@lobehub/editor 1.18.2 → 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 +36 -5
- package/es/plugins/common/plugin/mdReader.d.ts +1 -1
- package/es/plugins/common/react/ReactPlainText.js +1 -1
- package/es/plugins/common/utils/index.d.ts +5 -0
- package/es/plugins/common/utils/index.js +61 -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) {
|
|
@@ -24,15 +24,16 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
24
24
|
import { registerDragonSupport } from '@lexical/dragon';
|
|
25
25
|
import { createEmptyHistoryState, registerHistory } from '@lexical/history';
|
|
26
26
|
import { $createHeadingNode, $createQuoteNode, $isHeadingNode, $isQuoteNode, HeadingNode, QuoteNode, registerRichText } from '@lexical/rich-text';
|
|
27
|
-
import { $createLineBreakNode, $createParagraphNode, $isTextNode, COMMAND_PRIORITY_HIGH, INSERT_LINE_BREAK_COMMAND, INSERT_PARAGRAPH_COMMAND } from 'lexical';
|
|
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";
|
|
33
34
|
import { patchBreakLine, registerBreakLineClick } from "../node/ElementDOMSlot";
|
|
34
35
|
import { CursorNode, registerCursorNode } from "../node/cursor";
|
|
35
|
-
import { createBlockNode } from "../utils";
|
|
36
|
+
import { $isCursorInQuote, $isCursorInTable, createBlockNode } from "../utils";
|
|
36
37
|
import { registerMDReader } from "./mdReader";
|
|
37
38
|
import { registerHeaderBackspace, registerLastElement, registerRichKeydown } from "./register";
|
|
38
39
|
patchBreakLine();
|
|
@@ -319,8 +320,38 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
319
320
|
// Convert soft line breaks (Shift+Enter) to hard line breaks (paragraph breaks)
|
|
320
321
|
// This allows breaking out of code blocks with Shift+Enter
|
|
321
322
|
editor.registerCommand(INSERT_LINE_BREAK_COMMAND, function () {
|
|
322
|
-
//
|
|
323
|
-
|
|
323
|
+
// editor.read(() => {
|
|
324
|
+
var selection = $getSelection();
|
|
325
|
+
if (!$isRangeSelection(selection)) {
|
|
326
|
+
console.info('---------?');
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
// Check if cursor is in a table
|
|
331
|
+
var _$isCursorInTable = $isCursorInTable(selection),
|
|
332
|
+
inCell = _$isCursorInTable.inCell,
|
|
333
|
+
inTable = _$isCursorInTable.inTable;
|
|
334
|
+
if (inCell) {
|
|
335
|
+
// We're in a table cell, allow normal line break behavior
|
|
336
|
+
return false;
|
|
337
|
+
}
|
|
338
|
+
if (inTable) {
|
|
339
|
+
// We're in a table but not in a cell, prevent line break
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
// Check if cursor is in a quote
|
|
344
|
+
var inQuote = $isCursorInQuote(selection);
|
|
345
|
+
if (inQuote) {
|
|
346
|
+
// We're in a quote block, allow normal line break behavior
|
|
347
|
+
// This preserves line breaks within quotes while maintaining quote formatting
|
|
348
|
+
return false;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
// Not in a table or quote, convert to paragraph break
|
|
352
|
+
editor.update(function () {
|
|
353
|
+
editor.dispatchCommand(INSERT_PARAGRAPH_COMMAND, undefined);
|
|
354
|
+
});
|
|
324
355
|
return true; // Prevent default line break behavior
|
|
325
356
|
}, COMMAND_PRIORITY_HIGH));
|
|
326
357
|
this.registerMarkdown(this.kernel);
|
|
@@ -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";
|
|
@@ -26,3 +26,8 @@ export declare function $canShowPlaceholder(isComposing: boolean): boolean;
|
|
|
26
26
|
* @returns A function that executes $canShowPlaceholder with arguments.
|
|
27
27
|
*/
|
|
28
28
|
export declare function $canShowPlaceholderCurry(isEditorComposing: boolean): () => boolean;
|
|
29
|
+
export declare function $isCursorInTable(selection: any): {
|
|
30
|
+
inCell: boolean;
|
|
31
|
+
inTable: boolean;
|
|
32
|
+
};
|
|
33
|
+
export declare function $isCursorInQuote(selection: any): boolean;
|
|
@@ -4,7 +4,9 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
5
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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
|
-
import { $
|
|
7
|
+
import { $isQuoteNode } from '@lexical/rich-text';
|
|
8
|
+
import { $isTableCellNode, $isTableNode } from '@lexical/table';
|
|
9
|
+
import { $getRoot, $isDecoratorNode, $isElementNode, $isParagraphNode, $isRangeSelection, $isTextNode } from 'lexical';
|
|
8
10
|
export var createBlockNode = function createBlockNode(createNode) {
|
|
9
11
|
return function (parentNode, children, match, isImport) {
|
|
10
12
|
var node = createNode(match, parentNode);
|
|
@@ -93,4 +95,62 @@ export function $canShowPlaceholderCurry(isEditorComposing) {
|
|
|
93
95
|
return function () {
|
|
94
96
|
return $canShowPlaceholder(isEditorComposing);
|
|
95
97
|
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Utility function to check if cursor is in a table
|
|
101
|
+
export function $isCursorInTable(selection) {
|
|
102
|
+
if (!$isRangeSelection(selection)) {
|
|
103
|
+
return {
|
|
104
|
+
inCell: false,
|
|
105
|
+
inTable: false
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
var focusNode = selection.focus.getNode();
|
|
109
|
+
var currentNode = focusNode;
|
|
110
|
+
var inTable = false;
|
|
111
|
+
var inCell = false;
|
|
112
|
+
|
|
113
|
+
// Traverse up the parent chain to find table context
|
|
114
|
+
while (currentNode) {
|
|
115
|
+
if ($isTableCellNode(currentNode)) {
|
|
116
|
+
inCell = true;
|
|
117
|
+
inTable = true;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
if ($isTableNode(currentNode)) {
|
|
121
|
+
inTable = true;
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
var parent = currentNode.getParent();
|
|
125
|
+
if (!parent) {
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
currentNode = parent;
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
inCell: inCell,
|
|
132
|
+
inTable: inTable
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Utility function to check if cursor is in a quote
|
|
137
|
+
export function $isCursorInQuote(selection) {
|
|
138
|
+
if (!$isRangeSelection(selection)) {
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
var focusNode = selection.focus.getNode();
|
|
142
|
+
var currentNode = focusNode;
|
|
143
|
+
|
|
144
|
+
// Traverse up the parent chain to find quote context
|
|
145
|
+
while (currentNode) {
|
|
146
|
+
if ($isQuoteNode(currentNode)) {
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
var parent = currentNode.getParent();
|
|
150
|
+
if (!parent) {
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
currentNode = parent;
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
96
156
|
}
|
|
@@ -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