AIO 編輯器
Link
超連結 mark。
超連結標記(a 元素)。游標位於連結內時會出現 LinkTips bubble(開啟 / 編輯 / 移除)。
- config key:
AioEditorCoreExtension.Link - 來源:
@tiptap/extension-link
載入途徑:跟隨 features 宣告:Link、UnLink。按鈕未宣告但要保留能力 → include: [AioEditorCoreExtension.Link]。
排除影響(exclude: [Link]): 按鈕 Link、UnLink 將自動隱藏; 以 extraExtensions 補上同名 extension(link)即為替換。
選項
| 欄位 | 型別 | 預設值 | 說明 |
|---|---|---|---|
openOnClick | boolean | false | 編輯中點擊連結即開啟 |
linkOnPaste | boolean | true | 選取文字時貼上 URL 自動成連結 |
autolink | boolean | true | 輸入 URL 自動轉為連結 |
protocols | (string 或 { scheme, optionalSlashes })[] | [] | 額外允許之協定 |
defaultProtocol | string | 'http' | autolink 之預設協定 |
HTMLAttributes | Record<string, any> | { target: '_blank', rel: 'noopener noreferrer nofollow', class: null } | 渲染輸出時附加之 HTML 屬性 |
isAllowedUri | (url, ctx) => boolean | 依 protocols 驗證 | URL 白名單驗證 |
validate | (url) => boolean | 非空即通過 | autolink 前之驗證 |
shouldAutoLink | (url) => boolean | 非空即通過 | 已通過驗證後是否自動成連結 |
Commands
| Command | 說明 |
|---|---|
setLink({ href, target? }) | 套用連結 |
toggleLink({ href }) | 切換連結 |
unsetLink() | 移除連結 |
覆寫範例
const config: AioEditorConfig = { extensionsConfig: { Link: { HTMLAttributes: { target: '_self', rel: null } } }}