@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.mjs
CHANGED
|
@@ -2,27 +2,23 @@
|
|
|
2
2
|
import { injectIntoLogic } from "@elementor/editor";
|
|
3
3
|
import { injectIntoClassSelectorActions } from "@elementor/editor-editing-panel";
|
|
4
4
|
import { __registerPanel as registerPanel } from "@elementor/editor-panels";
|
|
5
|
-
import { stylesRepository
|
|
5
|
+
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
6
6
|
import { __privateListenTo as listenTo, v1ReadyEvent } from "@elementor/editor-v1-adapters";
|
|
7
7
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
8
8
|
|
|
9
9
|
// src/components/class-manager/class-manager-button.tsx
|
|
10
10
|
import * as React8 from "react";
|
|
11
11
|
import {
|
|
12
|
-
__useActiveDocument as
|
|
12
|
+
__useActiveDocument as useActiveDocument,
|
|
13
13
|
__useActiveDocumentActions as useActiveDocumentActions
|
|
14
14
|
} from "@elementor/editor-documents";
|
|
15
15
|
import { IconButton as IconButton3, Tooltip as Tooltip2 } from "@elementor/ui";
|
|
16
|
-
import { __ as
|
|
16
|
+
import { __ as __5 } from "@wordpress/i18n";
|
|
17
17
|
|
|
18
18
|
// src/components/class-manager/class-manager-panel.tsx
|
|
19
19
|
import * as React7 from "react";
|
|
20
|
-
import { useEffect
|
|
21
|
-
import {
|
|
22
|
-
__useActiveDocument as useActiveDocument,
|
|
23
|
-
getDocumentModifiedStatus,
|
|
24
|
-
setDocumentModifiedStatus
|
|
25
|
-
} from "@elementor/editor-documents";
|
|
20
|
+
import { useEffect } from "react";
|
|
21
|
+
import { setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
26
22
|
import {
|
|
27
23
|
__createPanel as createPanel,
|
|
28
24
|
Panel,
|
|
@@ -36,7 +32,7 @@ import { changeEditMode } from "@elementor/editor-v1-adapters";
|
|
|
36
32
|
import { XIcon } from "@elementor/icons";
|
|
37
33
|
import { useMutation } from "@elementor/query";
|
|
38
34
|
import { Alert, Box as Box4, Button as Button3, ErrorBoundary, IconButton as IconButton2, Stack as Stack2 } from "@elementor/ui";
|
|
39
|
-
import { __ as
|
|
35
|
+
import { __ as __4 } from "@wordpress/i18n";
|
|
40
36
|
|
|
41
37
|
// src/hooks/use-dirty-state.ts
|
|
42
38
|
import { __useSelector as useSelector } from "@elementor/store";
|
|
@@ -180,7 +176,7 @@ import * as React from "react";
|
|
|
180
176
|
import { useState } from "react";
|
|
181
177
|
import { useSuppressedMessage } from "@elementor/editor-current-user";
|
|
182
178
|
import { IntroductionModal } from "@elementor/editor-ui";
|
|
183
|
-
import { Box, Typography } from "@elementor/ui";
|
|
179
|
+
import { Box, Image, Typography } from "@elementor/ui";
|
|
184
180
|
import { __ } from "@wordpress/i18n";
|
|
185
181
|
var MESSAGE_KEY = "global-class-manager";
|
|
186
182
|
var ClassManagerIntroduction = () => {
|
|
@@ -190,31 +186,60 @@ var ClassManagerIntroduction = () => {
|
|
|
190
186
|
IntroductionModal,
|
|
191
187
|
{
|
|
192
188
|
open: shouldShowIntroduction,
|
|
193
|
-
title: __("
|
|
194
|
-
image: {
|
|
195
|
-
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
196
|
-
alt: __("Class manager screenshot", "elementor")
|
|
197
|
-
},
|
|
198
|
-
content: /* @__PURE__ */ React.createElement(IntroductionContent, null),
|
|
189
|
+
title: __("Class Manager", "elementor"),
|
|
199
190
|
handleClose: (shouldShowAgain) => {
|
|
200
191
|
if (!shouldShowAgain) {
|
|
201
192
|
suppressMessage();
|
|
202
193
|
}
|
|
203
194
|
setShouldShowIntroduction(false);
|
|
204
195
|
}
|
|
205
|
-
}
|
|
196
|
+
},
|
|
197
|
+
/* @__PURE__ */ React.createElement(
|
|
198
|
+
Image,
|
|
199
|
+
{
|
|
200
|
+
sx: { width: "100%", aspectRatio: "16 / 9" },
|
|
201
|
+
src: "https://assets.elementor.com/packages/v1/images/class-manager-intro.svg",
|
|
202
|
+
alt: ""
|
|
203
|
+
}
|
|
204
|
+
),
|
|
205
|
+
/* @__PURE__ */ React.createElement(IntroductionContent, null)
|
|
206
206
|
);
|
|
207
207
|
};
|
|
208
208
|
var IntroductionContent = () => {
|
|
209
|
-
return /* @__PURE__ */ React.createElement(Box, {
|
|
210
|
-
"The
|
|
209
|
+
return /* @__PURE__ */ React.createElement(Box, { p: 3 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
|
|
210
|
+
"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.",
|
|
211
211
|
"elementor"
|
|
212
212
|
)), /* @__PURE__ */ React.createElement("br", null), /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, __(
|
|
213
|
-
"
|
|
213
|
+
"Remember, when editing an item within a specific class, any changes you make will apply across all elements in that class.",
|
|
214
214
|
"elementor"
|
|
215
215
|
)));
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
// src/components/class-manager/delete-class.ts
|
|
219
|
+
import { getCurrentDocument, getV1DocumentsManager } from "@elementor/editor-documents";
|
|
220
|
+
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
221
|
+
import { __dispatch as dispatch2 } from "@elementor/store";
|
|
222
|
+
var isDeleted = false;
|
|
223
|
+
var deleteClass = (id2) => {
|
|
224
|
+
dispatch2(slice.actions.delete(id2));
|
|
225
|
+
isDeleted = true;
|
|
226
|
+
};
|
|
227
|
+
var onDelete = async () => {
|
|
228
|
+
await reloadDocument();
|
|
229
|
+
isDeleted = false;
|
|
230
|
+
};
|
|
231
|
+
var hasDeletedItems = () => isDeleted;
|
|
232
|
+
var reloadDocument = () => {
|
|
233
|
+
const currentDocument = getCurrentDocument();
|
|
234
|
+
const documentsManager = getV1DocumentsManager();
|
|
235
|
+
documentsManager.invalidateCache();
|
|
236
|
+
return runCommand("editor/documents/switch", {
|
|
237
|
+
id: currentDocument?.id,
|
|
238
|
+
shouldScroll: false,
|
|
239
|
+
shouldNavigateToDefaultRoute: false
|
|
240
|
+
});
|
|
241
|
+
};
|
|
242
|
+
|
|
218
243
|
// src/components/class-manager/flipped-color-swatch-icon.tsx
|
|
219
244
|
import * as React2 from "react";
|
|
220
245
|
import { ColorSwatchIcon } from "@elementor/icons";
|
|
@@ -222,9 +247,10 @@ var FlippedColorSwatchIcon = ({ sx, ...props }) => /* @__PURE__ */ React2.create
|
|
|
222
247
|
|
|
223
248
|
// src/components/class-manager/global-classes-list.tsx
|
|
224
249
|
import * as React5 from "react";
|
|
225
|
-
import {
|
|
250
|
+
import { validateStyleLabel } from "@elementor/editor-styles-repository";
|
|
226
251
|
import { EditableField, EllipsisWithTooltip, MenuListItem, useEditable } from "@elementor/editor-ui";
|
|
227
252
|
import { DotsVerticalIcon } from "@elementor/icons";
|
|
253
|
+
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
228
254
|
import {
|
|
229
255
|
bindMenu,
|
|
230
256
|
bindTrigger,
|
|
@@ -239,71 +265,7 @@ import {
|
|
|
239
265
|
Typography as Typography3,
|
|
240
266
|
usePopupState
|
|
241
267
|
} from "@elementor/ui";
|
|
242
|
-
import { __ as
|
|
243
|
-
|
|
244
|
-
// src/global-classes-styles-provider.ts
|
|
245
|
-
import { generateId } from "@elementor/editor-styles";
|
|
246
|
-
import {
|
|
247
|
-
__dispatch as dispatch2,
|
|
248
|
-
__getState as getState2,
|
|
249
|
-
__subscribeWithSelector as subscribeWithSelector
|
|
250
|
-
} from "@elementor/store";
|
|
251
|
-
import { __ as __2 } from "@wordpress/i18n";
|
|
252
|
-
var MAX_CLASSES = 50;
|
|
253
|
-
var globalClassesStylesProvider = {
|
|
254
|
-
key: "global-classes",
|
|
255
|
-
priority: 30,
|
|
256
|
-
limit: MAX_CLASSES,
|
|
257
|
-
actions: {
|
|
258
|
-
get: () => selectOrderedClasses(getState2()),
|
|
259
|
-
getById: (id2) => selectClass(getState2(), id2),
|
|
260
|
-
create: (label) => {
|
|
261
|
-
const classes = selectGlobalClasses(getState2());
|
|
262
|
-
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
263
|
-
if (existingLabels.includes(label)) {
|
|
264
|
-
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
265
|
-
}
|
|
266
|
-
const existingIds = Object.keys(classes);
|
|
267
|
-
const id2 = generateId("g-", existingIds);
|
|
268
|
-
dispatch2(
|
|
269
|
-
slice.actions.add({
|
|
270
|
-
id: id2,
|
|
271
|
-
type: "class",
|
|
272
|
-
label,
|
|
273
|
-
variants: []
|
|
274
|
-
})
|
|
275
|
-
);
|
|
276
|
-
return id2;
|
|
277
|
-
},
|
|
278
|
-
update: (payload) => {
|
|
279
|
-
dispatch2(
|
|
280
|
-
slice.actions.update({
|
|
281
|
-
style: payload
|
|
282
|
-
})
|
|
283
|
-
);
|
|
284
|
-
},
|
|
285
|
-
delete: (id2) => {
|
|
286
|
-
dispatch2(slice.actions.delete(id2));
|
|
287
|
-
},
|
|
288
|
-
setOrder: (order) => {
|
|
289
|
-
dispatch2(slice.actions.setOrder(order));
|
|
290
|
-
},
|
|
291
|
-
updateProps: (args) => {
|
|
292
|
-
dispatch2(
|
|
293
|
-
slice.actions.updateProps({
|
|
294
|
-
id: args.id,
|
|
295
|
-
meta: args.meta,
|
|
296
|
-
props: args.props
|
|
297
|
-
})
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
},
|
|
301
|
-
subscribe: (cb) => subscribeWithSelector((state) => state.globalClasses, cb),
|
|
302
|
-
labels: {
|
|
303
|
-
singular: __2("Global class", "elementor"),
|
|
304
|
-
plural: __2("Global CSS classes", "elementor")
|
|
305
|
-
}
|
|
306
|
-
};
|
|
268
|
+
import { __ as __3 } from "@wordpress/i18n";
|
|
307
269
|
|
|
308
270
|
// src/hooks/use-classes-order.ts
|
|
309
271
|
import { __useSelector as useSelector2 } from "@elementor/store";
|
|
@@ -330,7 +292,7 @@ import {
|
|
|
330
292
|
DialogTitle,
|
|
331
293
|
Typography as Typography2
|
|
332
294
|
} from "@elementor/ui";
|
|
333
|
-
import { __ as
|
|
295
|
+
import { __ as __2 } from "@wordpress/i18n";
|
|
334
296
|
var context = createContext(null);
|
|
335
297
|
var DeleteConfirmationProvider = ({ children }) => {
|
|
336
298
|
const [dialogProps, setDialogProps] = useState2(null);
|
|
@@ -346,13 +308,13 @@ var TITLE_ID = "delete-class-dialog";
|
|
|
346
308
|
var DeleteConfirmationDialog = ({ label, id: id2 }) => {
|
|
347
309
|
const { closeDialog } = useDeleteConfirmation();
|
|
348
310
|
const onConfirm = () => {
|
|
349
|
-
|
|
311
|
+
deleteClass(id2);
|
|
350
312
|
closeDialog();
|
|
351
313
|
};
|
|
352
|
-
return /* @__PURE__ */ React3.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(AlertOctagonFilledIcon, { color: "error" }),
|
|
314
|
+
return /* @__PURE__ */ React3.createElement(Dialog, { open: true, onClose: closeDialog, "aria-labelledby": TITLE_ID, maxWidth: "xs" }, /* @__PURE__ */ React3.createElement(DialogTitle, { id: TITLE_ID, display: "flex", alignItems: "center", gap: 1, sx: { lineHeight: 1 } }, /* @__PURE__ */ React3.createElement(AlertOctagonFilledIcon, { color: "error" }), __2("Delete this class?", "elementor")), /* @__PURE__ */ React3.createElement(DialogContent, null, /* @__PURE__ */ React3.createElement(DialogContentText, { variant: "body2", color: "textPrimary" }, __2("Deleting", "elementor"), /* @__PURE__ */ React3.createElement(Typography2, { variant: "subtitle2", component: "span" }, "\xA0", label, "\xA0"), __2(
|
|
353
315
|
"will permanently remove it from your project and may affect the design across all elements using it. This action cannot be undone.",
|
|
354
316
|
"elementor"
|
|
355
|
-
))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog },
|
|
317
|
+
))), /* @__PURE__ */ React3.createElement(DialogActions, null, /* @__PURE__ */ React3.createElement(Button, { color: "secondary", onClick: closeDialog }, __2("Not now", "elementor")), /* @__PURE__ */ React3.createElement(Button, { variant: "contained", color: "error", onClick: onConfirm }, __2("Delete", "elementor"))));
|
|
356
318
|
};
|
|
357
319
|
var useDeleteConfirmation = () => {
|
|
358
320
|
const contextValue = useContext(context);
|
|
@@ -431,13 +393,21 @@ var SortableItemIndicator = styled(Box2)`
|
|
|
431
393
|
// src/components/class-manager/global-classes-list.tsx
|
|
432
394
|
var GlobalClassesList = ({ disabled }) => {
|
|
433
395
|
const cssClasses = useOrderedClasses();
|
|
396
|
+
const dispatch4 = useDispatch();
|
|
434
397
|
const [classesOrder, reorderClasses] = useReorder();
|
|
435
398
|
if (!cssClasses?.length) {
|
|
436
399
|
return /* @__PURE__ */ React5.createElement(EmptyState, null);
|
|
437
400
|
}
|
|
438
401
|
return /* @__PURE__ */ React5.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React5.createElement(List, { sx: { display: "flex", flexDirection: "column", gap: 0.5 } }, /* @__PURE__ */ React5.createElement(SortableProvider, { value: classesOrder, onChange: reorderClasses }, cssClasses?.map(({ id: id2, label }) => {
|
|
439
402
|
const renameClass = (newLabel) => {
|
|
440
|
-
|
|
403
|
+
dispatch4(
|
|
404
|
+
slice.actions.update({
|
|
405
|
+
style: {
|
|
406
|
+
id: id2,
|
|
407
|
+
label: newLabel
|
|
408
|
+
}
|
|
409
|
+
})
|
|
410
|
+
);
|
|
441
411
|
};
|
|
442
412
|
return /* @__PURE__ */ React5.createElement(SortableItem, { key: id2, id: id2 }, ({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React5.createElement(
|
|
443
413
|
ClassItem,
|
|
@@ -453,9 +423,10 @@ var GlobalClassesList = ({ disabled }) => {
|
|
|
453
423
|
}))));
|
|
454
424
|
};
|
|
455
425
|
var useReorder = () => {
|
|
426
|
+
const dispatch4 = useDispatch();
|
|
456
427
|
const order = useClassesOrder();
|
|
457
428
|
const reorder = (newIds) => {
|
|
458
|
-
|
|
429
|
+
dispatch4(slice.actions.setOrder(newIds));
|
|
459
430
|
};
|
|
460
431
|
return [order, reorder];
|
|
461
432
|
};
|
|
@@ -505,7 +476,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
505
476
|
{
|
|
506
477
|
placement: "top",
|
|
507
478
|
className: "class-item-more-actions",
|
|
508
|
-
title:
|
|
479
|
+
title: __3("More actions", "elementor")
|
|
509
480
|
},
|
|
510
481
|
/* @__PURE__ */ React5.createElement(IconButton, { size: "tiny", ...bindTrigger(popupState), "aria-label": "More actions" }, /* @__PURE__ */ React5.createElement(DotsVerticalIcon, { fontSize: "tiny" }))
|
|
511
482
|
)
|
|
@@ -531,7 +502,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
531
502
|
openEditMode();
|
|
532
503
|
}
|
|
533
504
|
},
|
|
534
|
-
/* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "text.primary" } },
|
|
505
|
+
/* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "text.primary" } }, __3("Rename", "elementor"))
|
|
535
506
|
),
|
|
536
507
|
/* @__PURE__ */ React5.createElement(
|
|
537
508
|
MenuListItem,
|
|
@@ -541,7 +512,7 @@ var ClassItem = ({ id: id2, label, renameClass, selected, disabled, sortableTrig
|
|
|
541
512
|
openDialog({ id: id2, label });
|
|
542
513
|
}
|
|
543
514
|
},
|
|
544
|
-
/* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "error.light" } },
|
|
515
|
+
/* @__PURE__ */ React5.createElement(Typography3, { variant: "caption", sx: { color: "error.light" } }, __3("Delete", "elementor"))
|
|
545
516
|
)
|
|
546
517
|
));
|
|
547
518
|
};
|
|
@@ -570,7 +541,7 @@ var StyledListItemButton = styled2(ListItemButton, {
|
|
|
570
541
|
}
|
|
571
542
|
`
|
|
572
543
|
);
|
|
573
|
-
var EmptyState = () => /* @__PURE__ */ React5.createElement(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" },
|
|
544
|
+
var EmptyState = () => /* @__PURE__ */ React5.createElement(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" }, __3("There are no global classes yet.", "elementor")), /* @__PURE__ */ React5.createElement(Typography3, { align: "center", variant: "caption", color: "text.secondary" }, __3(
|
|
574
545
|
"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.",
|
|
575
546
|
"elementor"
|
|
576
547
|
)));
|
|
@@ -601,15 +572,23 @@ var getIndicatorBorder = ({ isActive, isError, theme }) => {
|
|
|
601
572
|
return "none";
|
|
602
573
|
};
|
|
603
574
|
var validateLabel = (newLabel) => {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (stylesRepository.isLabelExist(newLabel)) {
|
|
608
|
-
return __4("Existing name", "elementor");
|
|
575
|
+
const result = validateStyleLabel(newLabel);
|
|
576
|
+
if (result.isValid) {
|
|
577
|
+
return null;
|
|
609
578
|
}
|
|
610
|
-
return
|
|
579
|
+
return result.error;
|
|
611
580
|
};
|
|
612
581
|
|
|
582
|
+
// src/components/class-manager/panel-interactions.ts
|
|
583
|
+
function blockPanelInteractions() {
|
|
584
|
+
const extendedWindow = window;
|
|
585
|
+
extendedWindow.$e?.components?.get?.("panel")?.blockUserInteractions?.();
|
|
586
|
+
}
|
|
587
|
+
function unblockPanelInteractions() {
|
|
588
|
+
const extendedWindow = window;
|
|
589
|
+
extendedWindow.$e?.components?.get?.("panel")?.unblockUserInteractions?.();
|
|
590
|
+
}
|
|
591
|
+
|
|
613
592
|
// src/components/class-manager/save-changes-dialog.tsx
|
|
614
593
|
import * as React6 from "react";
|
|
615
594
|
import { useState as useState3 } from "react";
|
|
@@ -656,13 +635,11 @@ var { panel, usePanelActions } = createPanel({
|
|
|
656
635
|
allowedEditModes: ["edit", id],
|
|
657
636
|
onOpen: () => {
|
|
658
637
|
changeEditMode(id);
|
|
659
|
-
|
|
638
|
+
blockPanelInteractions();
|
|
660
639
|
},
|
|
661
|
-
onClose: (
|
|
640
|
+
onClose: () => {
|
|
662
641
|
changeEditMode("edit");
|
|
663
|
-
|
|
664
|
-
setDocumentModifiedStatus(documentModifiedState);
|
|
665
|
-
}
|
|
642
|
+
unblockPanelInteractions();
|
|
666
643
|
}
|
|
667
644
|
});
|
|
668
645
|
function ClassManagerPanel() {
|
|
@@ -671,10 +648,11 @@ function ClassManagerPanel() {
|
|
|
671
648
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
672
649
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
673
650
|
usePreventUnload();
|
|
674
|
-
return /* @__PURE__ */ React7.createElement(
|
|
651
|
+
return /* @__PURE__ */ React7.createElement(ThemeProvider, null, /* @__PURE__ */ React7.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React7.createElement(ErrorBoundaryFallback, null) }, /* @__PURE__ */ React7.createElement(Panel, null, /* @__PURE__ */ React7.createElement(PanelHeader, null, /* @__PURE__ */ React7.createElement(Stack2, { p: 1, pl: 2, width: "100%", direction: "row", alignItems: "center" }, /* @__PURE__ */ React7.createElement(PanelHeaderTitle, { sx: { display: "flex", alignItems: "center", gap: 0.5 } }, /* @__PURE__ */ React7.createElement(FlippedColorSwatchIcon, { fontSize: "inherit" }), __4("Class Manager", "elementor")), /* @__PURE__ */ React7.createElement(
|
|
675
652
|
CloseButton,
|
|
676
653
|
{
|
|
677
654
|
sx: { marginLeft: "auto" },
|
|
655
|
+
disabled: isPublishing,
|
|
678
656
|
onClose: () => {
|
|
679
657
|
if (isDirty2) {
|
|
680
658
|
openSaveChangesDialog();
|
|
@@ -694,17 +672,17 @@ function ClassManagerPanel() {
|
|
|
694
672
|
disabled: !isDirty2,
|
|
695
673
|
loading: isPublishing
|
|
696
674
|
},
|
|
697
|
-
|
|
698
|
-
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null,
|
|
675
|
+
__4("Save changes", "elementor")
|
|
676
|
+
)))), /* @__PURE__ */ React7.createElement(ClassManagerIntroduction, null), isSaveChangesDialogOpen && /* @__PURE__ */ React7.createElement(SaveChangesDialog, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.Title, null, __4("You have unsaved changes", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __4("You have unsaved changes in the Class Manager.", "elementor")), /* @__PURE__ */ React7.createElement(SaveChangesDialog.ContentText, null, __4("To avoid losing your updates, save your changes before leaving.", "elementor"))), /* @__PURE__ */ React7.createElement(
|
|
699
677
|
SaveChangesDialog.Actions,
|
|
700
678
|
{
|
|
701
679
|
actions: {
|
|
702
680
|
cancel: {
|
|
703
|
-
label:
|
|
681
|
+
label: __4("Cancel", "elementor"),
|
|
704
682
|
action: closeSaveChangesDialog
|
|
705
683
|
},
|
|
706
684
|
confirm: {
|
|
707
|
-
label:
|
|
685
|
+
label: __4("Save & Continue", "elementor"),
|
|
708
686
|
action: async () => {
|
|
709
687
|
await publish();
|
|
710
688
|
closeSaveChangesDialog();
|
|
@@ -713,10 +691,10 @@ function ClassManagerPanel() {
|
|
|
713
691
|
}
|
|
714
692
|
}
|
|
715
693
|
}
|
|
716
|
-
)))
|
|
694
|
+
)));
|
|
717
695
|
}
|
|
718
696
|
var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React7.createElement(IconButton2, { size: "small", color: "secondary", onClick: onClose, "aria-label": "Close", ...props }, /* @__PURE__ */ React7.createElement(XIcon, { fontSize: "small" }));
|
|
719
|
-
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null,
|
|
697
|
+
var ErrorBoundaryFallback = () => /* @__PURE__ */ React7.createElement(Box4, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React7.createElement(Alert, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React7.createElement("strong", null, __4("Something went wrong", "elementor"))));
|
|
720
698
|
var usePreventUnload = () => {
|
|
721
699
|
const isDirty2 = useDirtyState();
|
|
722
700
|
useEffect(() => {
|
|
@@ -732,13 +710,12 @@ var usePreventUnload = () => {
|
|
|
732
710
|
}, [isDirty2]);
|
|
733
711
|
};
|
|
734
712
|
var usePublish = () => {
|
|
735
|
-
const document = useActiveDocument();
|
|
736
|
-
const [initialDocumentStatus] = useState4(document?.isDirty ?? false);
|
|
737
713
|
return useMutation({
|
|
738
714
|
mutationFn: () => saveGlobalClasses({ context: "frontend" }),
|
|
739
|
-
onSuccess: () => {
|
|
740
|
-
|
|
741
|
-
|
|
715
|
+
onSuccess: async () => {
|
|
716
|
+
setDocumentModifiedStatus(false);
|
|
717
|
+
if (hasDeletedItems()) {
|
|
718
|
+
await onDelete();
|
|
742
719
|
}
|
|
743
720
|
}
|
|
744
721
|
});
|
|
@@ -746,7 +723,7 @@ var usePublish = () => {
|
|
|
746
723
|
|
|
747
724
|
// src/components/class-manager/class-manager-button.tsx
|
|
748
725
|
var ClassManagerButton = () => {
|
|
749
|
-
const document =
|
|
726
|
+
const document = useActiveDocument();
|
|
750
727
|
const { open: openPanel } = usePanelActions();
|
|
751
728
|
const { save: saveDocument } = useActiveDocumentActions();
|
|
752
729
|
const { open: openSaveChangesDialog, close: closeSaveChangesDialog, isOpen: isSaveChangesDialogOpen } = useDialog();
|
|
@@ -757,19 +734,19 @@ var ClassManagerButton = () => {
|
|
|
757
734
|
}
|
|
758
735
|
openPanel();
|
|
759
736
|
};
|
|
760
|
-
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Tooltip2, { title:
|
|
761
|
-
"
|
|
737
|
+
return /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement(Tooltip2, { title: __5("Class Manager", "elementor"), placement: "top" }, /* @__PURE__ */ React8.createElement(IconButton3, { onClick: handleOpenPanel }, /* @__PURE__ */ React8.createElement(FlippedColorSwatchIcon, { fontSize: "tiny" }))), isSaveChangesDialogOpen && /* @__PURE__ */ React8.createElement(SaveChangesDialog, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.Title, null, __5("You have unsaved changes", "elementor")), /* @__PURE__ */ React8.createElement(SaveChangesDialog.Content, null, /* @__PURE__ */ React8.createElement(SaveChangesDialog.ContentText, { sx: { mb: 2 } }, __5(
|
|
738
|
+
"To open the Class Manager, save your page first. You can't continue without saving.",
|
|
762
739
|
"elementor"
|
|
763
|
-
))
|
|
740
|
+
))), /* @__PURE__ */ React8.createElement(
|
|
764
741
|
SaveChangesDialog.Actions,
|
|
765
742
|
{
|
|
766
743
|
actions: {
|
|
767
744
|
cancel: {
|
|
768
|
-
label:
|
|
745
|
+
label: __5("Stay here", "elementor"),
|
|
769
746
|
action: closeSaveChangesDialog
|
|
770
747
|
},
|
|
771
748
|
confirm: {
|
|
772
|
-
label:
|
|
749
|
+
label: __5("Save & Continue", "elementor"),
|
|
773
750
|
action: async () => {
|
|
774
751
|
await saveDocument();
|
|
775
752
|
closeSaveChangesDialog();
|
|
@@ -783,18 +760,80 @@ var ClassManagerButton = () => {
|
|
|
783
760
|
|
|
784
761
|
// src/components/populate-store.tsx
|
|
785
762
|
import { useEffect as useEffect2 } from "react";
|
|
786
|
-
import { __useDispatch as
|
|
763
|
+
import { __useDispatch as useDispatch2 } from "@elementor/store";
|
|
787
764
|
function PopulateStore() {
|
|
788
|
-
const
|
|
765
|
+
const dispatch4 = useDispatch2();
|
|
789
766
|
useEffect2(() => {
|
|
790
767
|
apiClient.all().then((res) => {
|
|
791
768
|
const { data, meta } = res.data;
|
|
792
|
-
|
|
769
|
+
dispatch4(slice.actions.init({ items: data, order: meta.order }));
|
|
793
770
|
});
|
|
794
|
-
}, [
|
|
771
|
+
}, [dispatch4]);
|
|
795
772
|
return null;
|
|
796
773
|
}
|
|
797
774
|
|
|
775
|
+
// src/global-classes-styles-provider.ts
|
|
776
|
+
import { generateId } from "@elementor/editor-styles";
|
|
777
|
+
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
778
|
+
import {
|
|
779
|
+
__dispatch as dispatch3,
|
|
780
|
+
__getState as getState2,
|
|
781
|
+
__subscribeWithSelector as subscribeWithSelector
|
|
782
|
+
} from "@elementor/store";
|
|
783
|
+
import { __ as __6 } from "@wordpress/i18n";
|
|
784
|
+
var MAX_CLASSES = 50;
|
|
785
|
+
var globalClassesStylesProvider = createStylesProvider({
|
|
786
|
+
key: "global-classes",
|
|
787
|
+
priority: 30,
|
|
788
|
+
limit: MAX_CLASSES,
|
|
789
|
+
labels: {
|
|
790
|
+
singular: __6("class", "elementor"),
|
|
791
|
+
plural: __6("classes", "elementor")
|
|
792
|
+
},
|
|
793
|
+
subscribe: (cb) => subscribeWithSelector((state) => state.globalClasses, cb),
|
|
794
|
+
actions: {
|
|
795
|
+
all: () => selectOrderedClasses(getState2()),
|
|
796
|
+
get: (id2) => selectClass(getState2(), id2),
|
|
797
|
+
create: (label) => {
|
|
798
|
+
const classes = selectGlobalClasses(getState2());
|
|
799
|
+
const existingLabels = Object.values(classes).map((style) => style.label);
|
|
800
|
+
if (existingLabels.includes(label)) {
|
|
801
|
+
throw new GlobalClassLabelAlreadyExistsError({ context: { label } });
|
|
802
|
+
}
|
|
803
|
+
const existingIds = Object.keys(classes);
|
|
804
|
+
const id2 = generateId("g-", existingIds);
|
|
805
|
+
dispatch3(
|
|
806
|
+
slice.actions.add({
|
|
807
|
+
id: id2,
|
|
808
|
+
type: "class",
|
|
809
|
+
label,
|
|
810
|
+
variants: []
|
|
811
|
+
})
|
|
812
|
+
);
|
|
813
|
+
return id2;
|
|
814
|
+
},
|
|
815
|
+
update: (payload) => {
|
|
816
|
+
dispatch3(
|
|
817
|
+
slice.actions.update({
|
|
818
|
+
style: payload
|
|
819
|
+
})
|
|
820
|
+
);
|
|
821
|
+
},
|
|
822
|
+
delete: (id2) => {
|
|
823
|
+
dispatch3(slice.actions.delete(id2));
|
|
824
|
+
},
|
|
825
|
+
updateProps: (args) => {
|
|
826
|
+
dispatch3(
|
|
827
|
+
slice.actions.updateProps({
|
|
828
|
+
id: args.id,
|
|
829
|
+
meta: args.meta,
|
|
830
|
+
props: args.props
|
|
831
|
+
})
|
|
832
|
+
);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
|
|
798
837
|
// src/sync-with-document-save.ts
|
|
799
838
|
import { setDocumentModifiedStatus as setDocumentModifiedStatus2 } from "@elementor/editor-documents";
|
|
800
839
|
import { registerDataHook } from "@elementor/editor-v1-adapters";
|
|
@@ -827,7 +866,7 @@ function isDirty() {
|
|
|
827
866
|
function init() {
|
|
828
867
|
registerSlice(slice);
|
|
829
868
|
registerPanel(panel);
|
|
830
|
-
|
|
869
|
+
stylesRepository.register(globalClassesStylesProvider);
|
|
831
870
|
injectIntoLogic({
|
|
832
871
|
id: "global-classes-populate-store",
|
|
833
872
|
component: PopulateStore
|
|
@@ -840,7 +879,7 @@ function init() {
|
|
|
840
879
|
syncWithDocumentSave();
|
|
841
880
|
});
|
|
842
881
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
882
|
+
export {
|
|
883
|
+
init
|
|
884
|
+
};
|
|
846
885
|
//# sourceMappingURL=index.mjs.map
|