···491 const pos = view.state.selection.from;
492 setMentionInsertPos(pos);
493494- // Get coordinates for the popup
495 const coords = view.coordsAtPos(pos - 1); // Position of the @
496- setMentionCoords({
497- top: coords.bottom + window.scrollY,
498- left: coords.left + window.scrollX,
499- });
0000000000000500 setMentionOpen(true);
501 }, [entityID]);
502
···491 const pos = view.state.selection.from;
492 setMentionInsertPos(pos);
493494+ // Get coordinates for the popup relative to the positioned parent
495 const coords = view.coordsAtPos(pos - 1); // Position of the @
496+497+ // Find the relative positioned parent container
498+ const editorEl = view.dom;
499+ const container = editorEl.closest('.relative') as HTMLElement | null;
500+501+ if (container) {
502+ const containerRect = container.getBoundingClientRect();
503+ setMentionCoords({
504+ top: coords.bottom - containerRect.top,
505+ left: coords.left - containerRect.left,
506+ });
507+ } else {
508+ setMentionCoords({
509+ top: coords.bottom,
510+ left: coords.left,
511+ });
512+ }
513 setMentionOpen(true);
514 }, [entityID]);
515
+12-1
components/Blocks/TextBlock/inputRules.ts
···192 return tr;
193 }),
194195- // Mention - @ at start of line or after space
196 new InputRule(/(?:^|\s)@$/, (state, match, start, end) => {
197 if (!openMentionAutocomplete) return null;
198 // Schedule opening the autocomplete after the transaction is applied
199 setTimeout(() => openMentionAutocomplete(), 0);
00000000000200 return null; // Let the @ be inserted normally
201 }),
202 ],
···192 return tr;
193 }),
194195+ // Mention - @ at start of line, after space, or after hard break
196 new InputRule(/(?:^|\s)@$/, (state, match, start, end) => {
197 if (!openMentionAutocomplete) return null;
198 // Schedule opening the autocomplete after the transaction is applied
199 setTimeout(() => openMentionAutocomplete(), 0);
200+ return null; // Let the @ be inserted normally
201+ }),
202+ // Mention - @ immediately after a hard break (hard breaks are nodes, not text)
203+ new InputRule(/@$/, (state, match, start, end) => {
204+ if (!openMentionAutocomplete) return null;
205+ // Check if the character before @ is a hard break node
206+ const $pos = state.doc.resolve(start);
207+ const nodeBefore = $pos.nodeBefore;
208+ if (nodeBefore && nodeBefore.type.name === "hard_break") {
209+ setTimeout(() => openMentionAutocomplete(), 0);
210+ }
211 return null; // Let the @ be inserted normally
212 }),
213 ],