eddev 2.3.14 → 2.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/lib/blocks/editor/block-templates.d.ts.map +1 -1
- package/dist/app/lib/blocks/editor/block-templates.js +17 -11
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +1 -1
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts.map +1 -1
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +32 -41
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-templates.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/block-templates.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,EAAE,CAAA;AAE9F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAO,UAO7D;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,
|
|
1
|
+
{"version":3,"file":"block-templates.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/block-templates.tsx"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,aAAa,CAAC,EAAE,CAAA;AAE9F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,UAAO,UAO7D;AAED,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,aAAa,GAAG,aAAa,CAU7E;AAED,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,GAAG,EAAE,EACpB,MAAM,EAAE;IACN,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,cAAc,CAAC,EAAE,aAAa,CAAA;IAC9B,cAAc,CAAC,EAAE,aAAa,CAAA;CAC/B,SA2CF;AAED,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,UAAO,EAAE,cAAc,UAAO,GAAG,GAAG,CA2B5G"}
|
|
@@ -9,7 +9,15 @@ export function resolveAcfBlockName(name, check = true) {
|
|
|
9
9
|
}
|
|
10
10
|
export function transformBlockTemplate(template) {
|
|
11
11
|
return template.map(([name, props, children]) => {
|
|
12
|
-
|
|
12
|
+
const blockName = resolveAcfBlockName(name);
|
|
13
|
+
const outProps = { ...props };
|
|
14
|
+
if (blockName.startsWith("acf/")) {
|
|
15
|
+
if (!outProps.data)
|
|
16
|
+
outProps.data = {};
|
|
17
|
+
if (!outProps.inline)
|
|
18
|
+
outProps.inline = {};
|
|
19
|
+
}
|
|
20
|
+
return [blockName, outProps, children ? transformBlockTemplate(children) : undefined];
|
|
13
21
|
});
|
|
14
22
|
}
|
|
15
23
|
export function applyTemplateBlocks(currentBlocks, config) {
|
|
@@ -50,12 +58,15 @@ export function applyTemplateBlocks(currentBlocks, config) {
|
|
|
50
58
|
}
|
|
51
59
|
export function transformTemplateToBlocks(template, locked = true, isFromTemplate = true) {
|
|
52
60
|
return template.map(([name, props, children]) => {
|
|
61
|
+
const blockName = resolveAcfBlockName(name);
|
|
53
62
|
const attributes = {
|
|
54
|
-
data: {},
|
|
55
|
-
inline: {},
|
|
56
63
|
isFromTemplate: isFromTemplate,
|
|
57
64
|
lock: undefined,
|
|
58
65
|
};
|
|
66
|
+
if (blockName.startsWith("acf/")) {
|
|
67
|
+
attributes.data = {};
|
|
68
|
+
attributes.inline = {};
|
|
69
|
+
}
|
|
59
70
|
if (props.locked === false) {
|
|
60
71
|
attributes.lock = { move: false, remove: false };
|
|
61
72
|
}
|
|
@@ -66,13 +77,8 @@ export function transformTemplateToBlocks(template, locked = true, isFromTemplat
|
|
|
66
77
|
attributes.lock = props.lock;
|
|
67
78
|
}
|
|
68
79
|
Object.assign(attributes, props);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
attributes: attributes,
|
|
73
|
-
innerBlocks: children ? transformTemplateToBlocks(children, false, isFromTemplate) : [],
|
|
74
|
-
isValid: true,
|
|
75
|
-
validationIssues: [],
|
|
76
|
-
};
|
|
80
|
+
const block = wp.blocks.createBlock(blockName, attributes, children ? transformTemplateToBlocks(children, false, isFromTemplate) : []);
|
|
81
|
+
Object.assign(block.attributes, attributes);
|
|
82
|
+
return block;
|
|
77
83
|
});
|
|
78
84
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const blockMetaDescriptors: Map<string, BlockMeta> & {
|
|
2
|
-
$$valtioSnapshot: Omit<Map<string, BlockMeta>, "set" | "
|
|
2
|
+
$$valtioSnapshot: Omit<Map<string, BlockMeta>, "set" | "clear" | "delete">;
|
|
3
3
|
};
|
|
4
4
|
export declare function whenEditorIsReady(): Promise<void>;
|
|
5
5
|
export declare function installEDGutenbergHooks(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installGutenbergHooks.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/installGutenbergHooks.tsx"],"names":[],"mappings":"AA2BA,eAAO,MAAM,oBAAoB;;CAAgC,CAAA;AAEjE,wBAAgB,iBAAiB,kBAsBhC;AAED,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"installGutenbergHooks.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/installGutenbergHooks.tsx"],"names":[],"mappings":"AA2BA,eAAO,MAAM,oBAAoB;;CAAgC,CAAA;AAEjE,wBAAgB,iBAAiB,kBAsBhC;AAED,wBAAgB,uBAAuB,SAmTtC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createElement as _createElement } from "react";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { proxy,
|
|
3
|
+
import { Fragment, useEffect, useMemo } from "react";
|
|
4
|
+
import { proxy, subscribe, useSnapshot } from "valtio";
|
|
5
5
|
import { proxyMap } from "valtio/utils";
|
|
6
6
|
import { addBlockMetadata, getBlockMetadata } from "../block-utils.js";
|
|
7
7
|
import { registerBuiltinBlocks } from "../builtin-blocks.js";
|
|
@@ -199,11 +199,13 @@ export function installEDGutenbergHooks() {
|
|
|
199
199
|
item.attributes.inline = { type: "object" };
|
|
200
200
|
item.attributes.values = { type: "object" };
|
|
201
201
|
// Add className support to all ACF blocks
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
if (item.styles) {
|
|
203
|
+
const defaultStyleName = item.styles?.find((s) => s.isDefault)?.name;
|
|
204
|
+
item.attributes.className = {
|
|
205
|
+
type: "string",
|
|
206
|
+
default: item.attributes?.className?.default ?? (defaultStyleName ? "is-style-" + defaultStyleName : undefined),
|
|
207
|
+
};
|
|
208
|
+
}
|
|
207
209
|
item.attributes.isFromTemplate = { type: "boolean" };
|
|
208
210
|
item.supports.customClassName = false;
|
|
209
211
|
item.edit = function (props) {
|
|
@@ -268,45 +270,34 @@ export function installEDGutenbergHooks() {
|
|
|
268
270
|
registerBuiltinBlocks();
|
|
269
271
|
}
|
|
270
272
|
const acf = "acf" in window ? window.acf : {};
|
|
271
|
-
acf.parseJSX = (html) => {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
let clientId = null;
|
|
273
|
+
// acf.parseJSX = (html: string) => {
|
|
274
|
+
// let payload: any
|
|
275
|
+
// try {
|
|
276
|
+
// payload = JSON.parse(html)
|
|
277
|
+
// } catch (err) {
|
|
278
|
+
// console.error(err)
|
|
279
|
+
// throw new Error("eddev: Error parsing block data from: \n" + html)
|
|
280
|
+
// }
|
|
281
|
+
// return <EditableBlock payload={payload ?? {}} />
|
|
282
|
+
// }
|
|
283
|
+
acf.addFilter("blocks/preview/render", (html) => {
|
|
284
|
+
const trimmed = html.trim();
|
|
284
285
|
try {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
if (!existing || existing.key !== data.__key) {
|
|
288
|
-
const payload = JSON.parse(data);
|
|
289
|
-
clientId = payload.__clientId;
|
|
290
|
-
BlockPropsStore.blocks.set(payload.__clientId, {
|
|
291
|
-
payload: payload ? ref(payload) : null,
|
|
292
|
-
key: key,
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
clientId = existing.payload?.__clientId;
|
|
297
|
-
}
|
|
286
|
+
JSON.parse(trimmed);
|
|
287
|
+
return `<edblock data-payload="${encodeURIComponent(trimmed)}"></edblock>`;
|
|
298
288
|
}
|
|
299
|
-
catch
|
|
300
|
-
|
|
301
|
-
console.error(err);
|
|
289
|
+
catch {
|
|
290
|
+
return html;
|
|
302
291
|
}
|
|
303
|
-
return '<edblock data-clientid="' + clientId + '" />';
|
|
304
292
|
});
|
|
305
293
|
if (acf.jsxNameReplacements) {
|
|
306
|
-
acf.jsxNameReplacements["edblock"] =
|
|
307
|
-
const payload =
|
|
308
|
-
|
|
309
|
-
|
|
294
|
+
acf.jsxNameReplacements["edblock"] = function EDBlock(props) {
|
|
295
|
+
const payload = useMemo(() => {
|
|
296
|
+
const raw = props["data-payload"];
|
|
297
|
+
return raw ? JSON.parse(decodeURIComponent(raw)) : null;
|
|
298
|
+
}, [props["data-payload"]]);
|
|
299
|
+
return _jsx(EditableBlock, { payload: payload ?? {} });
|
|
300
|
+
};
|
|
310
301
|
}
|
|
311
302
|
}
|
|
312
303
|
const BlockPropsStore = proxy({
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "2.3.
|
|
1
|
+
export declare const VERSION = "2.3.15";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/node/cli/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "2.3.
|
|
1
|
+
export const VERSION = "2.3.15";
|