@puckeditor/core 0.22.4 → 0.23.0-canary.026f0300
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/{Editor-ZZW3KF2T.css → Editor-T7TKW6NT.css} +7 -7
- package/dist/{Editor-MLHOIEVM.mjs → Editor-Z6P5UAVB.mjs} +8 -8
- package/dist/{actions-Csn3gOP8.d.mts → actions-3w-1VzY_.d.mts} +7 -1
- package/dist/{actions-Csn3gOP8.d.ts → actions-3w-1VzY_.d.ts} +7 -1
- package/dist/{chunk-25O24MZR.mjs → chunk-3OLRWMRO.mjs} +37 -22
- package/dist/{chunk-JNJJ2M57.mjs → chunk-3TERNOIP.mjs} +1 -1
- package/dist/{chunk-KJQTOPIV.mjs → chunk-DIYX54ZO.mjs} +136 -7
- package/dist/{chunk-4I2WN43X.mjs → chunk-L73ATZ55.mjs} +15 -8
- package/dist/{chunk-WUO7D6OQ.mjs → chunk-NPAYGEG5.mjs} +1 -0
- package/dist/{chunk-C2H4WQP2.mjs → chunk-OCFR2FFG.mjs} +27 -12
- package/dist/{chunk-NKDMBWQC.mjs → chunk-OSPG5CWL.mjs} +21 -10
- package/dist/{chunk-PRZEIT36.mjs → chunk-PJYHZPJK.mjs} +3 -3
- package/dist/{chunk-WH6PO5ND.mjs → chunk-S3CSGIQ3.mjs} +2047 -797
- package/dist/{chunk-25QAPMLH.mjs → chunk-UAWUZ45G.mjs} +41 -18
- package/dist/{full-YXSOFDYM.mjs → full-67VCA5MX.mjs} +7 -7
- package/dist/{full-S3QQ2IBQ.css → full-AAZK6KLI.css} +7 -7
- package/dist/index-KWLAZybR.d.ts +206 -0
- package/dist/index-l1l-a8tj.d.mts +206 -0
- package/dist/index.css +308 -111
- package/dist/index.d.mts +24 -11
- package/dist/index.d.ts +24 -11
- package/dist/index.js +2352 -809
- package/dist/index.mjs +10 -10
- package/dist/internal.d.mts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +40 -18
- package/dist/internal.mjs +1 -1
- package/dist/{loaded-LMF4JLYG.mjs → loaded-4XVG2RKQ.mjs} +4 -4
- package/dist/{loaded-FVWRAJR3.css → loaded-CA3Q7UHH.css} +7 -7
- package/dist/{loaded-IFFZACEG.mjs → loaded-LM723CWI.mjs} +4 -4
- package/dist/{loaded-SJJPEREQ.mjs → loaded-VBJBTUSI.mjs} +4 -4
- package/dist/no-external.css +308 -111
- package/dist/no-external.d.mts +4 -4
- package/dist/no-external.d.ts +4 -4
- package/dist/no-external.js +2352 -809
- package/dist/no-external.mjs +10 -10
- package/dist/rsc.d.mts +2 -2
- package/dist/rsc.d.ts +2 -2
- package/dist/rsc.js +1 -0
- package/dist/rsc.mjs +2 -2
- package/dist/{walk-tree-CWrsBHHe.d.ts → walk-tree-ConR82Y6.d.ts} +1 -1
- package/dist/{walk-tree-BrW9VQ_t.d.mts → walk-tree-DJMo6GTF.d.mts} +1 -1
- package/package.json +1 -1
- package/dist/index-B1b1cFug.d.ts +0 -117
- package/dist/index-ClzBCbx_.d.mts +0 -117
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
rootAreaId,
|
|
2
3
|
rootDroppableId,
|
|
3
4
|
setupZone,
|
|
4
5
|
walkAppState,
|
|
@@ -378,16 +379,13 @@ var reorderAction = (state, action, appStore) => {
|
|
|
378
379
|
init_react_import();
|
|
379
380
|
var removeAction = (state, action, appStore) => {
|
|
380
381
|
const item = getItem({ index: action.index, zone: action.zone }, state);
|
|
381
|
-
const nodesToDelete =
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
},
|
|
389
|
-
[item.props.id]
|
|
390
|
-
);
|
|
382
|
+
const nodesToDelete = /* @__PURE__ */ new Set([item.props.id]);
|
|
383
|
+
Object.entries(state.indexes.nodes).forEach(([nodeId, nodeData]) => {
|
|
384
|
+
const pathIds = nodeData.path.map((p) => p.split(":")[0]);
|
|
385
|
+
if (pathIds.includes(item.props.id)) {
|
|
386
|
+
nodesToDelete.add(nodeId);
|
|
387
|
+
}
|
|
388
|
+
});
|
|
391
389
|
const newState = walkAppState(
|
|
392
390
|
state,
|
|
393
391
|
appStore.config,
|
|
@@ -400,19 +398,22 @@ var removeAction = (state, action, appStore) => {
|
|
|
400
398
|
);
|
|
401
399
|
Object.keys(newState.data.zones || {}).forEach((zoneCompound) => {
|
|
402
400
|
const parentId = zoneCompound.split(":")[0];
|
|
403
|
-
if (nodesToDelete.
|
|
401
|
+
if (nodesToDelete.has(parentId) && newState.data.zones) {
|
|
404
402
|
delete newState.data.zones[zoneCompound];
|
|
405
403
|
}
|
|
406
404
|
});
|
|
407
405
|
Object.keys(newState.indexes.zones).forEach((zoneCompound) => {
|
|
408
406
|
const parentId = zoneCompound.split(":")[0];
|
|
409
|
-
if (nodesToDelete.
|
|
407
|
+
if (nodesToDelete.has(parentId)) {
|
|
410
408
|
delete newState.indexes.zones[zoneCompound];
|
|
411
409
|
}
|
|
412
410
|
});
|
|
411
|
+
const newItemExpanded = __spreadValues({}, newState.ui.itemExpanded);
|
|
413
412
|
nodesToDelete.forEach((id) => {
|
|
414
413
|
delete newState.indexes.nodes[id];
|
|
414
|
+
delete newItemExpanded[id];
|
|
415
415
|
});
|
|
416
|
+
newState.ui = __spreadProps(__spreadValues({}, newState.ui), { itemExpanded: newItemExpanded });
|
|
416
417
|
return newState;
|
|
417
418
|
};
|
|
418
419
|
|
|
@@ -481,14 +482,36 @@ var setDataAction = (state, action, appStore) => {
|
|
|
481
482
|
|
|
482
483
|
// reducer/actions/set-ui.ts
|
|
483
484
|
init_react_import();
|
|
484
|
-
var
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
485
|
+
var revealSelectedItem = (state, partialUi) => {
|
|
486
|
+
var _a, _b;
|
|
487
|
+
const itemSelector = partialUi.itemSelector;
|
|
488
|
+
if (!itemSelector) {
|
|
489
|
+
return partialUi;
|
|
490
|
+
}
|
|
491
|
+
const item = getItem(itemSelector, state);
|
|
492
|
+
if (!item) {
|
|
493
|
+
return partialUi;
|
|
494
|
+
}
|
|
495
|
+
const path = (_b = (_a = state.indexes.nodes[item.props.id]) == null ? void 0 : _a.path) != null ? _b : [];
|
|
496
|
+
const collapsedAncestorIds = path.map((zoneCompound) => zoneCompound.split(":")[0]).filter(
|
|
497
|
+
(ancestorId) => {
|
|
498
|
+
var _a2, _b2;
|
|
499
|
+
return ancestorId && ancestorId !== rootAreaId && !((_a2 = state.ui.itemExpanded) == null ? void 0 : _a2[ancestorId]) && !((_b2 = partialUi.itemExpanded) == null ? void 0 : _b2[ancestorId]);
|
|
500
|
+
}
|
|
501
|
+
);
|
|
502
|
+
if (collapsedAncestorIds.length === 0) {
|
|
503
|
+
return partialUi;
|
|
489
504
|
}
|
|
505
|
+
const itemExpanded = __spreadValues(__spreadValues({}, state.ui.itemExpanded), partialUi.itemExpanded);
|
|
506
|
+
collapsedAncestorIds.forEach((ancestorId) => {
|
|
507
|
+
itemExpanded[ancestorId] = true;
|
|
508
|
+
});
|
|
509
|
+
return __spreadProps(__spreadValues({}, partialUi), { itemExpanded });
|
|
510
|
+
};
|
|
511
|
+
var setUiAction = (state, action) => {
|
|
512
|
+
const partialUi = typeof action.ui === "object" ? action.ui : action.ui(state.ui);
|
|
490
513
|
return __spreadProps(__spreadValues({}, state), {
|
|
491
|
-
ui: __spreadValues(__spreadValues({}, state.ui),
|
|
514
|
+
ui: __spreadValues(__spreadValues({}, state.ui), revealSelectedItem(state, partialUi))
|
|
492
515
|
});
|
|
493
516
|
};
|
|
494
517
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LoadedRichTextMenuInner
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import "./chunk-
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
3
|
+
} from "./chunk-3OLRWMRO.mjs";
|
|
4
|
+
import "./chunk-OSPG5CWL.mjs";
|
|
5
|
+
import "./chunk-OCFR2FFG.mjs";
|
|
6
|
+
import "./chunk-L73ATZ55.mjs";
|
|
7
|
+
import "./chunk-DIYX54ZO.mjs";
|
|
8
|
+
import "./chunk-UAWUZ45G.mjs";
|
|
9
|
+
import "./chunk-NPAYGEG5.mjs";
|
|
10
10
|
import "./chunk-Y2EFNT5P.mjs";
|
|
11
11
|
import "./chunk-QHQD3BMI.mjs";
|
|
12
12
|
import {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/* css-module:/home/runner/work/puck/puck/packages/core/components/IconButton/IconButton.module.css/#css-module-data */
|
|
44
|
-
.
|
|
44
|
+
._IconButton_1pxxt_1 {
|
|
45
45
|
align-items: center;
|
|
46
46
|
background: var(--puck-iconbutton-color-bg, transparent);
|
|
47
47
|
border: none;
|
|
@@ -53,26 +53,26 @@
|
|
|
53
53
|
padding: var(--puck-iconbutton-space, var(--puck-space-1));
|
|
54
54
|
transition: background-color var(--puck-duration-fast) var(--puck-ease-exit), color var(--puck-duration-fast) var(--puck-ease-exit);
|
|
55
55
|
}
|
|
56
|
-
._IconButton--
|
|
56
|
+
._IconButton--active_1pxxt_15 {
|
|
57
57
|
color: var( --puck-iconbutton-color-icon-active, var(--puck-color-interactive) );
|
|
58
58
|
}
|
|
59
|
-
.
|
|
59
|
+
._IconButton_1pxxt_1:focus-visible {
|
|
60
60
|
outline: var(--puck-border-width-focus) solid var(--puck-color-focus-ring);
|
|
61
61
|
outline-offset: calc(var(--puck-border-width-focus) * -1);
|
|
62
62
|
}
|
|
63
63
|
@media (hover: hover) and (pointer: fine) {
|
|
64
|
-
.
|
|
65
|
-
background: var( --puck-iconbutton-color-bg-hover, var(--puck-color-interactive-neutral-hover) );
|
|
64
|
+
._IconButton_1pxxt_1:hover:not(._IconButton--disabled_1pxxt_28) {
|
|
65
|
+
background: var( --_puck-iconbutton-color-bg-hover, var( --puck-iconbutton-color-bg-hover, var(--puck-color-interactive-neutral-hover) ) );
|
|
66
66
|
color: var( --puck-iconbutton-color-icon-hover, var(--puck-color-interactive) );
|
|
67
67
|
cursor: pointer;
|
|
68
68
|
transition: none;
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
|
-
.
|
|
71
|
+
._IconButton_1pxxt_1:active {
|
|
72
72
|
background: var( --puck-iconbutton-color-bg-active, var(--puck-color-interactive-soft) );
|
|
73
73
|
transition: none;
|
|
74
74
|
}
|
|
75
|
-
._IconButton--
|
|
75
|
+
._IconButton--disabled_1pxxt_28 {
|
|
76
76
|
color: var( --puck-iconbutton-color-icon-disabled, var(--puck-color-text-subtle) );
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Q as History, a0 as Permissions, i as ComponentData, m as Config, an as UserGenerics, P as Fields, a4 as PuckAction, ae as RootDataWithProps, a9 as ResolveDataTrigger, a1 as Plugin, $ as Overrides, ap as Viewports, R as IframeConfig, am as UiState, f as ComponentConfig, a as AppState, W as Metadata, x as DndConfig, O as FieldTransforms, ab as RichtextField } from './actions-3w-1VzY_.js';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
type HistorySlice<D = any> = {
|
|
5
|
+
index: number;
|
|
6
|
+
hasPast: () => boolean;
|
|
7
|
+
hasFuture: () => boolean;
|
|
8
|
+
histories: History<D>[];
|
|
9
|
+
record: (data: D) => void;
|
|
10
|
+
back: VoidFunction;
|
|
11
|
+
forward: VoidFunction;
|
|
12
|
+
currentHistory: () => History;
|
|
13
|
+
nextHistory: () => History<D> | null;
|
|
14
|
+
prevHistory: () => History<D> | null;
|
|
15
|
+
setHistories: (histories: History[]) => void;
|
|
16
|
+
setHistoryIndex: (index: number) => void;
|
|
17
|
+
initialAppState: D;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type NodeHandle = {
|
|
21
|
+
sync: () => void;
|
|
22
|
+
hideOverlay: () => void;
|
|
23
|
+
showOverlay: () => void;
|
|
24
|
+
};
|
|
25
|
+
type NodesSlice = {
|
|
26
|
+
registerNode: (id: string, handle: NodeHandle) => void;
|
|
27
|
+
unregisterNode: (id: string) => void;
|
|
28
|
+
syncNode: (id?: string | null) => void;
|
|
29
|
+
syncNodes: (ids: Array<string | null | undefined>) => void;
|
|
30
|
+
setOverlayVisible: (id: string | null | undefined, visible: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
34
|
+
item?: G["UserComponentData"] | null;
|
|
35
|
+
type?: keyof G["UserProps"];
|
|
36
|
+
root?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
|
39
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
|
40
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
|
41
|
+
type Cache = Record<string, {
|
|
42
|
+
lastPermissions: Partial<Permissions>;
|
|
43
|
+
lastData: ComponentData | null;
|
|
44
|
+
lastParentId: string | null;
|
|
45
|
+
}>;
|
|
46
|
+
type PermissionsSlice = {
|
|
47
|
+
cache: Cache;
|
|
48
|
+
globalPermissions: Permissions;
|
|
49
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
|
50
|
+
getPermissions: GetPermissions<Config>;
|
|
51
|
+
resolvePermissions: ResolvePermissions<Config>;
|
|
52
|
+
refreshPermissions: RefreshPermissions<Config>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
|
56
|
+
type FieldsSlice = {
|
|
57
|
+
fields: Fields | Partial<Fields>;
|
|
58
|
+
loading: boolean;
|
|
59
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
|
60
|
+
id: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Default messages for every hard-coded string shown in the Puck editor UI.
|
|
65
|
+
*
|
|
66
|
+
* Tokens follow a `{area}-{name}-{variant}` structure, where hyphens only
|
|
67
|
+
* separate segments (compound words within a segment are concatenated, e.g.
|
|
68
|
+
* `field-arrayitem-summary`).
|
|
69
|
+
*/
|
|
70
|
+
declare const defaultDictionary: {
|
|
71
|
+
readonly "header-publish": "Publish";
|
|
72
|
+
readonly "header-undo": "undo";
|
|
73
|
+
readonly "header-redo": "redo";
|
|
74
|
+
readonly "header-toggle-leftsidebar": "Toggle left sidebar";
|
|
75
|
+
readonly "header-toggle-rightsidebar": "Toggle right sidebar";
|
|
76
|
+
readonly "header-toggle-menubar": "Toggle menu bar";
|
|
77
|
+
readonly "action-selectparent": "Select parent";
|
|
78
|
+
readonly "action-duplicate": "Duplicate";
|
|
79
|
+
readonly "action-delete": "Delete";
|
|
80
|
+
readonly "label-page": "Page";
|
|
81
|
+
readonly "label-component": "Component";
|
|
82
|
+
readonly "outline-empty": "No items";
|
|
83
|
+
readonly "outline-item-collapse": "Collapse";
|
|
84
|
+
readonly "outline-item-expand": "Expand";
|
|
85
|
+
readonly "outline-header-title": "Outline";
|
|
86
|
+
readonly "outline-header-collapseall": "Collapse all";
|
|
87
|
+
readonly "outline-item-duplicate": "Duplicate";
|
|
88
|
+
readonly "outline-item-delete": "Delete";
|
|
89
|
+
readonly "drawer-category-collapse": "Collapse {title}";
|
|
90
|
+
readonly "drawer-category-expand": "Expand {title}";
|
|
91
|
+
readonly "drawer-category-other": "Other";
|
|
92
|
+
readonly "canvas-noconfig": "No configuration for {type}";
|
|
93
|
+
readonly "field-readonly": "Read-only";
|
|
94
|
+
readonly "field-arrayitem-summary": "Item #{index}";
|
|
95
|
+
readonly "field-arrayitem-duplicate": "Duplicate";
|
|
96
|
+
readonly "field-arrayitem-delete": "Delete";
|
|
97
|
+
readonly "field-external-selectdata": "Select data";
|
|
98
|
+
readonly "field-external-search": "Search";
|
|
99
|
+
readonly "field-external-togglefilters": "Toggle filters";
|
|
100
|
+
readonly "field-external-item": "External item";
|
|
101
|
+
readonly "field-external-result-singular": "{count} result";
|
|
102
|
+
readonly "field-external-result-plural": "{count} results";
|
|
103
|
+
readonly "field-richtext-bold": "Bold";
|
|
104
|
+
readonly "field-richtext-italic": "Italic";
|
|
105
|
+
readonly "field-richtext-underline": "Underline";
|
|
106
|
+
readonly "field-richtext-strikethrough": "Strikethrough";
|
|
107
|
+
readonly "field-richtext-blockquote": "Blockquote";
|
|
108
|
+
readonly "field-richtext-code-inline": "Inline code";
|
|
109
|
+
readonly "field-richtext-code-block": "Code block";
|
|
110
|
+
readonly "field-richtext-list-bullet": "Bullet list";
|
|
111
|
+
readonly "field-richtext-list-ordered": "Ordered list";
|
|
112
|
+
readonly "field-richtext-horizontalrule": "Horizontal rule";
|
|
113
|
+
readonly "field-richtext-align-left": "Align left";
|
|
114
|
+
readonly "field-richtext-align-center": "Align center";
|
|
115
|
+
readonly "field-richtext-align-right": "Align right";
|
|
116
|
+
readonly "field-richtext-align-justify": "Justify";
|
|
117
|
+
readonly "field-richtext-select": "Select";
|
|
118
|
+
readonly "field-richtext-headingselect-1": "Heading 1";
|
|
119
|
+
readonly "field-richtext-headingselect-2": "Heading 2";
|
|
120
|
+
readonly "field-richtext-headingselect-3": "Heading 3";
|
|
121
|
+
readonly "field-richtext-headingselect-4": "Heading 4";
|
|
122
|
+
readonly "field-richtext-headingselect-5": "Heading 5";
|
|
123
|
+
readonly "field-richtext-headingselect-6": "Heading 6";
|
|
124
|
+
readonly "field-richtext-alignselect-left": "Left";
|
|
125
|
+
readonly "field-richtext-alignselect-center": "Center";
|
|
126
|
+
readonly "field-richtext-alignselect-right": "Right";
|
|
127
|
+
readonly "field-richtext-alignselect-justify": "Justify";
|
|
128
|
+
readonly "field-richtext-listselect-bullet": "Bullet list";
|
|
129
|
+
readonly "field-richtext-listselect-ordered": "Ordered list";
|
|
130
|
+
readonly "viewport-zoom-in": "Zoom viewport in";
|
|
131
|
+
readonly "viewport-zoom-out": "Zoom viewport out";
|
|
132
|
+
readonly "viewport-zoom-auto": "{zoom}% (Auto)";
|
|
133
|
+
readonly "viewport-toggle-menu": "Toggle viewport menu";
|
|
134
|
+
readonly "viewport-switch": "Switch to {label} viewport";
|
|
135
|
+
readonly "viewport-switch-default": "Switch viewport";
|
|
136
|
+
readonly "plugin-blocks": "Blocks";
|
|
137
|
+
readonly "plugin-outline": "Outline";
|
|
138
|
+
readonly "plugin-fields": "Fields";
|
|
139
|
+
readonly "plugin-components": "Components";
|
|
140
|
+
readonly "layout-maximize": "maximize";
|
|
141
|
+
readonly "layout-minimize": "minimize";
|
|
142
|
+
readonly "loader-loading": "loading";
|
|
143
|
+
};
|
|
144
|
+
type DictionaryKey = keyof typeof defaultDictionary;
|
|
145
|
+
/**
|
|
146
|
+
* Override any of Puck's built-in UI strings, or provide your own custom strings.
|
|
147
|
+
*/
|
|
148
|
+
type Dictionary = Partial<Record<DictionaryKey, string> & Record<string, string>>;
|
|
149
|
+
|
|
150
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
|
151
|
+
type ZoomConfig = {
|
|
152
|
+
autoZoom: number;
|
|
153
|
+
rootHeight: number;
|
|
154
|
+
zoom: number;
|
|
155
|
+
};
|
|
156
|
+
type ComponentState = Record<string, {
|
|
157
|
+
loadingCount: number;
|
|
158
|
+
}>;
|
|
159
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
160
|
+
instanceId: string;
|
|
161
|
+
state: G["UserAppState"];
|
|
162
|
+
dispatch: (action: PuckAction) => void;
|
|
163
|
+
config: UserConfig;
|
|
164
|
+
componentState: ComponentState;
|
|
165
|
+
setComponentState: (componentState: ComponentState) => void;
|
|
166
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
|
|
167
|
+
unsetComponentLoading: (id: string) => void;
|
|
168
|
+
pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
|
|
169
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
|
170
|
+
node: T;
|
|
171
|
+
didChange: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
resolveAndCommitData: () => void;
|
|
174
|
+
plugins: Plugin[];
|
|
175
|
+
overrides: Partial<Overrides>;
|
|
176
|
+
viewports: Viewports;
|
|
177
|
+
zoomConfig: ZoomConfig;
|
|
178
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
|
179
|
+
status: Status;
|
|
180
|
+
setStatus: (status: Status) => void;
|
|
181
|
+
iframe: IframeConfig;
|
|
182
|
+
_experimentalFullScreenCanvas: boolean;
|
|
183
|
+
_experimentalVirtualization: boolean;
|
|
184
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
|
185
|
+
getCurrentData: () => G["UserData"]["content"][0] | G["UserData"]["root"];
|
|
186
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
|
187
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
|
188
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
|
189
|
+
metadata: Metadata;
|
|
190
|
+
dictionary: Dictionary;
|
|
191
|
+
dnd?: DndConfig;
|
|
192
|
+
fields: FieldsSlice;
|
|
193
|
+
history: HistorySlice;
|
|
194
|
+
nodes: NodesSlice;
|
|
195
|
+
permissions: PermissionsSlice;
|
|
196
|
+
fieldTransforms: FieldTransforms;
|
|
197
|
+
currentRichText?: {
|
|
198
|
+
inlineComponentId?: string;
|
|
199
|
+
inline: boolean;
|
|
200
|
+
field: RichtextField;
|
|
201
|
+
editor: Editor;
|
|
202
|
+
id: string;
|
|
203
|
+
} | null;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export type { AppStore as A, Dictionary as D, GetPermissions as G, HistorySlice as H, RefreshPermissions as R };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { Q as History, a0 as Permissions, i as ComponentData, m as Config, an as UserGenerics, P as Fields, a4 as PuckAction, ae as RootDataWithProps, a9 as ResolveDataTrigger, a1 as Plugin, $ as Overrides, ap as Viewports, R as IframeConfig, am as UiState, f as ComponentConfig, a as AppState, W as Metadata, x as DndConfig, O as FieldTransforms, ab as RichtextField } from './actions-3w-1VzY_.mjs';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
|
|
4
|
+
type HistorySlice<D = any> = {
|
|
5
|
+
index: number;
|
|
6
|
+
hasPast: () => boolean;
|
|
7
|
+
hasFuture: () => boolean;
|
|
8
|
+
histories: History<D>[];
|
|
9
|
+
record: (data: D) => void;
|
|
10
|
+
back: VoidFunction;
|
|
11
|
+
forward: VoidFunction;
|
|
12
|
+
currentHistory: () => History;
|
|
13
|
+
nextHistory: () => History<D> | null;
|
|
14
|
+
prevHistory: () => History<D> | null;
|
|
15
|
+
setHistories: (histories: History[]) => void;
|
|
16
|
+
setHistoryIndex: (index: number) => void;
|
|
17
|
+
initialAppState: D;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type NodeHandle = {
|
|
21
|
+
sync: () => void;
|
|
22
|
+
hideOverlay: () => void;
|
|
23
|
+
showOverlay: () => void;
|
|
24
|
+
};
|
|
25
|
+
type NodesSlice = {
|
|
26
|
+
registerNode: (id: string, handle: NodeHandle) => void;
|
|
27
|
+
unregisterNode: (id: string) => void;
|
|
28
|
+
syncNode: (id?: string | null) => void;
|
|
29
|
+
syncNodes: (ids: Array<string | null | undefined>) => void;
|
|
30
|
+
setOverlayVisible: (id: string | null | undefined, visible: boolean) => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
type PermissionsArgs<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
34
|
+
item?: G["UserComponentData"] | null;
|
|
35
|
+
type?: keyof G["UserProps"];
|
|
36
|
+
root?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type GetPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>) => Permissions;
|
|
39
|
+
type ResolvePermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
|
40
|
+
type RefreshPermissions<UserConfig extends Config = Config> = (params?: PermissionsArgs<UserConfig>, force?: boolean) => void;
|
|
41
|
+
type Cache = Record<string, {
|
|
42
|
+
lastPermissions: Partial<Permissions>;
|
|
43
|
+
lastData: ComponentData | null;
|
|
44
|
+
lastParentId: string | null;
|
|
45
|
+
}>;
|
|
46
|
+
type PermissionsSlice = {
|
|
47
|
+
cache: Cache;
|
|
48
|
+
globalPermissions: Permissions;
|
|
49
|
+
resolvedPermissions: Record<string, Partial<Permissions> | undefined>;
|
|
50
|
+
getPermissions: GetPermissions<Config>;
|
|
51
|
+
resolvePermissions: ResolvePermissions<Config>;
|
|
52
|
+
refreshPermissions: RefreshPermissions<Config>;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
type ComponentOrRootData = Omit<ComponentData<any>, "type">;
|
|
56
|
+
type FieldsSlice = {
|
|
57
|
+
fields: Fields | Partial<Fields>;
|
|
58
|
+
loading: boolean;
|
|
59
|
+
lastResolvedData: Partial<ComponentOrRootData>;
|
|
60
|
+
id: string | undefined;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Default messages for every hard-coded string shown in the Puck editor UI.
|
|
65
|
+
*
|
|
66
|
+
* Tokens follow a `{area}-{name}-{variant}` structure, where hyphens only
|
|
67
|
+
* separate segments (compound words within a segment are concatenated, e.g.
|
|
68
|
+
* `field-arrayitem-summary`).
|
|
69
|
+
*/
|
|
70
|
+
declare const defaultDictionary: {
|
|
71
|
+
readonly "header-publish": "Publish";
|
|
72
|
+
readonly "header-undo": "undo";
|
|
73
|
+
readonly "header-redo": "redo";
|
|
74
|
+
readonly "header-toggle-leftsidebar": "Toggle left sidebar";
|
|
75
|
+
readonly "header-toggle-rightsidebar": "Toggle right sidebar";
|
|
76
|
+
readonly "header-toggle-menubar": "Toggle menu bar";
|
|
77
|
+
readonly "action-selectparent": "Select parent";
|
|
78
|
+
readonly "action-duplicate": "Duplicate";
|
|
79
|
+
readonly "action-delete": "Delete";
|
|
80
|
+
readonly "label-page": "Page";
|
|
81
|
+
readonly "label-component": "Component";
|
|
82
|
+
readonly "outline-empty": "No items";
|
|
83
|
+
readonly "outline-item-collapse": "Collapse";
|
|
84
|
+
readonly "outline-item-expand": "Expand";
|
|
85
|
+
readonly "outline-header-title": "Outline";
|
|
86
|
+
readonly "outline-header-collapseall": "Collapse all";
|
|
87
|
+
readonly "outline-item-duplicate": "Duplicate";
|
|
88
|
+
readonly "outline-item-delete": "Delete";
|
|
89
|
+
readonly "drawer-category-collapse": "Collapse {title}";
|
|
90
|
+
readonly "drawer-category-expand": "Expand {title}";
|
|
91
|
+
readonly "drawer-category-other": "Other";
|
|
92
|
+
readonly "canvas-noconfig": "No configuration for {type}";
|
|
93
|
+
readonly "field-readonly": "Read-only";
|
|
94
|
+
readonly "field-arrayitem-summary": "Item #{index}";
|
|
95
|
+
readonly "field-arrayitem-duplicate": "Duplicate";
|
|
96
|
+
readonly "field-arrayitem-delete": "Delete";
|
|
97
|
+
readonly "field-external-selectdata": "Select data";
|
|
98
|
+
readonly "field-external-search": "Search";
|
|
99
|
+
readonly "field-external-togglefilters": "Toggle filters";
|
|
100
|
+
readonly "field-external-item": "External item";
|
|
101
|
+
readonly "field-external-result-singular": "{count} result";
|
|
102
|
+
readonly "field-external-result-plural": "{count} results";
|
|
103
|
+
readonly "field-richtext-bold": "Bold";
|
|
104
|
+
readonly "field-richtext-italic": "Italic";
|
|
105
|
+
readonly "field-richtext-underline": "Underline";
|
|
106
|
+
readonly "field-richtext-strikethrough": "Strikethrough";
|
|
107
|
+
readonly "field-richtext-blockquote": "Blockquote";
|
|
108
|
+
readonly "field-richtext-code-inline": "Inline code";
|
|
109
|
+
readonly "field-richtext-code-block": "Code block";
|
|
110
|
+
readonly "field-richtext-list-bullet": "Bullet list";
|
|
111
|
+
readonly "field-richtext-list-ordered": "Ordered list";
|
|
112
|
+
readonly "field-richtext-horizontalrule": "Horizontal rule";
|
|
113
|
+
readonly "field-richtext-align-left": "Align left";
|
|
114
|
+
readonly "field-richtext-align-center": "Align center";
|
|
115
|
+
readonly "field-richtext-align-right": "Align right";
|
|
116
|
+
readonly "field-richtext-align-justify": "Justify";
|
|
117
|
+
readonly "field-richtext-select": "Select";
|
|
118
|
+
readonly "field-richtext-headingselect-1": "Heading 1";
|
|
119
|
+
readonly "field-richtext-headingselect-2": "Heading 2";
|
|
120
|
+
readonly "field-richtext-headingselect-3": "Heading 3";
|
|
121
|
+
readonly "field-richtext-headingselect-4": "Heading 4";
|
|
122
|
+
readonly "field-richtext-headingselect-5": "Heading 5";
|
|
123
|
+
readonly "field-richtext-headingselect-6": "Heading 6";
|
|
124
|
+
readonly "field-richtext-alignselect-left": "Left";
|
|
125
|
+
readonly "field-richtext-alignselect-center": "Center";
|
|
126
|
+
readonly "field-richtext-alignselect-right": "Right";
|
|
127
|
+
readonly "field-richtext-alignselect-justify": "Justify";
|
|
128
|
+
readonly "field-richtext-listselect-bullet": "Bullet list";
|
|
129
|
+
readonly "field-richtext-listselect-ordered": "Ordered list";
|
|
130
|
+
readonly "viewport-zoom-in": "Zoom viewport in";
|
|
131
|
+
readonly "viewport-zoom-out": "Zoom viewport out";
|
|
132
|
+
readonly "viewport-zoom-auto": "{zoom}% (Auto)";
|
|
133
|
+
readonly "viewport-toggle-menu": "Toggle viewport menu";
|
|
134
|
+
readonly "viewport-switch": "Switch to {label} viewport";
|
|
135
|
+
readonly "viewport-switch-default": "Switch viewport";
|
|
136
|
+
readonly "plugin-blocks": "Blocks";
|
|
137
|
+
readonly "plugin-outline": "Outline";
|
|
138
|
+
readonly "plugin-fields": "Fields";
|
|
139
|
+
readonly "plugin-components": "Components";
|
|
140
|
+
readonly "layout-maximize": "maximize";
|
|
141
|
+
readonly "layout-minimize": "minimize";
|
|
142
|
+
readonly "loader-loading": "loading";
|
|
143
|
+
};
|
|
144
|
+
type DictionaryKey = keyof typeof defaultDictionary;
|
|
145
|
+
/**
|
|
146
|
+
* Override any of Puck's built-in UI strings, or provide your own custom strings.
|
|
147
|
+
*/
|
|
148
|
+
type Dictionary = Partial<Record<DictionaryKey, string> & Record<string, string>>;
|
|
149
|
+
|
|
150
|
+
type Status = "LOADING" | "MOUNTED" | "READY";
|
|
151
|
+
type ZoomConfig = {
|
|
152
|
+
autoZoom: number;
|
|
153
|
+
rootHeight: number;
|
|
154
|
+
zoom: number;
|
|
155
|
+
};
|
|
156
|
+
type ComponentState = Record<string, {
|
|
157
|
+
loadingCount: number;
|
|
158
|
+
}>;
|
|
159
|
+
type AppStore<UserConfig extends Config = Config, G extends UserGenerics<UserConfig> = UserGenerics<UserConfig>> = {
|
|
160
|
+
instanceId: string;
|
|
161
|
+
state: G["UserAppState"];
|
|
162
|
+
dispatch: (action: PuckAction) => void;
|
|
163
|
+
config: UserConfig;
|
|
164
|
+
componentState: ComponentState;
|
|
165
|
+
setComponentState: (componentState: ComponentState) => void;
|
|
166
|
+
setComponentLoading: (id: string, loading?: boolean, defer?: number) => () => void;
|
|
167
|
+
unsetComponentLoading: (id: string) => void;
|
|
168
|
+
pendingLoadTimeouts: Record<string, NodeJS.Timeout>;
|
|
169
|
+
resolveComponentData: <T extends ComponentData | RootDataWithProps>(componentData: T, trigger: ResolveDataTrigger) => Promise<{
|
|
170
|
+
node: T;
|
|
171
|
+
didChange: boolean;
|
|
172
|
+
}>;
|
|
173
|
+
resolveAndCommitData: () => void;
|
|
174
|
+
plugins: Plugin[];
|
|
175
|
+
overrides: Partial<Overrides>;
|
|
176
|
+
viewports: Viewports;
|
|
177
|
+
zoomConfig: ZoomConfig;
|
|
178
|
+
setZoomConfig: (zoomConfig: ZoomConfig) => void;
|
|
179
|
+
status: Status;
|
|
180
|
+
setStatus: (status: Status) => void;
|
|
181
|
+
iframe: IframeConfig;
|
|
182
|
+
_experimentalFullScreenCanvas: boolean;
|
|
183
|
+
_experimentalVirtualization: boolean;
|
|
184
|
+
selectedItem?: G["UserData"]["content"][0] | null;
|
|
185
|
+
getCurrentData: () => G["UserData"]["content"][0] | G["UserData"]["root"];
|
|
186
|
+
setUi: (ui: Partial<UiState>, recordHistory?: boolean) => void;
|
|
187
|
+
getComponentConfig: (type?: string) => ComponentConfig | null | undefined;
|
|
188
|
+
onAction?: (action: PuckAction, newState: AppState, state: AppState) => void;
|
|
189
|
+
metadata: Metadata;
|
|
190
|
+
dictionary: Dictionary;
|
|
191
|
+
dnd?: DndConfig;
|
|
192
|
+
fields: FieldsSlice;
|
|
193
|
+
history: HistorySlice;
|
|
194
|
+
nodes: NodesSlice;
|
|
195
|
+
permissions: PermissionsSlice;
|
|
196
|
+
fieldTransforms: FieldTransforms;
|
|
197
|
+
currentRichText?: {
|
|
198
|
+
inlineComponentId?: string;
|
|
199
|
+
inline: boolean;
|
|
200
|
+
field: RichtextField;
|
|
201
|
+
editor: Editor;
|
|
202
|
+
id: string;
|
|
203
|
+
} | null;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
export type { AppStore as A, Dictionary as D, GetPermissions as G, HistorySlice as H, RefreshPermissions as R };
|