@lobehub/editor 1.19.0 → 1.19.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/plugins/code/node/code.d.ts +1 -1
- package/es/plugins/code/node/code.js +1 -1
- package/es/plugins/code/react/CodeReactPlugin.js +1 -1
- package/es/plugins/codeblock/plugin/index.js +1 -1
- package/es/plugins/codeblock/react/ReactCodeblockPlugin.js +1 -1
- package/es/plugins/common/plugin/index.js +2 -1
- package/es/plugins/common/plugin/mdReader.d.ts +1 -1
- package/es/plugins/common/react/ReactPlainText.js +1 -1
- package/es/plugins/file/plugin/index.js +1 -1
- package/es/plugins/hr/plugin/index.js +1 -1
- package/es/plugins/hr/react/ReactHRPlugin.js +1 -1
- package/es/plugins/link/plugin/index.js +1 -1
- package/es/plugins/link/react/ReactLinkPlugin.js +1 -1
- package/es/plugins/list/plugin/index.js +1 -1
- package/es/plugins/list/react/ReactListPlugin.js +1 -1
- package/es/plugins/markdown/plugin/index.js +44 -1
- package/es/plugins/math/plugin/index.js +1 -1
- package/es/plugins/math/react/index.js +1 -1
- package/es/plugins/mention/plugin/index.js +1 -1
- package/es/plugins/mention/react/ReactMentionPlugin.js +1 -1
- package/es/plugins/table/plugin/index.js +1 -1
- package/es/react/Editor/Editor.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorConfig, LexicalEditor, LexicalNode, SerializedElementNode } from 'lexical';
|
|
2
|
-
import { CardLikeElementNode } from "../../common";
|
|
2
|
+
import { CardLikeElementNode } from "../../common/node/cursor";
|
|
3
3
|
export type SerializedCodeNode = SerializedElementNode;
|
|
4
4
|
export declare class CodeNode extends CardLikeElementNode {
|
|
5
5
|
static getType(): string;
|
|
@@ -16,7 +16,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
17
17
|
import { addClassNamesToElement } from '@lexical/utils';
|
|
18
18
|
import { $applyNodeReplacement, $createTextNode, $getSelection, $isNodeSelection, $isRangeSelection } from 'lexical';
|
|
19
|
-
import { $createCursorNode, $isCursorNode, CardLikeElementNode } from "../../common";
|
|
19
|
+
import { $createCursorNode, $isCursorNode, CardLikeElementNode } from "../../common/node/cursor";
|
|
20
20
|
export var CodeNode = /*#__PURE__*/function (_CardLikeElementNode) {
|
|
21
21
|
_inherits(CodeNode, _CardLikeElementNode);
|
|
22
22
|
var _super = _createSuper(CodeNode);
|
|
@@ -8,7 +8,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
12
12
|
import { CodePlugin } from "../plugin";
|
|
13
13
|
import { useStyles } from "./style";
|
|
14
14
|
var ReactCodePlugin = function ReactCodePlugin(_ref) {
|
|
@@ -17,7 +17,7 @@ import { $createCodeNode, $isCodeHighlightNode, $isCodeNode, CodeHighlightNode,
|
|
|
17
17
|
import { TabNode } from 'lexical';
|
|
18
18
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
19
19
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
20
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
20
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
21
21
|
import { CustomShikiTokenizer, registerCodeCommand } from "../command";
|
|
22
22
|
import { getCodeLanguageByInput } from "../utils/language";
|
|
23
23
|
import { registerCodeHighlighting, toCodeTheme } from "./CodeHighlighterShiki";
|
|
@@ -9,7 +9,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
9
9
|
import { usePrevious } from 'ahooks';
|
|
10
10
|
import { useEffect, useLayoutEffect, useRef } from 'react';
|
|
11
11
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
12
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
12
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
13
13
|
import { CodeblockPlugin } from "../plugin";
|
|
14
14
|
import { colorReplacements, useStyles } from "./style";
|
|
15
15
|
export var ReactCodeblockPlugin = function ReactCodeblockPlugin(_ref) {
|
|
@@ -26,7 +26,8 @@ import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
|
26
26
|
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode, registerRichText } from '@lexical/rich-text';
|
|
27
27
|
import { $createLineBreakNode, $createParagraphNode, $getSelection, $isRangeSelection, $isTextNode, COMMAND_PRIORITY_HIGH, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND } from 'lexical';
|
|
28
28
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
29
|
-
import { IMarkdownShortCutService
|
|
29
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
30
|
+
import { isPunctuationChar } from "../../markdown/utils";
|
|
30
31
|
import { registerCommands } from "../command";
|
|
31
32
|
import JSONDataSource from "../data-source/json-data-source";
|
|
32
33
|
import TextDataSource from "../data-source/text-data-source";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { IMarkdownShortCutService } from "../../markdown";
|
|
1
|
+
import type { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
2
2
|
export declare function registerMDReader(markdownService: IMarkdownShortCutService): void;
|
|
@@ -20,7 +20,7 @@ import { Children, memo, useEffect, useLayoutEffect, useRef, useState } from 're
|
|
|
20
20
|
import { LexicalErrorBoundary } from "../../../editor-kernel/react/LexicalErrorBoundary";
|
|
21
21
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
22
22
|
import { useDecorators } from "../../../editor-kernel/react/useDecorators";
|
|
23
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
23
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
24
24
|
import { CommonPlugin } from "../plugin";
|
|
25
25
|
import Placeholder from "./Placeholder";
|
|
26
26
|
import { useStyles, useThemeStyles } from "./style";
|
|
@@ -19,7 +19,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
19
19
|
import { $wrapNodeInElement } from '@lexical/utils';
|
|
20
20
|
import { $createParagraphNode, $createRangeSelection, $insertNodes, $isRootOrShadowRoot, $setSelection } from 'lexical';
|
|
21
21
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
22
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
22
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
23
23
|
import { IUploadService } from "../../upload";
|
|
24
24
|
import { createDebugLogger } from "../../../utils/debug";
|
|
25
25
|
import { registerFileCommand } from "../command";
|
|
@@ -15,7 +15,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
15
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
16
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
17
17
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
18
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
18
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
19
19
|
import { registerHorizontalRuleCommand } from "../command";
|
|
20
20
|
import { $createHorizontalRuleNode, $isHorizontalRuleNode, HorizontalRuleNode } from "../node/HorizontalRuleNode";
|
|
21
21
|
|
|
@@ -8,7 +8,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
12
12
|
import { HRPlugin } from "../plugin";
|
|
13
13
|
import HRNode from "./components/HRNode";
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -22,7 +22,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
22
22
|
import { $createTextNode, COMMAND_PRIORITY_NORMAL, PASTE_COMMAND } from 'lexical';
|
|
23
23
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
24
24
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
25
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
25
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
26
26
|
import { INSERT_LINK_COMMAND, registerLinkCommand } from "../command";
|
|
27
27
|
import { $createLinkNode, $isLinkNode, AutoLinkNode, LinkNode } from "../node/LinkNode";
|
|
28
28
|
import { registerLinkCommands } from "./registry";
|
|
@@ -9,7 +9,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import PortalAnchor from "../../../editor-kernel/react/PortalAnchor";
|
|
11
11
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
12
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
12
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
13
13
|
import { LinkPlugin } from "../plugin";
|
|
14
14
|
import LinkEdit from "./components/LinkEdit";
|
|
15
15
|
import LinkToolbar from "./components/LinkToolbar";
|
|
@@ -19,7 +19,7 @@ import { cx } from 'antd-style';
|
|
|
19
19
|
import { $isRootNode } from 'lexical';
|
|
20
20
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
21
21
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
22
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
22
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
23
23
|
import { listReplace } from "../utils";
|
|
24
24
|
import { registerCheckList } from "./checkList";
|
|
25
25
|
import { registerListCommands } from "./registry";
|
|
@@ -8,7 +8,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
12
12
|
import { ListPlugin } from "../plugin";
|
|
13
13
|
import { useStyles } from "./style";
|
|
14
14
|
var ReactListPlugin = function ReactListPlugin(_ref) {
|
|
@@ -13,9 +13,10 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
13
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
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
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 { $createCodeNode, $isCodeNode } from '@lexical/code';
|
|
16
|
+
import { $createCodeNode, $isCodeHighlightNode, $isCodeNode } from '@lexical/code';
|
|
17
17
|
import { $getNodeByKey, $getSelection, $isRangeSelection, $isTextNode, COLLABORATION_TAG, COMMAND_PRIORITY_CRITICAL, HISTORIC_TAG, KEY_ENTER_COMMAND, PASTE_COMMAND } from 'lexical';
|
|
18
18
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
19
|
+
import { $isCodeInlineNode } from "../../code/node/code";
|
|
19
20
|
import { createDebugLogger } from "../../../utils/debug";
|
|
20
21
|
import { registerMarkdownCommand } from "../command";
|
|
21
22
|
import MarkdownDataSource from "../data-source/markdown-data-source";
|
|
@@ -137,6 +138,48 @@ export var MarkdownPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
137
138
|
htmlLength: (html === null || html === void 0 ? void 0 : html.length) || 0,
|
|
138
139
|
textLength: text.length
|
|
139
140
|
});
|
|
141
|
+
|
|
142
|
+
// Check if cursor is inside code block or inline code
|
|
143
|
+
// If so, always paste as plain text
|
|
144
|
+
var isInCodeBlock = editor.read(function () {
|
|
145
|
+
var selection = $getSelection();
|
|
146
|
+
if (!$isRangeSelection(selection)) return false;
|
|
147
|
+
var anchorNode = selection.anchor.getNode();
|
|
148
|
+
var focusNode = selection.focus.getNode();
|
|
149
|
+
|
|
150
|
+
// Check if in code block (CodeNode or CodeHighlightNode)
|
|
151
|
+
var anchorParent = anchorNode.getParent();
|
|
152
|
+
var focusParent = focusNode.getParent();
|
|
153
|
+
if ($isCodeNode(anchorNode) || $isCodeNode(focusNode)) {
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
if ($isCodeNode(anchorParent) || $isCodeNode(focusParent)) {
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
if ($isCodeHighlightNode(anchorNode) || $isCodeHighlightNode(focusNode)) {
|
|
160
|
+
return true;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Check if in inline code
|
|
164
|
+
if ($isCodeInlineNode(anchorNode) || $isCodeInlineNode(focusNode)) {
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
if ($isCodeInlineNode(anchorParent) || $isCodeInlineNode(focusParent)) {
|
|
168
|
+
return true;
|
|
169
|
+
}
|
|
170
|
+
return false;
|
|
171
|
+
});
|
|
172
|
+
if (isInCodeBlock) {
|
|
173
|
+
_this2.logger.debug('cursor in code block, pasting as plain text');
|
|
174
|
+
event.preventDefault();
|
|
175
|
+
event.stopPropagation();
|
|
176
|
+
editor.update(function () {
|
|
177
|
+
var selection = $getSelection();
|
|
178
|
+
if (!$isRangeSelection(selection)) return;
|
|
179
|
+
selection.insertText(text);
|
|
180
|
+
});
|
|
181
|
+
return true;
|
|
182
|
+
}
|
|
140
183
|
var enablePasteMarkdown = (_this2$config$enableP = (_this2$config = _this2.config) === null || _this2$config === void 0 ? void 0 : _this2$config.enablePasteMarkdown) !== null && _this2$config$enableP !== void 0 ? _this2$config$enableP : true;
|
|
141
184
|
|
|
142
185
|
// If markdown formatting is disabled, we're done
|
|
@@ -22,7 +22,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
22
22
|
import { $createNodeSelection, $setSelection } from 'lexical';
|
|
23
23
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
24
24
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
25
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
25
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
26
26
|
import { createDebugLogger } from "../../../utils/debug";
|
|
27
27
|
import { registerMathCommand } from "../command";
|
|
28
28
|
import { $createMathBlockNode, $createMathInlineNode, MathBlockNode, MathInlineNode } from "../node";
|
|
@@ -8,7 +8,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
12
12
|
import { MathPlugin } from "../plugin";
|
|
13
13
|
import MathEdit from "./components/MathEditor";
|
|
14
14
|
import MathInline from "./components/MathInline";
|
|
@@ -14,7 +14,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
14
14
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
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
16
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
17
|
-
import { IMarkdownShortCutService, MARKDOWN_READER_LEVEL_HIGH } from "../../markdown";
|
|
17
|
+
import { IMarkdownShortCutService, MARKDOWN_READER_LEVEL_HIGH } from "../../markdown/service/shortcut";
|
|
18
18
|
import { registerMentionCommand } from "../command";
|
|
19
19
|
import { $isMentionNode, MentionNode } from "../node/MentionNode";
|
|
20
20
|
import { registerMentionNodeSelectionObserver } from "./register";
|
|
@@ -8,7 +8,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
9
|
import { useLayoutEffect } from 'react';
|
|
10
10
|
import { useLexicalComposerContext } from "../../../editor-kernel/react/react-context";
|
|
11
|
-
import { MarkdownPlugin } from "../../markdown";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown/plugin";
|
|
12
12
|
import { MentionPlugin } from "../plugin";
|
|
13
13
|
import Mention from "./components/Mention";
|
|
14
14
|
import { useStyles } from "./style";
|
|
@@ -17,7 +17,7 @@ import { $isTableNode, TableCellNode, TableRowNode, registerTableCellUnmergeTran
|
|
|
17
17
|
import { cx } from 'antd-style';
|
|
18
18
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
19
19
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
20
|
-
import { IMarkdownShortCutService } from "../../markdown";
|
|
20
|
+
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
21
21
|
import { registerTableCommand } from "../command";
|
|
22
22
|
import { TableNode, patchTableNode } from "../node";
|
|
23
23
|
|
|
@@ -18,7 +18,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
18
18
|
import { createElement, memo, useMemo } from 'react';
|
|
19
19
|
import { ReactEditor } from "../../editor-kernel/react/react-editor";
|
|
20
20
|
import { ReactEditorContent, ReactPlainText } from "../../plugins/common";
|
|
21
|
-
import
|
|
21
|
+
import ReactMarkdownPlugin from "../../plugins/markdown/react";
|
|
22
22
|
import { ReactMentionPlugin } from "../../plugins/mention";
|
|
23
23
|
import { ReactSlashOption, ReactSlashPlugin } from "../../plugins/slash";
|
|
24
24
|
import { useEditorContent } from "../EditorProvider";
|
package/package.json
CHANGED