On 2023-03-13 08:36, Robert Vogel via Wikitech-l wrote:
Hi everyone!
Inspired by https://www.mediawiki.org/wiki/VisualEditor/Gadgets#Implementing_a_custom_command I was trying to add a `<br />` into the VE using this command:

```
ve.init.target.getSurface().getModel().getFragment().insertContent( [ { type: 'break' }, { type: '/break' } ] );
```

While it actually inserted the line break in visual edit mode, there was not `<br />` in the wikitext after saving the page or switching to wikitext mode within the edit session. I also tried to implement the whole "command/tool" in an extension, but the behavior was the same. The odd thing is that a `<br />` inserted  in wikitext mode survives the round trip. The linear data model shows it as "alienInline" node then.

Any ideas why the official example didn't work for me?

Interesting, I can reproduce the problem. As far as I know this should work, and has worked in the past.

The line break disappears when the HTML generated by visual editor is being turned into wikitext in Parsoid.

Parsoid is supposed to apply some "cleanup" before saving the page (e.g. if you leave an empty heading in the document, it will disappear when saving in visual editor), and IIRC some of these cleanups also affected br tags, but I don't think they're supposed to be removed entirely.

Want to file a bug?


--
Bartosz Dziewoński
_______________________________________________
Wikitech-l mailing list -- wikitech-l@lists.wikimedia.org
To unsubscribe send an email to wikitech-l-le...@lists.wikimedia.org
https://lists.wikimedia.org/postorius/lists/wikitech-l.lists.wikimedia.org/

Reply via email to