2023-10-23 18:05:06 +03:00
|
|
|
<script>
|
2026-05-14 22:49:47 +03:00
|
|
|
import { getContext } from "svelte";
|
|
|
|
|
import { htmlurl, presetUrl } from "../../files/imageserver";
|
2023-10-23 18:05:06 +03:00
|
|
|
import Codemirror from "../../libs/CodemirrorMarkdown.svelte";
|
|
|
|
|
import { getErrorMessage } from "./errorMessage";
|
2024-09-07 15:31:56 +03:00
|
|
|
import RichEditorFiles from "./RichEditorFiles.svelte";
|
2026-05-14 22:49:47 +03:00
|
|
|
const channel = getContext("channel");
|
2023-10-23 18:05:06 +03:00
|
|
|
export let value;
|
|
|
|
|
export let field;
|
2026-05-14 22:49:47 +03:00
|
|
|
|
2024-09-07 15:31:56 +03:00
|
|
|
export let record;
|
2023-10-23 18:05:06 +03:00
|
|
|
export let isCreateMode;
|
|
|
|
|
// export let id;
|
|
|
|
|
export let validationErrors;
|
|
|
|
|
$: errorMessage = getErrorMessage(validationErrors, field.name);
|
2024-09-07 15:31:56 +03:00
|
|
|
let editor;
|
|
|
|
|
|
2026-05-14 22:49:47 +03:00
|
|
|
function onFilesInserted(e) {
|
|
|
|
|
const presetPath = e.detail.preset.path;
|
2026-05-14 23:10:07 +03:00
|
|
|
editor.insertMedia(channel, e.detail.files, presetPath);
|
2026-05-14 22:49:47 +03:00
|
|
|
}
|
2023-10-23 18:05:06 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<div class="mb-3">
|
2026-05-14 23:10:07 +03:00
|
|
|
<RichEditorFiles {record} {field} {validationErrors} {onFilesInserted}
|
2026-05-14 19:24:25 +03:00
|
|
|
></RichEditorFiles>
|
2026-05-14 22:49:47 +03:00
|
|
|
<Codemirror
|
|
|
|
|
bind:this={editor}
|
|
|
|
|
bind:value
|
|
|
|
|
editable={!field.readonly || isCreateMode}
|
|
|
|
|
/>
|
|
|
|
|
|
2023-10-23 18:05:06 +03:00
|
|
|
{#if errorMessage}
|
|
|
|
|
<div class="invalid-feedback d-block">
|
|
|
|
|
{errorMessage}
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|