@elementor/editor-components 3.33.0-263 → 3.33.0-266
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/dist/index.js +50 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -16
- package/src/components/create-component-form/create-component-form.tsx +2 -26
- package/src/create-component-type.ts +11 -0
- package/src/store/create-unpublished-component.ts +40 -0
package/dist/index.mjs
CHANGED
|
@@ -578,11 +578,14 @@ import { useEffect, useMemo as useMemo2, useRef, useState as useState2 } from "r
|
|
|
578
578
|
import { getElementLabel } from "@elementor/editor-elements";
|
|
579
579
|
import { ThemeProvider as ThemeProvider2 } from "@elementor/editor-ui";
|
|
580
580
|
import { StarIcon } from "@elementor/icons";
|
|
581
|
-
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
582
581
|
import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack as Stack4, TextField as TextField2, Typography as Typography3 } from "@elementor/ui";
|
|
583
|
-
import { generateUniqueId } from "@elementor/utils";
|
|
584
582
|
import { __ as __4 } from "@wordpress/i18n";
|
|
585
583
|
|
|
584
|
+
// src/store/create-unpublished-component.ts
|
|
585
|
+
import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
|
|
586
|
+
import { __dispatch as dispatch2 } from "@elementor/store";
|
|
587
|
+
import { generateUniqueId } from "@elementor/utils";
|
|
588
|
+
|
|
586
589
|
// src/utils/tracking.ts
|
|
587
590
|
import { getMixpanel } from "@elementor/mixpanel";
|
|
588
591
|
import { __getState as getState3 } from "@elementor/store";
|
|
@@ -617,6 +620,28 @@ var onElementDrop = (_args, element) => {
|
|
|
617
620
|
});
|
|
618
621
|
};
|
|
619
622
|
|
|
623
|
+
// src/store/create-unpublished-component.ts
|
|
624
|
+
function createUnpublishedComponent(name, element, eventData) {
|
|
625
|
+
const uid = generateUniqueId("component");
|
|
626
|
+
const componentBase = { uid, name };
|
|
627
|
+
dispatch2(
|
|
628
|
+
slice.actions.addUnpublished({
|
|
629
|
+
...componentBase,
|
|
630
|
+
elements: [element]
|
|
631
|
+
})
|
|
632
|
+
);
|
|
633
|
+
dispatch2(slice.actions.addCreatedThisSession(uid));
|
|
634
|
+
replaceElementWithComponent(element, componentBase);
|
|
635
|
+
trackComponentEvent({
|
|
636
|
+
action: "created",
|
|
637
|
+
component_uid: uid,
|
|
638
|
+
component_name: name,
|
|
639
|
+
...eventData
|
|
640
|
+
});
|
|
641
|
+
runCommand("document/save/auto");
|
|
642
|
+
return uid;
|
|
643
|
+
}
|
|
644
|
+
|
|
620
645
|
// src/components/create-component-form/hooks/use-form.ts
|
|
621
646
|
import { useMemo, useState } from "react";
|
|
622
647
|
var useForm = (initialValues) => {
|
|
@@ -726,7 +751,6 @@ function CreateComponentForm() {
|
|
|
726
751
|
const [element, setElement] = useState2(null);
|
|
727
752
|
const [anchorPosition, setAnchorPosition] = useState2();
|
|
728
753
|
const [resultNotification, setResultNotification] = useState2(null);
|
|
729
|
-
const dispatch5 = useDispatch();
|
|
730
754
|
const eventData = useRef(null);
|
|
731
755
|
useEffect(() => {
|
|
732
756
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
@@ -749,22 +773,7 @@ function CreateComponentForm() {
|
|
|
749
773
|
if (!element) {
|
|
750
774
|
throw new Error(`Can't save element as component: element not found`);
|
|
751
775
|
}
|
|
752
|
-
const uid =
|
|
753
|
-
dispatch5(
|
|
754
|
-
slice.actions.addUnpublished({
|
|
755
|
-
uid,
|
|
756
|
-
name: values.componentName,
|
|
757
|
-
elements: [element.element]
|
|
758
|
-
})
|
|
759
|
-
);
|
|
760
|
-
dispatch5(slice.actions.addCreatedThisSession(uid));
|
|
761
|
-
replaceElementWithComponent(element.element, { uid, name: values.componentName });
|
|
762
|
-
trackComponentEvent({
|
|
763
|
-
action: "created",
|
|
764
|
-
component_uid: uid,
|
|
765
|
-
component_name: values.componentName,
|
|
766
|
-
...eventData.current
|
|
767
|
-
});
|
|
776
|
+
const uid = createUnpublishedComponent(values.componentName, element.element, eventData.current);
|
|
768
777
|
setResultNotification({
|
|
769
778
|
show: true,
|
|
770
779
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
@@ -885,7 +894,7 @@ import { useCallback, useEffect as useEffect4, useState as useState4 } from "rea
|
|
|
885
894
|
import { getV1DocumentsManager } from "@elementor/editor-documents";
|
|
886
895
|
import {
|
|
887
896
|
__privateListenTo as listenTo,
|
|
888
|
-
__privateRunCommand as
|
|
897
|
+
__privateRunCommand as runCommand2,
|
|
889
898
|
commandEndEvent as commandEndEvent2
|
|
890
899
|
} from "@elementor/editor-v1-adapters";
|
|
891
900
|
|
|
@@ -1128,7 +1137,7 @@ function useNavigateBack(path) {
|
|
|
1128
1137
|
const { component: prevComponent, instanceId: prevComponentInstanceId } = path.at(-2) ?? {};
|
|
1129
1138
|
const { id: prevComponentId } = prevComponent ?? {};
|
|
1130
1139
|
const switchToDocument = (id, selector) => {
|
|
1131
|
-
|
|
1140
|
+
runCommand2("editor/documents/switch", {
|
|
1132
1141
|
id,
|
|
1133
1142
|
selector,
|
|
1134
1143
|
mode: "autosave",
|
|
@@ -1167,7 +1176,8 @@ var EditModeDialog = ({ lockedBy }) => {
|
|
|
1167
1176
|
import {
|
|
1168
1177
|
createTemplatedElementView
|
|
1169
1178
|
} from "@elementor/editor-canvas";
|
|
1170
|
-
import {
|
|
1179
|
+
import { getCurrentDocument } from "@elementor/editor-documents";
|
|
1180
|
+
import { __privateRunCommand as runCommand3 } from "@elementor/editor-v1-adapters";
|
|
1171
1181
|
import { __ as __7 } from "@wordpress/i18n";
|
|
1172
1182
|
var TYPE = "e-component";
|
|
1173
1183
|
function createComponentType(options) {
|
|
@@ -1185,6 +1195,10 @@ function createComponentView(options) {
|
|
|
1185
1195
|
return class extends createTemplatedElementView(options) {
|
|
1186
1196
|
legacyWindow = window;
|
|
1187
1197
|
eventsManagerConfig = this.legacyWindow.elementorCommon.eventsManager.config;
|
|
1198
|
+
isComponentCurrentlyEdited() {
|
|
1199
|
+
const currentDocument = getCurrentDocument();
|
|
1200
|
+
return currentDocument?.id === this.getComponentId()?.value;
|
|
1201
|
+
}
|
|
1188
1202
|
afterSettingsResolve(settings) {
|
|
1189
1203
|
if (settings.component) {
|
|
1190
1204
|
this.collection = this.legacyWindow.elementor.createBackboneElementsCollection(settings.component);
|
|
@@ -1236,7 +1250,7 @@ function createComponentView(options) {
|
|
|
1236
1250
|
if (!isAllowedToSwitchDocument) {
|
|
1237
1251
|
options.showLockedByModal?.(lockedBy || "");
|
|
1238
1252
|
} else {
|
|
1239
|
-
|
|
1253
|
+
runCommand3("editor/documents/switch", {
|
|
1240
1254
|
id: this.getComponentId()?.value,
|
|
1241
1255
|
mode: "autosave",
|
|
1242
1256
|
selector: `[data-id="${this.model.get("id")}"]`,
|
|
@@ -1245,6 +1259,9 @@ function createComponentView(options) {
|
|
|
1245
1259
|
}
|
|
1246
1260
|
}
|
|
1247
1261
|
editComponent({ trigger, location, secondaryLocation }) {
|
|
1262
|
+
if (this.isComponentCurrentlyEdited()) {
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1248
1265
|
this.switchDocument();
|
|
1249
1266
|
const editorSettings = this.model.get("editor_settings");
|
|
1250
1267
|
trackComponentEvent({
|
|
@@ -1294,10 +1311,10 @@ function setInactiveRecursively(model) {
|
|
|
1294
1311
|
|
|
1295
1312
|
// src/populate-store.ts
|
|
1296
1313
|
import { useEffect as useEffect5 } from "react";
|
|
1297
|
-
import { __dispatch as
|
|
1314
|
+
import { __dispatch as dispatch3 } from "@elementor/store";
|
|
1298
1315
|
function PopulateStore() {
|
|
1299
1316
|
useEffect5(() => {
|
|
1300
|
-
|
|
1317
|
+
dispatch3(loadComponents());
|
|
1301
1318
|
}, []);
|
|
1302
1319
|
return null;
|
|
1303
1320
|
}
|
|
@@ -1325,15 +1342,15 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
1325
1342
|
});
|
|
1326
1343
|
|
|
1327
1344
|
// src/store/remove-component-styles.ts
|
|
1328
|
-
import { __dispatch as
|
|
1345
|
+
import { __dispatch as dispatch4 } from "@elementor/store";
|
|
1329
1346
|
function removeComponentStyles(id) {
|
|
1330
1347
|
apiClient.invalidateComponentConfigCache(id);
|
|
1331
|
-
|
|
1348
|
+
dispatch4(slice.actions.removeStyles({ id }));
|
|
1332
1349
|
}
|
|
1333
1350
|
|
|
1334
1351
|
// src/sync/create-components-before-save.ts
|
|
1335
1352
|
import { updateElementSettings } from "@elementor/editor-elements";
|
|
1336
|
-
import { __dispatch as
|
|
1353
|
+
import { __dispatch as dispatch5, __getState as getState5 } from "@elementor/store";
|
|
1337
1354
|
async function createComponentsBeforeSave({
|
|
1338
1355
|
container,
|
|
1339
1356
|
status
|
|
@@ -1346,7 +1363,7 @@ async function createComponentsBeforeSave({
|
|
|
1346
1363
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
1347
1364
|
const elements = container.model.get("elements").toJSON();
|
|
1348
1365
|
updateComponentInstances(elements, uidToComponentId);
|
|
1349
|
-
|
|
1366
|
+
dispatch5(
|
|
1350
1367
|
slice.actions.add(
|
|
1351
1368
|
unpublishedComponents.map((component) => ({
|
|
1352
1369
|
id: uidToComponentId.get(component.uid),
|
|
@@ -1355,7 +1372,7 @@ async function createComponentsBeforeSave({
|
|
|
1355
1372
|
}))
|
|
1356
1373
|
)
|
|
1357
1374
|
);
|
|
1358
|
-
|
|
1375
|
+
dispatch5(slice.actions.resetUnpublished());
|
|
1359
1376
|
} catch (error) {
|
|
1360
1377
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
1361
1378
|
}
|