@lobehub/editor 3.4.0 → 3.4.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.
@@ -25,7 +25,7 @@ import { registerDragonSupport } from '@lexical/dragon';
25
25
  import { registerHistory } from '@lexical/history';
26
26
  import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode, registerRichText } from '@lexical/rich-text';
27
27
  import { CAN_USE_DOM } from '@lexical/utils';
28
- import { $createLineBreakNode, $createParagraphNode, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_HIGH, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, ParagraphNode, TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical';
28
+ import { $createLineBreakNode, $createParagraphNode, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_CRITICAL, COMMAND_PRIORITY_HIGH, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND, PASTE_COMMAND, ParagraphNode, TEXT_TYPE_TO_FORMAT, TextNode } from 'lexical';
29
29
  import { noop } from "../../../editor-kernel";
30
30
  import { INodeHelper } from "../../../editor-kernel/inode/helper";
31
31
  import { KernelPlugin } from "../../../editor-kernel/plugin";
@@ -325,7 +325,15 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
325
325
  }, {
326
326
  key: "onInit",
327
327
  value: function onInit(editor) {
328
- var _this$config2;
328
+ var _this2 = this,
329
+ _this$config2;
330
+ this.register(this.kernel.registerHighCommand(PASTE_COMMAND, function (event) {
331
+ if (!(event instanceof ClipboardEvent)) return false;
332
+ var clipboardData = event.clipboardData;
333
+ if (!clipboardData) return false;
334
+ _this2.kernel.emit('onPaste', event);
335
+ return false;
336
+ }, COMMAND_PRIORITY_CRITICAL));
329
337
  this.registerClears(registerRichText(editor), CAN_USE_DOM ? registerDragonSupport(editor) : noop, registerHistory(editor, this.kernel.getHistoryState(), 300), registerHeaderBackspace(editor), registerRichKeydown(editor, this.kernel, {
330
338
  enableHotkey: (_this$config2 = this.config) === null || _this$config2 === void 0 ? void 0 : _this$config2.enableHotkey
331
339
  }), registerCommands(editor), registerBreakLineClick(editor), registerCursorNode(editor), registerLastElement(editor),
@@ -21,19 +21,21 @@ export function $parseSerializedNodeImpl(serializedNode, editor) {
21
21
  }
22
22
  var children = serializedNode.children;
23
23
  if ($isElementNode(node) && Array.isArray(children)) {
24
+ var childNodes = [];
24
25
  var _iterator = _createForOfIteratorHelper(children),
25
26
  _step;
26
27
  try {
27
28
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
28
29
  var serializedJSONChildNode = _step.value;
29
30
  var childNode = $parseSerializedNodeImpl(serializedJSONChildNode, editor, keepId, state);
30
- node.append(childNode);
31
+ childNodes.push(childNode);
31
32
  }
32
33
  } catch (err) {
33
34
  _iterator.e(err);
34
35
  } finally {
35
36
  _iterator.f();
36
37
  }
38
+ node.append.apply(node, childNodes);
37
39
  }
38
40
  return node;
39
41
  }
@@ -45,6 +45,10 @@ export interface IKernelEventMap {
45
45
  historyState: HistoryStateEntry | null;
46
46
  markdown: string;
47
47
  }) => void;
48
+ /**
49
+ * handle paste event
50
+ */
51
+ onPaste: (event: ClipboardEvent) => void;
48
52
  }
49
53
  /**
50
54
  * External API
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
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",