backdrop-contrib / tinymce

Integration for the TinyMCE editor in Backdrop CMS
https://backdropcms.org/project/tinymce
GNU General Public License v2.0
2 stars 1 forks source link

Figure / image / figcaption revisited #123

Closed indigoxela closed 1 month ago

indigoxela commented 2 months ago

There's some room for improvement with figure / figcaption.

According to developer.mozilla.org figcaption may contain a lot more than we allow now. But we also can't allow all valid elements, as that would break compatibility to CKE (4 and 5, core), which in turn would lead to odd situations, when toggling between editors (OK, v5 allows less than v4).

However, currently Tiny (the library) allows to add whatever's actually valid, but toggling source mode (as an example, anything that triggers conversion to data attribute), the paragraphs are gone. And that's odd from user perspective.

Another problem: if a figure with image and figcaption is the only element in the editor, it's a bit tricky to escape (get the cursor outside the figure). EDIT: it's hitting an keyboard arrow button twice. :wink:

Another problem: how in the world did I manage to introduce a similar linked-image-in-figure bug as core CKE5 has? (The link from caption content slips to the image, the link from the image (if any) to the caption.) Fix that.

Nested markup in caption's also broken - they get stripped when saving. Not nice.

See also:

indigoxela commented 1 month ago

Fixed so far:

Still pending:

Function captionAstNodeToString() grew quite a bit. Not sure if I can simplify that. Probably not.