@elementor/editor-default-styles 4.3.0-1049 → 4.3.0-1051
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/index.d.mts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +169 -311
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +180 -327
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/{default-styles-panel-content.tsx → default-styles-tab-embedded.tsx} +28 -40
- package/src/index.ts +1 -0
- package/src/init.ts +7 -18
- package/src/store.ts +3 -4
- package/src/default-styles-open-gate.tsx +0 -99
- package/src/default-styles-panel.tsx +0 -32
- package/src/hooks/use-default-styles-action-props.ts +0 -15
- package/src/panel-interactions.ts +0 -24
package/dist/index.mjs
CHANGED
|
@@ -1,18 +1,56 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// src/components/default-styles-tab-embedded.tsx
|
|
2
|
+
import * as React3 from "react";
|
|
3
|
+
import { useCallback, useEffect, useMemo, useState as useState2 } from "react";
|
|
4
|
+
import {
|
|
5
|
+
ControlActionsProvider,
|
|
6
|
+
ControlReplacementsProvider,
|
|
7
|
+
getControlReplacements
|
|
8
|
+
} from "@elementor/editor-controls";
|
|
9
|
+
import {
|
|
10
|
+
ClassesPropProvider,
|
|
11
|
+
CreatableAutocomplete,
|
|
12
|
+
ElementProvider,
|
|
13
|
+
SectionsList,
|
|
14
|
+
StyleInheritanceProvider,
|
|
15
|
+
StyleProvider,
|
|
16
|
+
StyleSections
|
|
17
|
+
} from "@elementor/editor-editing-panel";
|
|
18
|
+
import { useActiveBreakpoint } from "@elementor/editor-responsive";
|
|
19
|
+
import { SaveChangesDialog, ThemeProvider, useDialog } from "@elementor/editor-ui";
|
|
20
|
+
import { controlActionsMenu } from "@elementor/menus";
|
|
21
|
+
import { useMutation } from "@elementor/query";
|
|
22
|
+
import { getSessionStorageItem, SessionStorageProvider, setSessionStorageItem } from "@elementor/session";
|
|
23
|
+
import { __dispatch as dispatch2, __useSelector as useSelector } from "@elementor/store";
|
|
24
|
+
import {
|
|
25
|
+
Box,
|
|
26
|
+
Button,
|
|
27
|
+
ErrorBoundary,
|
|
28
|
+
FormControl,
|
|
29
|
+
FormLabel,
|
|
30
|
+
Stack as Stack2
|
|
31
|
+
} from "@elementor/ui";
|
|
32
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
8
33
|
|
|
9
|
-
// src/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
34
|
+
// src/allowed-tags.ts
|
|
35
|
+
var getElementorConfig = () => window.elementor?.config ?? {};
|
|
36
|
+
var getAllowedDefaultStyleTags = () => {
|
|
37
|
+
const tags = getElementorConfig().atomic?.default_styles?.allowed_tags;
|
|
38
|
+
if (!tags?.length) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
return tags;
|
|
42
|
+
};
|
|
43
|
+
var getDefaultActiveTag = (tags) => {
|
|
44
|
+
if (tags.includes("h1")) {
|
|
45
|
+
return "h1";
|
|
46
|
+
}
|
|
47
|
+
return tags[0] ?? "";
|
|
48
|
+
};
|
|
49
|
+
var isAllowedDefaultStyleTag = (tag, tags = getAllowedDefaultStyleTags()) => tags.includes(tag);
|
|
13
50
|
|
|
14
|
-
// src/
|
|
15
|
-
import { __dispatch as dispatch } from "@elementor/store";
|
|
51
|
+
// src/save-default-styles.ts
|
|
52
|
+
import { __dispatch as dispatch, __getState as getState } from "@elementor/store";
|
|
53
|
+
import { hash } from "@elementor/utils";
|
|
16
54
|
|
|
17
55
|
// src/api.ts
|
|
18
56
|
import { httpService } from "@elementor/http-client";
|
|
@@ -78,8 +116,7 @@ var slice = createSlice({
|
|
|
78
116
|
if (mode === "replace") {
|
|
79
117
|
variant.props = payloadProps;
|
|
80
118
|
} else {
|
|
81
|
-
|
|
82
|
-
variant.props = { ...variantProps, ...payloadProps };
|
|
119
|
+
variant.props = { ...variant.props, ...payloadProps };
|
|
83
120
|
}
|
|
84
121
|
variant.custom_css = customCss;
|
|
85
122
|
} else {
|
|
@@ -93,11 +130,11 @@ var slice = createSlice({
|
|
|
93
130
|
state.isDirty = true;
|
|
94
131
|
},
|
|
95
132
|
reset(state) {
|
|
96
|
-
state.data =
|
|
133
|
+
state.data = state.initialData;
|
|
97
134
|
state.isDirty = false;
|
|
98
135
|
},
|
|
99
136
|
commit(state) {
|
|
100
|
-
state.initialData =
|
|
137
|
+
state.initialData = state.data;
|
|
101
138
|
state.isDirty = false;
|
|
102
139
|
},
|
|
103
140
|
deleteTag(state, { payload }) {
|
|
@@ -123,119 +160,7 @@ var selectTagStyle = createSelector(
|
|
|
123
160
|
(data, id) => data[id]
|
|
124
161
|
);
|
|
125
162
|
|
|
126
|
-
// src/load-default-styles.ts
|
|
127
|
-
async function loadDefaultStyles() {
|
|
128
|
-
const response = await apiClient.all();
|
|
129
|
-
const items = response.data.data;
|
|
130
|
-
dispatch(
|
|
131
|
-
slice.actions.load({
|
|
132
|
-
data: items
|
|
133
|
-
})
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// src/components/populate-store.tsx
|
|
138
|
-
var V2_PANEL_ROUTE = "panel/v2";
|
|
139
|
-
function PopulateStore() {
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
void loadDefaultStyles();
|
|
142
|
-
registerDataHook("after", "editor/documents/attach-preview", async () => {
|
|
143
|
-
if (selectIsDirty(getState())) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
await loadDefaultStyles();
|
|
147
|
-
});
|
|
148
|
-
const unsubscribe = listenTo(routeCloseEvent(V2_PANEL_ROUTE), () => {
|
|
149
|
-
if (selectIsDirty(getState())) {
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
void loadDefaultStyles();
|
|
153
|
-
});
|
|
154
|
-
return unsubscribe;
|
|
155
|
-
}, []);
|
|
156
|
-
return null;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// src/default-styles-open-gate.tsx
|
|
160
|
-
import * as React5 from "react";
|
|
161
|
-
import { useCallback as useCallback2, useEffect as useEffect3, useRef } from "react";
|
|
162
|
-
import {
|
|
163
|
-
__useActiveDocument as useActiveDocument,
|
|
164
|
-
__useActiveDocumentActions as useActiveDocumentActions
|
|
165
|
-
} from "@elementor/editor-documents";
|
|
166
|
-
import { SaveChangesDialog as SaveChangesDialog2, ThemeProvider as ThemeProvider2, useDialog as useDialog2 } from "@elementor/editor-ui";
|
|
167
|
-
import { __ as __3 } from "@wordpress/i18n";
|
|
168
|
-
|
|
169
|
-
// src/default-styles-panel.tsx
|
|
170
|
-
import * as React4 from "react";
|
|
171
|
-
import { __createPanel as createPanel } from "@elementor/editor-panels";
|
|
172
|
-
import { changeEditMode } from "@elementor/editor-v1-adapters";
|
|
173
|
-
|
|
174
|
-
// src/components/default-styles-panel-content.tsx
|
|
175
|
-
import * as React3 from "react";
|
|
176
|
-
import { useCallback, useEffect as useEffect2, useMemo, useState as useState2 } from "react";
|
|
177
|
-
import {
|
|
178
|
-
ControlActionsProvider,
|
|
179
|
-
ControlReplacementsProvider,
|
|
180
|
-
getControlReplacements
|
|
181
|
-
} from "@elementor/editor-controls";
|
|
182
|
-
import {
|
|
183
|
-
ClassesPropProvider,
|
|
184
|
-
CreatableAutocomplete,
|
|
185
|
-
ElementProvider,
|
|
186
|
-
SectionsList,
|
|
187
|
-
StyleInheritanceProvider,
|
|
188
|
-
StyleProvider,
|
|
189
|
-
StyleSections
|
|
190
|
-
} from "@elementor/editor-editing-panel";
|
|
191
|
-
import { Panel, PanelBody, PanelFooter, PanelHeader, PanelHeaderTitle } from "@elementor/editor-panels";
|
|
192
|
-
import { useActiveBreakpoint } from "@elementor/editor-responsive";
|
|
193
|
-
import { SaveChangesDialog, ThemeProvider, useDialog } from "@elementor/editor-ui";
|
|
194
|
-
import { controlActionsMenu } from "@elementor/menus";
|
|
195
|
-
import { useMutation } from "@elementor/query";
|
|
196
|
-
import { getSessionStorageItem, SessionStorageProvider, setSessionStorageItem } from "@elementor/session";
|
|
197
|
-
import { __dispatch as dispatch3, __useSelector as useSelector } from "@elementor/store";
|
|
198
|
-
import {
|
|
199
|
-
Box,
|
|
200
|
-
Button,
|
|
201
|
-
CloseButton,
|
|
202
|
-
ErrorBoundary,
|
|
203
|
-
FormControl,
|
|
204
|
-
FormLabel,
|
|
205
|
-
Stack as Stack2
|
|
206
|
-
} from "@elementor/ui";
|
|
207
|
-
import { __ as __2 } from "@wordpress/i18n";
|
|
208
|
-
|
|
209
|
-
// src/allowed-tags.ts
|
|
210
|
-
var getElementorConfig = () => window.elementor?.config ?? {};
|
|
211
|
-
var getAllowedDefaultStyleTags = () => {
|
|
212
|
-
const tags = getElementorConfig().atomic?.default_styles?.allowed_tags;
|
|
213
|
-
if (!tags?.length) {
|
|
214
|
-
return [];
|
|
215
|
-
}
|
|
216
|
-
return tags;
|
|
217
|
-
};
|
|
218
|
-
var getDefaultActiveTag = (tags) => {
|
|
219
|
-
if (tags.includes("h1")) {
|
|
220
|
-
return "h1";
|
|
221
|
-
}
|
|
222
|
-
return tags[0] ?? "";
|
|
223
|
-
};
|
|
224
|
-
var isAllowedDefaultStyleTag = (tag, tags = getAllowedDefaultStyleTags()) => tags.includes(tag);
|
|
225
|
-
|
|
226
|
-
// src/panel-interactions.ts
|
|
227
|
-
function blockPanelInteractions() {
|
|
228
|
-
const extendedWindow = window;
|
|
229
|
-
extendedWindow.$e?.components?.get?.("panel")?.blockUserInteractions?.();
|
|
230
|
-
}
|
|
231
|
-
function unblockPanelInteractions() {
|
|
232
|
-
const extendedWindow = window;
|
|
233
|
-
extendedWindow.$e?.components?.get?.("panel")?.unblockUserInteractions?.();
|
|
234
|
-
}
|
|
235
|
-
|
|
236
163
|
// src/save-default-styles.ts
|
|
237
|
-
import { __dispatch as dispatch2, __getState as getState2 } from "@elementor/store";
|
|
238
|
-
import { hash } from "@elementor/utils";
|
|
239
164
|
function getChangedTags(state) {
|
|
240
165
|
const current = selectData(state);
|
|
241
166
|
const initial = selectInitialData(state);
|
|
@@ -255,7 +180,7 @@ function getChangedTags(state) {
|
|
|
255
180
|
return changed;
|
|
256
181
|
}
|
|
257
182
|
async function saveDefaultStyles() {
|
|
258
|
-
const state =
|
|
183
|
+
const state = getState();
|
|
259
184
|
if (!selectIsDirty(state)) {
|
|
260
185
|
return;
|
|
261
186
|
}
|
|
@@ -271,7 +196,7 @@ async function saveDefaultStyles() {
|
|
|
271
196
|
await apiClient.put(tag, style.variants);
|
|
272
197
|
})
|
|
273
198
|
);
|
|
274
|
-
|
|
199
|
+
dispatch(slice.actions.commit());
|
|
275
200
|
}
|
|
276
201
|
|
|
277
202
|
// src/components/tag-chip.tsx
|
|
@@ -387,7 +312,7 @@ function TagChip({ label, chipProps, activeState, onSelectState }) {
|
|
|
387
312
|
));
|
|
388
313
|
}
|
|
389
314
|
|
|
390
|
-
// src/components/default-styles-
|
|
315
|
+
// src/components/default-styles-tab-embedded.tsx
|
|
391
316
|
var { useMenuItems } = controlActionsMenu;
|
|
392
317
|
var SHIM_ELEMENT_ID = "default-styles-editor-shim";
|
|
393
318
|
var SHIM_CLASSES_PROP = "__default_styles_classes__";
|
|
@@ -415,7 +340,7 @@ var shimElementType = {
|
|
|
415
340
|
propsSchema: {},
|
|
416
341
|
title: __2("Default Style", "elementor")
|
|
417
342
|
};
|
|
418
|
-
function
|
|
343
|
+
function DefaultStylesTabEmbedded({ onRequestClose, onExposeCloseAttempt }) {
|
|
419
344
|
const allowedTags = useMemo(() => getAllowedDefaultStyleTags(), []);
|
|
420
345
|
const tagOptions = useMemo(
|
|
421
346
|
() => allowedTags.map((tag) => ({ label: tag, value: tag })),
|
|
@@ -438,14 +363,15 @@ function DefaultStylesPanelContent({ onRequestClose }) {
|
|
|
438
363
|
openSaveChangesDialog();
|
|
439
364
|
return;
|
|
440
365
|
}
|
|
441
|
-
onRequestClose();
|
|
366
|
+
void onRequestClose();
|
|
442
367
|
}, [isDirty, onRequestClose, openSaveChangesDialog]);
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
368
|
+
useEffect(() => {
|
|
369
|
+
if (!onExposeCloseAttempt) {
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
onExposeCloseAttempt(() => handleClosePanel());
|
|
373
|
+
return () => onExposeCloseAttempt(null);
|
|
374
|
+
}, [onExposeCloseAttempt, handleClosePanel]);
|
|
449
375
|
usePreventUnload(isDirty);
|
|
450
376
|
const handleTagSelect = (_selected, reason, option) => {
|
|
451
377
|
if (reason !== "selectOption" || !option.value) {
|
|
@@ -455,9 +381,9 @@ function DefaultStylesPanelContent({ onRequestClose }) {
|
|
|
455
381
|
setActiveStyleState(null);
|
|
456
382
|
};
|
|
457
383
|
const resetAndClosePanel = () => {
|
|
458
|
-
|
|
384
|
+
dispatch2(slice.actions.reset());
|
|
459
385
|
closeSaveChangesDialog();
|
|
460
|
-
onRequestClose();
|
|
386
|
+
void onRequestClose();
|
|
461
387
|
};
|
|
462
388
|
const handleSaveAndContinue = async () => {
|
|
463
389
|
try {
|
|
@@ -466,89 +392,82 @@ function DefaultStylesPanelContent({ onRequestClose }) {
|
|
|
466
392
|
return;
|
|
467
393
|
}
|
|
468
394
|
closeSaveChangesDialog();
|
|
469
|
-
onRequestClose();
|
|
395
|
+
void onRequestClose();
|
|
470
396
|
};
|
|
471
|
-
return /* @__PURE__ */ React3.createElement(ErrorBoundary, { fallback: null }, /* @__PURE__ */ React3.createElement(ThemeProvider, null, /* @__PURE__ */ React3.createElement(ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React3.createElement(ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React3.createElement(
|
|
397
|
+
return /* @__PURE__ */ React3.createElement(ErrorBoundary, { fallback: null }, /* @__PURE__ */ React3.createElement(ThemeProvider, null, /* @__PURE__ */ React3.createElement(ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React3.createElement(ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React3.createElement(
|
|
472
398
|
Stack2,
|
|
473
399
|
{
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
400
|
+
sx: {
|
|
401
|
+
flex: 1,
|
|
402
|
+
minHeight: 0,
|
|
403
|
+
overflow: "hidden",
|
|
404
|
+
display: "flex",
|
|
405
|
+
flexDirection: "column"
|
|
406
|
+
}
|
|
481
407
|
},
|
|
482
|
-
/* @__PURE__ */ React3.createElement(
|
|
483
|
-
|
|
484
|
-
CloseButton,
|
|
408
|
+
/* @__PURE__ */ React3.createElement(Box, { sx: { flex: 1, minHeight: 0, overflow: "auto" } }, /* @__PURE__ */ React3.createElement(Stack2, { sx: { px: 2, pt: 1, gap: 1 } }, /* @__PURE__ */ React3.createElement(FormControl, { fullWidth: true, size: "small" }, /* @__PURE__ */ React3.createElement(FormLabel, { htmlFor: TAG_SELECTOR_ID, size: "small", sx: { mb: 1 } }, __2("Tag", "elementor")), /* @__PURE__ */ React3.createElement(
|
|
409
|
+
CreatableAutocomplete,
|
|
485
410
|
{
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
411
|
+
id: TAG_SELECTOR_ID,
|
|
412
|
+
size: "tiny",
|
|
413
|
+
placeholder: __2("Type tag name", "elementor"),
|
|
414
|
+
options: tagOptions,
|
|
415
|
+
selected: [toTagChip(selectedTag)],
|
|
416
|
+
onSelect: handleTagSelect,
|
|
417
|
+
renderTags: (values, getTagProps) => values.map((value, index) => /* @__PURE__ */ React3.createElement(
|
|
418
|
+
TagChip,
|
|
419
|
+
{
|
|
420
|
+
key: value.value ?? value.label,
|
|
421
|
+
label: value.label,
|
|
422
|
+
chipProps: getTagProps({ index }),
|
|
423
|
+
activeState: activeStyleState,
|
|
424
|
+
onSelectState: setActiveStyleState
|
|
425
|
+
}
|
|
426
|
+
))
|
|
489
427
|
}
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
CreatableAutocomplete,
|
|
493
|
-
{
|
|
494
|
-
id: TAG_SELECTOR_ID,
|
|
495
|
-
size: "tiny",
|
|
496
|
-
placeholder: __2("Type tag name", "elementor"),
|
|
497
|
-
options: tagOptions,
|
|
498
|
-
selected: [toTagChip(selectedTag)],
|
|
499
|
-
onSelect: handleTagSelect,
|
|
500
|
-
renderTags: (values, getTagProps) => values.map((value, index) => /* @__PURE__ */ React3.createElement(
|
|
501
|
-
TagChip,
|
|
502
|
-
{
|
|
503
|
-
key: value.value ?? value.label,
|
|
504
|
-
label: value.label,
|
|
505
|
-
chipProps: getTagProps({ index }),
|
|
506
|
-
activeState: activeStyleState,
|
|
507
|
-
onSelectState: setActiveStyleState
|
|
508
|
-
}
|
|
509
|
-
))
|
|
510
|
-
}
|
|
511
|
-
))), /* @__PURE__ */ React3.createElement(
|
|
512
|
-
ElementProvider,
|
|
513
|
-
{
|
|
514
|
-
element: shimElement,
|
|
515
|
-
elementType: shimElementType,
|
|
516
|
-
settings: {}
|
|
517
|
-
},
|
|
518
|
-
/* @__PURE__ */ React3.createElement(ClassesPropProvider, { prop: SHIM_CLASSES_PROP }, /* @__PURE__ */ React3.createElement(
|
|
519
|
-
StyleProvider,
|
|
428
|
+
))), /* @__PURE__ */ React3.createElement(
|
|
429
|
+
ElementProvider,
|
|
520
430
|
{
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
id: selectedTag,
|
|
526
|
-
setId: () => {
|
|
527
|
-
},
|
|
528
|
-
setMetaState: setActiveStyleState
|
|
431
|
+
element: shimElement,
|
|
432
|
+
elementType: shimElementType,
|
|
433
|
+
settings: {}
|
|
529
434
|
},
|
|
530
|
-
/* @__PURE__ */ React3.createElement(
|
|
531
|
-
|
|
435
|
+
/* @__PURE__ */ React3.createElement(ClassesPropProvider, { prop: SHIM_CLASSES_PROP }, /* @__PURE__ */ React3.createElement(
|
|
436
|
+
StyleProvider,
|
|
532
437
|
{
|
|
533
|
-
|
|
534
|
-
|
|
438
|
+
meta: {
|
|
439
|
+
breakpoint,
|
|
440
|
+
state: activeStyleState
|
|
441
|
+
},
|
|
442
|
+
id: selectedTag,
|
|
443
|
+
setId: () => {
|
|
444
|
+
},
|
|
445
|
+
setMetaState: setActiveStyleState
|
|
446
|
+
},
|
|
447
|
+
/* @__PURE__ */ React3.createElement(SessionStorageProvider, { prefix: selectedTag }, /* @__PURE__ */ React3.createElement(StyleInheritanceProvider, null, /* @__PURE__ */ React3.createElement(SectionsList, null, /* @__PURE__ */ React3.createElement(StyleSections, null)), /* @__PURE__ */ React3.createElement(
|
|
448
|
+
Box,
|
|
449
|
+
{
|
|
450
|
+
sx: {
|
|
451
|
+
height: "150px"
|
|
452
|
+
}
|
|
535
453
|
}
|
|
536
|
-
|
|
537
|
-
))
|
|
454
|
+
)))
|
|
455
|
+
))
|
|
456
|
+
)),
|
|
457
|
+
/* @__PURE__ */ React3.createElement(Box, { sx: { flexShrink: 0, px: 2, py: 1.5 } }, /* @__PURE__ */ React3.createElement(
|
|
458
|
+
Button,
|
|
459
|
+
{
|
|
460
|
+
fullWidth: true,
|
|
461
|
+
size: "small",
|
|
462
|
+
color: "global",
|
|
463
|
+
variant: "contained",
|
|
464
|
+
onClick: () => void save(),
|
|
465
|
+
disabled: !isDirty,
|
|
466
|
+
loading: isSaving
|
|
467
|
+
},
|
|
468
|
+
__2("Save changes", "elementor")
|
|
538
469
|
))
|
|
539
|
-
)), /* @__PURE__ */ React3.createElement(
|
|
540
|
-
Button,
|
|
541
|
-
{
|
|
542
|
-
fullWidth: true,
|
|
543
|
-
size: "small",
|
|
544
|
-
color: "global",
|
|
545
|
-
variant: "contained",
|
|
546
|
-
onClick: () => void save(),
|
|
547
|
-
disabled: !isDirty,
|
|
548
|
-
loading: isSaving
|
|
549
|
-
},
|
|
550
|
-
__2("Save changes", "elementor")
|
|
551
|
-
))))), isSaveChangesDialogOpen && /* @__PURE__ */ React3.createElement(SaveChangesDialog, null, /* @__PURE__ */ React3.createElement(SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, __2("You have unsaved changes", "elementor")), /* @__PURE__ */ React3.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React3.createElement(SaveChangesDialog.ContentText, null, __2("You have unsaved changes in Default Styles.", "elementor")), /* @__PURE__ */ React3.createElement(SaveChangesDialog.ContentText, null, __2("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React3.createElement(
|
|
470
|
+
))), isSaveChangesDialogOpen && /* @__PURE__ */ React3.createElement(SaveChangesDialog, null, /* @__PURE__ */ React3.createElement(SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, __2("You have unsaved changes", "elementor")), /* @__PURE__ */ React3.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React3.createElement(SaveChangesDialog.ContentText, null, __2("You have unsaved changes in Default Styles.", "elementor")), /* @__PURE__ */ React3.createElement(SaveChangesDialog.ContentText, null, __2("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React3.createElement(
|
|
552
471
|
SaveChangesDialog.Actions,
|
|
553
472
|
{
|
|
554
473
|
actions: {
|
|
@@ -570,7 +489,7 @@ function useSave() {
|
|
|
570
489
|
});
|
|
571
490
|
}
|
|
572
491
|
function usePreventUnload(isDirty) {
|
|
573
|
-
|
|
492
|
+
useEffect(() => {
|
|
574
493
|
const handleBeforeUnload = (event) => {
|
|
575
494
|
if (isDirty) {
|
|
576
495
|
event.preventDefault();
|
|
@@ -583,98 +502,50 @@ function usePreventUnload(isDirty) {
|
|
|
583
502
|
}, [isDirty]);
|
|
584
503
|
}
|
|
585
504
|
|
|
586
|
-
// src/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
}
|
|
600
|
-
function
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
{
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
}
|
|
505
|
+
// src/init.ts
|
|
506
|
+
import { injectIntoLogic } from "@elementor/editor";
|
|
507
|
+
import { registerElementPanelDefaults, STYLE_SECTION_NAMES } from "@elementor/editor-editing-panel";
|
|
508
|
+
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
509
|
+
import { isExperimentActive } from "@elementor/editor-v1-adapters";
|
|
510
|
+
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
511
|
+
|
|
512
|
+
// src/components/populate-store.tsx
|
|
513
|
+
import { useEffect as useEffect2 } from "react";
|
|
514
|
+
import { __privateListenTo as listenTo, registerDataHook, routeCloseEvent } from "@elementor/editor-v1-adapters";
|
|
515
|
+
import { __getState as getState2 } from "@elementor/store";
|
|
516
|
+
|
|
517
|
+
// src/load-default-styles.ts
|
|
518
|
+
import { __dispatch as dispatch3 } from "@elementor/store";
|
|
519
|
+
async function loadDefaultStyles() {
|
|
520
|
+
const response = await apiClient.all();
|
|
521
|
+
const items = response.data.data;
|
|
522
|
+
dispatch3(
|
|
523
|
+
slice.actions.load({
|
|
524
|
+
data: items
|
|
525
|
+
})
|
|
609
526
|
);
|
|
610
527
|
}
|
|
611
528
|
|
|
612
|
-
// src/
|
|
613
|
-
var
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const documentRef = useRef(document);
|
|
620
|
-
documentRef.current = document;
|
|
621
|
-
const pendingOpenRef = useRef(null);
|
|
622
|
-
const gatedOpen = useCallback2(
|
|
623
|
-
(onClean) => {
|
|
624
|
-
if (documentRef.current?.isDirty) {
|
|
625
|
-
pendingOpenRef.current = onClean;
|
|
626
|
-
openSaveDialog();
|
|
529
|
+
// src/components/populate-store.tsx
|
|
530
|
+
var V2_PANEL_ROUTE = "panel/v2";
|
|
531
|
+
function PopulateStore() {
|
|
532
|
+
useEffect2(() => {
|
|
533
|
+
void loadDefaultStyles();
|
|
534
|
+
registerDataHook("after", "editor/documents/attach-preview", async () => {
|
|
535
|
+
if (selectIsDirty(getState2())) {
|
|
627
536
|
return;
|
|
628
537
|
}
|
|
629
|
-
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
try {
|
|
635
|
-
await saveDocument();
|
|
636
|
-
closeSaveDialog();
|
|
637
|
-
pendingOpenRef.current?.();
|
|
638
|
-
pendingOpenRef.current = null;
|
|
639
|
-
} catch {
|
|
640
|
-
}
|
|
641
|
-
}, [saveDocument, closeSaveDialog]);
|
|
642
|
-
const handleStayHere = useCallback2(() => {
|
|
643
|
-
closeSaveDialog();
|
|
644
|
-
pendingOpenRef.current = null;
|
|
645
|
-
}, [closeSaveDialog]);
|
|
646
|
-
useEffect3(() => {
|
|
647
|
-
const handler = () => {
|
|
648
|
-
gatedOpen(() => {
|
|
649
|
-
void open();
|
|
650
|
-
});
|
|
651
|
-
};
|
|
652
|
-
window.addEventListener(EVENT_REQUEST_OPEN_DEFAULT_STYLES, handler);
|
|
653
|
-
return () => {
|
|
654
|
-
window.removeEventListener(EVENT_REQUEST_OPEN_DEFAULT_STYLES, handler);
|
|
655
|
-
};
|
|
656
|
-
}, [gatedOpen, open]);
|
|
657
|
-
if (!isSaveDialogOpen) {
|
|
658
|
-
return null;
|
|
659
|
-
}
|
|
660
|
-
return /* @__PURE__ */ React5.createElement(ThemeProvider2, null, /* @__PURE__ */ React5.createElement(SaveChangesDialog2, null, /* @__PURE__ */ React5.createElement(SaveChangesDialog2.Title, null, __3("You have unsaved changes", "elementor")), /* @__PURE__ */ React5.createElement(SaveChangesDialog2.Content, null, /* @__PURE__ */ React5.createElement(SaveChangesDialog2.ContentText, { sx: { mb: 2 } }, __3(
|
|
661
|
-
"To open Default Styles, save your page first. You can't continue without saving.",
|
|
662
|
-
"elementor"
|
|
663
|
-
))), /* @__PURE__ */ React5.createElement(
|
|
664
|
-
SaveChangesDialog2.Actions,
|
|
665
|
-
{
|
|
666
|
-
actions: {
|
|
667
|
-
cancel: {
|
|
668
|
-
label: __3("Stay here", "elementor"),
|
|
669
|
-
action: handleStayHere
|
|
670
|
-
},
|
|
671
|
-
confirm: {
|
|
672
|
-
label: __3("Save & Continue", "elementor"),
|
|
673
|
-
action: handleSaveAndContinue
|
|
674
|
-
}
|
|
538
|
+
await loadDefaultStyles();
|
|
539
|
+
});
|
|
540
|
+
const unsubscribe = listenTo(routeCloseEvent(V2_PANEL_ROUTE), () => {
|
|
541
|
+
if (selectIsDirty(getState2())) {
|
|
542
|
+
return;
|
|
675
543
|
}
|
|
676
|
-
|
|
677
|
-
|
|
544
|
+
void loadDefaultStyles();
|
|
545
|
+
});
|
|
546
|
+
return unsubscribe;
|
|
547
|
+
}, []);
|
|
548
|
+
return null;
|
|
678
549
|
}
|
|
679
550
|
|
|
680
551
|
// src/default-styles-provider.ts
|
|
@@ -684,7 +555,7 @@ import {
|
|
|
684
555
|
__getState as getState3,
|
|
685
556
|
__subscribeWithSelector as subscribeWithSelector
|
|
686
557
|
} from "@elementor/store";
|
|
687
|
-
import { __ as
|
|
558
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
688
559
|
var DEFAULT_STYLES_PROVIDER_KEY = "default-styles";
|
|
689
560
|
var DEFAULT_STYLES_CSS_NAME_PREFIX = "e-default-";
|
|
690
561
|
var resolveCssName = (id) => `${DEFAULT_STYLES_CSS_NAME_PREFIX}${id}`;
|
|
@@ -702,8 +573,8 @@ var defaultStylesStylesProvider = createStylesProvider({
|
|
|
702
573
|
key: DEFAULT_STYLES_PROVIDER_KEY,
|
|
703
574
|
priority: 15,
|
|
704
575
|
labels: {
|
|
705
|
-
singular:
|
|
706
|
-
plural:
|
|
576
|
+
singular: __3("tag", "elementor"),
|
|
577
|
+
plural: __3("tags", "elementor")
|
|
707
578
|
},
|
|
708
579
|
subscribe: (cb) => subscribeWithStates(cb),
|
|
709
580
|
actions: {
|
|
@@ -759,21 +630,12 @@ var subscribeWithStates = (cb) => {
|
|
|
759
630
|
);
|
|
760
631
|
};
|
|
761
632
|
|
|
762
|
-
// src/hooks/use-default-styles-action-props.ts
|
|
763
|
-
import { TextIcon } from "@elementor/icons";
|
|
764
|
-
import { __ as __5 } from "@wordpress/i18n";
|
|
765
|
-
function useDefaultStylesActionProps() {
|
|
766
|
-
return {
|
|
767
|
-
title: __5("Default Styles", "elementor"),
|
|
768
|
-
icon: TextIcon,
|
|
769
|
-
onClick: () => {
|
|
770
|
-
window.dispatchEvent(new CustomEvent(EVENT_REQUEST_OPEN_DEFAULT_STYLES));
|
|
771
|
-
}
|
|
772
|
-
};
|
|
773
|
-
}
|
|
774
|
-
|
|
775
633
|
// src/init.ts
|
|
634
|
+
var DEFAULT_STYLES_EXPERIMENT = "e_default_styles";
|
|
776
635
|
function init() {
|
|
636
|
+
if (!isExperimentActive(DEFAULT_STYLES_EXPERIMENT)) {
|
|
637
|
+
return;
|
|
638
|
+
}
|
|
777
639
|
registerSlice(slice);
|
|
778
640
|
registerElementPanelDefaults("default-style", {
|
|
779
641
|
defaultTab: "style",
|
|
@@ -781,23 +643,14 @@ function init() {
|
|
|
781
643
|
style: [...STYLE_SECTION_NAMES]
|
|
782
644
|
}
|
|
783
645
|
});
|
|
784
|
-
registerPanel(panel);
|
|
785
646
|
stylesRepository.register(defaultStylesStylesProvider);
|
|
786
|
-
toolsMenu.registerAction({
|
|
787
|
-
id: "default-styles-button",
|
|
788
|
-
priority: 4,
|
|
789
|
-
useProps: useDefaultStylesActionProps
|
|
790
|
-
});
|
|
791
647
|
injectIntoLogic({
|
|
792
648
|
id: "default-styles-populate-store",
|
|
793
649
|
component: PopulateStore
|
|
794
650
|
});
|
|
795
|
-
injectIntoLogic({
|
|
796
|
-
id: "default-styles-open-gate",
|
|
797
|
-
component: DefaultStylesOpenGate
|
|
798
|
-
});
|
|
799
651
|
}
|
|
800
652
|
export {
|
|
653
|
+
DefaultStylesTabEmbedded,
|
|
801
654
|
init
|
|
802
655
|
};
|
|
803
656
|
//# sourceMappingURL=index.mjs.map
|