fix crash in ff

This commit is contained in:
Anton Tranelis 2025-12-03 21:13:08 +01:00
parent e375553b3f
commit c57013b930
2 changed files with 8 additions and 8 deletions

View File

@ -98,7 +98,7 @@ export function RichTextEditor({
className={`editor-wrapper tw:border-base-content/20 tw:rounded-box tw:border tw:flex tw:flex-col tw:flex-1 tw:min-h-0`}
>
<>
{showMenu ? <TextEditorMenu editor={editor} /> : null}
{showMenu && editor ? <TextEditorMenu editor={editor} /> : null}
<EditorContent editor={editor} />
</>
</div>

View File

@ -16,14 +16,14 @@ export const TextEditorMenu = ({ editor }: { editor: Editor }) => {
selector: (ctx) => {
return {
isBold: ctx.editor.isActive('bold'),
canBold: ctx.editor.can().chain().focus().toggleBold().run(),
canBold: ctx.editor.can().toggleBold(),
isItalic: ctx.editor.isActive('italic'),
canItalic: ctx.editor.can().chain().focus().toggleItalic().run(),
canItalic: ctx.editor.can().toggleItalic(),
isStrike: ctx.editor.isActive('strike'),
canStrike: ctx.editor.can().chain().focus().toggleStrike().run(),
canStrike: ctx.editor.can().toggleStrike(),
isCode: ctx.editor.isActive('code'),
canCode: ctx.editor.can().chain().focus().toggleCode().run(),
canClearMarks: ctx.editor.can().chain().focus().unsetAllMarks().run(),
canCode: ctx.editor.can().toggleCode(),
canClearMarks: ctx.editor.can().unsetAllMarks(),
isParagraph: ctx.editor.isActive('paragraph'),
isHeading1: ctx.editor.isActive('heading', { level: 1 }),
isHeading2: ctx.editor.isActive('heading', { level: 2 }),
@ -36,8 +36,8 @@ export const TextEditorMenu = ({ editor }: { editor: Editor }) => {
isOrderedList: ctx.editor.isActive('orderedList'),
isCodeBlock: ctx.editor.isActive('codeBlock'),
isBlockquote: ctx.editor.isActive('blockquote'),
canUndo: ctx.editor.can().chain().focus().undo().run(),
canRedo: ctx.editor.can().chain().focus().redo().run(),
canUndo: ctx.editor.can().undo(),
canRedo: ctx.editor.can().redo(),
}
},
})