[Wikitext-l] [Wikitech-l] Alternate/remote editor API?

Brion Vibber brion at wikimedia.org
Fri Jun 17 21:09:54 UTC 2011


(Cross-posting this update to wikitech-l & wikitext-l since this ties into
Visual Editor project)

I've made some more updates to the CodeEditor extension & gadget
demonstrating integration & adaption of the WikiEditor editor & toolbar
framework.

The syntax-highlighting mode in CodeEditor can now be toggled on and off;
when it's off, any WikiEditor functions that had been patched for CodeEditor
fall automatically through to the defaults, and you get the regular textarea
view.

(If you just want to go poke at it, scroll down to the older quoted post and
follow the extension link ;)

There's a few more things I'll want to poke to make it suitable for dropping
the visual editor in:

* a concept of 'document format' that lets us specify that certain tools are
suitable for wikitext pages, while others are suitable for JS/CSS code --
this'll let things like the 'bold' and 'link' buttons hide themselves
automatically on regular wiki pages, while the JS/CSS pages can
automatically show tools like 'indent/deindent block', 'find declaration',
'syntax cleanup'. (Right now this can be done by manually removing/adding
tools in the JS & CSS modes, but we can integrate that better -- just like
the browser & RTL compatibility checks currently in some WikiEditor modules)

* An abstraction layer on data type / structure type? For the way tools like
text insertions, link dialogs, search & replace etc work we can in many ways
treat 'plain textarea', 'wikiEditor iframe with template folding', and 'Ace
syntax-highting editor' as equivalent: all are views on a plain text
document that can be addressed character by character, and all that needs to
be implemented are the pieces to get text in and out, do selection and
insert/delete, etc. For the visual editor, we'll have a document structure
that's very different, so something that 'makes a section bold' would work
differently: operating on a DOM-like model to move some nodes around, rather
than dropping bits of text in.

* cleaner implementation for toggle switches on the toolbar


In the meantime though, I should be able to get the ParserPlayground demos
more tightly integrated into the editor widget, and will try to hack up some
temporary handling for the bold/italic/link etc on the provisional dom
structure.

-- brion


On Mon, Jun 13, 2011 at 5:37 PM, Brion Vibber <brion at pobox.com> wrote:

> On Fri, May 6, 2011 at 11:22 AM, Brion Vibber <brion at pobox.com> wrote:
>
>> On Fri, May 6, 2011 at 11:20 AM, Trevor Parscal <tparscal at wikimedia.org>wrote:
>>
>>> The way the WikiEditor works right now, the textbox can be replaced with
>>> anything that can support a few methods, such as getSelection,
>>> encapsulateSelection, etc. There are some modules that depend on specific
>>> edit box implementations, such as the current and only alternative to the
>>> textarea we called "iframe" since it's a contentEditable iframe.
>>>
>>> If you take a look at jquery.wikiEditor.iframe.js, you will see what I
>>> mean.
>>> It should be pretty straightforward to drop anything in there, and be
>>> able
>>> to take advantage of the toolbar. There are some things, like find and
>>> replace that may need to be reworked or just turned off, but even things
>>> like the link dialog should work just fine but just supporting a few
>>> methods.
>>>
>>> The API could be better documented, and re-factored a bit to be even more
>>> generic, but the basic structure is there, and can be reused without much
>>> hacking.
>>>
>>
>> Spiffy... I'll play with it for CodeEditor, see if I can make the
>> special-char inserts for instance work on it (which would actually be useful
>> for some JS!).
>>
>
> Finally got around to poking at this recently as practice for the rich
> editor project.
>
> CodeEditor is now implemented as an extension:
> http://www.mediawiki.org/wiki/Extension:CodeEditor
> and the gadget pulls in the JS from there -- so if you're using the gadget
> on mediawiki.org, it should continue to work.
>
> I've also got it now working with WikiEditor's formatting toolbar (mostly),
> special characters list (works great!), and search & replace dialog,
> implementing most of the same interfaces that WikiEditor's iframe mode does.
>
> We'll probably want to extend that API a bit further, a few offhand notes:
>
> * Our jquery.textSelection module which implements the
> fetch-and-encapsulate-text stuff still has a few WikiEditor-specific
> assumptions, and probably needs to be generalized a little more.
>
> * Various bits of formatting & help text that are suitable for wikitext
> pages are less useful when you're on a JS or CSS page. We may want to have a
> concept of moving up from 'generic' editor (a few generic buttons) to having
> a specific data format ('wiki' pages get the wikitext help; 'js' pages get a
> MediaWiki JS API help page; 'css' pages get a list of common selectors and a
> link to CSS documentation). Those should be independent of what actual
> *editor mode* is being used as well, so we can show JS-relevant help on a JS
> page even if you don't have some fancy syntax highlighting thing.
>
> * For things that are 'fancy views of plain text' like the WikiEditor
> iframe mode and CodeEditor, the formatting toolbars etc work fairly
> straightforwardly; we just need to get at some selection of text, spit back
> a modified bit of text, and fiddle around the selection or view. This
> probably won't adapt so well for a rich visual editor; so we may need an
> adaptor layer to let plain-text and enhanced-text editors fiddle with the
> wikitext sample fragments while a rich editor has its own adaptor that turns
> high-level calls like 'wrap in a link' or 'make bold' and does the
> appropriate AST & view modifications.
>
> * A few of WikiEditor's experimental fields require the iframe mode and
> force it to switch in; may need something to avoid ambiguity when we're
> deliberately using a different mode.
>
> * Probably would be good to add a specific notion of switching editor
> modes; WikiEditor's preview tab opens up _surrounding_ the editor, but if we
> switch between plaintext & syntax-highlighting, we probably want a toggle on
> the toolbar which just swaps the guts around.
>
> -- brion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikimedia.org/pipermail/wikitext-l/attachments/20110617/19070df7/attachment-0001.htm 


More information about the Wikitext-l mailing list