Fix @-mention tab completion cursor positioning

After tab-completing a mention, the cursor was placed before the
completion instead of after it. The root cause: Lexical's DOM
reconciliation after document.execCommand("insertText") would lose
the browser-set cursor position. Added requestAnimationFrame-based
cursor repositioning that first tries the original text node, then
falls back to searching for the mention text in the DOM.

Also normalizes editor content padding for consistent mention dropdown
positioning.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-20 16:07:37 -06:00
parent 9906a5ba06
commit 95f0d36adc
2 changed files with 71 additions and 17 deletions

View File

@@ -237,12 +237,12 @@
.paperclip-mdxeditor .mdxeditor-root-contenteditable {
min-height: 2.5rem;
padding: 0.375rem 0.625rem;
padding: 0;
line-height: 1.5;
}
.paperclip-mdxeditor--borderless .mdxeditor-root-contenteditable {
padding: 0;
.paperclip-mdxeditor [class*="_contentEditable_"] {
padding: 0.375rem 0.625rem !important;
}
.paperclip-mdxeditor--borderless [class*="_contentEditable_"] {
@@ -250,17 +250,12 @@
}
.paperclip-mdxeditor [class*="_placeholder_"] {
padding: 0.375rem 0.625rem;
font-family: inherit;
font-size: 0.875rem;
line-height: 1.5;
color: var(--muted-foreground);
}
.paperclip-mdxeditor--borderless [class*="_placeholder_"] {
padding: 0;
}
.paperclip-mdxeditor-content {
font-family: inherit;
font-size: inherit;