@lobehub/editor 3.1.0 → 3.1.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.
- package/es/editor-kernel/kernel.js +1 -1
- package/es/plugins/auto-complete/plugin/index.js +7 -5
- package/es/plugins/common/plugin/register.js +3 -1
- package/es/plugins/link/node/LinkNode.js +4 -2
- package/es/plugins/link-highlight/node/link-highlight.js +3 -1
- package/es/plugins/litexml/command/index.js +8 -6
- package/es/plugins/table/react/TableHoverActions/utils.d.ts +1 -1
- package/es/plugins/table/react/TableHoverActions/utils.js +1 -1
- package/es/plugins/table/react/hooks.d.ts +1 -1
- package/es/plugins/table/react/hooks.js +1 -1
- package/es/plugins/toolbar/react/index.js +3 -1
- package/es/react/hooks/useEditorState/index.js +1 -1
- package/es/react/hooks/useSize.js +1 -1
- package/package.json +2 -2
|
@@ -20,9 +20,9 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
20
20
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
21
21
|
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); }
|
|
22
22
|
import { createEmptyHistoryState } from '@lexical/history';
|
|
23
|
+
import { get, merge, template, templateSettings } from 'es-toolkit/compat';
|
|
23
24
|
import EventEmitter from 'eventemitter3';
|
|
24
25
|
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_CRITICAL, KEY_DOWN_COMMAND, createEditor } from 'lexical';
|
|
25
|
-
import { get, merge, template, templateSettings } from 'lodash-es';
|
|
26
26
|
import defaultLocale from "../locale";
|
|
27
27
|
import { $isRootTextContentEmpty } from "../plugins/common/utils";
|
|
28
28
|
import { createDebugLogger } from "../utils/debug";
|
|
@@ -22,6 +22,7 @@ import { $getSelection, $insertNodes, $isRangeSelection, $setSelection, COMMAND_
|
|
|
22
22
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
23
23
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
24
24
|
import { IMarkdownShortCutService } from "../../markdown";
|
|
25
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
25
26
|
import { PlaceholderBlockNode, PlaceholderNode } from "../node/placeholderNode";
|
|
26
27
|
export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
27
28
|
_inherits(AutoCompletePlugin, _KernelPlugin);
|
|
@@ -31,6 +32,7 @@ export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin)
|
|
|
31
32
|
var _this;
|
|
32
33
|
_classCallCheck(this, AutoCompletePlugin);
|
|
33
34
|
_this = _super.call(this);
|
|
35
|
+
_defineProperty(_assertThisInitialized(_this), "logger", createDebugLogger('plugin', 'auto-complete'));
|
|
34
36
|
_defineProperty(_assertThisInitialized(_this), "lastCursorPosition", null);
|
|
35
37
|
_defineProperty(_assertThisInitialized(_this), "cursorStableTimer", null);
|
|
36
38
|
_defineProperty(_assertThisInitialized(_this), "abortController", null);
|
|
@@ -53,7 +55,7 @@ export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin)
|
|
|
53
55
|
var _this2 = this;
|
|
54
56
|
this.markdownService = this.kernel.requireService(IMarkdownShortCutService);
|
|
55
57
|
if (!this.markdownService) {
|
|
56
|
-
|
|
58
|
+
this.logger.error('❌ MarkdownShortCutService is required for AutoCompletePlugin');
|
|
57
59
|
return;
|
|
58
60
|
}
|
|
59
61
|
this.register(editor.registerUpdateListener(function (_ref) {
|
|
@@ -186,7 +188,7 @@ export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin)
|
|
|
186
188
|
// Store suggestion and show placeholder
|
|
187
189
|
_this3.currentSuggestion = result;
|
|
188
190
|
_this3.showPlaceholderNodes(editor, result);
|
|
189
|
-
|
|
191
|
+
_this3.logger.debug('🔍 Auto-complete triggered:', {
|
|
190
192
|
afterText: textRet.textAfter,
|
|
191
193
|
input: textRet.textBefore,
|
|
192
194
|
position: currentPosition,
|
|
@@ -220,7 +222,7 @@ export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin)
|
|
|
220
222
|
if (!paragraphNode) {
|
|
221
223
|
return ret;
|
|
222
224
|
}
|
|
223
|
-
|
|
225
|
+
this.logger.debug('🔍 Paragraph Node Type:', paragraphNode, anchorNode);
|
|
224
226
|
var founded = false;
|
|
225
227
|
|
|
226
228
|
// Collect all text before cursor in the paragraph
|
|
@@ -290,11 +292,11 @@ export var AutoCompletePlugin = (_class = /*#__PURE__*/function (_KernelPlugin)
|
|
|
290
292
|
editor.update(function () {
|
|
291
293
|
var selection = $getSelection();
|
|
292
294
|
if (!$isRangeSelection(selection) || !selection.isCollapsed()) {
|
|
293
|
-
|
|
295
|
+
_this4.logger.warn('⚠️ No valid selection for placeholder');
|
|
294
296
|
return;
|
|
295
297
|
}
|
|
296
298
|
if (!_this4.markdownService) {
|
|
297
|
-
|
|
299
|
+
_this4.logger.warn('⚠️ No valid markdown service for placeholder');
|
|
298
300
|
return;
|
|
299
301
|
}
|
|
300
302
|
var nodes = _this4.markdownService.parseMarkdownToLexical(suggestion);
|
|
@@ -8,6 +8,8 @@ import { mergeRegister } from '@lexical/utils';
|
|
|
8
8
|
import { $createNodeSelection, $createParagraphNode, $getRoot, $getSelection, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, $setSelection, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, FORMAT_TEXT_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, REDO_COMMAND, UNDO_COMMAND } from 'lexical';
|
|
9
9
|
import { $closest } from "../../../editor-kernel";
|
|
10
10
|
import { HotkeyEnum } from "../../../types/hotkey";
|
|
11
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
12
|
+
var logger = createDebugLogger('plugin', 'common');
|
|
11
13
|
function resolveElement(element, isBackward, focusOffset) {
|
|
12
14
|
var parent = element.getParent();
|
|
13
15
|
var offset = focusOffset;
|
|
@@ -163,7 +165,7 @@ export function registerRichKeydown(editor, kernel, options) {
|
|
|
163
165
|
case 7:
|
|
164
166
|
_context.prev = 7;
|
|
165
167
|
_context.t0 = _context["catch"](0);
|
|
166
|
-
|
|
168
|
+
logger.error('❌ Failed to paste as plain text:', _context.t0);
|
|
167
169
|
case 10:
|
|
168
170
|
case "end":
|
|
169
171
|
return _context.stop();
|
|
@@ -23,6 +23,8 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
23
23
|
import { $findMatchingParent, addClassNamesToElement, isHTMLAnchorElement } from '@lexical/utils';
|
|
24
24
|
import { $applyNodeReplacement, $getSelection, $isElementNode, $isNodeSelection, $isRangeSelection, $normalizeSelection__EXPERIMENTAL, $setSelection, ElementNode, createCommand } from 'lexical';
|
|
25
25
|
import { assert } from "../../../editor-kernel/utils";
|
|
26
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
27
|
+
var logger = createDebugLogger('plugin', 'link');
|
|
26
28
|
var SUPPORTED_URL_PROTOCOLS = new Set(['http:', 'https:', 'mailto:', 'sms:', 'tel:']);
|
|
27
29
|
export var HOVER_LINK_COMMAND = createCommand('HOVER_LINK_COMMAND');
|
|
28
30
|
export var HOVER_OUT_LINK_COMMAND = createCommand('HOVER_OUT_LINK_COMMAND');
|
|
@@ -62,7 +64,7 @@ export var LinkNode = /*#__PURE__*/function (_ElementNode) {
|
|
|
62
64
|
key: "createDOM",
|
|
63
65
|
value: function createDOM(config, editor) {
|
|
64
66
|
var _this2 = this;
|
|
65
|
-
|
|
67
|
+
logger.debug('🔍 config', config);
|
|
66
68
|
var element = document.createElement('a');
|
|
67
69
|
this.updateLinkDOM(null, element, config);
|
|
68
70
|
addClassNamesToElement(element, config.theme.link);
|
|
@@ -357,7 +359,7 @@ export var AutoLinkNode = /*#__PURE__*/function (_LinkNode) {
|
|
|
357
359
|
}, {
|
|
358
360
|
key: "createDOM",
|
|
359
361
|
value: function createDOM(config, editor) {
|
|
360
|
-
|
|
362
|
+
logger.debug('🔍 config', config);
|
|
361
363
|
if (this.__isUnlinked) {
|
|
362
364
|
return document.createElement('span');
|
|
363
365
|
} else {
|
|
@@ -14,6 +14,8 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
14
14
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
15
15
|
import { addClassNamesToElement } from '@lexical/utils';
|
|
16
16
|
import { $applyNodeReplacement, $getSelection, $isNodeSelection, $isRangeSelection, ElementNode } from 'lexical';
|
|
17
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
18
|
+
var logger = createDebugLogger('plugin', 'link-highlight');
|
|
17
19
|
export var LinkHighlightNode = /*#__PURE__*/function (_ElementNode) {
|
|
18
20
|
_inherits(LinkHighlightNode, _ElementNode);
|
|
19
21
|
var _super = _createSuper(LinkHighlightNode);
|
|
@@ -24,7 +26,7 @@ export var LinkHighlightNode = /*#__PURE__*/function (_ElementNode) {
|
|
|
24
26
|
_createClass(LinkHighlightNode, [{
|
|
25
27
|
key: "createDOM",
|
|
26
28
|
value: function createDOM(config) {
|
|
27
|
-
|
|
29
|
+
logger.debug('🔍 config', config);
|
|
28
30
|
var element = document.createElement('a');
|
|
29
31
|
|
|
30
32
|
// Set link attributes
|
|
@@ -11,8 +11,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
11
11
|
import { mergeRegister } from '@lexical/utils';
|
|
12
12
|
import { $createParagraphNode, $getNodeByKey, $insertNodes, $isElementNode, COMMAND_PRIORITY_EDITOR, createCommand } from 'lexical';
|
|
13
13
|
import { $closest } from "../../../editor-kernel";
|
|
14
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
14
15
|
import { $createDiffNode, DiffNode } from "../node/DiffNode";
|
|
15
16
|
import { $cloneNode, $parseSerializedNodeImpl, charToId } from "../utils";
|
|
17
|
+
var logger = createDebugLogger('plugin', 'litexml');
|
|
16
18
|
|
|
17
19
|
// Helpers to reduce duplication and improve readability
|
|
18
20
|
function toArrayXml(litexml) {
|
|
@@ -27,7 +29,7 @@ function tryParseChild(child, editor) {
|
|
|
27
29
|
oldNode: oldNode
|
|
28
30
|
};
|
|
29
31
|
} catch (error) {
|
|
30
|
-
|
|
32
|
+
logger.error('❌ Error parsing child node:', error);
|
|
31
33
|
return {
|
|
32
34
|
newNode: null,
|
|
33
35
|
oldNode: null
|
|
@@ -154,7 +156,7 @@ export function registerLiteXMLCommand(editor, dataSource) {
|
|
|
154
156
|
}
|
|
155
157
|
default:
|
|
156
158
|
{
|
|
157
|
-
|
|
159
|
+
logger.warn("\u26A0\uFE0F Unknown action type: ".concat(action));
|
|
158
160
|
}
|
|
159
161
|
}
|
|
160
162
|
});
|
|
@@ -194,10 +196,10 @@ function handleModify(editor, dataSource, arrayXml, delay) {
|
|
|
194
196
|
if (oldNode && newNode) {
|
|
195
197
|
handleReplaceForApplyDelay(oldNode, newNode, modifyBlockNodes, diffNodeMap, editor);
|
|
196
198
|
} else {
|
|
197
|
-
|
|
199
|
+
logger.warn("\u26A0\uFE0F Node with key ".concat(child.id, " not found for diffing."));
|
|
198
200
|
}
|
|
199
201
|
} catch (error) {
|
|
200
|
-
|
|
202
|
+
logger.error('❌ Error replacing node:', error);
|
|
201
203
|
}
|
|
202
204
|
});
|
|
203
205
|
});
|
|
@@ -236,7 +238,7 @@ function handleModify(editor, dataSource, arrayXml, delay) {
|
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
} catch (error) {
|
|
239
|
-
|
|
241
|
+
logger.error('❌ Error replacing node:', error);
|
|
240
242
|
}
|
|
241
243
|
});
|
|
242
244
|
});
|
|
@@ -433,7 +435,7 @@ function handleInsert(editor, payload, dataSource) {
|
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
437
|
} catch (error) {
|
|
436
|
-
|
|
438
|
+
logger.error('❌ Error inserting node:', error);
|
|
437
439
|
}
|
|
438
440
|
});
|
|
439
441
|
}
|
|
@@ -5,4 +5,4 @@ export declare function getMouseInfo(event: MouseEvent, iEditor: IEditor): {
|
|
|
5
5
|
isOutside: boolean;
|
|
6
6
|
tableDOMNode: HTMLElement | null;
|
|
7
7
|
};
|
|
8
|
-
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("
|
|
8
|
+
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("es-toolkit/compat").DebouncedFunc<(...args: Parameters<T>) => void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("
|
|
1
|
+
export declare function useDebounce<T extends (...args: never[]) => void>(fn: T, ms: number, maxWait?: number): import("es-toolkit/compat").DebouncedFunc<(...args: Parameters<T>) => void>;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
7
|
*/
|
|
8
|
-
import { debounce } from '
|
|
8
|
+
import { debounce } from 'es-toolkit/compat';
|
|
9
9
|
import { useMemo, useRef } from 'react';
|
|
10
10
|
export function useDebounce(fn, ms, maxWait) {
|
|
11
11
|
var funcRef = useRef(null);
|
|
@@ -10,6 +10,7 @@ import { $getSelection, COMMAND_PRIORITY_LOW, SELECTION_CHANGE_COMMAND, getDOMSe
|
|
|
10
10
|
import { useCallback, useRef } from 'react';
|
|
11
11
|
import { useLexicalComposerContext, useLexicalEditor } from "../../../editor-kernel/react";
|
|
12
12
|
import { ILinkService } from "../../link";
|
|
13
|
+
import { createDebugLogger } from "../../../utils/debug";
|
|
13
14
|
import { HIDE_TOOLBAR_COMMAND, registerToolbarCommand } from "../command";
|
|
14
15
|
import { getDOMRangeRect } from "../utils/getDOMRangeRect";
|
|
15
16
|
import { setFloatingElemPosition } from "../utils/setFloatingElemPosition";
|
|
@@ -27,6 +28,7 @@ export var ReactToolbarPlugin = function ReactToolbarPlugin(_ref) {
|
|
|
27
28
|
cx = _useStyles.cx,
|
|
28
29
|
styles = _useStyles.styles;
|
|
29
30
|
var isMouseDownRef = useRef(false);
|
|
31
|
+
var logger = createDebugLogger('plugin', 'toolbar');
|
|
30
32
|
var $updateTextFormatFloatingToolbar = useCallback(function (editor) {
|
|
31
33
|
if (!anchorElemRef.current) {
|
|
32
34
|
return;
|
|
@@ -40,7 +42,7 @@ export var ReactToolbarPlugin = function ReactToolbarPlugin(_ref) {
|
|
|
40
42
|
var rootElement = editor.getRootElement();
|
|
41
43
|
if (selection !== null && nativeSelection !== null && !nativeSelection.isCollapsed && rootElement !== null && rootElement.contains(nativeSelection.anchorNode)) {
|
|
42
44
|
var rangeRect = getDOMRangeRect(nativeSelection, rootElement);
|
|
43
|
-
|
|
45
|
+
logger.debug('🔍 rangeRect', rangeRect);
|
|
44
46
|
setFloatingElemPosition(rangeRect, popupCharStylesEditorElem, anchorElemRef.current, false);
|
|
45
47
|
} else {
|
|
46
48
|
popupCharStylesEditorElem.style.opacity = '0';
|
|
@@ -9,8 +9,8 @@ import { $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND
|
|
|
9
9
|
import { $createQuoteNode, $isHeadingNode, $isQuoteNode } from '@lexical/rich-text';
|
|
10
10
|
import { $setBlocksType } from '@lexical/selection';
|
|
11
11
|
import { $getNearestNodeOfType, mergeRegister } from '@lexical/utils';
|
|
12
|
+
import { debounce } from 'es-toolkit';
|
|
12
13
|
import { $createNodeSelection, $getSelection, $isParagraphNode, $isRangeSelection, $setSelection, CAN_REDO_COMMAND, CAN_UNDO_COMMAND, COMMAND_PRIORITY_LOW, FORMAT_TEXT_COMMAND, REDO_COMMAND, SELECTION_CHANGE_COMMAND, UNDO_COMMAND } from 'lexical';
|
|
13
|
-
import { debounce } from 'lodash-es';
|
|
14
14
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
15
15
|
import { noop } from "../../../editor-kernel";
|
|
16
16
|
import { INSERT_CODEINLINE_COMMAND } from "../../../plugins/code";
|
|
@@ -5,7 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
5
|
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; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
// hooks/useContainerSize.ts
|
|
8
|
-
import { debounce } from '
|
|
8
|
+
import { debounce } from 'es-toolkit';
|
|
9
9
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
export var useWidth = function useWidth() {
|
|
11
11
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/editor",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.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",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"ahooks": "^3.9.6",
|
|
48
48
|
"antd-style": "^4.0.0",
|
|
49
49
|
"debug": "^4.4.3",
|
|
50
|
+
"es-toolkit": "^1.43.0",
|
|
50
51
|
"eventemitter3": "^5.0.1",
|
|
51
52
|
"fuse.js": "^7.1.0",
|
|
52
53
|
"katex": "^0.16.27",
|
|
53
54
|
"lexical": "^0.39.0",
|
|
54
|
-
"lodash-es": "^4.17.22",
|
|
55
55
|
"lucide-react": "^0.562.0",
|
|
56
56
|
"polished": "^4.3.1",
|
|
57
57
|
"re-resizable": "^6.11.2",
|