Skip to content
This repository was archived by the owner on May 5, 2021. It is now read-only.

Commit 7db849a

Browse files
Zyntondmo-odoo
authored andcommitted
[FIX] Link: prevent the toolbar from crashing on click in empty element
Clicking in an empty element made the toolbar crash.
1 parent db7e798 commit 7db849a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/plugin-link/src/LinkButtons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const LinkButton: Button = {
1010
selected: (editor: JWEditor): boolean => {
1111
const range = editor.selection.range;
1212
const node = range.start.nextSibling() || range.start.previousSibling();
13-
return node.is(InlineNode) && !!node.modifiers.find(LinkFormat);
13+
return node && node.is(InlineNode) && !!node.modifiers.find(LinkFormat);
1414
},
1515
};
1616

@@ -21,6 +21,6 @@ export const UnlinkButton: Button = {
2121
enabled: (editor: JWEditor): boolean => {
2222
const range = editor.selection.range;
2323
const node = range.start.nextSibling() || range.start.previousSibling();
24-
return node.is(InlineNode) && !!node.modifiers.find(LinkFormat);
24+
return node && node.is(InlineNode) && !!node.modifiers.find(LinkFormat);
2525
},
2626
};

0 commit comments

Comments
 (0)