PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
← All changes | src/Agent/lib/delete-target.js +7 -8 3.1.53.2.1 View file →
@@ -1,8 +1,7 @@
1 +import { BLOCK_ID_SEL, blockIdOf, findBlockEl } from './block-el';
1 2 import { detectBlockType } from './block-type';
2 3
3 -const BLOCK_ID_ATTR = 'data-extendify-agent-block-id';
4 -
5 4 // Wrappers that are broken markup without their last item — the op takes the
6 5 // wrapper. Not group/columns: an empty one still renders a box worth keeping.
7 6 const LIST_WRAPPERS = new Set([
8 7 'core/buttons',
@@ -12,19 +11,19 @@
12 11 ]);
13 12
14 13 // The wrapper never reaches the model (dropped from the manifest), so "delete this
15 14 // button" can only name the button — walk up to the wrapper when it's the last item.
16 -export const resolveDeleteTarget = (blockId) => {
17 - const el = document.querySelector(`[${BLOCK_ID_ATTR}="${blockId}"]`);
15 +export const resolveDeleteTarget = (blockId, scope = null) => {
16 + const el = findBlockEl(blockId, document, scope);
18 17 if (!el) return blockId;
19 18 let targetId = blockId;
20 - let parent = el.parentElement?.closest(`[${BLOCK_ID_ATTR}]`);
19 + let parent = el.parentElement?.closest(BLOCK_ID_SEL);
21 20 while (
22 21 parent &&
23 22 LIST_WRAPPERS.has(detectBlockType(parent)) &&
24 - parent.querySelectorAll(`[${BLOCK_ID_ATTR}]`).length === 1
23 + parent.querySelectorAll(BLOCK_ID_SEL).length === 1
25 24 ) {
26 - targetId = parent.getAttribute(BLOCK_ID_ATTR);
27 - parent = parent.parentElement?.closest(`[${BLOCK_ID_ATTR}]`);
25 + targetId = blockIdOf(parent);
26 + parent = parent.parentElement?.closest(BLOCK_ID_SEL);
28 27 }
29 28 return targetId;
30 29 };