rich editor
This commit is contained in:
@@ -15,34 +15,14 @@
|
||||
$: errorMessage = getErrorMessage(validationErrors, field.name);
|
||||
let editor;
|
||||
|
||||
function insertMedia(e) {
|
||||
editor.insertMedia(e.detail);
|
||||
}
|
||||
|
||||
function onFilesInserted(e) {
|
||||
console.log(e.detail);
|
||||
const presetPath = e.detail.preset.path;
|
||||
|
||||
e.detail.files.map((aFile) => {
|
||||
let html = htmlurl(channel, record, presetPath);
|
||||
|
||||
editor.insertMedia({
|
||||
html: html,
|
||||
url: presetUrl(channel, aFile, presetPath),
|
||||
originalUrl: channel.filesUrl + "/" + aFile.path,
|
||||
file: aFile,
|
||||
});
|
||||
});
|
||||
editor.insertMedia(channel, e.detail.files, presetPath);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="mb-3">
|
||||
<RichEditorFiles
|
||||
{record}
|
||||
{field}
|
||||
{validationErrors}
|
||||
{onFilesInserted}
|
||||
on:editor-insert={insertMedia}
|
||||
<RichEditorFiles {record} {field} {validationErrors} {onFilesInserted}
|
||||
></RichEditorFiles>
|
||||
<Codemirror
|
||||
bind:this={editor}
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
import RichEditorFiles from "./RichEditorFiles.svelte";
|
||||
import { getErrorMessage } from "./errorMessage";
|
||||
import Trix from "../../libs/Trix.svelte";
|
||||
import { htmlurl } from "../../files/imageserver";
|
||||
import { getContext } from "svelte";
|
||||
|
||||
const channel = getContext("channel");
|
||||
export let value;
|
||||
export let field;
|
||||
export let record;
|
||||
@@ -12,19 +15,18 @@
|
||||
|
||||
$: errorMessage = getErrorMessage(validationErrors, field.name);
|
||||
|
||||
function insertMedia(e) {
|
||||
editor.insertMedia(e.detail);
|
||||
function onFilesInserted(e) {
|
||||
const presetPath = e.detail.preset.path;
|
||||
e.detail.files.map((aFile) => {
|
||||
const html = htmlurl(channel, aFile, presetPath);
|
||||
editor.insertMedia(html);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="mb-0">
|
||||
<Trix {field} bind:this={editor} bind:value></Trix>
|
||||
<RichEditorFiles
|
||||
{record}
|
||||
{field}
|
||||
{validationErrors}
|
||||
on:editor-insert={insertMedia}
|
||||
></RichEditorFiles>
|
||||
<RichEditorFiles {record} {field} {onFilesInserted}></RichEditorFiles>
|
||||
|
||||
{#if errorMessage}
|
||||
<div class="invalid-feedback d-block">
|
||||
|
||||
Reference in New Issue
Block a user