@elementor/editor-components 3.33.0-260 → 3.33.0-262
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 +117 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +107 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +16 -15
- package/src/components/create-component-form/create-component-form.tsx +32 -5
- package/src/components/create-component-form/utils/get-component-event-data.ts +54 -0
- package/src/components/create-component-form/utils/replace-element-with-component.ts +2 -2
- package/src/create-component-type.ts +30 -3
- package/src/init.ts +6 -0
- package/src/utils/tracking.ts +47 -0
package/dist/index.js
CHANGED
|
@@ -41,7 +41,7 @@ var import_editor_documents2 = require("@elementor/editor-documents");
|
|
|
41
41
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
42
42
|
var import_editor_styles_repository2 = require("@elementor/editor-styles-repository");
|
|
43
43
|
var import_editor_v1_adapters5 = require("@elementor/editor-v1-adapters");
|
|
44
|
-
var
|
|
44
|
+
var import_store20 = require("@elementor/store");
|
|
45
45
|
var import_i18n8 = require("@wordpress/i18n");
|
|
46
46
|
|
|
47
47
|
// src/component-id-transformer.ts
|
|
@@ -604,11 +604,45 @@ var import_react3 = require("react");
|
|
|
604
604
|
var import_editor_elements4 = require("@elementor/editor-elements");
|
|
605
605
|
var import_editor_ui2 = require("@elementor/editor-ui");
|
|
606
606
|
var import_icons4 = require("@elementor/icons");
|
|
607
|
-
var
|
|
607
|
+
var import_store11 = require("@elementor/store");
|
|
608
608
|
var import_ui5 = require("@elementor/ui");
|
|
609
609
|
var import_utils2 = require("@elementor/utils");
|
|
610
610
|
var import_i18n4 = require("@wordpress/i18n");
|
|
611
611
|
|
|
612
|
+
// src/utils/tracking.ts
|
|
613
|
+
var import_mixpanel = require("@elementor/mixpanel");
|
|
614
|
+
var import_store9 = require("@elementor/store");
|
|
615
|
+
var trackComponentEvent = ({ action, ...data }) => {
|
|
616
|
+
const { dispatchEvent, config } = (0, import_mixpanel.getMixpanel)();
|
|
617
|
+
if (!config?.names?.components?.[action]) {
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const name = config.names.components[action];
|
|
621
|
+
dispatchEvent?.(name, data);
|
|
622
|
+
};
|
|
623
|
+
var onElementDrop = (_args, element) => {
|
|
624
|
+
if (!(element.model.get("widgetType") === "e-component")) {
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const editorSettings = element.model.get("editor_settings");
|
|
628
|
+
const componentName = editorSettings?.title;
|
|
629
|
+
const componentUID = editorSettings?.component_uid;
|
|
630
|
+
const instanceId = element.id;
|
|
631
|
+
const createdThisSession = selectCreatedThisSession((0, import_store9.__getState)());
|
|
632
|
+
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
633
|
+
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
634
|
+
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
635
|
+
trackComponentEvent({
|
|
636
|
+
action: "instanceAdded",
|
|
637
|
+
instance_id: instanceId,
|
|
638
|
+
component_uid: componentUID,
|
|
639
|
+
component_name: componentName,
|
|
640
|
+
is_same_session_reuse: isSameSessionReuse,
|
|
641
|
+
location: locations.widgetPanel,
|
|
642
|
+
secondary_location: secondaryLocations.componentsTab
|
|
643
|
+
});
|
|
644
|
+
};
|
|
645
|
+
|
|
612
646
|
// src/components/create-component-form/hooks/use-form.ts
|
|
613
647
|
var import_react2 = require("react");
|
|
614
648
|
var useForm = (initialValues) => {
|
|
@@ -684,17 +718,52 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
684
718
|
});
|
|
685
719
|
};
|
|
686
720
|
|
|
721
|
+
// src/components/create-component-form/utils/get-component-event-data.ts
|
|
722
|
+
var getComponentEventData = (containerElement, options) => {
|
|
723
|
+
const { elementsCount, componentsCount } = countNestedElements(containerElement);
|
|
724
|
+
return {
|
|
725
|
+
nested_elements_count: elementsCount,
|
|
726
|
+
nested_components_count: componentsCount,
|
|
727
|
+
top_element_type: containerElement.elType,
|
|
728
|
+
location: options?.location,
|
|
729
|
+
secondary_location: options?.secondaryLocation,
|
|
730
|
+
trigger: options?.trigger
|
|
731
|
+
};
|
|
732
|
+
};
|
|
733
|
+
function countNestedElements(container) {
|
|
734
|
+
if (!container.elements || container.elements.length === 0) {
|
|
735
|
+
return { elementsCount: 0, componentsCount: 0 };
|
|
736
|
+
}
|
|
737
|
+
let elementsCount = container.elements.length;
|
|
738
|
+
let componentsCount = 0;
|
|
739
|
+
for (const element of container.elements) {
|
|
740
|
+
if (element.widgetType === "e-component") {
|
|
741
|
+
componentsCount++;
|
|
742
|
+
}
|
|
743
|
+
const { elementsCount: nestedElementsCount, componentsCount: nestedComponentsCount } = countNestedElements(element);
|
|
744
|
+
elementsCount += nestedElementsCount;
|
|
745
|
+
componentsCount += nestedComponentsCount;
|
|
746
|
+
}
|
|
747
|
+
return { elementsCount, componentsCount };
|
|
748
|
+
}
|
|
749
|
+
|
|
687
750
|
// src/components/create-component-form/create-component-form.tsx
|
|
688
751
|
function CreateComponentForm() {
|
|
689
752
|
const [element, setElement] = (0, import_react3.useState)(null);
|
|
690
753
|
const [anchorPosition, setAnchorPosition] = (0, import_react3.useState)();
|
|
691
754
|
const [resultNotification, setResultNotification] = (0, import_react3.useState)(null);
|
|
692
|
-
const dispatch5 = (0,
|
|
755
|
+
const dispatch5 = (0, import_store11.__useDispatch)();
|
|
756
|
+
const eventData = (0, import_react3.useRef)(null);
|
|
693
757
|
(0, import_react3.useEffect)(() => {
|
|
694
758
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
695
759
|
const openPopup = (event) => {
|
|
696
760
|
setElement({ element: event.detail.element, elementLabel: (0, import_editor_elements4.getElementLabel)(event.detail.element.id) });
|
|
697
761
|
setAnchorPosition(event.detail.anchorPosition);
|
|
762
|
+
eventData.current = getComponentEventData(event.detail.element, event.detail.options);
|
|
763
|
+
trackComponentEvent({
|
|
764
|
+
action: "createClicked",
|
|
765
|
+
...eventData.current
|
|
766
|
+
});
|
|
698
767
|
};
|
|
699
768
|
window.addEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
|
|
700
769
|
return () => {
|
|
@@ -711,11 +780,17 @@ function CreateComponentForm() {
|
|
|
711
780
|
slice.actions.addUnpublished({
|
|
712
781
|
uid,
|
|
713
782
|
name: values.componentName,
|
|
714
|
-
elements: [element.element
|
|
783
|
+
elements: [element.element]
|
|
715
784
|
})
|
|
716
785
|
);
|
|
717
786
|
dispatch5(slice.actions.addCreatedThisSession(uid));
|
|
718
787
|
replaceElementWithComponent(element.element, { uid, name: values.componentName });
|
|
788
|
+
trackComponentEvent({
|
|
789
|
+
action: "created",
|
|
790
|
+
component_uid: uid,
|
|
791
|
+
component_name: values.componentName,
|
|
792
|
+
...eventData.current
|
|
793
|
+
});
|
|
719
794
|
setResultNotification({
|
|
720
795
|
show: true,
|
|
721
796
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
@@ -738,6 +813,10 @@ function CreateComponentForm() {
|
|
|
738
813
|
};
|
|
739
814
|
const cancelSave = () => {
|
|
740
815
|
resetAndClosePopup();
|
|
816
|
+
trackComponentEvent({
|
|
817
|
+
action: "createCancelled",
|
|
818
|
+
...eventData.current
|
|
819
|
+
});
|
|
741
820
|
};
|
|
742
821
|
return /* @__PURE__ */ React7.createElement(import_editor_ui2.ThemeProvider, null, /* @__PURE__ */ React7.createElement(
|
|
743
822
|
import_ui5.Popover,
|
|
@@ -1125,6 +1204,7 @@ function createComponentType(options) {
|
|
|
1125
1204
|
function createComponentView(options) {
|
|
1126
1205
|
return class extends (0, import_editor_canvas4.createTemplatedElementView)(options) {
|
|
1127
1206
|
legacyWindow = window;
|
|
1207
|
+
eventsManagerConfig = this.legacyWindow.elementorCommon.eventsManager.config;
|
|
1128
1208
|
afterSettingsResolve(settings) {
|
|
1129
1209
|
if (settings.component) {
|
|
1130
1210
|
this.collection = this.legacyWindow.elementor.createBackboneElementsCollection(settings.component);
|
|
@@ -1162,7 +1242,7 @@ function createComponentView(options) {
|
|
|
1162
1242
|
icon: "eicon-edit",
|
|
1163
1243
|
title: () => (0, import_i18n7.__)("Edit Component", "elementor"),
|
|
1164
1244
|
isEnabled: () => true,
|
|
1165
|
-
callback: () => this.
|
|
1245
|
+
callback: (_, eventData) => this.editComponent(eventData)
|
|
1166
1246
|
}
|
|
1167
1247
|
]
|
|
1168
1248
|
}
|
|
@@ -1184,9 +1264,26 @@ function createComponentView(options) {
|
|
|
1184
1264
|
});
|
|
1185
1265
|
}
|
|
1186
1266
|
}
|
|
1267
|
+
editComponent({ trigger, location, secondaryLocation }) {
|
|
1268
|
+
this.switchDocument();
|
|
1269
|
+
const editorSettings = this.model.get("editor_settings");
|
|
1270
|
+
trackComponentEvent({
|
|
1271
|
+
action: "edited",
|
|
1272
|
+
component_uid: editorSettings?.component_uid,
|
|
1273
|
+
component_name: editorSettings?.title,
|
|
1274
|
+
location,
|
|
1275
|
+
secondary_location: secondaryLocation,
|
|
1276
|
+
trigger
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1187
1279
|
handleDblClick(e) {
|
|
1188
1280
|
e.stopPropagation();
|
|
1189
|
-
this.
|
|
1281
|
+
const { triggers, locations, secondaryLocations } = this.eventsManagerConfig;
|
|
1282
|
+
this.editComponent({
|
|
1283
|
+
trigger: triggers.doubleClick,
|
|
1284
|
+
location: locations.canvas,
|
|
1285
|
+
secondaryLocation: secondaryLocations.canvasElement
|
|
1286
|
+
});
|
|
1190
1287
|
}
|
|
1191
1288
|
events() {
|
|
1192
1289
|
return {
|
|
@@ -1217,21 +1314,21 @@ function setInactiveRecursively(model) {
|
|
|
1217
1314
|
|
|
1218
1315
|
// src/populate-store.ts
|
|
1219
1316
|
var import_react7 = require("react");
|
|
1220
|
-
var
|
|
1317
|
+
var import_store13 = require("@elementor/store");
|
|
1221
1318
|
function PopulateStore() {
|
|
1222
1319
|
(0, import_react7.useEffect)(() => {
|
|
1223
|
-
(0,
|
|
1320
|
+
(0, import_store13.__dispatch)(loadComponents());
|
|
1224
1321
|
}, []);
|
|
1225
1322
|
return null;
|
|
1226
1323
|
}
|
|
1227
1324
|
|
|
1228
1325
|
// src/store/components-styles-provider.ts
|
|
1229
1326
|
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
1230
|
-
var
|
|
1327
|
+
var import_store14 = require("@elementor/store");
|
|
1231
1328
|
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
1232
1329
|
key: "components-styles",
|
|
1233
1330
|
priority: 100,
|
|
1234
|
-
subscribe: (cb) => (0,
|
|
1331
|
+
subscribe: (cb) => (0, import_store14.__subscribeWithSelector)(
|
|
1235
1332
|
(state) => state[SLICE_NAME],
|
|
1236
1333
|
() => {
|
|
1237
1334
|
cb();
|
|
@@ -1239,29 +1336,29 @@ var componentsStylesProvider = (0, import_editor_styles_repository.createStylesP
|
|
|
1239
1336
|
),
|
|
1240
1337
|
actions: {
|
|
1241
1338
|
all: () => {
|
|
1242
|
-
return selectFlatStyles((0,
|
|
1339
|
+
return selectFlatStyles((0, import_store14.__getState)());
|
|
1243
1340
|
},
|
|
1244
1341
|
get: (id) => {
|
|
1245
|
-
return selectFlatStyles((0,
|
|
1342
|
+
return selectFlatStyles((0, import_store14.__getState)()).find((style) => style.id === id) ?? null;
|
|
1246
1343
|
}
|
|
1247
1344
|
}
|
|
1248
1345
|
});
|
|
1249
1346
|
|
|
1250
1347
|
// src/store/remove-component-styles.ts
|
|
1251
|
-
var
|
|
1348
|
+
var import_store16 = require("@elementor/store");
|
|
1252
1349
|
function removeComponentStyles(id) {
|
|
1253
1350
|
apiClient.invalidateComponentConfigCache(id);
|
|
1254
|
-
(0,
|
|
1351
|
+
(0, import_store16.__dispatch)(slice.actions.removeStyles({ id }));
|
|
1255
1352
|
}
|
|
1256
1353
|
|
|
1257
1354
|
// src/sync/create-components-before-save.ts
|
|
1258
1355
|
var import_editor_elements5 = require("@elementor/editor-elements");
|
|
1259
|
-
var
|
|
1356
|
+
var import_store18 = require("@elementor/store");
|
|
1260
1357
|
async function createComponentsBeforeSave({
|
|
1261
1358
|
container,
|
|
1262
1359
|
status
|
|
1263
1360
|
}) {
|
|
1264
|
-
const unpublishedComponents = selectUnpublishedComponents((0,
|
|
1361
|
+
const unpublishedComponents = selectUnpublishedComponents((0, import_store18.__getState)());
|
|
1265
1362
|
if (!unpublishedComponents.length) {
|
|
1266
1363
|
return;
|
|
1267
1364
|
}
|
|
@@ -1269,7 +1366,7 @@ async function createComponentsBeforeSave({
|
|
|
1269
1366
|
const uidToComponentId = await createComponents(unpublishedComponents, status);
|
|
1270
1367
|
const elements = container.model.get("elements").toJSON();
|
|
1271
1368
|
updateComponentInstances(elements, uidToComponentId);
|
|
1272
|
-
(0,
|
|
1369
|
+
(0, import_store18.__dispatch)(
|
|
1273
1370
|
slice.actions.add(
|
|
1274
1371
|
unpublishedComponents.map((component) => ({
|
|
1275
1372
|
id: uidToComponentId.get(component.uid),
|
|
@@ -1278,7 +1375,7 @@ async function createComponentsBeforeSave({
|
|
|
1278
1375
|
}))
|
|
1279
1376
|
)
|
|
1280
1377
|
);
|
|
1281
|
-
(0,
|
|
1378
|
+
(0, import_store18.__dispatch)(slice.actions.resetUnpublished());
|
|
1282
1379
|
} catch (error) {
|
|
1283
1380
|
throw new Error(`Failed to publish components and update component instances: ${error}`);
|
|
1284
1381
|
}
|
|
@@ -1364,7 +1461,7 @@ var beforeSave = ({ container, status }) => {
|
|
|
1364
1461
|
var COMPONENT_DOCUMENT_TYPE2 = "elementor_component";
|
|
1365
1462
|
function init() {
|
|
1366
1463
|
import_editor_styles_repository2.stylesRepository.register(componentsStylesProvider);
|
|
1367
|
-
(0,
|
|
1464
|
+
(0, import_store20.__registerSlice)(slice);
|
|
1368
1465
|
(0, import_editor_canvas5.registerElementType)(
|
|
1369
1466
|
TYPE,
|
|
1370
1467
|
(options) => createComponentType({ ...options, showLockedByModal: openEditModeDialog })
|
|
@@ -1376,6 +1473,7 @@ function init() {
|
|
|
1376
1473
|
}
|
|
1377
1474
|
return true;
|
|
1378
1475
|
});
|
|
1476
|
+
(0, import_editor_v1_adapters5.registerDataHook)("after", "preview/drop", onElementDrop);
|
|
1379
1477
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
1380
1478
|
(0, import_editor_elements_panel.injectTab)({
|
|
1381
1479
|
id: "components",
|