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