Clean up drafts implementation (#164)

This commit is contained in:
2026-04-07 13:06:29 +00:00
parent 30c2a6ef79
commit 17fb4e780b
13 changed files with 173 additions and 162 deletions
+3 -2
View File
@@ -4,9 +4,10 @@
type Props = {
editor: Promise<Editor>
autofocus?: boolean
}
const {editor}: Props = $props()
const {editor, autofocus}: Props = $props()
let element: HTMLElement
@@ -16,7 +17,7 @@
element?.append(ed.options.element)
}
if ((ed as any)._shouldAutofocus) {
if (autofocus) {
const hasContent = ed.getText().trim().length > 0
requestAnimationFrame(() => {
+1 -6
View File
@@ -25,7 +25,6 @@ import {pushToast} from "@app/util/toast"
export const makeEditor = async ({
encryptFiles = false,
aggressive = false,
autofocus = false,
charCount,
content = "",
onChange,
@@ -37,10 +36,9 @@ export const makeEditor = async ({
}: {
encryptFiles?: boolean
aggressive?: boolean
autofocus?: boolean
charCount?: Writable<number>
content?: string | object
onChange?: (json: unknown) => void
onChange?: (json: object) => void
placeholder?: string
url?: string
submit: () => void
@@ -86,7 +84,6 @@ export const makeEditor = async ({
const ed = new Editor({
content: typeof content === "string" ? escapeHtml(content) : content,
autofocus: false,
editorProps,
element: document.createElement("div"),
extensions: [
@@ -148,7 +145,5 @@ export const makeEditor = async ({
},
})
;(ed as any)._shouldAutofocus = autofocus
return ed
}