lexical 0.38.3-nightly.20251103.0 → 0.38.3-nightly.20251104.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Lexical.dev.js CHANGED
@@ -1328,7 +1328,7 @@ function $normalizePoint(point) {
1328
1328
 
1329
1329
  let subTreeTextContent = '';
1330
1330
  let subTreeTextFormat = null;
1331
- let subTreeTextStyle = '';
1331
+ let subTreeTextStyle = null;
1332
1332
  let editorTextContent = '';
1333
1333
  let activeEditorConfig;
1334
1334
  let activeEditor$1;
@@ -1504,8 +1504,6 @@ function $createChildren(children, element, _startIndex, endIndex, slot) {
1504
1504
  if (node !== null && $isTextNode(node)) {
1505
1505
  if (subTreeTextFormat === null) {
1506
1506
  subTreeTextFormat = node.getFormat();
1507
- }
1508
- if (subTreeTextStyle === '') {
1509
1507
  subTreeTextStyle = node.getStyle();
1510
1508
  }
1511
1509
  }
@@ -1545,13 +1543,13 @@ function reconcileTextFormat(element) {
1545
1543
  }
1546
1544
  }
1547
1545
  function reconcileTextStyle(element) {
1548
- if (subTreeTextStyle !== '' && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) {
1546
+ if (subTreeTextStyle != null && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) {
1549
1547
  element.setTextStyle(subTreeTextStyle);
1550
1548
  }
1551
1549
  }
1552
1550
  function $reconcileChildrenWithDirection(prevElement, nextElement, dom) {
1553
1551
  subTreeTextFormat = null;
1554
- subTreeTextStyle = '';
1552
+ subTreeTextStyle = null;
1555
1553
  $reconcileChildren(prevElement, nextElement, nextElement.getDOMSlot(dom));
1556
1554
  reconcileTextFormat(nextElement);
1557
1555
  reconcileTextStyle(nextElement);
@@ -1601,8 +1599,6 @@ function $reconcileChildren(prevElement, nextElement, slot) {
1601
1599
  if ($isTextNode(nextChildNode)) {
1602
1600
  if (subTreeTextFormat === null) {
1603
1601
  subTreeTextFormat = nextChildNode.getFormat();
1604
- }
1605
- if (subTreeTextStyle === '') {
1606
1602
  subTreeTextStyle = nextChildNode.getStyle();
1607
1603
  }
1608
1604
  }
@@ -1810,8 +1806,6 @@ function $reconcileNodeChildren(nextElement, prevChildren, nextChildren, prevChi
1810
1806
  if (node !== null && $isTextNode(node)) {
1811
1807
  if (subTreeTextFormat === null) {
1812
1808
  subTreeTextFormat = node.getFormat();
1813
- }
1814
- if (subTreeTextStyle === '') {
1815
1809
  subTreeTextStyle = node.getStyle();
1816
1810
  }
1817
1811
  }
@@ -9491,11 +9485,15 @@ class ElementNode extends LexicalNode {
9491
9485
  };
9492
9486
  const textFormat = this.getTextFormat();
9493
9487
  const textStyle = this.getTextStyle();
9494
- if (textFormat !== 0) {
9495
- json.textFormat = textFormat;
9496
- }
9497
- if (textStyle !== '') {
9498
- json.textStyle = textStyle;
9488
+ // Only persist for cases when there are no TextNode children from which
9489
+ // these would be set on reconcile (#7968)
9490
+ if ((textFormat !== 0 || textStyle !== '') && !$isRootOrShadowRoot(this) && !this.getChildren().some($isTextNode)) {
9491
+ if (textFormat !== 0) {
9492
+ json.textFormat = textFormat;
9493
+ }
9494
+ if (textStyle !== '') {
9495
+ json.textStyle = textStyle;
9496
+ }
9499
9497
  }
9500
9498
  return json;
9501
9499
  }
@@ -9892,12 +9890,20 @@ class ParagraphNode extends ElementNode {
9892
9890
  return $createParagraphNode().updateFromJSON(serializedNode);
9893
9891
  }
9894
9892
  exportJSON() {
9895
- return {
9896
- ...super.exportJSON(),
9897
- // These are included explicitly for backwards compatibility
9898
- textFormat: this.getTextFormat(),
9899
- textStyle: this.getTextStyle()
9900
- };
9893
+ const json = super.exportJSON();
9894
+ // Provide backwards compatible values, see #7971
9895
+ if (json.textFormat === undefined || json.textStyle === undefined) {
9896
+ // Compute the same value that the reconciler would
9897
+ const firstTextNode = this.getChildren().find($isTextNode);
9898
+ if (firstTextNode) {
9899
+ json.textFormat = firstTextNode.getFormat();
9900
+ json.textStyle = firstTextNode.getStyle();
9901
+ } else {
9902
+ json.textFormat = this.getTextFormat();
9903
+ json.textStyle = this.getTextStyle();
9904
+ }
9905
+ }
9906
+ return json;
9901
9907
  }
9902
9908
 
9903
9909
  // Mutation
@@ -10859,7 +10865,7 @@ class LexicalEditor {
10859
10865
  };
10860
10866
  }
10861
10867
  }
10862
- LexicalEditor.version = "0.38.3-nightly.20251103.0+dev.cjs";
10868
+ LexicalEditor.version = "0.38.3-nightly.20251104.0+dev.cjs";
10863
10869
 
10864
10870
  let pendingNodeToClone = null;
10865
10871
  function setPendingNodeToClone(pendingNode) {
package/Lexical.dev.mjs CHANGED
@@ -1326,7 +1326,7 @@ function $normalizePoint(point) {
1326
1326
 
1327
1327
  let subTreeTextContent = '';
1328
1328
  let subTreeTextFormat = null;
1329
- let subTreeTextStyle = '';
1329
+ let subTreeTextStyle = null;
1330
1330
  let editorTextContent = '';
1331
1331
  let activeEditorConfig;
1332
1332
  let activeEditor$1;
@@ -1502,8 +1502,6 @@ function $createChildren(children, element, _startIndex, endIndex, slot) {
1502
1502
  if (node !== null && $isTextNode(node)) {
1503
1503
  if (subTreeTextFormat === null) {
1504
1504
  subTreeTextFormat = node.getFormat();
1505
- }
1506
- if (subTreeTextStyle === '') {
1507
1505
  subTreeTextStyle = node.getStyle();
1508
1506
  }
1509
1507
  }
@@ -1543,13 +1541,13 @@ function reconcileTextFormat(element) {
1543
1541
  }
1544
1542
  }
1545
1543
  function reconcileTextStyle(element) {
1546
- if (subTreeTextStyle !== '' && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) {
1544
+ if (subTreeTextStyle != null && subTreeTextStyle !== element.__textStyle && !activeEditorStateReadOnly) {
1547
1545
  element.setTextStyle(subTreeTextStyle);
1548
1546
  }
1549
1547
  }
1550
1548
  function $reconcileChildrenWithDirection(prevElement, nextElement, dom) {
1551
1549
  subTreeTextFormat = null;
1552
- subTreeTextStyle = '';
1550
+ subTreeTextStyle = null;
1553
1551
  $reconcileChildren(prevElement, nextElement, nextElement.getDOMSlot(dom));
1554
1552
  reconcileTextFormat(nextElement);
1555
1553
  reconcileTextStyle(nextElement);
@@ -1599,8 +1597,6 @@ function $reconcileChildren(prevElement, nextElement, slot) {
1599
1597
  if ($isTextNode(nextChildNode)) {
1600
1598
  if (subTreeTextFormat === null) {
1601
1599
  subTreeTextFormat = nextChildNode.getFormat();
1602
- }
1603
- if (subTreeTextStyle === '') {
1604
1600
  subTreeTextStyle = nextChildNode.getStyle();
1605
1601
  }
1606
1602
  }
@@ -1808,8 +1804,6 @@ function $reconcileNodeChildren(nextElement, prevChildren, nextChildren, prevChi
1808
1804
  if (node !== null && $isTextNode(node)) {
1809
1805
  if (subTreeTextFormat === null) {
1810
1806
  subTreeTextFormat = node.getFormat();
1811
- }
1812
- if (subTreeTextStyle === '') {
1813
1807
  subTreeTextStyle = node.getStyle();
1814
1808
  }
1815
1809
  }
@@ -9489,11 +9483,15 @@ class ElementNode extends LexicalNode {
9489
9483
  };
9490
9484
  const textFormat = this.getTextFormat();
9491
9485
  const textStyle = this.getTextStyle();
9492
- if (textFormat !== 0) {
9493
- json.textFormat = textFormat;
9494
- }
9495
- if (textStyle !== '') {
9496
- json.textStyle = textStyle;
9486
+ // Only persist for cases when there are no TextNode children from which
9487
+ // these would be set on reconcile (#7968)
9488
+ if ((textFormat !== 0 || textStyle !== '') && !$isRootOrShadowRoot(this) && !this.getChildren().some($isTextNode)) {
9489
+ if (textFormat !== 0) {
9490
+ json.textFormat = textFormat;
9491
+ }
9492
+ if (textStyle !== '') {
9493
+ json.textStyle = textStyle;
9494
+ }
9497
9495
  }
9498
9496
  return json;
9499
9497
  }
@@ -9890,12 +9888,20 @@ class ParagraphNode extends ElementNode {
9890
9888
  return $createParagraphNode().updateFromJSON(serializedNode);
9891
9889
  }
9892
9890
  exportJSON() {
9893
- return {
9894
- ...super.exportJSON(),
9895
- // These are included explicitly for backwards compatibility
9896
- textFormat: this.getTextFormat(),
9897
- textStyle: this.getTextStyle()
9898
- };
9891
+ const json = super.exportJSON();
9892
+ // Provide backwards compatible values, see #7971
9893
+ if (json.textFormat === undefined || json.textStyle === undefined) {
9894
+ // Compute the same value that the reconciler would
9895
+ const firstTextNode = this.getChildren().find($isTextNode);
9896
+ if (firstTextNode) {
9897
+ json.textFormat = firstTextNode.getFormat();
9898
+ json.textStyle = firstTextNode.getStyle();
9899
+ } else {
9900
+ json.textFormat = this.getTextFormat();
9901
+ json.textStyle = this.getTextStyle();
9902
+ }
9903
+ }
9904
+ return json;
9899
9905
  }
9900
9906
 
9901
9907
  // Mutation
@@ -10857,7 +10863,7 @@ class LexicalEditor {
10857
10863
  };
10858
10864
  }
10859
10865
  }
10860
- LexicalEditor.version = "0.38.3-nightly.20251103.0+dev.esm";
10866
+ LexicalEditor.version = "0.38.3-nightly.20251104.0+dev.esm";
10861
10867
 
10862
10868
  let pendingNodeToClone = null;
10863
10869
  function setPendingNodeToClone(pendingNode) {