@lobehub/editor 4.27.0 → 4.27.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/headless.js
CHANGED
|
@@ -10492,10 +10492,19 @@ const INSERT_MENTION_COMMAND = createCommand("INSERT_MENTION_COMMAND");
|
|
|
10492
10492
|
function registerMentionCommand(editor) {
|
|
10493
10493
|
return editor.registerCommand(INSERT_MENTION_COMMAND, (payload) => {
|
|
10494
10494
|
const { metadata, label } = payload;
|
|
10495
|
+
const hasCursorNode = editor.hasNodes([CursorNode]);
|
|
10495
10496
|
editor.update(() => {
|
|
10496
10497
|
const mentionNode = $createMentionNode(label, metadata);
|
|
10497
10498
|
$insertNodes([mentionNode]);
|
|
10498
|
-
if ($isRootOrShadowRoot(mentionNode.getParentOrThrow()))
|
|
10499
|
+
if ($isRootOrShadowRoot(mentionNode.getParentOrThrow())) {
|
|
10500
|
+
const paragraph = $wrapNodeInElement(mentionNode, $createParagraphNode);
|
|
10501
|
+
if (!hasCursorNode) paragraph.selectEnd();
|
|
10502
|
+
}
|
|
10503
|
+
if (hasCursorNode) {
|
|
10504
|
+
const cursorNode = $createCursorNode();
|
|
10505
|
+
mentionNode.insertAfter(cursorNode);
|
|
10506
|
+
cursorNode.selectEnd();
|
|
10507
|
+
}
|
|
10499
10508
|
});
|
|
10500
10509
|
return true;
|
|
10501
10510
|
}, COMMAND_PRIORITY_HIGH);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { $createCursorNode, CursorNode } from "../../common/node/cursor.js";
|
|
1
2
|
import { $createMentionNode } from "../node/MentionNode.js";
|
|
2
3
|
import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from "lexical";
|
|
3
4
|
import { $wrapNodeInElement } from "@lexical/utils";
|
|
@@ -6,10 +7,19 @@ const INSERT_MENTION_COMMAND = createCommand("INSERT_MENTION_COMMAND");
|
|
|
6
7
|
function registerMentionCommand(editor) {
|
|
7
8
|
return editor.registerCommand(INSERT_MENTION_COMMAND, (payload) => {
|
|
8
9
|
const { metadata, label } = payload;
|
|
10
|
+
const hasCursorNode = editor.hasNodes([CursorNode]);
|
|
9
11
|
editor.update(() => {
|
|
10
12
|
const mentionNode = $createMentionNode(label, metadata);
|
|
11
13
|
$insertNodes([mentionNode]);
|
|
12
|
-
if ($isRootOrShadowRoot(mentionNode.getParentOrThrow()))
|
|
14
|
+
if ($isRootOrShadowRoot(mentionNode.getParentOrThrow())) {
|
|
15
|
+
const paragraph = $wrapNodeInElement(mentionNode, $createParagraphNode);
|
|
16
|
+
if (!hasCursorNode) paragraph.selectEnd();
|
|
17
|
+
}
|
|
18
|
+
if (hasCursorNode) {
|
|
19
|
+
const cursorNode = $createCursorNode();
|
|
20
|
+
mentionNode.insertAfter(cursorNode);
|
|
21
|
+
cursorNode.selectEnd();
|
|
22
|
+
}
|
|
13
23
|
});
|
|
14
24
|
return true;
|
|
15
25
|
}, COMMAND_PRIORITY_HIGH);
|
|
@@ -133,8 +133,7 @@ const SlashPlugin = class extends KernelPlugin {
|
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
135
|
const slashOptions = this.service?.getSlashOptions(triggerText);
|
|
136
|
-
|
|
137
|
-
if (text.length - lastIndex > maxLength || !slashOptions) {
|
|
136
|
+
if (!slashOptions) {
|
|
138
137
|
this.triggerClose();
|
|
139
138
|
return;
|
|
140
139
|
}
|
package/package.json
CHANGED