@elementor/editor-global-classes 0.11.0 → 0.12.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/CHANGELOG.md +56 -0
- package/dist/index.js +182 -149
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -152
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -12
- package/src/api.ts +22 -2
- package/src/components/class-manager/class-manager-introduction.tsx +5 -1
- package/src/components/class-manager/class-manager-panel.tsx +42 -8
- package/src/components/class-manager/global-classes-list.tsx +98 -100
- package/src/components/class-manager/sortable.tsx +23 -39
- package/src/save-global-classes.ts +27 -0
- package/src/sync-with-document-save.ts +9 -4
- package/src/publish-global-classes.ts +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# @elementor/editor-global-classes
|
|
2
2
|
|
|
3
|
+
## 0.12.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e798985: Support preview in Global Classes
|
|
8
|
+
- c3a0125: Clean modified status on global classes save.
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- a87cdd1: Add image to class manager introduction
|
|
13
|
+
- Updated dependencies [7ff3371]
|
|
14
|
+
- Updated dependencies [1e2dfa0]
|
|
15
|
+
- Updated dependencies [1ead543]
|
|
16
|
+
- Updated dependencies [c5d5e79]
|
|
17
|
+
- Updated dependencies [0ed25f2]
|
|
18
|
+
- Updated dependencies [6379dba]
|
|
19
|
+
- Updated dependencies [d0d5d6e]
|
|
20
|
+
- Updated dependencies [a789dfa]
|
|
21
|
+
- Updated dependencies [dcfcd9f]
|
|
22
|
+
- Updated dependencies [e798985]
|
|
23
|
+
- Updated dependencies [5c469a4]
|
|
24
|
+
- Updated dependencies [c63e5db]
|
|
25
|
+
- Updated dependencies [d8bc786]
|
|
26
|
+
- Updated dependencies [4c2935b]
|
|
27
|
+
- Updated dependencies [f03fcf0]
|
|
28
|
+
- Updated dependencies [8231e7c]
|
|
29
|
+
- Updated dependencies [6a5dd01]
|
|
30
|
+
- Updated dependencies [19f5dfe]
|
|
31
|
+
- Updated dependencies [c002cba]
|
|
32
|
+
- Updated dependencies [353031f]
|
|
33
|
+
- Updated dependencies [51432b9]
|
|
34
|
+
- Updated dependencies [03a6feb]
|
|
35
|
+
- Updated dependencies [0909b4b]
|
|
36
|
+
- Updated dependencies [c3a0125]
|
|
37
|
+
- @elementor/editor-editing-panel@1.18.0
|
|
38
|
+
- @elementor/editor-current-user@0.3.0
|
|
39
|
+
- @elementor/editor-ui@0.4.2
|
|
40
|
+
- @elementor/editor-v1-adapters@0.11.0
|
|
41
|
+
- @elementor/editor-props@0.11.0
|
|
42
|
+
- @elementor/editor@0.18.3
|
|
43
|
+
- @elementor/editor-documents@0.12.0
|
|
44
|
+
- @elementor/editor-panels@0.13.0
|
|
45
|
+
- @elementor/editor-styles-repository@0.7.6
|
|
46
|
+
- @elementor/editor-styles@0.6.3
|
|
47
|
+
|
|
48
|
+
## 0.11.1
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- f6a49b1: Global classes list UI updates.
|
|
53
|
+
- Updated dependencies [7d37fc1]
|
|
54
|
+
- @elementor/editor-props@0.10.0
|
|
55
|
+
- @elementor/editor-editing-panel@1.17.1
|
|
56
|
+
- @elementor/editor-styles-repository@0.7.5
|
|
57
|
+
- @elementor/editor-styles@0.6.2
|
|
58
|
+
|
|
3
59
|
## 0.11.0
|
|
4
60
|
|
|
5
61
|
### Minor Changes
|
package/dist/index.js
CHANGED
|
@@ -32,16 +32,18 @@ var import_store16 = require("@elementor/store");
|
|
|
32
32
|
|
|
33
33
|
// src/components/class-manager/class-manager-button.tsx
|
|
34
34
|
var React8 = __toESM(require("react"));
|
|
35
|
-
var
|
|
35
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
36
36
|
var import_ui7 = require("@elementor/ui");
|
|
37
37
|
var import_i18n6 = require("@wordpress/i18n");
|
|
38
38
|
|
|
39
39
|
// src/components/class-manager/class-manager-panel.tsx
|
|
40
40
|
var React7 = __toESM(require("react"));
|
|
41
41
|
var import_react4 = require("react");
|
|
42
|
+
var import_editor_documents = require("@elementor/editor-documents");
|
|
42
43
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
43
44
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
44
45
|
var import_icons6 = require("@elementor/icons");
|
|
46
|
+
var import_query = require("@elementor/query");
|
|
45
47
|
var import_ui6 = require("@elementor/ui");
|
|
46
48
|
var import_i18n5 = require("@wordpress/i18n");
|
|
47
49
|
|
|
@@ -138,32 +140,44 @@ var useDirtyState = () => {
|
|
|
138
140
|
return (0, import_store2.__useSelector)(selectIsDirty);
|
|
139
141
|
};
|
|
140
142
|
|
|
141
|
-
// src/
|
|
143
|
+
// src/save-global-classes.ts
|
|
142
144
|
var import_store4 = require("@elementor/store");
|
|
143
145
|
|
|
144
146
|
// src/api.ts
|
|
145
147
|
var import_http = require("@elementor/http");
|
|
146
148
|
var RESOURCE_URL = "/global-classes";
|
|
147
149
|
var apiClient = {
|
|
148
|
-
all: () => (0, import_http.httpService)().get("elementor/v1" + RESOURCE_URL
|
|
149
|
-
|
|
150
|
+
all: () => (0, import_http.httpService)().get("elementor/v1" + RESOURCE_URL, {
|
|
151
|
+
params: {
|
|
152
|
+
context: "preview"
|
|
153
|
+
}
|
|
154
|
+
}),
|
|
155
|
+
publish: (payload) => (0, import_http.httpService)().put("elementor/v1" + RESOURCE_URL, payload, {
|
|
156
|
+
params: {
|
|
157
|
+
context: "frontend"
|
|
158
|
+
}
|
|
159
|
+
}),
|
|
160
|
+
saveDraft: (payload) => (0, import_http.httpService)().put("elementor/v1" + RESOURCE_URL, payload, {
|
|
161
|
+
params: {
|
|
162
|
+
context: "preview"
|
|
163
|
+
}
|
|
164
|
+
})
|
|
150
165
|
};
|
|
151
166
|
|
|
152
|
-
// src/
|
|
153
|
-
async function
|
|
154
|
-
if (!isDirty()) {
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
167
|
+
// src/save-global-classes.ts
|
|
168
|
+
async function saveGlobalClasses({ context: context2 }) {
|
|
157
169
|
const state = (0, import_store4.__getState)().globalClasses;
|
|
158
|
-
|
|
170
|
+
const data = {
|
|
159
171
|
items: state.items,
|
|
160
172
|
order: state.order
|
|
161
|
-
}
|
|
173
|
+
};
|
|
174
|
+
if (context2 === "preview") {
|
|
175
|
+
await apiClient.saveDraft(data);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
await apiClient.publish(data);
|
|
162
179
|
(0, import_store4.__dispatch)(slice.actions.setPristine());
|
|
163
180
|
}
|
|
164
|
-
function isDirty() {
|
|
165
|
-
return selectIsDirty((0, import_store4.__getState)());
|
|
166
|
-
}
|
|
167
181
|
|
|
168
182
|
// src/components/class-manager/class-manager-introduction.tsx
|
|
169
183
|
var React = __toESM(require("react"));
|
|
@@ -192,7 +206,14 @@ var ClassManagerIntroduction = () => {
|
|
|
192
206
|
);
|
|
193
207
|
};
|
|
194
208
|
var IntroductionContent = () => {
|
|
195
|
-
return /* @__PURE__ */ React.createElement(import_ui.Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(
|
|
209
|
+
return /* @__PURE__ */ React.createElement(import_ui.Stack, { gap: 1.5, padding: 3 }, /* @__PURE__ */ React.createElement(
|
|
210
|
+
import_ui.Image,
|
|
211
|
+
{
|
|
212
|
+
sx: { width: "100%", height: "312px" },
|
|
213
|
+
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
214
|
+
alt: ""
|
|
215
|
+
}
|
|
216
|
+
), /* @__PURE__ */ React.createElement(import_ui.Box, null, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
|
|
196
217
|
"The CSS Class Manager allows you to manage and organize your site's CSS classes efficiently. You can reorder classes to adjust their priority, rename them to maintain clarity in your design system, and delete unused classes to keep your CSS structured.",
|
|
197
218
|
"elementor"
|
|
198
219
|
)), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
|
|
@@ -326,7 +347,7 @@ var React4 = __toESM(require("react"));
|
|
|
326
347
|
var import_icons3 = require("@elementor/icons");
|
|
327
348
|
var import_ui3 = require("@elementor/ui");
|
|
328
349
|
var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
329
|
-
var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(
|
|
350
|
+
var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(import_icons3.GripVerticalIcon, { fontSize: "tiny" }));
|
|
330
351
|
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
331
352
|
return /* @__PURE__ */ React4.createElement(
|
|
332
353
|
import_ui3.UnstableSortableItem,
|
|
@@ -345,55 +366,45 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
345
366
|
isDragPlaceholder
|
|
346
367
|
}) => {
|
|
347
368
|
return /* @__PURE__ */ React4.createElement(
|
|
348
|
-
|
|
369
|
+
import_ui3.Box,
|
|
349
370
|
{
|
|
350
371
|
...itemProps,
|
|
351
|
-
|
|
372
|
+
style: itemStyle,
|
|
373
|
+
component: "li",
|
|
352
374
|
role: "listitem",
|
|
353
|
-
|
|
375
|
+
sx: {
|
|
376
|
+
backgroundColor: isDragOverlay ? "background.paper" : void 0
|
|
377
|
+
}
|
|
354
378
|
},
|
|
355
|
-
/* @__PURE__ */ React4.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }),
|
|
356
379
|
children({
|
|
357
380
|
itemProps,
|
|
358
381
|
isDragged,
|
|
359
382
|
triggerProps,
|
|
360
383
|
itemStyle,
|
|
361
384
|
triggerStyle,
|
|
362
|
-
dropIndicationStyle,
|
|
363
|
-
showDropIndication,
|
|
364
385
|
isDragPlaceholder
|
|
365
|
-
})
|
|
386
|
+
}),
|
|
387
|
+
showDropIndication && /* @__PURE__ */ React4.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
366
388
|
);
|
|
367
389
|
}
|
|
368
390
|
}
|
|
369
391
|
);
|
|
370
392
|
};
|
|
371
|
-
var
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
& .class-item-sortable-trigger {
|
|
381
|
-
visibility: hidden;
|
|
382
|
-
position: absolute;
|
|
383
|
-
left: 0;
|
|
384
|
-
top: 50%;
|
|
385
|
-
transform: translate( -75%, -50% );
|
|
386
|
-
}
|
|
387
|
-
`;
|
|
393
|
+
var StyledSortableTrigger = (0, import_ui3.styled)("div")(({ theme }) => ({
|
|
394
|
+
position: "absolute",
|
|
395
|
+
left: 0,
|
|
396
|
+
top: "50%",
|
|
397
|
+
transform: `translate( -${theme.spacing(1.5)}, -50% )`,
|
|
398
|
+
color: theme.palette.action.active
|
|
399
|
+
}));
|
|
388
400
|
var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
|
|
389
401
|
width: 100%;
|
|
390
|
-
height:
|
|
391
|
-
border-radius: ${({ theme }) => theme.spacing(0.5)};
|
|
402
|
+
height: 1px;
|
|
392
403
|
background-color: ${({ theme }) => theme.palette.text.primary};
|
|
393
404
|
`;
|
|
394
405
|
|
|
395
406
|
// src/components/class-manager/global-classes-list.tsx
|
|
396
|
-
var GlobalClassesList = () => {
|
|
407
|
+
var GlobalClassesList = ({ disabled }) => {
|
|
397
408
|
const cssClasses = useOrderedClasses();
|
|
398
409
|
const [classesOrder, reorderClasses] = useReorder();
|
|
399
410
|
if (!cssClasses?.length) {
|
|
@@ -403,16 +414,16 @@ var GlobalClassesList = () => {
|
|
|
403
414
|
const renameClass = (newLabel) => {
|
|
404
415
|
globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
|
|
405
416
|
};
|
|
406
|
-
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged,
|
|
417
|
+
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
407
418
|
ClassItem,
|
|
408
419
|
{
|
|
409
420
|
id: id2,
|
|
410
421
|
label,
|
|
411
422
|
renameClass,
|
|
412
423
|
selected: isDragged,
|
|
413
|
-
disabled: isDragPlaceholder
|
|
414
|
-
|
|
415
|
-
|
|
424
|
+
disabled: disabled || isDragPlaceholder,
|
|
425
|
+
sortableTriggerProps: { ...triggerProps, style: triggerStyle }
|
|
426
|
+
}
|
|
416
427
|
));
|
|
417
428
|
}))));
|
|
418
429
|
};
|
|
@@ -423,14 +434,7 @@ var useReorder = () => {
|
|
|
423
434
|
};
|
|
424
435
|
return [order, reorder];
|
|
425
436
|
};
|
|
426
|
-
var ClassItem = ({
|
|
427
|
-
id: id2,
|
|
428
|
-
label,
|
|
429
|
-
renameClass,
|
|
430
|
-
selected,
|
|
431
|
-
children,
|
|
432
|
-
disabled
|
|
433
|
-
}) => {
|
|
437
|
+
var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTriggerProps }) => {
|
|
434
438
|
const {
|
|
435
439
|
ref: editableRef,
|
|
436
440
|
openEditMode,
|
|
@@ -447,99 +451,100 @@ var ClassItem = ({
|
|
|
447
451
|
variant: "popover",
|
|
448
452
|
disableAutoFocus: true
|
|
449
453
|
});
|
|
450
|
-
|
|
451
|
-
|
|
454
|
+
const isSelected = (selected || popupState.isOpen) && !disabled;
|
|
455
|
+
return /* @__PURE__ */ React5.createElement(React5.Fragment, null, /* @__PURE__ */ React5.createElement(
|
|
456
|
+
StyledListItemButton,
|
|
452
457
|
{
|
|
453
|
-
|
|
454
|
-
disablePadding: true,
|
|
458
|
+
dense: true,
|
|
455
459
|
disableGutters: true,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
},
|
|
463
|
-
/* @__PURE__ */ React5.createElement(import_ui4.IconButton, { size: "tiny", ...(0, import_ui4.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(import_icons4.DotsVerticalIcon, { fontSize: "tiny" }))
|
|
464
|
-
)
|
|
460
|
+
showActions: isSelected || isEditing,
|
|
461
|
+
shape: "rounded",
|
|
462
|
+
onDoubleClick: openEditMode,
|
|
463
|
+
selected: isSelected,
|
|
464
|
+
disabled,
|
|
465
|
+
focusVisibleClassName: "visible-class-item"
|
|
465
466
|
},
|
|
467
|
+
/* @__PURE__ */ React5.createElement(SortableTrigger, { ...sortableTriggerProps }),
|
|
468
|
+
/* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
|
|
469
|
+
import_editor_ui2.EditableField,
|
|
470
|
+
{
|
|
471
|
+
ref: editableRef,
|
|
472
|
+
error,
|
|
473
|
+
as: import_ui4.Typography,
|
|
474
|
+
variant: "caption",
|
|
475
|
+
...getEditableProps()
|
|
476
|
+
}
|
|
477
|
+
) : /* @__PURE__ */ React5.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" })),
|
|
466
478
|
/* @__PURE__ */ React5.createElement(
|
|
467
|
-
import_ui4.
|
|
479
|
+
import_ui4.Tooltip,
|
|
468
480
|
{
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
}
|
|
481
|
+
placement: "top",
|
|
482
|
+
className: "class-item-more-actions",
|
|
483
|
+
title: (0, import_i18n4.__)("More actions", "elementor")
|
|
484
|
+
},
|
|
485
|
+
/* @__PURE__ */ React5.createElement(import_ui4.IconButton, { size: "tiny", ...(0, import_ui4.bindTrigger)(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(import_icons4.DotsVerticalIcon, { fontSize: "tiny" }))
|
|
486
|
+
)
|
|
487
|
+
), /* @__PURE__ */ React5.createElement(
|
|
488
|
+
import_ui4.Menu,
|
|
489
|
+
{
|
|
490
|
+
...(0, import_ui4.bindMenu)(popupState),
|
|
491
|
+
anchorOrigin: {
|
|
492
|
+
vertical: "bottom",
|
|
493
|
+
horizontal: "right"
|
|
483
494
|
},
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
495
|
+
transformOrigin: {
|
|
496
|
+
vertical: "top",
|
|
497
|
+
horizontal: "right"
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
/* @__PURE__ */ React5.createElement(
|
|
501
|
+
import_ui4.MenuItem,
|
|
502
|
+
{
|
|
503
|
+
sx: { minWidth: "160px" },
|
|
504
|
+
onClick: () => {
|
|
505
|
+
popupState.close();
|
|
506
|
+
openEditMode();
|
|
492
507
|
}
|
|
493
|
-
|
|
508
|
+
},
|
|
509
|
+
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
|
|
494
510
|
),
|
|
495
|
-
children,
|
|
496
511
|
/* @__PURE__ */ React5.createElement(
|
|
497
|
-
import_ui4.
|
|
512
|
+
import_ui4.MenuItem,
|
|
498
513
|
{
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
horizontal: "right"
|
|
503
|
-
},
|
|
504
|
-
transformOrigin: {
|
|
505
|
-
vertical: "top",
|
|
506
|
-
horizontal: "right"
|
|
514
|
+
onClick: () => {
|
|
515
|
+
popupState.close();
|
|
516
|
+
openDialog({ id: id2, label });
|
|
507
517
|
}
|
|
508
518
|
},
|
|
509
|
-
/* @__PURE__ */ React5.createElement(
|
|
510
|
-
import_ui4.MenuItem,
|
|
511
|
-
{
|
|
512
|
-
sx: { minWidth: "160px" },
|
|
513
|
-
onClick: () => {
|
|
514
|
-
popupState.close();
|
|
515
|
-
openEditMode();
|
|
516
|
-
}
|
|
517
|
-
},
|
|
518
|
-
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
|
|
519
|
-
),
|
|
520
|
-
/* @__PURE__ */ React5.createElement(
|
|
521
|
-
import_ui4.MenuItem,
|
|
522
|
-
{
|
|
523
|
-
onClick: () => {
|
|
524
|
-
popupState.close();
|
|
525
|
-
openDialog({ id: id2, label });
|
|
526
|
-
}
|
|
527
|
-
},
|
|
528
|
-
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
|
|
529
|
-
)
|
|
519
|
+
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
|
|
530
520
|
)
|
|
531
521
|
));
|
|
532
522
|
};
|
|
533
|
-
var
|
|
534
|
-
|
|
535
|
-
|
|
523
|
+
var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
|
|
524
|
+
shouldForwardProp: (prop) => !["showActions"].includes(prop)
|
|
525
|
+
})(
|
|
526
|
+
({ showActions }) => `
|
|
527
|
+
min-height: 36px;
|
|
528
|
+
|
|
529
|
+
&.visible-class-item {
|
|
530
|
+
box-shadow: none !important;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.class-item-more-actions, .class-item-sortable-trigger {
|
|
534
|
+
visibility: ${showActions ? "visible" : "hidden"};
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
.class-item-sortable-trigger {
|
|
538
|
+
visibility: ${showActions ? "visible" : "hidden"};
|
|
536
539
|
}
|
|
537
|
-
|
|
538
|
-
|
|
540
|
+
|
|
541
|
+
&:hover&:not(:disabled) {
|
|
542
|
+
.class-item-more-actions, .class-item-sortable-trigger {
|
|
539
543
|
visibility: visible;
|
|
540
544
|
}
|
|
541
545
|
}
|
|
542
|
-
|
|
546
|
+
`
|
|
547
|
+
);
|
|
543
548
|
var EmptyState = () => /* @__PURE__ */ React5.createElement(import_ui4.Stack, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React5.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React5.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, (0, import_i18n4.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n4.__)(
|
|
544
549
|
"CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.",
|
|
545
550
|
"elementor"
|
|
@@ -558,7 +563,8 @@ var Indicator = (0, import_ui4.styled)(import_ui4.Box, {
|
|
|
558
563
|
borderRadius: theme.spacing(0.5),
|
|
559
564
|
border: getIndicatorBorder({ isActive, isError, theme }),
|
|
560
565
|
padding: `0 ${theme.spacing(1)}`,
|
|
561
|
-
marginLeft: isActive ? theme.spacing(1) : 0
|
|
566
|
+
marginLeft: isActive ? theme.spacing(1) : 0,
|
|
567
|
+
minWidth: 0
|
|
562
568
|
}));
|
|
563
569
|
var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
564
570
|
if (isError) {
|
|
@@ -615,36 +621,46 @@ var id = "global-classes-manager";
|
|
|
615
621
|
var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
616
622
|
id,
|
|
617
623
|
component: ClassManagerPanel,
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
624
|
+
allowedEditModes: ["edit", id],
|
|
625
|
+
onOpen: () => {
|
|
626
|
+
(0, import_editor_v1_adapters.changeEditMode)(id);
|
|
627
|
+
return (0, import_editor_documents.getDocumentModifiedStatus)();
|
|
628
|
+
},
|
|
629
|
+
onClose: (documentModifiedState) => {
|
|
630
|
+
(0, import_editor_v1_adapters.changeEditMode)("edit");
|
|
631
|
+
if ((0, import_editor_documents.getDocumentModifiedStatus)() !== documentModifiedState) {
|
|
632
|
+
(0, import_editor_documents.setDocumentModifiedStatus)(documentModifiedState);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
621
635
|
});
|
|
622
636
|
function ClassManagerPanel() {
|
|
623
|
-
const
|
|
637
|
+
const isDirty2 = useDirtyState();
|
|
624
638
|
const { close: closePanel } = usePanelActions();
|
|
625
639
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
640
|
+
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
626
641
|
usePreventUnload();
|
|
627
642
|
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(import_ui6.ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React7.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React7.createElement(import_ui6.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React7.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), (0, import_i18n5.__)("CSS Class manager", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
628
643
|
CloseButton,
|
|
629
644
|
{
|
|
630
645
|
sx: { marginLeft: "auto" },
|
|
631
646
|
onClose: () => {
|
|
632
|
-
if (
|
|
647
|
+
if (isDirty2) {
|
|
633
648
|
openSaveChangesDialog();
|
|
634
649
|
return;
|
|
635
650
|
}
|
|
636
651
|
closePanel();
|
|
637
652
|
}
|
|
638
653
|
}
|
|
639
|
-
))), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList,
|
|
654
|
+
))), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, { disabled: isPublishing })), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React7.createElement(
|
|
640
655
|
import_ui6.Button,
|
|
641
656
|
{
|
|
642
657
|
fullWidth: true,
|
|
643
658
|
size: "small",
|
|
644
|
-
variant: "contained",
|
|
645
659
|
color: "global",
|
|
646
|
-
|
|
647
|
-
onClick:
|
|
660
|
+
variant: "contained",
|
|
661
|
+
onClick: publish,
|
|
662
|
+
disabled: !isDirty2,
|
|
663
|
+
loading: isPublishing
|
|
648
664
|
},
|
|
649
665
|
(0, import_i18n5.__)("Save changes", "elementor")
|
|
650
666
|
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0, import_i18n5.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n5.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
|
|
@@ -658,7 +674,7 @@ function ClassManagerPanel() {
|
|
|
658
674
|
confirm: {
|
|
659
675
|
label: (0, import_i18n5.__)("Save & Continue", "elementor"),
|
|
660
676
|
action: async () => {
|
|
661
|
-
await
|
|
677
|
+
await publish();
|
|
662
678
|
closeSaveChangesDialog();
|
|
663
679
|
closePanel();
|
|
664
680
|
}
|
|
@@ -670,10 +686,10 @@ function ClassManagerPanel() {
|
|
|
670
686
|
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(import_ui6.IconButton, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(import_icons6.XIcon, { fontSize: "small" }));
|
|
671
687
|
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(import_ui6.Box, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(import_ui6.Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, (0, import_i18n5.__)("Something went wrong", "elementor"))));
|
|
672
688
|
var usePreventUnload = () => {
|
|
673
|
-
const
|
|
689
|
+
const isDirty2 = useDirtyState();
|
|
674
690
|
(0, import_react4.useEffect)(() => {
|
|
675
691
|
const handleBeforeUnload = (event) => {
|
|
676
|
-
if (
|
|
692
|
+
if (isDirty2) {
|
|
677
693
|
event.preventDefault();
|
|
678
694
|
}
|
|
679
695
|
};
|
|
@@ -681,14 +697,26 @@ var usePreventUnload = () => {
|
|
|
681
697
|
return () => {
|
|
682
698
|
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
683
699
|
};
|
|
684
|
-
}, [
|
|
700
|
+
}, [isDirty2]);
|
|
701
|
+
};
|
|
702
|
+
var usePublish = () => {
|
|
703
|
+
const document = (0, import_editor_documents.__useActiveDocument)();
|
|
704
|
+
const [initialDocumentStatus] = (0, import_react4.useState)(document?.isDirty ?? false);
|
|
705
|
+
return (0, import_query.useMutation)({
|
|
706
|
+
mutationFn: () => saveGlobalClasses({ context: "frontend" }),
|
|
707
|
+
onSuccess: () => {
|
|
708
|
+
if (initialDocumentStatus !== document?.isDirty) {
|
|
709
|
+
(0, import_editor_documents.setDocumentModifiedStatus)(initialDocumentStatus);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
});
|
|
685
713
|
};
|
|
686
714
|
|
|
687
715
|
// src/components/class-manager/class-manager-button.tsx
|
|
688
716
|
var ClassManagerButton = () => {
|
|
689
|
-
const document = (0,
|
|
717
|
+
const document = (0, import_editor_documents2.__useActiveDocument)();
|
|
690
718
|
const { open: openPanel } = usePanelActions();
|
|
691
|
-
const { save: saveDocument } = (0,
|
|
719
|
+
const { save: saveDocument } = (0, import_editor_documents2.__useActiveDocumentActions)();
|
|
692
720
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
693
721
|
const handleOpenPanel = () => {
|
|
694
722
|
if (document?.isDirty) {
|
|
@@ -736,6 +764,7 @@ function PopulateStore() {
|
|
|
736
764
|
}
|
|
737
765
|
|
|
738
766
|
// src/sync-with-document-save.ts
|
|
767
|
+
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
739
768
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
740
769
|
var import_store14 = require("@elementor/store");
|
|
741
770
|
function syncWithDocumentSave() {
|
|
@@ -745,16 +774,20 @@ function syncWithDocumentSave() {
|
|
|
745
774
|
}
|
|
746
775
|
function syncDirtyState() {
|
|
747
776
|
return (0, import_store14.__subscribeWithSelector)(selectIsDirty, () => {
|
|
748
|
-
if (!
|
|
777
|
+
if (!isDirty()) {
|
|
749
778
|
return;
|
|
750
779
|
}
|
|
751
|
-
(0,
|
|
780
|
+
(0, import_editor_documents3.setDocumentModifiedStatus)(true);
|
|
752
781
|
});
|
|
753
782
|
}
|
|
754
783
|
function bindSaveAction() {
|
|
755
|
-
(0, import_editor_v1_adapters2.registerDataHook)("after", "document/save/save",
|
|
784
|
+
(0, import_editor_v1_adapters2.registerDataHook)("after", "document/save/save", (args) => {
|
|
785
|
+
return saveGlobalClasses({
|
|
786
|
+
context: args.status === "publish" ? "frontend" : "preview"
|
|
787
|
+
});
|
|
788
|
+
});
|
|
756
789
|
}
|
|
757
|
-
function
|
|
790
|
+
function isDirty() {
|
|
758
791
|
return selectIsDirty((0, import_store14.__getState)());
|
|
759
792
|
}
|
|
760
793
|
|