PluginProbe
Extendify / trunk
Extendify vtrunk
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/workflows/content/components/UpdatePostConfirm.jsx +10 -4 3.1.3 → trunk View file →
@@ -19,9 +19,10 @@
19 19 }, []);
20 20
21 21 const handleConfirm = () => {
22 22 confirmed.current = true;
23 - onConfirm({ data: inputs });
23 + // The preview patched the DOM, so only a reload shows what was saved.
24 + onConfirm({ data: inputs, shouldRefreshPage: true });
24 25 };
25 26
26 27 const handleRetry = useCallback(() => {
27 28 undoTextReplacements();
@@ -32,9 +33,9 @@
32 33 updateAllTextNodesAndAttributes(inputs.replacements);
33 34 }, [inputs.replacements]);
34 35
35 36 return (
36 - <div className="mb-4 ml-10 mr-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50 rtl:ml-2 rtl:mr-10">
37 + <div className="mb-4 ms-2 me-2 flex flex-col rounded-lg border border-gray-300 bg-gray-50">
37 38 <div className="rounded-lg border-b border-gray-300 bg-white">
38 39 <div className="p-3">
39 40 <p className="m-0 p-0 text-sm text-gray-900">
40 41 {__(
@@ -70,8 +71,13 @@
70 71 </div>
71 72 );
72 73 };
73 74
75 +const PART_ID_ATTR = 'data-extendify-part-block-id';
76 +
77 +// The save rewrites this post alone, so a part preview reverts on the reload.
78 +const isInTemplatePart = (el) => Boolean(el?.closest?.(`[${PART_ID_ATTR}]`));
79 +
74 80 const updateAllTextNodesAndAttributes = (replacements) => {
75 81 const chat = document.getElementById('extendify-agent-chat');
76 82 const isInChat = (node) => chat?.contains(node);
77 83 // Update all text nodes
@@ -84,10 +90,10 @@
84 90 let node = walker.nextNode();
85 91 while (node) {
86 92 const current = node;
87 93 node = walker.nextNode();
88 - // Skip nodes that are inside the chat
89 94 if (isInChat(current.parentNode)) continue;
95 + if (isInTemplatePart(current.parentElement)) continue;
90 96
91 97 for (const { original, updated } of replacements ?? []) {
92 98 const value = current.nodeValue ?? '';
93 99 if (!value.includes(original)) continue;
@@ -97,10 +103,10 @@
97 103
98 104 // Update attributes
99 105 ['alt', 'title', 'aria-label', 'href', 'data-id'].forEach((attr) => {
100 106 document.querySelectorAll(`[${attr}]`).forEach((el) => {
101 - // Skip elements that are inside the chat
102 107 if (isInChat(el)) return;
108 + if (isInTemplatePart(el)) return;
103 109 for (const { original, updated } of replacements ?? []) {
104 110 const val = el.getAttribute(attr);
105 111 if (!val?.includes(original)) continue;
106 112 el.setAttribute(attr, val.split(original).join(updated));