javascript - TinyMce 允许 HTML 标签

标签 javascript tinymce

我在 TinyMce 中使用 html 标签时遇到问题。

我尝试了不同的方法来完成这些工作。

TinyMce Docu 说的 使用[]包含所有元素和所有属性。

但是没有成功。

这是代码:

tinymce.init({
    selector: ".mytextarea",
    theme: "modern",
    language: "de",
    plugins : 'advlist autolink link images lists charmap print preview jbimages',
    toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
    relative_urls: true,
    valid_elements: '+*[*]',
});

我想要其中一些引导元素(例如等等)

非常感谢我的 friend =)

最佳答案

由于tinymce 使用自己的 iframe 以及自己的 head、html 和 body html 元素 - 您不能在内容中使用这些元素。

更新:这是我的tinymce基本配置

plugins: 'paste,searchreplace,style',    // and some more ....

dialog_type : "modal",

// Override inline_styles setting to force TinyMCE to produce deprecated contents
inline_styles: false,

// Theme options
theme_advanced_buttons3 : "",
theme_advanced_buttons4 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : false,

relative_urls: false,

gecko_spellcheck: true,

button_tile_map: true,

// disable drag und drop
disable_drag: true,

indentation: "0px",

// No resize handle an the editor itself
resize: false,

//turn on/off the inline resizing controls of tables and images in Firefox/Mozilla
object_resizing: false,
paste_strip_class_attributes : "none",
paste_remove_styles: true,
paste_convert_middot_lists: false,

// Default ab 3.0.1
forced_root_block: 'p',

// All characters will be stored in non-entity form except these XML default entities: & < > "
entity_encoding: "raw",

// This option controls if invalid contents should be corrected before insertion in IE. This option is disabled by default since it might be a bit slow. 
fix_nesting: true,

// This option should contain a comma separated list of element names to exclude from the content. Elements in this list will be removed when TinyMCE executes a cleanup.
invalid_elements: "strong,em,div",

// The valid_elements option defines which elements will remain in the edited text when the editor saves.
valid_elements: "@[id|class|title|style],"
+ "a[name|href|target|title|alt],"
+ "#p,-ol,-ul,-li,br,img[src|unselectable],-sub,-sup,-b,-i,-u,"
+ "-span[data-mce-type],hr",

valid_child_elements : "body[p,ol,ul]"
+ ",p[a|span|b|i|u|sup|sub|img|hr|#text]"
+ ",span[a|b|i|u|sup|sub|img|#text]"
+ ",a[span|b|i|u|sup|sub|img|#text]"
+ ",b[span|a|i|u|sup|sub|img|#text]"
+ ",i[span|a|b|u|sup|sub|img|#text]"
+ ",sup[span|a|i|b|u|sub|img|#text]"
+ ",sub[span|a|i|b|u|sup|img|#text]"
+ ",li[span|a|b|i|u|sup|sub|img|ol|ul|#text]"
+ ",ol[li]"
+ ",ul[li]",

formats: {
    bold : {inline : 'b' },  
    italic : {inline : 'i' },
    underline: { inline: 'u' }
},

关于javascript - TinyMce 允许 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32978300/

相关文章:

javascript - 对数组对象进行分组,使具有相似键的对象不会放入同一组中

php - 使用 tinymce 编辑器的问题

javascript - TinyMCE - 插入组合框和选定的值与格式

javascript - TinyMCE 返回没有 HTML 的内容

css - 将 CSS 样式添加到 WordPress 编辑器

javascript - 在 javascript 中使用原型(prototype)会对 ajax 调用和异步代码产生负面影响吗?

javascript - 如何在 Javascript DOM 更新后触发 CSS 布局重新计算?

javascript - Nuxt Vue 中的 Splidejs

javascript - Ajax 没有将数据完全发布到 php 文件

keyboard - 禁用 tinyMCE ctrl+s 快捷方式以启用此快捷方式以保存 ajax 内容