@lobehub/editor 1.9.0 → 1.9.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.
@@ -6,7 +6,7 @@ export var useStyles = createStyles(function (_ref) {
6
6
  var css = _ref.css,
7
7
  token = _ref.token;
8
8
  return {
9
- placeholder: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: none;\n user-select: none;\n\n position: absolute;\n inset-block-start: 0;\n\n margin-block: 0 !important;\n\n color: ", ";\n "])), token.colorTextDescription),
9
+ placeholder: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: none;\n user-select: none;\n\n position: absolute;\n inset-block-start: 0;\n\n margin-block: 4px;\n\n line-height: var(--lobe-markdown-line-height);\n color: ", ";\n letter-spacing: 0.02em;\n "])), token.colorTextDescription),
10
10
  placeholderContainer: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transform: translateY(-2px);\n "])))
11
11
  };
12
12
  });
@@ -1,5 +1,5 @@
1
1
  import { $wrapNodeInElement } from '@lexical/utils';
2
- import { $createParagraphNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from 'lexical';
2
+ import { $createParagraphNode, $createTextNode, $insertNodes, $isRootOrShadowRoot, COMMAND_PRIORITY_HIGH, createCommand } from 'lexical';
3
3
  import { $createMentionNode } from "../node/MentionNode";
4
4
  export var INSERT_MENTION_COMMAND = createCommand('INSERT_MENTION_COMMAND');
5
5
  export function registerMentionCommand(editor) {
@@ -8,10 +8,15 @@ export function registerMentionCommand(editor) {
8
8
  label = payload.label;
9
9
  editor.update(function () {
10
10
  var mentionNode = $createMentionNode(label, metadata);
11
- $insertNodes([mentionNode]); // Insert a zero-width space to ensure the image is not the last child
11
+ $insertNodes([mentionNode]);
12
+ // Ensure mention is inside a paragraph when inserted at root
12
13
  if ($isRootOrShadowRoot(mentionNode.getParentOrThrow())) {
13
- $wrapNodeInElement(mentionNode, $createParagraphNode).selectEnd();
14
+ $wrapNodeInElement(mentionNode, $createParagraphNode);
14
15
  }
16
+ // Insert a trailing text node and move caret into it to enable IME input
17
+ var trailingText = $createTextNode("\u200B");
18
+ mentionNode.insertAfter(trailingText);
19
+ trailingText.selectEnd();
15
20
  });
16
21
  return true;
17
22
  }, COMMAND_PRIORITY_HIGH // Priority
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/editor",
3
- "version": "1.9.0",
3
+ "version": "1.9.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",