简体   繁体   English

将 sharejs 与 contenteditable 元素一起使用

[英]Using sharejs with contenteditable elements

Is there a way to use sharejs together with contenteditable-Elements like <div contenteditable="true">Content <b>with html</b></div> with HTML-Content in it?有没有办法将sharejs与 contenteditable-Elements 一起使用,例如<div contenteditable="true">Content <b>with html</b></div>和 HTML-Content ?

Or are there other best practises for Operational Transformation (OT) in conjunction with HTML-Content or Rich-Text?或者还有其他与 HTML 内容或富文本结合的操作转换 (OT) 的最佳实践吗? How could this be done with node.js?这怎么能用 node.js 来完成?

It is possible to define an OT algorithm on trees such as DOM trees.可以在 DOM 树等树上定义 OT 算法。 I've written a shareJS-compliant OT type for DOM operations: https://github.com/marcelklehr/dom-ot我为 DOM 操作编写了一个符合 shareJS 的 OT 类型: https : //github.com/marcelklehr/dom-ot

Use it with caution, though.不过请谨慎使用。 Even though it works, the question is if syncing the raw DOM is a good idea and really what you want.尽管它有效,但问题是同步原始 DOM 是否是一个好主意并且真的是您想要的。 Many browsers have a variety of quirks regarding their DOM implementation and especially in handling contenteditable elements.许多浏览器在它们的 DOM 实现方面有各种各样的怪癖,尤其是在处理 contenteditable 元素方面。

A different approach would be to rely on an in-browser rich text editor to provide OT interoperability.另一种方法是依靠浏览器内的富文本编辑器来提供 OT 互操作性。 The CKeditor team for example is currently devising such a feature for v5.例如,CKeditor 团队目前正在为 v5设计这样的功能 ProseMirror advocates and supports a rebasing and transformation scheme similar to that found in version control systems (the difference to OT is that replicas are not guaranteed to converge if you apply edits in different orders). ProseMirror提倡并支持类似于版本控制系统中的变基和转换方案(与 OT 的不同之处在于,如果您以不同的顺序应用编辑,则不能保证副本会收敛)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM