PluginProbe
Extendify / 3.2.2
Extendify v3.2.2
3.2.2 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 All 128 releases
← All changes | src/Agent/workflows/block-selector/tools/update-block-content.js +13 -1 3.0.6 → 3.2.2 View file →
@@ -1,8 +1,11 @@
1 +import { healBlockMarkup } from '@agent/lib/heal-blocks';
2 +import { ensureCoreBlocksRegistered } from '@agent/lib/register-blocks';
1 3 import apiFetch from '@wordpress/api-fetch';
2 4
3 5 // TODO: check for post_lock and error that someone is editing
4 6 export default async ({ previousContent, newContent }) => {
7 + await ensureCoreBlocksRegistered();
5 8 const { postType, postId } = window.extAgentData.context;
6 9
7 10 const type = await apiFetch({
8 11 path: `/wp/v2/types/${encodeURIComponent(postType)}`,
@@ -12,9 +15,18 @@
12 15 const response = await apiFetch({
13 16 path: `/wp/v2/${base}/${postId}?context=edit`,
14 17 });
15 18
16 - const content = response.content.raw.replace(previousContent, newContent);
19 + const content = response.content.raw.replace(
20 + previousContent,
21 + healBlockMarkup(newContent),
22 + );
23 +
24 + // A string-replace that matched nothing writes the post back unchanged;
25 + // refuse so the user sees a retry prompt instead of a false success.
26 + if (content === response.content.raw) {
27 + return { refused: true, reason: 'no-op' };
28 + }
17 29
18 30 await apiFetch({
19 31 path: `/wp/v2/${base}/${postId}`,
20 32 method: 'POST',