<script>
    import Tinymce from "../../libs/Tinymce.svelte";
    import {getErrorMessage} from "./errorMessage";

    export let value;
    export let field;
    export let isCreateMode;
    export let schema;
    export let validationErrors;
    $: errorMessage = getErrorMessage(validationErrors, field.name);
    let additionalConfig = {
        readonly: field.readonly && !isCreateMode,
    };
</script>

<div class="mb-0">
    <Tinymce bind:value {additionalConfig} {schema}/>

    {#if errorMessage}
        <div class="invalid-feedback d-block">
            {errorMessage}
        </div>
    {/if}
</div>
