···491491 const pos = view.state.selection.from;
492492 setMentionInsertPos(pos);
493493494494- // Get coordinates for the popup
494494+ // Get coordinates for the popup relative to the positioned parent
495495 const coords = view.coordsAtPos(pos - 1); // Position of the @
496496- setMentionCoords({
497497- top: coords.bottom + window.scrollY,
498498- left: coords.left + window.scrollX,
499499- });
496496+497497+ // Find the relative positioned parent container
498498+ const editorEl = view.dom;
499499+ const container = editorEl.closest('.relative') as HTMLElement | null;
500500+501501+ if (container) {
502502+ const containerRect = container.getBoundingClientRect();
503503+ setMentionCoords({
504504+ top: coords.bottom - containerRect.top,
505505+ left: coords.left - containerRect.left,
506506+ });
507507+ } else {
508508+ setMentionCoords({
509509+ top: coords.bottom,
510510+ left: coords.left,
511511+ });
512512+ }
500513 setMentionOpen(true);
501514 }, [entityID]);
502515
+12-1
components/Blocks/TextBlock/inputRules.ts
···192192 return tr;
193193 }),
194194195195- // Mention - @ at start of line or after space
195195+ // Mention - @ at start of line, after space, or after hard break
196196 new InputRule(/(?:^|\s)@$/, (state, match, start, end) => {
197197 if (!openMentionAutocomplete) return null;
198198 // Schedule opening the autocomplete after the transaction is applied
199199 setTimeout(() => openMentionAutocomplete(), 0);
200200+ return null; // Let the @ be inserted normally
201201+ }),
202202+ // Mention - @ immediately after a hard break (hard breaks are nodes, not text)
203203+ new InputRule(/@$/, (state, match, start, end) => {
204204+ if (!openMentionAutocomplete) return null;
205205+ // Check if the character before @ is a hard break node
206206+ const $pos = state.doc.resolve(start);
207207+ const nodeBefore = $pos.nodeBefore;
208208+ if (nodeBefore && nodeBefore.type.name === "hard_break") {
209209+ setTimeout(() => openMentionAutocomplete(), 0);
210210+ }
200211 return null; // Let the @ be inserted normally
201212 }),
202213 ],