@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.d.mts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type DefaultStylesTabEmbeddedProps = {
|
|
4
|
+
onRequestClose: () => void | Promise<void>;
|
|
5
|
+
onExposeCloseAttempt?: (attemptClose: (() => void) | null) => void;
|
|
6
|
+
};
|
|
7
|
+
declare function DefaultStylesTabEmbedded({ onRequestClose, onExposeCloseAttempt }: DefaultStylesTabEmbeddedProps): React.JSX.Element;
|
|
8
|
+
|
|
1
9
|
declare function init(): void;
|
|
2
10
|
|
|
3
|
-
export { init };
|
|
11
|
+
export { DefaultStylesTabEmbedded, init };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
type DefaultStylesTabEmbeddedProps = {
|
|
4
|
+
onRequestClose: () => void | Promise<void>;
|
|
5
|
+
onExposeCloseAttempt?: (attemptClose: (() => void) | null) => void;
|
|
6
|
+
};
|
|
7
|
+
declare function DefaultStylesTabEmbedded({ onRequestClose, onExposeCloseAttempt }: DefaultStylesTabEmbeddedProps): React.JSX.Element;
|
|
8
|
+
|
|
1
9
|
declare function init(): void;
|
|
2
10
|
|
|
3
|
-
export { init };
|
|
11
|
+
export { DefaultStylesTabEmbedded, init };
|
package/dist/index.js
CHANGED
|
@@ -30,25 +30,45 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
DefaultStylesTabEmbedded: () => DefaultStylesTabEmbedded,
|
|
33
34
|
init: () => init
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(index_exports);
|
|
36
37
|
|
|
37
|
-
// src/
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
var
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
var
|
|
47
|
-
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
38
|
+
// src/components/default-styles-tab-embedded.tsx
|
|
39
|
+
var React3 = __toESM(require("react"));
|
|
40
|
+
var import_react2 = require("react");
|
|
41
|
+
var import_editor_controls = require("@elementor/editor-controls");
|
|
42
|
+
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
43
|
+
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
44
|
+
var import_editor_ui = require("@elementor/editor-ui");
|
|
45
|
+
var import_menus = require("@elementor/menus");
|
|
46
|
+
var import_query = require("@elementor/query");
|
|
47
|
+
var import_session = require("@elementor/session");
|
|
48
48
|
var import_store4 = require("@elementor/store");
|
|
49
|
+
var import_ui3 = require("@elementor/ui");
|
|
50
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
49
51
|
|
|
50
|
-
// src/
|
|
52
|
+
// src/allowed-tags.ts
|
|
53
|
+
var getElementorConfig = () => window.elementor?.config ?? {};
|
|
54
|
+
var getAllowedDefaultStyleTags = () => {
|
|
55
|
+
const tags = getElementorConfig().atomic?.default_styles?.allowed_tags;
|
|
56
|
+
if (!tags?.length) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
return tags;
|
|
60
|
+
};
|
|
61
|
+
var getDefaultActiveTag = (tags) => {
|
|
62
|
+
if (tags.includes("h1")) {
|
|
63
|
+
return "h1";
|
|
64
|
+
}
|
|
65
|
+
return tags[0] ?? "";
|
|
66
|
+
};
|
|
67
|
+
var isAllowedDefaultStyleTag = (tag, tags = getAllowedDefaultStyleTags()) => tags.includes(tag);
|
|
68
|
+
|
|
69
|
+
// src/save-default-styles.ts
|
|
51
70
|
var import_store2 = require("@elementor/store");
|
|
71
|
+
var import_utils = require("@elementor/utils");
|
|
52
72
|
|
|
53
73
|
// src/api.ts
|
|
54
74
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -153,96 +173,7 @@ var selectTagStyle = (0, import_store.__createSelector)(
|
|
|
153
173
|
(data, id) => data[id]
|
|
154
174
|
);
|
|
155
175
|
|
|
156
|
-
// src/load-default-styles.ts
|
|
157
|
-
async function loadDefaultStyles() {
|
|
158
|
-
const response = await apiClient.all();
|
|
159
|
-
const items = response.data.data;
|
|
160
|
-
(0, import_store2.__dispatch)(
|
|
161
|
-
slice.actions.load({
|
|
162
|
-
data: items
|
|
163
|
-
})
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// src/components/populate-store.tsx
|
|
168
|
-
var V2_PANEL_ROUTE = "panel/v2";
|
|
169
|
-
function PopulateStore() {
|
|
170
|
-
(0, import_react.useEffect)(() => {
|
|
171
|
-
void loadDefaultStyles();
|
|
172
|
-
(0, import_editor_v1_adapters.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
173
|
-
if (selectIsDirty((0, import_store4.__getState)())) {
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
await loadDefaultStyles();
|
|
177
|
-
});
|
|
178
|
-
const unsubscribe = (0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL_ROUTE), () => {
|
|
179
|
-
if (selectIsDirty((0, import_store4.__getState)())) {
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
void loadDefaultStyles();
|
|
183
|
-
});
|
|
184
|
-
return unsubscribe;
|
|
185
|
-
}, []);
|
|
186
|
-
return null;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// src/default-styles-open-gate.tsx
|
|
190
|
-
var React5 = __toESM(require("react"));
|
|
191
|
-
var import_react4 = require("react");
|
|
192
|
-
var import_editor_documents = require("@elementor/editor-documents");
|
|
193
|
-
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
194
|
-
var import_i18n3 = require("@wordpress/i18n");
|
|
195
|
-
|
|
196
|
-
// src/default-styles-panel.tsx
|
|
197
|
-
var React4 = __toESM(require("react"));
|
|
198
|
-
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
199
|
-
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
200
|
-
|
|
201
|
-
// src/components/default-styles-panel-content.tsx
|
|
202
|
-
var React3 = __toESM(require("react"));
|
|
203
|
-
var import_react3 = require("react");
|
|
204
|
-
var import_editor_controls = require("@elementor/editor-controls");
|
|
205
|
-
var import_editor_editing_panel2 = require("@elementor/editor-editing-panel");
|
|
206
|
-
var import_editor_panels = require("@elementor/editor-panels");
|
|
207
|
-
var import_editor_responsive = require("@elementor/editor-responsive");
|
|
208
|
-
var import_editor_ui = require("@elementor/editor-ui");
|
|
209
|
-
var import_menus = require("@elementor/menus");
|
|
210
|
-
var import_query = require("@elementor/query");
|
|
211
|
-
var import_session = require("@elementor/session");
|
|
212
|
-
var import_store8 = require("@elementor/store");
|
|
213
|
-
var import_ui3 = require("@elementor/ui");
|
|
214
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
215
|
-
|
|
216
|
-
// src/allowed-tags.ts
|
|
217
|
-
var getElementorConfig = () => window.elementor?.config ?? {};
|
|
218
|
-
var getAllowedDefaultStyleTags = () => {
|
|
219
|
-
const tags = getElementorConfig().atomic?.default_styles?.allowed_tags;
|
|
220
|
-
if (!tags?.length) {
|
|
221
|
-
return [];
|
|
222
|
-
}
|
|
223
|
-
return tags;
|
|
224
|
-
};
|
|
225
|
-
var getDefaultActiveTag = (tags) => {
|
|
226
|
-
if (tags.includes("h1")) {
|
|
227
|
-
return "h1";
|
|
228
|
-
}
|
|
229
|
-
return tags[0] ?? "";
|
|
230
|
-
};
|
|
231
|
-
var isAllowedDefaultStyleTag = (tag, tags = getAllowedDefaultStyleTags()) => tags.includes(tag);
|
|
232
|
-
|
|
233
|
-
// src/panel-interactions.ts
|
|
234
|
-
function blockPanelInteractions() {
|
|
235
|
-
const extendedWindow = window;
|
|
236
|
-
extendedWindow.$e?.components?.get?.("panel")?.blockUserInteractions?.();
|
|
237
|
-
}
|
|
238
|
-
function unblockPanelInteractions() {
|
|
239
|
-
const extendedWindow = window;
|
|
240
|
-
extendedWindow.$e?.components?.get?.("panel")?.unblockUserInteractions?.();
|
|
241
|
-
}
|
|
242
|
-
|
|
243
176
|
// src/save-default-styles.ts
|
|
244
|
-
var import_store6 = require("@elementor/store");
|
|
245
|
-
var import_utils = require("@elementor/utils");
|
|
246
177
|
function getChangedTags(state) {
|
|
247
178
|
const current = selectData(state);
|
|
248
179
|
const initial = selectInitialData(state);
|
|
@@ -262,7 +193,7 @@ function getChangedTags(state) {
|
|
|
262
193
|
return changed;
|
|
263
194
|
}
|
|
264
195
|
async function saveDefaultStyles() {
|
|
265
|
-
const state = (0,
|
|
196
|
+
const state = (0, import_store2.__getState)();
|
|
266
197
|
if (!selectIsDirty(state)) {
|
|
267
198
|
return;
|
|
268
199
|
}
|
|
@@ -278,12 +209,12 @@ async function saveDefaultStyles() {
|
|
|
278
209
|
await apiClient.put(tag, style.variants);
|
|
279
210
|
})
|
|
280
211
|
);
|
|
281
|
-
(0,
|
|
212
|
+
(0, import_store2.__dispatch)(slice.actions.commit());
|
|
282
213
|
}
|
|
283
214
|
|
|
284
215
|
// src/components/tag-chip.tsx
|
|
285
216
|
var React2 = __toESM(require("react"));
|
|
286
|
-
var
|
|
217
|
+
var import_react = require("react");
|
|
287
218
|
var import_icons = require("@elementor/icons");
|
|
288
219
|
var import_ui2 = require("@elementor/ui");
|
|
289
220
|
var import_i18n = require("@wordpress/i18n");
|
|
@@ -322,7 +253,7 @@ function TagChip({ label, chipProps, activeState, onSelectState }) {
|
|
|
322
253
|
variant: "popover",
|
|
323
254
|
popupId: "tag-state-menu"
|
|
324
255
|
});
|
|
325
|
-
const [chipRef, setChipRef] = (0,
|
|
256
|
+
const [chipRef, setChipRef] = (0, import_react.useState)(null);
|
|
326
257
|
const { onDelete: _onDelete, ...chipGroupProps } = chipProps;
|
|
327
258
|
const isShowingState = Boolean(activeState);
|
|
328
259
|
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(
|
|
@@ -387,7 +318,7 @@ function TagChip({ label, chipProps, activeState, onSelectState }) {
|
|
|
387
318
|
));
|
|
388
319
|
}
|
|
389
320
|
|
|
390
|
-
// src/components/default-styles-
|
|
321
|
+
// src/components/default-styles-tab-embedded.tsx
|
|
391
322
|
var { useMenuItems } = import_menus.controlActionsMenu;
|
|
392
323
|
var SHIM_ELEMENT_ID = "default-styles-editor-shim";
|
|
393
324
|
var SHIM_CLASSES_PROP = "__default_styles_classes__";
|
|
@@ -415,37 +346,38 @@ var shimElementType = {
|
|
|
415
346
|
propsSchema: {},
|
|
416
347
|
title: (0, import_i18n2.__)("Default Style", "elementor")
|
|
417
348
|
};
|
|
418
|
-
function
|
|
419
|
-
const allowedTags = (0,
|
|
420
|
-
const tagOptions = (0,
|
|
349
|
+
function DefaultStylesTabEmbedded({ onRequestClose, onExposeCloseAttempt }) {
|
|
350
|
+
const allowedTags = (0, import_react2.useMemo)(() => getAllowedDefaultStyleTags(), []);
|
|
351
|
+
const tagOptions = (0, import_react2.useMemo)(
|
|
421
352
|
() => allowedTags.map((tag) => ({ label: tag, value: tag })),
|
|
422
353
|
[allowedTags]
|
|
423
354
|
);
|
|
424
|
-
const [selectedTag, setSelectedTagState] = (0,
|
|
425
|
-
const [activeStyleState, setActiveStyleState] = (0,
|
|
355
|
+
const [selectedTag, setSelectedTagState] = (0, import_react2.useState)(() => readStoredActiveTag(allowedTags));
|
|
356
|
+
const [activeStyleState, setActiveStyleState] = (0, import_react2.useState)(null);
|
|
426
357
|
const breakpoint = (0, import_editor_responsive.useActiveBreakpoint)();
|
|
427
358
|
const menuItems = useMenuItems().default;
|
|
428
359
|
const controlReplacements = (0, import_editor_controls.getControlReplacements)();
|
|
429
|
-
const isDirty = (0,
|
|
360
|
+
const isDirty = (0, import_store4.__useSelector)(selectIsDirty);
|
|
430
361
|
const { mutateAsync: save, isPending: isSaving } = useSave();
|
|
431
362
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = (0, import_editor_ui.useDialog)();
|
|
432
363
|
const setSelectedTag = (tag) => {
|
|
433
364
|
setSelectedTagState(tag);
|
|
434
365
|
(0, import_session.setSessionStorageItem)(LAST_ACTIVE_TAG_STORAGE_KEY, tag);
|
|
435
366
|
};
|
|
436
|
-
const handleClosePanel = (0,
|
|
367
|
+
const handleClosePanel = (0, import_react2.useCallback)(() => {
|
|
437
368
|
if (isDirty) {
|
|
438
369
|
openSaveChangesDialog();
|
|
439
370
|
return;
|
|
440
371
|
}
|
|
441
|
-
onRequestClose();
|
|
372
|
+
void onRequestClose();
|
|
442
373
|
}, [isDirty, onRequestClose, openSaveChangesDialog]);
|
|
443
|
-
(0,
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
374
|
+
(0, import_react2.useEffect)(() => {
|
|
375
|
+
if (!onExposeCloseAttempt) {
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
onExposeCloseAttempt(() => handleClosePanel());
|
|
379
|
+
return () => onExposeCloseAttempt(null);
|
|
380
|
+
}, [onExposeCloseAttempt, handleClosePanel]);
|
|
449
381
|
usePreventUnload(isDirty);
|
|
450
382
|
const handleTagSelect = (_selected, reason, option) => {
|
|
451
383
|
if (reason !== "selectOption" || !option.value) {
|
|
@@ -455,9 +387,9 @@ function DefaultStylesPanelContent({ onRequestClose }) {
|
|
|
455
387
|
setActiveStyleState(null);
|
|
456
388
|
};
|
|
457
389
|
const resetAndClosePanel = () => {
|
|
458
|
-
(0,
|
|
390
|
+
(0, import_store4.__dispatch)(slice.actions.reset());
|
|
459
391
|
closeSaveChangesDialog();
|
|
460
|
-
onRequestClose();
|
|
392
|
+
void onRequestClose();
|
|
461
393
|
};
|
|
462
394
|
const handleSaveAndContinue = async () => {
|
|
463
395
|
try {
|
|
@@ -466,89 +398,82 @@ function DefaultStylesPanelContent({ onRequestClose }) {
|
|
|
466
398
|
return;
|
|
467
399
|
}
|
|
468
400
|
closeSaveChangesDialog();
|
|
469
|
-
onRequestClose();
|
|
401
|
+
void onRequestClose();
|
|
470
402
|
};
|
|
471
|
-
return /* @__PURE__ */ React3.createElement(import_ui3.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React3.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React3.createElement(import_editor_controls.ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React3.createElement(import_editor_controls.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React3.createElement(
|
|
403
|
+
return /* @__PURE__ */ React3.createElement(import_ui3.ErrorBoundary, { fallback: null }, /* @__PURE__ */ React3.createElement(import_editor_ui.ThemeProvider, null, /* @__PURE__ */ React3.createElement(import_editor_controls.ControlActionsProvider, { items: menuItems }, /* @__PURE__ */ React3.createElement(import_editor_controls.ControlReplacementsProvider, { replacements: controlReplacements }, /* @__PURE__ */ React3.createElement(
|
|
472
404
|
import_ui3.Stack,
|
|
473
405
|
{
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
406
|
+
sx: {
|
|
407
|
+
flex: 1,
|
|
408
|
+
minHeight: 0,
|
|
409
|
+
overflow: "hidden",
|
|
410
|
+
display: "flex",
|
|
411
|
+
flexDirection: "column"
|
|
412
|
+
}
|
|
481
413
|
},
|
|
482
|
-
/* @__PURE__ */ React3.createElement(
|
|
483
|
-
|
|
484
|
-
import_ui3.CloseButton,
|
|
414
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Box, { sx: { flex: 1, minHeight: 0, overflow: "auto" } }, /* @__PURE__ */ React3.createElement(import_ui3.Stack, { sx: { px: 2, pt: 1, gap: 1 } }, /* @__PURE__ */ React3.createElement(import_ui3.FormControl, { fullWidth: true, size: "small" }, /* @__PURE__ */ React3.createElement(import_ui3.FormLabel, { htmlFor: TAG_SELECTOR_ID, size: "small", sx: { mb: 1 } }, (0, import_i18n2.__)("Tag", "elementor")), /* @__PURE__ */ React3.createElement(
|
|
415
|
+
import_editor_editing_panel2.CreatableAutocomplete,
|
|
485
416
|
{
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
417
|
+
id: TAG_SELECTOR_ID,
|
|
418
|
+
size: "tiny",
|
|
419
|
+
placeholder: (0, import_i18n2.__)("Type tag name", "elementor"),
|
|
420
|
+
options: tagOptions,
|
|
421
|
+
selected: [toTagChip(selectedTag)],
|
|
422
|
+
onSelect: handleTagSelect,
|
|
423
|
+
renderTags: (values, getTagProps) => values.map((value, index) => /* @__PURE__ */ React3.createElement(
|
|
424
|
+
TagChip,
|
|
425
|
+
{
|
|
426
|
+
key: value.value ?? value.label,
|
|
427
|
+
label: value.label,
|
|
428
|
+
chipProps: getTagProps({ index }),
|
|
429
|
+
activeState: activeStyleState,
|
|
430
|
+
onSelectState: setActiveStyleState
|
|
431
|
+
}
|
|
432
|
+
))
|
|
489
433
|
}
|
|
490
|
-
)
|
|
491
|
-
|
|
492
|
-
import_editor_editing_panel2.CreatableAutocomplete,
|
|
493
|
-
{
|
|
494
|
-
id: TAG_SELECTOR_ID,
|
|
495
|
-
size: "tiny",
|
|
496
|
-
placeholder: (0, import_i18n2.__)("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
|
-
import_editor_editing_panel2.ElementProvider,
|
|
513
|
-
{
|
|
514
|
-
element: shimElement,
|
|
515
|
-
elementType: shimElementType,
|
|
516
|
-
settings: {}
|
|
517
|
-
},
|
|
518
|
-
/* @__PURE__ */ React3.createElement(import_editor_editing_panel2.ClassesPropProvider, { prop: SHIM_CLASSES_PROP }, /* @__PURE__ */ React3.createElement(
|
|
519
|
-
import_editor_editing_panel2.StyleProvider,
|
|
434
|
+
))), /* @__PURE__ */ React3.createElement(
|
|
435
|
+
import_editor_editing_panel2.ElementProvider,
|
|
520
436
|
{
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
},
|
|
525
|
-
id: selectedTag,
|
|
526
|
-
setId: () => {
|
|
527
|
-
},
|
|
528
|
-
setMetaState: setActiveStyleState
|
|
437
|
+
element: shimElement,
|
|
438
|
+
elementType: shimElementType,
|
|
439
|
+
settings: {}
|
|
529
440
|
},
|
|
530
|
-
/* @__PURE__ */ React3.createElement(
|
|
531
|
-
|
|
441
|
+
/* @__PURE__ */ React3.createElement(import_editor_editing_panel2.ClassesPropProvider, { prop: SHIM_CLASSES_PROP }, /* @__PURE__ */ React3.createElement(
|
|
442
|
+
import_editor_editing_panel2.StyleProvider,
|
|
532
443
|
{
|
|
533
|
-
|
|
534
|
-
|
|
444
|
+
meta: {
|
|
445
|
+
breakpoint,
|
|
446
|
+
state: activeStyleState
|
|
447
|
+
},
|
|
448
|
+
id: selectedTag,
|
|
449
|
+
setId: () => {
|
|
450
|
+
},
|
|
451
|
+
setMetaState: setActiveStyleState
|
|
452
|
+
},
|
|
453
|
+
/* @__PURE__ */ React3.createElement(import_session.SessionStorageProvider, { prefix: selectedTag }, /* @__PURE__ */ React3.createElement(import_editor_editing_panel2.StyleInheritanceProvider, null, /* @__PURE__ */ React3.createElement(import_editor_editing_panel2.SectionsList, null, /* @__PURE__ */ React3.createElement(import_editor_editing_panel2.StyleSections, null)), /* @__PURE__ */ React3.createElement(
|
|
454
|
+
import_ui3.Box,
|
|
455
|
+
{
|
|
456
|
+
sx: {
|
|
457
|
+
height: "150px"
|
|
458
|
+
}
|
|
535
459
|
}
|
|
536
|
-
|
|
537
|
-
))
|
|
460
|
+
)))
|
|
461
|
+
))
|
|
462
|
+
)),
|
|
463
|
+
/* @__PURE__ */ React3.createElement(import_ui3.Box, { sx: { flexShrink: 0, px: 2, py: 1.5 } }, /* @__PURE__ */ React3.createElement(
|
|
464
|
+
import_ui3.Button,
|
|
465
|
+
{
|
|
466
|
+
fullWidth: true,
|
|
467
|
+
size: "small",
|
|
468
|
+
color: "global",
|
|
469
|
+
variant: "contained",
|
|
470
|
+
onClick: () => void save(),
|
|
471
|
+
disabled: !isDirty,
|
|
472
|
+
loading: isSaving
|
|
473
|
+
},
|
|
474
|
+
(0, import_i18n2.__)("Save changes", "elementor")
|
|
538
475
|
))
|
|
539
|
-
)), /* @__PURE__ */ React3.createElement(
|
|
540
|
-
import_ui3.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
|
-
(0, import_i18n2.__)("Save changes", "elementor")
|
|
551
|
-
))))), isSaveChangesDialogOpen && /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog, null, /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n2.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.Content, null, /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.ContentText, null, (0, import_i18n2.__)("You have unsaved changes in Default Styles.", "elementor")), /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.ContentText, null, (0, import_i18n2.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React3.createElement(
|
|
476
|
+
))), isSaveChangesDialogOpen && /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog, null, /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.Title, { onClose: closeSaveChangesDialog }, (0, import_i18n2.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.Content, null, /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.ContentText, null, (0, import_i18n2.__)("You have unsaved changes in Default Styles.", "elementor")), /* @__PURE__ */ React3.createElement(import_editor_ui.SaveChangesDialog.ContentText, null, (0, import_i18n2.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React3.createElement(
|
|
552
477
|
import_editor_ui.SaveChangesDialog.Actions,
|
|
553
478
|
{
|
|
554
479
|
actions: {
|
|
@@ -570,7 +495,7 @@ function useSave() {
|
|
|
570
495
|
});
|
|
571
496
|
}
|
|
572
497
|
function usePreventUnload(isDirty) {
|
|
573
|
-
(0,
|
|
498
|
+
(0, import_react2.useEffect)(() => {
|
|
574
499
|
const handleBeforeUnload = (event) => {
|
|
575
500
|
if (isDirty) {
|
|
576
501
|
event.preventDefault();
|
|
@@ -583,104 +508,56 @@ function usePreventUnload(isDirty) {
|
|
|
583
508
|
}, [isDirty]);
|
|
584
509
|
}
|
|
585
510
|
|
|
586
|
-
// src/
|
|
587
|
-
var
|
|
588
|
-
var
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
function
|
|
601
|
-
const
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
{
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
}
|
|
511
|
+
// src/init.ts
|
|
512
|
+
var import_editor = require("@elementor/editor");
|
|
513
|
+
var import_editor_editing_panel3 = require("@elementor/editor-editing-panel");
|
|
514
|
+
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
515
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
516
|
+
var import_store12 = require("@elementor/store");
|
|
517
|
+
|
|
518
|
+
// src/components/populate-store.tsx
|
|
519
|
+
var import_react3 = require("react");
|
|
520
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
521
|
+
var import_store8 = require("@elementor/store");
|
|
522
|
+
|
|
523
|
+
// src/load-default-styles.ts
|
|
524
|
+
var import_store6 = require("@elementor/store");
|
|
525
|
+
async function loadDefaultStyles() {
|
|
526
|
+
const response = await apiClient.all();
|
|
527
|
+
const items = response.data.data;
|
|
528
|
+
(0, import_store6.__dispatch)(
|
|
529
|
+
slice.actions.load({
|
|
530
|
+
data: items
|
|
531
|
+
})
|
|
609
532
|
);
|
|
610
533
|
}
|
|
611
534
|
|
|
612
|
-
// src/
|
|
613
|
-
var
|
|
614
|
-
function
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
const documentRef = (0, import_react4.useRef)(document);
|
|
620
|
-
documentRef.current = document;
|
|
621
|
-
const pendingOpenRef = (0, import_react4.useRef)(null);
|
|
622
|
-
const gatedOpen = (0, import_react4.useCallback)(
|
|
623
|
-
(onClean) => {
|
|
624
|
-
if (documentRef.current?.isDirty) {
|
|
625
|
-
pendingOpenRef.current = onClean;
|
|
626
|
-
openSaveDialog();
|
|
535
|
+
// src/components/populate-store.tsx
|
|
536
|
+
var V2_PANEL_ROUTE = "panel/v2";
|
|
537
|
+
function PopulateStore() {
|
|
538
|
+
(0, import_react3.useEffect)(() => {
|
|
539
|
+
void loadDefaultStyles();
|
|
540
|
+
(0, import_editor_v1_adapters.registerDataHook)("after", "editor/documents/attach-preview", async () => {
|
|
541
|
+
if (selectIsDirty((0, import_store8.__getState)())) {
|
|
627
542
|
return;
|
|
628
543
|
}
|
|
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 = (0, import_react4.useCallback)(() => {
|
|
643
|
-
closeSaveDialog();
|
|
644
|
-
pendingOpenRef.current = null;
|
|
645
|
-
}, [closeSaveDialog]);
|
|
646
|
-
(0, import_react4.useEffect)(() => {
|
|
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(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React5.createElement(import_editor_ui2.SaveChangesDialog, null, /* @__PURE__ */ React5.createElement(import_editor_ui2.SaveChangesDialog.Title, null, (0, import_i18n3.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React5.createElement(import_editor_ui2.SaveChangesDialog.Content, null, /* @__PURE__ */ React5.createElement(import_editor_ui2.SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n3.__)(
|
|
661
|
-
"To open Default Styles, save your page first. You can't continue without saving.",
|
|
662
|
-
"elementor"
|
|
663
|
-
))), /* @__PURE__ */ React5.createElement(
|
|
664
|
-
import_editor_ui2.SaveChangesDialog.Actions,
|
|
665
|
-
{
|
|
666
|
-
actions: {
|
|
667
|
-
cancel: {
|
|
668
|
-
label: (0, import_i18n3.__)("Stay here", "elementor"),
|
|
669
|
-
action: handleStayHere
|
|
670
|
-
},
|
|
671
|
-
confirm: {
|
|
672
|
-
label: (0, import_i18n3.__)("Save & Continue", "elementor"),
|
|
673
|
-
action: handleSaveAndContinue
|
|
674
|
-
}
|
|
544
|
+
await loadDefaultStyles();
|
|
545
|
+
});
|
|
546
|
+
const unsubscribe = (0, import_editor_v1_adapters.__privateListenTo)((0, import_editor_v1_adapters.routeCloseEvent)(V2_PANEL_ROUTE), () => {
|
|
547
|
+
if (selectIsDirty((0, import_store8.__getState)())) {
|
|
548
|
+
return;
|
|
675
549
|
}
|
|
676
|
-
|
|
677
|
-
|
|
550
|
+
void loadDefaultStyles();
|
|
551
|
+
});
|
|
552
|
+
return unsubscribe;
|
|
553
|
+
}, []);
|
|
554
|
+
return null;
|
|
678
555
|
}
|
|
679
556
|
|
|
680
557
|
// src/default-styles-provider.ts
|
|
681
558
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
682
559
|
var import_store10 = require("@elementor/store");
|
|
683
|
-
var
|
|
560
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
684
561
|
var DEFAULT_STYLES_PROVIDER_KEY = "default-styles";
|
|
685
562
|
var DEFAULT_STYLES_CSS_NAME_PREFIX = "e-default-";
|
|
686
563
|
var resolveCssName = (id) => `${DEFAULT_STYLES_CSS_NAME_PREFIX}${id}`;
|
|
@@ -698,8 +575,8 @@ var defaultStylesStylesProvider = (0, import_editor_styles_repository.createStyl
|
|
|
698
575
|
key: DEFAULT_STYLES_PROVIDER_KEY,
|
|
699
576
|
priority: 15,
|
|
700
577
|
labels: {
|
|
701
|
-
singular: (0,
|
|
702
|
-
plural: (0,
|
|
578
|
+
singular: (0, import_i18n3.__)("tag", "elementor"),
|
|
579
|
+
plural: (0, import_i18n3.__)("tags", "elementor")
|
|
703
580
|
},
|
|
704
581
|
subscribe: (cb) => subscribeWithStates(cb),
|
|
705
582
|
actions: {
|
|
@@ -755,21 +632,12 @@ var subscribeWithStates = (cb) => {
|
|
|
755
632
|
);
|
|
756
633
|
};
|
|
757
634
|
|
|
758
|
-
// src/hooks/use-default-styles-action-props.ts
|
|
759
|
-
var import_icons2 = require("@elementor/icons");
|
|
760
|
-
var import_i18n5 = require("@wordpress/i18n");
|
|
761
|
-
function useDefaultStylesActionProps() {
|
|
762
|
-
return {
|
|
763
|
-
title: (0, import_i18n5.__)("Default Styles", "elementor"),
|
|
764
|
-
icon: import_icons2.TextIcon,
|
|
765
|
-
onClick: () => {
|
|
766
|
-
window.dispatchEvent(new CustomEvent(EVENT_REQUEST_OPEN_DEFAULT_STYLES));
|
|
767
|
-
}
|
|
768
|
-
};
|
|
769
|
-
}
|
|
770
|
-
|
|
771
635
|
// src/init.ts
|
|
636
|
+
var DEFAULT_STYLES_EXPERIMENT = "e_default_styles";
|
|
772
637
|
function init() {
|
|
638
|
+
if (!(0, import_editor_v1_adapters2.isExperimentActive)(DEFAULT_STYLES_EXPERIMENT)) {
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
773
641
|
(0, import_store12.__registerSlice)(slice);
|
|
774
642
|
(0, import_editor_editing_panel3.registerElementPanelDefaults)("default-style", {
|
|
775
643
|
defaultTab: "style",
|
|
@@ -777,24 +645,15 @@ function init() {
|
|
|
777
645
|
style: [...import_editor_editing_panel3.STYLE_SECTION_NAMES]
|
|
778
646
|
}
|
|
779
647
|
});
|
|
780
|
-
(0, import_editor_panels3.__registerPanel)(panel);
|
|
781
648
|
import_editor_styles_repository2.stylesRepository.register(defaultStylesStylesProvider);
|
|
782
|
-
import_editor_app_bar.toolsMenu.registerAction({
|
|
783
|
-
id: "default-styles-button",
|
|
784
|
-
priority: 4,
|
|
785
|
-
useProps: useDefaultStylesActionProps
|
|
786
|
-
});
|
|
787
649
|
(0, import_editor.injectIntoLogic)({
|
|
788
650
|
id: "default-styles-populate-store",
|
|
789
651
|
component: PopulateStore
|
|
790
652
|
});
|
|
791
|
-
(0, import_editor.injectIntoLogic)({
|
|
792
|
-
id: "default-styles-open-gate",
|
|
793
|
-
component: DefaultStylesOpenGate
|
|
794
|
-
});
|
|
795
653
|
}
|
|
796
654
|
// Annotate the CommonJS export names for ESM import in node:
|
|
797
655
|
0 && (module.exports = {
|
|
656
|
+
DefaultStylesTabEmbedded,
|
|
798
657
|
init
|
|
799
658
|
});
|
|
800
659
|
//# sourceMappingURL=index.js.map
|