import {DecoratorListener} from "lexical/LexicalEditor";
import type {NodeKey} from "lexical/LexicalNode";
import {EditorContextToolbar, EditorContextToolbarDefinition} from "./toolbars";
+import {getLastSelection, setLastSelection} from "../../utils/selection";
export type SelectionChangeHandler = (selection: BaseSelection|null) => void;
}
protected triggerStateUpdate(update: EditorUiStateUpdate): void {
- const context = this.getContext();
- context.lastSelection = update.selection;
+ setLastSelection(update.editor, update.selection);
this.toolbar?.updateState(update);
this.updateContextToolbars(update);
for (const toolbar of this.activeContextToolbars) {
}
triggerStateRefresh(): void {
+ const editor = this.getContext().editor;
this.triggerStateUpdate({
- editor: this.getContext().editor,
- selection: this.getContext().lastSelection,
+ editor,
+ selection: getLastSelection(editor),
});
}