簡體   English   中英

如何在ckeditor中定義自定義html標簽

[英]How to define custom html tags in ckeditor

如何在ckeditor中定義自定義html標簽。

  • 當用戶選擇單詞時,例如Apple。
  • 然后,我要用profileTag Apple / profileTag替換它。
  • 但是,如果所選單詞已具有標簽,則應附加配置文件標簽。
  • 例如,如果anchorTag Apple / anchorTag,則在用戶選擇后,它將是profileTag anchorTag蘋果/ anchorTag / profileTag。

上面的東西正在工作。 但是,當我執行以下代碼時,對於自定義html標簽(如配置文件標簽),輸出為null。

var current_selected_element = editor.getSelection()。getSelectedElement(); 的console.log(current_selected_element);

問題在於CKeditor的高級內容過濾器正在過濾您的自定義標簽...您將必須配置ACF以接受您的插件正在創建並插入DOM的自定義標簽。 有兩種方法可以完成此操作。 最基本的方法是實現config.extraAllowedContent = 'profile'或自定義標記的名稱。 否則,您可以使用全局CKEditor.filter對象。 這里有關於CKEDITOR.filter對象的更多文檔

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM