On Fri, Sep 4, 2009 at 6:56 AM, Jeremy Whitlock
<
jcscoob...@gmail.com>wrote:
> I'm new to mobwrite but I was thinking how cool it would be to
> take a WYSIWYG editor, like YUI's editor, and hooking up mobwrite to
> it. The problem is that from what I can tell looking at the
> documentation and the sources, mobwrite only shares forms and form
> objects. I don't mind writing my own implementation that works with
> other non-form elements but before I went down that path, I figured I
> would ask here.
Well, if you aren't too worried about pathalogical cases where HTML
may get mangled (as Joe pointed out), all you need to do is create
your own getClientText and setClientText functions. See
mobwrite_form.js for five different examples of this. This is trivial
(~10 minutes of programming) and will get your editor synchronizing.
But every time there's a sync, your cursor will disappear since
setClientText is replacing the entire content. To fix this, you'll
need to write a patchClientText function which either uses ranges to
gently insert the content without disturbing the cursor, or else
captures the cursor location, makes the edits then restores the cursor
location. This function can get 'interesting', there's an example of
one in mobwrite_form.js
On Sep 4, 11:39 am, Joe Walker <
jwal...@mozilla.com> wrote:
> Diff operations which chop text around would need to be aware of these
> semantic links as they decide what to accept and reject. I think this means
> a re-write of diff-match-patch to be based on a tree rather than a stream of
> characters.
Correct, best-effort patching is not good enough when accidentally
mangling a </TABLE> tag would mean the rest of the page becomes
invisible. There's a wiki page about this with a possible work-
around:
http://code.google.com/p/google-diff-match-patch/wiki/Plaintext
As for tree-based differencing, I've looked into it very seriously.
It a completely different set of algorithms, and a very tough problem
to handle efficiently. If a tree-based version of DMP were written,
it could be plugged into MobWrite and rich text could be synced
without any modifications.