diff --git a/lib/FieldType/XmlText/Converter/EmbedLinking.php b/lib/FieldType/XmlText/Converter/EmbedLinking.php index 21c42f88..6c893841 100644 --- a/lib/FieldType/XmlText/Converter/EmbedLinking.php +++ b/lib/FieldType/XmlText/Converter/EmbedLinking.php @@ -31,9 +31,9 @@ class EmbedLinking implements Converter public function convert(DOMDocument $document) { $xpath = new DOMXPath($document); - // Select embeds that are linked + // Select embeds that are linked ( but only where embed is the only child of the link ) // After Expanding converter such links will contain only single embed element - $xpathExpression = '//embed[parent::link]|//embed-inline[parent::link]'; + $xpathExpression = '//embed[parent::link][count(preceding-sibling::*)+count(following-sibling::*)=0]|//embed-inline[parent::link][count(preceding-sibling::*)+count(following-sibling::*)=0]'; $linkedEmbeds = $xpath->query($xpathExpression); diff --git a/tests/lib/FieldType/Converter/_fixtures/richtext/input/048-link_outside_embed.xml b/tests/lib/FieldType/Converter/_fixtures/richtext/input/048-link_outside_embed.xml new file mode 100644 index 00000000..49c73216 --- /dev/null +++ b/tests/lib/FieldType/Converter/_fixtures/richtext/input/048-link_outside_embed.xml @@ -0,0 +1,10 @@ + +
+ paragraph text and ( + + + +
diff --git a/tests/lib/FieldType/Converter/_fixtures/richtext/input/049-link_outside_embeds.xml b/tests/lib/FieldType/Converter/_fixtures/richtext/input/049-link_outside_embeds.xml new file mode 100644 index 00000000..55e6b62a --- /dev/null +++ b/tests/lib/FieldType/Converter/_fixtures/richtext/input/049-link_outside_embeds.xml @@ -0,0 +1,11 @@ + +
+ paragraph text and ( + Foo + bar + 2 + +
diff --git a/tests/lib/FieldType/Converter/_fixtures/richtext/output/048-link_outside_embed.xml b/tests/lib/FieldType/Converter/_fixtures/richtext/output/048-link_outside_embed.xml new file mode 100644 index 00000000..648c8c89 --- /dev/null +++ b/tests/lib/FieldType/Converter/_fixtures/richtext/output/048-link_outside_embed.xml @@ -0,0 +1,9 @@ + +
+ paragraph text and ( + original +
diff --git a/tests/lib/FieldType/Converter/_fixtures/richtext/output/049-link_outside_embeds.xml b/tests/lib/FieldType/Converter/_fixtures/richtext/output/049-link_outside_embeds.xml new file mode 100644 index 00000000..ed906a68 --- /dev/null +++ b/tests/lib/FieldType/Converter/_fixtures/richtext/output/049-link_outside_embeds.xml @@ -0,0 +1,12 @@ + +
+ paragraph text and ( + Foo + originalbar + original2 + +