Author CSS action to insert optional elements
Posted: Thu Apr 04, 2019 4:00 pm
I have a schema with sequences of many optional elements. Authors are having a hard time navigating to the right place to insert a specific element type, and often can't recall which might be allowed. I see the Elements view as helpful to show what is possible, but an inline visual display where an optional element might appear would be ideal, maybe as a button or link with an oxy_action to insert that element and position the cursor.
So far I haven't found a way to do this inline, so I'm asking for any helpful advice on that.
Meanwhile, as a fallback, I have been able to add :after content where an optional element is missing, to prompt the user to add it.
This shows the prompt by default after parentElement, and overrides the prompt when the optionalElement is present:
For a schema with many sequences of optional elements, this could be very clunky to write and maintain. Each optional element would need corresponding :after(N) sections for each N.
This would be easier using the :not() selector, with something like:
However, that :not() selector doesn't seem to work as I expected.
I would appreciate any advice to improve my authors' experience and I'm hoping for an elegant solution that I've missed, but I'll work with what's possible.
Thanks!
Ryan
So far I haven't found a way to do this inline, so I'm asking for any helpful advice on that.
Meanwhile, as a fallback, I have been able to add :after content where an optional element is missing, to prompt the user to add it.
This shows the prompt by default after parentElement, and overrides the prompt when the optionalElement is present:
Code: Select all
parentElement:after(N) { content: "add optionalElement"; } /* Content would be a link or button with an oxy_action in practice. */
parentElement:has(optionalElement):after(N) { content: none; }
This would be easier using the :not() selector, with something like:
Code: Select all
parentElement:not(optionalElement):after { -oxy-append-content: "add optionalElement"; }
I would appreciate any advice to improve my authors' experience and I'm hoping for an elegant solution that I've missed, but I'll work with what's possible.
Thanks!
Ryan