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

deletion fix

parent c6679a3d
No related branches found
No related tags found
1 merge request!459Oen issues
......@@ -45,7 +45,7 @@ export default ({ setPosition, position }) => {
const imageId = selection.node.attrs.id;
const image = document.querySelector(`[data-id='${imageId}']`);
const figCaption = document.getElementsByTagName('figcaption')[0];
if (!image) return;
if (!image || !figCaption) return;
const imagePosition = image.getBoundingClientRect();
const figCaptionPosition = figCaption.getBoundingClientRect().height - 5;
const left = imagePosition.left - WaxSurface.left;
......
......@@ -112,16 +112,14 @@ const captionPlugin = key =>
}
// delete caption if figure is deleted
if (e.key === 'Delete' || e.code === 'Backspace') {
const figcap = document.getElementsByTagName('figcaption');
const figcapLength = figcap.length;
const figCap = view.state.selection.$head.path;
if (figCap[6] && figCap[6].type.name === 'figcaption') {
const figCapEl = document.getElementById(figCap[6].attrs.id);
if (figcapLength) {
for (let i = 0; i < figcapLength; i += 1) {
if (
figcap[i].parentElement.firstChild.tagName === 'FIGCAPTION'
) {
figcap[i].parentElement.remove();
}
if (
figCapEl.parentElement.firstChild.tagName === 'figCapElTION'
) {
figCapEl.parentElement.remove();
}
}
}
......
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