-
|
So, I've extended a TextNode with a lang attribute: const DEFAULT_LANG = undefined;
const langState = createState('lang', {
parse: value => (typeof value === 'string' ? value : DEFAULT_LANG)
});
export class LangTextNode extends TextNode {
$config() {
return this.config('lang-text', {
extends: TextNode,
stateConfigs: [{flat: true, stateConfig: langState}]
});
}
setLang(lang) {
$setState(this, langState, lang);
}
getLang() {
return $getState(this, langState);
}
createDOM(config) {
...
}
updateDOM(prevNode, dom, config) {
...
}
}I also replaced a TextNode according to the docs: const editorConfig = {
...
nodes=[
// Don't forget to register your custom node separately!
LangTextNode,
{
replace: LangTextNode,
with: (node) => {
return $createLangTextNode(node.__text),;
},
withKlass: LangTextNode,
}
]
}And everything works as it should, except that when I remove formatting from a piece of text, the nodes don’t get merged as they used to. So my question is: why does this happen? Have I missed something? |
Beta Was this translation helpful? Give feedback.
Answered by
etrepum
Sep 23, 2025
Replies: 2 comments
-
|
You need to override isSimpleText to return true https://lexical.dev/docs/api/modules/lexical#issimpletext |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
DonTomato
-
|
It works, thanks a lot! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to override isSimpleText to return true https://lexical.dev/docs/api/modules/lexical#issimpletext