Skip to content

Commit

Permalink
IBX-3988: Fixed storing RichText formatting options for lists (#64)
Browse files Browse the repository at this point in the history
For more details see https://issues.ibexa.co/browse/IBX-3988 and #64

* Added support for styled itemized list

* Added support for styled ordered list
  • Loading branch information
vidarl authored Feb 3, 2023
1 parent 0ab4ff0 commit 3711ae5
Show file tree
Hide file tree
Showing 10 changed files with 327 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/bundle/Resources/richtext/schemas/docbook/ezpublish.rng
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@
</zeroOrMore>
</define>

<!-- Adding 'arabicleadingzero' to db.orderedlist.numeration.enumeration as this is exposed in editor from Ibexa DXP 4.0 -->
<define name="db.orderedlist.numeration.enumeration">
<choice>
<value>arabic</value>
<a:documentation>Specifies Arabic numeration (1, 2, 3, …)</a:documentation>
<value>arabicleadingzero</value>
<a:documentation>Specifies Arabic numeration with leading zero(01, 02, 03, …)</a:documentation>
<value>upperalpha</value>
<a:documentation>Specifies upper-case alphabetic numeration (A, B, C, …)</a:documentation>
<value>loweralpha</value>
<a:documentation>Specifies lower-case alphabetic numeration (a, b, c, …)</a:documentation>
<value>upperroman</value>
<a:documentation>Specifies upper-case Roman numeration (I, II, III, …)</a:documentation>
<value>lowerroman</value>
<a:documentation>Specifies lower-case Roman numeration (i, ii, iii …)</a:documentation>
</choice>
</define>
<define name="db.orderedlist">
<element name="orderedlist">
<a:documentation>A list in which each entry is marked with a sequentially incremented label</a:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@
<xsl:value-of select="@ezxhtml:class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@numeration = 'arabic'"><xsl:attribute name="style">list-style-type:decimal;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'arabicleadingzero'"><xsl:attribute name="style">list-style-type:decimal-leading-zero;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'lowerroman'"><xsl:attribute name="style">list-style-type:lower-roman;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'upperroman'"><xsl:attribute name="style">list-style-type:upper-roman;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'loweralpha'"><xsl:attribute name="style">list-style-type:lower-latin;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'upperalpha'"><xsl:attribute name="style">list-style-type:upper-latin;</xsl:attribute></xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</xsl:element>
Expand All @@ -334,6 +340,11 @@
<xsl:value-of select="@ezxhtml:class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@mark">
<xsl:attribute name="style">
<xsl:value-of select="concat('list-style-type:', @mark, ';')"/>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</xsl:element>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,12 @@
<xsl:value-of select="@ezxhtml:class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@numeration = 'arabic'"><xsl:attribute name="style">list-style-type:decimal;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'arabicleadingzero'"><xsl:attribute name="style">list-style-type:decimal-leading-zero;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'lowerroman'"><xsl:attribute name="style">list-style-type:lower-roman;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'upperroman'"><xsl:attribute name="style">list-style-type:upper-roman;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'loweralpha'"><xsl:attribute name="style">list-style-type:lower-latin;</xsl:attribute></xsl:if>
<xsl:if test="@numeration = 'upperalpha'"><xsl:attribute name="style">list-style-type:upper-latin;</xsl:attribute></xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</xsl:element>
Expand All @@ -342,6 +348,11 @@
<xsl:value-of select="@ezxhtml:class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@mark">
<xsl:attribute name="style">
<xsl:value-of select="concat('list-style-type:', @mark, ';')"/>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</xsl:element>
Expand Down
18 changes: 18 additions & 0 deletions src/bundle/Resources/richtext/stylesheets/xhtml5/edit/docbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@
<xsl:value-of select="@class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@style">
<xsl:attribute name="numeration">
<xsl:if test="@style = 'list-style-type:decimal;'">arabic</xsl:if>
<xsl:if test="@style = 'list-style-type:decimal-leading-zero;'">arabicleadingzero</xsl:if>
<xsl:if test="@style = 'list-style-type:lower-roman;'">lowerroman</xsl:if>
<xsl:if test="@style = 'list-style-type:upper-roman;'">upperroman</xsl:if>
<xsl:if test="@style = 'list-style-type:lower-latin;'">loweralpha</xsl:if>
<xsl:if test="@style = 'list-style-type:upper-latin;'">upperalpha</xsl:if>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</orderedlist>
Expand All @@ -361,6 +371,14 @@
<xsl:value-of select="@class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="contains( @style, 'list-style-type:' )">
<xsl:attribute name="mark">
<xsl:call-template name="extractStyleValue">
<xsl:with-param name="style" select="@style"/>
<xsl:with-param name="property" select="'list-style-type'"/>
</xsl:call-template>
</xsl:attribute>
</xsl:if>
<xsl:call-template name="ezattribute"/>
<xsl:apply-templates/>
</itemizedlist>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml"
xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom"
version="5.0-variant ezpublish-1.0">
<itemizedlist mark="disc">
<ezattribute>
<ezvalue key="name-1">value 1</ezvalue>
<ezvalue key="name-2">value 2</ezvalue>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-2">value 2</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-2">value 2</ezvalue>
</ezattribute>This is a list item.</para>
</listitem>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<literallayout class="normal">This is a list item
with a line break.</literallayout>
</para>
</listitem>
</itemizedlist>
<itemizedlist mark="circle">
<ezattribute>
<ezvalue key="name-1">value 1</ezvalue>
<ezvalue key="name-2">value 2</ezvalue>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-2">value 2</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-2">value 2</ezvalue>
</ezattribute>This is a list item.</para>
</listitem>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<literallayout class="normal">This is a list item
with a line break.</literallayout>
</para>
</listitem>
</itemizedlist>
<itemizedlist mark="square">
<ezattribute>
<ezvalue key="name-1">value 1</ezvalue>
<ezvalue key="name-2">value 2</ezvalue>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-2">value 2</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass"><ezattribute><ezvalue key="name-2">value 2</ezvalue></ezattribute>This is a list item.</para>
</listitem>
<listitem ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<para ezxhtml:class="listItemClass">
<ezattribute>
<ezvalue key="name-3">value 3</ezvalue>
</ezattribute>
<literallayout class="normal">This is a list item
with a line break.</literallayout>
</para>
</listitem>
</itemizedlist>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml"
xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom"
version="5.0-variant ezpublish-1.0">
<para>default</para>
<orderedlist>
<listitem>
<para>default 1</para>
</listitem>
<listitem>
<para>default 2</para>
</listitem>
</orderedlist>
<para>decimal</para>
<orderedlist numeration="arabic">
<listitem>
<para>decimal 1</para>
</listitem>
<listitem>
<para>decimal 2</para>
</listitem>
</orderedlist>
<para>decimal leading zero</para>
<orderedlist numeration="arabicleadingzero">
<listitem>
<para>decimal leading zero 1</para>
</listitem>
<listitem>
<para>decimal leading zero 2</para>
</listitem>
</orderedlist>
<para>lower roman</para>
<orderedlist numeration="lowerroman">
<listitem>
<para>lower roman 1</para>
</listitem>
<listitem>
<para>lower roman 2</para>
</listitem>
</orderedlist>
<para>upper roman</para>
<orderedlist numeration="upperroman">
<listitem>
<para>upper roman 1</para>
</listitem>
</orderedlist>
<orderedlist>
<listitem>
<para>upper roman 2</para>
</listitem>
</orderedlist>
<para>lower latin</para>
<orderedlist numeration="loweralpha">
<listitem>
<para>lower latin 1</para>
</listitem>
<listitem>
<para>lower latin 2</para>
</listitem>
</orderedlist>
<para>upper latin</para>
<orderedlist numeration="upperalpha">
<listitem>
<para>upper latin 1</para>
</listitem>
<listitem>
<para>upper latin 2</para>
</listitem>
</orderedlist>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5/edit">
<ul style="list-style-type:disc;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
<ul style="list-style-type:circle;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
<ul style="list-style-type:square;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5/edit">
<p>default</p>
<ol>
<li>default 1</li>
<li>default 2</li>
</ol>
<p>decimal</p>
<ol style="list-style-type:decimal;">
<li>decimal 1</li>
<li>decimal 2</li>
</ol>
<p>decimal leading zero</p>
<ol style="list-style-type:decimal-leading-zero;">
<li>decimal leading zero 1</li>
<li>decimal leading zero 2</li>
</ol>
<p>lower roman</p>
<ol style="list-style-type:lower-roman;">
<li>lower roman 1</li>
<li>lower roman 2</li>
</ol>
<p>upper roman</p>
<ol style="list-style-type:upper-roman;">
<li>upper roman 1</li>
</ol>
<ol>
<li>upper roman 2</li>
</ol>
<p>lower latin</p>
<ol style="list-style-type:lower-latin;">
<li>lower latin 1</li>
<li>lower latin 2</li>
</ol>
<p>upper latin</p>
<ol style="list-style-type:upper-latin;">
<li>upper latin 1</li>
<li>upper latin 2</li>
</ol>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5">
<ul style="list-style-type:disc;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
<ul style="list-style-type:circle;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
<ul style="list-style-type:square;" data-ezattribute-name-1="value 1" data-ezattribute-name-2="value 2" data-ezattribute-name-3="value 3">
<li class="listItemClass" data-ezattribute-name-2="value 2">This is a list item.</li>
<li class="listItemClass" data-ezattribute-name-3="value 3">This is a list item<br/>with a line break.</li>
</ul>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5">
<p>default</p>
<ol>
<li>default 1</li>
<li>default 2</li>
</ol>
<p>decimal</p>
<ol style="list-style-type:decimal;">
<li>decimal 1</li>
<li>decimal 2</li>
</ol>
<p>decimal leading zero</p>
<ol style="list-style-type:decimal-leading-zero;">
<li>decimal leading zero 1</li>
<li>decimal leading zero 2</li>
</ol>
<p>lower roman</p>
<ol style="list-style-type:lower-roman;">
<li>lower roman 1</li>
<li>lower roman 2</li>
</ol>
<p>upper roman</p>
<ol style="list-style-type:upper-roman;">
<li>upper roman 1</li>
</ol>
<ol>
<li>upper roman 2</li>
</ol>
<p>lower latin</p>
<ol style="list-style-type:lower-latin;">
<li>lower latin 1</li>
<li>lower latin 2</li>
</ol>
<p>upper latin</p>
<ol style="list-style-type:upper-latin;">
<li>upper latin 1</li>
<li>upper latin 2</li>
</ol>
</section>

0 comments on commit 3711ae5

Please sign in to comment.