@elementor/editor-global-classes 0.15.3 → 0.16.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 +41 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +143 -109
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +132 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
- package/src/components/class-manager/class-manager-button.tsx +1 -1
- package/src/components/class-manager/class-manager-introduction.tsx +9 -7
- package/src/components/class-manager/class-manager-panel.tsx +5 -0
- package/src/components/class-manager/delete-class.ts +4 -2
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @elementor/editor-global-classes
|
|
2
2
|
|
|
3
|
+
## 0.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0ab4b84: Alignment for the controls (right-side) settings & styles tabs
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [0ab4b84]
|
|
12
|
+
- Updated dependencies [3afb048]
|
|
13
|
+
- @elementor/editor-editing-panel@1.29.0
|
|
14
|
+
|
|
15
|
+
## 0.15.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- 42c42ee: Remove side-effects
|
|
20
|
+
- 34b0236: Keep top bar actions disabled in class manager
|
|
21
|
+
- 044815b: Fix introduction modal transition.
|
|
22
|
+
- 64574e3: Refactor styles provider as a preparation for header/footer styles not being rendered
|
|
23
|
+
- Updated dependencies [93d3e45]
|
|
24
|
+
- Updated dependencies [42c42ee]
|
|
25
|
+
- Updated dependencies [a53f563]
|
|
26
|
+
- Updated dependencies [5fa575c]
|
|
27
|
+
- Updated dependencies [2125601]
|
|
28
|
+
- Updated dependencies [03dad77]
|
|
29
|
+
- Updated dependencies [a27cc75]
|
|
30
|
+
- Updated dependencies [044815b]
|
|
31
|
+
- Updated dependencies [64574e3]
|
|
32
|
+
- Updated dependencies [fe0ab45]
|
|
33
|
+
- Updated dependencies [14d8b08]
|
|
34
|
+
- Updated dependencies [fd5251c]
|
|
35
|
+
- @elementor/editor-editing-panel@1.28.0
|
|
36
|
+
- @elementor/editor-styles-repository@0.8.4
|
|
37
|
+
- @elementor/editor-documents@0.13.1
|
|
38
|
+
- @elementor/editor-panels@0.14.1
|
|
39
|
+
- @elementor/editor@0.18.6
|
|
40
|
+
- @elementor/editor-ui@0.7.1
|
|
41
|
+
- @elementor/editor-props@0.12.0
|
|
42
|
+
- @elementor/editor-styles@0.6.6
|
|
43
|
+
|
|
3
44
|
## 0.15.3
|
|
4
45
|
|
|
5
46
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
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,20 +25,28 @@ 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
|
|
41
|
+
var import_editor_styles_repository3 = require("@elementor/editor-styles-repository");
|
|
30
42
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
31
|
-
var
|
|
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
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"));
|
|
@@ -46,7 +58,7 @@ 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");
|
|
@@ -196,18 +208,22 @@ var ClassManagerIntroduction = () => {
|
|
|
196
208
|
{
|
|
197
209
|
open: shouldShowIntroduction,
|
|
198
210
|
title: (0, import_i18n.__)("Class Manager", "elementor"),
|
|
199
|
-
content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
|
|
200
|
-
image: {
|
|
201
|
-
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
202
|
-
alt: ""
|
|
203
|
-
},
|
|
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 = () => {
|
|
@@ -223,71 +239,10 @@ var IntroductionContent = () => {
|
|
|
223
239
|
// src/components/class-manager/delete-class.ts
|
|
224
240
|
var import_editor_documents = require("@elementor/editor-documents");
|
|
225
241
|
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
226
|
-
|
|
227
|
-
// src/global-classes-styles-provider.ts
|
|
228
|
-
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
229
242
|
var import_store6 = require("@elementor/store");
|
|
230
|
-
var import_i18n2 = require("@wordpress/i18n");
|
|
231
|
-
var MAX_CLASSES = 50;
|
|
232
|
-
var globalClassesStylesProvider = {
|
|
233
|
-
key: "global-classes",
|
|
234
|
-
priority: 30,
|
|
235
|
-
limit: MAX_CLASSES,
|
|
236
|
-
actions: {
|
|
237
|
-
get: () => selectOrderedClasses((0, import_store6.__getState)()),
|
|
238
|
-
getById: (id2) => selectClass((0, import_store6.__getState)(), id2),
|
|
239
|
-
create: (label) => {
|
|
240
|
-
const classes = selectGlobalClasses((0, import_store6.__getState)());
|
|
241
|
-
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
242
|
-
if (existingLabels.includes(label)) {
|
|
243
|
-
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
244
|
-
}
|
|
245
|
-
const existingIds = Object.keys(classes);
|
|
246
|
-
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
247
|
-
(0, import_store6.__dispatch)(
|
|
248
|
-
slice.actions.add({
|
|
249
|
-
id: id2,
|
|
250
|
-
type: "class",
|
|
251
|
-
label,
|
|
252
|
-
variants: []
|
|
253
|
-
})
|
|
254
|
-
);
|
|
255
|
-
return id2;
|
|
256
|
-
},
|
|
257
|
-
update: (payload) => {
|
|
258
|
-
(0, import_store6.__dispatch)(
|
|
259
|
-
slice.actions.update({
|
|
260
|
-
style: payload
|
|
261
|
-
})
|
|
262
|
-
);
|
|
263
|
-
},
|
|
264
|
-
delete: (id2) => {
|
|
265
|
-
(0, import_store6.__dispatch)(slice.actions.delete(id2));
|
|
266
|
-
},
|
|
267
|
-
setOrder: (order) => {
|
|
268
|
-
(0, import_store6.__dispatch)(slice.actions.setOrder(order));
|
|
269
|
-
},
|
|
270
|
-
updateProps: (args) => {
|
|
271
|
-
(0, import_store6.__dispatch)(
|
|
272
|
-
slice.actions.updateProps({
|
|
273
|
-
id: args.id,
|
|
274
|
-
meta: args.meta,
|
|
275
|
-
props: args.props
|
|
276
|
-
})
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
subscribe: (cb) => (0, import_store6.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
281
|
-
labels: {
|
|
282
|
-
singular: (0, import_i18n2.__)("class", "elementor"),
|
|
283
|
-
plural: (0, import_i18n2.__)("classes", "elementor")
|
|
284
|
-
}
|
|
285
|
-
};
|
|
286
|
-
|
|
287
|
-
// src/components/class-manager/delete-class.ts
|
|
288
243
|
var isDeleted = false;
|
|
289
244
|
var deleteClass = (id2) => {
|
|
290
|
-
|
|
245
|
+
(0, import_store6.__dispatch)(slice.actions.delete(id2));
|
|
291
246
|
isDeleted = true;
|
|
292
247
|
};
|
|
293
248
|
var onDelete = async () => {
|
|
@@ -316,8 +271,9 @@ var React5 = __toESM(require("react"));
|
|
|
316
271
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
317
272
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
318
273
|
var import_icons4 = require("@elementor/icons");
|
|
274
|
+
var import_store12 = require("@elementor/store");
|
|
319
275
|
var import_ui4 = require("@elementor/ui");
|
|
320
|
-
var
|
|
276
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
321
277
|
|
|
322
278
|
// src/hooks/use-classes-order.ts
|
|
323
279
|
var import_store8 = require("@elementor/store");
|
|
@@ -336,7 +292,7 @@ var React3 = __toESM(require("react"));
|
|
|
336
292
|
var import_react2 = require("react");
|
|
337
293
|
var import_icons2 = require("@elementor/icons");
|
|
338
294
|
var import_ui2 = require("@elementor/ui");
|
|
339
|
-
var
|
|
295
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
340
296
|
var context = (0, import_react2.createContext)(null);
|
|
341
297
|
var DeleteConfirmationProvider = ({ children }) => {
|
|
342
298
|
const [dialogProps, setDialogProps] = (0, import_react2.useState)(null);
|
|
@@ -355,10 +311,10 @@ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
|
355
311
|
deleteClass(id2);
|
|
356
312
|
closeDialog();
|
|
357
313
|
};
|
|
358
|
-
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.__)(
|
|
359
315
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
360
316
|
"elementor"
|
|
361
|
-
))), /* @__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"))));
|
|
362
318
|
};
|
|
363
319
|
var useDeleteConfirmation = () => {
|
|
364
320
|
const contextValue = (0, import_react2.useContext)(context);
|
|
@@ -432,13 +388,21 @@ var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
|
|
|
432
388
|
// src/components/class-manager/global-classes-list.tsx
|
|
433
389
|
var GlobalClassesList = ({ disabled }) => {
|
|
434
390
|
const cssClasses = useOrderedClasses();
|
|
391
|
+
const dispatch4 = (0, import_store12.__useDispatch)();
|
|
435
392
|
const [classesOrder, reorderClasses] = useReorder();
|
|
436
393
|
if (!cssClasses?.length) {
|
|
437
394
|
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
438
395
|
}
|
|
439
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 }) => {
|
|
440
397
|
const renameClass = (newLabel) => {
|
|
441
|
-
|
|
398
|
+
dispatch4(
|
|
399
|
+
slice.actions.update({
|
|
400
|
+
style: {
|
|
401
|
+
id: id2,
|
|
402
|
+
label: newLabel
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
);
|
|
442
406
|
};
|
|
443
407
|
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
444
408
|
ClassItem,
|
|
@@ -454,9 +418,10 @@ var GlobalClassesList = ({ disabled }) => {
|
|
|
454
418
|
}))));
|
|
455
419
|
};
|
|
456
420
|
var useReorder = () => {
|
|
421
|
+
const dispatch4 = (0, import_store12.__useDispatch)();
|
|
457
422
|
const order = useClassesOrder();
|
|
458
423
|
const reorder = (newIds) => {
|
|
459
|
-
|
|
424
|
+
dispatch4(slice.actions.setOrder(newIds));
|
|
460
425
|
};
|
|
461
426
|
return [order, reorder];
|
|
462
427
|
};
|
|
@@ -506,7 +471,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
506
471
|
{
|
|
507
472
|
placement: "top",
|
|
508
473
|
className: "class-item-more-actions",
|
|
509
|
-
title: (0,
|
|
474
|
+
title: (0, import_i18n3.__)("More actions", "elementor")
|
|
510
475
|
},
|
|
511
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" }))
|
|
512
477
|
)
|
|
@@ -532,7 +497,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
532
497
|
openEditMode();
|
|
533
498
|
}
|
|
534
499
|
},
|
|
535
|
-
/* @__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"))
|
|
536
501
|
),
|
|
537
502
|
/* @__PURE__ */ React5.createElement(
|
|
538
503
|
import_editor_ui2.MenuListItem,
|
|
@@ -542,7 +507,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
542
507
|
openDialog({ id: id2, label });
|
|
543
508
|
}
|
|
544
509
|
},
|
|
545
|
-
/* @__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"))
|
|
546
511
|
)
|
|
547
512
|
));
|
|
548
513
|
};
|
|
@@ -571,7 +536,7 @@ var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
|
|
|
571
536
|
}
|
|
572
537
|
`
|
|
573
538
|
);
|
|
574
|
-
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.__)(
|
|
575
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.",
|
|
576
541
|
"elementor"
|
|
577
542
|
)));
|
|
@@ -602,15 +567,23 @@ var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
|
602
567
|
return "none";
|
|
603
568
|
};
|
|
604
569
|
var validateLabel = (newLabel) => {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
if (import_editor_styles_repository.stylesRepository.isLabelExist(newLabel)) {
|
|
609
|
-
return (0, import_i18n4.__)("Name exists", "elementor");
|
|
570
|
+
const result = (0, import_editor_styles_repository.validateStyleLabel)(newLabel);
|
|
571
|
+
if (result.isValid) {
|
|
572
|
+
return null;
|
|
610
573
|
}
|
|
611
|
-
return
|
|
574
|
+
return result.error;
|
|
612
575
|
};
|
|
613
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
|
+
|
|
614
587
|
// src/components/class-manager/save-changes-dialog.tsx
|
|
615
588
|
var React6 = __toESM(require("react"));
|
|
616
589
|
var import_react3 = require("react");
|
|
@@ -650,9 +623,11 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
650
623
|
allowedEditModes: ["edit", id],
|
|
651
624
|
onOpen: () => {
|
|
652
625
|
(0, import_editor_v1_adapters2.changeEditMode)(id);
|
|
626
|
+
blockPanelInteractions();
|
|
653
627
|
},
|
|
654
628
|
onClose: () => {
|
|
655
629
|
(0, import_editor_v1_adapters2.changeEditMode)("edit");
|
|
630
|
+
unblockPanelInteractions();
|
|
656
631
|
}
|
|
657
632
|
});
|
|
658
633
|
function ClassManagerPanel() {
|
|
@@ -661,7 +636,7 @@ function ClassManagerPanel() {
|
|
|
661
636
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
662
637
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
663
638
|
usePreventUnload();
|
|
664
|
-
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,
|
|
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(
|
|
665
640
|
CloseButton,
|
|
666
641
|
{
|
|
667
642
|
sx: { marginLeft: "auto" },
|
|
@@ -685,17 +660,17 @@ function ClassManagerPanel() {
|
|
|
685
660
|
disabled: !isDirty2,
|
|
686
661
|
loading: isPublishing
|
|
687
662
|
},
|
|
688
|
-
(0,
|
|
689
|
-
)))), /* @__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(
|
|
690
665
|
SaveChangesDialog.Actions,
|
|
691
666
|
{
|
|
692
667
|
actions: {
|
|
693
668
|
cancel: {
|
|
694
|
-
label: (0,
|
|
669
|
+
label: (0, import_i18n4.__)("Cancel", "elementor"),
|
|
695
670
|
action: closeSaveChangesDialog
|
|
696
671
|
},
|
|
697
672
|
confirm: {
|
|
698
|
-
label: (0,
|
|
673
|
+
label: (0, import_i18n4.__)("Save & Continue", "elementor"),
|
|
699
674
|
action: async () => {
|
|
700
675
|
await publish();
|
|
701
676
|
closeSaveChangesDialog();
|
|
@@ -707,7 +682,7 @@ function ClassManagerPanel() {
|
|
|
707
682
|
)));
|
|
708
683
|
}
|
|
709
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" }));
|
|
710
|
-
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"))));
|
|
711
686
|
var usePreventUnload = () => {
|
|
712
687
|
const isDirty2 = useDirtyState();
|
|
713
688
|
(0, import_react4.useEffect)(() => {
|
|
@@ -747,7 +722,7 @@ var ClassManagerButton = () => {
|
|
|
747
722
|
}
|
|
748
723
|
openPanel();
|
|
749
724
|
};
|
|
750
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0,
|
|
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, { size: "tiny", onClick: handleOpenPanel, sx: { marginInlineEnd: -0.75 } }, /* @__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.__)(
|
|
751
726
|
"To open the Class Manager, save your page first. You can't continue without saving.",
|
|
752
727
|
"elementor"
|
|
753
728
|
))), /* @__PURE__ */ React8.createElement(
|
|
@@ -755,11 +730,11 @@ var ClassManagerButton = () => {
|
|
|
755
730
|
{
|
|
756
731
|
actions: {
|
|
757
732
|
cancel: {
|
|
758
|
-
label: (0,
|
|
733
|
+
label: (0, import_i18n5.__)("Stay here", "elementor"),
|
|
759
734
|
action: closeSaveChangesDialog
|
|
760
735
|
},
|
|
761
736
|
confirm: {
|
|
762
|
-
label: (0,
|
|
737
|
+
label: (0, import_i18n5.__)("Save & Continue", "elementor"),
|
|
763
738
|
action: async () => {
|
|
764
739
|
await saveDocument();
|
|
765
740
|
closeSaveChangesDialog();
|
|
@@ -773,29 +748,87 @@ var ClassManagerButton = () => {
|
|
|
773
748
|
|
|
774
749
|
// src/components/populate-store.tsx
|
|
775
750
|
var import_react5 = require("react");
|
|
776
|
-
var
|
|
751
|
+
var import_store14 = require("@elementor/store");
|
|
777
752
|
function PopulateStore() {
|
|
778
|
-
const
|
|
753
|
+
const dispatch4 = (0, import_store14.__useDispatch)();
|
|
779
754
|
(0, import_react5.useEffect)(() => {
|
|
780
755
|
apiClient.all().then((res) => {
|
|
781
756
|
const { data, meta } = res.data;
|
|
782
|
-
|
|
757
|
+
dispatch4(slice.actions.init({ items: data, order: meta.order }));
|
|
783
758
|
});
|
|
784
|
-
}, [
|
|
759
|
+
}, [dispatch4]);
|
|
785
760
|
return null;
|
|
786
761
|
}
|
|
787
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
|
+
|
|
788
821
|
// src/sync-with-document-save.ts
|
|
789
822
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
790
823
|
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
791
|
-
var
|
|
824
|
+
var import_store18 = require("@elementor/store");
|
|
792
825
|
function syncWithDocumentSave() {
|
|
793
826
|
const unsubscribe = syncDirtyState();
|
|
794
827
|
bindSaveAction();
|
|
795
828
|
return unsubscribe;
|
|
796
829
|
}
|
|
797
830
|
function syncDirtyState() {
|
|
798
|
-
return (0,
|
|
831
|
+
return (0, import_store18.__subscribeWithSelector)(selectIsDirty, () => {
|
|
799
832
|
if (!isDirty()) {
|
|
800
833
|
return;
|
|
801
834
|
}
|
|
@@ -810,14 +843,14 @@ function bindSaveAction() {
|
|
|
810
843
|
});
|
|
811
844
|
}
|
|
812
845
|
function isDirty() {
|
|
813
|
-
return selectIsDirty((0,
|
|
846
|
+
return selectIsDirty((0, import_store18.__getState)());
|
|
814
847
|
}
|
|
815
848
|
|
|
816
849
|
// src/init.ts
|
|
817
850
|
function init() {
|
|
818
|
-
(0,
|
|
851
|
+
(0, import_store20.__registerSlice)(slice);
|
|
819
852
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
820
|
-
|
|
853
|
+
import_editor_styles_repository3.stylesRepository.register(globalClassesStylesProvider);
|
|
821
854
|
(0, import_editor.injectIntoLogic)({
|
|
822
855
|
id: "global-classes-populate-store",
|
|
823
856
|
component: PopulateStore
|
|
@@ -830,7 +863,8 @@ function init() {
|
|
|
830
863
|
syncWithDocumentSave();
|
|
831
864
|
});
|
|
832
865
|
}
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
init
|
|
866
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
867
|
+
0 && (module.exports = {
|
|
868
|
+
init
|
|
869
|
+
});
|
|
836
870
|
//# sourceMappingURL=index.js.map
|