Create new EditorContent component
This commit is contained in:
+3
-13
@@ -1,6 +1,6 @@
|
||||
import {asClassComponent} from "svelte/legacy"
|
||||
import type {Writable} from "svelte/store"
|
||||
import {derived, readable} from "svelte/store"
|
||||
import {derived} from "svelte/store"
|
||||
import {Editor, SvelteNodeViewRenderer} from "svelte-tiptap"
|
||||
import {ctx} from "@welshman/lib"
|
||||
import type {StampedEvent} from "@welshman/util"
|
||||
@@ -44,10 +44,8 @@ export const makeEditor = ({
|
||||
submit: () => void
|
||||
uploading?: Writable<boolean>
|
||||
wordCount?: Writable<number>
|
||||
}) => {
|
||||
let setter: (editor: Editor) => void
|
||||
|
||||
const _editor = new Editor({
|
||||
}) =>
|
||||
new Editor({
|
||||
content,
|
||||
autofocus,
|
||||
extensions: [
|
||||
@@ -96,15 +94,7 @@ export const makeEditor = ({
|
||||
}),
|
||||
],
|
||||
onUpdate({editor}) {
|
||||
setter?.(editor)
|
||||
wordCount?.set(editor.storage.wordCount.words)
|
||||
charCount?.set(editor.storage.wordCount.chars)
|
||||
},
|
||||
})
|
||||
|
||||
return readable(_editor, set => {
|
||||
setter = set
|
||||
|
||||
return () => _editor.destroy()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user