-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: Error: $validatePoint: anchor point.offset > node.getTextContentSize() in StencilJS #7028
Description
After updating the lexical to the latest stable version 0.23.0, editor throws a error on typing more than one alphabet in the editor.
Lexical version:
"lexical": "0.23.0"
"@lexical/history": "0.23.0",
"@lexical/html": "0.23.0",
"@lexical/rich-text": "0.23.0",
"@lexical/utils": "0.23.0",
Framework
Stencil "^4.23.0"
Steps To Reproduce
- Load Editor in an Iframe
- Start typing more than one alphabet.
- Error displayed in the browser console.
index.js:5 Error: $validatePoint: anchor point.offset > node.getTextContentSize() (2 > 1)
at $validatePoint (lexical-adapter-4fa3a28c.js:7678:13)
at $internalResolveSelectionPoints (lexical-adapter-4fa3a28c.js:7561:5)
at $internalCreateRangeSelection (lexical-adapter-4fa3a28c.js:7660:35)
at $internalCreateSelection (lexical-adapter-4fa3a28c.js:7613:12)
at $beginUpdate (lexical-adapter-4fa3a28c.js:8668:41)
at updateEditor (lexical-adapter-4fa3a28c.js:8748:5)
at onInput (lexical-adapter-4fa3a28c.js:3067:3)
at HTMLDivElement. (lexical-adapter-4fa3a28c.js:3398:9)
Editor SetUp Class
import {
createEditor,
} from 'lexical';
initialConfig = {
namespace: 'Lexical',
// Register nodes specific for @lexical/rich-text
nodes: [],
onError: (error: Error) => {
throw error;
},
// theme: {
// // Adding styling to Quote node, see lexical-styles.css
// // quote: 'lexical__quote ', this is an example
// },
};
private createEditor(editableContainer: HTMLElement): void {
this.editor = createEditor(initialConfig);
this.editor.setRootElement(editableContainer);
mergeRegister(
registerRichText(this.editor),
registerHistory(this.editor, createEmptyHistoryState(), 300),
);
}
public async initialize(): Promise<void> {
// Creates iframe element with srcDoc
const iframeDocument = this.renderIframe();
iframeDocument.onload = () => {
const editableContainer = frameDocument.contentDocument?.querySelector('#lexical-editor') as HTMLElement;
if (editableContainer) {
this.createEditor(editableContainer);
} else {
// eslint-disable-next-line
console.error('Editable container not found in iframe');
}
};
}