Skip to content

Commit 4c738dd

Browse files
authored
IBX-6077: Fixed saving custom classes and attributes on tables in OE (#107)
For more details see https://issues.ibexa.co/browse/IBX-6077 and #107
1 parent 560c619 commit 4c738dd

File tree

4 files changed

+115
-0
lines changed

4 files changed

+115
-0
lines changed

src/bundle/Resources/richtext/stylesheets/xhtml5/edit/docbook.xsl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,21 @@
4040
</xsl:if>
4141
</xsl:template>
4242

43+
<xsl:template name="ezattribute_from_figure">
44+
<xsl:if test="ancestor::ezxhtml5:figure/@*[starts-with(name(), 'data-ezattribute-')]">
45+
<xsl:element name="ezattribute" namespace="http://docbook.org/ns/docbook">
46+
<xsl:for-each select="ancestor::ezxhtml5:figure/@*[starts-with(name(), 'data-ezattribute-')]">
47+
<xsl:element name="ezvalue" namespace="http://docbook.org/ns/docbook">
48+
<xsl:attribute name="key">
49+
<xsl:value-of select="substring-after(name(), 'data-ezattribute-')"/>
50+
</xsl:attribute>
51+
<xsl:value-of select="."/>
52+
</xsl:element>
53+
</xsl:for-each>
54+
</xsl:element>
55+
</xsl:if>
56+
</xsl:template>
57+
4358
<!-- Note: use only in context where literallayout is handled always in parent context -->
4459
<xsl:template name="breakline">
4560
<xsl:param name="node"/>
@@ -425,6 +440,13 @@
425440
<xsl:value-of select="@class"/>
426441
</xsl:attribute>
427442
</xsl:if>
443+
<!-- Adding class and ezattribute from parent element (<figure>) -->
444+
<xsl:if test="ancestor::ezxhtml5:figure/@class">
445+
<xsl:attribute name="class">
446+
<xsl:value-of select="../@class"/>
447+
</xsl:attribute>
448+
</xsl:if>
449+
<xsl:call-template name="ezattribute_from_figure"/>
428450
<xsl:if test="contains( @style, 'width:' )">
429451
<xsl:variable name="width">
430452
<xsl:call-template name="extractStyleValue">
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<section xmlns="http://docbook.org/ns/docbook" xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom" xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0-variant ezpublish-1.0">
3+
<para ezxhtml:class="p-special">
4+
<ezattribute>
5+
<ezvalue key="p-custom-attribute">true</ezvalue>
6+
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
7+
</ezattribute>sdf V8</para>
8+
<informaltable class="table t-special">
9+
<ezattribute>
10+
<ezvalue key="t-custom-attribute">true</ezvalue>
11+
<ezvalue key="t-another-attribute">attr2,attr1</ezvalue>
12+
</ezattribute>
13+
<tbody>
14+
<tr>
15+
<td> </td>
16+
<td> </td>
17+
</tr>
18+
<tr>
19+
<td> </td>
20+
<td> </td>
21+
</tr>
22+
<tr>
23+
<td> </td>
24+
<td> </td>
25+
</tr>
26+
<tr>
27+
<td> </td>
28+
<td> </td>
29+
</tr>
30+
</tbody>
31+
</informaltable>
32+
</section>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0"?>
2+
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5/edit">
3+
<p class="p-special" data-ezattribute-p-custom-attribute="true" data-ezattribute-p-another-attribute="attr2,attr1">sdf V8</p>
4+
<figure class="table t-special" data-ezattribute-t-custom-attribute="true" data-ezattribute-t-another-attribute="attr2,attr1">
5+
<table>
6+
<tbody>
7+
<tr>
8+
<td> </td>
9+
<td> </td>
10+
</tr>
11+
<tr>
12+
<td> </td>
13+
<td> </td>
14+
</tr>
15+
<tr>
16+
<td> </td>
17+
<td> </td>
18+
</tr>
19+
<tr>
20+
<td> </td>
21+
<td> </td>
22+
</tr>
23+
</tbody>
24+
</table>
25+
</figure>
26+
</section>

tests/lib/RichText/Validator/DocbookTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,41 @@ public function providerForTestValidate()
111111
<emphasis role="strikedthrough">strikedthrough</emphasis>
112112
</subscript>
113113
</para>
114+
</section>',
115+
[],
116+
],
117+
[
118+
'<?xml version="1.0" encoding="UTF-8"?>
119+
<section xmlns="http://docbook.org/ns/docbook" xmlns:ezcustom="http://ibexa.co/xmlns/dxp/docbook/custom" xmlns:ezxhtml="http://ibexa.co/xmlns/dxp/docbook/xhtml" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0-variant ezpublish-1.0">
120+
<para ezxhtml:class="p-special">
121+
<ezattribute>
122+
<ezvalue key="p-custom-attribute">true</ezvalue>
123+
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
124+
</ezattribute>sdf V8</para>
125+
<informaltable class="p-special">
126+
<ezattribute>
127+
<ezvalue key="p-custom-attribute">true</ezvalue>
128+
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
129+
</ezattribute>
130+
<tbody>
131+
<tr>
132+
<td> </td>
133+
<td> </td>
134+
</tr>
135+
<tr>
136+
<td> </td>
137+
<td> </td>
138+
</tr>
139+
<tr>
140+
<td> </td>
141+
<td> </td>
142+
</tr>
143+
<tr>
144+
<td> </td>
145+
<td> </td>
146+
</tr>
147+
</tbody>
148+
</informaltable>
114149
</section>',
115150
[],
116151
],

0 commit comments

Comments
 (0)