eddev 0.2.2-beta.2 → 0.2.2-beta.4
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 +1 -1
- package/blocks/blockAttributes.d.ts +2 -0
- package/blocks/blockAttributes.js +7 -1
- package/blocks/inlineEditing.d.ts +2 -0
- package/blocks/inlineEditing.js +10 -2
- package/blocks/installGutenbergHooks.js +7 -3
- package/build/graphql-codegen/graphql-codegen-blocks.js +0 -1
- package/build/serverless/create-next-app.js +0 -4
- package/package.json +1 -1
package/blocks/ContentBlocks.js
CHANGED
|
@@ -33,7 +33,7 @@ var ErrorBoundaryFrontend_1 = require("./ErrorBoundaryFrontend");
|
|
|
33
33
|
exports.BlocksContext = (0, react_1.createContext)(undefined);
|
|
34
34
|
function ContentBlocks(props) {
|
|
35
35
|
if (process.admin) {
|
|
36
|
-
throw new Error("ContentBlocks
|
|
36
|
+
throw new Error("ContentBlocks should only be used on the frontend.");
|
|
37
37
|
}
|
|
38
38
|
if (!Array.isArray(props.blocks))
|
|
39
39
|
return null;
|
|
@@ -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,6 +11,8 @@ 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
17
|
export declare function EditableText<T extends ElementType>({ id, as, ...props }: PropTypes<T>): JSX.Element | null;
|
|
16
18
|
declare type InnerBlocksProps = {
|
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");
|
|
@@ -36,7 +38,14 @@ function EditableText(_a) {
|
|
|
36
38
|
var id = _a.id, as = _a.as, props = __rest(_a, ["id", "as"]);
|
|
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" && props.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,7 +78,6 @@ exports.EditableText = EditableText;
|
|
|
69
78
|
function InnerBlocks(props) {
|
|
70
79
|
if (process.admin) {
|
|
71
80
|
var allowedBlocks = props.allowedBlocks;
|
|
72
|
-
// console.log("ALLOWED BLOCKS", props.allowTaggedBlocks, allowedBlocks)
|
|
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, renderAppender: props.renderAppender, templateLock: props.templateLock, template: props.template }, void 0) }), void 0));
|
|
74
82
|
}
|
|
75
83
|
else {
|
|
@@ -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,9 +89,8 @@ function installEDGutenbergHooks() {
|
|
|
84
89
|
// @ts-ignore
|
|
85
90
|
window.wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
86
91
|
}, []);
|
|
87
|
-
// console.log(useBlockProps(), useBlockEditContext(), useInnerBlocksProps())
|
|
88
92
|
var children = (0, data_1.useSelect)(function (select) {
|
|
89
|
-
var _a = select(
|
|
93
|
+
var _a = select("core/block-editor"), getBlock = _a.getBlock, getBlockOrder = _a.getBlockOrder;
|
|
90
94
|
var innerBlockIDs = getBlockOrder(props.clientId);
|
|
91
95
|
var children = innerBlockIDs.map(function (id) {
|
|
92
96
|
return getBlock(id);
|
|
@@ -95,7 +99,7 @@ function installEDGutenbergHooks() {
|
|
|
95
99
|
}, []);
|
|
96
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) {
|
|
97
101
|
props.setAttributes(__assign(__assign({}, props.attributes), { inline: attrs }));
|
|
98
|
-
} }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
102
|
+
}, insertBlocksAfter: props.insertBlocksAfter }, { children: edit_1.call(self, props) }), void 0) }), void 0));
|
|
99
103
|
};
|
|
100
104
|
}
|
|
101
105
|
// Remember the block type name
|
|
@@ -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"))
|