mediawikitextcolorvisual-editor

MediaWiki VisualEditor textcolor


I'm trying to extend the VisualEditor by adding custom functionality.

It was pretty easy to add stuff which is realized with a single HTML-tag without parameters. But now I try to add textcolor. I tried to replicate the LanguageAnnotation as that's pretty similar (using span lang=.. while I want span style=color:..).

But it looks like there are a lot more things which I have to change here & I don't understand.

I'd be very grateful for any kind of help here.

Edit: To provide more information: Currently I am trying to replicate the .toDomElements function which I struggle with because I can not find the place where to modify the exact tag syntax (style instead of lang).


Solution

  • Well, I'm not sure if it's the best possible solution, but I've managed this problem by replicating the LanguageAnnotatation, including the widget-system (I chose it because it was the closest one to what I wanted to accomplish as it uses CSS and the span-tag).

    I've replicated the following classes, adjusting the attributes (language has lang and dir attributes, my color-annotation only the color attribute):

    It works pretty good imo. The only problem I see right now (and which I am working on next) is that with this implementation, text (or background)-color can only be applied to text, but not to tables (only when marking the text inside a cell).