Skip to content

Commit

Permalink
feat: Expose getActiveEditor and getActiveEditorState (#5409)
Browse files Browse the repository at this point in the history
  • Loading branch information
yf-yang authored Jan 25, 2024
1 parent ba901cc commit e511326
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/lexical/flow/Lexical.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ declare export function $copyNode(
node: ElementNode,
offset: number,
): [ElementNode, ElementNode];
declare export function $getEditor(): LexicalEditor;

/**
* LexicalNormalization
Expand Down
8 changes: 8 additions & 0 deletions packages/lexical/src/LexicalUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1615,3 +1615,11 @@ export function $getAncestor<NodeType extends LexicalNode = LexicalNode>(
}
return predicate(parent) ? parent : null;
}

/**
* Utility function for accessing current active editor instance.
* @returns Current active editor
*/
export function $getEditor(): LexicalEditor {
return getActiveEditor();
}
1 change: 1 addition & 0 deletions packages/lexical/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export {
$applyNodeReplacement,
$copyNode,
$getAdjacentNode,
$getEditor,
$getNearestNodeFromDOMNode,
$getNearestRootOrShadowRoot,
$getNodeByKey,
Expand Down

2 comments on commit e511326

@vercel
Copy link

@vercel vercel bot commented on e511326 Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical – ./packages/lexical-website

lexical.dev
lexical-git-main-fbopensource.vercel.app
lexical-fbopensource.vercel.app
lexicaljs.org
lexicaljs.com
www.lexical.dev

@vercel
Copy link

@vercel vercel bot commented on e511326 Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical-playground – ./packages/lexical-playground

lexical-playground-git-main-fbopensource.vercel.app
lexical-playground.vercel.app
playground.lexical.dev
lexical-playground-fbopensource.vercel.app

Please sign in to comment.