0

我有一个用于 aloha-editor 的表格插件,它在创建新表格时会提供一些额外的样式和用于选择行和列的额外单元格。创建表格时,会将事件附加到它们,当编辑器失去焦点时删除额外的样式,这样它们就不会出现在最终的 HTML 中。目前这一切都很好。

我遇到的问题是另一个插件可以让您编辑编辑器的 HTML 源代码。在这种情况下,它会<textarea>在灯箱中创建一个<div>。然后它获取编辑器内容并将其放置在您可以编辑源代码的文本区域中。一旦源代码发生变化,主页上的编辑器内容就会被替换为 textarea 版本。

接下来发生的是,附加到表的事件丢失了,因为表已被新表替换。因此,额外的表格单元格和样式保留在表格上。

我不确定从这里开始的最佳行动方案是什么。

表插件如何绑定到事件的示例是:

Aloha.bind('aloha-editable-activated', function (__event__, data) {
            that._splitcellsButton.enable(false);
            that._mergecellsButton.enable(false);
            that._splitcellsRowButton.enable(false);
            that._mergecellsRowButton.enable(false);
            that._splitcellsColumnButton.enable(false);
            that._mergecellsColumnButton.enable(false);

            data.editable.obj.find('table').each(function () {
                var registry = TablePlugin.TableRegistry;
                for (var i = 0; i < registry.length; i++) {
                    if (registry[i].obj.attr('id') === jQuery(this).attr('id')) {
                        registry[i].activate();
                        return true;
                    }
                }

                // Because table this is a new table that is not yet in the
                // registry.
                createNewTable(this);
            });

        });
4

0 回答 0