# extendify/3.1.5/src/Agent/lib/delete-target.js

Extendify, version 3.1.5. 31 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Agent/lib/delete-target.js
- Raw: https://pluginprobe.com/plugins/extendify/3.1.5/raw/src/Agent/lib/delete-target.js
- Modified: 2026-08-12T16:23:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.1.5/code/src/Agent/lib/delete-target.js#L10-L20`.

```javascript
import { detectBlockType } from './block-type';

const BLOCK_ID_ATTR = 'data-extendify-agent-block-id';

// Wrappers that are broken markup without their last item — the op takes the
// wrapper. Not group/columns: an empty one still renders a box worth keeping.
const LIST_WRAPPERS = new Set([
	'core/buttons',
	'core/social-links',
	'core/list',
	'core/quote',
]);

// The wrapper never reaches the model (dropped from the manifest), so "delete this
// button" can only name the button — walk up to the wrapper when it's the last item.
export const resolveDeleteTarget = (blockId) => {
	const el = document.querySelector(`[${BLOCK_ID_ATTR}="${blockId}"]`);
	if (!el) return blockId;
	let targetId = blockId;
	let parent = el.parentElement?.closest(`[${BLOCK_ID_ATTR}]`);
	while (
		parent &&
		LIST_WRAPPERS.has(detectBlockType(parent)) &&
		parent.querySelectorAll(`[${BLOCK_ID_ATTR}]`).length === 1
	) {
		targetId = parent.getAttribute(BLOCK_ID_ATTR);
		parent = parent.parentElement?.closest(`[${BLOCK_ID_ATTR}]`);
	}
	return targetId;
};

```
