aboutsummaryrefslogtreecommitdiff
path: root/vnext/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src/utils')
-rw-r--r--vnext/src/utils/embed.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/vnext/src/utils/embed.js b/vnext/src/utils/embed.js
index 11434938..79674e28 100644
--- a/vnext/src/utils/embed.js
+++ b/vnext/src/utils/embed.js
@@ -1,8 +1,8 @@
function htmlEscape(html) {
return html.replace(/&/g, '&')
- .replace(/"/g, '"')
- .replace(/</g, '&lt;')
- .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
}
function insertAfter(newNode, referenceNode) {
@@ -352,15 +352,17 @@ function embedLink(aNode, linkTypes, container, afterNode = false) {
function embedLinks(aNodes, container) {
let anyEmbed = false
let embeddableLinkTypes = getEmbeddableLinkTypes()
- Array.from(aNodes).forEach(aNode => {
+ Array.from(aNodes).every(aNode => {
let isEmbedded = embedLink(aNode, embeddableLinkTypes, container)
+ // stop on first embedded link
anyEmbed = anyEmbed || isEmbedded
+ return !(anyEmbed)
})
return anyEmbed
}
/**
- * Embed all the links inside element "x" that match to "allLinksSelector".
+ * Embed first link from supplied links inside element "x" that match to "allLinksSelector".
* All the embedded media is placed inside "div.embedContainer".
* "div.embedContainer" is inserted before an element matched by "beforeNodeSelector"
* if not present. Existing container is used otherwise.
@@ -369,7 +371,7 @@ function embedLinks(aNodes, container) {
* @param {string} allLinksSelector
*/
export function embedLinksToX(x, beforeNodeSelector, allLinksSelector) {
- let allLinks = [x.querySelector(allLinksSelector)]
+ let allLinks = x.querySelectorAll(allLinksSelector)
let existingContainer = x.querySelector('div.embedContainer')
if (existingContainer) {