@elementor/editor-global-classes 0.14.1 → 0.15.4
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 +77 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +194 -138
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +173 -134
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/components/class-manager/class-manager-button.tsx +3 -6
- package/src/components/class-manager/class-manager-introduction.tsx +13 -11
- package/src/components/class-manager/class-manager-panel.tsx +83 -91
- package/src/components/class-manager/delete-class.ts +36 -0
- package/src/components/class-manager/delete-confirmation-dialog.tsx +4 -4
- package/src/components/class-manager/global-classes-list.tsx +18 -10
- package/src/components/class-manager/panel-interactions.ts +24 -0
- package/src/global-classes-styles-provider.ts +10 -13
- package/src/index.ts +1 -3
package/dist/index.js
CHANGED
|
@@ -5,6 +5,10 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
8
12
|
var __copyProps = (to, from, except, desc) => {
|
|
9
13
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
14
|
for (let key of __getOwnPropNames(from))
|
|
@@ -21,32 +25,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/index.ts
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
|
+
init: () => init
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(index_exports);
|
|
24
36
|
|
|
25
37
|
// src/init.ts
|
|
26
38
|
var import_editor = require("@elementor/editor");
|
|
27
39
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
28
40
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var
|
|
41
|
+
var import_editor_styles_repository3 = require("@elementor/editor-styles-repository");
|
|
42
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
43
|
+
var import_store20 = require("@elementor/store");
|
|
32
44
|
|
|
33
45
|
// src/components/class-manager/class-manager-button.tsx
|
|
34
46
|
var React8 = __toESM(require("react"));
|
|
35
|
-
var
|
|
47
|
+
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
36
48
|
var import_ui7 = require("@elementor/ui");
|
|
37
|
-
var
|
|
49
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
38
50
|
|
|
39
51
|
// src/components/class-manager/class-manager-panel.tsx
|
|
40
52
|
var React7 = __toESM(require("react"));
|
|
41
53
|
var import_react4 = require("react");
|
|
42
|
-
var
|
|
54
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
43
55
|
var import_editor_panels = require("@elementor/editor-panels");
|
|
44
56
|
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
45
|
-
var
|
|
57
|
+
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
46
58
|
var import_icons6 = require("@elementor/icons");
|
|
47
59
|
var import_query = require("@elementor/query");
|
|
48
60
|
var import_ui6 = require("@elementor/ui");
|
|
49
|
-
var
|
|
61
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
50
62
|
|
|
51
63
|
// src/hooks/use-dirty-state.ts
|
|
52
64
|
var import_store2 = require("@elementor/store");
|
|
@@ -195,31 +207,60 @@ var ClassManagerIntroduction = () => {
|
|
|
195
207
|
import_editor_ui.IntroductionModal,
|
|
196
208
|
{
|
|
197
209
|
open: shouldShowIntroduction,
|
|
198
|
-
title: (0, import_i18n.__)("
|
|
199
|
-
image: {
|
|
200
|
-
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
201
|
-
alt: (0, import_i18n.__)("Class manager screenshot", "elementor")
|
|
202
|
-
},
|
|
203
|
-
content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
|
|
210
|
+
title: (0, import_i18n.__)("Class Manager", "elementor"),
|
|
204
211
|
handleClose: (shouldShowAgain) => {
|
|
205
212
|
if (!shouldShowAgain) {
|
|
206
213
|
suppressMessage();
|
|
207
214
|
}
|
|
208
215
|
setShouldShowIntroduction(false);
|
|
209
216
|
}
|
|
210
|
-
}
|
|
217
|
+
},
|
|
218
|
+
/* @__PURE__ */ React.createElement(
|
|
219
|
+
import_ui.Image,
|
|
220
|
+
{
|
|
221
|
+
sx: { width: "100%", aspectRatio: "16 / 9" },
|
|
222
|
+
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
223
|
+
alt: ""
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ React.createElement(IntroductionContent, null)
|
|
211
227
|
);
|
|
212
228
|
};
|
|
213
229
|
var IntroductionContent = () => {
|
|
214
|
-
return /* @__PURE__ */ React.createElement(import_ui.Box, {
|
|
215
|
-
"The
|
|
230
|
+
return /* @__PURE__ */ React.createElement(import_ui.Box, { p: 3 }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
|
|
231
|
+
"The Class Manager lets you see all the classes you've created, plus adjust their priority, rename them, and delete unused classes to keep your CSS structured.",
|
|
216
232
|
"elementor"
|
|
217
233
|
)), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n.__)(
|
|
218
|
-
"
|
|
234
|
+
"Remember, when editing an item within a specific class, any changes you make will apply across all elements in that class.",
|
|
219
235
|
"elementor"
|
|
220
236
|
)));
|
|
221
237
|
};
|
|
222
238
|
|
|
239
|
+
// src/components/class-manager/delete-class.ts
|
|
240
|
+
var import_editor_documents = require("@elementor/editor-documents");
|
|
241
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
242
|
+
var import_store6 = require("@elementor/store");
|
|
243
|
+
var isDeleted = false;
|
|
244
|
+
var deleteClass = (id2) => {
|
|
245
|
+
(0, import_store6.__dispatch)(slice.actions.delete(id2));
|
|
246
|
+
isDeleted = true;
|
|
247
|
+
};
|
|
248
|
+
var onDelete = async () => {
|
|
249
|
+
await reloadDocument();
|
|
250
|
+
isDeleted = false;
|
|
251
|
+
};
|
|
252
|
+
var hasDeletedItems = () => isDeleted;
|
|
253
|
+
var reloadDocument = () => {
|
|
254
|
+
const currentDocument = (0, import_editor_documents.getCurrentDocument)();
|
|
255
|
+
const documentsManager = (0, import_editor_documents.getV1DocumentsManager)();
|
|
256
|
+
documentsManager.invalidateCache();
|
|
257
|
+
return (0, import_editor_v1_adapters.__privateRunCommand)("editor/documents/switch", {
|
|
258
|
+
id: currentDocument?.id,
|
|
259
|
+
shouldScroll: false,
|
|
260
|
+
shouldNavigateToDefaultRoute: false
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
|
|
223
264
|
// src/components/class-manager/flipped-color-swatch-icon.tsx
|
|
224
265
|
var React2 = __toESM(require("react"));
|
|
225
266
|
var import_icons = require("@elementor/icons");
|
|
@@ -230,68 +271,9 @@ var React5 = __toESM(require("react"));
|
|
|
230
271
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
231
272
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
232
273
|
var import_icons4 = require("@elementor/icons");
|
|
274
|
+
var import_store12 = require("@elementor/store");
|
|
233
275
|
var import_ui4 = require("@elementor/ui");
|
|
234
|
-
var
|
|
235
|
-
|
|
236
|
-
// src/global-classes-styles-provider.ts
|
|
237
|
-
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
238
|
-
var import_store6 = require("@elementor/store");
|
|
239
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
240
|
-
var MAX_CLASSES = 50;
|
|
241
|
-
var globalClassesStylesProvider = {
|
|
242
|
-
key: "global-classes",
|
|
243
|
-
priority: 30,
|
|
244
|
-
limit: MAX_CLASSES,
|
|
245
|
-
actions: {
|
|
246
|
-
get: () => selectOrderedClasses((0, import_store6.__getState)()),
|
|
247
|
-
getById: (id2) => selectClass((0, import_store6.__getState)(), id2),
|
|
248
|
-
create: (label) => {
|
|
249
|
-
const classes = selectGlobalClasses((0, import_store6.__getState)());
|
|
250
|
-
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
251
|
-
if (existingLabels.includes(label)) {
|
|
252
|
-
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
253
|
-
}
|
|
254
|
-
const existingIds = Object.keys(classes);
|
|
255
|
-
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
256
|
-
(0, import_store6.__dispatch)(
|
|
257
|
-
slice.actions.add({
|
|
258
|
-
id: id2,
|
|
259
|
-
type: "class",
|
|
260
|
-
label,
|
|
261
|
-
variants: []
|
|
262
|
-
})
|
|
263
|
-
);
|
|
264
|
-
return id2;
|
|
265
|
-
},
|
|
266
|
-
update: (payload) => {
|
|
267
|
-
(0, import_store6.__dispatch)(
|
|
268
|
-
slice.actions.update({
|
|
269
|
-
style: payload
|
|
270
|
-
})
|
|
271
|
-
);
|
|
272
|
-
},
|
|
273
|
-
delete: (id2) => {
|
|
274
|
-
(0, import_store6.__dispatch)(slice.actions.delete(id2));
|
|
275
|
-
},
|
|
276
|
-
setOrder: (order) => {
|
|
277
|
-
(0, import_store6.__dispatch)(slice.actions.setOrder(order));
|
|
278
|
-
},
|
|
279
|
-
updateProps: (args) => {
|
|
280
|
-
(0, import_store6.__dispatch)(
|
|
281
|
-
slice.actions.updateProps({
|
|
282
|
-
id: args.id,
|
|
283
|
-
meta: args.meta,
|
|
284
|
-
props: args.props
|
|
285
|
-
})
|
|
286
|
-
);
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
subscribe: (cb) => (0, import_store6.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
290
|
-
labels: {
|
|
291
|
-
singular: (0, import_i18n2.__)("Global class", "elementor"),
|
|
292
|
-
plural: (0, import_i18n2.__)("Global CSS classes", "elementor")
|
|
293
|
-
}
|
|
294
|
-
};
|
|
276
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
295
277
|
|
|
296
278
|
// src/hooks/use-classes-order.ts
|
|
297
279
|
var import_store8 = require("@elementor/store");
|
|
@@ -310,7 +292,7 @@ var React3 = __toESM(require("react"));
|
|
|
310
292
|
var import_react2 = require("react");
|
|
311
293
|
var import_icons2 = require("@elementor/icons");
|
|
312
294
|
var import_ui2 = require("@elementor/ui");
|
|
313
|
-
var
|
|
295
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
314
296
|
var context = (0, import_react2.createContext)(null);
|
|
315
297
|
var DeleteConfirmationProvider = ({ children }) => {
|
|
316
298
|
const [dialogProps, setDialogProps] = (0, import_react2.useState)(null);
|
|
@@ -326,13 +308,13 @@ var TITLE_ID = "delete-class-dialog";
|
|
|
326
308
|
var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
327
309
|
const { closeDialog } = useDeleteConfirmation();
|
|
328
310
|
const onConfirm = () => {
|
|
329
|
-
|
|
311
|
+
deleteClass(id2);
|
|
330
312
|
closeDialog();
|
|
331
313
|
};
|
|
332
|
-
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,
|
|
314
|
+
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_i18n2.__)("Delete this class?", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.DialogContent, null, /* @__PURE__ */ React3.createElement(import_ui2.DialogContentText, { variant: "body2", color: "textPrimary" }, (0, import_i18n2.__)("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(import_ui2.Typography, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), (0, import_i18n2.__)(
|
|
333
315
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
334
316
|
"elementor"
|
|
335
|
-
))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0,
|
|
317
|
+
))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n2.__)("Not now", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n2.__)("Delete", "elementor"))));
|
|
336
318
|
};
|
|
337
319
|
var useDeleteConfirmation = () => {
|
|
338
320
|
const contextValue = (0, import_react2.useContext)(context);
|
|
@@ -406,13 +388,21 @@ var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
|
|
|
406
388
|
// src/components/class-manager/global-classes-list.tsx
|
|
407
389
|
var GlobalClassesList = ({ disabled }) => {
|
|
408
390
|
const cssClasses = useOrderedClasses();
|
|
391
|
+
const dispatch4 = (0, import_store12.__useDispatch)();
|
|
409
392
|
const [classesOrder, reorderClasses] = useReorder();
|
|
410
393
|
if (!cssClasses?.length) {
|
|
411
394
|
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
412
395
|
}
|
|
413
396
|
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 }) => {
|
|
414
397
|
const renameClass = (newLabel) => {
|
|
415
|
-
|
|
398
|
+
dispatch4(
|
|
399
|
+
slice.actions.update({
|
|
400
|
+
style: {
|
|
401
|
+
id: id2,
|
|
402
|
+
label: newLabel
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
);
|
|
416
406
|
};
|
|
417
407
|
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
418
408
|
ClassItem,
|
|
@@ -428,9 +418,10 @@ var GlobalClassesList = ({ disabled }) => {
|
|
|
428
418
|
}))));
|
|
429
419
|
};
|
|
430
420
|
var useReorder = () => {
|
|
421
|
+
const dispatch4 = (0, import_store12.__useDispatch)();
|
|
431
422
|
const order = useClassesOrder();
|
|
432
423
|
const reorder = (newIds) => {
|
|
433
|
-
|
|
424
|
+
dispatch4(slice.actions.setOrder(newIds));
|
|
434
425
|
};
|
|
435
426
|
return [order, reorder];
|
|
436
427
|
};
|
|
@@ -480,7 +471,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
480
471
|
{
|
|
481
472
|
placement: "top",
|
|
482
473
|
className: "class-item-more-actions",
|
|
483
|
-
title: (0,
|
|
474
|
+
title: (0, import_i18n3.__)("More actions", "elementor")
|
|
484
475
|
},
|
|
485
476
|
/* @__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
477
|
)
|
|
@@ -506,7 +497,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
506
497
|
openEditMode();
|
|
507
498
|
}
|
|
508
499
|
},
|
|
509
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0,
|
|
500
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n3.__)("Rename", "elementor"))
|
|
510
501
|
),
|
|
511
502
|
/* @__PURE__ */ React5.createElement(
|
|
512
503
|
import_editor_ui2.MenuListItem,
|
|
@@ -516,7 +507,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
516
507
|
openDialog({ id: id2, label });
|
|
517
508
|
}
|
|
518
509
|
},
|
|
519
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "error.light" } }, (0,
|
|
510
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n3.__)("Delete", "elementor"))
|
|
520
511
|
)
|
|
521
512
|
));
|
|
522
513
|
};
|
|
@@ -545,7 +536,7 @@ var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
|
|
|
545
536
|
}
|
|
546
537
|
`
|
|
547
538
|
);
|
|
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,
|
|
539
|
+
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_i18n3.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(import_ui4.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n3.__)(
|
|
549
540
|
"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.",
|
|
550
541
|
"elementor"
|
|
551
542
|
)));
|
|
@@ -576,15 +567,23 @@ var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
|
576
567
|
return "none";
|
|
577
568
|
};
|
|
578
569
|
var validateLabel = (newLabel) => {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
if (import_editor_styles_repository.stylesRepository.isLabelExist(newLabel)) {
|
|
583
|
-
return (0, import_i18n4.__)("Existing name", "elementor");
|
|
570
|
+
const result = (0, import_editor_styles_repository.validateStyleLabel)(newLabel);
|
|
571
|
+
if (result.isValid) {
|
|
572
|
+
return null;
|
|
584
573
|
}
|
|
585
|
-
return
|
|
574
|
+
return result.error;
|
|
586
575
|
};
|
|
587
576
|
|
|
577
|
+
// src/components/class-manager/panel-interactions.ts
|
|
578
|
+
function blockPanelInteractions() {
|
|
579
|
+
const extendedWindow = window;
|
|
580
|
+
extendedWindow.$e?.components?.get?.("panel")?.blockUserInteractions?.();
|
|
581
|
+
}
|
|
582
|
+
function unblockPanelInteractions() {
|
|
583
|
+
const extendedWindow = window;
|
|
584
|
+
extendedWindow.$e?.components?.get?.("panel")?.unblockUserInteractions?.();
|
|
585
|
+
}
|
|
586
|
+
|
|
588
587
|
// src/components/class-manager/save-changes-dialog.tsx
|
|
589
588
|
var React6 = __toESM(require("react"));
|
|
590
589
|
var import_react3 = require("react");
|
|
@@ -623,14 +622,12 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
623
622
|
component: ClassManagerPanel,
|
|
624
623
|
allowedEditModes: ["edit", id],
|
|
625
624
|
onOpen: () => {
|
|
626
|
-
(0,
|
|
627
|
-
|
|
625
|
+
(0, import_editor_v1_adapters2.changeEditMode)(id);
|
|
626
|
+
blockPanelInteractions();
|
|
628
627
|
},
|
|
629
|
-
onClose: (
|
|
630
|
-
(0,
|
|
631
|
-
|
|
632
|
-
(0, import_editor_documents.setDocumentModifiedStatus)(documentModifiedState);
|
|
633
|
-
}
|
|
628
|
+
onClose: () => {
|
|
629
|
+
(0, import_editor_v1_adapters2.changeEditMode)("edit");
|
|
630
|
+
unblockPanelInteractions();
|
|
634
631
|
}
|
|
635
632
|
});
|
|
636
633
|
function ClassManagerPanel() {
|
|
@@ -639,10 +636,11 @@ function ClassManagerPanel() {
|
|
|
639
636
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
640
637
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
641
638
|
usePreventUnload();
|
|
642
|
-
return /* @__PURE__ */ React7.createElement(
|
|
639
|
+
return /* @__PURE__ */ React7.createElement(import_editor_ui3.ThemeProvider, 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_i18n4.__)("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
643
640
|
CloseButton,
|
|
644
641
|
{
|
|
645
642
|
sx: { marginLeft: "auto" },
|
|
643
|
+
disabled: isPublishing,
|
|
646
644
|
onClose: () => {
|
|
647
645
|
if (isDirty2) {
|
|
648
646
|
openSaveChangesDialog();
|
|
@@ -662,17 +660,17 @@ function ClassManagerPanel() {
|
|
|
662
660
|
disabled: !isDirty2,
|
|
663
661
|
loading: isPublishing
|
|
664
662
|
},
|
|
665
|
-
(0,
|
|
666
|
-
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0,
|
|
663
|
+
(0, import_i18n4.__)("Save changes", "elementor")
|
|
664
|
+
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0, import_i18n4.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n4.__)("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, (0, import_i18n4.__)("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
|
|
667
665
|
SaveChangesDialog.Actions,
|
|
668
666
|
{
|
|
669
667
|
actions: {
|
|
670
668
|
cancel: {
|
|
671
|
-
label: (0,
|
|
669
|
+
label: (0, import_i18n4.__)("Cancel", "elementor"),
|
|
672
670
|
action: closeSaveChangesDialog
|
|
673
671
|
},
|
|
674
672
|
confirm: {
|
|
675
|
-
label: (0,
|
|
673
|
+
label: (0, import_i18n4.__)("Save & Continue", "elementor"),
|
|
676
674
|
action: async () => {
|
|
677
675
|
await publish();
|
|
678
676
|
closeSaveChangesDialog();
|
|
@@ -681,10 +679,10 @@ function ClassManagerPanel() {
|
|
|
681
679
|
}
|
|
682
680
|
}
|
|
683
681
|
}
|
|
684
|
-
)))
|
|
682
|
+
)));
|
|
685
683
|
}
|
|
686
684
|
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" }));
|
|
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,
|
|
685
|
+
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_i18n4.__)("Something went wrong", "elementor"))));
|
|
688
686
|
var usePreventUnload = () => {
|
|
689
687
|
const isDirty2 = useDirtyState();
|
|
690
688
|
(0, import_react4.useEffect)(() => {
|
|
@@ -700,13 +698,12 @@ var usePreventUnload = () => {
|
|
|
700
698
|
}, [isDirty2]);
|
|
701
699
|
};
|
|
702
700
|
var usePublish = () => {
|
|
703
|
-
const document = (0, import_editor_documents.__useActiveDocument)();
|
|
704
|
-
const [initialDocumentStatus] = (0, import_react4.useState)(document?.isDirty ?? false);
|
|
705
701
|
return (0, import_query.useMutation)({
|
|
706
702
|
mutationFn: () => saveGlobalClasses({ context: "frontend" }),
|
|
707
|
-
onSuccess: () => {
|
|
708
|
-
|
|
709
|
-
|
|
703
|
+
onSuccess: async () => {
|
|
704
|
+
(0, import_editor_documents2.setDocumentModifiedStatus)(false);
|
|
705
|
+
if (hasDeletedItems()) {
|
|
706
|
+
await onDelete();
|
|
710
707
|
}
|
|
711
708
|
}
|
|
712
709
|
});
|
|
@@ -714,9 +711,9 @@ var usePublish = () => {
|
|
|
714
711
|
|
|
715
712
|
// src/components/class-manager/class-manager-button.tsx
|
|
716
713
|
var ClassManagerButton = () => {
|
|
717
|
-
const document = (0,
|
|
714
|
+
const document = (0, import_editor_documents3.__useActiveDocument)();
|
|
718
715
|
const { open: openPanel } = usePanelActions();
|
|
719
|
-
const { save: saveDocument } = (0,
|
|
716
|
+
const { save: saveDocument } = (0, import_editor_documents3.__useActiveDocumentActions)();
|
|
720
717
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
721
718
|
const handleOpenPanel = () => {
|
|
722
719
|
if (document?.isDirty) {
|
|
@@ -725,19 +722,19 @@ var ClassManagerButton = () => {
|
|
|
725
722
|
}
|
|
726
723
|
openPanel();
|
|
727
724
|
};
|
|
728
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0,
|
|
729
|
-
"
|
|
725
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0, import_i18n5.__)("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_i18n5.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n5.__)(
|
|
726
|
+
"To open the Class Manager, save your page first. You can't continue without saving.",
|
|
730
727
|
"elementor"
|
|
731
|
-
))
|
|
728
|
+
))), /* @__PURE__ */ React8.createElement(
|
|
732
729
|
SaveChangesDialog.Actions,
|
|
733
730
|
{
|
|
734
731
|
actions: {
|
|
735
732
|
cancel: {
|
|
736
|
-
label: (0,
|
|
733
|
+
label: (0, import_i18n5.__)("Stay here", "elementor"),
|
|
737
734
|
action: closeSaveChangesDialog
|
|
738
735
|
},
|
|
739
736
|
confirm: {
|
|
740
|
-
label: (0,
|
|
737
|
+
label: (0, import_i18n5.__)("Save & Continue", "elementor"),
|
|
741
738
|
action: async () => {
|
|
742
739
|
await saveDocument();
|
|
743
740
|
closeSaveChangesDialog();
|
|
@@ -751,51 +748,109 @@ var ClassManagerButton = () => {
|
|
|
751
748
|
|
|
752
749
|
// src/components/populate-store.tsx
|
|
753
750
|
var import_react5 = require("react");
|
|
754
|
-
var
|
|
751
|
+
var import_store14 = require("@elementor/store");
|
|
755
752
|
function PopulateStore() {
|
|
756
|
-
const
|
|
753
|
+
const dispatch4 = (0, import_store14.__useDispatch)();
|
|
757
754
|
(0, import_react5.useEffect)(() => {
|
|
758
755
|
apiClient.all().then((res) => {
|
|
759
756
|
const { data, meta } = res.data;
|
|
760
|
-
|
|
757
|
+
dispatch4(slice.actions.init({ items: data, order: meta.order }));
|
|
761
758
|
});
|
|
762
|
-
}, [
|
|
759
|
+
}, [dispatch4]);
|
|
763
760
|
return null;
|
|
764
761
|
}
|
|
765
762
|
|
|
763
|
+
// src/global-classes-styles-provider.ts
|
|
764
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
765
|
+
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
766
|
+
var import_store16 = require("@elementor/store");
|
|
767
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
768
|
+
var MAX_CLASSES = 50;
|
|
769
|
+
var globalClassesStylesProvider = (0, import_editor_styles_repository2.createStylesProvider)({
|
|
770
|
+
key: "global-classes",
|
|
771
|
+
priority: 30,
|
|
772
|
+
limit: MAX_CLASSES,
|
|
773
|
+
labels: {
|
|
774
|
+
singular: (0, import_i18n6.__)("class", "elementor"),
|
|
775
|
+
plural: (0, import_i18n6.__)("classes", "elementor")
|
|
776
|
+
},
|
|
777
|
+
subscribe: (cb) => (0, import_store16.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
778
|
+
actions: {
|
|
779
|
+
all: () => selectOrderedClasses((0, import_store16.__getState)()),
|
|
780
|
+
get: (id2) => selectClass((0, import_store16.__getState)(), id2),
|
|
781
|
+
create: (label) => {
|
|
782
|
+
const classes = selectGlobalClasses((0, import_store16.__getState)());
|
|
783
|
+
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
784
|
+
if (existingLabels.includes(label)) {
|
|
785
|
+
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
786
|
+
}
|
|
787
|
+
const existingIds = Object.keys(classes);
|
|
788
|
+
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
789
|
+
(0, import_store16.__dispatch)(
|
|
790
|
+
slice.actions.add({
|
|
791
|
+
id: id2,
|
|
792
|
+
type: "class",
|
|
793
|
+
label,
|
|
794
|
+
variants: []
|
|
795
|
+
})
|
|
796
|
+
);
|
|
797
|
+
return id2;
|
|
798
|
+
},
|
|
799
|
+
update: (payload) => {
|
|
800
|
+
(0, import_store16.__dispatch)(
|
|
801
|
+
slice.actions.update({
|
|
802
|
+
style: payload
|
|
803
|
+
})
|
|
804
|
+
);
|
|
805
|
+
},
|
|
806
|
+
delete: (id2) => {
|
|
807
|
+
(0, import_store16.__dispatch)(slice.actions.delete(id2));
|
|
808
|
+
},
|
|
809
|
+
updateProps: (args) => {
|
|
810
|
+
(0, import_store16.__dispatch)(
|
|
811
|
+
slice.actions.updateProps({
|
|
812
|
+
id: args.id,
|
|
813
|
+
meta: args.meta,
|
|
814
|
+
props: args.props
|
|
815
|
+
})
|
|
816
|
+
);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
});
|
|
820
|
+
|
|
766
821
|
// src/sync-with-document-save.ts
|
|
767
|
-
var
|
|
768
|
-
var
|
|
769
|
-
var
|
|
822
|
+
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
823
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
824
|
+
var import_store18 = require("@elementor/store");
|
|
770
825
|
function syncWithDocumentSave() {
|
|
771
826
|
const unsubscribe = syncDirtyState();
|
|
772
827
|
bindSaveAction();
|
|
773
828
|
return unsubscribe;
|
|
774
829
|
}
|
|
775
830
|
function syncDirtyState() {
|
|
776
|
-
return (0,
|
|
831
|
+
return (0, import_store18.__subscribeWithSelector)(selectIsDirty, () => {
|
|
777
832
|
if (!isDirty()) {
|
|
778
833
|
return;
|
|
779
834
|
}
|
|
780
|
-
(0,
|
|
835
|
+
(0, import_editor_documents4.setDocumentModifiedStatus)(true);
|
|
781
836
|
});
|
|
782
837
|
}
|
|
783
838
|
function bindSaveAction() {
|
|
784
|
-
(0,
|
|
839
|
+
(0, import_editor_v1_adapters3.registerDataHook)("after", "document/save/save", (args) => {
|
|
785
840
|
return saveGlobalClasses({
|
|
786
841
|
context: args.status === "publish" ? "frontend" : "preview"
|
|
787
842
|
});
|
|
788
843
|
});
|
|
789
844
|
}
|
|
790
845
|
function isDirty() {
|
|
791
|
-
return selectIsDirty((0,
|
|
846
|
+
return selectIsDirty((0, import_store18.__getState)());
|
|
792
847
|
}
|
|
793
848
|
|
|
794
849
|
// src/init.ts
|
|
795
850
|
function init() {
|
|
796
|
-
(0,
|
|
851
|
+
(0, import_store20.__registerSlice)(slice);
|
|
797
852
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
798
|
-
|
|
853
|
+
import_editor_styles_repository3.stylesRepository.register(globalClassesStylesProvider);
|
|
799
854
|
(0, import_editor.injectIntoLogic)({
|
|
800
855
|
id: "global-classes-populate-store",
|
|
801
856
|
component: PopulateStore
|
|
@@ -804,11 +859,12 @@ function init() {
|
|
|
804
859
|
id: "global-classes-manager-button",
|
|
805
860
|
component: ClassManagerButton
|
|
806
861
|
});
|
|
807
|
-
(0,
|
|
862
|
+
(0, import_editor_v1_adapters4.__privateListenTo)((0, import_editor_v1_adapters4.v1ReadyEvent)(), () => {
|
|
808
863
|
syncWithDocumentSave();
|
|
809
864
|
});
|
|
810
865
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
init
|
|
866
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
867
|
+
0 && (module.exports = {
|
|
868
|
+
init
|
|
869
|
+
});
|
|
814
870
|
//# sourceMappingURL=index.js.map
|