mirror of
https://github.com/strapi/strapi.git
synced 2025-11-09 22:59:14 +00:00
Allow to add <a><img /><a>
This commit is contained in:
parent
54fc51592b
commit
57e34cf994
@ -181,13 +181,9 @@ class PreviewWysiwyg extends React.PureComponent {
|
|||||||
previewHTML = rawContent => {
|
previewHTML = rawContent => {
|
||||||
const initHtml = isEmpty(rawContent) ? '<p></p>' : rawContent;
|
const initHtml = isEmpty(rawContent) ? '<p></p>' : rawContent;
|
||||||
const html = new DOMParser().parseFromString(converter.makeHtml(initHtml), 'text/html');
|
const html = new DOMParser().parseFromString(converter.makeHtml(initHtml), 'text/html');
|
||||||
toArray(html.querySelectorAll('a')).forEach(aReplacer);
|
toArray(html.getElementsByTagName('a')) // Retrieve all the links <a> tags
|
||||||
|
.filter((value) => value.getElementsByTagName('img').length > 0) // Filter by checking if they have any <img> children
|
||||||
// const initHtml = isEmpty(rawContent) ? '<p></p>' : rawContent;
|
.forEach(aReplacer); // Change those links into <blockquote> elements so we can set some metacharacters with the img content
|
||||||
// const html = new DOMParser().parseFromString(converter.makeHtml(initHtml), 'text/html');
|
|
||||||
// toArray(html.getElementsByTagName('a'))
|
|
||||||
// .filter((value) => value.getElementsByTagName('img').length > 0)
|
|
||||||
// .forEach(aReplacer);
|
|
||||||
let blocksFromHTML = convertFromHTML(html.body.innerHTML);
|
let blocksFromHTML = convertFromHTML(html.body.innerHTML);
|
||||||
|
|
||||||
if (blocksFromHTML.contentBlocks) {
|
if (blocksFromHTML.contentBlocks) {
|
||||||
@ -208,7 +204,7 @@ class PreviewWysiwyg extends React.PureComponent {
|
|||||||
{ type: 'atomic', text: ' ', key: block.getKey() },
|
{ type: 'atomic', text: ' ', key: block.getKey() },
|
||||||
{ entityData },
|
{ entityData },
|
||||||
);
|
);
|
||||||
const atomicBlock = createContentBlock(blockSpec);
|
const atomicBlock = createContentBlock(blockSpec); // Create an atomic block so we can identify it easily
|
||||||
|
|
||||||
return acc.concat([atomicBlock]);
|
return acc.concat([atomicBlock]);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import { List } from 'immutable';
|
|||||||
import { DEFAULT_INDENTATION } from './constants';
|
import { DEFAULT_INDENTATION } from './constants';
|
||||||
|
|
||||||
export function createNewBlock(text = '', type = 'unstyled', key = genKey()) {
|
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) {
|
export function getNextBlocksList(editorState, startKey) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user