eddev 0.2.2-beta.1 → 0.2.2-beta.5
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/blocks/ContentBlocks.js +3 -0
- package/blocks/blockAttributes.d.ts +2 -0
- package/blocks/blockAttributes.js +7 -1
- package/blocks/inlineEditing.d.ts +7 -2
- package/blocks/inlineEditing.js +14 -4
- package/blocks/installGutenbergHooks.js +14 -6
- package/build/graphql-codegen/graphql-codegen-blocks.js +0 -1
- package/build/serverless/create-next-app.js +0 -4
- package/build/workers/codegen-worker-script.js +3 -1
- package/hooks/useAppData.js +4 -0
- package/package.json +1 -1
- package/serverless-template/_utils/fetch-wp.ts +1 -0
- package/serverless-template/pages/_app.tsx +3 -1
package/blocks/ContentBlocks.js
CHANGED
|
@@ -32,6 +32,9 @@ var react_1 = require("react");
|
|
|
32
32
|
var ErrorBoundaryFrontend_1 = require("./ErrorBoundaryFrontend");
|
|
33
33
|
exports.BlocksContext = (0, react_1.createContext)(undefined);
|
|
34
34
|
function ContentBlocks(props) {
|
|
35
|
+
if (process.admin) {
|
|
36
|
+
throw new Error("ContentBlocks should only be used on the frontend.");
|
|
37
|
+
}
|
|
35
38
|
if (!Array.isArray(props.blocks))
|
|
36
39
|
return null;
|
|
37
40
|
var parentContext = (0, react_1.useContext)(exports.BlocksContext);
|
|
@@ -7,8 +7,10 @@ declare type ProviderProps = PropsWithChildren<{
|
|
|
7
7
|
values: Attributes;
|
|
8
8
|
innerBlocks: ContentBlock[];
|
|
9
9
|
onChange?: (attrs: Attributes) => void;
|
|
10
|
+
insertBlocksAfter?: (block: any) => void;
|
|
10
11
|
}>;
|
|
11
12
|
export declare function InlineEditingContextProvider(props: ProviderProps): JSX.Element;
|
|
12
13
|
export declare function useInlineEditableValue<T>(key: string, defaultValue?: T): [T, (value: T) => void];
|
|
14
|
+
export declare function useBlockAppender(): ((block: any) => void) | undefined;
|
|
13
15
|
export declare function useInnerBlocks(): ContentBlock[];
|
|
14
16
|
export {};
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.useInnerBlocks = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
|
|
14
|
+
exports.useInnerBlocks = exports.useBlockAppender = exports.useInlineEditableValue = exports.InlineEditingContextProvider = void 0;
|
|
15
15
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
16
16
|
var react_1 = require("react");
|
|
17
17
|
var InlineEditingContext = (0, react_1.createContext)(undefined);
|
|
@@ -29,6 +29,7 @@ function InlineEditingContextProvider(props) {
|
|
|
29
29
|
props.onChange(__assign(__assign({}, (props.values || {})), (_a = {}, _a[key] = value, _a)));
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
insertBlocksAfter: props.insertBlocksAfter,
|
|
32
33
|
} }, { children: props.children }), void 0));
|
|
33
34
|
}
|
|
34
35
|
exports.InlineEditingContextProvider = InlineEditingContextProvider;
|
|
@@ -43,6 +44,11 @@ function useInlineEditableValue(key, defaultValue) {
|
|
|
43
44
|
];
|
|
44
45
|
}
|
|
45
46
|
exports.useInlineEditableValue = useInlineEditableValue;
|
|
47
|
+
function useBlockAppender() {
|
|
48
|
+
var ctx = (0, react_1.useContext)(InlineEditingContext);
|
|
49
|
+
return ctx === null || ctx === void 0 ? void 0 : ctx.insertBlocksAfter;
|
|
50
|
+
}
|
|
51
|
+
exports.useBlockAppender = useBlockAppender;
|
|
46
52
|
function useInnerBlocks() {
|
|
47
53
|
var ctx = (0, react_1.useContext)(InlineEditingContext);
|
|
48
54
|
return (ctx === null || ctx === void 0 ? void 0 : ctx.innerBlocks) || [];
|
|
@@ -11,14 +11,19 @@ declare type PropTypes<T extends ElementType> = {
|
|
|
11
11
|
inlineToolbar?: boolean;
|
|
12
12
|
/** Specify default content to use on the frontend if nothing has been entered */
|
|
13
13
|
defaultValue?: string;
|
|
14
|
+
/** Append a new block when the user hits 'Enter' */
|
|
15
|
+
appendOnEnter?: boolean;
|
|
14
16
|
} & React.ComponentPropsWithoutRef<T>;
|
|
15
|
-
export declare function EditableText<T extends ElementType>({ id, as, ...props }: PropTypes<T>): JSX.Element | null;
|
|
17
|
+
export declare function EditableText<T extends ElementType>({ id, as, appendOnEnter, ...props }: PropTypes<T>): JSX.Element | null;
|
|
18
|
+
declare type AppenderConfig = {
|
|
19
|
+
button?: boolean;
|
|
20
|
+
};
|
|
16
21
|
declare type InnerBlocksProps = {
|
|
17
22
|
allowedBlocks?: string[];
|
|
18
23
|
orientation?: "horizontal" | "vertical";
|
|
19
24
|
templateLock?: any;
|
|
20
25
|
template?: any;
|
|
21
|
-
|
|
26
|
+
appender?: AppenderConfig;
|
|
22
27
|
} & ContentBlocksSettings;
|
|
23
28
|
export declare function InnerBlocks(props: InnerBlocksProps): JSX.Element;
|
|
24
29
|
export {};
|
package/blocks/inlineEditing.js
CHANGED
|
@@ -26,6 +26,8 @@ exports.InnerBlocks = exports.EditableText = void 0;
|
|
|
26
26
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
27
27
|
// @ts-ignore
|
|
28
28
|
var block_editor_1 = require("@wordpress/block-editor");
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
var blocks_1 = require("@wordpress/blocks");
|
|
29
31
|
var ContentBlocks_1 = require("./ContentBlocks");
|
|
30
32
|
var react_1 = require("react");
|
|
31
33
|
var blockAttributes_1 = require("./blockAttributes");
|
|
@@ -33,10 +35,17 @@ var react_2 = require("@stitches/react");
|
|
|
33
35
|
var remoteProps_1 = require("../routing/remoteProps");
|
|
34
36
|
var __1 = require("..");
|
|
35
37
|
function EditableText(_a) {
|
|
36
|
-
var id = _a.id, as = _a.as, props = __rest(_a, ["id", "as"]);
|
|
38
|
+
var id = _a.id, as = _a.as, appendOnEnter = _a.appendOnEnter, props = __rest(_a, ["id", "as", "appendOnEnter"]);
|
|
37
39
|
if (process.admin) {
|
|
38
40
|
var _b = (0, blockAttributes_1.useInlineEditableValue)(id), value = _b[0], setValue = _b[1];
|
|
39
|
-
|
|
41
|
+
var appendBlocks_1 = (0, blockAttributes_1.useBlockAppender)();
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)(block_editor_1.RichText, __assign({}, props, { tagName: as, value: value || "", onChange: setValue, disableLineBreaks: props.disableLineBreaks, onKeyDownCapture: function (e) {
|
|
43
|
+
if (e.key === "Enter" && appendOnEnter && appendBlocks_1) {
|
|
44
|
+
appendBlocks_1([(0, blocks_1.createBlock)("core/paragraph")]);
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
e.stopPropagation();
|
|
47
|
+
}
|
|
48
|
+
} }), void 0));
|
|
40
49
|
}
|
|
41
50
|
else {
|
|
42
51
|
var value = (0, blockAttributes_1.useInlineEditableValue)(id)[0];
|
|
@@ -69,8 +78,9 @@ exports.EditableText = EditableText;
|
|
|
69
78
|
function InnerBlocks(props) {
|
|
70
79
|
if (process.admin) {
|
|
71
80
|
var allowedBlocks = props.allowedBlocks;
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(InnerBlocksAdminWrapper, __assign({ orientation: props.orientation || "vertical" }, { children: (0, jsx_runtime_1.jsx)(block_editor_1.InnerBlocks, { orientation: props.orientation, allowedBlocks: allowedBlocks,
|
|
82
|
+
// renderAppender={ButtonBlockAppender}
|
|
83
|
+
templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
|
|
74
84
|
}
|
|
75
85
|
else {
|
|
76
86
|
var blocks = (0, blockAttributes_1.useInnerBlocks)();
|
|
@@ -47,6 +47,11 @@ function installEDGutenbergHooks() {
|
|
|
47
47
|
if (!window.wp.blockEditor)
|
|
48
48
|
return;
|
|
49
49
|
(0, react_2.globalCss)({
|
|
50
|
+
".edit-post-visual-editor__post-title-wrapper": {
|
|
51
|
+
width: "var(--grid-inner-width)",
|
|
52
|
+
marginLeft: "auto",
|
|
53
|
+
marginRight: "auto",
|
|
54
|
+
},
|
|
50
55
|
".block-editor-block-list__block:hover": {
|
|
51
56
|
outline: "1px solid #e1e1e1",
|
|
52
57
|
},
|
|
@@ -84,10 +89,8 @@ function installEDGutenbergHooks() {
|
|
|
84
89
|
// @ts-ignore
|
|
85
90
|
window.wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
86
91
|
}, []);
|
|
87
|
-
console.log("PROPS", props);
|
|
88
|
-
// console.log(useBlockProps(), useBlockEditContext(), useInnerBlocksProps())
|
|
89
92
|
var children = (0, data_1.useSelect)(function (select) {
|
|
90
|
-
var _a = select(
|
|
93
|
+
var _a = select("core/block-editor"), getBlock = _a.getBlock, getBlockOrder = _a.getBlockOrder;
|
|
91
94
|
var innerBlockIDs = getBlockOrder(props.clientId);
|
|
92
95
|
var children = innerBlockIDs.map(function (id) {
|
|
93
96
|
return getBlock(id);
|
|
@@ -96,7 +99,7 @@ function installEDGutenbergHooks() {
|
|
|
96
99
|
}, []);
|
|
97
100
|
return ((0, jsx_runtime_1.jsx)(BlockContext.Provider, __assign({ value: { name: name, props: props } }, { children: (0, jsx_runtime_1.jsx)(blockAttributes_1.InlineEditingContextProvider, __assign({ values: props.attributes.inline || {}, innerBlocks: children, onChange: function (attrs) {
|
|
98
101
|
props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
|
|
99
|
-
} }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
102
|
+
}, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
100
103
|
};
|
|
101
104
|
}
|
|
102
105
|
// Remember the block type name
|
|
@@ -166,8 +169,13 @@ function installEDGutenbergHooks() {
|
|
|
166
169
|
var parseJSX = acf.parseJSX;
|
|
167
170
|
// @ts-ignore
|
|
168
171
|
acf.parseJSX = function (html) {
|
|
169
|
-
|
|
170
|
-
|
|
172
|
+
var payload;
|
|
173
|
+
try {
|
|
174
|
+
payload = JSON.parse(html.replace(/(^[^>]+>|<[^>]+>$)/g, ""));
|
|
175
|
+
}
|
|
176
|
+
catch (err) {
|
|
177
|
+
throw new Error("eddev: Error parsing block data from: \n" + html);
|
|
178
|
+
}
|
|
171
179
|
return (0, jsx_runtime_1.jsx)(BlockRenderer, { payload: payload }, void 0);
|
|
172
180
|
};
|
|
173
181
|
}
|
|
@@ -185,10 +185,6 @@ function createNextApp(opts) {
|
|
|
185
185
|
// Write APIs proxy code
|
|
186
186
|
_b.sent();
|
|
187
187
|
// Remove pages/api/trpc directory if no _rpc is found
|
|
188
|
-
console.log({
|
|
189
|
-
index: (0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts"),
|
|
190
|
-
rpc: (0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"),
|
|
191
|
-
});
|
|
192
188
|
if (!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc/index.ts")) &&
|
|
193
189
|
!(0, fs_1.existsSync)((0, path_1.join)(opts.baseDirectory, "apis/_rpc.ts"))) {
|
|
194
190
|
// removeSync(join(serverlessDirectory, "pages/api/trpc"))
|
|
@@ -181,7 +181,9 @@ function beginWork(opts) {
|
|
|
181
181
|
if (!endpoint) {
|
|
182
182
|
sendSignal({
|
|
183
183
|
code: "error",
|
|
184
|
-
errors: [
|
|
184
|
+
errors: [
|
|
185
|
+
"Could not find DEBUG_GRAPHQL_URL value in .env. This will be automatically populated once you visit WP Admin first the first time!",
|
|
186
|
+
],
|
|
185
187
|
});
|
|
186
188
|
regenerating = false;
|
|
187
189
|
return [2 /*return*/];
|
package/hooks/useAppData.js
CHANGED
|
@@ -22,6 +22,10 @@ function useAppData(selector) {
|
|
|
22
22
|
return selector(value);
|
|
23
23
|
return value;
|
|
24
24
|
}
|
|
25
|
+
else if (process.admin) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
return selector ? selector(__ED_APP_DATA.data) : __ED_APP_DATA.data;
|
|
28
|
+
}
|
|
25
29
|
else {
|
|
26
30
|
return useAppDataStore(function (store) {
|
|
27
31
|
if (selector)
|
package/package.json
CHANGED
|
@@ -26,7 +26,9 @@ function Root({ Component, pageProps }: AppProps) {
|
|
|
26
26
|
|
|
27
27
|
if (!appData) return <div />
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
if (!View) {
|
|
30
|
+
console.log(`Could not load view named "${pageProps.view}"`)
|
|
31
|
+
}
|
|
30
32
|
|
|
31
33
|
return (
|
|
32
34
|
<ServerlessAppDataProvider value={appData}>
|