verbb / vizy

A flexible visual editor for Craft CMS
Other
44 stars 8 forks source link

Allow to add markup in HTML mode #298

Open peerfischer opened 6 months ago

peerfischer commented 6 months ago

What are you trying to do?

I try to add a custom CSS class to a H2 tag

What's your proposed solution?

allow custom markup if HTML mode ist enabled in config

Additional context

No response

engram-design commented 6 months ago

This is by design with ProseMirror and its schema. You can't just add arbitrary HTML and have it save against a node. So while you can edit the raw HTML of the field, it won't necessarily save everything as you input it. This is to ensure that the HTML can be effectively represented as blocks of content (JSON).

This is true for HTML elements (the tags) and the attributes on the tag. We would need to modify the default Heading tag to allow for any additional attributes we want to support.

See https://github.com/verbb/vizy/issues/255

We need to look at ways to force-save node attributes in some fashion, but it's going against both Tiptap and ProseMirror.