使用 jscript 跟踪对网页字段所做的更改?
我们有一位客户向我们即将启动的项目添加了新的“要求”,这让我们有点困惑。从最终用户的角度来看,这很简单,但作为开发人员,我不知道如何实现它!
我们的用户想要的是一个网络表单文本框(最好是富文本编辑器,例如 CKEditor)来跟踪用户对内容所做的更改。请注意,这并不是为了跟踪是否进行了更改,而是为了实际突出显示这些更改。基本上他们是在追求 Microsoft Word 的“跟踪更改”功能!
这个想法是,当请求在用户之间传递时,如果一个用户更改了包含大量文本的文本框,则下一个用户将能够轻松识别更改的内容。
我很想听听是否有人做过类似的事情,或者有人对它是否或如何可能有什么想法?
We've had a a client add a new "requirement" to a project we're about to start and it's thrown us a little bit. From the end users perspective it's simple, but as a developer I have no idea how to implement it!
What our user would like is for a web form text box (ideally a rich text editor, such as CKEditor) to track the changes a user makes to the content. Note this is not to track if a change has been made but to actually highlight those changes. Basically they're after Microsoft Word's "Track Changes" feature!
The idea is as a request goes between users if one users alters a text box containing a large amount of text the next user will be easily able to identify what's changed.
I'd love to hear if anybody has ever done something similar or anybody's thoughts on if or how it may be possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
有人已经在这里发布了一个很好的答案:
如何突出显示一个文本段落与另一个文本段落中的更改/差异?
Some one already posted an excellent answer here:
How to highlight changes/difference in one text paragraph from the other?
嗯......好吧,你可以将盒子的内容存储在一个变量中,然后使用 diff 算法(肯定有一些)来检查 onChange 和格式的更改是否适当,但只会在用户时显示差异在框外点击。这样就足够了吗?如果没有,您可以将 onkeypress 事件与 onkeyup 事件进行比较,并对差异应用格式?
Hmmm... well you could store the contents of the box in a variable, then use a diff algorithm (there must be some out there, surely) to check the changes onChange and format appropriately, but will only display the difference when the user clicks outside the box. Will that be good enough? If not, you could compare the onkeypress event with the onkeyup event, and apply formatting to the difference?
那么,您需要某种内容管理解决方案。它需要具有版本控制,以便您可以存储内容的不同版本。如果您的内容只是文本,那么进行差异并不难。如果它以某种方式构建(HTML 或其他不同于文本的格式),则可能很难识别更改。
我认为在后一种情况下,您可以使用不可见标签标记新文本,例如
编辑器将突出显示的
。您还可以为已删除的文本创建标签。您可以不突出显示文本,也不将删除显示为选项。Well, you need some kind of content management solution for that. It needs to have versioning so you can store different versions of the content. If your content is just text it won't be hard to do diff. If it is structured in some way (HTML or other format different from text) it might be pretty hard to identify changes.
I think in the latter case you could mark new text with invisible tags, something like
<edition version="1.0"> </edition>
that the editor will highlight. You could also make tag for deleted text. And you could just not highlight the text and don't show the deletions as an option.