简体   繁体   English

如何在ckeditor中定义自定义html标签

[英]How to define custom html tags in ckeditor

How can I define custom html tags in ckeditor. 如何在ckeditor中定义自定义html标签。

  • When user select a word eg Apple. 当用户选择单词时,例如Apple。
  • Then I want to replace this with profileTag Apple /profileTag". 然后,我要用profileTag Apple / profileTag替换它。
  • But if the selected word already has a tag then it should append the profile tag. 但是,如果所选单词已具有标签,则应附加配置文件标签。
  • For example if anchorTag Apple /anchorTag then after user selection it will be profileTag anchorTag Apple /anchorTag /profileTag. 例如,如果anchorTag Apple / anchorTag,则在用户选择后,它将是profileTag anchorTag苹果/ anchorTag / profileTag。

The above thing is working. 上面的东西正在工作。 But when I execute the below code the output is null in case of custom html tag like profile tag. 但是,当我执行以下代码时,对于自定义html标签(如配置文件标签),输出为null。

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

The problem is that CKeditor's advanced content filter is filtering out your custom tags ... you're going to have to configure the ACF to accept the custom tags your plugin is creating and inserting into the DOM. 问题在于CKeditor的高级内容过滤器正在过滤您的自定义标签...您将必须配置ACF以接受您的插件正在创建并插入DOM的自定义标签。 There are a couple ways this can be done. 有两种方法可以完成此操作。 The most basic would be to implement config.extraAllowedContent = 'profile' or whatever the name of your custom markup will be. 最基本的方法是实现config.extraAllowedContent = 'profile'或自定义标记的名称。 Otherwise you can work with the global CKEditor.filter object. 否则,您可以使用全局CKEditor.filter对象。 There's more documentation on the CKEDITOR.filter object here . 这里有关于CKEDITOR.filter对象的更多文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM