feat: prevent command crash
This commit is contained in:
parent
5a333a06b9
commit
0165d73ce9
|
|
@ -75,9 +75,9 @@ export const BoldText: FC<{
|
|||
currentValue: string;
|
||||
}> = ({ editor }) => {
|
||||
const mark = () => {
|
||||
editor.commands.unsetUnderline();
|
||||
editor.commands.toggleBold();
|
||||
editor.commands.focus();
|
||||
editor?.commands?.unsetUnderline();
|
||||
editor?.commands?.toggleBold();
|
||||
editor?.commands?.focus();
|
||||
};
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export const Bullets: FC<{
|
|||
currentValue: string;
|
||||
}> = ({ editor }) => {
|
||||
const bullet = () => {
|
||||
editor.commands.toggleBulletList();
|
||||
editor?.commands?.toggleBulletList();
|
||||
};
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ const InterceptBoldShortcut = Extension.create({
|
|||
return {
|
||||
'Mod-b': () => {
|
||||
// For example, toggle bold while removing underline
|
||||
this.editor.commands.unsetUnderline();
|
||||
return this.editor.commands.toggleBold();
|
||||
this?.editor?.commands?.unsetUnderline();
|
||||
return this?.editor?.commands?.toggleBold();
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
@ -78,8 +78,8 @@ const InterceptUnderlineShortcut = Extension.create({
|
|||
return {
|
||||
'Mod-u': () => {
|
||||
// For example, toggle bold while removing underline
|
||||
this.editor.commands.unsetBold();
|
||||
return this.editor.commands.toggleUnderline();
|
||||
this?.editor?.commands?.unsetBold();
|
||||
return this?.editor?.commands?.toggleUnderline();
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
@ -505,8 +505,8 @@ export const Editor: FC<{
|
|||
|
||||
const addText = useCallback(
|
||||
(emoji: string) => {
|
||||
editorRef?.current?.editor.commands.insertContent(emoji);
|
||||
editorRef?.current?.editor.commands.focus();
|
||||
editorRef?.current?.editor?.commands?.insertContent(emoji);
|
||||
editorRef?.current?.editor?.commands?.focus();
|
||||
},
|
||||
[props.value, id]
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export const HeadingComponent: FC<{
|
|||
currentValue: string;
|
||||
}> = ({ editor }) => {
|
||||
const setHeading = (level: number) => () => {
|
||||
editor.commands.toggleHeading({ level })
|
||||
editor?.commands?.toggleHeading({ level })
|
||||
};
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ export const UText: FC<{
|
|||
currentValue: string;
|
||||
}> = ({ editor }) => {
|
||||
const mark = () => {
|
||||
editor.commands.unsetBold();
|
||||
editor.commands.toggleUnderline();
|
||||
editor.commands.focus();
|
||||
editor?.commands?.unsetBold();
|
||||
editor?.commands?.toggleUnderline();
|
||||
editor?.commands?.focus();
|
||||
};
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ export const SignatureBox: FC<{
|
|||
setShowModal(true);
|
||||
}, [showModal]);
|
||||
const appendValue = (val: string) => {
|
||||
editor?.commands.insertContent("\n\n" + val);
|
||||
editor?.commands.focus();
|
||||
editor?.commands?.insertContent("\n\n" + val);
|
||||
editor?.commands?.focus();
|
||||
setShowModal(false);
|
||||
};
|
||||
return (
|
||||
|
|
|
|||
Loading…
Reference in New Issue