亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

向 CKeditor 中的鏈接添加類

向 CKeditor 中的鏈接添加類

Helenr 2021-10-14 14:05:45
我對在 ckeditor5 中向鏈接添加類有一些特定要求 - 我已經閱讀了文檔并嘗試了多種方法,但我仍然在努力實現我想要的。我的要求是:添加的所有鏈接(無論是使用鏈接 UI 還是通過粘貼)都必須分配一個類。defaultClass如果未分配類或分配的類不在有效類列表中,則應將該類設置為鏈接類必須在有效鏈接類列表中我建立了一個包含有效類列表的下拉列表并將其添加到鏈接界面這是我到目前為止的代碼:    const { editor } = this    const linkClasses = editor.config.get('link.options.classes')    const defaultLinkClass = editor.config.get('link.options.defaultClass')    editor.model.schema.extend('$text', { allowAttributes: 'linkClass' })    editor.conversion.for('downcast').attributeToElement({      model: 'linkClass',      view: (attributeValue, writer) => writer.createAttributeElement('a', { class: attributeValue }, { priority: 5 }),      converterPriority: 'low'    })    editor.conversion.for('upcast').attributeToAttribute({      view: {        name: 'a',        key: 'class'      },      model: 'linkClass',      converterPriority: 'low'    })
查看完整描述

3 回答

?
人到中年有點甜

TA貢獻1895條經驗 獲得超7個贊

使用callback在功能上decorators和內部callback,使用setTimeout函數來檢查的有效類列表urls

檢查jsFiddle。有關更多信息,請參閱鏈接中的 CKEditor5 手動裝飾器,請確認Link已安裝插件@ckeditor/ckeditor5-link

希望這會有所幫助。


查看完整回答
反對 回復 2021-10-14
?
DIEA

TA貢獻1820條經驗 獲得超3個贊

如果您要定義自定義類,請在字段配置中查找自定義編輯器 JS 樣式集并輸入 .js 文件的路徑。


在此文件中,您可以像這樣定義自定義樣式:


CKEDITOR.stylesSet.add

( 'mystyles', 

    [ 

        { name: 'Bootstrap Blockquote', 

          element: 'blockquote', 

          attributes: { 'class': 'blockquote' }

        },

    ] 

);

還要確保您啟用了樣式工具欄項


您還應該在此處使用編輯器的樣式功能查看樣式


查看完整回答
反對 回復 2021-10-14
  • 3 回答
  • 0 關注
  • 278 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號