【问题标题】:TinyMCE with contenteditableTinyMCE with contenteditable
【发布时间】:2013-02-21 16:26:29
【问题描述】:

我读到 TinyMCE 支持 contenteditable 而不是 textarea / iframe 版本

来源:

http://www.tinymce.com/forum/viewtopic.php?id=22164

上面写着:

我发现了一个名为“content_editable”的配置属性 TinyMCE v3.5.2 的源代码。此标志可防止 iframe 正在渲染。

Javascript

tinyMCE.init({
    // General options
    mode : "exact",
    element : "my_id",
    theme : "advanced",
    plugins : "table,inlinepopups",
editor_selector : "tinymce",

    // Theme options
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,formatselect,code",
    theme_advanced_buttons2 : "",
    theme_advanced_buttons3 : "",
    theme_advanced_buttons4 : "",
    theme_advanced_toolbar_location : "external",
    theme_advanced_toolbar_align : "left",
    theme_advanced_resizing : true,
    content_editable: true,

    // Example content CSS (should be your site CSS)
    content_css : "/js/tinymce/examples/css/content.css",

    // Style formats
    style_formats : [
            {title : 'Bold text', inline : 'b'},
            {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
            {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
            {title : 'Example 1', inline : 'span', classes : 'example1'},
            {title : 'Example 2', inline : 'span', classes : 'example2'},
            {title : 'Table styles'},
            {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
    ],

    formats : {
            alignleft : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'left'},
            aligncenter : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'center'},
            alignright : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'right'},
            alignfull : {selector : 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li,table,img', classes : 'full'},
            bold : {inline : 'span', 'classes' : 'bold'},
            italic : {inline : 'span', 'classes' : 'italic'},
            underline : {inline : 'span', 'classes' : 'underline', exact : true},
            strikethrough : {inline : 'del'},
            customformat : {inline : 'span', styles : {color : '#00ff00', fontSize : '20px'}, attributes : {title : 'My custom format'}}
    },
});

HTML

<div class="tinymce" id="my_id" contenteditable="true">test</div>

我改变了什么

发生了这种情况

什么都没有。脚本运行并没有给我任何错误。有什么提示吗?

【问题讨论】:

  • +1 有趣的 tinymce 论坛主题

标签: javascript tinymce wysiwyg contenteditable


【解决方案1】:

TinyMCE 4 已正式支持此功能 - 请参阅“内联”示例:http://www.tinymce.com/tryit/inline.php

【讨论】:

    【解决方案2】:

    没有官方的configuration parameter叫做'content_editable', 但我在来源中找到了它。

    tinymce 确实使用 contenteditable iframe 来编辑其内容。 我关注了讨论,但正如 Spoke 所说,会有很多权衡,而且对于新的浏览器,你永远无法确定这样的编辑器会如何反应。 我建议不要使用这样的编辑器。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-03-10
    • 2016-10-21
    • 2014-03-22
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 2019-01-12
    • 1970-01-01
    相关资源
    最近更新 更多