eddev 2.0.0-beta.9 → 2.0.0-beta.91
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/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 +11 -6
- 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 +4 -5
- package/dist/app/entry/ssr-root-client.d.ts +3 -1
- package/dist/app/entry/ssr-root-client.js +24 -8
- package/dist/app/entry/ssr-root.d.ts +5 -4
- package/dist/app/entry/ssr-root.js +21 -20
- 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 +1 -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 +1 -1
- package/dist/app/lib/blocks/EditableText.js +3 -3
- package/dist/app/lib/blocks/InnerBlocks.d.ts +13 -3
- package/dist/app/lib/blocks/InnerBlocks.js +13 -5
- 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/editor/EditorHighlights.d.ts +7 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.js +130 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +4 -5
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -1
- package/dist/app/lib/blocks/editor/editor-config.d.ts +17 -4
- package/dist/app/lib/blocks/editor/editor-config.js +21 -9
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +20 -14
- 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 +9 -9
- package/dist/app/lib/blocks/index.js +9 -9
- package/dist/app/lib/blocks/inline-editing.d.ts +1 -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 +1014 -1014
- 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 +1 -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 +4 -1
- package/dist/app/lib/routing/components/BrowserRouter.js +95 -19
- package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -1
- package/dist/app/lib/routing/components/ClientOnly.js +1 -1
- 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 +36 -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 +32 -14
- package/dist/app/server/render-ssr-page.d.ts +21 -2
- package/dist/app/server/render-ssr-page.js +143 -11
- 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 +42 -4
- package/dist/app/server/server-context.js +196 -30
- 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/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 +79 -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 +3 -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 +1 -0
- package/dist/node/compiler/get-vite-config.js +34 -11
- 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 +321 -108
- 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 +1 -0
- 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 +9 -1
- package/dist/node/project/project.js +37 -6
- package/dist/node/project/wp-info.d.ts +1 -0
- package/dist/node/project/wp-info.js +13 -1
- 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/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 +17 -13
- package/types.app.d.ts +4 -2
- package/types.app.internal.d.ts +2 -2
- 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
- package/dist/app/server/utils/index.html.d.ts +0 -2
- package/dist/app/server/utils/index.html.js +0 -14
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { proxy } from "valtio";
|
|
2
|
-
import { resolveAcfBlockName, transformBlockTemplate } from "./block-templates";
|
|
2
|
+
import { resolveAcfBlockName, transformBlockTemplate } from "./block-templates.js";
|
|
3
3
|
export const editorConfigStore = proxy({
|
|
4
4
|
config: null,
|
|
5
|
-
currentBlocksConfig:
|
|
5
|
+
currentBlocksConfig: {},
|
|
6
6
|
});
|
|
7
7
|
export function configureEditorBlocks(config) {
|
|
8
8
|
const wp = window.wp;
|
|
@@ -27,14 +27,27 @@ export function configureEditorBlocks(config) {
|
|
|
27
27
|
}
|
|
28
28
|
const currentBlocks = wp.data.select("core/block-editor").getBlocks();
|
|
29
29
|
const templateBlocks = currentBlocks.filter((block) => block.attributes.isFromTemplate);
|
|
30
|
-
let blocks = currentBlocks.filter((block) => !block.attributes.isFromTemplate);
|
|
31
30
|
let header = config.headerTemplate ? syncBlocks(transformTemplateToBlocks(config.headerTemplate)) : [];
|
|
32
31
|
let footer = config.footerTemplate ? syncBlocks(transformTemplateToBlocks(config.footerTemplate)) : [];
|
|
32
|
+
let blocks = currentBlocks.filter((block) => !header.includes(block) && !footer.includes(block));
|
|
33
|
+
blocks.forEach((block) => {
|
|
34
|
+
delete block.attributes.lock;
|
|
35
|
+
delete block.isFromTemplate;
|
|
36
|
+
});
|
|
37
|
+
// const blocksToDelete = currentBlocks.filter((block: any) => {
|
|
38
|
+
// return !header.includes(block) && !footer.includes(block) && !blocks.includes(block)
|
|
39
|
+
// })
|
|
40
|
+
// blocksToDelete.forEach((block: any) => {
|
|
41
|
+
// delete block.attributes.lock
|
|
42
|
+
// delete block.isFromTemplate
|
|
43
|
+
// })
|
|
44
|
+
// blocks = [...blocks, ...blocksToDelete]
|
|
45
|
+
// console.log("blocks", blocks)
|
|
46
|
+
// console.log("blocksToDelete", blocksToDelete)
|
|
33
47
|
if (!blocks.length && config.defaultBlocks) {
|
|
34
|
-
blocks = transformTemplateToBlocks(config.defaultBlocks, false);
|
|
48
|
+
blocks = transformTemplateToBlocks(config.defaultBlocks, false, false);
|
|
35
49
|
}
|
|
36
50
|
let newBlocks = [...header, ...blocks, ...footer];
|
|
37
|
-
// console.log("Configuring", newBlocks)
|
|
38
51
|
wp.data.dispatch("core/block-editor").resetBlocks(newBlocks);
|
|
39
52
|
function syncBlocks(blocks) {
|
|
40
53
|
return blocks.map((block) => {
|
|
@@ -48,12 +61,12 @@ export function configureEditorBlocks(config) {
|
|
|
48
61
|
});
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
|
-
export function transformTemplateToBlocks(template, locked = true) {
|
|
64
|
+
export function transformTemplateToBlocks(template, locked = true, isFromTemplate = true) {
|
|
52
65
|
return template.map(([name, props, children]) => {
|
|
53
66
|
const attributes = {
|
|
54
67
|
data: {},
|
|
55
68
|
inline: {},
|
|
56
|
-
isFromTemplate:
|
|
69
|
+
isFromTemplate: isFromTemplate,
|
|
57
70
|
lock: undefined,
|
|
58
71
|
};
|
|
59
72
|
if (props.locked === false) {
|
|
@@ -70,7 +83,7 @@ export function transformTemplateToBlocks(template, locked = true) {
|
|
|
70
83
|
clientId: "block-" + Math.random().toString(36),
|
|
71
84
|
name: resolveAcfBlockName(name),
|
|
72
85
|
attributes: attributes,
|
|
73
|
-
innerBlocks: children ? transformTemplateToBlocks(children, false) : [],
|
|
86
|
+
innerBlocks: children ? transformTemplateToBlocks(children, false, isFromTemplate) : [],
|
|
74
87
|
isValid: true,
|
|
75
88
|
validationIssues: [],
|
|
76
89
|
};
|
|
@@ -174,7 +187,6 @@ function setWrapperBlock(blockName, blocks) {
|
|
|
174
187
|
}
|
|
175
188
|
function setTemplate(template) {
|
|
176
189
|
const wp = window.wp;
|
|
177
|
-
// console.log("Setting template", template)
|
|
178
190
|
let currentBlocks = wp.data.select("core/block-editor").getBlocks();
|
|
179
191
|
wp.data.dispatch("core/block-editor").updateSettings({
|
|
180
192
|
templateLock: "all",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { InlineEditingContextProvider } from "../inline-editing";
|
|
4
|
-
import { BlockContext, EditableBlock } from "./EditorSupport";
|
|
5
|
-
import { blocksByTag } from "./blocks-by-tag";
|
|
6
|
-
import { editorConfigStore, getEditingPostInfo, watchEditorTemplate } from "./editor-config";
|
|
7
3
|
import { useSnapshot } from "valtio";
|
|
8
|
-
import { getBlockMetadata } from "../block-utils";
|
|
4
|
+
import { getBlockMetadata } from "../block-utils.js";
|
|
5
|
+
import { InlineEditingContextProvider } from "../inline-editing.js";
|
|
6
|
+
import { BlockContext, EditableBlock } from "./EditorSupport.js";
|
|
7
|
+
import { blocksByTag } from "./blocks-by-tag.js";
|
|
8
|
+
import { editorConfigStore, getEditingPostInfo, watchEditorTemplate } from "./editor-config.js";
|
|
9
|
+
import { rootBlocks } from "./root-blocks.js";
|
|
10
|
+
import { EditorHighlights } from "./EditorHighlights.js";
|
|
9
11
|
function listenForHandleResize() {
|
|
10
12
|
let interval = setInterval(() => {
|
|
11
13
|
let viewportTarget = document.querySelector(".interface-interface-skeleton__content");
|
|
@@ -53,6 +55,8 @@ export function installEDGutenbergHooks() {
|
|
|
53
55
|
wp.richText.unregisterFormatType("core/keyboard");
|
|
54
56
|
wp.richText.unregisterFormatType("core/text-color");
|
|
55
57
|
whenEditorIsReady().then(() => watchEditorTemplate());
|
|
58
|
+
// Recalculate registered blocks when rootBlocks change
|
|
59
|
+
rootBlocks.listen();
|
|
56
60
|
wp.hooks.addFilter("blocks.registerBlockType", "ed", (item, name) => {
|
|
57
61
|
// Hook into ACF blocks, customising the edit mode.
|
|
58
62
|
if (name.startsWith("acf/")) {
|
|
@@ -63,6 +67,7 @@ export function installEDGutenbergHooks() {
|
|
|
63
67
|
};
|
|
64
68
|
// Add an 'inline' object attribute, which will hold all inline contents
|
|
65
69
|
item.attributes.inline = { type: "object" };
|
|
70
|
+
item.attributes.values = { type: "object" };
|
|
66
71
|
item.attributes.isFromTemplate = { type: "boolean" };
|
|
67
72
|
item.supports.customClassName = false;
|
|
68
73
|
item.edit = function (props) {
|
|
@@ -71,17 +76,20 @@ export function installEDGutenbergHooks() {
|
|
|
71
76
|
;
|
|
72
77
|
wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
73
78
|
}, []);
|
|
74
|
-
const children = wp.data.useSelect((select) => {
|
|
75
|
-
const { getBlock, getBlockOrder } = select("core/block-editor");
|
|
79
|
+
const { children, index } = wp.data.useSelect((select) => {
|
|
80
|
+
const { getBlock, getBlockOrder, getBlockIndex } = select("core/block-editor");
|
|
76
81
|
const innerBlockIDs = getBlockOrder(props.clientId);
|
|
77
82
|
const children = innerBlockIDs.map((id) => {
|
|
78
83
|
return getBlock(id);
|
|
79
84
|
});
|
|
80
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
children,
|
|
87
|
+
index: getBlockIndex(props.clientId),
|
|
88
|
+
};
|
|
81
89
|
}, []);
|
|
82
|
-
return (_jsx(BlockContext.Provider, { value: { name, props }, children: _jsx(InlineEditingContextProvider, { values: props.attributes.inline || {}, innerBlocks: children, block: [name, props], index: -1, onChange: (attrs) => {
|
|
90
|
+
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
91
|
props.setAttributes({ ...props.attributes, inline: attrs });
|
|
84
|
-
}, insertBlocksAfter: props.insertBlocksAfter, children: edit.call(self, props) }) }));
|
|
92
|
+
}, insertBlocksAfter: props.insertBlocksAfter, children: _jsx(EditorHighlights, { enabled: true, clientId: props.clientId, children: edit.call(self, props) }) }) }));
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
95
|
// Find PHP-defined 'tags' for core blocks.
|
|
@@ -99,13 +107,11 @@ export function installEDGutenbergHooks() {
|
|
|
99
107
|
item.tags = [];
|
|
100
108
|
}
|
|
101
109
|
blocksByTag.add(item.name, item.tags);
|
|
110
|
+
const isRootBlock = rootBlocks.isRootBlock(name, item.tags);
|
|
102
111
|
return {
|
|
103
112
|
...item,
|
|
104
113
|
get parent() {
|
|
105
|
-
return blocksByTag.expand([
|
|
106
|
-
...(item.parent ?? []),
|
|
107
|
-
...(item.tags.includes("root") ? ["core/post-content"] : []),
|
|
108
|
-
]);
|
|
114
|
+
return blocksByTag.expand([...(item.parent ?? []), ...(isRootBlock ? ["core/post-content"] : [])]);
|
|
109
115
|
},
|
|
110
116
|
get ancestor() {
|
|
111
117
|
return item.ancestor ? blocksByTag.expand(item.ancestor) : undefined;
|
|
@@ -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,9 @@
|
|
|
1
|
-
export * from "./ContentBlocks";
|
|
2
|
-
export * from "./EditableText";
|
|
3
|
-
export * from "./InnerBlocks";
|
|
4
|
-
export * from "./defineBlock";
|
|
5
|
-
export * from "./editor/controls";
|
|
6
|
-
export * from "./editor/usePostEditor";
|
|
7
|
-
export * from "./block-utils";
|
|
8
|
-
export { defineEditorConfig } from "./editor/editor-config";
|
|
9
|
-
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing";
|
|
1
|
+
export * from "./ContentBlocks.js";
|
|
2
|
+
export * from "./EditableText.js";
|
|
3
|
+
export * from "./InnerBlocks.js";
|
|
4
|
+
export * from "./defineBlock.js";
|
|
5
|
+
export * from "./editor/controls.js";
|
|
6
|
+
export * from "./editor/usePostEditor.js";
|
|
7
|
+
export * from "./block-utils.js";
|
|
8
|
+
export { defineEditorConfig } from "./editor/editor-config.js";
|
|
9
|
+
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing.js";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from "./ContentBlocks";
|
|
2
|
-
export * from "./EditableText";
|
|
3
|
-
export * from "./InnerBlocks";
|
|
4
|
-
export * from "./defineBlock";
|
|
5
|
-
export * from "./editor/controls";
|
|
6
|
-
export * from "./editor/usePostEditor";
|
|
7
|
-
export * from "./block-utils";
|
|
8
|
-
export { defineEditorConfig } from "./editor/editor-config";
|
|
9
|
-
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing";
|
|
1
|
+
export * from "./ContentBlocks.js";
|
|
2
|
+
export * from "./EditableText.js";
|
|
3
|
+
export * from "./InnerBlocks.js";
|
|
4
|
+
export * from "./defineBlock.js";
|
|
5
|
+
export * from "./editor/controls.js";
|
|
6
|
+
export * from "./editor/usePostEditor.js";
|
|
7
|
+
export * from "./block-utils.js";
|
|
8
|
+
export { defineEditorConfig } from "./editor/editor-config.js";
|
|
9
|
+
export { useBlockContext, useInlineEditableValue, useInnerBlocks, useTemplate } from "./inline-editing.js";
|
|
@@ -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
|
}
|