@lobehub/editor 3.7.0 → 3.9.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.
@@ -23,7 +23,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
23
23
  /* eslint-disable import/no-duplicates */
24
24
  /* eslint-disable unicorn/no-for-loop */
25
25
  import { $isTableSelection } from '@lexical/table';
26
- import { $getCharacterOffsets, $getNodeByKey, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, IS_CODE } from 'lexical';
26
+ import { $getCharacterOffsets, $getNodeByKey, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, IS_CODE, resetRandomKey } from 'lexical';
27
27
  import { $getRoot } from 'lexical';
28
28
  import { DataSource } from "../../../editor-kernel";
29
29
  import { INodeHelper } from "../../../editor-kernel/inode/helper";
@@ -75,6 +75,13 @@ var JSONDataSource = /*#__PURE__*/function (_DataSource) {
75
75
  }, function (state) {
76
76
  try {
77
77
  var root = $parseSerializedNodeImpl(dataObj.root, editor, true, state);
78
+ var maxId = -1;
79
+ Array.from(state._nodeMap.keys()).forEach(function (key) {
80
+ if (key === 'root') return;
81
+ maxId = Math.max(maxId, Number(key));
82
+ });
83
+ // make sure to reset random key to avoid id conflicts
84
+ resetRandomKey(maxId + 1);
78
85
  state._nodeMap.set(root.getKey(), root);
79
86
  } catch (error) {
80
87
  console.error(error);
@@ -8,13 +8,13 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
8
8
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
9
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
10
  /* eslint-disable @typescript-eslint/no-use-before-define */
11
+ import { $isListItemNode } from '@lexical/list';
11
12
  import { mergeRegister } from '@lexical/utils';
12
13
  import { $createParagraphNode, $getNodeByKey, $insertNodes, $isElementNode, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
13
14
  import { $closest } from "../../../editor-kernel";
14
15
  import { createDebugLogger } from "../../../utils/debug";
15
16
  import { $createDiffNode, DiffNode } from "../node/DiffNode";
16
17
  import { $cloneNode, $parseSerializedNodeImpl, charToId } from "../utils";
17
- import { $isListItemNode } from '@lexical/list';
18
18
  var logger = createDebugLogger('plugin', 'litexml');
19
19
 
20
20
  // Helpers to reduce duplication and improve readability
@@ -113,6 +113,22 @@ function finalizeModifyBlocks(modifyBlockNodes, diffNodeMap, editor) {
113
113
  * transitions where we want to show a modify diff.
114
114
  */
115
115
  function wrapBlockModify(oldBlock, editor, changeFn) {
116
+ if ($isListItemNode(oldBlock)) {
117
+ var _diffNode2 = $createDiffNode('listItemModify');
118
+ var p = $createParagraphNode();
119
+ oldBlock.getChildren().forEach(function (child) {
120
+ p.append($cloneNode(child, editor));
121
+ });
122
+ changeFn();
123
+ _diffNode2.append(p);
124
+ var pNew = $createParagraphNode();
125
+ oldBlock.getChildren().forEach(function (child) {
126
+ pNew.append(child);
127
+ });
128
+ _diffNode2.append(pNew);
129
+ oldBlock.append(_diffNode2);
130
+ return;
131
+ }
116
132
  var diffNode = $createDiffNode('modify');
117
133
  diffNode.append($cloneNode(oldBlock, editor));
118
134
  changeFn();
@@ -311,9 +327,9 @@ function handleRemove(editor, key, delay) {
311
327
  node.clear();
312
328
  node.append(diffNode);
313
329
  } else {
314
- var _diffNode2 = $createDiffNode('remove');
315
- _diffNode2.append($cloneNode(node, editor));
316
- node.replace(_diffNode2, false);
330
+ var _diffNode3 = $createDiffNode('remove');
331
+ _diffNode3.append($cloneNode(node, editor));
332
+ node.replace(_diffNode3, false);
317
333
  }
318
334
  } else {
319
335
  var oldBlock = $closest(node, function (node) {
@@ -432,9 +448,9 @@ function handleInsert(editor, payload, dataSource) {
432
448
  node.append(diffNode);
433
449
  referenceNode = referenceNode.insertAfter(node);
434
450
  } else {
435
- var _diffNode3 = $createDiffNode('add');
436
- _diffNode3.append(node);
437
- referenceNode = referenceNode.insertAfter(_diffNode3);
451
+ var _diffNode4 = $createDiffNode('add');
452
+ _diffNode4.append(node);
453
+ referenceNode = referenceNode.insertAfter(_diffNode4);
438
454
  }
439
455
  }
440
456
  });
@@ -4,5 +4,5 @@ import { createStaticStyles } from 'antd-style';
4
4
  export var styles = createStaticStyles(function (_ref) {
5
5
  var css = _ref.css,
6
6
  cssVar = _ref.cssVar;
7
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n .toolbar {\n position: absolute;\n z-index: 10;\n inset-block-end: 0;\n inset-inline-end: 8px;\n\n opacity: 0;\n }\n\n &:hover {\n .toolbar {\n opacity: 1;\n }\n }\n\n &[data-diff-type='add'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n }\n\n &[data-diff-type='remove'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n }\n\n\n &[data-diff-type='listItemRemove'] {\n display: inline-block;\n }\n\n &[data-diff-type='listItemRemove'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n\n &[data-diff-type='listItemModify'] {\n display: inline-block;\n\n p {\n display: block !important;\n }\n }\n\n &[data-diff-type='listItemModify'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n\n &[data-diff-type='modify'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n "])), cssVar.colorSuccess, cssVar.colorError, cssVar.colorTextQuaternary, cssVar.colorError, cssVar.colorTextQuaternary, cssVar.colorWarning, cssVar.colorTextQuaternary, cssVar.colorWarning, cssVar.colorTextQuaternary);
7
+ return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n .toolbar {\n position: absolute;\n z-index: 10;\n inset-block-end: 0;\n inset-inline-end: 8px;\n\n opacity: 0;\n }\n\n &:hover {\n .toolbar {\n opacity: 1;\n }\n }\n\n &[data-diff-type='add'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n }\n\n &[data-diff-type='remove'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n }\n\n &[data-diff-type='listItemRemove'] {\n display: inline-block;\n min-width: 100%;\n }\n\n &[data-diff-type='listItemRemove'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n\n &[data-diff-type='listItemModify'] {\n display: inline-block;\n min-width: 100%;\n\n p {\n display: block !important;\n }\n }\n\n &[data-diff-type='listItemModify'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n\n &[data-diff-type='modify'] .content {\n position: relative;\n margin-block-start: calc(var(--lobe-markdown-margin-multiple) * 0.5em);\n padding-inline-end: 4px;\n border-inline-end: 3px solid ", ";\n\n /* first child: original (deleted) */\n\n /* > *:first-child {} */\n\n /* visually indicate deletion with strike-through for text nodes */\n > *:first-child * {\n color: ", " !important;\n text-decoration: line-through !important;\n }\n\n /* second child: modified/new - normal appearance */\n > *:nth-child(2) {\n color: inherit;\n opacity: 1;\n }\n }\n "])), cssVar.colorSuccess, cssVar.colorError, cssVar.colorTextQuaternary, cssVar.colorError, cssVar.colorTextQuaternary, cssVar.colorWarning, cssVar.colorTextQuaternary, cssVar.colorWarning, cssVar.colorTextQuaternary);
8
8
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "3.7.0",
3
+ "version": "3.9.0",
4
4
  "description": "A powerful and extensible rich text editor built on Meta's Lexical framework, providing a modern editing experience with React integration.",
5
5
  "keywords": [
6
6
  "lobehub",