从 TinyMCE 复制粘贴中剥离样式?
有没有办法通过从外部源(例如Word)复制+粘贴来去除进入微型MCE的特定标签?我想防止字体系列和图像标签被复制+粘贴,但字体大小等没有问题。
谢谢!
is there a way to strip specific tags from coming into tiny MCE through a copy+paste from an external source (e.g. Word)? I'd like to prevent font-family and image tags from being copy+pasted over, but have no problem with font-size etc.
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您无法真正阻止某人粘贴某些内容,因此我相信您最好的选择是通过调用表单提交上的函数或微小的 MCE 文本区域的 onchange 来过滤掉不需要的标签。然后您可以使用一些正则表达式替换来删除不需要的标签。
编辑:实际上有一个简单的方法。检查 TinyMCE 文档。
You can't really stop someone from pasting something, so I believe your best bet would be to filter out the unwanted tags by calling a function on form submit, or onchange of the tiny MCE textarea. Then you could use some regular expression replacement to get rid of the unwanted tags.
EDIT: Actually there is a simple way. check the TinyMCE documentation.
以下是类似 SO 问题的链接,其中详细描述了如何删除不需要的标签: TinyMCE Paste作为纯文本
Here is the link to a similar SO question with a detailed description of howto strip out unwanted tags: TinyMCE Paste As Plain Text
我不知道这会有多大用处,但您可能想看看这个 jQuery 插件,它允许您过滤标签并从您粘贴的文本中进行归因。
FilteredPaste.js - 用于过滤和过滤的 jQuery 插件清理粘贴的输入
I don't know how useful this will be, but you might want to take a look at this jQuery plugin which allows you to filter tags and attributed from the text your are pasting.
FilteredPaste.js - A jQuery Plugin To Filter & Clean Pasted Input
尽管“您确实无法阻止某人粘贴某些内容”,但您可以转换您的网络应用程序插入到 TinyMCE 文本框(或任何其他输入)中的内容。
text/html
字符串。粘贴
默认操作。看看这个:
Although "You can't really stop someone from pasting something" indeed, you can transform what your web app inserts into your TinyMCE textbox (or any other input).
text/html
string with DOMParser.paste
default action.Check this out: