【问题标题】:TinyMCE is adding &nbsp instead of the space when using the word pasteTinyMCE 在使用 paste 一词时添加 &nbsp 而不是空格
【发布时间】:2012-08-28 04:19:41
【问题描述】:

我正在使用 TinyMCE 编辑器和 word 粘贴功能。

我的问题是,当我有空格时,tinyMCE 将它们转换为 &nbsp,我想保留正常的空格。

是否有可以在 tinyMCe.init 中使用的过滤功能或类似功能?

谢谢。

【问题讨论】:

    标签: tinymce


    【解决方案1】:

    您是否尝试过添加: entity_encoding: 'raw' 在初始化 tinyMce 时?它对我有帮助。

    问候。

    【讨论】:

      【解决方案2】:

      我找到了一个灵魂,我不确定那是正确的,但它有效。在 tinyMCE.init 中,我添加了:

      paste_auto_cleanup_on_paste : true,
          paste_postprocess : function(pl, o) {
              // remove extra line breaks
              o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " ");
          }
      

      这是整个 tinyMCE 初始化:

      function addTinyMCE_Authors_AffiliationsWord() {
          jQuery('#dialog-authors_affiliations_parsing').tinymce({
              script_url: '/js/tiny_mce_3.2.7_jquery/jscripts/tiny_mce/tiny_mce.js',
              width: "800px",
              height: "250px",
              mode: "textarea",
              theme : "advanced",
              plugins : "paste",
              // Theme options
              theme_advanced_buttons1 : "pasteword",
              theme_advanced_buttons2 :"",
              theme_advanced_buttons3 :"",
              theme_advanced_buttons4 :"",
              theme_advanced_toolbar_location : "bottom",
              valid_elements : "p",
              paste_auto_cleanup_on_paste : true,
              paste_postprocess : function(pl, o) {
                  // remove &nbsp
                  o.node.innerHTML = o.node.innerHTML.replace(/ /ig, " ");
               }
           });
      }
      

      享受...

      【讨论】:

      • 如果单词之间有多个空格,并且将 nbsp 更改为常规空格(未定义正确的 css),则多个空格将呈现为单个空格,这不是一个可行的解决方案。
      猜你喜欢
      • 2015-03-03
      • 1970-01-01
      • 1970-01-01
      • 2010-12-06
      • 2014-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多