Operational-Transformation / ot.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OT Question

spfoos opened this issue · comments

I have an issue where OT.js is not working the way I'm expecting it to.

The jsfiddle shows the code and the output. The issue is the transform is not creating the expected prime operation.

The parent string is "<div><br><div>"
A = r: 5, i: "abc", d: "<br>", r: 6
B = r: 6, i: "span id="xxx"></span>", r: 9

When creating the transforms, and applying the result apply(apply(S, A), B'), I'm expecting:

"<div><span id="xxx"></span><div>"

However, the output is:

"<div>span id="xxx"></span><div>"

(missing the < before span).

Is this an issue with the algorithm or my understanding?

http://jsfiddle.net/6N99d/5/

Aren't you missing the '<' in your input?

The parent string has the '<' at position 6. Operation B has retain 6,
which should include the '<' before the span.

On Wednesday, January 8, 2014, Sigurd Gartmann wrote:

Aren't you missing the '<' in your input?


Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-31823759
.

But you are deleting that '<' in operation A? So the character should be deleted. Both operations should be honored. Inserts and deletes has to be valued higher than retain, or this can't work.

(I'm not the author of this lib, I just read a lot about OT during the weeked. And I may have missed something important. I wanted to use OT on wysiwyg, but concluded that it would get very messy.)

That is the behavior in OT.js. I was wondering if it was the algorithm that was implemented. With delete and insert preceding retains, intention is not preserved in this particular case. Are there alternative algorithms that can handle this case?

BTW, I'm implementing concurrency on top of a rich text editor.

@spfoos
I think that the OT implementation of togetherjs is based on this project
They added rich text support:
jsfiddle/togetherjs#931
I don't understand how they solved the known issues with OT on HTML

@benbro what are the known issues with OT on HTML?

  1. The order of tag matters
  2. You might get a corrupted tag
    http://stackoverflow.com/questions/10149861/does-operational-transformation-work-on-structured-documents-such-as-html-if-sim

I don't understand how togetherjs solved the issues.
I also think that they calculate the changes on the whole innerHTML on every key stoke.

My approach is similar. Capture innerHTML on every key stroke. I haven't had issues yet with malformed HTML.