gpt4 book ai didi

jquery - 在临时 div 包装器中包装短代码以进行编辑,然后在保存内容之前将其删除

转载 作者:太空宇宙 更新时间:2023-11-03 18:47:31 27 4
gpt4 key购买 nike

我正在开发一个短代码预览过滤器,我将所有短代码包装在 CSS 分类的 div 中,这些 div 仅供在内容位于 tinyMCE 编辑器中时查看。

我面临的第一个挑战是如何在保存文档之前从标记中去除包装 div。

第二个挑战是每次保存后编辑器中出现短代码时如何重新应用包装器。

我正在寻找使用 jQuery 在加载和保存例程期间解析和过滤 TinyMCE 编辑器内容的示例。

最佳答案

The first challenge I have is how to strip out the wrapper divs from the markup prior to the document being saved.

这个很简单。给你的 wrapperDivs 一个特殊的类

var ed = tinymce.get('my_editor_id');
$(ed.getBody()).find('div.my_special_class').each(function(){
$(this).replaceWith(this.innerHTML);
});

The second challenge is how to reapply the wrappers each time a shortcode appears within the editor after a save.

这个比较难回答。这取决于检测短代码的难度。

关于jquery - 在临时 div 包装器中包装短代码以进行编辑,然后在保存内容之前将其删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15953334/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com