I have been struggling for 2 days to get svg image content to be rendereded inside prosemirror. Basically what i did was to create schemas to allow the properties to be added and not cleaned when adding them but it seems like something is not correct. All the html is generated in the editor but looks like the image is not loaded. If i move the same html out of prosemirror it renderes correctly. Any guidance how to allow any tag and attribute below the svg tag would be awesome because its a lot of work to specift every allowed element and attribute in svg.
Here is example of the code for each node and schema
get schema() {
return {
attrs: {
style: {
default: null,
},
xmlns: {
default: null
},
viewBox: {
default: null
}
},
content: 'block*',
group: 'block',
draggable: false,
parseDOM: [{
tag: 'svg',
getAttrs: dom => {
let allowed = {};
for (var i = 0; i < dom.attributes.length; i++) {
var attrib = dom.attributes[i];
allowed[attrib.name] = attrib.value
}
return allowed;
}
}],
toDOM: node => ['svg', node.attrs, 0],
}
}
get schema() {
return {
attrs: {
style: {
default: null,
},
xmlns: {
default: null
}
},
content: 'block*',
group: 'block',
draggable: false,
parseDOM: [{
tag: 'defs',
getAttrs: dom => {
let allowed = {};
for (var i = 0; i < dom.attributes.length; i++) {
var attrib = dom.attributes[i];
allowed[attrib.name] = attrib.value
}
return allowed;
}
}],
toDOM: node => ['defs', node.attrs, 0],
}
}
get schema() { return { attrs: { style: { default: null }, href: { default: null }, x: { default: null }, y: { default: null }, width: { default: null }, height: { default: null }, preserveAspectRatio: { default: null } }, content: ‘block+’, group: ‘block’, draggable: false, parseDOM: [{ tag: ‘image’, getAttrs: dom => { let allowed = {}; for (var i = 0; i < dom.attributes.length; i++) { var attrib = dom.attributes[i]; allowed[attrib.name] = attrib.value } return allowed; } }], toDOM: node => [‘image’, node.attrs, 0], } }