@makeswift/runtime 0.8.11 → 0.9.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/dist/Box.cjs.js +1 -1
- package/dist/Box.es.js +1 -1
- package/dist/Button.cjs.js +1 -1
- package/dist/Button.es.js +1 -1
- package/dist/Carousel.cjs.js +2 -2
- package/dist/Carousel.es.js +2 -2
- package/dist/Countdown.cjs.js +1 -1
- package/dist/Countdown.es.js +1 -1
- package/dist/Divider.cjs.js +1 -1
- package/dist/Divider.es.js +1 -1
- package/dist/Embed.cjs.js +1 -1
- package/dist/Embed.es.js +1 -1
- package/dist/Form.cjs.js +1 -1
- package/dist/Form.es.js +1 -1
- package/dist/Image.cjs.js +1 -1
- package/dist/Image.es.js +1 -1
- package/dist/LiveProvider.cjs.js +2 -2
- package/dist/LiveProvider.es.js +3 -3
- package/dist/Navigation.cjs.js +2 -2
- package/dist/Navigation.es.js +2 -2
- package/dist/PreviewProvider.cjs.js +17 -2
- package/dist/PreviewProvider.cjs.js.map +1 -1
- package/dist/PreviewProvider.es.js +19 -4
- package/dist/PreviewProvider.es.js.map +1 -1
- package/dist/ReadOnlyText.cjs.js +10 -9
- package/dist/ReadOnlyText.cjs.js.map +1 -1
- package/dist/ReadOnlyText.es.js +10 -9
- package/dist/ReadOnlyText.es.js.map +1 -1
- package/dist/ReadOnlyTextV2.cjs.js +10 -9
- package/dist/ReadOnlyTextV2.cjs.js.map +1 -1
- package/dist/ReadOnlyTextV2.es.js +10 -9
- package/dist/ReadOnlyTextV2.es.js.map +1 -1
- package/dist/Root.cjs.js +1 -1
- package/dist/Root.es.js +1 -1
- package/dist/SocialLinks.cjs.js +1 -1
- package/dist/SocialLinks.es.js +1 -1
- package/dist/Text.cjs.js +1 -1
- package/dist/Text.es.js +1 -1
- package/dist/Video.cjs.js +1 -1
- package/dist/Video.es.js +1 -1
- package/dist/actions.cjs.js +16 -1
- package/dist/actions.cjs.js.map +1 -1
- package/dist/actions.es.js +14 -2
- package/dist/actions.es.js.map +1 -1
- package/dist/components.cjs.js +1 -1
- package/dist/components.es.js +1 -1
- package/dist/control-serialization.cjs.js +1 -1
- package/dist/control-serialization.es.js +2 -2
- package/dist/controls.cjs.js +2 -3
- package/dist/controls.cjs.js.map +1 -1
- package/dist/controls.es.js +1 -2
- package/dist/controls.es.js.map +1 -1
- package/dist/index.cjs.js +253 -218
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs10.js +11 -10
- package/dist/index.cjs10.js.map +1 -1
- package/dist/index.cjs2.js +1 -1
- package/dist/index.cjs5.js +0 -522
- package/dist/index.cjs5.js.map +1 -1
- package/dist/index.cjs6.js +1 -2
- package/dist/index.cjs6.js.map +1 -1
- package/dist/index.cjs7.js +0 -52
- package/dist/index.cjs7.js.map +1 -1
- package/dist/index.cjs8.js +1 -1
- package/dist/index.cjs9.js +42 -3
- package/dist/index.cjs9.js.map +1 -1
- package/dist/index.es.js +253 -218
- package/dist/index.es.js.map +1 -1
- package/dist/index.es10.js +12 -11
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es2.js +2 -2
- package/dist/index.es5.js +2 -514
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es6.js +1 -2
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es7.js +2 -53
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es8.js +1 -1
- package/dist/index.es9.js +43 -4
- package/dist/index.es9.js.map +1 -1
- package/dist/leaf.es.js +1 -1
- package/dist/main.cjs.js +3 -0
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.es.js +2 -2
- package/dist/next.cjs.js +1 -1
- package/dist/next.es.js +1 -1
- package/dist/react-page.cjs.js +711 -61
- package/dist/react-page.cjs.js.map +1 -1
- package/dist/react-page.es.js +694 -56
- package/dist/react-page.es.js.map +1 -1
- package/dist/react.cjs.js +1 -1
- package/dist/react.es.js +1 -1
- package/dist/slate.cjs.js +11 -13
- package/dist/slate.cjs.js.map +1 -1
- package/dist/slate.es.js +4 -5
- package/dist/slate.es.js.map +1 -1
- package/dist/types/src/api/graphql/documents/queries.d.ts.map +1 -1
- package/dist/types/src/api/graphql/generated/types.d.ts +0 -8
- package/dist/types/src/api/graphql/generated/types.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Button/Button.d.ts +1 -1
- package/dist/types/src/components/builtin/Carousel/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Countdown/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Divider/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Embed/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Form/components/Field/components/Checkbox/index.d.ts +1 -1
- package/dist/types/src/components/builtin/Form/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Navigation/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/SocialLinks/register.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/EditableText/editable-text.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/ReadOnlyText.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Text/components/Element/block.d.ts.map +1 -1
- package/dist/types/src/components/builtin/Video/register.d.ts.map +1 -1
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts +3 -3
- package/dist/types/src/controls/rich-text-v2/rich-text-v2.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +2 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts +3 -1
- package/dist/types/src/next/api-handler/handlers/manifest.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/handlers/proxy-preview-mode.d.ts.map +1 -1
- package/dist/types/src/next/api-handler/index.d.ts +2 -1
- package/dist/types/src/next/api-handler/index.d.ts.map +1 -1
- package/dist/types/src/next/client.d.ts +7 -7
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/dist/types/src/next/index.d.ts +8 -5
- package/dist/types/src/next/index.d.ts.map +1 -1
- package/dist/types/src/next/preview-mode.d.ts +17 -3
- package/dist/types/src/next/preview-mode.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/EditableTextV2/editable-text-v2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/controls/rich-text-v2/ReadOnlyTextV2.d.ts.map +1 -1
- package/dist/types/src/runtimes/react/index.d.ts +3 -1
- package/dist/types/src/runtimes/react/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/constants.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/dedent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/indent.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/index.d.ts +26 -3
- package/dist/types/src/slate/BlockPlugin/index.d.ts.map +1 -1
- package/dist/types/src/slate/BlockPlugin/toggleList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/unwrapList.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/filterForSubtreeRoots.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/getSelectedListItems.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/utils/location.d.ts.map +1 -0
- package/dist/types/src/slate/BlockPlugin/wrapList.d.ts.map +1 -0
- package/dist/types/src/slate/InlineModePlugin/index.d.ts +1 -1
- package/dist/types/src/slate/index.d.ts +0 -1
- package/dist/types/src/slate/index.d.ts.map +1 -1
- package/dist/types/src/slate/utils/element.d.ts +1 -2
- package/dist/types/src/slate/utils/element.d.ts.map +1 -1
- package/dist/types/src/state/actions.d.ts +26 -1
- package/dist/types/src/state/actions.d.ts.map +1 -1
- package/dist/types/src/state/modules/components-meta.d.ts +25 -1
- package/dist/types/src/state/modules/components-meta.d.ts.map +1 -1
- package/dist/types/src/state/modules/locales.d.ts +16 -0
- package/dist/types/src/state/modules/locales.d.ts.map +1 -0
- package/dist/types/src/state/react-builder-preview.d.ts +2 -0
- package/dist/types/src/state/react-builder-preview.d.ts.map +1 -1
- package/dist/types/src/state/react-page.d.ts +5 -1
- package/dist/types/src/state/react-page.d.ts.map +1 -1
- package/package.json +6 -3
- package/dist/select.cjs.js +0 -8
- package/dist/select.cjs.js.map +0 -1
- package/dist/select.es.js +0 -6
- package/dist/select.es.js.map +0 -1
- package/dist/types/src/slate/ListPlugin/constants.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/dedent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/indent.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/index.d.ts +0 -17
- package/dist/types/src/slate/ListPlugin/index.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/toggleList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/unwrapList.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/filterForSubtreeRoots.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/getSelectedListItems.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/utils/location.d.ts.map +0 -1
- package/dist/types/src/slate/ListPlugin/wrapList.d.ts.map +0 -1
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/constants.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/dedent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/indent.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/toggleList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/unwrapList.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/filterForSubtreeRoots.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/getSelectedListItems.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/utils/location.d.ts +0 -0
- /package/dist/types/src/slate/{ListPlugin → BlockPlugin}/wrapList.d.ts +0 -0
package/dist/react-page.es.js
CHANGED
|
@@ -25,10 +25,55 @@ const import_meta = {};
|
|
|
25
25
|
import { combineReducers, createStore, applyMiddleware } from "redux";
|
|
26
26
|
import thunk from "redux-thunk";
|
|
27
27
|
import { A as ActionTypes } from "./actions.es.js";
|
|
28
|
-
import { reducer as reducer$
|
|
29
|
-
import "slate";
|
|
30
|
-
import "is-hotkey";
|
|
28
|
+
import { findBreakpointOverride, reducer as reducer$a, getInitialState as getInitialState$9 } from "./state/breakpoints.es.js";
|
|
29
|
+
import { Element, Range, Editor, Text, Path, Transforms, Node, Point } from "slate";
|
|
30
|
+
import isHotkey from "is-hotkey";
|
|
31
31
|
import "slate-react";
|
|
32
|
+
const ComponentIcon = {
|
|
33
|
+
Billing: "billing",
|
|
34
|
+
Bolt: "bolt",
|
|
35
|
+
Button: "button",
|
|
36
|
+
Carousel: "carousel",
|
|
37
|
+
Chats: "chats",
|
|
38
|
+
Code: "code",
|
|
39
|
+
Countdown: "countdown",
|
|
40
|
+
Cube: "cube",
|
|
41
|
+
Database: "database",
|
|
42
|
+
Divider: "divider",
|
|
43
|
+
Form: "form",
|
|
44
|
+
Gallery: "gallery",
|
|
45
|
+
Help: "help",
|
|
46
|
+
Image: "image",
|
|
47
|
+
Layout: "layout",
|
|
48
|
+
Lock: "lock",
|
|
49
|
+
Navigation: "navigation",
|
|
50
|
+
SocialLinks: "social-links",
|
|
51
|
+
Star: "star",
|
|
52
|
+
Text: "text",
|
|
53
|
+
Users: "users",
|
|
54
|
+
Video: "video"
|
|
55
|
+
};
|
|
56
|
+
function getInitialState$8({
|
|
57
|
+
componentsMeta = /* @__PURE__ */ new Map()
|
|
58
|
+
} = {}) {
|
|
59
|
+
return componentsMeta;
|
|
60
|
+
}
|
|
61
|
+
function getComponentsMeta(state) {
|
|
62
|
+
return state;
|
|
63
|
+
}
|
|
64
|
+
function reducer$9(state = getInitialState$8(), action) {
|
|
65
|
+
switch (action.type) {
|
|
66
|
+
case ActionTypes.REGISTER_COMPONENT:
|
|
67
|
+
return new Map(state).set(action.payload.type, action.payload.meta);
|
|
68
|
+
case ActionTypes.UNREGISTER_COMPONENT: {
|
|
69
|
+
const nextState = new Map(state);
|
|
70
|
+
const deleted = nextState.delete(action.payload.type);
|
|
71
|
+
return deleted ? nextState : state;
|
|
72
|
+
}
|
|
73
|
+
default:
|
|
74
|
+
return state;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
32
77
|
function isElementReference(element) {
|
|
33
78
|
return !("props" in element);
|
|
34
79
|
}
|
|
@@ -93,27 +138,6 @@ function reducer$7(state = getInitialState$6(), action) {
|
|
|
93
138
|
}
|
|
94
139
|
}
|
|
95
140
|
function getInitialState$5({
|
|
96
|
-
componentsMeta = /* @__PURE__ */ new Map()
|
|
97
|
-
} = {}) {
|
|
98
|
-
return componentsMeta;
|
|
99
|
-
}
|
|
100
|
-
function getComponentsMeta(state) {
|
|
101
|
-
return state;
|
|
102
|
-
}
|
|
103
|
-
function reducer$6(state = getInitialState$5(), action) {
|
|
104
|
-
switch (action.type) {
|
|
105
|
-
case ActionTypes.REGISTER_COMPONENT:
|
|
106
|
-
return new Map(state).set(action.payload.type, action.payload.meta);
|
|
107
|
-
case ActionTypes.UNREGISTER_COMPONENT: {
|
|
108
|
-
const nextState = new Map(state);
|
|
109
|
-
const deleted = nextState.delete(action.payload.type);
|
|
110
|
-
return deleted ? nextState : state;
|
|
111
|
-
}
|
|
112
|
-
default:
|
|
113
|
-
return state;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function getInitialState$4({
|
|
117
141
|
propControllerDescriptors = /* @__PURE__ */ new Map()
|
|
118
142
|
} = {}) {
|
|
119
143
|
return propControllerDescriptors;
|
|
@@ -125,7 +149,7 @@ function getComponentPropControllerDescriptors$1(state, componentType) {
|
|
|
125
149
|
var _a;
|
|
126
150
|
return (_a = getPropControllerDescriptors$1(state).get(componentType)) != null ? _a : null;
|
|
127
151
|
}
|
|
128
|
-
function reducer$
|
|
152
|
+
function reducer$6(state = getInitialState$5(), action) {
|
|
129
153
|
switch (action.type) {
|
|
130
154
|
case ActionTypes.REGISTER_COMPONENT:
|
|
131
155
|
return new Map(state).set(action.payload.type, action.payload.propControllerDescriptors);
|
|
@@ -144,7 +168,7 @@ function isPropControllersHandle(value) {
|
|
|
144
168
|
}
|
|
145
169
|
return false;
|
|
146
170
|
}
|
|
147
|
-
function getInitialState$
|
|
171
|
+
function getInitialState$4() {
|
|
148
172
|
return { handles: /* @__PURE__ */ new Map(), instances: /* @__PURE__ */ new Map() };
|
|
149
173
|
}
|
|
150
174
|
function getPropControllersHandle(state, documentKey, elementKey) {
|
|
@@ -159,7 +183,7 @@ function getPropController(state, documentKey, elementKey, propName) {
|
|
|
159
183
|
var _a, _b;
|
|
160
184
|
return (_b = (_a = getPropControllers$1(state, documentKey, elementKey)) == null ? void 0 : _a[propName]) != null ? _b : null;
|
|
161
185
|
}
|
|
162
|
-
function reducer$
|
|
186
|
+
function reducer$5(state = getInitialState$4(), action) {
|
|
163
187
|
var _a, _b, _c, _d;
|
|
164
188
|
switch (action.type) {
|
|
165
189
|
case ActionTypes.REGISTER_PROP_CONTROLLERS_HANDLE: {
|
|
@@ -190,10 +214,10 @@ function reducer$4(state = getInitialState$3(), action) {
|
|
|
190
214
|
return state;
|
|
191
215
|
}
|
|
192
216
|
}
|
|
193
|
-
function getInitialState$
|
|
217
|
+
function getInitialState$3() {
|
|
194
218
|
return false;
|
|
195
219
|
}
|
|
196
|
-
function reducer$
|
|
220
|
+
function reducer$4(state = getInitialState$3(), action) {
|
|
197
221
|
switch (action.type) {
|
|
198
222
|
case ActionTypes.SET_IS_IN_BUILDER:
|
|
199
223
|
return action.payload;
|
|
@@ -201,13 +225,13 @@ function reducer$3(state = getInitialState$2(), action) {
|
|
|
201
225
|
return state;
|
|
202
226
|
}
|
|
203
227
|
}
|
|
204
|
-
function getInitialState$
|
|
228
|
+
function getInitialState$2(isPreview = false) {
|
|
205
229
|
return isPreview;
|
|
206
230
|
}
|
|
207
231
|
function getIsPreview$1(state) {
|
|
208
232
|
return state;
|
|
209
233
|
}
|
|
210
|
-
function reducer$
|
|
234
|
+
function reducer$3(state = getInitialState$2(), action) {
|
|
211
235
|
switch (action.type) {
|
|
212
236
|
default:
|
|
213
237
|
return state;
|
|
@@ -218,10 +242,10 @@ const BuilderEditMode = {
|
|
|
218
242
|
CONTENT: "content",
|
|
219
243
|
INTERACT: "interact"
|
|
220
244
|
};
|
|
221
|
-
function getInitialState() {
|
|
245
|
+
function getInitialState$1() {
|
|
222
246
|
return null;
|
|
223
247
|
}
|
|
224
|
-
function reducer$
|
|
248
|
+
function reducer$2(state = getInitialState$1(), action) {
|
|
225
249
|
switch (action.type) {
|
|
226
250
|
case ActionTypes.SET_BUILDER_EDIT_MODE:
|
|
227
251
|
return action.payload.editMode;
|
|
@@ -229,6 +253,34 @@ function reducer$1(state = getInitialState(), action) {
|
|
|
229
253
|
return state;
|
|
230
254
|
}
|
|
231
255
|
}
|
|
256
|
+
function getInitialState(initialState) {
|
|
257
|
+
var _a, _b, _c;
|
|
258
|
+
return {
|
|
259
|
+
locales: (_a = initialState == null ? void 0 : initialState.locales) != null ? _a : [],
|
|
260
|
+
locale: (_b = initialState == null ? void 0 : initialState.locale) != null ? _b : null,
|
|
261
|
+
defaultLocale: (_c = initialState == null ? void 0 : initialState.defaultLocale) != null ? _c : null
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
function reducer$1(state = getInitialState(), action) {
|
|
265
|
+
switch (action.type) {
|
|
266
|
+
case ActionTypes.SET_LOCALES: {
|
|
267
|
+
const locales = action.payload.locales;
|
|
268
|
+
return __spreadProps(__spreadValues({}, state), { locales });
|
|
269
|
+
}
|
|
270
|
+
case ActionTypes.SET_LOCALE: {
|
|
271
|
+
if (action.payload.locale === state.locale)
|
|
272
|
+
return state;
|
|
273
|
+
return __spreadProps(__spreadValues({}, state), { locale: action.payload.locale });
|
|
274
|
+
}
|
|
275
|
+
case ActionTypes.SET_DEFAULT_LOCALE: {
|
|
276
|
+
if (action.payload.defaultLocale === state.defaultLocale)
|
|
277
|
+
return state;
|
|
278
|
+
return __spreadProps(__spreadValues({}, state), { defaultLocale: action.payload.defaultLocale });
|
|
279
|
+
}
|
|
280
|
+
default:
|
|
281
|
+
return state;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
232
284
|
const ColorControlType = "makeswift::controls::color";
|
|
233
285
|
function Color(config = {}) {
|
|
234
286
|
return { type: ColorControlType, config };
|
|
@@ -504,11 +556,11 @@ class ListControl extends PropController {
|
|
|
504
556
|
this.controls = /* @__PURE__ */ new Map();
|
|
505
557
|
}
|
|
506
558
|
}
|
|
507
|
-
function copyListData(
|
|
559
|
+
function copyListData(definition2, value, context) {
|
|
508
560
|
if (value == null)
|
|
509
561
|
return value;
|
|
510
562
|
return value && value.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
511
|
-
value: copy(
|
|
563
|
+
value: copy(definition2.config.type, item.value, context)
|
|
512
564
|
}));
|
|
513
565
|
}
|
|
514
566
|
const ShapeControlType = "makeswift::controls::shape";
|
|
@@ -554,11 +606,11 @@ class ShapeControl extends PropController {
|
|
|
554
606
|
this.setControls();
|
|
555
607
|
}
|
|
556
608
|
}
|
|
557
|
-
function copyShapeData(
|
|
609
|
+
function copyShapeData(definition2, value, context) {
|
|
558
610
|
if (value == null)
|
|
559
611
|
return value;
|
|
560
612
|
const newValue = {};
|
|
561
|
-
for (const [key, itemDefinition] of Object.entries(
|
|
613
|
+
for (const [key, itemDefinition] of Object.entries(definition2.config.type)) {
|
|
562
614
|
const prop = value[key];
|
|
563
615
|
newValue[key] = copy(itemDefinition, prop, context);
|
|
564
616
|
}
|
|
@@ -1554,8 +1606,8 @@ function copy$1(descriptor, value, context) {
|
|
|
1554
1606
|
function copyElementReference(value, context) {
|
|
1555
1607
|
return context.replacementContext.globalElementIds.get(value) || value;
|
|
1556
1608
|
}
|
|
1557
|
-
function copy(
|
|
1558
|
-
switch (
|
|
1609
|
+
function copy(definition2, value, context) {
|
|
1610
|
+
switch (definition2.type) {
|
|
1559
1611
|
case Types.Backgrounds:
|
|
1560
1612
|
case Types.Grid:
|
|
1561
1613
|
case Types.NavigationLinks:
|
|
@@ -1569,7 +1621,7 @@ function copy(definition, value, context) {
|
|
|
1569
1621
|
case Types.Border:
|
|
1570
1622
|
case Types.RichText:
|
|
1571
1623
|
case Types.ElementID:
|
|
1572
|
-
return copy$1(
|
|
1624
|
+
return copy$1(definition2, value, context);
|
|
1573
1625
|
case ColorControlType:
|
|
1574
1626
|
return copyColorData(value, context);
|
|
1575
1627
|
case ImageControlType:
|
|
@@ -1577,9 +1629,9 @@ function copy(definition, value, context) {
|
|
|
1577
1629
|
case LinkControlType:
|
|
1578
1630
|
return copyLinkData(value, context);
|
|
1579
1631
|
case ShapeControlType:
|
|
1580
|
-
return copyShapeData(
|
|
1632
|
+
return copyShapeData(definition2, value, context);
|
|
1581
1633
|
case ListControlType:
|
|
1582
|
-
return copyListData(
|
|
1634
|
+
return copyListData(definition2, value, context);
|
|
1583
1635
|
case StyleControlType:
|
|
1584
1636
|
return copyStyleData(value, context);
|
|
1585
1637
|
case SlotControlType:
|
|
@@ -1588,14 +1640,18 @@ function copy(definition, value, context) {
|
|
|
1588
1640
|
return value;
|
|
1589
1641
|
}
|
|
1590
1642
|
}
|
|
1591
|
-
function merge(
|
|
1592
|
-
switch (
|
|
1643
|
+
function merge(definition2, a, b = a, context) {
|
|
1644
|
+
switch (definition2.type) {
|
|
1593
1645
|
case SlotControlType:
|
|
1594
1646
|
return mergeSlotData(a, b, context);
|
|
1595
1647
|
default:
|
|
1596
1648
|
return b;
|
|
1597
1649
|
}
|
|
1598
1650
|
}
|
|
1651
|
+
const SelectControlType = "makeswift::controls::select";
|
|
1652
|
+
function Select(config) {
|
|
1653
|
+
return { type: SelectControlType, config };
|
|
1654
|
+
}
|
|
1599
1655
|
const ObjectType = {
|
|
1600
1656
|
Value: "value",
|
|
1601
1657
|
Text: "text",
|
|
@@ -1641,6 +1697,582 @@ const BlockTextAlignment = {
|
|
|
1641
1697
|
Right: "right",
|
|
1642
1698
|
Justify: "justify"
|
|
1643
1699
|
};
|
|
1700
|
+
const ElementUtils = {
|
|
1701
|
+
isRootBlock(node) {
|
|
1702
|
+
return Element.isElement(node) && (Element.isElementType(node, BlockType.Paragraph) || Element.isElementType(node, BlockType.Heading1) || Element.isElementType(node, BlockType.Heading2) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading3) || Element.isElementType(node, BlockType.Heading4) || Element.isElementType(node, BlockType.Heading5) || Element.isElementType(node, BlockType.Heading6) || Element.isElementType(node, BlockType.BlockQuote) || Element.isElementType(node, BlockType.UnorderedList) || Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.Text) || Element.isElementType(node, BlockType.Default));
|
|
1703
|
+
},
|
|
1704
|
+
isBlock(node) {
|
|
1705
|
+
return Element.isElement(node) && (this.isRootBlock(node) || Element.isElementType(node, BlockType.ListItem) || Element.isElementType(node, BlockType.ListItemChild));
|
|
1706
|
+
},
|
|
1707
|
+
isInline(node) {
|
|
1708
|
+
return Element.isElementType(node, InlineType.Code) || Element.isElementType(node, InlineType.Link) || Element.isElementType(node, InlineType.SubScript) || Element.isElementType(node, InlineType.SuperScript);
|
|
1709
|
+
},
|
|
1710
|
+
isConvertibleToListTextNode(node) {
|
|
1711
|
+
return !this.isList(node) && !this.isListItem(node) && !this.isListItemChild(node);
|
|
1712
|
+
},
|
|
1713
|
+
isList(node) {
|
|
1714
|
+
return Element.isElementType(node, BlockType.OrderedList) || Element.isElementType(node, BlockType.UnorderedList);
|
|
1715
|
+
},
|
|
1716
|
+
isListItem(node) {
|
|
1717
|
+
return Element.isElementType(node, BlockType.ListItem);
|
|
1718
|
+
},
|
|
1719
|
+
isListItemChild(node) {
|
|
1720
|
+
return Element.isElementType(node, BlockType.ListItemChild);
|
|
1721
|
+
},
|
|
1722
|
+
createText() {
|
|
1723
|
+
return { text: "" };
|
|
1724
|
+
},
|
|
1725
|
+
createParagraph() {
|
|
1726
|
+
return {
|
|
1727
|
+
children: [this.createText()],
|
|
1728
|
+
type: BlockType.Paragraph
|
|
1729
|
+
};
|
|
1730
|
+
},
|
|
1731
|
+
createList(type = BlockType.UnorderedList) {
|
|
1732
|
+
return { children: [this.createText()], type };
|
|
1733
|
+
},
|
|
1734
|
+
createListItem() {
|
|
1735
|
+
return {
|
|
1736
|
+
children: [this.createListItemChild()],
|
|
1737
|
+
type: BlockType.ListItem
|
|
1738
|
+
};
|
|
1739
|
+
},
|
|
1740
|
+
createListItemChild() {
|
|
1741
|
+
return {
|
|
1742
|
+
children: [this.createText()],
|
|
1743
|
+
type: BlockType.ListItemChild
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
};
|
|
1747
|
+
function unhangRange(editor, range) {
|
|
1748
|
+
let [start, end] = Range.edges(range);
|
|
1749
|
+
if (start.offset !== 0 || end.offset !== 0 || Range.isCollapsed(range)) {
|
|
1750
|
+
return range;
|
|
1751
|
+
}
|
|
1752
|
+
const endBlock = Editor.above(editor, {
|
|
1753
|
+
at: end,
|
|
1754
|
+
match: (n) => Element.isElement(n) && Editor.isBlock(editor, n)
|
|
1755
|
+
});
|
|
1756
|
+
const blockPath = endBlock ? endBlock[1] : [];
|
|
1757
|
+
const first = Editor.start(editor, start);
|
|
1758
|
+
const before = { anchor: first, focus: end };
|
|
1759
|
+
let skip = true;
|
|
1760
|
+
for (const [node, path] of Editor.nodes(editor, {
|
|
1761
|
+
at: before,
|
|
1762
|
+
match: Text.isText,
|
|
1763
|
+
reverse: true
|
|
1764
|
+
})) {
|
|
1765
|
+
if (skip) {
|
|
1766
|
+
skip = false;
|
|
1767
|
+
continue;
|
|
1768
|
+
}
|
|
1769
|
+
if (node.text !== "" || Path.isBefore(path, blockPath)) {
|
|
1770
|
+
end = { path, offset: node.text.length };
|
|
1771
|
+
break;
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
return { anchor: start, focus: end };
|
|
1775
|
+
}
|
|
1776
|
+
function getSelection(editor) {
|
|
1777
|
+
if (editor.selection)
|
|
1778
|
+
return unhangRange(editor, editor.selection);
|
|
1779
|
+
return {
|
|
1780
|
+
anchor: Editor.start(editor, []),
|
|
1781
|
+
focus: Editor.end(editor, [])
|
|
1782
|
+
};
|
|
1783
|
+
}
|
|
1784
|
+
function getBlocksInSelection(editor) {
|
|
1785
|
+
return Array.from(Editor.nodes(editor, {
|
|
1786
|
+
at: getSelection(editor),
|
|
1787
|
+
match: (node) => ElementUtils.isRootBlock(node)
|
|
1788
|
+
})).filter((entry) => ElementUtils.isRootBlock(entry[0]));
|
|
1789
|
+
}
|
|
1790
|
+
function getActiveBlockType(editor) {
|
|
1791
|
+
var _a;
|
|
1792
|
+
const rootBlocks = getBlocksInSelection(editor).map(([node]) => node.type);
|
|
1793
|
+
return rootBlocks.reduce((a, b) => a === b ? b : null, (_a = rootBlocks.at(0)) != null ? _a : null);
|
|
1794
|
+
}
|
|
1795
|
+
function setBlockKeyForDevice(editor, breakpoints, deviceId, key, value, options) {
|
|
1796
|
+
var _a, _b;
|
|
1797
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
1798
|
+
if (!at)
|
|
1799
|
+
return;
|
|
1800
|
+
const rootElements = getBlocksInSelection(editor);
|
|
1801
|
+
for (const [node, path] of rootElements) {
|
|
1802
|
+
if (ElementUtils.isBlock(node)) {
|
|
1803
|
+
const deviceValues = (_b = node[key]) != null ? _b : [];
|
|
1804
|
+
const currentDeviceValue = findBreakpointOverride(breakpoints, deviceValues, deviceId, (v) => v);
|
|
1805
|
+
const nextDeviceValue = __spreadProps(__spreadValues({}, currentDeviceValue), {
|
|
1806
|
+
deviceId,
|
|
1807
|
+
value
|
|
1808
|
+
});
|
|
1809
|
+
Transforms.setNodes(editor, {
|
|
1810
|
+
[key]: [...deviceValues.filter((v) => v.deviceId !== deviceId), nextDeviceValue]
|
|
1811
|
+
}, { at: path });
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
function clearBlockKeyForDevice(editor, deviceId, key) {
|
|
1816
|
+
var _a;
|
|
1817
|
+
const rootElements = getBlocksInSelection(editor);
|
|
1818
|
+
for (const [node, path] of rootElements) {
|
|
1819
|
+
if (ElementUtils.isBlock(node)) {
|
|
1820
|
+
const deviceOverrides = (_a = node[key]) != null ? _a : [];
|
|
1821
|
+
Transforms.setNodes(editor, {
|
|
1822
|
+
[key]: deviceOverrides.filter((v) => v.deviceId !== deviceId)
|
|
1823
|
+
}, { at: path });
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
function wrapInline(editor, inline) {
|
|
1828
|
+
Transforms.wrapNodes(editor, inline, {
|
|
1829
|
+
at: getSelection(editor),
|
|
1830
|
+
split: true
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
function unwrapInline(editor, type) {
|
|
1834
|
+
Transforms.unwrapNodes(editor, {
|
|
1835
|
+
match: (node) => ElementUtils.isInline(node) && node.type === type,
|
|
1836
|
+
at: getSelection(editor)
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
const EditorUtils = {
|
|
1840
|
+
getFirstAncestorList(editor, path) {
|
|
1841
|
+
try {
|
|
1842
|
+
const parentList = Editor.above(editor, {
|
|
1843
|
+
at: path,
|
|
1844
|
+
match: (node) => ElementUtils.isList(node)
|
|
1845
|
+
});
|
|
1846
|
+
return parentList != null ? parentList : null;
|
|
1847
|
+
} catch (e) {
|
|
1848
|
+
return null;
|
|
1849
|
+
}
|
|
1850
|
+
},
|
|
1851
|
+
getFirstAncestorListItem(editor, path) {
|
|
1852
|
+
try {
|
|
1853
|
+
const parentListItem = Editor.above(editor, {
|
|
1854
|
+
at: path,
|
|
1855
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
1856
|
+
});
|
|
1857
|
+
return parentListItem != null ? parentListItem : null;
|
|
1858
|
+
} catch (e) {
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
}
|
|
1862
|
+
};
|
|
1863
|
+
const LIST_ITEM_CHILD_POSITION = 0;
|
|
1864
|
+
const LIST_ITEM_LIST_POSITION = 1;
|
|
1865
|
+
function filterForSubtreeRoots(entries) {
|
|
1866
|
+
return entries.filter(([, nodePath]) => !Path.ancestors(nodePath).some((ancestor) => {
|
|
1867
|
+
return entries.some(([, path]) => Path.equals(path, ancestor));
|
|
1868
|
+
}));
|
|
1869
|
+
}
|
|
1870
|
+
function unwrapPath(editor, listItemPath) {
|
|
1871
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
1872
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
1873
|
+
if (!parentList || listItemContainingParentList)
|
|
1874
|
+
return;
|
|
1875
|
+
Editor.withoutNormalizing(editor, () => {
|
|
1876
|
+
const listItemTextPath = [...listItemPath, LIST_ITEM_CHILD_POSITION];
|
|
1877
|
+
const listItemNestedListPath = [...listItemPath, LIST_ITEM_LIST_POSITION];
|
|
1878
|
+
if (Node.has(editor, listItemNestedListPath)) {
|
|
1879
|
+
Transforms.setNodes(editor, { type: parentList[0].type }, { at: listItemNestedListPath });
|
|
1880
|
+
Transforms.liftNodes(editor, { at: listItemNestedListPath });
|
|
1881
|
+
Transforms.liftNodes(editor, { at: Path.next(listItemPath) });
|
|
1882
|
+
}
|
|
1883
|
+
if (Node.has(editor, listItemTextPath)) {
|
|
1884
|
+
Transforms.setNodes(editor, { type: BlockType.Paragraph }, {
|
|
1885
|
+
at: listItemTextPath
|
|
1886
|
+
});
|
|
1887
|
+
Transforms.liftNodes(editor, { at: listItemTextPath });
|
|
1888
|
+
Transforms.liftNodes(editor, { at: listItemPath });
|
|
1889
|
+
}
|
|
1890
|
+
});
|
|
1891
|
+
}
|
|
1892
|
+
function unwrapList(editor, options) {
|
|
1893
|
+
var _a;
|
|
1894
|
+
const at = (_a = options == null ? void 0 : options.at) != null ? _a : editor.selection;
|
|
1895
|
+
if (!at)
|
|
1896
|
+
return;
|
|
1897
|
+
const listItems = Array.from(Editor.nodes(editor, {
|
|
1898
|
+
at,
|
|
1899
|
+
match: (node) => {
|
|
1900
|
+
return Element.isElement(node) && ElementUtils.isListItem(node);
|
|
1901
|
+
}
|
|
1902
|
+
}));
|
|
1903
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
1904
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
1905
|
+
refs.forEach((ref) => {
|
|
1906
|
+
if (ref.current) {
|
|
1907
|
+
unwrapPath(editor, ref.current);
|
|
1908
|
+
}
|
|
1909
|
+
ref.unref();
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
function wrapList(editor, options = { type: BlockType.UnorderedList }) {
|
|
1913
|
+
var _a;
|
|
1914
|
+
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
1915
|
+
if (!at)
|
|
1916
|
+
return;
|
|
1917
|
+
const nonListEntries = Array.from(Editor.nodes(editor, {
|
|
1918
|
+
at,
|
|
1919
|
+
match: (node) => {
|
|
1920
|
+
return Element.isElement(node) && ElementUtils.isConvertibleToListTextNode(node);
|
|
1921
|
+
}
|
|
1922
|
+
}));
|
|
1923
|
+
const refs = nonListEntries.map(([_, path]) => Editor.pathRef(editor, path));
|
|
1924
|
+
refs.forEach((ref) => {
|
|
1925
|
+
const path = ref.current;
|
|
1926
|
+
if (path) {
|
|
1927
|
+
Editor.withoutNormalizing(editor, () => {
|
|
1928
|
+
Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
1929
|
+
at: path
|
|
1930
|
+
});
|
|
1931
|
+
Transforms.wrapNodes(editor, ElementUtils.createListItem(), {
|
|
1932
|
+
match: (node) => ElementUtils.isListItemChild(node),
|
|
1933
|
+
at: path
|
|
1934
|
+
});
|
|
1935
|
+
Transforms.wrapNodes(editor, ElementUtils.createList(options.type), {
|
|
1936
|
+
at: path
|
|
1937
|
+
});
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
ref.unref();
|
|
1941
|
+
});
|
|
1942
|
+
}
|
|
1943
|
+
const LocationUtils = {
|
|
1944
|
+
getStartPath(location) {
|
|
1945
|
+
if (Range.isRange(location))
|
|
1946
|
+
return Range.start(location).path;
|
|
1947
|
+
if (Point.isPoint(location))
|
|
1948
|
+
return location.path;
|
|
1949
|
+
return location;
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
function getSelectedListItems(editor) {
|
|
1953
|
+
var _a, _b;
|
|
1954
|
+
if (!editor.selection)
|
|
1955
|
+
return [];
|
|
1956
|
+
const start = LocationUtils.getStartPath(editor.selection);
|
|
1957
|
+
const listItems = Editor.nodes(editor, {
|
|
1958
|
+
at: editor.selection,
|
|
1959
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
1960
|
+
});
|
|
1961
|
+
const firstAncestorPath = (_b = (_a = EditorUtils.getFirstAncestorListItem(editor, start)) == null ? void 0 : _a[1]) != null ? _b : [];
|
|
1962
|
+
return Array.from(listItems).filter((node) => Path.isDescendant(start, node[1]) ? Path.equals(node[1], firstAncestorPath) : !Path.isAfter(start, node[1]));
|
|
1963
|
+
}
|
|
1964
|
+
function indentPath(editor, path) {
|
|
1965
|
+
const parent = Node.parent(editor, path);
|
|
1966
|
+
if (!path || !Path.hasPrevious(path) || !ElementUtils.isList(parent))
|
|
1967
|
+
return;
|
|
1968
|
+
const previosPath = Path.previous(path);
|
|
1969
|
+
const previousChildListPath = [...previosPath, LIST_ITEM_LIST_POSITION];
|
|
1970
|
+
const previousHasChildList = Node.has(editor, previousChildListPath);
|
|
1971
|
+
Editor.withoutNormalizing(editor, () => {
|
|
1972
|
+
if (!previousHasChildList) {
|
|
1973
|
+
Transforms.insertNodes(editor, ElementUtils.createList(parent.type), {
|
|
1974
|
+
at: previousChildListPath
|
|
1975
|
+
});
|
|
1976
|
+
}
|
|
1977
|
+
const previousChildList = Node.get(editor, previousChildListPath);
|
|
1978
|
+
if (ElementUtils.isList(previousChildList)) {
|
|
1979
|
+
const index = previousHasChildList ? previousChildList.children.length : 0;
|
|
1980
|
+
Transforms.moveNodes(editor, {
|
|
1981
|
+
at: path,
|
|
1982
|
+
to: [...previousChildListPath, index]
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
});
|
|
1986
|
+
}
|
|
1987
|
+
function indent(editor) {
|
|
1988
|
+
if (!editor.selection)
|
|
1989
|
+
return;
|
|
1990
|
+
const listItems = getSelectedListItems(editor);
|
|
1991
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
1992
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
1993
|
+
refs.forEach((ref) => {
|
|
1994
|
+
if (ref.current) {
|
|
1995
|
+
indentPath(editor, ref.current);
|
|
1996
|
+
}
|
|
1997
|
+
ref.unref();
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
function dedentPath(editor, listItemPath) {
|
|
2001
|
+
const parentList = EditorUtils.getFirstAncestorList(editor, listItemPath);
|
|
2002
|
+
const listItemContainingParentList = EditorUtils.getFirstAncestorListItem(editor, listItemPath);
|
|
2003
|
+
if (!parentList || !listItemContainingParentList)
|
|
2004
|
+
return;
|
|
2005
|
+
const [parentListNode, parentListPath] = parentList;
|
|
2006
|
+
const [_, listItemContainingParentListPath] = listItemContainingParentList;
|
|
2007
|
+
const listItemPosition = listItemPath[listItemPath.length - 1];
|
|
2008
|
+
const previousSiblings = parentListNode.children.slice(0, listItemPosition);
|
|
2009
|
+
const nextSiblings = parentListNode.children.slice(listItemPosition + 1);
|
|
2010
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2011
|
+
nextSiblings.forEach(() => {
|
|
2012
|
+
const nextSiblingPath = [...parentListPath, listItemPosition + 1];
|
|
2013
|
+
indentPath(editor, nextSiblingPath);
|
|
2014
|
+
});
|
|
2015
|
+
Transforms.moveNodes(editor, {
|
|
2016
|
+
at: listItemPath,
|
|
2017
|
+
to: Path.next(listItemContainingParentListPath)
|
|
2018
|
+
});
|
|
2019
|
+
if (previousSiblings.length === 0) {
|
|
2020
|
+
Transforms.removeNodes(editor, { at: parentListPath });
|
|
2021
|
+
}
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
function dedent(editor) {
|
|
2025
|
+
if (!editor.selection)
|
|
2026
|
+
return;
|
|
2027
|
+
const listItems = getSelectedListItems(editor);
|
|
2028
|
+
const subRoots = filterForSubtreeRoots(listItems);
|
|
2029
|
+
const refs = subRoots.map(([_, path]) => Editor.pathRef(editor, path));
|
|
2030
|
+
refs.forEach((ref) => {
|
|
2031
|
+
if (ref.current) {
|
|
2032
|
+
dedentPath(editor, ref.current);
|
|
2033
|
+
}
|
|
2034
|
+
ref.unref();
|
|
2035
|
+
});
|
|
2036
|
+
}
|
|
2037
|
+
function toggleList(editor, options = { type: BlockType.UnorderedList }) {
|
|
2038
|
+
var _a;
|
|
2039
|
+
const at = (_a = options.at) != null ? _a : editor.selection;
|
|
2040
|
+
if (at == null)
|
|
2041
|
+
return;
|
|
2042
|
+
const start = LocationUtils.getStartPath(at);
|
|
2043
|
+
const ancestorPath = Path.ancestors(start).at(1);
|
|
2044
|
+
if (!ancestorPath || !Node.has(editor, ancestorPath))
|
|
2045
|
+
return;
|
|
2046
|
+
const ancestor = Node.get(editor, ancestorPath);
|
|
2047
|
+
if (!ElementUtils.isList(ancestor)) {
|
|
2048
|
+
return wrapList(editor, { type: options.type, at });
|
|
2049
|
+
}
|
|
2050
|
+
if (ancestor.type === options.type) {
|
|
2051
|
+
unwrapList(editor, { at });
|
|
2052
|
+
} else {
|
|
2053
|
+
Transforms.setNodes(editor, { type: options.type }, { at: ancestorPath });
|
|
2054
|
+
}
|
|
2055
|
+
}
|
|
2056
|
+
const BlockActions = {
|
|
2057
|
+
setBlockKeyForDevice,
|
|
2058
|
+
clearBlockKeyForDevice,
|
|
2059
|
+
wrapInline,
|
|
2060
|
+
unwrapInline
|
|
2061
|
+
};
|
|
2062
|
+
const ListActions = {
|
|
2063
|
+
unwrapList,
|
|
2064
|
+
wrapList,
|
|
2065
|
+
indent,
|
|
2066
|
+
dedent,
|
|
2067
|
+
toggleList
|
|
2068
|
+
};
|
|
2069
|
+
function onKeyDown(e, editor) {
|
|
2070
|
+
if (!editor.selection || Array.from(Editor.nodes(editor, { match: (node) => ElementUtils.isListItem(node) })).length === 0)
|
|
2071
|
+
return;
|
|
2072
|
+
if (isHotkey("shift+tab", e)) {
|
|
2073
|
+
e.preventDefault();
|
|
2074
|
+
ListActions.dedent(editor);
|
|
2075
|
+
}
|
|
2076
|
+
if (isHotkey("tab", e)) {
|
|
2077
|
+
e.preventDefault();
|
|
2078
|
+
ListActions.indent(editor);
|
|
2079
|
+
}
|
|
2080
|
+
if (isHotkey("backspace", e)) {
|
|
2081
|
+
if (!editor.selection)
|
|
2082
|
+
return;
|
|
2083
|
+
if (Range.isExpanded(editor.selection))
|
|
2084
|
+
return;
|
|
2085
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2086
|
+
if (editor.selection.anchor.offset === 0 && listItem) {
|
|
2087
|
+
e.preventDefault();
|
|
2088
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2089
|
+
const list = EditorUtils.getFirstAncestorList(editor, listItem[1]);
|
|
2090
|
+
if (parentListItem) {
|
|
2091
|
+
ListActions.dedent(editor);
|
|
2092
|
+
} else if (list) {
|
|
2093
|
+
ListActions.unwrapList(editor);
|
|
2094
|
+
}
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
if (isHotkey("enter", e)) {
|
|
2099
|
+
e.preventDefault();
|
|
2100
|
+
if (!editor.selection)
|
|
2101
|
+
return;
|
|
2102
|
+
if (Range.isExpanded(editor.selection)) {
|
|
2103
|
+
Transforms.delete(editor);
|
|
2104
|
+
return;
|
|
2105
|
+
}
|
|
2106
|
+
const listItem = EditorUtils.getFirstAncestorListItem(editor, editor.selection.anchor.path);
|
|
2107
|
+
if (editor.selection.anchor.offset === 0 && listItem && Editor.string(editor, listItem[1]) === "") {
|
|
2108
|
+
const parentListItem = EditorUtils.getFirstAncestorListItem(editor, listItem[1]);
|
|
2109
|
+
if (parentListItem) {
|
|
2110
|
+
ListActions.dedent(editor);
|
|
2111
|
+
} else {
|
|
2112
|
+
ListActions.unwrapList(editor);
|
|
2113
|
+
}
|
|
2114
|
+
return;
|
|
2115
|
+
}
|
|
2116
|
+
Transforms.splitNodes(editor, {
|
|
2117
|
+
at: editor.selection,
|
|
2118
|
+
always: true,
|
|
2119
|
+
match: (node) => ElementUtils.isListItem(node)
|
|
2120
|
+
});
|
|
2121
|
+
}
|
|
2122
|
+
if (isHotkey("shift+enter", e)) {
|
|
2123
|
+
e.preventDefault();
|
|
2124
|
+
editor.insertText("\n");
|
|
2125
|
+
}
|
|
2126
|
+
}
|
|
2127
|
+
function withBlock(editor) {
|
|
2128
|
+
const { normalizeNode } = editor;
|
|
2129
|
+
editor.isInline = (entry) => {
|
|
2130
|
+
return ElementUtils.isInline(entry);
|
|
2131
|
+
};
|
|
2132
|
+
editor.normalizeNode = (entry) => {
|
|
2133
|
+
var _a;
|
|
2134
|
+
const [normalizationNode, normalizationPath] = entry;
|
|
2135
|
+
if (ElementUtils.isBlock(normalizationNode) && ((_a = normalizationNode == null ? void 0 : normalizationNode.textAlign) == null ? void 0 : _a.length) == 0) {
|
|
2136
|
+
Transforms.unsetNodes(editor, "textAlign", { at: normalizationPath });
|
|
2137
|
+
return;
|
|
2138
|
+
}
|
|
2139
|
+
if (ElementUtils.isListItem(normalizationNode)) {
|
|
2140
|
+
const pathToListItemText = [...normalizationPath, LIST_ITEM_CHILD_POSITION];
|
|
2141
|
+
if (Node.has(editor, pathToListItemText)) {
|
|
2142
|
+
const nodeInListItemTextPosition = Node.get(editor, pathToListItemText);
|
|
2143
|
+
if (ElementUtils.isRootBlock(nodeInListItemTextPosition)) {
|
|
2144
|
+
Transforms.setNodes(editor, { type: BlockType.ListItemChild }, {
|
|
2145
|
+
at: pathToListItemText
|
|
2146
|
+
});
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
} else {
|
|
2150
|
+
Transforms.insertNodes(editor, ElementUtils.createListItem(), {
|
|
2151
|
+
at: pathToListItemText
|
|
2152
|
+
});
|
|
2153
|
+
return;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
if (!Text.isText(normalizationNode)) {
|
|
2157
|
+
const mergeableChildren = Array.from(Node.children(editor, normalizationPath)).map((child, index, children) => {
|
|
2158
|
+
const potentialNodeToBeMerged = children.at(index + 1);
|
|
2159
|
+
if (!potentialNodeToBeMerged || !ElementUtils.isList(potentialNodeToBeMerged[0]) || !ElementUtils.isList(child[0]) || potentialNodeToBeMerged[0].type !== child[0].type) {
|
|
2160
|
+
return null;
|
|
2161
|
+
}
|
|
2162
|
+
return [
|
|
2163
|
+
Editor.pathRef(editor, child[1]),
|
|
2164
|
+
Editor.pathRef(editor, potentialNodeToBeMerged[1])
|
|
2165
|
+
];
|
|
2166
|
+
}).filter((mergeableNodes) => Boolean(mergeableNodes));
|
|
2167
|
+
if (mergeableChildren.length !== 0) {
|
|
2168
|
+
mergeableChildren.reverse().forEach(([nodePathRef, nodeToBeMergedPathRef]) => {
|
|
2169
|
+
const nodePath = nodePathRef.current;
|
|
2170
|
+
const nodeToBeMergedPath = nodeToBeMergedPathRef.current;
|
|
2171
|
+
if (nodePath == null || nodeToBeMergedPath == null)
|
|
2172
|
+
return;
|
|
2173
|
+
const nodeChildren = Array.from(Node.children(editor, nodePath));
|
|
2174
|
+
const childrenToBeMerged = Array.from(Node.children(editor, nodeToBeMergedPath));
|
|
2175
|
+
Editor.withoutNormalizing(editor, () => {
|
|
2176
|
+
childrenToBeMerged.reverse().forEach(([_, childPath]) => {
|
|
2177
|
+
Transforms.moveNodes(editor, {
|
|
2178
|
+
at: childPath,
|
|
2179
|
+
to: [...nodePath, nodeChildren.length]
|
|
2180
|
+
});
|
|
2181
|
+
});
|
|
2182
|
+
Transforms.removeNodes(editor, { at: nodeToBeMergedPath });
|
|
2183
|
+
});
|
|
2184
|
+
nodePathRef.unref();
|
|
2185
|
+
nodeToBeMergedPathRef.unref();
|
|
2186
|
+
});
|
|
2187
|
+
return;
|
|
2188
|
+
}
|
|
2189
|
+
}
|
|
2190
|
+
normalizeNode(entry);
|
|
2191
|
+
};
|
|
2192
|
+
return editor;
|
|
2193
|
+
}
|
|
2194
|
+
const definition = Select({
|
|
2195
|
+
label: "Block",
|
|
2196
|
+
labelOrientation: "horizontal",
|
|
2197
|
+
options: [
|
|
2198
|
+
{
|
|
2199
|
+
value: BlockType.Paragraph,
|
|
2200
|
+
label: "Paragraph"
|
|
2201
|
+
},
|
|
2202
|
+
{
|
|
2203
|
+
value: BlockType.Heading1,
|
|
2204
|
+
label: "Heading 1"
|
|
2205
|
+
},
|
|
2206
|
+
{
|
|
2207
|
+
value: BlockType.Heading2,
|
|
2208
|
+
label: "Heading 2"
|
|
2209
|
+
},
|
|
2210
|
+
{
|
|
2211
|
+
value: BlockType.Heading3,
|
|
2212
|
+
label: "Heading 3"
|
|
2213
|
+
},
|
|
2214
|
+
{
|
|
2215
|
+
value: BlockType.Heading4,
|
|
2216
|
+
label: "Heading 4"
|
|
2217
|
+
},
|
|
2218
|
+
{
|
|
2219
|
+
value: BlockType.Heading5,
|
|
2220
|
+
label: "Heading 5"
|
|
2221
|
+
},
|
|
2222
|
+
{
|
|
2223
|
+
value: BlockType.Heading6,
|
|
2224
|
+
label: "Heading 6"
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
value: BlockType.UnorderedList,
|
|
2228
|
+
label: "Bulleted list"
|
|
2229
|
+
},
|
|
2230
|
+
{
|
|
2231
|
+
value: BlockType.OrderedList,
|
|
2232
|
+
label: "Numbered list"
|
|
2233
|
+
},
|
|
2234
|
+
{
|
|
2235
|
+
value: BlockType.BlockQuote,
|
|
2236
|
+
label: "Quote"
|
|
2237
|
+
}
|
|
2238
|
+
],
|
|
2239
|
+
defaultValue: BlockType.Paragraph
|
|
2240
|
+
});
|
|
2241
|
+
function BlockPlugin() {
|
|
2242
|
+
return createRichTextV2Plugin({
|
|
2243
|
+
withPlugin: withBlock,
|
|
2244
|
+
onKeyDown,
|
|
2245
|
+
control: {
|
|
2246
|
+
definition,
|
|
2247
|
+
onChange: (editor, value) => {
|
|
2248
|
+
const activeBlockType = getActiveBlockType(editor);
|
|
2249
|
+
if (value === BlockType.UnorderedList || value === BlockType.OrderedList) {
|
|
2250
|
+
ListActions.toggleList(editor, {
|
|
2251
|
+
type: value,
|
|
2252
|
+
at: getSelection(editor)
|
|
2253
|
+
});
|
|
2254
|
+
} else if (activeBlockType === value) {
|
|
2255
|
+
Transforms.setNodes(editor, {
|
|
2256
|
+
type: BlockType.Default
|
|
2257
|
+
}, { at: getSelection(editor) });
|
|
2258
|
+
} else {
|
|
2259
|
+
ListActions.unwrapList(editor, {
|
|
2260
|
+
at: getSelection(editor)
|
|
2261
|
+
});
|
|
2262
|
+
Transforms.setNodes(editor, {
|
|
2263
|
+
type: value != null ? value : BlockType.Default
|
|
2264
|
+
}, { at: getSelection(editor) });
|
|
2265
|
+
}
|
|
2266
|
+
},
|
|
2267
|
+
getValue: (editor) => {
|
|
2268
|
+
const activeBlock = getActiveBlockType(editor);
|
|
2269
|
+
if (activeBlock === RootBlockType.Text || activeBlock === RootBlockType.Default)
|
|
2270
|
+
return void 0;
|
|
2271
|
+
return activeBlock;
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2274
|
+
});
|
|
2275
|
+
}
|
|
1644
2276
|
const RichTextV2ControlType = "makeswift::controls::rich-text-v2";
|
|
1645
2277
|
const RichTextV2Mode = {
|
|
1646
2278
|
Inline: "makeswift::controls::rich-text-v2::mode::inline",
|
|
@@ -1649,9 +2281,9 @@ const RichTextV2Mode = {
|
|
|
1649
2281
|
function createRichTextV2Plugin({
|
|
1650
2282
|
control,
|
|
1651
2283
|
withPlugin,
|
|
1652
|
-
onKeyDown
|
|
2284
|
+
onKeyDown: onKeyDown2
|
|
1653
2285
|
}) {
|
|
1654
|
-
return { control, withPlugin, onKeyDown };
|
|
2286
|
+
return { control, withPlugin, onKeyDown: onKeyDown2 };
|
|
1655
2287
|
}
|
|
1656
2288
|
function unstable_RichTextV2(config = {}) {
|
|
1657
2289
|
return { type: RichTextV2ControlType, config };
|
|
@@ -2541,13 +3173,14 @@ var introspection = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
|
|
|
2541
3173
|
const reducer = combineReducers({
|
|
2542
3174
|
documents: reducer$8,
|
|
2543
3175
|
reactComponents: reducer$7,
|
|
2544
|
-
componentsMeta: reducer$
|
|
2545
|
-
propControllers: reducer$
|
|
2546
|
-
propControllerHandles: reducer$
|
|
2547
|
-
isInBuilder: reducer$
|
|
2548
|
-
isPreview: reducer$
|
|
2549
|
-
builderEditMode: reducer$
|
|
2550
|
-
breakpoints: reducer$
|
|
3176
|
+
componentsMeta: reducer$9,
|
|
3177
|
+
propControllers: reducer$6,
|
|
3178
|
+
propControllerHandles: reducer$5,
|
|
3179
|
+
isInBuilder: reducer$4,
|
|
3180
|
+
isPreview: reducer$3,
|
|
3181
|
+
builderEditMode: reducer$2,
|
|
3182
|
+
breakpoints: reducer$a,
|
|
3183
|
+
locales: reducer$1
|
|
2551
3184
|
});
|
|
2552
3185
|
function getDocumentsStateSlice(state) {
|
|
2553
3186
|
return state.documents;
|
|
@@ -2690,15 +3323,20 @@ function getBuilderEditMode(state) {
|
|
|
2690
3323
|
function getBreakpoints(state) {
|
|
2691
3324
|
return state.breakpoints;
|
|
2692
3325
|
}
|
|
3326
|
+
function getLocales(state) {
|
|
3327
|
+
return state.locales;
|
|
3328
|
+
}
|
|
2693
3329
|
function configureStore({
|
|
2694
3330
|
rootElements,
|
|
2695
3331
|
preloadedState,
|
|
2696
|
-
breakpoints
|
|
3332
|
+
breakpoints,
|
|
3333
|
+
locales
|
|
2697
3334
|
} = {}) {
|
|
2698
3335
|
return createStore(reducer, __spreadProps(__spreadValues({}, preloadedState), {
|
|
2699
3336
|
documents: getInitialState$7({ rootElements }),
|
|
2700
|
-
breakpoints: getInitialState$
|
|
3337
|
+
breakpoints: getInitialState$9(breakpoints != null ? breakpoints : preloadedState == null ? void 0 : preloadedState.breakpoints),
|
|
3338
|
+
locales: getInitialState(locales != null ? locales : preloadedState == null ? void 0 : preloadedState.locales)
|
|
2701
3339
|
}), applyMiddleware(thunk));
|
|
2702
3340
|
}
|
|
2703
|
-
export {
|
|
3341
|
+
export { getBoxShadowsSwatchIds as $, ResponsiveLength as A, Backgrounds as B, ComponentIcon as C, Date as D, ElementID as E, Font as F, GapY as G, TextArea as H, Images as I, Table as J, TableFormFields as K, ListControlType as L, Margin as M, Number as N, Image as O, Padding as P, ResponsiveOpacity as Q, RichTextPropControllerMessageType as R, ShapeControlType as S, TableFormFieldsMessageType as T, NavigationLinks as U, SocialLinks as V, Width as W, RichText as X, Video as Y, getBorderSwatchIds as Z, isNonNullable as _, createDocumentReference as a, toSelectionDTO as a$, getResponsiveColorSwatchIds as a0, StyleControlProperty as a1, ImageControlValueFormat as a2, isPropControllersHandle as a3, StyleControlType as a4, RichTextV2ControlType as a5, RichTextControlType as a6, SlotControlType as a7, LinkControlType as a8, ImageControlType as a9, copyImageData as aA, Link$1 as aB, copyLinkData as aC, List$1 as aD, ListControlMessageType as aE, ListControl as aF, copyListData as aG, Select as aH, Shape$1 as aI, ShapeControlMessageType as aJ, ShapeControl as aK, copyShapeData as aL, Slot as aM, SlotControlMessageType as aN, SlotControl as aO, copySlotData as aP, mergeSlotData as aQ, Style as aR, StyleControlMessageType as aS, StyleControl as aT, copyStyleData as aU, ObjectType as aV, RichText$1 as aW, RichTextControlMessageType as aX, RichTextControl as aY, richTextDTOtoSelection as aZ, richTextDTOtoDAO as a_, ColorControlType as aa, SelectControlType as ab, getComponentPropControllerDescriptors as ac, getPropControllers as ad, BorderPropControllerFormat as ae, ShadowsPropControllerFormat as af, BorderRadiusPropControllerFormat as ag, MarginPropControllerFormat as ah, PaddingPropControllerFormat as ai, WidthPropControllerFormat as aj, configureStore as ak, copyElementTree as al, getBreakpoints as am, getDocument as an, getElementId as ao, getIsPreview as ap, getIsInBuilder as aq, getReactComponent as ar, getBuilderEditMode as as, getBackgroundsFileIds as at, getBackgroundsSwatchIds as au, Color as av, copyColorData as aw, copy as ax, merge as ay, Image$1 as az, isElementReference as b, richTextDAOToDTO as b0, RichTextV2Mode as b1, createRichTextV2Plugin as b2, unstable_RichTextV2 as b3, RichTextV2ControlMessageType as b4, RichTextV2Control as b5, BlockActions as b6, ListActions as b7, onKeyDown as b8, withBlock as b9, reducer$1 as bA, getInitialState$2 as bB, BlockPlugin as ba, RootBlockType as bb, BlockType as bc, InlineType as bd, BlockTextAlignment as be, ElementUtils as bf, getInitialState$7 as bg, reducer$8 as bh, getDocument$1 as bi, getComponentsMeta as bj, getComponentPropControllerDescriptors$1 as bk, getLocales as bl, BuilderEditMode as bm, getDocumentKeysSortedByDepth as bn, getPropController as bo, getPropControllersHandle as bp, getElement as bq, getElementPropControllerDescriptors as br, createPropController as bs, reducer$7 as bt, reducer$9 as bu, reducer$6 as bv, reducer$5 as bw, reducer$4 as bx, reducer$3 as by, reducer$2 as bz, createDocument as c, descriptors as d, getElementSwatchIds as e, getFileIds as f, getPropControllerDescriptors as g, getTypographyIds as h, introspection as i, getTableIds as j, getPageIds as k, getElementChildren as l, Types as m, ResponsiveIconRadioGroup as n, Border as o, BorderRadius as p, Shadows as q, GapX as r, ResponsiveSelect as s, ResponsiveNumber as t, Checkbox as u, Grid as v, TextInput as w, Link as x, ResponsiveColor as y, TextStyle as z };
|
|
2704
3342
|
//# sourceMappingURL=react-page.es.js.map
|