@questpie/admin 3.2.4 → 3.2.6
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/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +164 -339
- package/dist/client/components/actions/action-button.mjs +9 -9
- package/dist/client/components/actions/action-dialog.mjs +195 -493
- package/dist/client/components/actions/confirmation-dialog.mjs +44 -159
- package/dist/client/components/actions/header-actions.mjs +73 -165
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/admin-link.mjs +40 -126
- package/dist/client/components/auth/auth-loading.mjs +9 -44
- package/dist/client/components/blocks/block-canvas.mjs +31 -95
- package/dist/client/components/blocks/block-editor-context.mjs +13 -57
- package/dist/client/components/blocks/block-editor-layout.mjs +72 -166
- package/dist/client/components/blocks/block-editor-provider.mjs +184 -245
- package/dist/client/components/blocks/block-fields-renderer.mjs +54 -229
- package/dist/client/components/blocks/block-insert-button.mjs +49 -165
- package/dist/client/components/blocks/block-item-menu.mjs +102 -301
- package/dist/client/components/blocks/block-item.mjs +136 -370
- package/dist/client/components/blocks/block-library-sidebar.mjs +103 -230
- package/dist/client/components/blocks/block-tree.mjs +12 -68
- package/dist/client/components/blocks/block-type-icon.mjs +14 -56
- package/dist/client/components/brand-logo.mjs +35 -149
- package/dist/client/components/component-renderer.mjs +42 -118
- package/dist/client/components/error-boundary.mjs +14 -58
- package/dist/client/components/fields/array-field.mjs +209 -521
- package/dist/client/components/fields/asset-preview-field.mjs +41 -141
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +60 -156
- package/dist/client/components/fields/boolean-field.mjs +29 -59
- package/dist/client/components/fields/date-field.mjs +7 -37
- package/dist/client/components/fields/datetime-field.mjs +7 -38
- package/dist/client/components/fields/email-field.mjs +25 -54
- package/dist/client/components/fields/field-wrapper.mjs +30 -105
- package/dist/client/components/fields/json-field.mjs +94 -296
- package/dist/client/components/fields/locale-badge.mjs +6 -15
- package/dist/client/components/fields/number-field.mjs +27 -60
- package/dist/client/components/fields/object-array-field.mjs +283 -659
- package/dist/client/components/fields/object-field.mjs +165 -633
- package/dist/client/components/fields/relation/displays/cards-display.mjs +106 -220
- package/dist/client/components/fields/relation/displays/chips-display.mjs +78 -150
- package/dist/client/components/fields/relation/displays/grid-display.mjs +92 -186
- package/dist/client/components/fields/relation/displays/list-display.mjs +122 -239
- package/dist/client/components/fields/relation/displays/table-display.mjs +70 -244
- package/dist/client/components/fields/relation/relation-items-display.mjs +30 -126
- package/dist/client/components/fields/relation-field.mjs +10 -66
- package/dist/client/components/fields/relation-picker.mjs +18 -18
- package/dist/client/components/fields/relation-select.mjs +12 -12
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +80 -180
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +2 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +13 -29
- package/dist/client/components/fields/rich-text-editor/index.mjs +195 -513
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +61 -111
- package/dist/client/components/fields/rich-text-editor/table-controls.mjs +105 -415
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +256 -511
- package/dist/client/components/fields/rich-text-field.mjs +14 -53
- package/dist/client/components/fields/select-field.mjs +61 -72
- package/dist/client/components/fields/text-field.mjs +26 -59
- package/dist/client/components/fields/textarea-field.mjs +26 -58
- package/dist/client/components/fields/time-field.mjs +7 -35
- package/dist/client/components/fields/upload-field.mjs +47 -165
- package/dist/client/components/filter-builder/columns-tab.mjs +80 -280
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +197 -540
- package/dist/client/components/filter-builder/filters-tab.mjs +96 -386
- package/dist/client/components/filter-builder/saved-views-tab.mjs +133 -351
- package/dist/client/components/history-sidebar.mjs +285 -605
- package/dist/client/components/layout/field-layout-renderer.mjs +106 -254
- package/dist/client/components/locale-switcher.mjs +106 -228
- package/dist/client/components/media/media-grid.mjs +84 -273
- package/dist/client/components/media/media-picker-dialog.mjs +176 -476
- package/dist/client/components/preview/live-preview-mode.mjs +233 -458
- package/dist/client/components/preview/preview-pane.mjs +22 -22
- package/dist/client/components/primitives/asset-preview.mjs +290 -666
- package/dist/client/components/primitives/checkbox-input.mjs +9 -35
- package/dist/client/components/primitives/date-input.mjs +109 -327
- package/dist/client/components/primitives/dropzone.mjs +209 -336
- package/dist/client/components/primitives/field-select-control.mjs +12 -80
- package/dist/client/components/primitives/number-input.mjs +4 -4
- package/dist/client/components/primitives/select-multi.mjs +229 -572
- package/dist/client/components/primitives/select-single.mjs +179 -499
- package/dist/client/components/primitives/time-input.mjs +43 -117
- package/dist/client/components/primitives/toggle-input.mjs +9 -29
- package/dist/client/components/sheets/resource-sheet.mjs +61 -70
- package/dist/client/components/ui/accordion.mjs +35 -155
- package/dist/client/components/ui/alert.mjs +13 -68
- package/dist/client/components/ui/badge.mjs +9 -51
- package/dist/client/components/ui/button.mjs +8 -54
- package/dist/client/components/ui/card.mjs +37 -193
- package/dist/client/components/ui/checkbox.mjs +12 -68
- package/dist/client/components/ui/command.mjs +48 -219
- package/dist/client/components/ui/dialog.mjs +50 -262
- package/dist/client/components/ui/drawer.mjs +55 -259
- package/dist/client/components/ui/dropdown-menu.mjs +86 -427
- package/dist/client/components/ui/empty-state.mjs +28 -98
- package/dist/client/components/ui/field.mjs +73 -309
- package/dist/client/components/ui/input-group.mjs +42 -167
- package/dist/client/components/ui/input.mjs +7 -37
- package/dist/client/components/ui/kbd.mjs +6 -36
- package/dist/client/components/ui/label.mjs +7 -37
- package/dist/client/components/ui/popover.mjs +34 -169
- package/dist/client/components/ui/responsive-dialog.mjs +67 -273
- package/dist/client/components/ui/scroll-fade.mjs +63 -158
- package/dist/client/components/ui/search-input.mjs +33 -100
- package/dist/client/components/ui/select.mjs +72 -393
- package/dist/client/components/ui/separator.mjs +7 -38
- package/dist/client/components/ui/sheet.mjs +49 -269
- package/dist/client/components/ui/sidebar.mjs +171 -690
- package/dist/client/components/ui/skeleton.mjs +7 -38
- package/dist/client/components/ui/sonner.mjs +11 -42
- package/dist/client/components/ui/switch.mjs +9 -45
- package/dist/client/components/ui/table.mjs +48 -266
- package/dist/client/components/ui/tabs.mjs +26 -139
- package/dist/client/components/ui/textarea.mjs +6 -32
- package/dist/client/components/ui/tooltip.mjs +27 -129
- package/dist/client/components/widgets/chart-widget.mjs +174 -522
- package/dist/client/components/widgets/progress-widget.mjs +66 -172
- package/dist/client/components/widgets/quick-actions-widget.mjs +102 -261
- package/dist/client/components/widgets/recent-items-widget.mjs +69 -195
- package/dist/client/components/widgets/stats-widget.mjs +41 -175
- package/dist/client/components/widgets/table-widget.mjs +9 -9
- package/dist/client/components/widgets/timeline-widget.mjs +86 -226
- package/dist/client/components/widgets/value-widget.mjs +74 -381
- package/dist/client/components/widgets/widget-empty-state.mjs +26 -76
- package/dist/client/components/widgets/widget-skeletons.mjs +138 -421
- package/dist/client/contexts/focus-context.mjs +63 -146
- package/dist/client/hooks/typed-hooks.mjs +241 -701
- package/dist/client/hooks/use-action.mjs +62 -198
- package/dist/client/hooks/use-admin-config.mjs +5 -35
- package/dist/client/hooks/use-admin-preferences.mjs +16 -88
- package/dist/client/hooks/use-admin-routes.mjs +22 -56
- package/dist/client/hooks/use-audit-history.mjs +21 -69
- package/dist/client/hooks/use-brand.mjs +1 -9
- package/dist/client/hooks/use-collection-fields.mjs +17 -57
- package/dist/client/hooks/use-collection-meta.mjs +12 -44
- package/dist/client/hooks/use-collection-schema.mjs +10 -33
- package/dist/client/hooks/use-collection-validation.mjs +23 -53
- package/dist/client/hooks/use-collection.mjs +194 -614
- package/dist/client/hooks/use-current-user.mjs +0 -1
- package/dist/client/hooks/use-field-hooks.mjs +10 -10
- package/dist/client/hooks/use-field-options.mjs +61 -202
- package/dist/client/hooks/use-global-fields.mjs +14 -46
- package/dist/client/hooks/use-global-meta.mjs +9 -30
- package/dist/client/hooks/use-global-schema.mjs +9 -30
- package/dist/client/hooks/use-global.mjs +63 -219
- package/dist/client/hooks/use-locks.mjs +117 -325
- package/dist/client/hooks/use-media-query.mjs +16 -36
- package/dist/client/hooks/use-prefill-params.mjs +0 -1
- package/dist/client/hooks/use-questpie-query-options.mjs +12 -29
- package/dist/client/hooks/use-reactive-fields.mjs +1 -1
- package/dist/client/hooks/use-reactive-prop.mjs +65 -223
- package/dist/client/hooks/use-realtime-highlight.mjs +51 -114
- package/dist/client/hooks/use-saved-views.mjs +22 -103
- package/dist/client/hooks/use-search-param-toggle.mjs +28 -79
- package/dist/client/hooks/use-search.mjs +31 -143
- package/dist/client/hooks/use-server-actions.mjs +18 -50
- package/dist/client/hooks/use-server-validation.mjs +72 -166
- package/dist/client/hooks/use-server-widget-data.mjs +7 -33
- package/dist/client/hooks/use-setup-status.mjs +12 -25
- package/dist/client/hooks/use-sidebar-search-param.mjs +33 -78
- package/dist/client/hooks/use-transition-stage.mjs +8 -38
- package/dist/client/hooks/use-upload.mjs +54 -152
- package/dist/client/hooks/use-validation-error-map.mjs +6 -26
- package/dist/client/hooks/use-view-state.mjs +187 -437
- package/dist/client/i18n/hooks.mjs +65 -197
- package/dist/client/lib/render-profiler.mjs +14 -41
- package/dist/client/preview/block-scope-context.mjs +14 -36
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +42 -108
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +167 -348
- package/dist/client/preview/use-collection-preview.mjs +121 -215
- package/dist/client/runtime/content-locales-provider.mjs +31 -83
- package/dist/client/runtime/locale-scope.mjs +22 -63
- package/dist/client/runtime/provider.mjs +100 -255
- package/dist/client/runtime/translations-provider.mjs +41 -107
- package/dist/client/scope/picker.mjs +86 -321
- package/dist/client/scope/provider.mjs +8 -17
- package/dist/client/utils/build-field-definitions-from-schema.mjs +4 -2
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/accept-invite-form.mjs +121 -412
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/auth-layout.mjs +104 -284
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +94 -325
- package/dist/client/views/auth/invite-form.mjs +107 -442
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +116 -337
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +128 -453
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.mjs +140 -478
- package/dist/client/views/collection/auto-form-fields.mjs +243 -615
- package/dist/client/views/collection/bulk-action-toolbar.mjs +212 -379
- package/dist/client/views/collection/cells/complex-cells.mjs +183 -611
- package/dist/client/views/collection/cells/primitive-cells.mjs +116 -356
- package/dist/client/views/collection/cells/relation-cells.mjs +86 -233
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +142 -371
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +35 -131
- package/dist/client/views/collection/cells/upload-cells.mjs +60 -177
- package/dist/client/views/collection/columns/build-columns.mjs +8 -48
- package/dist/client/views/collection/field-renderer.mjs +58 -182
- package/dist/client/views/collection/form-view.mjs +284 -518
- package/dist/client/views/collection/table-view.mjs +231 -463
- package/dist/client/views/collection/view-skeletons.mjs +112 -237
- package/dist/client/views/common/global-search.mjs +241 -560
- package/dist/client/views/dashboard/dashboard-grid.mjs +256 -775
- package/dist/client/views/dashboard/dashboard-widget.mjs +38 -126
- package/dist/client/views/dashboard/widget-card.mjs +61 -269
- package/dist/client/views/globals/global-form-view.mjs +477 -1301
- package/dist/client/views/layout/admin-layout-provider.mjs +28 -88
- package/dist/client/views/layout/admin-layout.mjs +83 -246
- package/dist/client/views/layout/admin-router.mjs +458 -1274
- package/dist/client/views/layout/admin-sidebar.mjs +510 -1292
- package/dist/client/views/layout/admin-theme.mjs +30 -64
- package/dist/client/views/layout/admin-view-layout.mjs +40 -144
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +95 -290
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/dashboard-page.mjs +11 -57
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +31 -83
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +35 -90
- package/dist/client/views/pages/login-page.d.mts +2 -2
- package/dist/client/views/pages/login-page.mjs +41 -121
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +46 -173
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +33 -95
- package/dist/components/rich-text/rich-text-renderer.mjs +9 -33
- package/dist/server/adapters/index.d.mts +2 -0
- package/dist/server/adapters/nextjs.d.mts +1 -0
- package/dist/server/auth-helpers.d.mts +1 -0
- package/dist/server/modules/admin/.generated/module.d.mts +1 -0
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +50 -50
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +39 -39
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +62 -62
- package/dist/server/modules/admin/collections/verification.d.mts +23 -23
- package/dist/server/modules/admin/index.d.mts +20 -19
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +45 -45
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/dist/server.d.mts +2 -0
- package/package.json +3 -5
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { BlockEditorContextProvider } from "./block-editor-context.mjs";
|
|
4
4
|
import { duplicateBlockInTree, getAllBlockIds, getBlockPathIds, getDefaultValues, insertBlockInTree, removeBlockFromTree, reorderBlockInTree } from "./utils/tree-utils.mjs";
|
|
5
5
|
import { useFocusOptional } from "../../contexts/focus-context.mjs";
|
|
6
|
-
import { c } from "react/compiler-runtime";
|
|
7
6
|
import * as React from "react";
|
|
8
7
|
import { createStore } from "zustand";
|
|
9
8
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -14,263 +13,203 @@ import { jsx } from "react/jsx-runtime";
|
|
|
14
13
|
*
|
|
15
14
|
* Provides selector-driven state and actions for the block editor.
|
|
16
15
|
*/
|
|
17
|
-
function BlockEditorProvider(
|
|
18
|
-
const $ = c(22);
|
|
19
|
-
const { value, onChange, blocks, allowedBlocks, locale: t1, children } = t0;
|
|
20
|
-
const locale = t1 === void 0 ? "en" : t1;
|
|
16
|
+
function BlockEditorProvider({ value, onChange, blocks, allowedBlocks, locale = "en", children }) {
|
|
21
17
|
const onChangeRef = React.useRef(onChange);
|
|
22
18
|
const previewFocusState = useFocusOptional()?.state;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (process.env.NODE_ENV !== "production") console.warn(`Block type "${type}" not found`);
|
|
69
|
-
return;
|
|
19
|
+
React.useEffect(() => {
|
|
20
|
+
onChangeRef.current = onChange;
|
|
21
|
+
}, [onChange]);
|
|
22
|
+
const [store] = React.useState(() => createStore((set, get) => {
|
|
23
|
+
const actions = {
|
|
24
|
+
selectBlock: (id) => {
|
|
25
|
+
set((prev) => ({
|
|
26
|
+
selectedBlockId: id,
|
|
27
|
+
isLibraryOpen: id !== null ? false : prev.isLibraryOpen,
|
|
28
|
+
insertPosition: id !== null ? null : prev.insertPosition
|
|
29
|
+
}));
|
|
30
|
+
},
|
|
31
|
+
toggleExpanded: (id) => {
|
|
32
|
+
set((prev) => {
|
|
33
|
+
const next = new Set(prev.expandedBlockIds);
|
|
34
|
+
if (next.has(id)) next.delete(id);
|
|
35
|
+
else next.add(id);
|
|
36
|
+
return { expandedBlockIds: next };
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
expandAll: () => {
|
|
40
|
+
const allIds = getAllBlockIds(get().content._tree);
|
|
41
|
+
set({ expandedBlockIds: new Set(allIds) });
|
|
42
|
+
},
|
|
43
|
+
collapseAll: () => {
|
|
44
|
+
set({ expandedBlockIds: /* @__PURE__ */ new Set() });
|
|
45
|
+
},
|
|
46
|
+
addBlock: (type, position) => {
|
|
47
|
+
const state = get();
|
|
48
|
+
const blockDef = state.blocks[type];
|
|
49
|
+
if (!blockDef) {
|
|
50
|
+
if (process.env.NODE_ENV !== "production") console.warn(`Block type "${type}" not found`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const newBlock = {
|
|
54
|
+
id: crypto.randomUUID(),
|
|
55
|
+
type,
|
|
56
|
+
children: []
|
|
57
|
+
};
|
|
58
|
+
const newValues = getDefaultValues(blockDef.fields);
|
|
59
|
+
const nextContent = {
|
|
60
|
+
_tree: insertBlockInTree(state.content._tree, newBlock, position),
|
|
61
|
+
_values: {
|
|
62
|
+
...state.content._values,
|
|
63
|
+
[newBlock.id]: newValues
|
|
70
64
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
65
|
+
};
|
|
66
|
+
onChangeRef.current(nextContent);
|
|
67
|
+
set((prev) => ({
|
|
68
|
+
content: nextContent,
|
|
69
|
+
selectedBlockId: newBlock.id,
|
|
70
|
+
isLibraryOpen: false,
|
|
71
|
+
insertPosition: null,
|
|
72
|
+
expandedBlockIds: position.parentId ? new Set([...prev.expandedBlockIds, position.parentId]) : prev.expandedBlockIds
|
|
73
|
+
}));
|
|
74
|
+
},
|
|
75
|
+
removeBlock: (id) => {
|
|
76
|
+
const state = get();
|
|
77
|
+
const { newTree, removedIds } = removeBlockFromTree(state.content._tree, id);
|
|
78
|
+
const newValues = { ...state.content._values };
|
|
79
|
+
for (const removedId of removedIds) delete newValues[removedId];
|
|
80
|
+
const nextContent = {
|
|
81
|
+
_tree: newTree,
|
|
82
|
+
_values: newValues
|
|
83
|
+
};
|
|
84
|
+
onChangeRef.current(nextContent);
|
|
85
|
+
set((prev) => {
|
|
86
|
+
const nextExpanded = new Set(prev.expandedBlockIds);
|
|
87
|
+
for (const removedId of removedIds) nextExpanded.delete(removedId);
|
|
88
|
+
return {
|
|
86
89
|
content: nextContent,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
insertPosition: null,
|
|
90
|
-
expandedBlockIds: position.parentId ? new Set([...prev_1.expandedBlockIds, position.parentId]) : prev_1.expandedBlockIds
|
|
91
|
-
}));
|
|
92
|
-
},
|
|
93
|
-
removeBlock: (id_1) => {
|
|
94
|
-
const state_0 = get();
|
|
95
|
-
const { newTree, removedIds } = removeBlockFromTree(state_0.content._tree, id_1);
|
|
96
|
-
const newValues_0 = { ...state_0.content._values };
|
|
97
|
-
for (const removedId of removedIds) delete newValues_0[removedId];
|
|
98
|
-
const nextContent_0 = {
|
|
99
|
-
_tree: newTree,
|
|
100
|
-
_values: newValues_0
|
|
90
|
+
expandedBlockIds: nextExpanded,
|
|
91
|
+
selectedBlockId: prev.selectedBlockId === id || (prev.selectedBlockId ? removedIds.includes(prev.selectedBlockId) : false) ? null : prev.selectedBlockId
|
|
101
92
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
updateBlockValues: (id_3, newValues_2) => {
|
|
139
|
-
const state_3 = get();
|
|
140
|
-
const nextContent_3 = {
|
|
141
|
-
...state_3.content,
|
|
142
|
-
_values: {
|
|
143
|
-
...state_3.content._values,
|
|
144
|
-
[id_3]: {
|
|
145
|
-
...state_3.content._values[id_3],
|
|
146
|
-
...newValues_2
|
|
147
|
-
}
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
duplicateBlock: (id) => {
|
|
96
|
+
const state = get();
|
|
97
|
+
const { newTree, newIds, newValues } = duplicateBlockInTree(state.content._tree, state.content._values, id);
|
|
98
|
+
const nextContent = {
|
|
99
|
+
_tree: newTree,
|
|
100
|
+
_values: {
|
|
101
|
+
...state.content._values,
|
|
102
|
+
...newValues
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
onChangeRef.current(nextContent);
|
|
106
|
+
set({
|
|
107
|
+
content: nextContent,
|
|
108
|
+
selectedBlockId: newIds.length > 0 ? newIds[0] : state.selectedBlockId
|
|
109
|
+
});
|
|
110
|
+
},
|
|
111
|
+
moveBlock: (_id, parentId, fromIndex, toIndex) => {
|
|
112
|
+
const state = get();
|
|
113
|
+
const nextContent = {
|
|
114
|
+
...state.content,
|
|
115
|
+
_tree: reorderBlockInTree(state.content._tree, parentId, fromIndex, toIndex)
|
|
116
|
+
};
|
|
117
|
+
onChangeRef.current(nextContent);
|
|
118
|
+
set({ content: nextContent });
|
|
119
|
+
},
|
|
120
|
+
updateBlockValues: (id, newValues) => {
|
|
121
|
+
const state = get();
|
|
122
|
+
const nextContent = {
|
|
123
|
+
...state.content,
|
|
124
|
+
_values: {
|
|
125
|
+
...state.content._values,
|
|
126
|
+
[id]: {
|
|
127
|
+
...state.content._values[id],
|
|
128
|
+
...newValues
|
|
148
129
|
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
selectedBlockId: null
|
|
158
|
-
});
|
|
159
|
-
},
|
|
160
|
-
closeLibrary: () => {
|
|
161
|
-
set({
|
|
162
|
-
isLibraryOpen: false,
|
|
163
|
-
insertPosition: null
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
let initialAllowedBlocks;
|
|
168
|
-
if (allowedBlocks != null) initialAllowedBlocks = allowedBlocks;
|
|
169
|
-
else initialAllowedBlocks = null;
|
|
170
|
-
return {
|
|
171
|
-
content: value,
|
|
172
|
-
selectedBlockId: null,
|
|
173
|
-
expandedBlockIds: /* @__PURE__ */ new Set(),
|
|
174
|
-
isLibraryOpen: false,
|
|
175
|
-
insertPosition: null,
|
|
176
|
-
blocks,
|
|
177
|
-
allowedBlocks: initialAllowedBlocks,
|
|
178
|
-
locale,
|
|
179
|
-
actions
|
|
180
|
-
};
|
|
181
|
-
});
|
|
182
|
-
$[3] = allowedBlocks;
|
|
183
|
-
$[4] = blocks;
|
|
184
|
-
$[5] = locale;
|
|
185
|
-
$[6] = value;
|
|
186
|
-
$[7] = t4;
|
|
187
|
-
} else t4 = $[7];
|
|
188
|
-
const [store] = React.useState(t4);
|
|
189
|
-
let t5;
|
|
190
|
-
let t6;
|
|
191
|
-
if ($[8] !== previewFocusState || $[9] !== store) {
|
|
192
|
-
t5 = () => {
|
|
193
|
-
if (previewFocusState?.type !== "block" && previewFocusState?.type !== "block-insert") return;
|
|
194
|
-
const state_4 = store.getState();
|
|
195
|
-
const targetBlockId = previewFocusState.type === "block" ? previewFocusState.blockId : previewFocusState.referenceBlockId ?? previewFocusState.position.parentId;
|
|
196
|
-
let expandedBlockIds = state_4.expandedBlockIds;
|
|
197
|
-
if (targetBlockId) {
|
|
198
|
-
const blockPath = getBlockPathIds(state_4.content._tree, targetBlockId);
|
|
199
|
-
if (!blockPath) return;
|
|
200
|
-
expandedBlockIds = new Set(state_4.expandedBlockIds);
|
|
201
|
-
for (const blockId of blockPath) expandedBlockIds.add(blockId);
|
|
202
|
-
}
|
|
203
|
-
if (previewFocusState.type === "block-insert") {
|
|
204
|
-
store.setState({
|
|
205
|
-
selectedBlockId: targetBlockId,
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
onChangeRef.current(nextContent);
|
|
133
|
+
set({ content: nextContent });
|
|
134
|
+
},
|
|
135
|
+
openLibrary: (position) => {
|
|
136
|
+
set({
|
|
137
|
+
insertPosition: position,
|
|
206
138
|
isLibraryOpen: true,
|
|
207
|
-
|
|
208
|
-
|
|
139
|
+
selectedBlockId: null
|
|
140
|
+
});
|
|
141
|
+
},
|
|
142
|
+
closeLibrary: () => {
|
|
143
|
+
set({
|
|
144
|
+
isLibraryOpen: false,
|
|
145
|
+
insertPosition: null
|
|
209
146
|
});
|
|
210
|
-
return;
|
|
211
147
|
}
|
|
212
|
-
store.setState({
|
|
213
|
-
selectedBlockId: previewFocusState.blockId,
|
|
214
|
-
isLibraryOpen: false,
|
|
215
|
-
insertPosition: null,
|
|
216
|
-
expandedBlockIds
|
|
217
|
-
});
|
|
218
|
-
};
|
|
219
|
-
t6 = [previewFocusState, store];
|
|
220
|
-
$[8] = previewFocusState;
|
|
221
|
-
$[9] = store;
|
|
222
|
-
$[10] = t5;
|
|
223
|
-
$[11] = t6;
|
|
224
|
-
} else {
|
|
225
|
-
t5 = $[10];
|
|
226
|
-
t6 = $[11];
|
|
227
|
-
}
|
|
228
|
-
React.useEffect(t5, t6);
|
|
229
|
-
let t7;
|
|
230
|
-
let t8;
|
|
231
|
-
if ($[12] !== allowedBlocks || $[13] !== blocks || $[14] !== locale || $[15] !== store || $[16] !== value) {
|
|
232
|
-
t7 = () => {
|
|
233
|
-
const state_5 = store.getState();
|
|
234
|
-
let nextAllowedBlocks;
|
|
235
|
-
if (allowedBlocks != null) nextAllowedBlocks = allowedBlocks;
|
|
236
|
-
else nextAllowedBlocks = null;
|
|
237
|
-
const patch = {};
|
|
238
|
-
if (state_5.content !== value) patch.content = value;
|
|
239
|
-
if (state_5.blocks !== blocks) patch.blocks = blocks;
|
|
240
|
-
if (state_5.allowedBlocks !== nextAllowedBlocks) patch.allowedBlocks = nextAllowedBlocks;
|
|
241
|
-
if (state_5.locale !== locale) patch.locale = locale;
|
|
242
|
-
if (Object.keys(patch).length > 0) store.setState(patch);
|
|
243
148
|
};
|
|
244
|
-
|
|
245
|
-
|
|
149
|
+
let initialAllowedBlocks;
|
|
150
|
+
if (allowedBlocks != null) initialAllowedBlocks = allowedBlocks;
|
|
151
|
+
else initialAllowedBlocks = null;
|
|
152
|
+
return {
|
|
153
|
+
content: value,
|
|
154
|
+
selectedBlockId: null,
|
|
155
|
+
expandedBlockIds: /* @__PURE__ */ new Set(),
|
|
156
|
+
isLibraryOpen: false,
|
|
157
|
+
insertPosition: null,
|
|
246
158
|
blocks,
|
|
247
|
-
allowedBlocks,
|
|
159
|
+
allowedBlocks: initialAllowedBlocks,
|
|
248
160
|
locale,
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
161
|
+
actions
|
|
162
|
+
};
|
|
163
|
+
}));
|
|
164
|
+
React.useEffect(() => {
|
|
165
|
+
if (previewFocusState?.type !== "block" && previewFocusState?.type !== "block-insert") return;
|
|
166
|
+
const state = store.getState();
|
|
167
|
+
const targetBlockId = previewFocusState.type === "block" ? previewFocusState.blockId : previewFocusState.referenceBlockId ?? previewFocusState.position.parentId;
|
|
168
|
+
let expandedBlockIds = state.expandedBlockIds;
|
|
169
|
+
if (targetBlockId) {
|
|
170
|
+
const blockPath = getBlockPathIds(state.content._tree, targetBlockId);
|
|
171
|
+
if (!blockPath) return;
|
|
172
|
+
expandedBlockIds = new Set(state.expandedBlockIds);
|
|
173
|
+
for (const blockId of blockPath) expandedBlockIds.add(blockId);
|
|
174
|
+
}
|
|
175
|
+
if (previewFocusState.type === "block-insert") {
|
|
176
|
+
store.setState({
|
|
177
|
+
selectedBlockId: targetBlockId,
|
|
178
|
+
isLibraryOpen: true,
|
|
179
|
+
insertPosition: previewFocusState.position,
|
|
180
|
+
expandedBlockIds
|
|
181
|
+
});
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
store.setState({
|
|
185
|
+
selectedBlockId: previewFocusState.blockId,
|
|
186
|
+
isLibraryOpen: false,
|
|
187
|
+
insertPosition: null,
|
|
188
|
+
expandedBlockIds
|
|
268
189
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
190
|
+
}, [previewFocusState, store]);
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
const state = store.getState();
|
|
193
|
+
let nextAllowedBlocks;
|
|
194
|
+
if (allowedBlocks != null) nextAllowedBlocks = allowedBlocks;
|
|
195
|
+
else nextAllowedBlocks = null;
|
|
196
|
+
const patch = {};
|
|
197
|
+
if (state.content !== value) patch.content = value;
|
|
198
|
+
if (state.blocks !== blocks) patch.blocks = blocks;
|
|
199
|
+
if (state.allowedBlocks !== nextAllowedBlocks) patch.allowedBlocks = nextAllowedBlocks;
|
|
200
|
+
if (state.locale !== locale) patch.locale = locale;
|
|
201
|
+
if (Object.keys(patch).length > 0) store.setState(patch);
|
|
202
|
+
}, [
|
|
203
|
+
value,
|
|
204
|
+
blocks,
|
|
205
|
+
allowedBlocks,
|
|
206
|
+
locale,
|
|
207
|
+
store
|
|
208
|
+
]);
|
|
209
|
+
return /* @__PURE__ */ jsx(BlockEditorContextProvider, {
|
|
210
|
+
value: store,
|
|
211
|
+
children
|
|
212
|
+
});
|
|
274
213
|
}
|
|
275
214
|
|
|
276
215
|
//#endregion
|