Skip to content

Commit

Permalink
fix(@lexical/devtools): Fixed work of the $isElementNode wrapper in w…
Browse files Browse the repository at this point in the history
…ebsites that rely on "babelHelpers.inheritsLoose"
  • Loading branch information
StyleT committed Apr 23, 2024
1 parent 25b3579 commit 3fdb8f2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/lexical-devtools/src/lexicalForExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,25 @@ export function $getSelection(): null | lexical.BaseSelection {
export function $isElementNode(
node: lexical.LexicalNode | null | undefined,
): node is lexical.ElementNode {
if (node == null) {
return false;
}

const editor = getActiveEditor();
const ElementNode = Object.getPrototypeOf(
editor._nodes.get('paragraph')!.klass,
);
const ParagraphNode = editor._nodes.get('paragraph')!.klass;
const ElementNode = Object.getPrototypeOf(ParagraphNode.prototype);

return node instanceof ElementNode;
// eslint-disable-next-line no-prototype-builtins
return ElementNode.isPrototypeOf(node);
}

export function $isTextNode(
node: lexical.LexicalNode | null | undefined,
): node is lexical.TextNode {
if (node == null) {
return false;
}

const editor = getActiveEditor();
const TextNode = editor._nodes.get('text')!.klass;

Expand Down

0 comments on commit 3fdb8f2

Please sign in to comment.