verbb / vizy

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

Custom Formatting for lists #281

Closed pl-mnm closed 4 months ago

pl-mnm commented 4 months ago

Question

I'd like to create custom formatting for a bullet list, and have the following in my Default.json config:

{
      "title": "Large List",
      "type": "bulletList",
      "attrs": { "class": "large-text" },
      "editorStyle": ".large-text { font-size: 1.25em; }"
}

This however is not working, but I'm not sure if I go it wrong or if there's a bug.

I'd also like to know if it's possible to target multiple types with a single format. Eg. "type": ["bulletList", "paragraph"]. Thanks in advance

Craft 4.6.1, Vizy 2.1.15

Additional context

No response

engram-design commented 4 months ago

Unfortunately, you can only use this mechanism to alter styles of text, and it doesn't support customising other nodes like this. That's because under the hood we use the textStyle mark to modify text.

More the to the point, it's currently not possible to modify the schema of nodes in this fashion. I assume you want to be able to add a class to the <ul> elements in the editor? At the moment, you can't store any attributes on elements that we don't specifically allow. This is how ProseMirror's schema works, and is very restrictive.

The reason this works for paragraphs and text, is through the textStyle mark, which is an additional bit of content stored alongside other nodes. That's not possible for the list nodes.

It's also not possible to target multiple types with this format.

I'll have to look at some options here to make things more flexible, but for the moment, you're really stuck with creating your own nodes.

pl-mnm commented 4 months ago

Gotcha, thanks for the explanation.

bleepsandblops commented 1 month ago

Am interested in this too, specifically showing custom list style in the editor and being able to add them / remove them.