Skip to content
Snippets Groups Projects
Commit 5a26533e authored by chris's avatar chris
Browse files

fix img id

parent 18a9b983
No related branches found
No related tags found
No related merge requests found
/* eslint-disable no-param-reassign */
import { v4 as uuidv4 } from 'uuid';
import { Plugin, PluginKey } from 'prosemirror-state';
const disallowPasteImagesPlugin = new PluginKey('disallowPasteImagesPlugin');
......@@ -15,14 +16,23 @@ export default onWarning => {
let imageFound = false;
content.forEach(node => {
if (node.type.name === 'image') {
node.attrs.id = uuidv4();
node.attrs.src = '';
node.attrs.alt = '';
imageFound = true;
}
if (node.type.name === 'figure') {
node.lastChild.attrs.src = '';
node.lastChild.attrs.alt = '';
imageFound = true;
if (node.firstChild && node.firstChild.type.name === 'image') {
node.firstChild.attrs.id = uuidv4();
node.firstChild.attrs.src = '';
node.firstChild.attrs.alt = '';
imageFound = true;
} else if (node.lastChild && node.lastChild.type.name === 'image') {
node.lastChild.attrs.id = uuidv4();
node.lastChild.attrs.src = '';
node.lastChild.attrs.alt = '';
imageFound = true;
}
}
});
if (imageFound) onWarning();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment