<bdo id='bHFuo'></bdo><ul id='bHFuo'></ul>
      <legend id='bHFuo'><style id='bHFuo'><dir id='bHFuo'><q id='bHFuo'></q></dir></style></legend>

    1. <small id='bHFuo'></small><noframes id='bHFuo'>

      <tfoot id='bHFuo'></tfoot>

      <i id='bHFuo'><tr id='bHFuo'><dt id='bHFuo'><q id='bHFuo'><span id='bHFuo'><b id='bHFuo'><form id='bHFuo'><ins id='bHFuo'></ins><ul id='bHFuo'></ul><sub id='bHFuo'></sub></form><legend id='bHFuo'></legend><bdo id='bHFuo'><pre id='bHFuo'><center id='bHFuo'></center></pre></bdo></b><th id='bHFuo'></th></span></q></dt></tr></i><div id='bHFuo'><tfoot id='bHFuo'></tfoot><dl id='bHFuo'><fieldset id='bHFuo'></fieldset></dl></div>

        CKEditor,初始化使用 insertElement 添加的小部件

        时间:2023-09-07
        <tfoot id='vz2Nr'></tfoot>

          1. <i id='vz2Nr'><tr id='vz2Nr'><dt id='vz2Nr'><q id='vz2Nr'><span id='vz2Nr'><b id='vz2Nr'><form id='vz2Nr'><ins id='vz2Nr'></ins><ul id='vz2Nr'></ul><sub id='vz2Nr'></sub></form><legend id='vz2Nr'></legend><bdo id='vz2Nr'><pre id='vz2Nr'><center id='vz2Nr'></center></pre></bdo></b><th id='vz2Nr'></th></span></q></dt></tr></i><div id='vz2Nr'><tfoot id='vz2Nr'></tfoot><dl id='vz2Nr'><fieldset id='vz2Nr'></fieldset></dl></div>
          2. <legend id='vz2Nr'><style id='vz2Nr'><dir id='vz2Nr'><q id='vz2Nr'></q></dir></style></legend>
          3. <small id='vz2Nr'></small><noframes id='vz2Nr'>

              <bdo id='vz2Nr'></bdo><ul id='vz2Nr'></ul>

                  <tbody id='vz2Nr'></tbody>
                  本文介绍了CKEditor,初始化使用 insertElement 添加的小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我创建了一些小部件,它们在初始启动时加载正常,但我通过以下方式将更多此类小部件添加到编辑器:

                  I have some widgets created, they on initial startup they load fine, but i add more of this type of widget to the editor through:

                  ckeditorInstance.insertElement(
                          CKEDITOR.dom.element.createFromHtml('<html></html>'));
                  

                  它插入得很好,但 ckeditor 无法识别作为小部件插入的元素,因此小部件可编辑字段没有像应有的那样启用.

                  It inserts just fine, but the ckeditor does not recognize the element inserted as a widget, so the widget editable fields are not getting enabled like they should.

                  有什么方法可以让 ckeditor 重新扫描其内容以初始化它尚未初始化的任何新小部件?

                  Is there any way to make ckeditor do a rescan of its content to initialize any new widgets that it has not already initialized?

                  推荐答案

                  数据格式

                  首先 - 小部件的数据格式(小部件如何在数据中表示)和内部格式(它如何在编辑器中表示)是分开的.您可能熟悉 upcast和 downcast 函数 - 它们使这些格式之间的转换(向上转换意味着将数据格式转换为内部格式).

                  Data formats

                  First of all - there's a separation for data format of a widget (how widget is represented in data) and internal format (how it is represented in editor). You may be familiar with the upcast and downcast functions - they make the transition between those formats (upcasting means transforming data format to internal format).

                  仅当数据 string 被处理时,向上转换和向下转换才有效,但如果您使用 editor#insertElement 插入内容,则没有处理,因此没有向上转换.

                  Upcasting and downcasting work only if data string is processed, but if you insert content using editor#insertElement there's no processing, so there's no upcasting.

                  您有两种解决方案:

                  1. 使用 editor#insertHtml 而不是 editor#insertElement.您的小部件将在插入之前向上转换,因此它会以良好的格式插入.

                  1. Use editor#insertHtml instead of editor#insertElement. Your widget will be upcasted before insertion, so it will be inserted in a good format.

                  自己负责向上转换(如果需要)并使用 editor#insertElement.

                  Take care of upcasting (if needed) yourself and use editor#insertElement.

                  正在初始化

                  这是小部件生命的第一步 - 它必须被插入.二是被初始化.

                  Initializing

                  This was a first step of widget's life - it has to be inserted. Second is to be initialized.

                  1. 目前有一个 错误(它会两周内修复),由 insertHtml 方法插入的小部件未初始化.因此,此时,在使用 editor#insertHtml 插入小部件后,您需要调用:

                  1. There's a bug currently (it will be fixed in two weeks), that widgets inserted by the insertHtml method are not initialized. So, at this moment, after inserting widget with editor#insertHtml you need to call:

                  editor.widgets.checkWidgets()

                  如果您使用 editor#insertElement,您需要注意初始化小部件.要进行该调用:

                  If you use editor#insertElement you need to take care of initializing widget. To do that call:

                  editor.widgets.initOn(元素,'widgetName')

                  在这两种情况下插入后初始化小部件.

                  查看 Widgets API 了解更多详情.

                  Check out the Widgets API for more details.

                  另请参阅我的回答 解释如何知道一个元素是否是一个小部件以及如何将它们插入到编辑器中.

                  这篇关于CKEditor,初始化使用 insertElement 添加的小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  1. <legend id='9amHr'><style id='9amHr'><dir id='9amHr'><q id='9amHr'></q></dir></style></legend>

                      <i id='9amHr'><tr id='9amHr'><dt id='9amHr'><q id='9amHr'><span id='9amHr'><b id='9amHr'><form id='9amHr'><ins id='9amHr'></ins><ul id='9amHr'></ul><sub id='9amHr'></sub></form><legend id='9amHr'></legend><bdo id='9amHr'><pre id='9amHr'><center id='9amHr'></center></pre></bdo></b><th id='9amHr'></th></span></q></dt></tr></i><div id='9amHr'><tfoot id='9amHr'></tfoot><dl id='9amHr'><fieldset id='9amHr'></fieldset></dl></div>

                          <tbody id='9amHr'></tbody>

                        <small id='9amHr'></small><noframes id='9amHr'>

                          <bdo id='9amHr'></bdo><ul id='9amHr'></ul>
                          <tfoot id='9amHr'></tfoot>