AIO 編輯器

Mention

@ 提及(opt-in)。

@ 提及節點與 suggestion 選單。不在預設集合——須經 config.include 啟用,並提供 suggestion.onRender 實作(選單 UI 由 consumer 全權決定,見 AioEditor 之 Mention demo)。自製變體額外支援 htmlData 屬性(data-* 透傳)。

  • config key:AioEditorCoreExtension.Mention
  • 來源:自製(基於 @tiptap/extension-mention)

載入途徑:不在預設集合——經 `include` 啟用。按鈕未宣告但要保留能力 → include: [AioEditorCoreExtension.Mention]。

排除影響(exclude: [Mention]): 無按鈕與依賴者受影響; 以 extraExtensions 補上同名 extension(mention)即為替換。

選項

欄位型別預設值說明
HTMLAttributesRecord<string, any>{ class: 'editor-mention' }節點之 HTML 屬性
deleteTriggerWithBackspacebooleanfalseBackspace 刪除節點時是否還原觸發字元
renderText(props) => string觸發字元+label純文字輸出格式
renderHTML(props) => DOMOutputSpecspan 包觸發字元+labelHTML 輸出格式
suggestionOmit<SuggestionOptions, "editor">mentionSuggestion({ … })suggestion 行為(觸發字元、items、選單渲染 hooks)

suggestion 選單 hooks

選單以 mentionSuggestion(hooks) 建立,定位由 floating-ui 處理,渲染交給 consumer:

interface MentionSuggestionRuntimeEvent {  /** 必要:建立選單,回傳選單元素 */  onRender: (props: unknown, mountEl?: HTMLElement) => HTMLElement | void  /** 自訂掛載位置(預設掛編輯器容器) */  onAppend?: (target: HTMLElement, componentEl?: HTMLElement) => void  /** query 變更時更新選單 */  onUpdate?: (props: unknown, componentEl?: HTMLElement) => void  /** 鍵盤導航(回傳 true 表示已處理) */  onKeyDown?: (props: unknown, componentEl?: HTMLElement) => boolean  /** 選單關閉清理 */  onDestroy?: (componentEl?: HTMLElement) => void}

搭配 suggestion.items: ({ query }) => item[] 提供候選資料;選單內以 props.command({ id, label }) 插入節點。