forked from coracle/flotilla
Clean up drafts implementation (#164)
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user