@elementor/editor-global-classes 0.17.9 → 0.19.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 +42 -0
- package/dist/index.js +153 -125
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +148 -120
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -11
- package/src/capabilities.ts +18 -0
- package/src/components/class-manager/class-manager-button.tsx +10 -0
- package/src/global-classes-styles-provider.ts +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# @elementor/editor-global-classes
|
|
2
2
|
|
|
3
|
+
## 0.19.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6e1d5ff: Enforce capabilities on global classes.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 615baa1: upgrade elementor/ui version
|
|
12
|
+
- Updated dependencies [93642ee]
|
|
13
|
+
- Updated dependencies [ab07642]
|
|
14
|
+
- Updated dependencies [12fab9e]
|
|
15
|
+
- Updated dependencies [6e1d5ff]
|
|
16
|
+
- Updated dependencies [d80a316]
|
|
17
|
+
- Updated dependencies [35cdc76]
|
|
18
|
+
- Updated dependencies [615baa1]
|
|
19
|
+
- Updated dependencies [ae40ebe]
|
|
20
|
+
- @elementor/editor-editing-panel@1.39.0
|
|
21
|
+
- @elementor/editor-ui@0.9.0
|
|
22
|
+
- @elementor/editor-styles-repository@0.10.0
|
|
23
|
+
- @elementor/editor-current-user@0.5.0
|
|
24
|
+
- @elementor/editor-panels@0.15.4
|
|
25
|
+
- @elementor/editor@0.19.4
|
|
26
|
+
- @elementor/editor-documents@0.13.6
|
|
27
|
+
|
|
28
|
+
## 0.18.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 15450a8: Allow render labels of global classes as css selector
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [15450a8]
|
|
37
|
+
- Updated dependencies [89dfaf2]
|
|
38
|
+
- Updated dependencies [27c4c1f]
|
|
39
|
+
- @elementor/editor-styles-repository@0.9.0
|
|
40
|
+
- @elementor/editor-current-user@0.4.0
|
|
41
|
+
- @elementor/editor-editing-panel@1.38.1
|
|
42
|
+
- @elementor/editor-props@0.12.1
|
|
43
|
+
- @elementor/editor-styles@0.6.8
|
|
44
|
+
|
|
3
45
|
## 0.17.9
|
|
4
46
|
|
|
5
47
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -38,35 +38,39 @@ module.exports = __toCommonJS(index_exports);
|
|
|
38
38
|
var import_editor = require("@elementor/editor");
|
|
39
39
|
var import_editor_editing_panel = require("@elementor/editor-editing-panel");
|
|
40
40
|
var import_editor_panels2 = require("@elementor/editor-panels");
|
|
41
|
-
var
|
|
42
|
-
var
|
|
41
|
+
var import_editor_styles_repository4 = require("@elementor/editor-styles-repository");
|
|
42
|
+
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
43
43
|
var import_store20 = require("@elementor/store");
|
|
44
44
|
|
|
45
45
|
// src/components/class-manager/class-manager-button.tsx
|
|
46
46
|
var React8 = __toESM(require("react"));
|
|
47
47
|
var import_editor_documents3 = require("@elementor/editor-documents");
|
|
48
|
+
var import_editor_styles_repository3 = require("@elementor/editor-styles-repository");
|
|
48
49
|
var import_ui7 = require("@elementor/ui");
|
|
49
|
-
var
|
|
50
|
+
var import_i18n6 = require("@wordpress/i18n");
|
|
50
51
|
|
|
51
|
-
// src/
|
|
52
|
-
var
|
|
53
|
-
var
|
|
54
|
-
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
55
|
-
var import_editor_panels = require("@elementor/editor-panels");
|
|
56
|
-
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
52
|
+
// src/global-classes-styles-provider.ts
|
|
53
|
+
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
54
|
+
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
57
55
|
var import_editor_v1_adapters2 = require("@elementor/editor-v1-adapters");
|
|
58
|
-
var import_icons6 = require("@elementor/icons");
|
|
59
|
-
var import_query = require("@elementor/query");
|
|
60
|
-
var import_ui6 = require("@elementor/ui");
|
|
61
|
-
var import_i18n4 = require("@wordpress/i18n");
|
|
62
|
-
|
|
63
|
-
// src/hooks/use-dirty-state.ts
|
|
64
56
|
var import_store2 = require("@elementor/store");
|
|
57
|
+
var import_i18n = require("@wordpress/i18n");
|
|
65
58
|
|
|
66
|
-
// src/
|
|
67
|
-
var
|
|
68
|
-
var
|
|
69
|
-
var
|
|
59
|
+
// src/capabilities.ts
|
|
60
|
+
var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
|
|
61
|
+
var EXPERIMENT_KEY = "global_classes_should_enforce_capabilities";
|
|
62
|
+
var UPDATE_CLASS_CAPABILITY_KEY = "elementor_global_classes_update_class";
|
|
63
|
+
var getCapabilities = () => {
|
|
64
|
+
const shouldEnforceCapabilities = (0, import_editor_v1_adapters.isExperimentActive)(EXPERIMENT_KEY);
|
|
65
|
+
if (shouldEnforceCapabilities) {
|
|
66
|
+
return {
|
|
67
|
+
update: UPDATE_CLASS_CAPABILITY_KEY,
|
|
68
|
+
create: UPDATE_CLASS_CAPABILITY_KEY,
|
|
69
|
+
delete: UPDATE_CLASS_CAPABILITY_KEY,
|
|
70
|
+
updateProps: UPDATE_CLASS_CAPABILITY_KEY
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
70
74
|
|
|
71
75
|
// src/errors.ts
|
|
72
76
|
var import_utils = require("@elementor/utils");
|
|
@@ -80,6 +84,9 @@ var GlobalClassLabelAlreadyExistsError = (0, import_utils.createError)({
|
|
|
80
84
|
});
|
|
81
85
|
|
|
82
86
|
// src/store.ts
|
|
87
|
+
var import_editor_props = require("@elementor/editor-props");
|
|
88
|
+
var import_editor_styles = require("@elementor/editor-styles");
|
|
89
|
+
var import_store = require("@elementor/store");
|
|
83
90
|
var initialState = {
|
|
84
91
|
data: { items: {}, order: [] },
|
|
85
92
|
initialData: {
|
|
@@ -163,13 +170,87 @@ var selectOrderedClasses = (0, import_store.__createSelector)(
|
|
|
163
170
|
);
|
|
164
171
|
var selectClass = (state, id2) => state[SLICE_NAME].data.items[id2] ?? null;
|
|
165
172
|
|
|
173
|
+
// src/global-classes-styles-provider.ts
|
|
174
|
+
var MAX_CLASSES = 50;
|
|
175
|
+
var globalClassesStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
176
|
+
key: "global-classes",
|
|
177
|
+
priority: 30,
|
|
178
|
+
limit: MAX_CLASSES,
|
|
179
|
+
labels: {
|
|
180
|
+
singular: (0, import_i18n.__)("class", "elementor"),
|
|
181
|
+
plural: (0, import_i18n.__)("classes", "elementor")
|
|
182
|
+
},
|
|
183
|
+
subscribe: (cb) => (0, import_store2.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
184
|
+
capabilities: getCapabilities(),
|
|
185
|
+
actions: {
|
|
186
|
+
all: () => selectOrderedClasses((0, import_store2.__getState)()),
|
|
187
|
+
get: (id2) => selectClass((0, import_store2.__getState)(), id2),
|
|
188
|
+
resolveCssName: (id2) => {
|
|
189
|
+
if (!(0, import_editor_v1_adapters2.isExperimentActive)("e_v_3_30")) {
|
|
190
|
+
return id2;
|
|
191
|
+
}
|
|
192
|
+
return selectClass((0, import_store2.__getState)(), id2)?.label ?? id2;
|
|
193
|
+
},
|
|
194
|
+
create: (label) => {
|
|
195
|
+
const classes = selectGlobalClasses((0, import_store2.__getState)());
|
|
196
|
+
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
197
|
+
if (existingLabels.includes(label)) {
|
|
198
|
+
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
199
|
+
}
|
|
200
|
+
const existingIds = Object.keys(classes);
|
|
201
|
+
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
202
|
+
(0, import_store2.__dispatch)(
|
|
203
|
+
slice.actions.add({
|
|
204
|
+
id: id2,
|
|
205
|
+
type: "class",
|
|
206
|
+
label,
|
|
207
|
+
variants: []
|
|
208
|
+
})
|
|
209
|
+
);
|
|
210
|
+
return id2;
|
|
211
|
+
},
|
|
212
|
+
update: (payload) => {
|
|
213
|
+
(0, import_store2.__dispatch)(
|
|
214
|
+
slice.actions.update({
|
|
215
|
+
style: payload
|
|
216
|
+
})
|
|
217
|
+
);
|
|
218
|
+
},
|
|
219
|
+
delete: (id2) => {
|
|
220
|
+
(0, import_store2.__dispatch)(slice.actions.delete(id2));
|
|
221
|
+
},
|
|
222
|
+
updateProps: (args) => {
|
|
223
|
+
(0, import_store2.__dispatch)(
|
|
224
|
+
slice.actions.updateProps({
|
|
225
|
+
id: args.id,
|
|
226
|
+
meta: args.meta,
|
|
227
|
+
props: args.props
|
|
228
|
+
})
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// src/components/class-manager/class-manager-panel.tsx
|
|
235
|
+
var React7 = __toESM(require("react"));
|
|
236
|
+
var import_react5 = require("react");
|
|
237
|
+
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
238
|
+
var import_editor_panels = require("@elementor/editor-panels");
|
|
239
|
+
var import_editor_ui3 = require("@elementor/editor-ui");
|
|
240
|
+
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
241
|
+
var import_icons6 = require("@elementor/icons");
|
|
242
|
+
var import_query = require("@elementor/query");
|
|
243
|
+
var import_ui6 = require("@elementor/ui");
|
|
244
|
+
var import_i18n5 = require("@wordpress/i18n");
|
|
245
|
+
|
|
166
246
|
// src/hooks/use-dirty-state.ts
|
|
247
|
+
var import_store4 = require("@elementor/store");
|
|
167
248
|
var useDirtyState = () => {
|
|
168
|
-
return (0,
|
|
249
|
+
return (0, import_store4.__useSelector)(selectIsDirty);
|
|
169
250
|
};
|
|
170
251
|
|
|
171
252
|
// src/save-global-classes.ts
|
|
172
|
-
var
|
|
253
|
+
var import_store6 = require("@elementor/store");
|
|
173
254
|
|
|
174
255
|
// src/api.ts
|
|
175
256
|
var import_http_client = require("@elementor/http-client");
|
|
@@ -192,21 +273,21 @@ var apiClient = {
|
|
|
192
273
|
|
|
193
274
|
// src/save-global-classes.ts
|
|
194
275
|
async function saveGlobalClasses({ context: context2 }) {
|
|
195
|
-
const state = selectData((0,
|
|
276
|
+
const state = selectData((0, import_store6.__getState)());
|
|
196
277
|
if (context2 === "preview") {
|
|
197
278
|
await apiClient.saveDraft({
|
|
198
279
|
items: state.items,
|
|
199
280
|
order: state.order,
|
|
200
|
-
changes: calculateChanges(state, selectPreviewInitialData((0,
|
|
281
|
+
changes: calculateChanges(state, selectPreviewInitialData((0, import_store6.__getState)()))
|
|
201
282
|
});
|
|
202
283
|
} else {
|
|
203
284
|
await apiClient.publish({
|
|
204
285
|
items: state.items,
|
|
205
286
|
order: state.order,
|
|
206
|
-
changes: calculateChanges(state, selectFrontendInitialData((0,
|
|
287
|
+
changes: calculateChanges(state, selectFrontendInitialData((0, import_store6.__getState)()))
|
|
207
288
|
});
|
|
208
289
|
}
|
|
209
|
-
(0,
|
|
290
|
+
(0, import_store6.__dispatch)(slice.actions.reset({ context: context2 }));
|
|
210
291
|
}
|
|
211
292
|
function calculateChanges(state, initialData) {
|
|
212
293
|
const stateIds = Object.keys(state.items);
|
|
@@ -238,7 +319,7 @@ var import_react = require("react");
|
|
|
238
319
|
var import_editor_current_user = require("@elementor/editor-current-user");
|
|
239
320
|
var import_editor_ui = require("@elementor/editor-ui");
|
|
240
321
|
var import_ui = require("@elementor/ui");
|
|
241
|
-
var
|
|
322
|
+
var import_i18n2 = require("@wordpress/i18n");
|
|
242
323
|
var MESSAGE_KEY = "global-class-manager";
|
|
243
324
|
var ClassManagerIntroduction = () => {
|
|
244
325
|
const [isMessageSuppressed, suppressMessage] = (0, import_editor_current_user.useSuppressedMessage)(MESSAGE_KEY);
|
|
@@ -247,7 +328,7 @@ var ClassManagerIntroduction = () => {
|
|
|
247
328
|
import_editor_ui.IntroductionModal,
|
|
248
329
|
{
|
|
249
330
|
open: shouldShowIntroduction,
|
|
250
|
-
title: (0,
|
|
331
|
+
title: (0, import_i18n2.__)("Class Manager", "elementor"),
|
|
251
332
|
handleClose: (shouldShowAgain) => {
|
|
252
333
|
if (!shouldShowAgain) {
|
|
253
334
|
suppressMessage();
|
|
@@ -267,10 +348,10 @@ var ClassManagerIntroduction = () => {
|
|
|
267
348
|
);
|
|
268
349
|
};
|
|
269
350
|
var IntroductionContent = () => {
|
|
270
|
-
return /* @__PURE__ */ React.createElement(import_ui.Box, { p: 3 }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0,
|
|
351
|
+
return /* @__PURE__ */ React.createElement(import_ui.Box, { p: 3 }, /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)(
|
|
271
352
|
"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.",
|
|
272
353
|
"elementor"
|
|
273
|
-
)), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0,
|
|
354
|
+
)), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(import_ui.Typography, { variant: "body2" }, (0, import_i18n2.__)(
|
|
274
355
|
"Remember, when editing an item within a specific class, any changes you make will apply across all elements in that class.",
|
|
275
356
|
"elementor"
|
|
276
357
|
)));
|
|
@@ -278,11 +359,11 @@ var IntroductionContent = () => {
|
|
|
278
359
|
|
|
279
360
|
// src/components/class-manager/delete-class.ts
|
|
280
361
|
var import_editor_documents = require("@elementor/editor-documents");
|
|
281
|
-
var
|
|
282
|
-
var
|
|
362
|
+
var import_editor_v1_adapters3 = require("@elementor/editor-v1-adapters");
|
|
363
|
+
var import_store8 = require("@elementor/store");
|
|
283
364
|
var isDeleted = false;
|
|
284
365
|
var deleteClass = (id2) => {
|
|
285
|
-
(0,
|
|
366
|
+
(0, import_store8.__dispatch)(slice.actions.delete(id2));
|
|
286
367
|
isDeleted = true;
|
|
287
368
|
};
|
|
288
369
|
var onDelete = async () => {
|
|
@@ -294,7 +375,7 @@ var reloadDocument = () => {
|
|
|
294
375
|
const currentDocument = (0, import_editor_documents.getCurrentDocument)();
|
|
295
376
|
const documentsManager = (0, import_editor_documents.getV1DocumentsManager)();
|
|
296
377
|
documentsManager.invalidateCache();
|
|
297
|
-
return (0,
|
|
378
|
+
return (0, import_editor_v1_adapters3.__privateRunCommand)("editor/documents/switch", {
|
|
298
379
|
id: currentDocument?.id,
|
|
299
380
|
shouldScroll: false,
|
|
300
381
|
shouldNavigateToDefaultRoute: false
|
|
@@ -309,23 +390,23 @@ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.create
|
|
|
309
390
|
// src/components/class-manager/global-classes-list.tsx
|
|
310
391
|
var React5 = __toESM(require("react"));
|
|
311
392
|
var import_react3 = require("react");
|
|
312
|
-
var
|
|
393
|
+
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
313
394
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
314
395
|
var import_icons4 = require("@elementor/icons");
|
|
315
|
-
var
|
|
396
|
+
var import_store14 = require("@elementor/store");
|
|
316
397
|
var import_ui4 = require("@elementor/ui");
|
|
317
|
-
var
|
|
398
|
+
var import_i18n4 = require("@wordpress/i18n");
|
|
318
399
|
|
|
319
400
|
// src/hooks/use-classes-order.ts
|
|
320
|
-
var
|
|
401
|
+
var import_store10 = require("@elementor/store");
|
|
321
402
|
var useClassesOrder = () => {
|
|
322
|
-
return (0,
|
|
403
|
+
return (0, import_store10.__useSelector)(selectOrder);
|
|
323
404
|
};
|
|
324
405
|
|
|
325
406
|
// src/hooks/use-ordered-classes.ts
|
|
326
|
-
var
|
|
407
|
+
var import_store12 = require("@elementor/store");
|
|
327
408
|
var useOrderedClasses = () => {
|
|
328
|
-
return (0,
|
|
409
|
+
return (0, import_store12.__useSelector)(selectOrderedClasses);
|
|
329
410
|
};
|
|
330
411
|
|
|
331
412
|
// src/components/class-manager/delete-confirmation-dialog.tsx
|
|
@@ -333,7 +414,7 @@ var React3 = __toESM(require("react"));
|
|
|
333
414
|
var import_react2 = require("react");
|
|
334
415
|
var import_icons2 = require("@elementor/icons");
|
|
335
416
|
var import_ui2 = require("@elementor/ui");
|
|
336
|
-
var
|
|
417
|
+
var import_i18n3 = require("@wordpress/i18n");
|
|
337
418
|
var context = (0, import_react2.createContext)(null);
|
|
338
419
|
var DeleteConfirmationProvider = ({ children }) => {
|
|
339
420
|
const [dialogProps, setDialogProps] = (0, import_react2.useState)(null);
|
|
@@ -352,10 +433,10 @@ var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
|
352
433
|
deleteClass(id2);
|
|
353
434
|
closeDialog();
|
|
354
435
|
};
|
|
355
|
-
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,
|
|
436
|
+
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 this 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.__)(
|
|
356
437
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
357
438
|
"elementor"
|
|
358
|
-
))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0,
|
|
439
|
+
))), /* @__PURE__ */ React3.createElement(import_ui2.DialogActions, null, /* @__PURE__ */ React3.createElement(import_ui2.Button, { color: "secondary", onClick: closeDialog }, (0, import_i18n3.__)("Not now", "elementor")), /* @__PURE__ */ React3.createElement(import_ui2.Button, { variant: "contained", color: "error", onClick: onConfirm }, (0, import_i18n3.__)("Delete", "elementor"))));
|
|
359
440
|
};
|
|
360
441
|
var useDeleteConfirmation = () => {
|
|
361
442
|
const contextValue = (0, import_react2.useContext)(context);
|
|
@@ -429,7 +510,7 @@ var SortableItemIndicator = (0, import_ui3.styled)(import_ui3.Box)`
|
|
|
429
510
|
// src/components/class-manager/global-classes-list.tsx
|
|
430
511
|
var GlobalClassesList = ({ disabled }) => {
|
|
431
512
|
const cssClasses = useOrderedClasses();
|
|
432
|
-
const dispatch4 = (0,
|
|
513
|
+
const dispatch4 = (0, import_store14.__useDispatch)();
|
|
433
514
|
const [classesOrder, reorderClasses] = useReorder();
|
|
434
515
|
if (!cssClasses?.length) {
|
|
435
516
|
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
@@ -459,7 +540,7 @@ var GlobalClassesList = ({ disabled }) => {
|
|
|
459
540
|
}))));
|
|
460
541
|
};
|
|
461
542
|
var useReorder = () => {
|
|
462
|
-
const dispatch4 = (0,
|
|
543
|
+
const dispatch4 = (0, import_store14.__useDispatch)();
|
|
463
544
|
const order = useClassesOrder();
|
|
464
545
|
const reorder = (newIds) => {
|
|
465
546
|
dispatch4(slice.actions.setOrder(newIds));
|
|
@@ -522,7 +603,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
522
603
|
{
|
|
523
604
|
placement: "top",
|
|
524
605
|
className: "class-item-more-actions",
|
|
525
|
-
title: (0,
|
|
606
|
+
title: (0, import_i18n4.__)("More actions", "elementor")
|
|
526
607
|
},
|
|
527
608
|
/* @__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" }))
|
|
528
609
|
)
|
|
@@ -549,7 +630,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
549
630
|
openEditMode();
|
|
550
631
|
}
|
|
551
632
|
},
|
|
552
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0,
|
|
633
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "text.primary" } }, (0, import_i18n4.__)("Rename", "elementor"))
|
|
553
634
|
),
|
|
554
635
|
/* @__PURE__ */ React5.createElement(
|
|
555
636
|
import_editor_ui2.MenuListItem,
|
|
@@ -559,7 +640,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
559
640
|
openDialog({ id: id2, label });
|
|
560
641
|
}
|
|
561
642
|
},
|
|
562
|
-
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "error.light" } }, (0,
|
|
643
|
+
/* @__PURE__ */ React5.createElement(import_ui4.Typography, { variant: "caption", sx: { color: "error.light" } }, (0, import_i18n4.__)("Delete", "elementor"))
|
|
563
644
|
)
|
|
564
645
|
));
|
|
565
646
|
};
|
|
@@ -588,7 +669,7 @@ var StyledListItemButton = (0, import_ui4.styled)(import_ui4.ListItemButton, {
|
|
|
588
669
|
}
|
|
589
670
|
`
|
|
590
671
|
);
|
|
591
|
-
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,
|
|
672
|
+
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.__)(
|
|
592
673
|
"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.",
|
|
593
674
|
"elementor"
|
|
594
675
|
)));
|
|
@@ -619,7 +700,7 @@ var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
|
619
700
|
return "none";
|
|
620
701
|
};
|
|
621
702
|
var validateLabel = (newLabel) => {
|
|
622
|
-
const result = (0,
|
|
703
|
+
const result = (0, import_editor_styles_repository2.validateStyleLabel)(newLabel, "rename");
|
|
623
704
|
if (result.isValid) {
|
|
624
705
|
return null;
|
|
625
706
|
}
|
|
@@ -674,11 +755,11 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
674
755
|
component: ClassManagerPanel,
|
|
675
756
|
allowedEditModes: ["edit", id],
|
|
676
757
|
onOpen: () => {
|
|
677
|
-
(0,
|
|
758
|
+
(0, import_editor_v1_adapters4.changeEditMode)(id);
|
|
678
759
|
blockPanelInteractions();
|
|
679
760
|
},
|
|
680
761
|
onClose: () => {
|
|
681
|
-
(0,
|
|
762
|
+
(0, import_editor_v1_adapters4.changeEditMode)("edit");
|
|
682
763
|
unblockPanelInteractions();
|
|
683
764
|
}
|
|
684
765
|
});
|
|
@@ -688,7 +769,7 @@ function ClassManagerPanel() {
|
|
|
688
769
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
689
770
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
690
771
|
usePreventUnload();
|
|
691
|
-
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,
|
|
772
|
+
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_i18n5.__)("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
692
773
|
CloseButton,
|
|
693
774
|
{
|
|
694
775
|
sx: { marginLeft: "auto" },
|
|
@@ -712,17 +793,17 @@ function ClassManagerPanel() {
|
|
|
712
793
|
disabled: !isDirty2,
|
|
713
794
|
loading: isPublishing
|
|
714
795
|
},
|
|
715
|
-
(0,
|
|
716
|
-
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, (0,
|
|
796
|
+
(0, import_i18n5.__)("Save changes", "elementor")
|
|
797
|
+
)))), /* @__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(
|
|
717
798
|
SaveChangesDialog.Actions,
|
|
718
799
|
{
|
|
719
800
|
actions: {
|
|
720
801
|
cancel: {
|
|
721
|
-
label: (0,
|
|
802
|
+
label: (0, import_i18n5.__)("Cancel", "elementor"),
|
|
722
803
|
action: closeSaveChangesDialog
|
|
723
804
|
},
|
|
724
805
|
confirm: {
|
|
725
|
-
label: (0,
|
|
806
|
+
label: (0, import_i18n5.__)("Save & Continue", "elementor"),
|
|
726
807
|
action: async () => {
|
|
727
808
|
await publish();
|
|
728
809
|
closeSaveChangesDialog();
|
|
@@ -734,7 +815,7 @@ function ClassManagerPanel() {
|
|
|
734
815
|
)));
|
|
735
816
|
}
|
|
736
817
|
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" }));
|
|
737
|
-
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,
|
|
818
|
+
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"))));
|
|
738
819
|
var usePreventUnload = () => {
|
|
739
820
|
const isDirty2 = useDirtyState();
|
|
740
821
|
(0, import_react5.useEffect)(() => {
|
|
@@ -767,6 +848,11 @@ var ClassManagerButton = () => {
|
|
|
767
848
|
const { open: openPanel } = usePanelActions();
|
|
768
849
|
const { save: saveDocument } = (0, import_editor_documents3.__useActiveDocumentActions)();
|
|
769
850
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
851
|
+
const { userCan } = (0, import_editor_styles_repository3.useUserStylesCapability)();
|
|
852
|
+
const isUserAllowedToUpdateClass = userCan(globalClassesStylesProvider.getKey()).update;
|
|
853
|
+
if (!isUserAllowedToUpdateClass) {
|
|
854
|
+
return null;
|
|
855
|
+
}
|
|
770
856
|
const handleOpenPanel = () => {
|
|
771
857
|
if (document?.isDirty) {
|
|
772
858
|
openSaveChangesDialog();
|
|
@@ -774,7 +860,7 @@ var ClassManagerButton = () => {
|
|
|
774
860
|
}
|
|
775
861
|
openPanel();
|
|
776
862
|
};
|
|
777
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(import_ui7.Tooltip, { title: (0,
|
|
863
|
+
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, { 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_i18n6.__)("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, (0, import_i18n6.__)(
|
|
778
864
|
"To open the Class Manager, save your page first. You can't continue without saving.",
|
|
779
865
|
"elementor"
|
|
780
866
|
))), /* @__PURE__ */ React8.createElement(
|
|
@@ -782,11 +868,11 @@ var ClassManagerButton = () => {
|
|
|
782
868
|
{
|
|
783
869
|
actions: {
|
|
784
870
|
cancel: {
|
|
785
|
-
label: (0,
|
|
871
|
+
label: (0, import_i18n6.__)("Stay here", "elementor"),
|
|
786
872
|
action: closeSaveChangesDialog
|
|
787
873
|
},
|
|
788
874
|
confirm: {
|
|
789
|
-
label: (0,
|
|
875
|
+
label: (0, import_i18n6.__)("Save & Continue", "elementor"),
|
|
790
876
|
action: async () => {
|
|
791
877
|
await saveDocument();
|
|
792
878
|
closeSaveChangesDialog();
|
|
@@ -800,9 +886,9 @@ var ClassManagerButton = () => {
|
|
|
800
886
|
|
|
801
887
|
// src/components/populate-store.tsx
|
|
802
888
|
var import_react6 = require("react");
|
|
803
|
-
var
|
|
889
|
+
var import_store16 = require("@elementor/store");
|
|
804
890
|
function PopulateStore() {
|
|
805
|
-
const dispatch4 = (0,
|
|
891
|
+
const dispatch4 = (0, import_store16.__useDispatch)();
|
|
806
892
|
(0, import_react6.useEffect)(() => {
|
|
807
893
|
Promise.all([apiClient.all("preview"), apiClient.all("frontend")]).then(
|
|
808
894
|
([previewRes, frontendRes]) => {
|
|
@@ -826,67 +912,9 @@ function PopulateStore() {
|
|
|
826
912
|
return null;
|
|
827
913
|
}
|
|
828
914
|
|
|
829
|
-
// src/global-classes-styles-provider.ts
|
|
830
|
-
var import_editor_styles2 = require("@elementor/editor-styles");
|
|
831
|
-
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
832
|
-
var import_store16 = require("@elementor/store");
|
|
833
|
-
var import_i18n6 = require("@wordpress/i18n");
|
|
834
|
-
var MAX_CLASSES = 50;
|
|
835
|
-
var globalClassesStylesProvider = (0, import_editor_styles_repository2.createStylesProvider)({
|
|
836
|
-
key: "global-classes",
|
|
837
|
-
priority: 30,
|
|
838
|
-
limit: MAX_CLASSES,
|
|
839
|
-
labels: {
|
|
840
|
-
singular: (0, import_i18n6.__)("class", "elementor"),
|
|
841
|
-
plural: (0, import_i18n6.__)("classes", "elementor")
|
|
842
|
-
},
|
|
843
|
-
subscribe: (cb) => (0, import_store16.__subscribeWithSelector)((state) => state.globalClasses, cb),
|
|
844
|
-
actions: {
|
|
845
|
-
all: () => selectOrderedClasses((0, import_store16.__getState)()),
|
|
846
|
-
get: (id2) => selectClass((0, import_store16.__getState)(), id2),
|
|
847
|
-
create: (label) => {
|
|
848
|
-
const classes = selectGlobalClasses((0, import_store16.__getState)());
|
|
849
|
-
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
850
|
-
if (existingLabels.includes(label)) {
|
|
851
|
-
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
852
|
-
}
|
|
853
|
-
const existingIds = Object.keys(classes);
|
|
854
|
-
const id2 = (0, import_editor_styles2.generateId)("g-", existingIds);
|
|
855
|
-
(0, import_store16.__dispatch)(
|
|
856
|
-
slice.actions.add({
|
|
857
|
-
id: id2,
|
|
858
|
-
type: "class",
|
|
859
|
-
label,
|
|
860
|
-
variants: []
|
|
861
|
-
})
|
|
862
|
-
);
|
|
863
|
-
return id2;
|
|
864
|
-
},
|
|
865
|
-
update: (payload) => {
|
|
866
|
-
(0, import_store16.__dispatch)(
|
|
867
|
-
slice.actions.update({
|
|
868
|
-
style: payload
|
|
869
|
-
})
|
|
870
|
-
);
|
|
871
|
-
},
|
|
872
|
-
delete: (id2) => {
|
|
873
|
-
(0, import_store16.__dispatch)(slice.actions.delete(id2));
|
|
874
|
-
},
|
|
875
|
-
updateProps: (args) => {
|
|
876
|
-
(0, import_store16.__dispatch)(
|
|
877
|
-
slice.actions.updateProps({
|
|
878
|
-
id: args.id,
|
|
879
|
-
meta: args.meta,
|
|
880
|
-
props: args.props
|
|
881
|
-
})
|
|
882
|
-
);
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
});
|
|
886
|
-
|
|
887
915
|
// src/sync-with-document-save.ts
|
|
888
916
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
889
|
-
var
|
|
917
|
+
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
890
918
|
var import_store18 = require("@elementor/store");
|
|
891
919
|
function syncWithDocumentSave() {
|
|
892
920
|
const unsubscribe = syncDirtyState();
|
|
@@ -902,7 +930,7 @@ function syncDirtyState() {
|
|
|
902
930
|
});
|
|
903
931
|
}
|
|
904
932
|
function bindSaveAction() {
|
|
905
|
-
(0,
|
|
933
|
+
(0, import_editor_v1_adapters5.registerDataHook)("after", "document/save/save", (args) => {
|
|
906
934
|
return saveGlobalClasses({
|
|
907
935
|
context: args.status === "publish" ? "frontend" : "preview"
|
|
908
936
|
});
|
|
@@ -916,7 +944,7 @@ function isDirty() {
|
|
|
916
944
|
function init() {
|
|
917
945
|
(0, import_store20.__registerSlice)(slice);
|
|
918
946
|
(0, import_editor_panels2.__registerPanel)(panel);
|
|
919
|
-
|
|
947
|
+
import_editor_styles_repository4.stylesRepository.register(globalClassesStylesProvider);
|
|
920
948
|
(0, import_editor.injectIntoLogic)({
|
|
921
949
|
id: "global-classes-populate-store",
|
|
922
950
|
component: PopulateStore
|
|
@@ -925,7 +953,7 @@ function init() {
|
|
|
925
953
|
id: "global-classes-manager-button",
|
|
926
954
|
component: ClassManagerButton
|
|
927
955
|
});
|
|
928
|
-
(0,
|
|
956
|
+
(0, import_editor_v1_adapters6.__privateListenTo)((0, import_editor_v1_adapters6.v1ReadyEvent)(), () => {
|
|
929
957
|
syncWithDocumentSave();
|
|
930
958
|
});
|
|
931
959
|
}
|