操作转换图书馆?

我正在寻找一个库,可以让我在多个用户之间实时同步文本(谷歌文档)。

我偶然发现了一种操作转换似乎很符合我的需要。话虽如此,我理解 OT 的要点,但不理解 OT 的数学和实现。

因此,我想知道是否有一个拖放 Javascript 库可以连接到一个文本区域,生成转换,然后允许我将这些转换应用到另一个客户机上?

(我已经得到了 Etherpad 来源,但我不能使头或尾了它。如果有人能够指出如何利用 Etherpad 的 OT 实现,那将是非常棒的!)

36071 次浏览

I think that parts of Google Wave's OT implementation are Open Source (and more parts are coming).

I'm not sure if this is what you are looking for, but an alternative to OT is Differential Synchronization:

You could talk to the guys at Cedanet. Though Ceda is closed source and no free trial is available on their web site. I have been involved in the development of Ceda and continue to work with it in commercial projects, so I might be able to provide some feedback/advice if you head down this path.

OT Libraries:

Within the HWIOS websocket project, i've succesfully used a combo of both(py-infinote at the serverside, jinfinote at clientside) to sync document states.

Also check out these Javascript Libraries:

I thing etherpad.org with etherpad lite is superior to other solutions.

With a js client lib (Strophe.js) you could use a free XMPP server (like jabber.org) along with my client-side OT lib (JSOTTEST) to build a complete client-server system.

I will submit the src of a demo client-server chat system when I have time to revise the code.

One of the ex-Wave engineers has released a Coffeescript implementation of its collaborative editing algorithm called ShareJS, now named ShareDB.

Npm has some nice ot libraries for node.js:

  • https://npmjs.org/package/ot -- adapters for codemirror and ace built in as well as a client and server implementation
  • https://npmjs.org/package/changesets -- plain ot library usable in node and the browser; allows you to build 'changesets' (essentially diffs) that you can send around, transform against each other and apply on a document

We're building a collaborate editor that combines Operational Transformation with versioning. That way we can support both, offline and online collab. We released our own OT library yesterday as part of our open source stack.

http://interior.substance.io/modules/operator.html

We've also contributed a library for versioning.

http://interior.substance.io/modules/chronicle.html

The ot.js library https://github.com/Operational-Transformation/ot.js may be useful for multi-user scenarios.

I'll summarize the solutions I found.

  • Operational Transformation: E.g.

    • Google Wave OT. The approach is based on the so called Jupiter approach.
    • ShareJs. Based on the same OT algorithm as Google Wave OT.
    • Coweb-jsoe. Based on COT - a very sophisticated OT approach that also supports p2p message propagation.
    • OpenCoweb. It leverages OpenCoweb-jsoe in order to provide a full-fledged Framework for a lot of similar problems.
    • OT.js is based on the operation-types of ShareJs.
    • DriveSDK. A very interesting API that can do a lot of things - e.g. collaboration on graphs.
    • SwellRT is a Fork of Apache Wave. Is is federated, and supports rich text.
  • Differential Synchronization:

    • Diff-Match-Patch from Neil Fraser.
    • MobWrite leverages the Diff-Match-Patch algorithm.
  • CRDT (Commutative Replicated Data Type):

    • There are a lot of different CRDT algorithms that allow the implementation of shared types. Some CRDTs work with P2P message propagation, some rely on client-server models
    • Yjs allows you to share arbitrary data types (RichText, Array, Hash Maps, .. extendable). Offline support and support for P2P communication protocols (there are modules for XMPP, Websockets, and WebRTC)
    • SwarmJS Client server shared database with offline support. Works well with React
    • Woot An implementation of the Woot CRDT
    • CRDT Another CRDT implementation
    • Automerge

I have written a small unixy (do one thing and do it well) library that implements an OT control layer, allowing you to plug in different OT types (supports all shareJS compliant types). It's similar to shareJS but less opinionated and more abstract.

https://github.com/marcelklehr/gulf

Turnkey, or "drag and drop" solutions to this problem haven't really existed due to the complexity of reliably synchronizing shared mutable state. dmonad's response is a decent roundup, and I posted a more up-to-date overview of the available solutions here.

This question is quite old, but Convergence (disclaimer: I am a founder) provides the most turnkey solution out there, providing not just data synchronization but a host of other APIs useful for building out a collaborative UX. Here is an example showing exactly what you requested: synchronization of a text field across multiple clients.

Otherwise, ShareDB is a great open-source solution that fits a lot of people's needs.