eddev 2.0.0-beta.190 → 2.0.0-beta.192

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.
@@ -1,10 +1,9 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useEffect, useMemo } from "react";
2
+ import { useMemo } from "react";
3
3
  import { ContentBlocks } from "./ContentBlocks.js";
4
- import { applyTemplateBlocks, transformBlockTemplate } from "./editor/block-templates.js";
4
+ import { transformBlockTemplate } from "./editor/block-templates.js";
5
5
  import { blocksByTag } from "./editor/blocks-by-tag.js";
6
6
  import { useBlockContext, useInnerBlocks } from "./inline-editing.js";
7
- import { hash } from "object-code";
8
7
  const Appender = ({ config, ...props }) => {
9
8
  const clientId = useBlockContext()?.block[1].clientId;
10
9
  if (config?.type === "button") {
@@ -85,16 +84,16 @@ export function InnerBlocks(props) {
85
84
  * Adds support for headerTemplate/defaultBlocks/footerTemplate, which was first introduced in `_editor.tsx` for generate templates.
86
85
  */
87
86
  const blockId = inlineContext?.block[1].clientId;
88
- useEffect(() => {
89
- if (props.defaultBlocks || props.headerTemplate || props.footerTemplate) {
90
- const newBlocks = applyTemplateBlocks(inlineContext?.innerBlocks ?? [], props);
91
- wp.data.dispatch(wp.blockEditor.store).replaceInnerBlocks(blockId, newBlocks);
92
- }
93
- }, [
94
- hash(inlineContext?.innerBlocks.map((b) => [b.blockName, b.clientId])),
95
- hash([props.template, props.defaultBlocks, props.headerTemplate, props.footerTemplate]),
96
- blockId,
97
- ]);
87
+ // useEffect(() => {
88
+ // if (props.defaultBlocks || props.headerTemplate || props.footerTemplate) {
89
+ // const newBlocks = applyTemplateBlocks(inlineContext?.innerBlocks ?? [], props)
90
+ // wp.data.dispatch(wp.blockEditor.store).replaceInnerBlocks(blockId, newBlocks)
91
+ // }
92
+ // }, [
93
+ // hash(inlineContext?.innerBlocks.map((b: any) => [b.blockName, b.clientId])),
94
+ // hash([props.template, props.defaultBlocks, props.headerTemplate, props.footerTemplate]),
95
+ // blockId,
96
+ // ])
98
97
  return (_jsx("div", { ...innerBlocksProps, className: [innerBlocksProps.className, props.adminClassName].filter(Boolean).join(" ") }));
99
98
  }
100
99
  }
@@ -1 +1 @@
1
- {"version":3,"file":"installGutenbergHooks.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/installGutenbergHooks.tsx"],"names":[],"mappings":"AA4BA,eAAO,MAAM,oBAAoB;;CAAgC,CAAA;AAEjE,wBAAgB,iBAAiB,kBAsBhC;AAED,wBAAgB,uBAAuB,SAiOtC"}
1
+ {"version":3,"file":"installGutenbergHooks.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/installGutenbergHooks.tsx"],"names":[],"mappings":"AA4BA,eAAO,MAAM,oBAAoB;;CAAgC,CAAA;AAEjE,wBAAgB,iBAAiB,kBAsBhC;AAED,wBAAgB,uBAAuB,SA4OtC"}
@@ -142,23 +142,31 @@ export function installEDGutenbergHooks() {
142
142
  ;
143
143
  wp.data.dispatch("core/block-editor").setTemplateValidity(true);
144
144
  }, []);
145
- const [index, setIndex] = useState(-1);
146
- const [children, setChildren] = useState([]);
145
+ function getIndex() {
146
+ const { getBlockIndex } = wp.data.select("core/block-editor");
147
+ return getBlockIndex(props.clientId);
148
+ }
149
+ function getChildren() {
150
+ const { getBlock, getBlockOrder } = wp.data.select("core/block-editor");
151
+ const innerBlockIDs = getBlockOrder(props.clientId);
152
+ const children = innerBlockIDs.map((id) => {
153
+ return getBlock(id);
154
+ });
155
+ return children;
156
+ }
157
+ const [index, setIndex] = useState(getIndex);
158
+ const [children, setChildren] = useState(getChildren);
147
159
  useEffect(() => {
148
160
  return wp.data.subscribe(() => {
149
- const { getBlock, getBlockOrder, getBlockIndex } = wp.data.select("core/block-editor");
150
- const innerBlockIDs = getBlockOrder(props.clientId);
151
- const children = innerBlockIDs.map((id) => {
152
- return getBlock(id);
153
- });
154
- setIndex(getBlockIndex(props.clientId));
161
+ setIndex(getIndex());
162
+ const children = getChildren();
155
163
  setChildren((current) => current.length === children.length
156
164
  ? current.every((item, i) => item === children[i])
157
165
  ? current
158
166
  : children
159
167
  : children);
160
168
  }, []);
161
- }, [props.clientId]);
169
+ }, [props.clientId, props.attributes]);
162
170
  return (_jsx(BlockContext.Provider, { value: { name, props }, children: _jsx(InlineEditingContextProvider, { values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], index: index ?? -1, onChange: (attrs) => {
163
171
  props.setAttributes({ ...props.attributes, inline: attrs });
164
172
  }, insertBlocksAfter: props.insertBlocksAfter, children: _jsx(EditorHighlights, { enabled: true, clientId: props.clientId, children: edit.call(self, props) }) }) }));
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.0-beta.190";
1
+ export declare const VERSION = "2.0.0-beta.192";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const VERSION = "2.0.0-beta.190";
1
+ export const VERSION = "2.0.0-beta.192";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eddev",
3
- "version": "2.0.0-beta.190",
3
+ "version": "2.0.0-beta.192",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "type": "module",