Page 1 of 1

Ordered list initial number

Posted: Wed Mar 22, 2023 8:24 am
by Silentar
Hello
I am trying to get ordered lists to start from value, defined by attribute
Css, that theoretically should work

Code: Select all

counter-reset: item-count oxy_add(oxy_xpath('../@start'), '-1', number);
If I replace oxy_add part with number it works (so selectors are correct)
oxy_xpath part is correct too - tested by adding :before rule with it as content
Using

Code: Select all

counter-reset: item-count oxy_xpath('../@start');
doesn't work a well
Generated editor html - Image
for

Code: Select all

    <ol id="ol_ew2_345_wwb" start="5">
      <li>asdfsdfg</li>
      <li>dfghfgdhj</li>
    </ol>
Thank you

Re: Ordered list initial number

Posted: Wed Mar 22, 2023 12:46 pm
by Bogdan Dumitru
Hello,

The problem that you encountered is caused by the fact that Oxygen XML Web Author lets the browser evaluate "counter-reset" and "counter-increment" CSS properties but the browser fails to evaluate "oxy_xpath" which is Oxygen-specific.
So you cannot use "oxy_xpath" as a value to the "counter-reset" CSS property in Oxygen XML Web Author.

As a solution, we think that you might be able to define CSS selectors for each value of the "start" attribute, somewhat like this:

Code: Select all

ol[start="1"] {
  counter-reset: item-count 1;
}
ol[start="2"] {
  counter-reset: item-count 2;
}
...
or maybe you can try using "attr" CSS function if possible, maybe like this:

Code: Select all

ol[start] {
  counter-reset: item-count attr(start);
}

Re: Ordered list initial number

Posted: Thu Mar 30, 2023 9:45 am
by Silentar
Thank you for your answer
Unfortunatelly attr doesn't work with counter-reset
But since data-attr-start is generated by Oxygen, it gave me another idea

Code: Select all

document.querySelectorAll('ol[data-attr-start]').forEach(n => n.style.counterReset = 'item-count ' + (n.getAttribute('data-attr-start') - 1));
is called in my plugin and sets OL numbering correctly
Problem left is that change is lost on document change. Currently calling it in setInterval which is not a long-term approach.
Question - how to subscribe to document change (or html redraw) event? Should be obvious but cannot find it in help or forum .
Thank you

Re: Ordered list initial number

Posted: Fri Mar 31, 2023 11:24 am
by Bogdan Dumitru
Hi,

We strongly suggest not building any customization that relies on the HTML DOM it's not an API of the application, thus you might generate subtle bugs and it might not work in a future version of Oxygen XML Web Author. See the Oxygen SDK for the Java API and the Customizing Web Author Using JavaScript Code for the JS API.

So the only solution for you is to generate a CSS with many matches for most of the "start" attribute values, like this:

Code: Select all

ol[start="1"] {
  counter-reset: item-count 1;
}
ol[start="2"] {
  counter-reset: item-count 2;
}
ol[start="3"] {
  counter-reset: item-count 3;
}
...