@elementor/editor-global-classes 0.9.1 → 0.11.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 +59 -0
- package/dist/index.js +182 -104
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +177 -96
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -13
- package/src/components/class-manager/class-manager-button.tsx +58 -7
- package/src/components/class-manager/class-manager-introduction.tsx +1 -1
- package/src/components/class-manager/class-manager-panel.tsx +54 -27
- package/src/components/class-manager/flipped-color-swatch-icon.tsx +7 -0
- package/src/components/class-manager/global-classes-list.tsx +10 -5
- package/src/components/class-manager/save-changes-dialog.tsx +84 -0
- package/src/components/class-manager/sortable.tsx +13 -3
- package/src/global-classes-styles-provider.ts +1 -1
- package/src/components/class-manager/unsaved-changes-dialog.tsx +0 -76
package/dist/index.js
CHANGED
|
@@ -27,19 +27,21 @@ var import_editor = require("@elementor/editor");
|
|
|
27
27
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
28
28
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
29
29
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
30
|
-
var
|
|
30
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
31
31
|
var import_store16 = require("@elementor/store");
|
|
32
32
|
|
|
33
33
|
// src/components/class-manager/class-manager-button.tsx
|
|
34
|
-
var
|
|
35
|
-
var
|
|
34
|
+
var React8 = __toESM(require("react"));
|
|
35
|
+
var import_editor_documents = 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
|
-
var
|
|
40
|
+
var React7 = __toESM(require("react"));
|
|
41
|
+
var import_react4 = require("react");
|
|
41
42
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
42
|
-
var
|
|
43
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
44
|
+
var import_icons6 = require("@elementor/icons");
|
|
43
45
|
var import_ui6 = require("@elementor/ui");
|
|
44
46
|
var import_i18n5 = require("@wordpress/i18n");
|
|
45
47
|
|
|
@@ -84,8 +86,8 @@ var slice = (0, import_store.__createSlice)({
|
|
|
84
86
|
state.isDirty = true;
|
|
85
87
|
},
|
|
86
88
|
delete(state, { payload }) {
|
|
87
|
-
state.items = Object.fromEntries(Object.entries(state.items).filter(([
|
|
88
|
-
state.order = state.order.filter((
|
|
89
|
+
state.items = Object.fromEntries(Object.entries(state.items).filter(([id2]) => id2 !== payload));
|
|
90
|
+
state.order = state.order.filter((id2) => id2 !== payload);
|
|
89
91
|
state.isDirty = true;
|
|
90
92
|
},
|
|
91
93
|
setOrder(state, { payload }) {
|
|
@@ -126,9 +128,9 @@ var selectGlobalClasses = (state) => state[SLICE_NAME].items;
|
|
|
126
128
|
var selectOrderedClasses = (0, import_store.__createSelector)(
|
|
127
129
|
selectGlobalClasses,
|
|
128
130
|
selectOrder,
|
|
129
|
-
(items, order) => order.map((
|
|
131
|
+
(items, order) => order.map((id2) => items[id2])
|
|
130
132
|
);
|
|
131
|
-
var selectClass = (state,
|
|
133
|
+
var selectClass = (state, id2) => state[SLICE_NAME].items[id2] ?? null;
|
|
132
134
|
var selectIsDirty = (state) => state.globalClasses.isDirty;
|
|
133
135
|
|
|
134
136
|
// src/hooks/use-dirty-state.ts
|
|
@@ -170,7 +172,7 @@ var import_editor_current_user = require("@elementor/editor-current-user");
|
|
|
170
172
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
171
173
|
var import_ui = require("@elementor/ui");
|
|
172
174
|
var import_i18n = require("@wordpress/i18n");
|
|
173
|
-
var MESSAGE_KEY = "global-class-manager
|
|
175
|
+
var MESSAGE_KEY = "global-class-manager";
|
|
174
176
|
var ClassManagerIntroduction = () => {
|
|
175
177
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user.useSuppressedMessage)(MESSAGE_KEY);
|
|
176
178
|
const [shouldShowIntroduction, setShouldShowIntroduction] = (0, import_react.useState)(!isMessageSuppressed);
|
|
@@ -199,11 +201,16 @@ var IntroductionContent = () => {
|
|
|
199
201
|
))));
|
|
200
202
|
};
|
|
201
203
|
|
|
204
|
+
// src/components/class-manager/flipped-color-swatch-icon.tsx
|
|
205
|
+
var React2 = __toESM(require("react"));
|
|
206
|
+
var import_icons = require("@elementor/icons");
|
|
207
|
+
var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.createElement(import_icons.ColorSwatchIcon, { sx: { transform: "rotate(90deg)", ...sx }, ...props });
|
|
208
|
+
|
|
202
209
|
// src/components/class-manager/global-classes-list.tsx
|
|
203
|
-
var
|
|
210
|
+
var React5 = __toESM(require("react"));
|
|
204
211
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
205
212
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
206
|
-
var
|
|
213
|
+
var import_icons4 = require("@elementor/icons");
|
|
207
214
|
var import_ui4 = require("@elementor/ui");
|
|
208
215
|
var import_i18n4 = require("@wordpress/i18n");
|
|
209
216
|
|
|
@@ -216,7 +223,7 @@ var globalClassesStylesProvider = {
|
|
|
216
223
|
priority: 30,
|
|
217
224
|
actions: {
|
|
218
225
|
get: () => selectOrderedClasses((0, import_store6.__getState)()),
|
|
219
|
-
getById: (
|
|
226
|
+
getById: (id2) => selectClass((0, import_store6.__getState)(), id2),
|
|
220
227
|
create: (label) => {
|
|
221
228
|
const classes = selectGlobalClasses((0, import_store6.__getState)());
|
|
222
229
|
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
@@ -224,16 +231,16 @@ var globalClassesStylesProvider = {
|
|
|
224
231
|
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
225
232
|
}
|
|
226
233
|
const existingIds = Object.keys(classes);
|
|
227
|
-
const
|
|
234
|
+
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
228
235
|
(0, import_store6.__dispatch)(
|
|
229
236
|
slice.actions.add({
|
|
230
|
-
id,
|
|
237
|
+
id: id2,
|
|
231
238
|
type: "class",
|
|
232
239
|
label,
|
|
233
240
|
variants: []
|
|
234
241
|
})
|
|
235
242
|
);
|
|
236
|
-
return
|
|
243
|
+
return id2;
|
|
237
244
|
},
|
|
238
245
|
update: (payload) => {
|
|
239
246
|
(0, import_store6.__dispatch)(
|
|
@@ -242,8 +249,8 @@ var globalClassesStylesProvider = {
|
|
|
242
249
|
})
|
|
243
250
|
);
|
|
244
251
|
},
|
|
245
|
-
delete: (
|
|
246
|
-
(0, import_store6.__dispatch)(slice.actions.delete(
|
|
252
|
+
delete: (id2) => {
|
|
253
|
+
(0, import_store6.__dispatch)(slice.actions.delete(id2));
|
|
247
254
|
},
|
|
248
255
|
setOrder: (order) => {
|
|
249
256
|
(0, import_store6.__dispatch)(slice.actions.setOrder(order));
|
|
@@ -261,7 +268,7 @@ var globalClassesStylesProvider = {
|
|
|
261
268
|
subscribe: (cb) => (0, import_store6.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
262
269
|
labels: {
|
|
263
270
|
singular: (0, import_i18n2.__)("Global class", "elementor"),
|
|
264
|
-
plural: (0, import_i18n2.__)("Global CSS
|
|
271
|
+
plural: (0, import_i18n2.__)("Global CSS classes", "elementor")
|
|
265
272
|
}
|
|
266
273
|
};
|
|
267
274
|
|
|
@@ -278,9 +285,9 @@ var useOrderedClasses = () => {
|
|
|
278
285
|
};
|
|
279
286
|
|
|
280
287
|
// src/components/class-manager/delete-confirmation-dialog.tsx
|
|
281
|
-
var
|
|
288
|
+
var React3 = __toESM(require("react"));
|
|
282
289
|
var import_react2 = require("react");
|
|
283
|
-
var
|
|
290
|
+
var import_icons2 = require("@elementor/icons");
|
|
284
291
|
var import_ui2 = require("@elementor/ui");
|
|
285
292
|
var import_i18n3 = require("@wordpress/i18n");
|
|
286
293
|
var context = (0, import_react2.createContext)(null);
|
|
@@ -292,19 +299,19 @@ var DeleteConfirmationProvider = ({ children }) => {
|
|
|
292
299
|
const closeDialog = () => {
|
|
293
300
|
setDialogProps(null);
|
|
294
301
|
};
|
|
295
|
-
return /* @__PURE__ */
|
|
302
|
+
return /* @__PURE__ */ React3.createElement(context.Provider, { value: { openDialog, closeDialog, dialogProps } }, children, !!dialogProps && /* @__PURE__ */ React3.createElement(DeleteConfirmationDialog, { ...dialogProps }));
|
|
296
303
|
};
|
|
297
304
|
var TITLE_ID = "delete-class-dialog";
|
|
298
|
-
var DeleteConfirmationDialog = ({ label, id }) => {
|
|
305
|
+
var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
299
306
|
const { closeDialog } = useDeleteConfirmation();
|
|
300
307
|
const onConfirm = () => {
|
|
301
|
-
globalClassesStylesProvider.actions.delete(
|
|
308
|
+
globalClassesStylesProvider.actions.delete(id2);
|
|
302
309
|
closeDialog();
|
|
303
310
|
};
|
|
304
|
-
return /* @__PURE__ */
|
|
311
|
+
return /* @__PURE__ */ React3.createElement(import_ui2.Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(import_ui2.DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(import_icons2.AlertOctagonFilledIcon, { color: "error" }), (0, import_i18n3.__)("Delete global class", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.DialogContent, null, /* @__PURE__ */ React3.createElement(import_ui2.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n3.__)("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n3.__)(
|
|
305
312
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
306
313
|
"elementor"
|
|
307
|
-
))), /* @__PURE__ */
|
|
314
|
+
))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n3.__)("Cancel", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n3.__)("Delete", "elementor"))));
|
|
308
315
|
};
|
|
309
316
|
var useDeleteConfirmation = () => {
|
|
310
317
|
const contextValue = (0, import_react2.useContext)(context);
|
|
@@ -315,16 +322,17 @@ var useDeleteConfirmation = () => {
|
|
|
315
322
|
};
|
|
316
323
|
|
|
317
324
|
// src/components/class-manager/sortable.tsx
|
|
318
|
-
var
|
|
319
|
-
var
|
|
325
|
+
var React4 = __toESM(require("react"));
|
|
326
|
+
var import_icons3 = require("@elementor/icons");
|
|
320
327
|
var import_ui3 = require("@elementor/ui");
|
|
321
|
-
var SortableProvider = (props) => /* @__PURE__ */
|
|
322
|
-
var SortableTrigger = (props) => /* @__PURE__ */
|
|
323
|
-
var SortableItem = ({ children, id }) => {
|
|
324
|
-
return /* @__PURE__ */
|
|
328
|
+
var SortableProvider = (props) => /* @__PURE__ */ React4.createElement(import_ui3.UnstableSortableProvider, { restrictAxis: true, variant: "static", dragPlaceholderStyle: { opacity: "1" }, ...props });
|
|
329
|
+
var SortableTrigger = (props) => /* @__PURE__ */ React4.createElement("div", { ...props, role: "button", className: "class-item-sortable-trigger" }, /* @__PURE__ */ React4.createElement(import_icons3.GripVerticalIcon, { fontSize: "tiny" }));
|
|
330
|
+
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
331
|
+
return /* @__PURE__ */ React4.createElement(
|
|
325
332
|
import_ui3.UnstableSortableItem,
|
|
326
333
|
{
|
|
327
|
-
|
|
334
|
+
...props,
|
|
335
|
+
id: id2,
|
|
328
336
|
render: ({
|
|
329
337
|
itemProps,
|
|
330
338
|
isDragged,
|
|
@@ -332,22 +340,35 @@ var SortableItem = ({ children, id }) => {
|
|
|
332
340
|
itemStyle,
|
|
333
341
|
triggerStyle,
|
|
334
342
|
dropIndicationStyle,
|
|
335
|
-
showDropIndication
|
|
343
|
+
showDropIndication,
|
|
344
|
+
isDragOverlay,
|
|
345
|
+
isDragPlaceholder
|
|
336
346
|
}) => {
|
|
337
|
-
return /* @__PURE__ */
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
347
|
+
return /* @__PURE__ */ React4.createElement(
|
|
348
|
+
StyledSortableItem,
|
|
349
|
+
{
|
|
350
|
+
...itemProps,
|
|
351
|
+
sx: itemStyle,
|
|
352
|
+
role: "listitem",
|
|
353
|
+
...isDragOverlay ? { component: import_ui3.Paper, elevation: 0 } : {}
|
|
354
|
+
},
|
|
355
|
+
/* @__PURE__ */ React4.createElement(SortableTrigger, { ...triggerProps, style: triggerStyle }),
|
|
356
|
+
children({
|
|
357
|
+
itemProps,
|
|
358
|
+
isDragged,
|
|
359
|
+
triggerProps,
|
|
360
|
+
itemStyle,
|
|
361
|
+
triggerStyle,
|
|
362
|
+
dropIndicationStyle,
|
|
363
|
+
showDropIndication,
|
|
364
|
+
isDragPlaceholder
|
|
365
|
+
})
|
|
366
|
+
);
|
|
346
367
|
}
|
|
347
368
|
}
|
|
348
369
|
);
|
|
349
370
|
};
|
|
350
|
-
var StyledSortableItem = (0, import_ui3.styled)(import_ui3.
|
|
371
|
+
var StyledSortableItem = (0, import_ui3.styled)(import_ui3.Box)`
|
|
351
372
|
position: relative;
|
|
352
373
|
|
|
353
374
|
&:hover {
|
|
@@ -376,21 +397,22 @@ var GlobalClassesList = () => {
|
|
|
376
397
|
const cssClasses = useOrderedClasses();
|
|
377
398
|
const [classesOrder, reorderClasses] = useReorder();
|
|
378
399
|
if (!cssClasses?.length) {
|
|
379
|
-
return /* @__PURE__ */
|
|
400
|
+
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
380
401
|
}
|
|
381
|
-
return /* @__PURE__ */
|
|
402
|
+
return /* @__PURE__ */ React5.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React5.createElement(import_ui4.List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id: id2, label }) => {
|
|
382
403
|
const renameClass = (newLabel) => {
|
|
383
|
-
globalClassesStylesProvider.actions.update({ label: newLabel, id });
|
|
404
|
+
globalClassesStylesProvider.actions.update({ label: newLabel, id: id2 });
|
|
384
405
|
};
|
|
385
|
-
return /* @__PURE__ */
|
|
406
|
+
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, showDropIndication, dropIndicationStyle, isDragPlaceholder }) => /* @__PURE__ */ React5.createElement(
|
|
386
407
|
ClassItem,
|
|
387
408
|
{
|
|
388
|
-
id,
|
|
409
|
+
id: id2,
|
|
389
410
|
label,
|
|
390
411
|
renameClass,
|
|
391
|
-
selected: isDragged
|
|
412
|
+
selected: isDragged,
|
|
413
|
+
disabled: isDragPlaceholder
|
|
392
414
|
},
|
|
393
|
-
showDropIndication && /* @__PURE__ */
|
|
415
|
+
showDropIndication && /* @__PURE__ */ React5.createElement(SortableItemIndicator, { style: dropIndicationStyle })
|
|
394
416
|
));
|
|
395
417
|
}))));
|
|
396
418
|
};
|
|
@@ -402,11 +424,12 @@ var useReorder = () => {
|
|
|
402
424
|
return [order, reorder];
|
|
403
425
|
};
|
|
404
426
|
var ClassItem = ({
|
|
405
|
-
id,
|
|
427
|
+
id: id2,
|
|
406
428
|
label,
|
|
407
429
|
renameClass,
|
|
408
430
|
selected,
|
|
409
|
-
children
|
|
431
|
+
children,
|
|
432
|
+
disabled
|
|
410
433
|
}) => {
|
|
411
434
|
const {
|
|
412
435
|
ref: editableRef,
|
|
@@ -424,23 +447,23 @@ var ClassItem = ({
|
|
|
424
447
|
variant: "popover",
|
|
425
448
|
disableAutoFocus: true
|
|
426
449
|
});
|
|
427
|
-
return /* @__PURE__ */
|
|
450
|
+
return /* @__PURE__ */ React5.createElement(import_ui4.Stack, { direction: "row", alignItems: "center", gap: 1, flexGrow: 1, flexShrink: 0 }, /* @__PURE__ */ React5.createElement(
|
|
428
451
|
StyledListItem,
|
|
429
452
|
{
|
|
430
453
|
component: "div",
|
|
431
454
|
disablePadding: true,
|
|
432
455
|
disableGutters: true,
|
|
433
|
-
secondaryAction: /* @__PURE__ */
|
|
456
|
+
secondaryAction: /* @__PURE__ */ React5.createElement(
|
|
434
457
|
import_ui4.Tooltip,
|
|
435
458
|
{
|
|
436
459
|
placement: "top",
|
|
437
460
|
className: "class-item-more-actions",
|
|
438
461
|
title: (0, import_i18n4.__)("More actions", "elementor")
|
|
439
462
|
},
|
|
440
|
-
/* @__PURE__ */
|
|
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" }))
|
|
441
464
|
)
|
|
442
465
|
},
|
|
443
|
-
/* @__PURE__ */
|
|
466
|
+
/* @__PURE__ */ React5.createElement(
|
|
444
467
|
import_ui4.ListItemButton,
|
|
445
468
|
{
|
|
446
469
|
dense: true,
|
|
@@ -448,6 +471,7 @@ var ClassItem = ({
|
|
|
448
471
|
shape: "rounded",
|
|
449
472
|
onDoubleClick: openEditMode,
|
|
450
473
|
selected: selected || popupState.isOpen,
|
|
474
|
+
disabled,
|
|
451
475
|
focusVisibleClassName: "visible-class-item",
|
|
452
476
|
sx: {
|
|
453
477
|
minHeight: "36px",
|
|
@@ -457,7 +481,7 @@ var ClassItem = ({
|
|
|
457
481
|
}
|
|
458
482
|
}
|
|
459
483
|
},
|
|
460
|
-
/* @__PURE__ */
|
|
484
|
+
/* @__PURE__ */ React5.createElement(Indicator, { isActive: isEditing, isError: !!error }, isEditing ? /* @__PURE__ */ React5.createElement(
|
|
461
485
|
import_editor_ui2.EditableField,
|
|
462
486
|
{
|
|
463
487
|
ref: editableRef,
|
|
@@ -466,10 +490,10 @@ var ClassItem = ({
|
|
|
466
490
|
variant: "caption",
|
|
467
491
|
...getEditableProps()
|
|
468
492
|
}
|
|
469
|
-
) : /* @__PURE__ */
|
|
493
|
+
) : /* @__PURE__ */ React5.createElement(import_editor_ui2.EllipsisWithTooltip, { title: label, as: import_ui4.Typography, variant: "caption" }))
|
|
470
494
|
),
|
|
471
495
|
children,
|
|
472
|
-
/* @__PURE__ */
|
|
496
|
+
/* @__PURE__ */ React5.createElement(
|
|
473
497
|
import_ui4.Menu,
|
|
474
498
|
{
|
|
475
499
|
...(0, import_ui4.bindMenu)(popupState),
|
|
@@ -482,7 +506,7 @@ var ClassItem = ({
|
|
|
482
506
|
horizontal: "right"
|
|
483
507
|
}
|
|
484
508
|
},
|
|
485
|
-
/* @__PURE__ */
|
|
509
|
+
/* @__PURE__ */ React5.createElement(
|
|
486
510
|
import_ui4.MenuItem,
|
|
487
511
|
{
|
|
488
512
|
sx: { minWidth: "160px" },
|
|
@@ -491,17 +515,17 @@ var ClassItem = ({
|
|
|
491
515
|
openEditMode();
|
|
492
516
|
}
|
|
493
517
|
},
|
|
494
|
-
/* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Rename", "elementor") })
|
|
495
519
|
),
|
|
496
|
-
/* @__PURE__ */
|
|
520
|
+
/* @__PURE__ */ React5.createElement(
|
|
497
521
|
import_ui4.MenuItem,
|
|
498
522
|
{
|
|
499
523
|
onClick: () => {
|
|
500
524
|
popupState.close();
|
|
501
|
-
openDialog({ id, label });
|
|
525
|
+
openDialog({ id: id2, label });
|
|
502
526
|
}
|
|
503
527
|
},
|
|
504
|
-
/* @__PURE__ */
|
|
528
|
+
/* @__PURE__ */ React5.createElement(import_ui4.ListItemText, { primary: (0, import_i18n4.__)("Delete", "elementor"), sx: { color: "error.light" } })
|
|
505
529
|
)
|
|
506
530
|
)
|
|
507
531
|
));
|
|
@@ -516,7 +540,7 @@ var StyledListItem = (0, import_ui4.styled)(import_ui4.ListItem)`
|
|
|
516
540
|
}
|
|
517
541
|
}
|
|
518
542
|
`;
|
|
519
|
-
var EmptyState = () => /* @__PURE__ */
|
|
543
|
+
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.__)(
|
|
520
544
|
"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.",
|
|
521
545
|
"elementor"
|
|
522
546
|
)));
|
|
@@ -555,22 +579,30 @@ var validateLabel = (newLabel) => {
|
|
|
555
579
|
return null;
|
|
556
580
|
};
|
|
557
581
|
|
|
558
|
-
// src/components/class-manager/
|
|
559
|
-
var
|
|
582
|
+
// src/components/class-manager/save-changes-dialog.tsx
|
|
583
|
+
var React6 = __toESM(require("react"));
|
|
560
584
|
var import_react3 = require("react");
|
|
561
|
-
var
|
|
585
|
+
var import_icons5 = require("@elementor/icons");
|
|
562
586
|
var import_ui5 = require("@elementor/ui");
|
|
563
|
-
var TITLE_ID2 = "
|
|
564
|
-
var
|
|
565
|
-
var
|
|
566
|
-
var
|
|
567
|
-
var
|
|
587
|
+
var TITLE_ID2 = "save-changes-dialog";
|
|
588
|
+
var SaveChangesDialog = ({ children, onClose }) => /* @__PURE__ */ React6.createElement(import_ui5.Dialog, { open: true, onClose, "aria-labelledby": TITLE_ID2, maxWidth: "xs" }, children);
|
|
589
|
+
var SaveChangesDialogTitle = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogTitle, { id: TITLE_ID2, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React6.createElement(import_icons5.AlertTriangleFilledIcon, { color: "secondary" }), children);
|
|
590
|
+
var SaveChangesDialogContent = ({ children }) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContent, null, children);
|
|
591
|
+
var SaveChangesDialogContentText = (props) => /* @__PURE__ */ React6.createElement(import_ui5.DialogContentText, { variant: "body2", color: "textPrimary", display: "flex", flexDirection: "column", ...props });
|
|
592
|
+
var SaveChangesDialogActions = ({ actions }) => {
|
|
593
|
+
const [isConfirming, setIsConfirming] = (0, import_react3.useState)(false);
|
|
568
594
|
const { cancel, confirm } = actions;
|
|
569
|
-
|
|
595
|
+
const onConfirm = async () => {
|
|
596
|
+
setIsConfirming(true);
|
|
597
|
+
await confirm.action();
|
|
598
|
+
setIsConfirming(false);
|
|
599
|
+
};
|
|
600
|
+
return /* @__PURE__ */ React6.createElement(import_ui5.DialogActions, null, /* @__PURE__ */ React6.createElement(import_ui5.Button, { variant: "text", color: "secondary", onClick: cancel.action }, cancel.label), /* @__PURE__ */ React6.createElement(import_ui5.Button, { variant: "contained", color: "secondary", onClick: onConfirm, loading: isConfirming }, confirm.label));
|
|
570
601
|
};
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
602
|
+
SaveChangesDialog.Title = SaveChangesDialogTitle;
|
|
603
|
+
SaveChangesDialog.Content = SaveChangesDialogContent;
|
|
604
|
+
SaveChangesDialog.ContentText = SaveChangesDialogContentText;
|
|
605
|
+
SaveChangesDialog.Actions = SaveChangesDialogActions;
|
|
574
606
|
var useDialog = () => {
|
|
575
607
|
const [isOpen, setIsOpen] = (0, import_react3.useState)(false);
|
|
576
608
|
const open = () => setIsOpen(true);
|
|
@@ -579,31 +611,32 @@ var useDialog = () => {
|
|
|
579
611
|
};
|
|
580
612
|
|
|
581
613
|
// src/components/class-manager/class-manager-panel.tsx
|
|
614
|
+
var id = "global-classes-manager";
|
|
582
615
|
var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
583
|
-
id
|
|
584
|
-
component: ClassManagerPanel
|
|
616
|
+
id,
|
|
617
|
+
component: ClassManagerPanel,
|
|
618
|
+
onOpen: () => (0, import_editor_v1_adapters.changeEditMode)(id),
|
|
619
|
+
onClose: () => (0, import_editor_v1_adapters.changeEditMode)("edit"),
|
|
620
|
+
allowedEditModes: ["edit", id]
|
|
585
621
|
});
|
|
586
622
|
function ClassManagerPanel() {
|
|
587
623
|
const isDirty3 = useDirtyState();
|
|
588
624
|
const { close: closePanel } = usePanelActions();
|
|
589
|
-
const {
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
isOpen: isUnsavedChangesDialogOpen
|
|
593
|
-
} = useDialog();
|
|
594
|
-
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement(import_ui6.ErrorBoundary, { fallback: /* @__PURE__ */ React6.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React6.createElement(import_editor_panels.Panel, null, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeader, null, /* @__PURE__ */ React6.createElement(import_ui6.Stack, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React6.createElement(import_editor_panels.PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React6.createElement(import_icons5.ColorSwatchIcon, { fontSize: "inherit", sx: { transform: "rotate(90deg)" } }), (0, import_i18n5.__)("CSS Class manager", "elementor")), /* @__PURE__ */ React6.createElement(
|
|
625
|
+
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
626
|
+
usePreventUnload();
|
|
627
|
+
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(
|
|
595
628
|
CloseButton,
|
|
596
629
|
{
|
|
597
630
|
sx: { marginLeft: "auto" },
|
|
598
631
|
onClose: () => {
|
|
599
632
|
if (isDirty3) {
|
|
600
|
-
|
|
633
|
+
openSaveChangesDialog();
|
|
601
634
|
return;
|
|
602
635
|
}
|
|
603
636
|
closePanel();
|
|
604
637
|
}
|
|
605
638
|
}
|
|
606
|
-
))), /* @__PURE__ */
|
|
639
|
+
))), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelBody, { px: 2 }, /* @__PURE__ */ React7.createElement(GlobalClassesList, null)), /* @__PURE__ */ React7.createElement(import_editor_panels.PanelFooter, null, /* @__PURE__ */ React7.createElement(
|
|
607
640
|
import_ui6.Button,
|
|
608
641
|
{
|
|
609
642
|
fullWidth: true,
|
|
@@ -614,19 +647,19 @@ function ClassManagerPanel() {
|
|
|
614
647
|
onClick: publishGlobalClasses
|
|
615
648
|
},
|
|
616
649
|
(0, import_i18n5.__)("Save changes", "elementor")
|
|
617
|
-
)))), /* @__PURE__ */
|
|
618
|
-
|
|
650
|
+
)))), /* @__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(
|
|
651
|
+
SaveChangesDialog.Actions,
|
|
619
652
|
{
|
|
620
653
|
actions: {
|
|
621
654
|
cancel: {
|
|
622
655
|
label: (0, import_i18n5.__)("Cancel", "elementor"),
|
|
623
|
-
action:
|
|
656
|
+
action: closeSaveChangesDialog
|
|
624
657
|
},
|
|
625
658
|
confirm: {
|
|
626
659
|
label: (0, import_i18n5.__)("Save & Continue", "elementor"),
|
|
627
|
-
action: () => {
|
|
628
|
-
publishGlobalClasses();
|
|
629
|
-
|
|
660
|
+
action: async () => {
|
|
661
|
+
await publishGlobalClasses();
|
|
662
|
+
closeSaveChangesDialog();
|
|
630
663
|
closePanel();
|
|
631
664
|
}
|
|
632
665
|
}
|
|
@@ -634,21 +667,66 @@ function ClassManagerPanel() {
|
|
|
634
667
|
}
|
|
635
668
|
)));
|
|
636
669
|
}
|
|
637
|
-
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */
|
|
638
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */
|
|
670
|
+
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
|
+
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
|
+
var usePreventUnload = () => {
|
|
673
|
+
const isDirty3 = useDirtyState();
|
|
674
|
+
(0, import_react4.useEffect)(() => {
|
|
675
|
+
const handleBeforeUnload = (event) => {
|
|
676
|
+
if (isDirty3) {
|
|
677
|
+
event.preventDefault();
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
window.addEventListener("beforeunload", handleBeforeUnload);
|
|
681
|
+
return () => {
|
|
682
|
+
window.removeEventListener("beforeunload", handleBeforeUnload);
|
|
683
|
+
};
|
|
684
|
+
}, [isDirty3]);
|
|
685
|
+
};
|
|
639
686
|
|
|
640
687
|
// src/components/class-manager/class-manager-button.tsx
|
|
641
688
|
var ClassManagerButton = () => {
|
|
642
|
-
const
|
|
643
|
-
|
|
689
|
+
const document = (0, import_editor_documents.__useActiveDocument)();
|
|
690
|
+
const { open: openPanel } = usePanelActions();
|
|
691
|
+
const { save: saveDocument } = (0, import_editor_documents.__useActiveDocumentActions)();
|
|
692
|
+
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
693
|
+
const handleOpenPanel = () => {
|
|
694
|
+
if (document?.isDirty) {
|
|
695
|
+
openSaveChangesDialog();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
openPanel();
|
|
699
|
+
};
|
|
700
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0, import_i18n6.__)("Class manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(import_ui7.IconButton, { onClick: handleOpenPanel }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, (0, import_i18n6.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n6.__)(
|
|
701
|
+
"Save your changes before moving to the class manager to ensure all updates are applied and saved.",
|
|
702
|
+
"elementor"
|
|
703
|
+
)), /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n6.__)("If you leave without saving, all changes will be discarded.", "elementor"))), /* @__PURE__ */ React8.createElement(
|
|
704
|
+
SaveChangesDialog.Actions,
|
|
705
|
+
{
|
|
706
|
+
actions: {
|
|
707
|
+
cancel: {
|
|
708
|
+
label: (0, import_i18n6.__)("Keep editing", "elementor"),
|
|
709
|
+
action: closeSaveChangesDialog
|
|
710
|
+
},
|
|
711
|
+
confirm: {
|
|
712
|
+
label: (0, import_i18n6.__)("Save & Continue", "elementor"),
|
|
713
|
+
action: async () => {
|
|
714
|
+
await saveDocument();
|
|
715
|
+
closeSaveChangesDialog();
|
|
716
|
+
openPanel();
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
)));
|
|
644
722
|
};
|
|
645
723
|
|
|
646
724
|
// src/components/populate-store.tsx
|
|
647
|
-
var
|
|
725
|
+
var import_react5 = require("react");
|
|
648
726
|
var import_store12 = require("@elementor/store");
|
|
649
727
|
function PopulateStore() {
|
|
650
728
|
const dispatch3 = (0, import_store12.__useDispatch)();
|
|
651
|
-
(0,
|
|
729
|
+
(0, import_react5.useEffect)(() => {
|
|
652
730
|
apiClient.all().then((res) => {
|
|
653
731
|
const { data, meta } = res.data;
|
|
654
732
|
dispatch3(slice.actions.init({ items: data, order: meta.order }));
|
|
@@ -658,7 +736,7 @@ function PopulateStore() {
|
|
|
658
736
|
}
|
|
659
737
|
|
|
660
738
|
// src/sync-with-document-save.ts
|
|
661
|
-
var
|
|
739
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
662
740
|
var import_store14 = require("@elementor/store");
|
|
663
741
|
function syncWithDocumentSave() {
|
|
664
742
|
const unsubscribe = syncDirtyState();
|
|
@@ -670,11 +748,11 @@ function syncDirtyState() {
|
|
|
670
748
|
if (!isDirty2()) {
|
|
671
749
|
return;
|
|
672
750
|
}
|
|
673
|
-
(0,
|
|
751
|
+
(0, import_editor_v1_adapters2.__privateRunCommandSync)("document/save/set-is-modified", { status: true }, { internal: true });
|
|
674
752
|
});
|
|
675
753
|
}
|
|
676
754
|
function bindSaveAction() {
|
|
677
|
-
(0,
|
|
755
|
+
(0, import_editor_v1_adapters2.registerDataHook)("after", "document/save/save", publishGlobalClasses);
|
|
678
756
|
}
|
|
679
757
|
function isDirty2() {
|
|
680
758
|
return selectIsDirty((0, import_store14.__getState)());
|
|
@@ -693,7 +771,7 @@ function init() {
|
|
|
693
771
|
id: "global-classes-manager-button",
|
|
694
772
|
component: ClassManagerButton
|
|
695
773
|
});
|
|
696
|
-
(0,
|
|
774
|
+
(0, import_editor_v1_adapters3.__privateListenTo)((0, import_editor_v1_adapters3.v1ReadyEvent)(), () => {
|
|
697
775
|
syncWithDocumentSave();
|
|
698
776
|
});
|
|
699
777
|
}
|