Topic on VisualEditor/Feedback

Visual Editor Programming: No <nowiki> around html tags please

4
Till.jonas.meyer (talkcontribs)

Hello! I want to develop a VE gadget which wraps the selected Text with a <div class='mw-collapsible'>...</div>. I found out how to replace the text. But the editor puts a nowiki-tag around my replacement. How can I prevent this? Greetings, Till-Jonas

He7d3r (talkcontribs)
79.194.201.49 (talkcontribs)

I don't speak Hebrew or which language these interesting characters come from...

ערן (talkcontribs)

The simplest solution is to wrap text with template in similar way to VisualEditor gadgets#Adding templates and VisualEditor gadgets#Replacing text. Using template instead of html tag may be preferred choice as it is more natural in wiki. But if you really want to add div with no templates, than you should probably create annotation class (e.g to inherit ve.dm.Annotation) and than use

var	fragment = ve.instances[0].getModel().getFragment();
fragment.annotateContent( 'set',  'collapsible');//assuming there is collapsible definition...

You can ask for tips and extra help on ve.dm in general in #mediawiki-visualeditor on freenode IRC.

Reply to "Visual Editor Programming: No <nowiki> around html tags please"