eddev 2.0.0-beta.12 → 2.0.0-beta.121
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/css/editor-styles.css +4 -0
- package/dist/app/entry/HydrationOverlay.d.ts +1 -0
- package/dist/app/entry/HydrationOverlay.js +2 -0
- package/dist/app/entry/MetaTags.d.ts +7 -0
- package/dist/app/entry/MetaTags.js +17 -0
- package/dist/app/entry/boot-admin.js +9 -3
- package/dist/app/entry/hydration-script.d.ts +1 -0
- package/dist/app/entry/hydration-script.js +18 -0
- package/dist/app/entry/spa-root.js +3 -5
- package/dist/app/entry/ssr-root-client.d.ts +3 -1
- package/dist/app/entry/ssr-root-client.js +18 -6
- package/dist/app/entry/ssr-root.d.ts +3 -4
- package/dist/app/entry/ssr-root.js +19 -19
- package/dist/app/lib/admin/index.d.ts +2 -2
- package/dist/app/lib/admin/index.js +2 -2
- package/dist/app/lib/admin/installFieldTypes.js +3 -1
- package/dist/app/lib/admin/runWidgets.js +1 -1
- package/dist/app/lib/blocks/ContentBlocks.d.ts +1 -1
- package/dist/app/lib/blocks/ContentBlocks.js +5 -5
- package/dist/app/lib/blocks/EditableText.d.ts +15 -2
- package/dist/app/lib/blocks/EditableText.js +10 -4
- package/dist/app/lib/blocks/InnerBlocks.d.ts +21 -7
- package/dist/app/lib/blocks/InnerBlocks.js +75 -28
- package/dist/app/lib/blocks/block-utils.d.ts +2 -2
- package/dist/app/lib/blocks/block-utils.js +2 -2
- package/dist/app/lib/blocks/defineBlock.d.ts +3 -0
- package/dist/app/lib/blocks/defineBlock.js +7 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +7 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.js +164 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +17 -12
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
- package/dist/app/lib/blocks/editor/block-templates.d.ts +6 -0
- package/dist/app/lib/blocks/editor/block-templates.js +64 -0
- package/dist/app/lib/blocks/editor/create-block.d.ts +9 -0
- package/dist/app/lib/blocks/editor/create-block.js +13 -0
- package/dist/app/lib/blocks/editor/editor-config.d.ts +70 -7
- package/dist/app/lib/blocks/editor/editor-config.js +29 -62
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +3 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +105 -16
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +6 -0
- package/dist/app/lib/blocks/editor/root-blocks.js +30 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +1 -1
- package/dist/app/lib/blocks/index.d.ts +10 -9
- package/dist/app/lib/blocks/index.js +10 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +9 -1
- package/dist/app/lib/blocks/inline-editing.js +7 -5
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +1 -1
- package/dist/app/lib/devtools/components/DevUI.js +4 -3
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +29 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -1
- package/dist/app/lib/devtools/hooks/usePersistState.js +11 -2
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +2305 -1261
- package/dist/app/lib/devtools/hooks/useTailwind.js +1 -1
- package/dist/app/lib/devtools/index.d.ts +1 -1
- package/dist/app/lib/devtools/index.js +1 -1
- package/dist/app/lib/devtools/loader.js +8 -7
- package/dist/app/lib/devtools/useQueryDebug.d.ts +7 -1
- package/dist/app/lib/devtools/useQueryDebug.js +5 -8
- package/dist/app/lib/dynamic/dynamic.d.ts +1 -1
- package/dist/app/lib/dynamic/dynamic.js +5 -1
- package/dist/app/lib/dynamic/index.d.ts +1 -1
- package/dist/app/lib/dynamic/index.js +1 -1
- package/dist/app/lib/hooks/index.d.ts +4 -5
- package/dist/app/lib/hooks/index.js +4 -5
- package/dist/app/lib/hooks/queryUtils.d.ts +37 -3
- package/dist/app/lib/hooks/queryUtils.js +66 -26
- package/dist/app/lib/hooks/useAppData.js +12 -1
- package/dist/app/lib/hooks/useRPC.d.ts +0 -4
- package/dist/app/lib/hooks/useRPC.js +1 -8
- package/dist/app/lib/internal/finalize-rpc.d.ts +17 -0
- package/dist/app/lib/internal/finalize-rpc.js +3 -0
- package/dist/app/lib/internal/index.d.ts +5 -4
- package/dist/app/lib/internal/index.js +5 -4
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +21 -21
- package/dist/app/lib/legacy-stitches/createStitches.js +1 -1
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -1
- package/dist/app/lib/legacy-stitches/index.js +1 -1
- package/dist/app/lib/routing/components/BackButton.d.ts +49 -0
- package/dist/app/lib/routing/components/BackButton.js +47 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +5 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +98 -19
- package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
- package/dist/app/lib/routing/components/ClientOnly.js +2 -2
- package/dist/app/lib/routing/components/Link.d.ts +1 -0
- package/dist/app/lib/routing/components/Link.js +11 -12
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -1
- package/dist/app/lib/routing/components/RouteRenderer.js +7 -6
- package/dist/app/lib/routing/components/SSRRouter.d.ts +2 -2
- package/dist/app/lib/routing/components/SSRRouter.js +5 -6
- package/dist/app/lib/routing/components/ScrollRestoration.js +5 -2
- package/dist/app/lib/routing/context.d.ts +8 -5
- package/dist/app/lib/routing/context.js +13 -96
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +2 -1
- package/dist/app/lib/routing/hooks/useRestorableState.js +2 -1
- package/dist/app/lib/routing/hooks/useRoute.d.ts +16 -1
- package/dist/app/lib/routing/hooks/useRoute.js +22 -1
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +5 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.js +9 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouteTransition.js +1 -1
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouter.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterEvents.js +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -1
- package/dist/app/lib/routing/hooks/useRouterState.js +1 -1
- package/dist/app/lib/routing/hooks/useSearchParams.js +2 -2
- package/dist/app/lib/routing/index.d.ts +14 -13
- package/dist/app/lib/routing/index.js +14 -13
- package/dist/app/lib/routing/loader.d.ts +2 -2
- package/dist/app/lib/routing/loader.js +20 -11
- package/dist/app/lib/routing/types.d.ts +37 -10
- package/dist/app/lib/routing/utils.d.ts +5 -2
- package/dist/app/lib/routing/utils.js +37 -4
- package/dist/app/lib/{hooks → runtime}/apiConfig.d.ts +6 -2
- package/dist/app/lib/runtime/apiConfig.js +6 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +39 -0
- package/dist/app/lib/runtime/errorHandling.js +6 -0
- package/dist/app/lib/runtime/index.d.ts +2 -0
- package/dist/app/lib/runtime/index.js +2 -0
- package/dist/app/lib/views/index.d.ts +1 -1
- package/dist/app/lib/views/index.js +1 -1
- package/dist/app/server/defineRouter.d.ts +2 -0
- package/dist/app/server/defineRouter.js +4 -0
- package/dist/app/server/index.d.ts +5 -3
- package/dist/app/server/index.js +5 -3
- package/dist/app/server/proxy-wp-admin.d.ts +1 -2
- package/dist/app/server/proxy-wp-admin.js +41 -14
- package/dist/app/server/render-ssr-page.d.ts +27 -2
- package/dist/app/server/render-ssr-page.js +192 -12
- package/dist/app/server/rpc.d.ts +56 -0
- package/dist/app/server/rpc.js +18 -0
- package/dist/app/server/server-context.d.ts +44 -4
- package/dist/app/server/server-context.js +305 -28
- package/dist/app/server/utils/replace-host.d.ts +1 -1
- package/dist/app/server/utils/replace-host.js +10 -2
- package/dist/app/server/utils/swr-cache.d.ts +4 -0
- package/dist/app/server/utils/swr-cache.js +31 -0
- package/dist/app/utils/APIProvider.d.ts +2 -0
- package/dist/app/utils/APIProvider.js +5 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +19 -0
- package/dist/app/utils/BlockErrorBoundary.js +38 -0
- package/dist/app/utils/ErrorMessage.d.ts +5 -0
- package/dist/app/utils/ErrorMessage.js +14 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +18 -0
- package/dist/app/utils/RouteErrorBoundary.js +38 -0
- package/dist/app/utils/asset-capture.d.ts +2 -0
- package/dist/app/utils/asset-capture.js +5 -0
- package/dist/app/utils/hydration-debugger.d.ts +13 -0
- package/dist/app/utils/hydration-debugger.js +11 -0
- package/dist/app/utils/query-client.d.ts +2 -0
- package/dist/app/utils/query-client.js +5 -1
- package/dist/app/utils/query-monitor.d.ts +26 -0
- package/dist/app/utils/query-monitor.js +7 -0
- package/dist/app/utils/trpc-client.d.ts +2 -0
- package/dist/app/utils/trpc-client.js +39 -0
- package/dist/node/cli/cli-worker.js +10 -5
- package/dist/node/cli/cli.js +81 -11
- package/dist/node/cli/display/CLIApp.js +3 -6
- package/dist/node/cli/display/boot-cli-app.js +1 -1
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -1
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -11
- package/dist/node/cli/display/tools/cli-tools.js +9 -9
- package/dist/node/cli/version.d.ts +1 -1
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.js +2 -1
- package/dist/node/compiler/bundler.admin.d.ts +1 -1
- package/dist/node/compiler/bundler.admin.js +1 -1
- package/dist/node/compiler/bundler.frontend.js +1 -1
- package/dist/node/compiler/dev-server.js +10 -0
- package/dist/node/compiler/get-vite-config.d.ts +7 -1
- package/dist/node/compiler/get-vite-config.js +96 -16
- package/dist/node/compiler/vinxi-app.d.ts +12 -0
- package/dist/node/compiler/vinxi-app.js +139 -32
- package/dist/node/compiler/vinxi-codegen.js +345 -112
- package/dist/node/graphql/graphql-codegen.d.ts +11 -1
- package/dist/node/graphql/graphql-codegen.js +210 -33
- package/dist/node/graphql/graphql-schema-loader.d.ts +2 -1
- package/dist/node/graphql/graphql-schema-loader.js +5 -16
- package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
- package/dist/node/graphql/query-files-loader.d.ts +3 -0
- package/dist/node/graphql/query-files-loader.js +5 -0
- package/dist/node/project/config.d.ts +159 -73
- package/dist/node/project/config.js +69 -20
- package/dist/node/project/env.d.ts +4 -0
- package/dist/node/project/env.js +1 -0
- package/dist/node/project/manifest/block-manifest.js +2 -1
- package/dist/node/project/manifest/manifest.d.ts +1 -0
- package/dist/node/project/manifest/manifest.js +14 -10
- package/dist/node/project/manifest/routes-manifest.d.ts +20 -0
- package/dist/node/project/manifest/routes-manifest.js +74 -0
- package/dist/node/project/manifest/view-manifest.js +1 -1
- package/dist/node/project/project.d.ts +11 -1
- package/dist/node/project/project.js +61 -7
- package/dist/node/project/wp-info.d.ts +1 -0
- package/dist/node/project/wp-info.js +13 -1
- package/dist/node/storybook/index.d.ts +2 -0
- package/dist/node/storybook/index.js +13 -0
- package/dist/node/types/block-type.d.ts +25 -20
- package/dist/node/types/block-type.js +1 -0
- package/dist/node/types/view-type.d.ts +7 -7
- package/dist/node/utils/fetch-wp.d.ts +1 -0
- package/dist/node/utils/fetch-wp.js +27 -0
- package/dist/node/utils/fs-codegen.d.ts +2 -0
- package/dist/node/utils/fs-codegen.js +2 -1
- package/dist/node/utils/is-deploying.js +1 -1
- package/dist/node/utils/report-builder.d.ts +6 -6
- package/dist/node/utils/self-signed-cert.d.ts +2 -0
- package/dist/node/utils/self-signed-cert.js +10 -2
- package/dist/node/utils/stateful-log.js +2 -0
- package/dist/node/utils/watch-file-tree.d.ts +17 -3
- package/dist/node/utils/watch-file-tree.js +12 -5
- package/package.json +21 -12
- package/types.app.d.ts +4 -2
- package/types.app.internal.d.ts +2 -2
- package/types.meta.d.ts +105 -0
- package/types.node.d.ts +3 -3
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.d.ts +0 -15
- package/dist/app/lib/blocks/ErrorBoundaryFrontend.js +0 -35
- package/dist/app/lib/hooks/apiConfig.js +0 -4
- package/dist/app/lib/hooks/usePageLoad.d.ts +0 -6
- package/dist/app/lib/hooks/usePageLoad.js +0 -5
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { subscribe, useSnapshot } from "valtio";
|
|
4
|
+
import { proxyMap } from "valtio/utils";
|
|
5
|
+
import { getBlockMetadata } from "../block-utils.js";
|
|
6
|
+
import { InlineEditingContextProvider } from "../inline-editing.js";
|
|
7
|
+
import { EditorHighlights } from "./EditorHighlights.js";
|
|
8
|
+
import { BlockContext, EditableBlock } from "./EditorSupport.js";
|
|
9
|
+
import { resolveAcfBlockName } from "./block-templates.js";
|
|
10
|
+
import { blocksByTag } from "./blocks-by-tag.js";
|
|
11
|
+
import { editorConfigStore, getEditingPostInfo, watchEditorTemplate } from "./editor-config.js";
|
|
12
|
+
import { rootBlocks } from "./root-blocks.js";
|
|
9
13
|
function listenForHandleResize() {
|
|
10
14
|
let interval = setInterval(() => {
|
|
11
15
|
let viewportTarget = document.querySelector(".interface-interface-skeleton__content");
|
|
@@ -19,16 +23,27 @@ function listenForHandleResize() {
|
|
|
19
23
|
}
|
|
20
24
|
}, 100);
|
|
21
25
|
}
|
|
26
|
+
export const blockMetaDescriptors = proxyMap();
|
|
22
27
|
export function whenEditorIsReady() {
|
|
23
28
|
return new Promise((resolve) => {
|
|
29
|
+
let ready = false;
|
|
24
30
|
const unsubscribe = wp.data.subscribe(() => {
|
|
25
31
|
// This will trigger after the initial render blocking, before the window load event
|
|
26
32
|
// This seems currently more reliable than using __unstableIsEditorReady
|
|
27
33
|
if (wp.data.select("core/editor").isCleanNewPost() || wp.data.select("core/block-editor").getBlockCount() > 0) {
|
|
34
|
+
if (ready)
|
|
35
|
+
return;
|
|
36
|
+
ready = true;
|
|
28
37
|
unsubscribe();
|
|
29
38
|
resolve();
|
|
30
39
|
}
|
|
31
40
|
});
|
|
41
|
+
setTimeout(() => {
|
|
42
|
+
if (ready)
|
|
43
|
+
return;
|
|
44
|
+
unsubscribe();
|
|
45
|
+
resolve();
|
|
46
|
+
}, 1000);
|
|
32
47
|
});
|
|
33
48
|
}
|
|
34
49
|
export function installEDGutenbergHooks() {
|
|
@@ -45,6 +60,45 @@ export function installEDGutenbergHooks() {
|
|
|
45
60
|
};
|
|
46
61
|
}, "withClientIdClassName");
|
|
47
62
|
wp.hooks.addFilter("editor.BlockListBlock", "ed", withClientIdClassName);
|
|
63
|
+
// Manage custom rich text formats
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
subscribe(editorConfigStore, () => {
|
|
66
|
+
const formats = editorConfigStore.config?.customRichTextFormats;
|
|
67
|
+
if (formats) {
|
|
68
|
+
const activeFormats = wp.data.select("core/rich-text").getFormatTypes();
|
|
69
|
+
formats.forEach((format) => {
|
|
70
|
+
if (activeFormats.some((f) => f.name === format.id)) {
|
|
71
|
+
wp.richText.unregisterFormatType(format.id);
|
|
72
|
+
}
|
|
73
|
+
const EditComponent = (props) => {
|
|
74
|
+
if (format.disabledByDefault) {
|
|
75
|
+
const explicitlyEnabled = props.contentRef.current
|
|
76
|
+
?.getAttribute("data-allowed-formats")
|
|
77
|
+
?.includes(format.id);
|
|
78
|
+
if (!explicitlyEnabled) {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return (_jsx(wp.components.Fill, { name: "BlockFormatControls", children: _jsx(wp.components.ToolbarButton, { icon: format.icon, title: format.title, onClick: () => {
|
|
83
|
+
props.onChange(wp.richText.toggleFormat(props.value, {
|
|
84
|
+
type: format.id,
|
|
85
|
+
}));
|
|
86
|
+
}, isActive: props.isActive }) }));
|
|
87
|
+
};
|
|
88
|
+
wp.richText.registerFormatType(format.id, {
|
|
89
|
+
name: format.id,
|
|
90
|
+
title: format.title,
|
|
91
|
+
tagName: format.tagName ?? "span",
|
|
92
|
+
className: format.className,
|
|
93
|
+
interactive: false,
|
|
94
|
+
edit: EditComponent,
|
|
95
|
+
// @ts-ignore
|
|
96
|
+
disabledByDefault: format.disabledByDefault,
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
48
102
|
listenForHandleResize();
|
|
49
103
|
// Remove unwanted formatting options
|
|
50
104
|
// https://developer.wordpress.org/block-editor/how-to-guides/format-api/
|
|
@@ -52,7 +106,11 @@ export function installEDGutenbergHooks() {
|
|
|
52
106
|
wp.richText.unregisterFormatType("core/language");
|
|
53
107
|
wp.richText.unregisterFormatType("core/keyboard");
|
|
54
108
|
wp.richText.unregisterFormatType("core/text-color");
|
|
55
|
-
whenEditorIsReady().then(() =>
|
|
109
|
+
whenEditorIsReady().then(() => {
|
|
110
|
+
watchEditorTemplate();
|
|
111
|
+
});
|
|
112
|
+
// Recalculate registered blocks when rootBlocks change
|
|
113
|
+
rootBlocks.listen();
|
|
56
114
|
wp.hooks.addFilter("blocks.registerBlockType", "ed", (item, name) => {
|
|
57
115
|
// Hook into ACF blocks, customising the edit mode.
|
|
58
116
|
if (name.startsWith("acf/")) {
|
|
@@ -63,25 +121,41 @@ export function installEDGutenbergHooks() {
|
|
|
63
121
|
};
|
|
64
122
|
// Add an 'inline' object attribute, which will hold all inline contents
|
|
65
123
|
item.attributes.inline = { type: "object" };
|
|
124
|
+
item.attributes.values = { type: "object" };
|
|
66
125
|
item.attributes.isFromTemplate = { type: "boolean" };
|
|
126
|
+
item.supports.mode = false;
|
|
67
127
|
item.supports.customClassName = false;
|
|
128
|
+
// item.transforms = {
|
|
129
|
+
// to: [
|
|
130
|
+
// {
|
|
131
|
+
// type: "block",
|
|
132
|
+
// blocks: ["core/paragraph"],
|
|
133
|
+
// transform: (attributes: any) => {
|
|
134
|
+
// return wp.blocks.createBlock("core/paragraph", { content: JSON.stringify(attributes) })
|
|
135
|
+
// },
|
|
136
|
+
// },
|
|
137
|
+
// ],
|
|
138
|
+
// }
|
|
68
139
|
item.edit = function (props) {
|
|
69
140
|
const self = this;
|
|
70
141
|
useEffect(() => {
|
|
71
142
|
;
|
|
72
143
|
wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
73
144
|
}, []);
|
|
74
|
-
const children = wp.data.useSelect((select) => {
|
|
75
|
-
const { getBlock, getBlockOrder } = select("core/block-editor");
|
|
145
|
+
const { children, index } = wp.data.useSelect((select) => {
|
|
146
|
+
const { getBlock, getBlockOrder, getBlockIndex } = select("core/block-editor");
|
|
76
147
|
const innerBlockIDs = getBlockOrder(props.clientId);
|
|
77
148
|
const children = innerBlockIDs.map((id) => {
|
|
78
149
|
return getBlock(id);
|
|
79
150
|
});
|
|
80
|
-
return
|
|
151
|
+
return {
|
|
152
|
+
children,
|
|
153
|
+
index: getBlockIndex(props.clientId),
|
|
154
|
+
};
|
|
81
155
|
}, []);
|
|
82
|
-
return (_jsx(BlockContext.Provider, { value: { name, props }, children: _jsx(InlineEditingContextProvider, { values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], index: -1, onChange: (attrs) => {
|
|
156
|
+
return (_jsx(BlockContext.Provider, { value: { name, props }, children: _jsx(InlineEditingContextProvider, { values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], index: index ?? -1, onChange: (attrs) => {
|
|
83
157
|
props.setAttributes({ ...props.attributes, inline: attrs });
|
|
84
|
-
}, insertBlocksAfter: props.insertBlocksAfter, children: edit.call(self, props) }) }));
|
|
158
|
+
}, insertBlocksAfter: props.insertBlocksAfter, children: _jsx(EditorHighlights, { enabled: true, clientId: props.clientId, children: edit.call(self, props) }) }) }));
|
|
85
159
|
};
|
|
86
160
|
}
|
|
87
161
|
// Find PHP-defined 'tags' for core blocks.
|
|
@@ -99,15 +173,30 @@ export function installEDGutenbergHooks() {
|
|
|
99
173
|
item.tags = [];
|
|
100
174
|
}
|
|
101
175
|
blocksByTag.add(item.name, item.tags);
|
|
176
|
+
const isRootBlock = rootBlocks.isRootBlock(name, item.tags);
|
|
102
177
|
return {
|
|
103
178
|
...item,
|
|
104
179
|
get parent() {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
180
|
+
if (name === "core/block")
|
|
181
|
+
return undefined;
|
|
182
|
+
return blocksByTag.expand([...(item.parent ?? []), ...(isRootBlock ? ["core/post-content"] : [])]);
|
|
183
|
+
},
|
|
184
|
+
get transforms() {
|
|
185
|
+
const result = {
|
|
186
|
+
from: item.transforms?.from ?? [],
|
|
187
|
+
to: item.transforms?.to ?? [],
|
|
188
|
+
ungroup: item.transforms?.ungroup,
|
|
189
|
+
};
|
|
190
|
+
const meta = blockMetaDescriptors.get(resolveAcfBlockName(name));
|
|
191
|
+
if (meta?.transforms) {
|
|
192
|
+
result.from = [...(result.from ?? []), ...(meta.transforms.from ?? [])];
|
|
193
|
+
result.to = [...(result.to ?? []), ...(meta.transforms.to ?? [])];
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
109
196
|
},
|
|
110
197
|
get ancestor() {
|
|
198
|
+
if (name === "core/block")
|
|
199
|
+
return undefined;
|
|
111
200
|
return item.ancestor ? blocksByTag.expand(item.ancestor) : undefined;
|
|
112
201
|
},
|
|
113
202
|
get allowedBlocks() {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { hash } from "object-code";
|
|
2
|
+
import { subscribe, snapshot } from "valtio";
|
|
3
|
+
import { editorConfigStore } from "./editor-config";
|
|
4
|
+
import { blocksByTag } from "./blocks-by-tag";
|
|
5
|
+
let constraint = ["root"];
|
|
6
|
+
let rootBlockList = new Set(["root"]);
|
|
7
|
+
export const rootBlocks = {
|
|
8
|
+
listen() {
|
|
9
|
+
let key = hash(rootBlocks);
|
|
10
|
+
subscribe(editorConfigStore, () => {
|
|
11
|
+
constraint = snapshot(editorConfigStore.currentBlocksConfig).rootBlocks ?? ["root"];
|
|
12
|
+
let newKey = hash(constraint);
|
|
13
|
+
if (key === newKey)
|
|
14
|
+
return;
|
|
15
|
+
// The root blocks config have changed, so we need to recalculate the registered blocks
|
|
16
|
+
key = newKey;
|
|
17
|
+
rootBlocks.update();
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
update() {
|
|
21
|
+
rootBlockList = new Set(blocksByTag.expand(constraint));
|
|
22
|
+
wp.data.dispatch("core/blocks").reapplyBlockTypeFilters();
|
|
23
|
+
},
|
|
24
|
+
getRootBlocks() {
|
|
25
|
+
return rootBlockList;
|
|
26
|
+
},
|
|
27
|
+
isRootBlock(blockName, tags) {
|
|
28
|
+
return rootBlockList.has(blockName) || (tags && tags.some((tag) => rootBlockList.has(tag)));
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./editor/controls";
|
|
6
|
-
export * from "./editor/
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing";
|
|
1
|
+
export * from "./block-utils.js";
|
|
2
|
+
export * from "./ContentBlocks.js";
|
|
3
|
+
export * from "./defineBlock.js";
|
|
4
|
+
export * from "./EditableText.js";
|
|
5
|
+
export * from "./editor/controls.js";
|
|
6
|
+
export * from "./editor/create-block.js";
|
|
7
|
+
export { defineEditorConfig } from "./editor/editor-config.js";
|
|
8
|
+
export * from "./editor/usePostEditor.js";
|
|
9
|
+
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing.js";
|
|
10
|
+
export * from "./InnerBlocks.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export * from "./
|
|
2
|
-
export * from "./
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./editor/controls";
|
|
6
|
-
export * from "./editor/
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing";
|
|
1
|
+
export * from "./block-utils.js";
|
|
2
|
+
export * from "./ContentBlocks.js";
|
|
3
|
+
export * from "./defineBlock.js";
|
|
4
|
+
export * from "./EditableText.js";
|
|
5
|
+
export * from "./editor/controls.js";
|
|
6
|
+
export * from "./editor/create-block.js";
|
|
7
|
+
export { defineEditorConfig } from "./editor/editor-config.js";
|
|
8
|
+
export * from "./editor/usePostEditor.js";
|
|
9
|
+
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing.js";
|
|
10
|
+
export * from "./InnerBlocks.js";
|
|
@@ -1,7 +1,15 @@
|
|
|
1
|
-
import { ContentBlock } from "./ContentBlocks";
|
|
1
|
+
import { ContentBlock } from "./ContentBlocks.js";
|
|
2
2
|
import { PropsWithChildren } from "react";
|
|
3
3
|
type Attributes = Record<string, any>;
|
|
4
4
|
export type InlineValueStore<T> = [value: T, setValue: (value: T) => void];
|
|
5
|
+
export type BlockInstance = {
|
|
6
|
+
attributes: any;
|
|
7
|
+
clientId: string;
|
|
8
|
+
innerBlocks: BlockInstance[];
|
|
9
|
+
isValid: boolean;
|
|
10
|
+
name: string;
|
|
11
|
+
originalContent?: string | undefined;
|
|
12
|
+
};
|
|
5
13
|
type InlineEditingContext = {
|
|
6
14
|
values: Attributes;
|
|
7
15
|
innerBlocks: ContentBlock[];
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
import { usePostEditor } from "./editor/usePostEditor";
|
|
4
|
-
import { useRoute } from "../routing";
|
|
5
|
-
import { addBlockMetadata } from "./block-utils";
|
|
2
|
+
import { createContext, useContext, useMemo } from "react";
|
|
3
|
+
import { usePostEditor } from "./editor/usePostEditor.js";
|
|
4
|
+
import { useRoute } from "../routing/index.js";
|
|
5
|
+
import { addBlockMetadata } from "./block-utils.js";
|
|
6
6
|
const InlineEditingContext = createContext(undefined);
|
|
7
7
|
export function InlineEditingContextProvider(props) {
|
|
8
8
|
const parentContext = useContext(InlineEditingContext);
|
|
9
|
-
|
|
9
|
+
useMemo(() => {
|
|
10
|
+
addBlockMetadata(props.innerBlocks ?? []);
|
|
11
|
+
}, [props.innerBlocks]);
|
|
10
12
|
return (_jsx(InlineEditingContext.Provider, { value: {
|
|
11
13
|
values: props.values,
|
|
12
14
|
innerBlocks: props.innerBlocks,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
-
import { useTailwindConfig } from "../hooks/useTailwind.js";
|
|
4
3
|
import { usePersistState } from "../hooks/usePersistState.js";
|
|
4
|
+
import { useTailwindConfig } from "../hooks/useTailwind.js";
|
|
5
5
|
function parseBreakpointMin(breakpoint) {
|
|
6
6
|
return parseInt(breakpoint);
|
|
7
7
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "../../../../../css/devtools.css";
|
|
3
|
-
import { BreakpointIndicator } from "./BreakpointIndicator";
|
|
3
|
+
import { BreakpointIndicator } from "./BreakpointIndicator.js";
|
|
4
|
+
import { GridIndicator } from "./GridIndicator";
|
|
4
5
|
export default function DevUI() {
|
|
5
|
-
return (
|
|
6
|
+
return (_jsxs("div", { className: "eddev-ui", children: [_jsx(BreakpointIndicator, {}), _jsx(GridIndicator, {})] }));
|
|
6
7
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GridIndicator(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
3
|
+
import { usePersistState } from "../hooks/usePersistState.js";
|
|
4
|
+
export function GridIndicator() {
|
|
5
|
+
const [enabled, setEnabled] = usePersistState("gridOverlayEnabled", false);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handleKeyDown = (e) => {
|
|
8
|
+
if (e.key === "g" && e.ctrlKey) {
|
|
9
|
+
setEnabled((e) => !e);
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener("keydown", handleKeyDown);
|
|
15
|
+
};
|
|
16
|
+
}, []);
|
|
17
|
+
const cols = [];
|
|
18
|
+
for (let i = 0; i < 12; i++) {
|
|
19
|
+
cols.push(_jsx("div", { style: { height: "100%", backgroundColor: "rgba(255,0,0,0.1)" } }));
|
|
20
|
+
}
|
|
21
|
+
if (env.client) {
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
document.documentElement.classList.toggle("debug-grid", enabled);
|
|
24
|
+
}, [enabled]);
|
|
25
|
+
}
|
|
26
|
+
if (!enabled)
|
|
27
|
+
return null;
|
|
28
|
+
return (_jsx("div", { style: { position: "fixed", inset: 0, zIndex: 999999999, pointerEvents: "none" }, children: _jsx("div", { className: "grid-auto debug-display", style: { height: "100%" }, children: cols }) }));
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function usePersistState<T>(id: string, initial: T): [T, (value: T) => void];
|
|
1
|
+
export declare function usePersistState<T>(id: string, initial: T): [T, (value: T | ((current: T) => T)) => void];
|
|
@@ -24,8 +24,17 @@ export function usePersistState(id, initial) {
|
|
|
24
24
|
return [
|
|
25
25
|
value,
|
|
26
26
|
(value) => {
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
if (typeof value === "function") {
|
|
28
|
+
return setValue((cur) => {
|
|
29
|
+
const next = value(cur);
|
|
30
|
+
set(id, next);
|
|
31
|
+
return next;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
set(id, value);
|
|
36
|
+
setValue(value);
|
|
37
|
+
}
|
|
29
38
|
},
|
|
30
39
|
];
|
|
31
40
|
}
|