Skip to content

Commit

Permalink
Fix inserting links, fix jshint nags
Browse files Browse the repository at this point in the history
  • Loading branch information
indigoxela committed Jul 17, 2024
1 parent eff616b commit 98370d4
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions js/plugins/backdropimage/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,9 @@

/**
* Limit allowed tags in figcaption to the same ones CKE4 allowed.
* Plus "span", because otherwise inserting links in figcaptions breaks.
*/
const tagsAllowedInFigcaption = ['a', 'em', 'strong', 'cite', 'code', 'br'];
const tagsAllowedInFigcaption = ['a', 'em', 'strong', 'cite', 'code', 'br', 'span'];

/**
* Parses an array of AstNodes into a string.
Expand All @@ -183,9 +184,7 @@
if (node.name === '#text') {
dummy.append(document.createTextNode(node.value));
}
else if (node.parent) {
// <br> elements without parent are stray.
// @todo figure out where they come from.
else {
dummy.append(document.createElement(node.name));
}
}
Expand All @@ -206,7 +205,7 @@
else {
let parent = document.createElement(node.name);
let lastChild = node.lastChild;
while (node = node.walk()) {
while (node = node.walk()) {// jshint ignore:line
// Caution, walk() does not only walk over this node, so we have to
// stop ourselves.
if (node.name === '#text') {
Expand Down Expand Up @@ -352,10 +351,10 @@
let childLinks = nodes[i].getAll('a');
if (childLinks.length) {
childLinks = childLinks.filter(function (item) {
if (item.parent.name == 'figcaption') {
if (item.parent.name === 'figcaption') {
return false;
}
if (item.parent.parent && item.parent.parent.name == 'figcaption') {
if (item.parent.parent && item.parent.parent.name === 'figcaption') {
return false;
}
return true;
Expand Down

0 comments on commit 98370d4

Please sign in to comment.