diff --git a/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts b/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts index ec6c540dac..1b084d1ac5 100644 --- a/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts +++ b/packages/editor/src/core/extensions/custom-link/helpers/clickHandler.ts @@ -18,9 +18,9 @@ export function clickHandler(options: ClickHandlerOptions): Plugin { let a = event.target as HTMLElement; const els = []; - while (a.nodeName !== "DIV") { + while (a?.nodeName !== "DIV") { els.push(a); - a = a.parentNode as HTMLElement; + a = a?.parentNode as HTMLElement; } if (!els.find((value) => value.nodeName === "A")) { diff --git a/packages/editor/src/core/extensions/slash-commands.tsx b/packages/editor/src/core/extensions/slash-commands.tsx index a61198db2b..78aa379576 100644 --- a/packages/editor/src/core/extensions/slash-commands.tsx +++ b/packages/editor/src/core/extensions/slash-commands.tsx @@ -63,7 +63,7 @@ const Command = Extension.create({ const { selection } = editor.state; const parentNode = selection.$from.node(selection.$from.depth); - const blockType = parentNode.type.name; + const blockType = parentNode?.type?.name; if (blockType === "codeBlock") { return false; diff --git a/yarn.lock b/yarn.lock index cc59ff6ff5..cec3a100ba 100644 --- a/yarn.lock +++ b/yarn.lock @@ -13146,4 +13146,4 @@ zeed-dom@^0.10.9: zxcvbn@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/zxcvbn/-/zxcvbn-4.4.2.tgz#28ec17cf09743edcab056ddd8b1b06262cc73c30" - integrity sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ== + integrity sha512-Bq0B+ixT/DMyG8kgX2xWcI5jUvCwqrMxSFam7m0lAf78nf04hv6lNCsyLYdyYTrCVMqNDY/206K7eExYCeSyUQ== \ No newline at end of file