Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IBX-6077: Fixed saving custom classes and attributes on tables in OE #107

Merged
merged 3 commits into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/bundle/Resources/richtext/stylesheets/xhtml5/edit/docbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,21 @@
</xsl:if>
</xsl:template>

<xsl:template name="ezattribute_from_figure">
<xsl:if test="ancestor::ezxhtml5:figure/@*[starts-with(name(), 'data-ezattribute-')]">
<xsl:element name="ezattribute" namespace="http://docbook.org/ns/docbook">
<xsl:for-each select="ancestor::ezxhtml5:figure/@*[starts-with(name(), 'data-ezattribute-')]">
<xsl:element name="ezvalue" namespace="http://docbook.org/ns/docbook">
<xsl:attribute name="key">
<xsl:value-of select="substring-after(name(), 'data-ezattribute-')"/>
</xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:if>
</xsl:template>

<!-- Note: use only in context where literallayout is handled always in parent context -->
<xsl:template name="breakline">
<xsl:param name="node"/>
Expand Down Expand Up @@ -425,6 +440,13 @@
<xsl:value-of select="@class"/>
</xsl:attribute>
</xsl:if>
<!-- Adding class and ezattribute from parent element (<figure>) -->
<xsl:if test="ancestor::ezxhtml5:figure/@class">
<xsl:attribute name="class">
<xsl:value-of select="../@class"/>
</xsl:attribute>
</xsl:if>
alongosz marked this conversation as resolved.
Show resolved Hide resolved
<xsl:call-template name="ezattribute_from_figure"/>
<xsl:if test="contains( @style, 'width:' )">
<xsl:variable name="width">
<xsl:call-template name="extractStyleValue">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<para ezxhtml:class="p-special">
<ezattribute>
<ezvalue key="p-custom-attribute">true</ezvalue>
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
</ezattribute>sdf V8</para>
<informaltable class="table t-special">
<ezattribute>
<ezvalue key="t-custom-attribute">true</ezvalue>
<ezvalue key="t-another-attribute">attr2,attr1</ezvalue>
</ezattribute>
<tbody>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</informaltable>
</section>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0"?>
<section xmlns="http://ibexa.co/namespaces/ezpublish5/xhtml5/edit">
<p class="p-special" data-ezattribute-p-custom-attribute="true" data-ezattribute-p-another-attribute="attr2,attr1">sdf V8</p>
<figure class="table t-special" data-ezattribute-t-custom-attribute="true" data-ezattribute-t-another-attribute="attr2,attr1">
<table>
<tbody>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</figure>
</section>
35 changes: 35 additions & 0 deletions tests/lib/RichText/Validator/DocbookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,41 @@ public function providerForTestValidate()
<emphasis role="strikedthrough">strikedthrough</emphasis>
</subscript>
</para>
</section>',
[],
],
[
'<?xml version="1.0" encoding="UTF-8"?>
<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">
<para ezxhtml:class="p-special">
<ezattribute>
<ezvalue key="p-custom-attribute">true</ezvalue>
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
</ezattribute>sdf V8</para>
<informaltable class="p-special">
<ezattribute>
<ezvalue key="p-custom-attribute">true</ezvalue>
<ezvalue key="p-another-attribute">attr2,attr1</ezvalue>
</ezattribute>
<tbody>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</informaltable>
</section>',
[],
],
Expand Down
Loading