# extendify/3.0.4/src/Agent/workflows/block-selector/tools/update-block-content.js

Extendify, version 3.0.4. 24 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.4/code/src/Agent/workflows/block-selector/tools/update-block-content.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.4/raw/src/Agent/workflows/block-selector/tools/update-block-content.js
- Modified: 2025-09-30T17:20:28+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.0.4/code/src/Agent/workflows/block-selector/tools/update-block-content.js#L10-L20`.

```javascript
import apiFetch from '@wordpress/api-fetch';

// TODO: check for post_lock and error that someone is editing
export default async ({ previousContent, newContent }) => {
	const { postType, postId } = window.extAgentData.context;

	const type = await apiFetch({
		path: `/wp/v2/types/${encodeURIComponent(postType)}`,
	});
	const base = type?.rest_base || `${postType}s`;

	const response = await apiFetch({
		path: `/wp/v2/${base}/${postId}?context=edit`,
	});

	const content = response.content.raw.replace(previousContent, newContent);

	await apiFetch({
		path: `/wp/v2/${base}/${postId}`,
		method: 'POST',
		data: { content },
	});
};

```
