插入表单时如何删除 Word 标记垃圾?

发布于 2024-07-10 23:25:52 字数 235 浏览 7 评论 0原文

我正在用 PHP 构建一个 CMS,我担心的一个问题是用户必须从现有的 Word(和 Excel,但不用担心)文档中填写数据。 现在,我已经看到了当他们不小心从 Word 复制并粘贴到文本区域时会发生什么:数据库充满了垃圾标记。

现在,我当然可以自己删除所有标记,但我必须首先开始学习它。 所以我问你:你是否测试过一些功能 - 常见的插件(tinyMCE、FCKeditor 等)在这里有帮助? 侵入性最小的解决方案的奖励。

I'm building a CMS in PHP and one dread I have is that the users will have to fill the data in from existing Word (and Excel, but nevermind that) documents. Now, I've seen what happens when they carelessly copy and paste from Word to a textarea: the database got filled with crap markup.

Now, I could certainly strip all markup myself, but I'd have to start learning about it first. So I ask you: have you tested some functionality - plugins of the usual suspects (tinyMCE, FCKeditor, etc) that helps here? Bonus for the least intrusive solution.

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

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

发布评论

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

评论(4

榕城若虚 2024-07-17 23:25:52

遗憾的是,我使用过的大多数 HTML 编辑器控件:

  1. 有一个按钮可以去除标记的各种元素(单词、html、脚本等)
  2. 通过 JavaScript 去除粘贴时的所有标记。

如果你把它留给一个按钮,那么通常非技术用户会忘记按下它,因为他们不(有些人会说“不应该”)关心它:(

稍微玩弄一下常规表达式(现在你遇到了另一个问题;))你可以做类似于2的事情,但只是针对word xml。

Sadly most of the HTML editor controls I've used either:

  1. Have a button to strip out various elements of mark up (word, html, script, etc)
  2. Strip out all markup on paste via JavaScript.

If you leave it to a button, then generally the non-technical users will forget to press it because they don't (some would say "shouldn't have to") care about it :(

With a bit of playing around with Regular Expressions (now you have another problem ;)) you could do something similar to 2 but just for word xml.

坏尐絯 2024-07-17 23:25:52

我发现 FCKEditor 可以处理从 Word 文档中拉出和抛出的文本,比tinyMCE 好得多。

I have found FCKEditor to handle text yanked and thrown at it from Word documents, much better than tinyMCE.

断肠人 2024-07-17 23:25:52

好的,我发现 TinyMCE 插件 显然可以满足我的需求。 尽管如此,这仍然要求用户按下按钮进行粘贴,这有点不太理想。 还有更好的吗?

Ok, I found a plugin for TinyMCE that apparently does what I wanted. Still, this asks for the users to press a button to paste, which is a bit less than ideal. Anything better?

别忘他 2024-07-17 23:25:52

ASP.NET? TelerikRadEditor 对我来说效果很好

ASP.NET? Telerik's RadEditor has worked very well for me

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