eddev 2.0.0-beta.98 → 2.1.0
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.d.ts.map +1 -0
- package/dist/app/entry/MetaTags.d.ts +1 -0
- package/dist/app/entry/MetaTags.d.ts.map +1 -0
- package/dist/app/entry/MetaTags.js +18 -3
- package/dist/app/entry/boot-admin.d.ts +1 -0
- package/dist/app/entry/boot-admin.d.ts.map +1 -0
- package/dist/app/entry/boot-admin.js +0 -1
- package/dist/app/entry/hydration-script.d.ts +1 -0
- package/dist/app/entry/hydration-script.d.ts.map +1 -0
- package/dist/app/entry/spa-root.d.ts +1 -0
- package/dist/app/entry/spa-root.d.ts.map +1 -0
- package/dist/app/entry/spa-root.js +1 -2
- package/dist/app/entry/ssr-root-client.d.ts +1 -0
- package/dist/app/entry/ssr-root-client.d.ts.map +1 -0
- package/dist/app/entry/ssr-root-client.js +3 -2
- package/dist/app/entry/ssr-root.d.ts +3 -0
- package/dist/app/entry/ssr-root.d.ts.map +1 -0
- package/dist/app/entry/ssr-root.js +3 -3
- package/dist/app/lib/admin/defineField.d.ts +1 -0
- package/dist/app/lib/admin/defineField.d.ts.map +1 -0
- package/dist/app/lib/admin/defineWidget.d.ts +1 -0
- package/dist/app/lib/admin/defineWidget.d.ts.map +1 -0
- package/dist/app/lib/admin/index.d.ts +1 -0
- package/dist/app/lib/admin/index.d.ts.map +1 -0
- package/dist/app/lib/admin/installFieldTypes.d.ts +1 -0
- package/dist/app/lib/admin/installFieldTypes.d.ts.map +1 -0
- package/dist/app/lib/admin/installFieldTypes.js +2 -0
- package/dist/app/lib/admin/runWidgets.d.ts +1 -0
- package/dist/app/lib/admin/runWidgets.d.ts.map +1 -0
- package/dist/app/lib/admin/runWidgets.js +7 -2
- package/dist/app/lib/blocks/BlockPropMutator.d.ts +33 -0
- package/dist/app/lib/blocks/BlockPropMutator.d.ts.map +1 -0
- package/dist/app/lib/blocks/BlockPropMutator.js +20 -0
- package/dist/app/lib/blocks/ContentBlocks.d.ts +7 -4
- package/dist/app/lib/blocks/ContentBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/ContentBlocks.js +14 -1
- package/dist/app/lib/blocks/EditableText.d.ts +30 -5
- package/dist/app/lib/blocks/EditableText.d.ts.map +1 -0
- package/dist/app/lib/blocks/EditableText.js +34 -5
- package/dist/app/lib/blocks/InnerBlocks.d.ts +11 -6
- package/dist/app/lib/blocks/InnerBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/InnerBlocks.js +67 -27
- package/dist/app/lib/blocks/SlotBlocks.d.ts +8 -0
- package/dist/app/lib/blocks/SlotBlocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/SlotBlocks.js +45 -0
- package/dist/app/lib/blocks/block-utils.d.ts +1 -0
- package/dist/app/lib/blocks/block-utils.d.ts.map +1 -0
- package/dist/app/lib/blocks/block-utils.js +18 -1
- package/dist/app/lib/blocks/builtin-blocks.d.ts +2 -0
- package/dist/app/lib/blocks/builtin-blocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/builtin-blocks.js +55 -0
- package/dist/app/lib/blocks/defineBlock.d.ts +4 -0
- package/dist/app/lib/blocks/defineBlock.d.ts.map +1 -0
- package/dist/app/lib/blocks/defineBlock.js +9 -0
- package/dist/app/lib/blocks/editor/EditingContext.d.ts +2 -0
- package/dist/app/lib/blocks/editor/EditingContext.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/EditingContext.js +31 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts +1 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/EditorHighlights.js +43 -9
- package/dist/app/lib/blocks/editor/EditorSupport.d.ts +1 -4
- package/dist/app/lib/blocks/editor/EditorSupport.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/EditorSupport.js +23 -9
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts +1 -0
- package/dist/app/lib/blocks/editor/ErrorBoundaryEditor.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/block-templates.d.ts +8 -1
- package/dist/app/lib/blocks/editor/block-templates.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/block-templates.js +71 -2
- package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts +1 -0
- package/dist/app/lib/blocks/editor/blocks-by-tag.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/controls.d.ts +1 -0
- package/dist/app/lib/blocks/editor/controls.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/create-block.d.ts +10 -0
- package/dist/app/lib/blocks/editor/create-block.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/create-block.js +13 -0
- package/dist/app/lib/blocks/editor/editor-config.d.ts +64 -7
- package/dist/app/lib/blocks/editor/editor-config.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/editor-config.js +28 -73
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts +4 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/installGutenbergHooks.js +152 -27
- package/dist/app/lib/blocks/editor/root-blocks.d.ts +1 -0
- package/dist/app/lib/blocks/editor/root-blocks.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts +12 -1
- package/dist/app/lib/blocks/editor/usePostEditor.d.ts.map +1 -0
- package/dist/app/lib/blocks/editor/usePostEditor.js +38 -13
- package/dist/app/lib/blocks/index.d.ts +8 -5
- package/dist/app/lib/blocks/index.d.ts.map +1 -0
- package/dist/app/lib/blocks/index.js +8 -5
- package/dist/app/lib/blocks/inline-editing.d.ts +16 -1
- package/dist/app/lib/blocks/inline-editing.d.ts.map +1 -0
- package/dist/app/lib/blocks/inline-editing.js +14 -1
- package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/BreakpointIndicator.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/BreakpointIndicator.js +1 -1
- package/dist/app/lib/devtools/components/DevUI.d.ts +1 -0
- package/dist/app/lib/devtools/components/DevUI.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/DevUI.js +1 -1
- package/dist/app/lib/devtools/components/GridIndicator.d.ts +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.d.ts.map +1 -0
- package/dist/app/lib/devtools/components/GridIndicator.js +1 -1
- package/dist/app/lib/devtools/dev-tools-store.d.ts +1 -0
- package/dist/app/lib/devtools/dev-tools-store.d.ts.map +1 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts +1 -0
- package/dist/app/lib/devtools/hooks/usePersistState.d.ts.map +1 -0
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts +1358 -313
- package/dist/app/lib/devtools/hooks/useTailwind.d.ts.map +1 -0
- package/dist/app/lib/devtools/index.d.ts +1 -0
- package/dist/app/lib/devtools/index.d.ts.map +1 -0
- package/dist/app/lib/devtools/loader.d.ts +2 -1
- package/dist/app/lib/devtools/loader.d.ts.map +1 -0
- package/dist/app/lib/devtools/loader.js +4 -3
- package/dist/app/lib/devtools/tailwind.config.d.ts +1 -0
- package/dist/app/lib/devtools/tailwind.config.d.ts.map +1 -0
- package/dist/app/lib/devtools/useQueryDebug.d.ts +2 -1
- package/dist/app/lib/devtools/useQueryDebug.d.ts.map +1 -0
- package/dist/app/lib/dynamic/dynamic.d.ts +1 -0
- package/dist/app/lib/dynamic/dynamic.d.ts.map +1 -0
- package/dist/app/lib/dynamic/index.d.ts +1 -0
- package/dist/app/lib/dynamic/index.d.ts.map +1 -0
- package/dist/app/lib/hooks/index.d.ts +2 -1
- package/dist/app/lib/hooks/index.d.ts.map +1 -0
- package/dist/app/lib/hooks/index.js +1 -1
- package/dist/app/lib/hooks/{queryUtils.d.ts → query-hooks.d.ts} +8 -2
- package/dist/app/lib/hooks/query-hooks.d.ts.map +1 -0
- package/dist/app/lib/hooks/{queryUtils.js → query-hooks.js} +43 -11
- package/dist/app/lib/hooks/useAppData.d.ts +1 -0
- package/dist/app/lib/hooks/useAppData.d.ts.map +1 -0
- package/dist/app/lib/hooks/useAppData.js +11 -0
- package/dist/app/lib/hooks/useRPC.d.ts +1 -0
- package/dist/app/lib/hooks/useRPC.d.ts.map +1 -0
- package/dist/app/lib/hooks/useRPC.js +0 -1
- package/dist/app/lib/integrations/gravityforms/index.d.ts +3 -0
- package/dist/app/lib/integrations/gravityforms/index.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/index.js +2 -0
- package/dist/app/lib/integrations/gravityforms/types.d.ts +145 -0
- package/dist/app/lib/integrations/gravityforms/types.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/types.js +1 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts +31 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.d.ts.map +1 -0
- package/dist/app/lib/integrations/gravityforms/useGravityForm.js +298 -0
- package/dist/app/lib/internal/finalize-rpc.d.ts +1 -0
- package/dist/app/lib/internal/finalize-rpc.d.ts.map +1 -0
- package/dist/app/lib/internal/index.d.ts +1 -0
- package/dist/app/lib/internal/index.d.ts.map +1 -0
- package/dist/app/lib/internal/internal-store.d.ts +1 -0
- package/dist/app/lib/internal/internal-store.d.ts.map +1 -0
- package/dist/app/lib/internal/read-admin-manifest.d.ts +1 -0
- package/dist/app/lib/internal/read-admin-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-block-manifest.d.ts +2 -0
- package/dist/app/lib/internal/read-block-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-block-manifest.js +7 -0
- package/dist/app/lib/internal/read-view-manifest.d.ts +7 -4
- package/dist/app/lib/internal/read-view-manifest.d.ts.map +1 -0
- package/dist/app/lib/internal/read-view-manifest.js +18 -0
- package/dist/app/lib/legacy-stitches/createStitches.d.ts +8 -7
- package/dist/app/lib/legacy-stitches/createStitches.d.ts.map +1 -0
- package/dist/app/lib/legacy-stitches/index.d.ts +1 -0
- package/dist/app/lib/legacy-stitches/index.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BackButton.d.ts +1 -0
- package/dist/app/lib/routing/components/BackButton.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BrowserRouter.d.ts +7 -1
- package/dist/app/lib/routing/components/BrowserRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/components/BrowserRouter.js +85 -14
- package/dist/app/lib/routing/components/ClientOnly.d.ts +1 -0
- package/dist/app/lib/routing/components/ClientOnly.d.ts.map +1 -0
- package/dist/app/lib/routing/components/ClientOnly.js +3 -3
- package/dist/app/lib/routing/components/Link.d.ts +21 -2
- package/dist/app/lib/routing/components/Link.d.ts.map +1 -0
- package/dist/app/lib/routing/components/Link.js +52 -23
- package/dist/app/lib/routing/components/NativeLinkHandler.d.ts +10 -0
- package/dist/app/lib/routing/components/NativeLinkHandler.d.ts.map +1 -0
- package/dist/app/lib/routing/components/NativeLinkHandler.js +23 -0
- package/dist/app/lib/routing/components/RouteRenderer.d.ts +1 -0
- package/dist/app/lib/routing/components/RouteRenderer.d.ts.map +1 -0
- package/dist/app/lib/routing/components/RouteRenderer.js +14 -1
- package/dist/app/lib/routing/components/SSRRouter.d.ts +3 -0
- package/dist/app/lib/routing/components/SSRRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/components/SSRRouter.js +2 -0
- package/dist/app/lib/routing/components/ScrollRestoration.d.ts +1 -0
- package/dist/app/lib/routing/components/ScrollRestoration.d.ts.map +1 -0
- package/dist/app/lib/routing/context.d.ts +1 -0
- package/dist/app/lib/routing/context.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/{useIsSSR.d.ts → useHydrating.d.ts} +7 -0
- package/dist/app/lib/routing/hooks/useHydrating.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/{useIsSSR.js → useHydrating.js} +13 -3
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRestorableState.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRestorableState.js +7 -2
- package/dist/app/lib/routing/hooks/useRoute.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRoute.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouteMeta.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouteTransition.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouter.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouter.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouterEvents.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useRouterState.d.ts +1 -0
- package/dist/app/lib/routing/hooks/useRouterState.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useSearchParams.d.ts +78 -6
- package/dist/app/lib/routing/hooks/useSearchParams.d.ts.map +1 -0
- package/dist/app/lib/routing/hooks/useSearchParams.js +75 -15
- package/dist/app/lib/routing/index.d.ts +4 -1
- package/dist/app/lib/routing/index.d.ts.map +1 -0
- package/dist/app/lib/routing/index.js +3 -1
- package/dist/app/lib/routing/loader.d.ts +1 -0
- package/dist/app/lib/routing/loader.d.ts.map +1 -0
- package/dist/app/lib/routing/loader.js +1 -1
- package/dist/app/lib/routing/types.d.ts +40 -6
- package/dist/app/lib/routing/types.d.ts.map +1 -0
- package/dist/app/lib/routing/utils.d.ts +2 -0
- package/dist/app/lib/routing/utils.d.ts.map +1 -0
- package/dist/app/lib/routing/utils.js +5 -1
- package/dist/app/lib/runtime/apiConfig.d.ts +5 -0
- package/dist/app/lib/runtime/apiConfig.d.ts.map +1 -0
- package/dist/app/lib/runtime/errorHandling.d.ts +1 -0
- package/dist/app/lib/runtime/errorHandling.d.ts.map +1 -0
- package/dist/app/lib/runtime/index.d.ts +1 -0
- package/dist/app/lib/runtime/index.d.ts.map +1 -0
- package/dist/app/lib/views/defineView.d.ts +2 -1
- package/dist/app/lib/views/defineView.d.ts.map +1 -0
- package/dist/app/lib/views/index.d.ts +1 -0
- package/dist/app/lib/views/index.d.ts.map +1 -0
- package/dist/app/server/index.d.ts +4 -3
- package/dist/app/server/index.d.ts.map +1 -0
- package/dist/app/server/index.js +3 -3
- package/dist/app/server/proxy-wp-admin.d.ts +1 -0
- package/dist/app/server/proxy-wp-admin.d.ts.map +1 -0
- package/dist/app/server/proxy-wp-admin.js +23 -9
- package/dist/app/server/render-ai-page.d.ts +13 -0
- package/dist/app/server/render-ai-page.d.ts.map +1 -0
- package/dist/app/server/render-ai-page.js +102 -0
- package/dist/app/server/render-ssr-page.d.ts +17 -6
- package/dist/app/server/render-ssr-page.d.ts.map +1 -0
- package/dist/app/server/render-ssr-page.js +119 -36
- package/dist/app/server/rpc.d.ts +18 -41
- package/dist/app/server/rpc.d.ts.map +1 -0
- package/dist/app/server/server-context.d.ts +14 -3
- package/dist/app/server/server-context.d.ts.map +1 -0
- package/dist/app/server/server-context.js +204 -21
- package/dist/app/server/server-custom-config.d.ts +3 -0
- package/dist/app/server/server-custom-config.d.ts.map +1 -0
- package/dist/app/server/server-custom-config.js +1 -0
- package/dist/app/server/utils/content-security.d.ts +26 -0
- package/dist/app/server/utils/content-security.d.ts.map +1 -0
- package/dist/app/server/utils/content-security.js +124 -0
- package/dist/app/server/utils/headers.d.ts +1 -0
- package/dist/app/server/utils/headers.d.ts.map +1 -0
- package/dist/app/server/utils/replace-host.d.ts +1 -0
- package/dist/app/server/utils/replace-host.d.ts.map +1 -0
- package/dist/app/server/utils/swr-cache.d.ts +1 -0
- package/dist/app/server/utils/swr-cache.d.ts.map +1 -0
- package/dist/app/utils/APIProvider.d.ts +1 -0
- package/dist/app/utils/APIProvider.d.ts.map +1 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts +1 -0
- package/dist/app/utils/BlockErrorBoundary.d.ts.map +1 -0
- package/dist/app/utils/ErrorMessage.d.ts +1 -0
- package/dist/app/utils/ErrorMessage.d.ts.map +1 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts +2 -0
- package/dist/app/utils/RouteErrorBoundary.d.ts.map +1 -0
- package/dist/app/utils/RouteErrorBoundary.js +3 -0
- package/dist/app/utils/asset-capture.d.ts +1 -0
- package/dist/app/utils/asset-capture.d.ts.map +1 -0
- package/dist/app/utils/hydration-debugger.d.ts +1 -0
- package/dist/app/utils/hydration-debugger.d.ts.map +1 -0
- package/dist/app/utils/query-client.d.ts +1 -0
- package/dist/app/utils/query-client.d.ts.map +1 -0
- package/dist/app/utils/query-monitor.d.ts +27 -0
- package/dist/app/utils/query-monitor.d.ts.map +1 -0
- package/dist/app/utils/query-monitor.js +7 -0
- package/dist/app/utils/trpc-client.d.ts +1 -0
- package/dist/app/utils/trpc-client.d.ts.map +1 -0
- package/dist/app/utils/trpc-client.js +1 -1
- package/dist/app/utils/wp.d.ts +11 -10
- package/dist/app/utils/wp.d.ts.map +1 -0
- package/dist/node/cli/cli-mode.d.ts +1 -0
- package/dist/node/cli/cli-mode.d.ts.map +1 -0
- package/dist/node/cli/cli-worker.d.ts +1 -0
- package/dist/node/cli/cli-worker.d.ts.map +1 -0
- package/dist/node/cli/cli-worker.js +1 -0
- package/dist/node/cli/cli.d.ts +1 -0
- package/dist/node/cli/cli.d.ts.map +1 -0
- package/dist/node/cli/cli.js +100 -11
- package/dist/node/cli/display/CLIApp.d.ts +1 -0
- package/dist/node/cli/display/CLIApp.d.ts.map +1 -0
- package/dist/node/cli/display/boot-cli-app.d.ts +1 -0
- package/dist/node/cli/display/boot-cli-app.d.ts.map +1 -0
- package/dist/node/cli/display/components/Fullscreen.d.ts +1 -0
- package/dist/node/cli/display/components/Fullscreen.d.ts.map +1 -0
- package/dist/node/cli/display/components/LogEntries.d.ts +1 -0
- package/dist/node/cli/display/components/LogEntries.d.ts.map +1 -0
- package/dist/node/cli/display/components/MenuItem.d.ts +1 -0
- package/dist/node/cli/display/components/MenuItem.d.ts.map +1 -0
- package/dist/node/cli/display/components/TextInput.d.ts +1 -0
- package/dist/node/cli/display/components/TextInput.d.ts.map +1 -0
- package/dist/node/cli/display/hooks/useManifest.d.ts +1 -0
- package/dist/node/cli/display/hooks/useManifest.d.ts.map +1 -0
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts +1 -0
- package/dist/node/cli/display/hooks/useStatefulLog.d.ts.map +1 -0
- package/dist/node/cli/display/tools/BlockList.d.ts +1 -0
- package/dist/node/cli/display/tools/BlockList.d.ts.map +1 -0
- package/dist/node/cli/display/tools/CreateBlock.d.ts +1 -0
- package/dist/node/cli/display/tools/CreateBlock.d.ts.map +1 -0
- package/dist/node/cli/display/tools/cli-tool-list.d.ts +1 -0
- package/dist/node/cli/display/tools/cli-tool-list.d.ts.map +1 -0
- package/dist/node/cli/display/tools/cli-tools.d.ts +1 -0
- package/dist/node/cli/display/tools/cli-tools.d.ts.map +1 -0
- package/dist/node/cli/display/util/colors.d.ts +1 -0
- package/dist/node/cli/display/util/colors.d.ts.map +1 -0
- package/dist/node/cli/version.d.ts +2 -1
- package/dist/node/cli/version.d.ts.map +1 -0
- package/dist/node/cli/version.js +1 -1
- package/dist/node/compiler/build-vinxi.d.ts +1 -0
- package/dist/node/compiler/build-vinxi.d.ts.map +1 -0
- package/dist/node/compiler/build-vinxi.js +1 -0
- package/dist/node/compiler/bundler.admin.d.ts +1 -0
- package/dist/node/compiler/bundler.admin.d.ts.map +1 -0
- package/dist/node/compiler/bundler.frontend.d.ts +2 -0
- package/dist/node/compiler/bundler.frontend.d.ts.map +1 -0
- package/dist/node/compiler/bundler.frontend.js +25 -11
- package/dist/node/compiler/cache-config.d.ts +3 -0
- package/dist/node/compiler/cache-config.d.ts.map +1 -0
- package/dist/node/compiler/cache-config.js +16 -0
- package/dist/node/compiler/dev-server.d.ts +4 -1
- package/dist/node/compiler/dev-server.d.ts.map +1 -0
- package/dist/node/compiler/dev-server.js +26 -13
- package/dist/node/compiler/get-vite-config.d.ts +11 -1
- package/dist/node/compiler/get-vite-config.d.ts.map +1 -0
- package/dist/node/compiler/get-vite-config.js +164 -36
- package/dist/node/compiler/vinxi-app.d.ts +1 -0
- package/dist/node/compiler/vinxi-app.d.ts.map +1 -0
- package/dist/node/compiler/vinxi-app.js +56 -39
- package/dist/node/compiler/vinxi-codegen.d.ts +1 -0
- package/dist/node/compiler/vinxi-codegen.d.ts.map +1 -0
- package/dist/node/compiler/vinxi-codegen.js +152 -85
- package/dist/node/graphql/graphql-codegen.d.ts +1 -0
- package/dist/node/graphql/graphql-codegen.d.ts.map +1 -0
- package/dist/node/graphql/graphql-codegen.js +52 -24
- package/dist/node/graphql/graphql-schema-loader.d.ts +1 -0
- package/dist/node/graphql/graphql-schema-loader.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-files.d.ts +3 -1
- package/dist/node/graphql/plugins/gql-plugin-files.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-files.js +3 -2
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts +1 -0
- package/dist/node/graphql/plugins/gql-plugin-no-duplicates.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.d.ts +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.d.ts.map +1 -0
- package/dist/node/graphql/plugins/gql-plugin-queries.js +1 -1
- package/dist/node/graphql/query-files-loader.d.ts +1 -0
- package/dist/node/graphql/query-files-loader.d.ts.map +1 -0
- package/dist/node/graphql/wp-info-query.d.ts +1 -0
- package/dist/node/graphql/wp-info-query.d.ts.map +1 -0
- package/dist/node/project/config.d.ts +112 -7
- package/dist/node/project/config.d.ts.map +1 -0
- package/dist/node/project/config.js +54 -24
- package/dist/node/project/eddev-build-file.d.ts +1 -0
- package/dist/node/project/eddev-build-file.d.ts.map +1 -0
- package/dist/node/project/eddev-build-file.js +4 -2
- package/dist/node/project/env.d.ts +1 -0
- package/dist/node/project/env.d.ts.map +1 -0
- package/dist/node/project/favicons.d.ts +1 -0
- package/dist/node/project/favicons.d.ts.map +1 -0
- package/dist/node/project/manifest/block-manifest.d.ts +1 -0
- package/dist/node/project/manifest/block-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/block-manifest.js +7 -2
- package/dist/node/project/manifest/field-manifest.d.ts +1 -0
- package/dist/node/project/manifest/field-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/manifest.d.ts +1 -0
- package/dist/node/project/manifest/manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/routes-manifest.d.ts +1 -0
- package/dist/node/project/manifest/routes-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/routes-manifest.js +1 -1
- package/dist/node/project/manifest/view-manifest.d.ts +1 -0
- package/dist/node/project/manifest/view-manifest.d.ts.map +1 -0
- package/dist/node/project/manifest/widget-manifest.d.ts +1 -0
- package/dist/node/project/manifest/widget-manifest.d.ts.map +1 -0
- package/dist/node/project/project.d.ts +4 -0
- package/dist/node/project/project.d.ts.map +1 -0
- package/dist/node/project/project.js +24 -1
- package/dist/node/project/wp-info.d.ts +2 -0
- package/dist/node/project/wp-info.d.ts.map +1 -0
- package/dist/node/storybook/index.d.ts +3 -0
- package/dist/node/storybook/index.d.ts.map +1 -0
- package/dist/node/storybook/index.js +13 -0
- package/dist/node/types/block-type.d.ts +33 -6
- package/dist/node/types/block-type.d.ts.map +1 -0
- package/dist/node/types/block-type.js +3 -1
- package/dist/node/types/view-type.d.ts +1 -0
- package/dist/node/types/view-type.d.ts.map +1 -0
- package/dist/node/utils/fetch-wp.d.ts +1 -0
- package/dist/node/utils/fetch-wp.d.ts.map +1 -0
- package/dist/node/utils/fetch-wp.js +4 -3
- package/dist/node/utils/format-zod-error.d.ts +1 -0
- package/dist/node/utils/format-zod-error.d.ts.map +1 -0
- package/dist/node/utils/fs-codegen.d.ts +2 -0
- package/dist/node/utils/fs-codegen.d.ts.map +1 -0
- package/dist/node/utils/fs-codegen.js +8 -1
- package/dist/node/utils/fs.d.ts +24 -16
- package/dist/node/utils/fs.d.ts.map +1 -0
- package/dist/node/utils/get-repo-info.d.ts +1 -0
- package/dist/node/utils/get-repo-info.d.ts.map +1 -0
- package/dist/node/utils/helpers.d.ts +1 -0
- package/dist/node/utils/helpers.d.ts.map +1 -0
- package/dist/node/utils/highlight-code.d.ts +1 -0
- package/dist/node/utils/highlight-code.d.ts.map +1 -0
- package/dist/node/utils/is-deploying.d.ts +1 -0
- package/dist/node/utils/is-deploying.d.ts.map +1 -0
- package/dist/node/utils/report-builder.d.ts +7 -6
- package/dist/node/utils/report-builder.d.ts.map +1 -0
- package/dist/node/utils/self-signed-cert.d.ts +5 -0
- package/dist/node/utils/self-signed-cert.d.ts.map +1 -0
- package/dist/node/utils/self-signed-cert.js +28 -4
- package/dist/node/utils/stateful-log.d.ts +1 -0
- package/dist/node/utils/stateful-log.d.ts.map +1 -0
- package/dist/node/utils/ts-export-extractor.d.ts +1 -0
- package/dist/node/utils/ts-export-extractor.d.ts.map +1 -0
- package/dist/node/utils/watch-file-tree.d.ts +1 -0
- package/dist/node/utils/watch-file-tree.d.ts.map +1 -0
- package/package.json +34 -24
- package/tsconfig.app.json +8 -3
- package/tsconfig.node.json +1 -0
- package/types.env.d.ts +3 -0
- package/types.meta.d.ts +449 -136
- package/dist/app/server/defineRouter.d.ts +0 -2
- package/dist/app/server/defineRouter.js +0 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BlockInstance } from "../inline-editing";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a block instance for the editor. This doesn't add the block to the editor on it's own.
|
|
4
|
+
* @param name The name of the block
|
|
5
|
+
* @param attributes
|
|
6
|
+
* @param innerBlocks
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function createBlock(name: ChildBlockTypeName, attributes?: Record<string, any>, innerBlocks?: BlockInstance[]): BlockInstance;
|
|
10
|
+
//# sourceMappingURL=create-block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-block.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/create-block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AAEjD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,kBAAkB,EACxB,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACpC,WAAW,GAAE,aAAa,EAAO,GAChC,aAAa,CAKf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a block instance for the editor. This doesn't add the block to the editor on it's own.
|
|
3
|
+
* @param name The name of the block
|
|
4
|
+
* @param attributes
|
|
5
|
+
* @param innerBlocks
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
export function createBlock(name, attributes = {}, innerBlocks = []) {
|
|
9
|
+
if (!env.admin) {
|
|
10
|
+
throw new Error("`createBlock` can only be used in the admin environment");
|
|
11
|
+
}
|
|
12
|
+
return wp.blocks.createBlock(name, attributes, innerBlocks);
|
|
13
|
+
}
|
|
@@ -26,29 +26,49 @@ export type EditorConfigItem = {
|
|
|
26
26
|
/** A full-page block template */
|
|
27
27
|
template?: BlockTemplate;
|
|
28
28
|
};
|
|
29
|
-
type
|
|
29
|
+
type EditorBlock = {
|
|
30
30
|
name: string;
|
|
31
31
|
slug: BlockTypeName | (string & {});
|
|
32
32
|
attributes: any;
|
|
33
33
|
clientId: string;
|
|
34
34
|
rootClientId: string;
|
|
35
|
+
isRootBlock: boolean;
|
|
36
|
+
getParent: () => EditorBlock | null;
|
|
35
37
|
canMove: boolean;
|
|
36
38
|
canRemove: boolean;
|
|
37
39
|
isSelected: boolean;
|
|
38
40
|
isSelectionEnabled: boolean;
|
|
39
|
-
tags?: DefinedBlockTags;
|
|
41
|
+
tags?: (keyof DefinedBlockTags)[];
|
|
40
42
|
flags?: DefinedBlockFlags;
|
|
41
|
-
}
|
|
43
|
+
};
|
|
44
|
+
export type BlockWrapperClassGenerator = (block: EditorBlock, post: PostInfo) => string | void;
|
|
42
45
|
export declare const editorConfigStore: {
|
|
43
46
|
config: EditorConfig | null;
|
|
44
47
|
currentBlocksConfig: EditorConfigItem;
|
|
45
48
|
};
|
|
46
49
|
export declare function configureEditorBlocks(config: EditorConfigItem): void;
|
|
47
|
-
export declare function transformTemplateToBlocks(template: BlockTemplate, locked?: boolean, isFromTemplate?: boolean): any;
|
|
48
50
|
type PostInfo = {
|
|
49
|
-
template: TemplateName | "default";
|
|
50
51
|
type: PostTypeName;
|
|
52
|
+
isPattern: false;
|
|
53
|
+
isTemplatePart: false;
|
|
54
|
+
template: TemplateName | "default";
|
|
55
|
+
slug: string;
|
|
56
|
+
parent: number;
|
|
57
|
+
title: string;
|
|
58
|
+
link: string;
|
|
59
|
+
} | {
|
|
60
|
+
type: "wp_block";
|
|
61
|
+
isPattern: true;
|
|
62
|
+
isTemplatePart: false;
|
|
63
|
+
title: string;
|
|
64
|
+
} | {
|
|
65
|
+
type: "wp_template_part";
|
|
66
|
+
isPattern: false;
|
|
67
|
+
isTemplatePart: true;
|
|
68
|
+
area: string;
|
|
69
|
+
title: string;
|
|
51
70
|
slug: string;
|
|
71
|
+
wp_pattern_category?: number[];
|
|
52
72
|
};
|
|
53
73
|
type MatcherFunction = (post: PostInfo) => boolean | void;
|
|
54
74
|
type Matcher = {
|
|
@@ -57,9 +77,45 @@ type Matcher = {
|
|
|
57
77
|
/** Configuration for the editor, when the post type and template match */
|
|
58
78
|
config: EditorConfigItem | ((post: PostInfo) => EditorConfigItem);
|
|
59
79
|
};
|
|
80
|
+
export type BlockTransform = {
|
|
81
|
+
from: ChildBlockTypeName[];
|
|
82
|
+
to: ChildBlockTypeName;
|
|
83
|
+
};
|
|
84
|
+
export type CustomRichTextFormat = {
|
|
85
|
+
/** The ID of the format, eg. `"custom/fancy"` */
|
|
86
|
+
id: string;
|
|
87
|
+
/** The title of the format, shown on the tooltip */
|
|
88
|
+
title: string;
|
|
89
|
+
/**
|
|
90
|
+
* The HTML tag name to use.
|
|
91
|
+
* @default `"span"`
|
|
92
|
+
**/
|
|
93
|
+
tagName?: string;
|
|
94
|
+
/**
|
|
95
|
+
* The class name to apply to the element.
|
|
96
|
+
* @default `undefined`
|
|
97
|
+
**/
|
|
98
|
+
className?: string;
|
|
99
|
+
/**
|
|
100
|
+
* The icon to use in the toolbar.
|
|
101
|
+
*/
|
|
102
|
+
icon?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Whether format makes content interactive or not.
|
|
105
|
+
* @default `false`
|
|
106
|
+
*/
|
|
107
|
+
interactive?: boolean;
|
|
108
|
+
/**
|
|
109
|
+
* Whether to disable this format by default. If `true`, you must pass the format ID to `allowedFormats` on a `EditableText` component.
|
|
110
|
+
*
|
|
111
|
+
* @default `false`
|
|
112
|
+
*/
|
|
113
|
+
disabledByDefault?: boolean;
|
|
114
|
+
};
|
|
60
115
|
type EditorConfig = {
|
|
61
|
-
|
|
62
|
-
matchers
|
|
116
|
+
customRichTextFormats?: CustomRichTextFormat[];
|
|
117
|
+
/** A list of template/post type matchers, and resulting editor config that they will apply */
|
|
118
|
+
matchers?: Matcher[];
|
|
63
119
|
};
|
|
64
120
|
/**
|
|
65
121
|
* This call should be placed in blocks/_editor.tsx
|
|
@@ -69,3 +125,4 @@ export declare function getEditingPostInfo(): PostInfo;
|
|
|
69
125
|
export declare function updateTemplateConfig(): void;
|
|
70
126
|
export declare function watchEditorTemplate(): void;
|
|
71
127
|
export {};
|
|
128
|
+
//# sourceMappingURL=editor-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"editor-config.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/editor-config.tsx"],"names":[],"mappings":"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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { proxy } from "valtio";
|
|
2
|
-
import { resolveAcfBlockName, transformBlockTemplate } from "./block-templates.js";
|
|
2
|
+
import { applyTemplateBlocks, resolveAcfBlockName, transformBlockTemplate, transformTemplateToBlocks, } from "./block-templates.js";
|
|
3
3
|
export const editorConfigStore = proxy({
|
|
4
4
|
config: null,
|
|
5
5
|
currentBlocksConfig: {},
|
|
@@ -21,73 +21,13 @@ export function configureEditorBlocks(config) {
|
|
|
21
21
|
if (config.template) {
|
|
22
22
|
setTemplate(config.template);
|
|
23
23
|
if (config.headerTemplate || config.footerTemplate) {
|
|
24
|
-
console.error("You cannot use both a template
|
|
24
|
+
console.error("You cannot use both a 'template' alongside 'headerBlock'/'footerBlock'. Did you mean to use 'defaultBlocks' instead?");
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
const currentBlocks = wp.data.select("core/block-editor").getBlocks();
|
|
29
|
-
const
|
|
30
|
-
let header = config.headerTemplate ? syncBlocks(transformTemplateToBlocks(config.headerTemplate)) : [];
|
|
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)
|
|
47
|
-
if (!blocks.length && config.defaultBlocks) {
|
|
48
|
-
blocks = transformTemplateToBlocks(config.defaultBlocks, false, false);
|
|
49
|
-
}
|
|
50
|
-
let newBlocks = [...header, ...blocks, ...footer];
|
|
29
|
+
const newBlocks = applyTemplateBlocks(currentBlocks, config);
|
|
51
30
|
wp.data.dispatch("core/block-editor").resetBlocks(newBlocks);
|
|
52
|
-
function syncBlocks(blocks) {
|
|
53
|
-
return blocks.map((block) => {
|
|
54
|
-
const matched = templateBlocks.find((templateBlock) => templateBlock.name === block.name);
|
|
55
|
-
templateBlocks.splice(templateBlocks.indexOf(matched), 1);
|
|
56
|
-
if (matched) {
|
|
57
|
-
matched.attributes.lock = block.attributes.lock;
|
|
58
|
-
return matched;
|
|
59
|
-
}
|
|
60
|
-
return block;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
export function transformTemplateToBlocks(template, locked = true, isFromTemplate = true) {
|
|
65
|
-
return template.map(([name, props, children]) => {
|
|
66
|
-
const attributes = {
|
|
67
|
-
data: {},
|
|
68
|
-
inline: {},
|
|
69
|
-
isFromTemplate: isFromTemplate,
|
|
70
|
-
lock: undefined,
|
|
71
|
-
};
|
|
72
|
-
if (props.locked === false) {
|
|
73
|
-
attributes.lock = { move: false, remove: false };
|
|
74
|
-
}
|
|
75
|
-
else if (locked || props.locked === true || props.locked === "all") {
|
|
76
|
-
attributes.lock = { move: true, remove: true };
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
attributes.lock = props.lock;
|
|
80
|
-
}
|
|
81
|
-
Object.assign(attributes, props);
|
|
82
|
-
return {
|
|
83
|
-
clientId: "block-" + Math.random().toString(36),
|
|
84
|
-
name: resolveAcfBlockName(name),
|
|
85
|
-
attributes: attributes,
|
|
86
|
-
innerBlocks: children ? transformTemplateToBlocks(children, false, isFromTemplate) : [],
|
|
87
|
-
isValid: true,
|
|
88
|
-
validationIssues: [],
|
|
89
|
-
};
|
|
90
|
-
});
|
|
91
31
|
}
|
|
92
32
|
/**
|
|
93
33
|
* This call should be placed in blocks/_editor.tsx
|
|
@@ -105,10 +45,18 @@ export function getEditingPostInfo() {
|
|
|
105
45
|
const postInfo = {
|
|
106
46
|
...post,
|
|
107
47
|
...edits,
|
|
48
|
+
isTemplatePart: false,
|
|
49
|
+
isPattern: false,
|
|
108
50
|
};
|
|
109
51
|
if (!postInfo.template)
|
|
110
52
|
postInfo.template = "default";
|
|
111
53
|
postInfo.template = postInfo.template.replace(/(^views\/|\.tsx?$)/g, "");
|
|
54
|
+
if (postInfo.type === "wp_template_part") {
|
|
55
|
+
postInfo.isTemplatePart = true;
|
|
56
|
+
}
|
|
57
|
+
if (postInfo.type === "wp_block") {
|
|
58
|
+
postInfo.isPattern = true;
|
|
59
|
+
}
|
|
112
60
|
return postInfo;
|
|
113
61
|
}
|
|
114
62
|
export function updateTemplateConfig() {
|
|
@@ -117,7 +65,7 @@ export function updateTemplateConfig() {
|
|
|
117
65
|
const editorConfig = editorConfigStore.config;
|
|
118
66
|
if (!editorConfig)
|
|
119
67
|
return;
|
|
120
|
-
const matched = editorConfig.matchers
|
|
68
|
+
const matched = editorConfig.matchers?.find((matcher) => {
|
|
121
69
|
return matcher.match(postInfo);
|
|
122
70
|
});
|
|
123
71
|
if (matched) {
|
|
@@ -131,17 +79,24 @@ export function updateTemplateConfig() {
|
|
|
131
79
|
}
|
|
132
80
|
}
|
|
133
81
|
export function watchEditorTemplate() {
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
82
|
+
let lastKey = "unknown";
|
|
83
|
+
let timer = 0;
|
|
84
|
+
const update = () => {
|
|
85
|
+
const post = wp.data.select("core/editor").getCurrentPost();
|
|
86
|
+
const template = wp.data.select("core/editor").getPostEdits()?.template ?? post?.template ?? "";
|
|
87
|
+
const key = [post.type, template, post.slug, post.title].join(";");
|
|
88
|
+
if (key !== lastKey) {
|
|
89
|
+
lastKey = key;
|
|
90
|
+
clearTimeout(timer);
|
|
91
|
+
timer = setTimeout(() => {
|
|
141
92
|
updateTemplateConfig();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
93
|
+
}, 20);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
wp.data.subscribe(() => {
|
|
97
|
+
update();
|
|
144
98
|
});
|
|
99
|
+
update();
|
|
145
100
|
}
|
|
146
101
|
function setWrapperBlock(blockName, blocks) {
|
|
147
102
|
const wp = window.wp;
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
export declare const blockMetaDescriptors: Map<string, BlockMeta> & {
|
|
2
|
+
$$valtioSnapshot: Omit<Map<string, BlockMeta>, "set" | "clear" | "delete">;
|
|
3
|
+
};
|
|
1
4
|
export declare function whenEditorIsReady(): Promise<void>;
|
|
2
5
|
export declare function installEDGutenbergHooks(): void;
|
|
6
|
+
//# sourceMappingURL=installGutenbergHooks.d.ts.map
|
|
@@ -0,0 +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,SAyQtC"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect } from "react";
|
|
3
|
-
import { useSnapshot } from "valtio";
|
|
4
|
-
import {
|
|
3
|
+
import { subscribe, useSnapshot } from "valtio";
|
|
4
|
+
import { proxyMap } from "valtio/utils";
|
|
5
|
+
import { addBlockMetadata, getBlockMetadata } from "../block-utils.js";
|
|
6
|
+
import { registerBuiltinBlocks } from "../builtin-blocks.js";
|
|
5
7
|
import { InlineEditingContextProvider } from "../inline-editing.js";
|
|
6
|
-
import {
|
|
8
|
+
import { EditorHighlights } from "./EditorHighlights.js";
|
|
9
|
+
import { EditableBlock } from "./EditorSupport.js";
|
|
10
|
+
import { resolveAcfBlockName } from "./block-templates.js";
|
|
7
11
|
import { blocksByTag } from "./blocks-by-tag.js";
|
|
8
12
|
import { editorConfigStore, getEditingPostInfo, watchEditorTemplate } from "./editor-config.js";
|
|
9
13
|
import { rootBlocks } from "./root-blocks.js";
|
|
10
|
-
import { EditorHighlights } from "./EditorHighlights.js";
|
|
11
14
|
function listenForHandleResize() {
|
|
12
15
|
let interval = setInterval(() => {
|
|
13
16
|
let viewportTarget = document.querySelector(".interface-interface-skeleton__content");
|
|
@@ -21,16 +24,28 @@ function listenForHandleResize() {
|
|
|
21
24
|
}
|
|
22
25
|
}, 100);
|
|
23
26
|
}
|
|
27
|
+
export const blockMetaDescriptors = proxyMap();
|
|
24
28
|
export function whenEditorIsReady() {
|
|
25
29
|
return new Promise((resolve) => {
|
|
30
|
+
let ready = false;
|
|
26
31
|
const unsubscribe = wp.data.subscribe(() => {
|
|
27
32
|
// This will trigger after the initial render blocking, before the window load event
|
|
28
33
|
// This seems currently more reliable than using __unstableIsEditorReady
|
|
29
|
-
if (wp.data.select("core/editor").isCleanNewPost() ||
|
|
34
|
+
if (wp.data.select("core/editor").isCleanNewPost(undefined) ||
|
|
35
|
+
wp.data.select("core/block-editor").getBlockCount() > 0) {
|
|
36
|
+
if (ready)
|
|
37
|
+
return;
|
|
38
|
+
ready = true;
|
|
30
39
|
unsubscribe();
|
|
31
40
|
resolve();
|
|
32
41
|
}
|
|
33
42
|
});
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
if (ready)
|
|
45
|
+
return;
|
|
46
|
+
unsubscribe();
|
|
47
|
+
resolve();
|
|
48
|
+
}, 1000);
|
|
34
49
|
});
|
|
35
50
|
}
|
|
36
51
|
export function installEDGutenbergHooks() {
|
|
@@ -42,19 +57,117 @@ export function installEDGutenbergHooks() {
|
|
|
42
57
|
return (props) => {
|
|
43
58
|
const generateClass = useSnapshot(editorConfigStore).currentBlocksConfig?.generateBlockClassName;
|
|
44
59
|
Object.assign(props, getBlockMetadata(props.name));
|
|
60
|
+
props.isRootBlock = !props.rootClientId;
|
|
61
|
+
props.getParent = () => props.rootClientId ? wp.data.select("core/block-editor").getBlock(props.rootClientId) : null;
|
|
45
62
|
let className = generateClass ? generateClass(props, getEditingPostInfo()) : "";
|
|
46
63
|
return _jsx(BlockListBlock, { ...props, className: className });
|
|
47
64
|
};
|
|
48
65
|
}, "withClientIdClassName");
|
|
49
66
|
wp.hooks.addFilter("editor.BlockListBlock", "ed", withClientIdClassName);
|
|
67
|
+
const withBlockContext = wp.compose.createHigherOrderComponent((BlockEdit) => {
|
|
68
|
+
return (props) => {
|
|
69
|
+
function getChildren() {
|
|
70
|
+
const { getBlock, getBlockOrder, getBlockIndex, getBlockRootClientId } = wp.data.select("core/block-editor");
|
|
71
|
+
const block = getBlock(props.clientId);
|
|
72
|
+
const rootClientId = getBlockRootClientId(props.clientId);
|
|
73
|
+
const index = getBlockIndex(props.clientId, rootClientId || undefined);
|
|
74
|
+
const innerBlockIDs = getBlockOrder(props.clientId);
|
|
75
|
+
if (block) {
|
|
76
|
+
addBlockMetadata([block]);
|
|
77
|
+
}
|
|
78
|
+
const children = innerBlockIDs.map((id) => {
|
|
79
|
+
return getBlock(id);
|
|
80
|
+
});
|
|
81
|
+
addBlockMetadata(children);
|
|
82
|
+
return {
|
|
83
|
+
block,
|
|
84
|
+
children,
|
|
85
|
+
index,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
const { block, children, index } = getChildren();
|
|
89
|
+
// const block = wp.data.useSelect(
|
|
90
|
+
// (select) => {
|
|
91
|
+
// // @ts-ignore
|
|
92
|
+
// return select("block-editor").getBlock(props.clientId)
|
|
93
|
+
// },
|
|
94
|
+
// [props.clientId],
|
|
95
|
+
// )
|
|
96
|
+
// const [index, setIndex] = useState(getIndex)
|
|
97
|
+
// const [children, setChildren] = useState<any[]>(getChildren)
|
|
98
|
+
// useEffect(() => {
|
|
99
|
+
// return wp.data.subscribe(() => {
|
|
100
|
+
// setIndex(getIndex())
|
|
101
|
+
// const children = getChildren()
|
|
102
|
+
// setChildren((current) =>
|
|
103
|
+
// current.length === children.length
|
|
104
|
+
// ? current.every((item, i) => item === children[i])
|
|
105
|
+
// ? current
|
|
106
|
+
// : children
|
|
107
|
+
// : children,
|
|
108
|
+
// )
|
|
109
|
+
// }, [])
|
|
110
|
+
// }, [props.clientId, props.attributes])
|
|
111
|
+
if (!block)
|
|
112
|
+
return null;
|
|
113
|
+
return (_jsx(InlineEditingContextProvider, { values: props.attributes.inline || {}, innerBlocks: children, block: [props.name, props], editorBlock: block, index: index ?? -1, onChange: (attrs) => {
|
|
114
|
+
props.setAttributes({ ...props.attributes, inline: attrs });
|
|
115
|
+
}, insertBlocksAfter: props.insertBlocksAfter, clientId: props.clientId, children: _jsx(BlockEdit, { ...props }, "edit") }));
|
|
116
|
+
};
|
|
117
|
+
}, "withMyPluginControls");
|
|
118
|
+
wp.hooks.addFilter("editor.BlockEdit", "ed", withBlockContext);
|
|
119
|
+
// if (wp.blocks) {
|
|
120
|
+
// }
|
|
121
|
+
// Manage custom rich text formats
|
|
122
|
+
setTimeout(() => {
|
|
123
|
+
subscribe(editorConfigStore, () => {
|
|
124
|
+
const formats = editorConfigStore.config?.customRichTextFormats;
|
|
125
|
+
if (formats) {
|
|
126
|
+
const activeFormats = wp.data.select("core/rich-text").getFormatTypes();
|
|
127
|
+
formats.forEach((format) => {
|
|
128
|
+
if (activeFormats.some((f) => f.name === format.id)) {
|
|
129
|
+
wp.richText.unregisterFormatType(format.id);
|
|
130
|
+
}
|
|
131
|
+
const EditComponent = (props) => {
|
|
132
|
+
if (format.disabledByDefault) {
|
|
133
|
+
const explicitlyEnabled = props.contentRef.current
|
|
134
|
+
?.getAttribute("data-allowed-formats")
|
|
135
|
+
?.includes(format.id);
|
|
136
|
+
if (!explicitlyEnabled) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return (_jsx(wp.components.Fill, { name: "BlockFormatControls", children: _jsx(wp.components.ToolbarButton, { icon: format.icon, title: format.title, onClick: () => {
|
|
141
|
+
props.onChange(wp.richText.toggleFormat(props.value, {
|
|
142
|
+
type: format.id,
|
|
143
|
+
}));
|
|
144
|
+
}, isActive: props.isActive }) }));
|
|
145
|
+
};
|
|
146
|
+
wp.richText.registerFormatType(format.id, {
|
|
147
|
+
name: format.id,
|
|
148
|
+
title: format.title,
|
|
149
|
+
tagName: format.tagName ?? "span",
|
|
150
|
+
className: format.className,
|
|
151
|
+
interactive: false,
|
|
152
|
+
edit: EditComponent,
|
|
153
|
+
// @ts-ignore
|
|
154
|
+
disabledByDefault: format.disabledByDefault,
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
50
160
|
listenForHandleResize();
|
|
51
161
|
// Remove unwanted formatting options
|
|
52
162
|
// https://developer.wordpress.org/block-editor/how-to-guides/format-api/
|
|
53
|
-
wp.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
163
|
+
const { removeFormatTypes } = wp.data.dispatch("core/rich-text");
|
|
164
|
+
removeFormatTypes("core/image");
|
|
165
|
+
removeFormatTypes("core/language");
|
|
166
|
+
removeFormatTypes("core/keyboard");
|
|
167
|
+
removeFormatTypes("core/text-color");
|
|
168
|
+
whenEditorIsReady().then(() => {
|
|
169
|
+
watchEditorTemplate();
|
|
170
|
+
});
|
|
58
171
|
// Recalculate registered blocks when rootBlocks change
|
|
59
172
|
rootBlocks.listen();
|
|
60
173
|
wp.hooks.addFilter("blocks.registerBlockType", "ed", (item, name) => {
|
|
@@ -68,6 +181,12 @@ export function installEDGutenbergHooks() {
|
|
|
68
181
|
// Add an 'inline' object attribute, which will hold all inline contents
|
|
69
182
|
item.attributes.inline = { type: "object" };
|
|
70
183
|
item.attributes.values = { type: "object" };
|
|
184
|
+
// Add className support to all ACF blocks
|
|
185
|
+
const defaultStyleName = item.styles?.find((s) => s.isDefault)?.name;
|
|
186
|
+
item.attributes.className = {
|
|
187
|
+
type: "string",
|
|
188
|
+
default: item.attributes?.className?.default ?? (defaultStyleName ? "is-style-" + defaultStyleName : undefined),
|
|
189
|
+
};
|
|
71
190
|
item.attributes.isFromTemplate = { type: "boolean" };
|
|
72
191
|
item.supports.customClassName = false;
|
|
73
192
|
item.edit = function (props) {
|
|
@@ -76,20 +195,7 @@ export function installEDGutenbergHooks() {
|
|
|
76
195
|
;
|
|
77
196
|
wp.data.dispatch("core/block-editor").setTemplateValidity(true);
|
|
78
197
|
}, []);
|
|
79
|
-
|
|
80
|
-
const { getBlock, getBlockOrder, getBlockIndex } = select("core/block-editor");
|
|
81
|
-
const innerBlockIDs = getBlockOrder(props.clientId);
|
|
82
|
-
const children = innerBlockIDs.map((id) => {
|
|
83
|
-
return getBlock(id);
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
children,
|
|
87
|
-
index: getBlockIndex(props.clientId),
|
|
88
|
-
};
|
|
89
|
-
}, []);
|
|
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) => {
|
|
91
|
-
props.setAttributes({ ...props.attributes, inline: attrs });
|
|
92
|
-
}, insertBlocksAfter: props.insertBlocksAfter, children: _jsx(EditorHighlights, { enabled: true, clientId: props.clientId, children: edit.call(self, props) }) }) }));
|
|
198
|
+
return (_jsx(EditorHighlights, { enabled: true, clientId: props.clientId, children: edit.call(self, props) }));
|
|
93
199
|
};
|
|
94
200
|
}
|
|
95
201
|
// Find PHP-defined 'tags' for core blocks.
|
|
@@ -111,18 +217,37 @@ export function installEDGutenbergHooks() {
|
|
|
111
217
|
return {
|
|
112
218
|
...item,
|
|
113
219
|
get parent() {
|
|
220
|
+
if (name === "core/block" || name === "core/slot-group")
|
|
221
|
+
return undefined;
|
|
114
222
|
return blocksByTag.expand([...(item.parent ?? []), ...(isRootBlock ? ["core/post-content"] : [])]);
|
|
115
223
|
},
|
|
224
|
+
get transforms() {
|
|
225
|
+
const result = {
|
|
226
|
+
from: item.transforms?.from ?? [],
|
|
227
|
+
to: item.transforms?.to ?? [],
|
|
228
|
+
ungroup: item.transforms?.ungroup,
|
|
229
|
+
};
|
|
230
|
+
const meta = blockMetaDescriptors.get(resolveAcfBlockName(name, false));
|
|
231
|
+
if (meta?.transforms) {
|
|
232
|
+
result.from = [...(result.from ?? []), ...(meta.transforms.from ?? [])];
|
|
233
|
+
result.to = [...(result.to ?? []), ...(meta.transforms.to ?? [])];
|
|
234
|
+
}
|
|
235
|
+
return result;
|
|
236
|
+
},
|
|
116
237
|
get ancestor() {
|
|
238
|
+
if (name === "core/block" || name === "core/slot-group")
|
|
239
|
+
return undefined;
|
|
117
240
|
return item.ancestor ? blocksByTag.expand(item.ancestor) : undefined;
|
|
118
241
|
},
|
|
119
242
|
get allowedBlocks() {
|
|
120
|
-
return item.allowedBlocks ? blocksByTag.expand(item.allowedBlocks) : undefined;
|
|
243
|
+
return item.allowedBlocks ? [...blocksByTag.expand(item.allowedBlocks), "core/slot-group"] : undefined;
|
|
121
244
|
},
|
|
122
245
|
};
|
|
123
246
|
});
|
|
247
|
+
if (wp.blocks) {
|
|
248
|
+
registerBuiltinBlocks();
|
|
249
|
+
}
|
|
124
250
|
const acf = "acf" in window ? window.acf : {};
|
|
125
|
-
const parseJSX = acf.parseJSX;
|
|
126
251
|
acf.parseJSX = (html) => {
|
|
127
252
|
let payload;
|
|
128
253
|
try {
|
|
@@ -132,6 +257,6 @@ export function installEDGutenbergHooks() {
|
|
|
132
257
|
console.error(err);
|
|
133
258
|
throw new Error("eddev: Error parsing block data from: \n" + html);
|
|
134
259
|
}
|
|
135
|
-
return _jsx(EditableBlock, { payload: payload });
|
|
260
|
+
return _jsx(EditableBlock, { payload: payload ?? {} });
|
|
136
261
|
};
|
|
137
262
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root-blocks.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/root-blocks.tsx"],"names":[],"mappings":"AAQA,eAAO,MAAM,UAAU;;;;2BAoBE,MAAM,SAAS,MAAM,EAAE;CAG/C,CAAA"}
|
|
@@ -14,7 +14,17 @@ export declare function usePostEditor(): {
|
|
|
14
14
|
*
|
|
15
15
|
* @returns [title, setTitle]
|
|
16
16
|
*/
|
|
17
|
-
export declare function usePostTitleEditor(
|
|
17
|
+
export declare function usePostTitleEditor(value?: string): InlineValueStore<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Returns the current post excerpt, allowing it to be updated.
|
|
20
|
+
*
|
|
21
|
+
* NOTE: This only works in the editor.
|
|
22
|
+
*
|
|
23
|
+
* For convenience, you can pass in a default title to use when not in the editor, which you can fetch via GraphQL
|
|
24
|
+
*
|
|
25
|
+
* @returns [excerpt, setExcerpt]
|
|
26
|
+
*/
|
|
27
|
+
export declare function usePostExcerptEditor(value?: string): InlineValueStore<string>;
|
|
18
28
|
/**
|
|
19
29
|
* Returns a post meta value, allowing it to be updated.
|
|
20
30
|
*
|
|
@@ -25,3 +35,4 @@ export declare function usePostTitleEditor(title?: string): InlineValueStore<str
|
|
|
25
35
|
* @returns [value, setValue]
|
|
26
36
|
*/
|
|
27
37
|
export declare function usePostMetaEditor<K extends keyof PostMetaTypes>(key: K, value?: PostMetaTypes[K]): InlineValueStore<PostMetaTypes[K]>;
|
|
38
|
+
//# sourceMappingURL=usePostEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePostEditor.d.ts","sourceRoot":"","sources":["../../../../../src/app/lib/blocks/editor/usePostEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,sBAAsB,CAAA;AAExE,wBAAgB,aAAa;;uBAgBN,GAAG;;;EAMzB;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,SAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAEvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,SAAK,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAMzE;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,aAAa,EAC7D,GAAG,EAAE,CAAC,EACN,KAAK,CAAC,EAAE,aAAa,CAAC,CAAC,CAAC,GACvB,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAmBpC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useBlockContext } from "../inline-editing.js";
|
|
1
2
|
export function usePostEditor() {
|
|
2
3
|
const post = wp.data.useSelect((select) => {
|
|
3
4
|
const editor = select("core/editor");
|
|
@@ -18,17 +19,9 @@ export function usePostEditor() {
|
|
|
18
19
|
updateMeta,
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
|
-
|
|
22
|
-
* Returns the current post title, allowing it to be updated.
|
|
23
|
-
*
|
|
24
|
-
* NOTE: This only works in the editor.
|
|
25
|
-
*
|
|
26
|
-
* For convenience, you can pass in a default title to use when not in the editor, which you can fetch via GraphQL
|
|
27
|
-
*
|
|
28
|
-
* @returns [title, setTitle]
|
|
29
|
-
*/
|
|
30
|
-
export function usePostTitleEditor(title = "") {
|
|
22
|
+
function usePostFieldEditor(key, value) {
|
|
31
23
|
if (env.admin) {
|
|
24
|
+
const isReadOnly = useBlockContext()?.readonly;
|
|
32
25
|
const post = wp.data.useSelect((select) => {
|
|
33
26
|
const editor = select("core/editor");
|
|
34
27
|
const post = editor.getCurrentPost();
|
|
@@ -38,15 +31,47 @@ export function usePostTitleEditor(title = "") {
|
|
|
38
31
|
...edits,
|
|
39
32
|
};
|
|
40
33
|
}, []);
|
|
34
|
+
if (isReadOnly) {
|
|
35
|
+
return [value, () => { }];
|
|
36
|
+
}
|
|
41
37
|
return [
|
|
42
|
-
post
|
|
38
|
+
post[key] ?? "",
|
|
43
39
|
(title) => {
|
|
44
|
-
wp.data.dispatch("core/editor").editPost({ title });
|
|
40
|
+
wp.data.dispatch("core/editor").editPost({ [key]: title });
|
|
45
41
|
},
|
|
46
42
|
];
|
|
47
43
|
}
|
|
48
44
|
else {
|
|
49
|
-
return [
|
|
45
|
+
return [value, () => { }];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns the current post title, allowing it to be updated.
|
|
50
|
+
*
|
|
51
|
+
* NOTE: This only works in the editor.
|
|
52
|
+
*
|
|
53
|
+
* For convenience, you can pass in a default title to use when not in the editor, which you can fetch via GraphQL
|
|
54
|
+
*
|
|
55
|
+
* @returns [title, setTitle]
|
|
56
|
+
*/
|
|
57
|
+
export function usePostTitleEditor(value = "") {
|
|
58
|
+
return usePostFieldEditor("title", value);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns the current post excerpt, allowing it to be updated.
|
|
62
|
+
*
|
|
63
|
+
* NOTE: This only works in the editor.
|
|
64
|
+
*
|
|
65
|
+
* For convenience, you can pass in a default title to use when not in the editor, which you can fetch via GraphQL
|
|
66
|
+
*
|
|
67
|
+
* @returns [excerpt, setExcerpt]
|
|
68
|
+
*/
|
|
69
|
+
export function usePostExcerptEditor(value = "") {
|
|
70
|
+
if (!env.admin) {
|
|
71
|
+
return [value, () => { }];
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return usePostFieldEditor("excerpt", value);
|
|
50
75
|
}
|
|
51
76
|
}
|
|
52
77
|
/**
|