From 57e34cf9946dd6f73863b2dda837e8795591b1b5 Mon Sep 17 00:00:00 2001 From: soupette Date: Wed, 11 Apr 2018 22:39:30 +0200 Subject: [PATCH] Allow to add --- .../lib/src/components/Wysiwyg/previewWysiwyg.js | 12 ++++-------- .../lib/src/components/Wysiwyg/utils.js | 2 +- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js index 2617578f03..80b6171d54 100644 --- a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js +++ b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/previewWysiwyg.js @@ -181,13 +181,9 @@ class PreviewWysiwyg extends React.PureComponent { previewHTML = rawContent => { const initHtml = isEmpty(rawContent) ? '

' : rawContent; const html = new DOMParser().parseFromString(converter.makeHtml(initHtml), 'text/html'); - toArray(html.querySelectorAll('a')).forEach(aReplacer); - - // const initHtml = isEmpty(rawContent) ? '

' : rawContent; - // const html = new DOMParser().parseFromString(converter.makeHtml(initHtml), 'text/html'); - // toArray(html.getElementsByTagName('a')) - // .filter((value) => value.getElementsByTagName('img').length > 0) - // .forEach(aReplacer); + toArray(html.getElementsByTagName('a')) // Retrieve all the links
tags + .filter((value) => value.getElementsByTagName('img').length > 0) // Filter by checking if they have any children + .forEach(aReplacer); // Change those links into
elements so we can set some metacharacters with the img content let blocksFromHTML = convertFromHTML(html.body.innerHTML); if (blocksFromHTML.contentBlocks) { @@ -208,7 +204,7 @@ class PreviewWysiwyg extends React.PureComponent { { type: 'atomic', text: ' ', key: block.getKey() }, { entityData }, ); - const atomicBlock = createContentBlock(blockSpec); + const atomicBlock = createContentBlock(blockSpec); // Create an atomic block so we can identify it easily return acc.concat([atomicBlock]); } catch (err) { diff --git a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/utils.js b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/utils.js index d13b4ac746..1ed5a91c0b 100644 --- a/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/utils.js +++ b/packages/strapi-helper-plugin/lib/src/components/Wysiwyg/utils.js @@ -9,7 +9,7 @@ import { List } from 'immutable'; import { DEFAULT_INDENTATION } from './constants'; export function createNewBlock(text = '', type = 'unstyled', key = genKey()) { - return new ContentBlock({ key, type, text, characterList: List([]) }); + return new ContentBlock({ key, type, text, charaterList: List([]) }); } export function getNextBlocksList(editorState, startKey) {