Skip to content

Commit

Permalink
Update lexical
Browse files Browse the repository at this point in the history
  • Loading branch information
aquarius-wing committed May 15, 2024
1 parent cb5f962 commit 5395482
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 16 deletions.
8 changes: 8 additions & 0 deletions packages/lexical/dist/LexicalNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ export declare class LexicalNode {
*
* */
updateDOM(_prevNode: unknown, _dom: HTMLElement, _config: EditorConfig): boolean;
/**
* Called when a node changes and should update the DOM properties
* will not call createDOM.
* @param _prevNode
* @param _dom
* @param _config
*/
updateDOMProperties(_prevNode: unknown, _dom: HTMLElement, _config: EditorConfig): void;
/**
* Controls how the this node is serialized to HTML. This is important for
* copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces,
Expand Down
13 changes: 13 additions & 0 deletions packages/lexical/npm/Lexical.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,8 @@ function reconcileNode(key, parentDOM) {
setMutatedNode(mutatedNodes, activeEditorNodes, activeMutationListeners, nextNode, 'updated');
}

// Only update node properties, not replace them
nextNode.updateDOMProperties(prevNode, dom, activeEditorConfig);
// Update node. If it returns true, we need to unmount and re-create the node
if (nextNode.updateDOM(prevNode, dom, activeEditorConfig)) {
const replacementDOM = createNode(key, null, null);
Expand Down Expand Up @@ -3845,6 +3847,17 @@ class LexicalNode {
}
}

/**
* Called when a node changes and should update the DOM properties
* will not call createDOM.
* @param _prevNode
* @param _dom
* @param _config
*/
updateDOMProperties(_prevNode, _dom, _config) {
//
}

/**
* Controls how the this node is serialized to HTML. This is important for
* copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces,
Expand Down
13 changes: 13 additions & 0 deletions packages/lexical/npm/Lexical.dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2083,6 +2083,8 @@ function reconcileNode(key, parentDOM) {
setMutatedNode(mutatedNodes, activeEditorNodes, activeMutationListeners, nextNode, 'updated');
}

// Only update node properties, not replace them
nextNode.updateDOMProperties(prevNode, dom, activeEditorConfig);
// Update node. If it returns true, we need to unmount and re-create the node
if (nextNode.updateDOM(prevNode, dom, activeEditorConfig)) {
const replacementDOM = createNode(key, null, null);
Expand Down Expand Up @@ -3843,6 +3845,17 @@ class LexicalNode {
}
}

/**
* Called when a node changes and should update the DOM properties
* will not call createDOM.
* @param _prevNode
* @param _dom
* @param _config
*/
updateDOMProperties(_prevNode, _dom, _config) {
//
}

/**
* Controls how the this node is serialized to HTML. This is important for
* copy and paste between Lexical and non-Lexical editors, or Lexical editors with different namespaces,
Expand Down
Loading

0 comments on commit 5395482

Please sign in to comment.