【问题标题】:TinyMce allow HTML TagsTinyMce 允许 HTML 标签
【发布时间】:2015-10-09 23:06:04
【问题描述】:

我在 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: '+*[*]',
});

我想要一些引导元素(比如等等)

非常感谢我的朋友们=)

【问题讨论】:

  • 什么是“引导元素”?
  • 只是普通的 html(我正在使用引导框架)

标签: javascript tinymce


【解决方案1】:

由于 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' }
},

【讨论】:

  • 我认为我读过,有可能。我需要它,因为我将它用于 cms 页面。所以我的用户应该为责任设置引导 div
  • 嗯,有整页插件 (tinymce.com/wiki.php/Plugin:fullpage) - 好像就是你需要的那个
  • 您好,感谢您的链接。我想你不明白我的问题 :D 我不想添加 html / body。我只想添加 div 等等。但实际上 db 中的条目是 <div>而不是
    .
  • 在我的系统上运行良好,你能验证那些 '' 是在哪里转换成实体的吗?
  • 我认为 TinyMce 改变了它们。
猜你喜欢
相关资源
最近更新 更多
热门标签