在保存到 CKEditor 插件之前立即更新编辑器内容

发布于 2024-08-21 16:16:32 字数 182 浏览 1 评论 0原文

我正在为 CKEditor 开发一个插件,需要在保存之前立即对编辑器的内容进行一些更改。在 FCKeditor 中,我使用 OnAfterLinkedFieldUpdate 事件实现了这一点,但我还没有找到在 CKEditor 中执行此操作的等效方法。我本来希望有一个合适的活动可以参加,但似乎没有。有谁知道这样做的方法吗?

I am developing a plug-in for CKEditor that needs to make some changes to the editor's content immediately before saving. In FCKeditor, I achieved this using the OnAfterLinkedFieldUpdate event but I haven't yet been able to find an equivalent way of doing this in CKEditor. I had hoped there would be a suitable event to hook into but there doesn't appear to be. Does anyone know of a way of doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长安忆 2024-08-28 16:16:32

您可以使用 getData 事件,但要小心,因为它也会在内部使用时触发。

我已提交 http://dev.fckeditor.net/ticket/5254 来重新创建之前的事件

You could use the getData event, but be careful because it's fired also for internal uses.

I've filed http://dev.fckeditor.net/ticket/5254 to recreate the previous event

天煞孤星 2024-08-28 16:16:32

由于上面的链接实际上没有关于替代 OnAfterLinkedFieldUpdate 事件的解决方案,我写了一篇关于如何解决它的简短文章。

形式如下:

<form id="my_form" action="submit.php" method="post" name="my_form">
   <textarea id="my_text" name="my_text"></textarea>
   <input id="submitForm" type="submit" name="submitForm" value="Submit" />
</form>

JavaScript:

var formSubmitted = false;
$("#submitForm").live('click', function(event) {
    if (formSubmitted === true) {
        formSubmitted = false;
        return;
    }
    event.preventDefault();
    //put here function to edit content == OnAfterLinkedFieldUpdate
    var editor = CKEDITOR.instances.my_text;
    var html = editor.getData();
    html.replace(searchvalue, newvalue);
    editor.setData(html);
    formSubmitted = true;
    $(this).trigger('click');
});

代码为 此处

As the link above doesn't really have the solution on substitude OnAfterLinkedFieldUpdate event I have writen a short post on how to go around it.

Here is the form:

<form id="my_form" action="submit.php" method="post" name="my_form">
   <textarea id="my_text" name="my_text"></textarea>
   <input id="submitForm" type="submit" name="submitForm" value="Submit" />
</form>

JavaScript:

var formSubmitted = false;
$("#submitForm").live('click', function(event) {
    if (formSubmitted === true) {
        formSubmitted = false;
        return;
    }
    event.preventDefault();
    //put here function to edit content == OnAfterLinkedFieldUpdate
    var editor = CKEDITOR.instances.my_text;
    var html = editor.getData();
    html.replace(searchvalue, newvalue);
    editor.setData(html);
    formSubmitted = true;
    $(this).trigger('click');
});

The code is here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文