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

EZP-29280: As an editor, I want to add anchors to RichText content #28

Merged
merged 3 commits into from
Feb 26, 2019
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
3 changes: 2 additions & 1 deletion src/bundle/Resources/views/RichText/embed/content.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{% if embedParams.link is defined %}
{% set params = params|merge( { "linkParameters": embedParams.link } ) %}
{% endif %}
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}">

<div {% if embedParams.anchor is defined %}id="{{ embedParams.anchor }}"{% endif %} class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}">
{{ fos_httpcache_tag('relation-' ~ embedParams.id) }}
{{
render(
Expand Down
3 changes: 2 additions & 1 deletion src/bundle/Resources/views/RichText/embed/location.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{% if embedParams.link is defined %}
{% set params = params|merge( { "linkParameters": embedParams.link } ) %}
{% endif %}
<div class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}">

<div {% if embedParams.anchor is defined %}id="{{ embedParams.anchor }}"{% endif %} class="{% if embedParams.align is defined %}align-{{ embedParams.align }}{% endif %}{% if embedParams.class is defined %} {{ embedParams.class }}{% endif %}">
{{ fos_httpcache_tag('relation-location-' ~ embedParams.id) }}
{{
render(
Expand Down
5 changes: 5 additions & 0 deletions src/lib/eZ/RichText/Converter/Render/Embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ protected function extractParameters(DOMElement $embed, $tagName)

$class = $embed->getAttribute('ezxhtml:class');
$align = $embed->getAttribute('ezxhtml:align');
$anchor = $embed->getAttribute('xml:id');
$linkParameters = $this->extractLinkParameters($embed);
$configuration = $this->extractConfiguration($embed);

Expand All @@ -130,6 +131,10 @@ protected function extractParameters(DOMElement $embed, $tagName)
'viewType' => $viewType,
];

if (!empty($anchor)) {
$parameters['anchor'] = $anchor;
}

if (!empty($class)) {
$parameters['class'] = $class;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@

<xsl:template match="docbook:para">
<xsl:element name="p" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -42,6 +47,11 @@

<xsl:template match="docbook:programlisting">
<xsl:element name="pre" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand Down Expand Up @@ -235,6 +245,11 @@
</xsl:choose>
</xsl:variable>
<xsl:element name="{$headingTag}" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -251,6 +266,11 @@

<xsl:template match="docbook:orderedlist">
<xsl:element name="ol" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -262,6 +282,11 @@

<xsl:template match="docbook:itemizedlist">
<xsl:element name="ul" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -284,6 +309,11 @@

<xsl:template match="docbook:table | docbook:informaltable">
<xsl:element name="table" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@

<xsl:template match="docbook:programlisting">
<xsl:element name="pre" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -43,6 +48,11 @@

<xsl:template match="docbook:para">
<xsl:element name="p" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand Down Expand Up @@ -247,6 +257,11 @@
<xsl:value-of select="@ezxhtml:class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:textalign">
<xsl:attribute name="style">
<xsl:value-of select="concat( 'text-align:', @ezxhtml:textalign, ';' )"/>
Expand All @@ -258,6 +273,11 @@

<xsl:template match="docbook:orderedlist">
<xsl:element name="ol" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -269,6 +289,11 @@

<xsl:template match="docbook:itemizedlist">
<xsl:element name="ul" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@ezxhtml:class">
<xsl:attribute name="class">
<xsl:value-of select="@ezxhtml:class"/>
Expand All @@ -291,6 +316,11 @@

<xsl:template match="docbook:table | docbook:informaltable">
<xsl:element name="table" namespace="{$outputNamespace}">
<xsl:if test="@xml:id">
<xsl:attribute name="id">
<xsl:value-of select="@xml:id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
Expand Down
30 changes: 30 additions & 0 deletions src/lib/eZ/RichText/Resources/stylesheets/xhtml5/edit/docbook.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@

<xsl:template match="ezxhtml5:p">
<para>
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="ezxhtml:class">
<xsl:value-of select="@class"/>
Expand Down Expand Up @@ -90,6 +95,11 @@

<xsl:template match="ezxhtml5:pre">
<xsl:element name="programlisting">
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="ezxhtml:class">
<xsl:value-of select="@class"/>
Expand Down Expand Up @@ -247,6 +257,11 @@
<xsl:value-of select="@class"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="contains( @style, 'text-align:' )">
<xsl:variable name="textAlign">
<xsl:call-template name="extractStyleValue">
Expand All @@ -266,6 +281,11 @@

<xsl:template match="ezxhtml5:ol">
<orderedlist>
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="ezxhtml:class">
<xsl:value-of select="@class"/>
Expand All @@ -277,6 +297,11 @@

<xsl:template match="ezxhtml5:ul">
<itemizedlist>
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="ezxhtml:class">
<xsl:value-of select="@class"/>
Expand Down Expand Up @@ -311,6 +336,11 @@
</xsl:choose>
</xsl:variable>
<xsl:element name="{$tablename}" namespace="http://docbook.org/ns/docbook">
<xsl:if test="@id">
<xsl:attribute name="xml:id">
<xsl:value-of select="@id"/>
</xsl:attribute>
</xsl:if>
<xsl:if test="@class">
<xsl:attribute name="class">
<xsl:value-of select="@class"/>
Expand Down
1 change: 1 addition & 0 deletions tests/lib/eZ/RichText/Converter/Render/EmbedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function providerForTestConvert()
],
'class' => 'embed-class',
'align' => 'left',
'anchor' => 'embed-id-1',
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
<para ezxhtml:textalign="center">This is a centered paragraph.</para>
<para ezxhtml:textalign="right">This is a right aligned paragraph.</para>
<para ezxhtml:textalign="justify">This is a justified paragraph.</para>
<para xml:id="para-id">This is a paragraph with id</para>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom"
version="5.0-variant ezpublish-1.0">
<orderedlist ezxhtml:class="orderedListClass">
<orderedlist xml:id="orderedlist-id" ezxhtml:class="orderedListClass">
<listitem ezxhtml:class="listItemClass"><para>This is a list item.</para></listitem>
</orderedlist>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom"
version="5.0-variant ezpublish-1.0">
<itemizedlist ezxhtml:class="itemizedListClass">
<itemizedlist xml:id="itemizedlist-id" ezxhtml:class="itemizedListClass">
<listitem ezxhtml:class="listItemClass"><para>This is a list item.</para></listitem>
</itemizedlist>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom"
version="5.0-variant ezpublish-1.0">
<informaltable class="tableClass" width="24" title="tableTitle" border="1" style="border-width:42px;">
<informaltable xml:id="informaltable-id" class="tableClass" width="24" title="tableTitle" border="1" style="border-width:42px;">
<tbody>
<tr class="rowClass1">
<th class="headingClass1" ezxhtml:width="102" valign="top" colspan="1" rowspan="5" abbr="XSLT" scope="col">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:ezxhtml="http://ez.no/xmlns/ezpublish/docbook/xhtml"
xmlns:ezcustom="http://ez.no/xmlns/ezpublish/docbook/custom"
version="5.0-variant ezpublish-1.0">
<table class="tableClass" width="24%" title="tableTitle">
<table xml:id="table-id" class="tableClass" width="24%" title="tableTitle">
<caption>Table caption.</caption>
<tbody>
<tr class="rowClass1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
thisIsSomePHPCode();
return 0;
}</programlisting>
<programlisting xml:id="programlisting-id"><![CDATA[Literal with CNAME end sequence here : ]]]]><![CDATA[> and some more text here]]></programlisting>
</section>
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
<p style="text-align:center;">This is a centered paragraph.</p>
<p style="text-align:right;">This is a right aligned paragraph.</p>
<p style="text-align:justify;">This is a justified paragraph.</p>
<p id="para-id">This is a paragraph with id</p>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
<ol class="orderedListClass">
<ol id="orderedlist-id" class="orderedListClass">
<li class="listItemClass">This is a list item.</li>
</ol>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
<ul class="itemizedListClass">
<ul id="itemizedlist-id" class="itemizedListClass">
<li class="listItemClass">This is a list item.</li>
</ul>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
<table class="tableClass" border="1" title="tableTitle" style="width:24px;border-width:42px;">
<table id="informaltable-id" class="tableClass" border="1" title="tableTitle" style="width:24px;border-width:42px;">
<tbody>
<tr class="rowClass1">
<th class="headingClass1" colspan="1" rowspan="5" abbr="XSLT" scope="col" style="width:102px;vertical-align:top;">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5/edit">
<table class="tableClass" title="tableTitle" style="width:24%;">
<table id="table-id" class="tableClass" title="tableTitle" style="width:24%;">
<caption>Table caption.</caption>
<tbody>
<tr class="rowClass1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@
thisIsSomePHPCode();
return 0;
}</pre>
<pre id="programlisting-id">Literal with CNAME end sequence here : ]]&gt; and some more text here</pre>
</section>
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5">
<h2>This is a heading.</h2>
<p class="paraClass">This is a paragraph.</p>
<p class="paraClass2" style="text-align:left;">This is a left aligned paragraph.</p>
<p style="text-align:center;">This is a centered paragraph.</p>
<p style="text-align:right;">This is a right aligned paragraph.</p>
<p style="text-align:justify;">This is a justified paragraph.</p>
<h2>This is a heading.</h2>
<p class="paraClass">This is a paragraph.</p>
<p class="paraClass2" style="text-align:left;">This is a left aligned paragraph.</p>
<p style="text-align:center;">This is a centered paragraph.</p>
<p style="text-align:right;">This is a right aligned paragraph.</p>
<p style="text-align:justify;">This is a justified paragraph.</p>
<p id="para-id">This is a paragraph with id</p>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5">
<ol class="orderedListClass">
<ol id="orderedlist-id" class="orderedListClass">
<li class="listItemClass">This is a list item.</li>
</ol>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5">
<ul class="itemizedListClass">
<ul id="itemizedlist-id" class="itemizedListClass">
<li class="listItemClass">This is a list item.</li>
</ul>
</section>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<section xmlns="http://ez.no/namespaces/ezpublish5/xhtml5">
<table class="tableClass" border="1" title="tableTitle" style="width:24px;border-width:42px;">
<table id="informaltable-id" class="tableClass" border="1" title="tableTitle" style="width:24px;border-width:42px;">
<tbody>
<tr class="rowClass1">
<th class="headingClass1" colspan="1" rowspan="5" abbr="XSLT" scope="col" style="width:102px;vertical-align:top;">
Expand Down
Loading