@lobehub/editor 1.23.1 → 1.24.0
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/README.md +0 -1
- package/es/plugins/codeblock/plugin/index.js +28 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -685,4 +685,3 @@ This project is [MIT](./LICENSE) licensed.
|
|
|
685
685
|
[pr-welcome-link]: https://github.com/lobehub/lobe-editor/pulls
|
|
686
686
|
[pr-welcome-shield]: https://img.shields.io/badge/%F0%9F%A4%AF%20PR%20WELCOME-%E2%86%92-ffcb47?labelColor=black&style=for-the-badge
|
|
687
687
|
[profile-link]: https://github.com/lobehub
|
|
688
|
-
|
|
@@ -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 { $createCodeNode, $isCodeHighlightNode, $isCodeNode, CodeHighlightNode, CodeNode } from '@lexical/code';
|
|
17
|
-
import { TabNode } from 'lexical';
|
|
17
|
+
import { $getSelection, $isRangeSelection, COMMAND_PRIORITY_EDITOR, PASTE_COMMAND, TabNode } from 'lexical';
|
|
18
18
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
19
19
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
20
20
|
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
@@ -93,6 +93,33 @@ export var CodeblockPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
93
93
|
this.register(registerCodeHighlighting(editor));
|
|
94
94
|
}
|
|
95
95
|
this.register(registerCodeCommand(editor));
|
|
96
|
+
this.register(editor.registerCommand(PASTE_COMMAND, function (event) {
|
|
97
|
+
if (!(event instanceof ClipboardEvent)) return false;
|
|
98
|
+
var clipboardData = event.clipboardData;
|
|
99
|
+
if (!clipboardData) return false;
|
|
100
|
+
var isInHighlightNodeSelection = editor.read(function () {
|
|
101
|
+
var sel = $getSelection();
|
|
102
|
+
if (!$isRangeSelection(sel)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
var node = sel.focus.getNode();
|
|
106
|
+
while (node) {
|
|
107
|
+
if ($isCodeHighlightNode(node) || $isCodeNode(node)) {
|
|
108
|
+
return sel;
|
|
109
|
+
}
|
|
110
|
+
node = node.getParent();
|
|
111
|
+
}
|
|
112
|
+
return false;
|
|
113
|
+
});
|
|
114
|
+
if (isInHighlightNodeSelection) {
|
|
115
|
+
var rawText = clipboardData.getData('text/plain').trimEnd() || clipboardData.getData('text/uri-list').trimEnd();
|
|
116
|
+
editor.update(function () {
|
|
117
|
+
isInHighlightNodeSelection.insertRawText(rawText);
|
|
118
|
+
});
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
96
123
|
this.registerMarkdown();
|
|
97
124
|
}
|
|
98
125
|
}, {
|
package/package.json
CHANGED