@lobehub/editor 3.11.0 → 3.12.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.
@@ -6,6 +6,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
  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; }
7
7
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ import { LOBE_THEME_APP_ID } from '@lobehub/ui';
9
10
  import { useMemo } from 'react';
10
11
  import { useLexicalComposerContext } from "./react-context";
11
12
  export var useAnchor = function useAnchor() {
@@ -20,7 +21,7 @@ export var useAnchor = function useAnchor() {
20
21
  var anchor = root ? root.parentElement : null;
21
22
  if (anchor) return anchor;
22
23
  // Fallback to .ant-app if exists, otherwise document.body
23
- var antApp = document.querySelector('.ant-app');
24
- return antApp || document.body;
24
+ var app = document.querySelector("#".concat(LOBE_THEME_APP_ID));
25
+ return app || document.body;
25
26
  }, [editor]);
26
27
  };
package/es/index.d.ts CHANGED
@@ -20,6 +20,7 @@ export * from './plugins/slash';
20
20
  export * from './plugins/table';
21
21
  export * from './plugins/toolbar';
22
22
  export * from './plugins/upload';
23
+ export * from './plugins/virtual-block';
23
24
  export type { IEditor } from './types';
24
25
  export * from './types/hotkey';
25
26
  export { getHotkeyById } from './utils/hotkey/registerHotkey';
package/es/index.js CHANGED
@@ -20,6 +20,7 @@ export * from "./plugins/slash";
20
20
  export * from "./plugins/table";
21
21
  export * from "./plugins/toolbar";
22
22
  export * from "./plugins/upload";
23
+ export * from "./plugins/virtual-block";
23
24
  // Hotkey utilities
24
25
  export * from "./types/hotkey";
25
26
  export { getHotkeyById } from "./utils/hotkey/registerHotkey";
@@ -0,0 +1,2 @@
1
+ export * from './plugin';
2
+ export * from './react';
@@ -0,0 +1,2 @@
1
+ export * from "./plugin";
2
+ export * from "./react";
@@ -0,0 +1,5 @@
1
+ import { IEditorPluginConstructor } from "../../../types";
2
+ export interface VirtualBlockPluginOptions {
3
+ theme?: string;
4
+ }
5
+ export declare const VirtualBlockPlugin: IEditorPluginConstructor<VirtualBlockPluginOptions>;
@@ -0,0 +1,41 @@
1
+ var _class;
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
4
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
5
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
6
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
7
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
10
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
11
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
15
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ import { KernelPlugin } from "../../../editor-kernel/plugin";
17
+ import { registerRichKeydown } from "./register";
18
+
19
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
20
+
21
+ export var VirtualBlockPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
22
+ _inherits(VirtualBlockPlugin, _KernelPlugin);
23
+ var _super = _createSuper(VirtualBlockPlugin);
24
+ function VirtualBlockPlugin(kernel, config) {
25
+ var _this;
26
+ _classCallCheck(this, VirtualBlockPlugin);
27
+ _this = _super.call(this);
28
+ _this.kernel = kernel;
29
+ kernel.registerThemes({
30
+ virtualBlock: (config === null || config === void 0 ? void 0 : config.theme) || ''
31
+ });
32
+ return _this;
33
+ }
34
+ _createClass(VirtualBlockPlugin, [{
35
+ key: "onInit",
36
+ value: function onInit(editor) {
37
+ this.register(registerRichKeydown(editor, this.kernel));
38
+ }
39
+ }]);
40
+ return VirtualBlockPlugin;
41
+ }(KernelPlugin), _defineProperty(_class, "pluginName", 'VirtualBlockPlugin'), _class);
@@ -0,0 +1,6 @@
1
+ import { ElementNode, LexicalEditor, LexicalNode, PointType } from 'lexical';
2
+ import { IEditor } from "../../../types";
3
+ export declare function toRootElement(node: LexicalNode): ElementNode;
4
+ export declare function $getAdjacentNode(focus: PointType, isBackward: boolean): null | LexicalNode;
5
+ export declare function $getDownUpNode(focus: PointType, isUp: boolean): null | LexicalNode;
6
+ export declare function registerRichKeydown(editor: LexicalEditor, kernel: IEditor): () => void;
@@ -0,0 +1,274 @@
1
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
2
+ 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); }
3
+ 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; }
4
+ import { $isCodeHighlightNode, $isCodeNode } from '@lexical/code';
5
+ import { mergeRegister } from '@lexical/utils';
6
+ import { $createParagraphNode, $getNodeByKey, $getRoot, $getSelection, $isDecoratorNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, COMMAND_PRIORITY_NORMAL, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_UP_COMMAND, ParagraphNode } from 'lexical';
7
+ import { $closest } from "../../../editor-kernel";
8
+ import { SELECT_AFTER_CODEMIRROR_COMMAND, SELECT_BEFORE_CODEMIRROR_COMMAND } from "../../codemirror-block";
9
+ import { createDebugLogger } from "../../../utils/debug";
10
+ var logger = createDebugLogger('plugin', 'virtual-block');
11
+ function resolveElement(element, isBackward, focusOffset) {
12
+ var parent = element.getParent();
13
+ var offset = focusOffset;
14
+ var block = element;
15
+ if (parent !== null) {
16
+ if (isBackward && focusOffset === 0) {
17
+ offset = block.getIndexWithinParent();
18
+ block = parent;
19
+ } else if (!isBackward && focusOffset === block.getChildrenSize()) {
20
+ offset = block.getIndexWithinParent() + 1;
21
+ block = parent;
22
+ }
23
+ }
24
+ return block.getChildAtIndex(isBackward ? offset - 1 : offset);
25
+ }
26
+ function isCodeNodeLastLine(focusNode) {
27
+ if (!$isCodeHighlightNode(focusNode)) {
28
+ return false;
29
+ }
30
+ var codeNode = focusNode.getParent();
31
+ if (!$isCodeNode(codeNode)) {
32
+ return false;
33
+ }
34
+ var last = codeNode.getLastChild();
35
+ do {
36
+ var _last;
37
+ if ($isLineBreakNode(last)) {
38
+ return false;
39
+ }
40
+ if (last === focusNode) {
41
+ return codeNode;
42
+ }
43
+ last = (_last = last) === null || _last === void 0 ? void 0 : _last.getPreviousSibling();
44
+ } while (last !== focusNode && last);
45
+ if (last === focusNode) {
46
+ return codeNode;
47
+ }
48
+ return false;
49
+ }
50
+ export function toRootElement(node) {
51
+ var currentNode = node;
52
+ var parent = currentNode.getParent();
53
+ while (parent !== null && !$isRootOrShadowRoot(parent)) {
54
+ currentNode = parent;
55
+ parent = currentNode.getParent();
56
+ }
57
+ return currentNode;
58
+ }
59
+ export function $getAdjacentNode(focus, isBackward) {
60
+ var focusOffset = focus.offset;
61
+ if (focus.type === 'element') {
62
+ var block = focus.getNode();
63
+ return resolveElement(block, isBackward, focusOffset);
64
+ } else {
65
+ var focusNode = focus.getNode();
66
+ if (isBackward && focusOffset === 0 || !isBackward && focusOffset === focusNode.getTextContentSize()) {
67
+ var possibleNode = isBackward ? focusNode.getPreviousSibling() : focusNode.getNextSibling();
68
+ if (possibleNode === null) {
69
+ return resolveElement(focusNode.getParentOrThrow(), isBackward, focusNode.getIndexWithinParent() + (isBackward ? 0 : 1));
70
+ }
71
+ return possibleNode;
72
+ } else if (!isBackward && isCodeNodeLastLine(focusNode)) {
73
+ var _focusNode$getParent;
74
+ return ((_focusNode$getParent = focusNode.getParent()) === null || _focusNode$getParent === void 0 ? void 0 : _focusNode$getParent.getNextSibling()) || null;
75
+ }
76
+ }
77
+ return null;
78
+ }
79
+ export function $getDownUpNode(focus, isUp) {
80
+ var focusNode = focus.getNode();
81
+ var blockParent = focusNode;
82
+ while (blockParent !== null && blockParent.isInline()) {
83
+ blockParent = blockParent.getParent();
84
+ }
85
+ if (!blockParent) {
86
+ return null;
87
+ }
88
+ var nextNode = isUp ? blockParent.getPreviousSibling() : blockParent.getNextSibling();
89
+ while (!nextNode && !$isRootOrShadowRoot(blockParent)) {
90
+ blockParent = blockParent.getParent();
91
+ if (!blockParent) {
92
+ return null;
93
+ }
94
+ nextNode = isUp ? blockParent.getPreviousSibling() : blockParent.getNextSibling();
95
+ }
96
+ if (!nextNode) {
97
+ return null;
98
+ }
99
+ return nextNode;
100
+ }
101
+ function $isEmptyNode(node) {
102
+ if (node.getChildrenSize() === 0) {
103
+ return true;
104
+ }
105
+ var _iterator = _createForOfIteratorHelper(node.getChildren()),
106
+ _step;
107
+ try {
108
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
109
+ var child = _step.value;
110
+ if ($isTextNode(child)) {
111
+ if (child.getTextContent().trim().length > 0) {
112
+ return false;
113
+ }
114
+ } else if (!$isEmptyNode(child)) {
115
+ return false;
116
+ }
117
+ }
118
+ } catch (err) {
119
+ _iterator.e(err);
120
+ } finally {
121
+ _iterator.f();
122
+ }
123
+ return true;
124
+ }
125
+ export function registerRichKeydown(editor, kernel) {
126
+ var needRemoveOnFocusNode = null;
127
+ return mergeRegister(editor.registerUpdateListener(function (payload) {
128
+ var mutatedNodes = payload.mutatedNodes;
129
+ if (needRemoveOnFocusNode) {
130
+ var _mutatedNodes$get;
131
+ if ((mutatedNodes === null || mutatedNodes === void 0 || (_mutatedNodes$get = mutatedNodes.get(ParagraphNode)) === null || _mutatedNodes$get === void 0 ? void 0 : _mutatedNodes$get.get(needRemoveOnFocusNode.getKey())) === 'destroyed') {
132
+ console.info('Virtual block node was removed externally', needRemoveOnFocusNode);
133
+ needRemoveOnFocusNode = null;
134
+ return;
135
+ }
136
+ editor.update(function () {
137
+ try {
138
+ var selection = $getSelection();
139
+ if ($isRangeSelection(selection)) {
140
+ var focusNode = selection.focus.getNode();
141
+ if (needRemoveOnFocusNode && !$closest(focusNode, function (node) {
142
+ return node === needRemoveOnFocusNode;
143
+ })) {
144
+ if ($isEmptyNode(needRemoveOnFocusNode)) {
145
+ var _needRemoveOnFocusNod;
146
+ logger.info('Removing virtual block node after focus moved away', needRemoveOnFocusNode);
147
+ (_needRemoveOnFocusNod = needRemoveOnFocusNode) === null || _needRemoveOnFocusNod === void 0 || _needRemoveOnFocusNod.remove();
148
+ needRemoveOnFocusNode = null;
149
+ } else {
150
+ needRemoveOnFocusNode = null;
151
+ }
152
+ return;
153
+ }
154
+ } else if ($isNodeSelection(selection) && needRemoveOnFocusNode) {
155
+ if ($isEmptyNode(needRemoveOnFocusNode)) {
156
+ var _needRemoveOnFocusNod2;
157
+ (_needRemoveOnFocusNod2 = needRemoveOnFocusNode) === null || _needRemoveOnFocusNod2 === void 0 || _needRemoveOnFocusNod2.remove();
158
+ needRemoveOnFocusNode = null;
159
+ } else {
160
+ needRemoveOnFocusNode = null;
161
+ }
162
+ return;
163
+ }
164
+ } catch (error) {
165
+ console.error('Error during virtual block cleanup', error);
166
+ }
167
+ });
168
+ }
169
+ }), kernel.registerHighCommand(KEY_ARROW_UP_COMMAND, function (event) {
170
+ var selection = $getSelection();
171
+ if (event.shiftKey) {
172
+ return false;
173
+ }
174
+ if ($isNodeSelection(selection)) {
175
+ // If selection is on a node, let's try and move selection
176
+ // back to being a range selection.
177
+ var nodes = selection.getNodes();
178
+ if (nodes.length > 0) {
179
+ var elementNode = toRootElement(nodes[0]);
180
+ event.preventDefault();
181
+ var p = $createParagraphNode();
182
+ needRemoveOnFocusNode = p;
183
+ elementNode.insertBefore(p);
184
+ p.selectEnd();
185
+ return true;
186
+ }
187
+ } else if ($isRangeSelection(selection)) {
188
+ var possibleNode = toRootElement(selection.focus.getNode());
189
+ if (possibleNode === needRemoveOnFocusNode || $isEmptyNode(possibleNode)) {
190
+ return false;
191
+ }
192
+ if ($getRoot().getFirstChild() === possibleNode) {
193
+ event.preventDefault();
194
+ var _p = $createParagraphNode();
195
+ possibleNode.insertBefore(_p);
196
+ needRemoveOnFocusNode = _p;
197
+ _p.selectStart();
198
+ return true;
199
+ } else if ($isDecoratorNode(possibleNode.getPreviousSibling())) {
200
+ event.preventDefault();
201
+ var _p2 = $createParagraphNode();
202
+ possibleNode.insertBefore(_p2);
203
+ needRemoveOnFocusNode = _p2;
204
+ _p2.selectStart();
205
+ return true;
206
+ }
207
+ }
208
+ return false;
209
+ }, COMMAND_PRIORITY_NORMAL), kernel.registerHighCommand(KEY_ARROW_DOWN_COMMAND, function (event) {
210
+ var selection = $getSelection();
211
+ if ($isNodeSelection(selection)) {
212
+ // If selection is on a node, let's try and move selection
213
+ // back to being a range selection.
214
+ var nodes = selection.getNodes();
215
+ if (nodes.length > 0) {
216
+ var node = nodes[0];
217
+ var blockNode = toRootElement(node);
218
+ event.preventDefault();
219
+ var p = $createParagraphNode();
220
+ needRemoveOnFocusNode = p;
221
+ blockNode.insertAfter(p);
222
+ p.selectStart();
223
+ return true;
224
+ }
225
+ } else if ($isRangeSelection(selection)) {
226
+ if (!selection.isCollapsed()) {
227
+ return false;
228
+ }
229
+ var focusNode = selection.focus.getNode();
230
+ var possibleNode = toRootElement(focusNode);
231
+ if (possibleNode === needRemoveOnFocusNode || $isEmptyNode(possibleNode)) {
232
+ return false;
233
+ }
234
+ var root = $getRoot();
235
+ if (root.getLastChild() === possibleNode) {
236
+ event.preventDefault();
237
+ var _p3 = $createParagraphNode();
238
+ possibleNode.insertAfter(_p3);
239
+ needRemoveOnFocusNode = _p3;
240
+ _p3.selectStart();
241
+ }
242
+ return true;
243
+ }
244
+ return false;
245
+ }, COMMAND_PRIORITY_NORMAL), editor.registerCommand(SELECT_BEFORE_CODEMIRROR_COMMAND, function (payload) {
246
+ editor.update(function () {
247
+ var node = $getNodeByKey(payload.key);
248
+ if (!node) {
249
+ return;
250
+ }
251
+ var p = $createParagraphNode();
252
+ needRemoveOnFocusNode = p;
253
+ node.insertBefore(p);
254
+ p.selectEnd();
255
+ editor.focus();
256
+ return true;
257
+ });
258
+ return true;
259
+ }, COMMAND_PRIORITY_NORMAL), editor.registerCommand(SELECT_AFTER_CODEMIRROR_COMMAND, function (payload) {
260
+ editor.update(function () {
261
+ var node = $getNodeByKey(payload.key);
262
+ if (!node) {
263
+ return;
264
+ }
265
+ var p = $createParagraphNode();
266
+ needRemoveOnFocusNode = p;
267
+ node.insertAfter(p);
268
+ p.selectEnd();
269
+ editor.focus();
270
+ return true;
271
+ });
272
+ return true;
273
+ }, COMMAND_PRIORITY_NORMAL));
274
+ }
@@ -0,0 +1,3 @@
1
+ import { type FC } from 'react';
2
+ declare const ReactVirtualBlockPlugin: FC;
3
+ export default ReactVirtualBlockPlugin;
@@ -0,0 +1,22 @@
1
+ 'use client';
2
+
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ 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); }
6
+ 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; }
7
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ import { useLayoutEffect } from 'react';
10
+ import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
11
+ import { VirtualBlockPlugin } from "../plugin";
12
+ var ReactVirtualBlockPlugin = function ReactVirtualBlockPlugin() {
13
+ var _useLexicalComposerCo = useLexicalComposerContext(),
14
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
15
+ editor = _useLexicalComposerCo2[0];
16
+ useLayoutEffect(function () {
17
+ editor.registerPlugin(VirtualBlockPlugin);
18
+ }, []);
19
+ return null;
20
+ };
21
+ ReactVirtualBlockPlugin.displayName = 'ReactVirtualBlockPlugin';
22
+ export default ReactVirtualBlockPlugin;
@@ -0,0 +1 @@
1
+ export { default as ReactVirtualBlockPlugin } from './ReactVirtualBlock';
@@ -0,0 +1 @@
1
+ export { default as ReactVirtualBlockPlugin } from "./ReactVirtualBlock";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "3.11.0",
3
+ "version": "3.12.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",