@lobehub/editor 1.10.0 → 1.11.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.
@@ -77,7 +77,9 @@ function updateCodeGutter(node, editor) {
77
77
  // in both cases we'll rerun whole reformatting over CodeNode, which is redundant.
78
78
  // Especially when pasting code into CodeBlock.
79
79
 
80
+ var MAX_CONCURRENT_HIGHLIGHTING = 2;
80
81
  var nodesCurrentlyHighlighting = new Set();
82
+ var waitingNodesCurrentlyHighlighting = new Set();
81
83
  function codeNodeTransform(node, editor, tokenizer) {
82
84
  var nodeKey = node.getKey();
83
85
 
@@ -118,6 +120,10 @@ function codeNodeTransform(node, editor, tokenizer) {
118
120
  if (nodesCurrentlyHighlighting.has(nodeKey)) {
119
121
  return;
120
122
  }
123
+ if (nodesCurrentlyHighlighting.size > MAX_CONCURRENT_HIGHLIGHTING) {
124
+ waitingNodesCurrentlyHighlighting.add(nodeKey);
125
+ return;
126
+ }
121
127
  nodesCurrentlyHighlighting.add(nodeKey);
122
128
 
123
129
  // Using nested update call to pass `skipTransforms` since we don't want
@@ -146,6 +152,16 @@ function codeNodeTransform(node, editor, tokenizer) {
146
152
  }, {
147
153
  onUpdate: function onUpdate() {
148
154
  nodesCurrentlyHighlighting.delete(nodeKey);
155
+ if (nodesCurrentlyHighlighting.size < MAX_CONCURRENT_HIGHLIGHTING && waitingNodesCurrentlyHighlighting.size) {
156
+ var next = waitingNodesCurrentlyHighlighting.values().next().value;
157
+ if (!next) return;
158
+ waitingNodesCurrentlyHighlighting.delete(next);
159
+ requestAnimationFrame(function () {
160
+ editor.read(function () {
161
+ codeNodeTransform($getNodeByKey(next), editor, tokenizer);
162
+ });
163
+ });
164
+ }
149
165
  },
150
166
  skipTransforms: true
151
167
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.10.0",
3
+ "version": "1.11.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",