@lobehub/editor 3.8.0 → 3.9.1
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);
|
package/package.json
CHANGED
package/scripts/patch-lexical.js
CHANGED
|
@@ -4,7 +4,7 @@ const path = require('node:path');
|
|
|
4
4
|
|
|
5
5
|
const sourceDir = path.resolve(__dirname, '../src/editor-kernel/lexical');
|
|
6
6
|
const esSourceDir = path.resolve(__dirname, '../es/editor-kernel/lexical');
|
|
7
|
-
const targetDir = path.resolve(
|
|
7
|
+
const targetDir = path.dirname(require.resolve('lexical'));
|
|
8
8
|
|
|
9
9
|
if (!fs.existsSync(targetDir)) {
|
|
10
10
|
console.warn('node_modules/lexical not found, skipping patch.');
|