@elementor/editor-components 3.33.0-261 → 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.mjs
CHANGED
|
@@ -574,7 +574,7 @@ var Components = () => {
|
|
|
574
574
|
|
|
575
575
|
// src/components/create-component-form/create-component-form.tsx
|
|
576
576
|
import * as React7 from "react";
|
|
577
|
-
import { useEffect, useMemo as useMemo2, useState as useState2 } from "react";
|
|
577
|
+
import { useEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
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";
|
|
@@ -583,6 +583,40 @@ import { Alert, Button, FormLabel, Grid, Popover, Snackbar, Stack as Stack4, Tex
|
|
|
583
583
|
import { generateUniqueId } from "@elementor/utils";
|
|
584
584
|
import { __ as __4 } from "@wordpress/i18n";
|
|
585
585
|
|
|
586
|
+
// src/utils/tracking.ts
|
|
587
|
+
import { getMixpanel } from "@elementor/mixpanel";
|
|
588
|
+
import { __getState as getState3 } from "@elementor/store";
|
|
589
|
+
var trackComponentEvent = ({ action, ...data }) => {
|
|
590
|
+
const { dispatchEvent, config } = getMixpanel();
|
|
591
|
+
if (!config?.names?.components?.[action]) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
const name = config.names.components[action];
|
|
595
|
+
dispatchEvent?.(name, data);
|
|
596
|
+
};
|
|
597
|
+
var onElementDrop = (_args, element) => {
|
|
598
|
+
if (!(element.model.get("widgetType") === "e-component")) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
const editorSettings = element.model.get("editor_settings");
|
|
602
|
+
const componentName = editorSettings?.title;
|
|
603
|
+
const componentUID = editorSettings?.component_uid;
|
|
604
|
+
const instanceId = element.id;
|
|
605
|
+
const createdThisSession = selectCreatedThisSession(getState3());
|
|
606
|
+
const isSameSessionReuse = componentUID && createdThisSession.includes(componentUID);
|
|
607
|
+
const eventsManagerConfig = window.elementorCommon.eventsManager.config;
|
|
608
|
+
const { locations, secondaryLocations } = eventsManagerConfig;
|
|
609
|
+
trackComponentEvent({
|
|
610
|
+
action: "instanceAdded",
|
|
611
|
+
instance_id: instanceId,
|
|
612
|
+
component_uid: componentUID,
|
|
613
|
+
component_name: componentName,
|
|
614
|
+
is_same_session_reuse: isSameSessionReuse,
|
|
615
|
+
location: locations.widgetPanel,
|
|
616
|
+
secondary_location: secondaryLocations.componentsTab
|
|
617
|
+
});
|
|
618
|
+
};
|
|
619
|
+
|
|
586
620
|
// src/components/create-component-form/hooks/use-form.ts
|
|
587
621
|
import { useMemo, useState } from "react";
|
|
588
622
|
var useForm = (initialValues) => {
|
|
@@ -658,17 +692,52 @@ var createSubmitComponentSchema = (existingNames) => {
|
|
|
658
692
|
});
|
|
659
693
|
};
|
|
660
694
|
|
|
695
|
+
// src/components/create-component-form/utils/get-component-event-data.ts
|
|
696
|
+
var getComponentEventData = (containerElement, options) => {
|
|
697
|
+
const { elementsCount, componentsCount } = countNestedElements(containerElement);
|
|
698
|
+
return {
|
|
699
|
+
nested_elements_count: elementsCount,
|
|
700
|
+
nested_components_count: componentsCount,
|
|
701
|
+
top_element_type: containerElement.elType,
|
|
702
|
+
location: options?.location,
|
|
703
|
+
secondary_location: options?.secondaryLocation,
|
|
704
|
+
trigger: options?.trigger
|
|
705
|
+
};
|
|
706
|
+
};
|
|
707
|
+
function countNestedElements(container) {
|
|
708
|
+
if (!container.elements || container.elements.length === 0) {
|
|
709
|
+
return { elementsCount: 0, componentsCount: 0 };
|
|
710
|
+
}
|
|
711
|
+
let elementsCount = container.elements.length;
|
|
712
|
+
let componentsCount = 0;
|
|
713
|
+
for (const element of container.elements) {
|
|
714
|
+
if (element.widgetType === "e-component") {
|
|
715
|
+
componentsCount++;
|
|
716
|
+
}
|
|
717
|
+
const { elementsCount: nestedElementsCount, componentsCount: nestedComponentsCount } = countNestedElements(element);
|
|
718
|
+
elementsCount += nestedElementsCount;
|
|
719
|
+
componentsCount += nestedComponentsCount;
|
|
720
|
+
}
|
|
721
|
+
return { elementsCount, componentsCount };
|
|
722
|
+
}
|
|
723
|
+
|
|
661
724
|
// src/components/create-component-form/create-component-form.tsx
|
|
662
725
|
function CreateComponentForm() {
|
|
663
726
|
const [element, setElement] = useState2(null);
|
|
664
727
|
const [anchorPosition, setAnchorPosition] = useState2();
|
|
665
728
|
const [resultNotification, setResultNotification] = useState2(null);
|
|
666
729
|
const dispatch5 = useDispatch();
|
|
730
|
+
const eventData = useRef(null);
|
|
667
731
|
useEffect(() => {
|
|
668
732
|
const OPEN_SAVE_AS_COMPONENT_FORM_EVENT = "elementor/editor/open-save-as-component-form";
|
|
669
733
|
const openPopup = (event) => {
|
|
670
734
|
setElement({ element: event.detail.element, elementLabel: getElementLabel(event.detail.element.id) });
|
|
671
735
|
setAnchorPosition(event.detail.anchorPosition);
|
|
736
|
+
eventData.current = getComponentEventData(event.detail.element, event.detail.options);
|
|
737
|
+
trackComponentEvent({
|
|
738
|
+
action: "createClicked",
|
|
739
|
+
...eventData.current
|
|
740
|
+
});
|
|
672
741
|
};
|
|
673
742
|
window.addEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
|
|
674
743
|
return () => {
|
|
@@ -685,11 +754,17 @@ function CreateComponentForm() {
|
|
|
685
754
|
slice.actions.addUnpublished({
|
|
686
755
|
uid,
|
|
687
756
|
name: values.componentName,
|
|
688
|
-
elements: [element.element
|
|
757
|
+
elements: [element.element]
|
|
689
758
|
})
|
|
690
759
|
);
|
|
691
760
|
dispatch5(slice.actions.addCreatedThisSession(uid));
|
|
692
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
|
+
});
|
|
693
768
|
setResultNotification({
|
|
694
769
|
show: true,
|
|
695
770
|
// Translators: %1$s: Component name, %2$s: Component UID
|
|
@@ -712,6 +787,10 @@ function CreateComponentForm() {
|
|
|
712
787
|
};
|
|
713
788
|
const cancelSave = () => {
|
|
714
789
|
resetAndClosePopup();
|
|
790
|
+
trackComponentEvent({
|
|
791
|
+
action: "createCancelled",
|
|
792
|
+
...eventData.current
|
|
793
|
+
});
|
|
715
794
|
};
|
|
716
795
|
return /* @__PURE__ */ React7.createElement(ThemeProvider2, null, /* @__PURE__ */ React7.createElement(
|
|
717
796
|
Popover,
|
|
@@ -1105,6 +1184,7 @@ function createComponentType(options) {
|
|
|
1105
1184
|
function createComponentView(options) {
|
|
1106
1185
|
return class extends createTemplatedElementView(options) {
|
|
1107
1186
|
legacyWindow = window;
|
|
1187
|
+
eventsManagerConfig = this.legacyWindow.elementorCommon.eventsManager.config;
|
|
1108
1188
|
afterSettingsResolve(settings) {
|
|
1109
1189
|
if (settings.component) {
|
|
1110
1190
|
this.collection = this.legacyWindow.elementor.createBackboneElementsCollection(settings.component);
|
|
@@ -1142,7 +1222,7 @@ function createComponentView(options) {
|
|
|
1142
1222
|
icon: "eicon-edit",
|
|
1143
1223
|
title: () => __7("Edit Component", "elementor"),
|
|
1144
1224
|
isEnabled: () => true,
|
|
1145
|
-
callback: () => this.
|
|
1225
|
+
callback: (_, eventData) => this.editComponent(eventData)
|
|
1146
1226
|
}
|
|
1147
1227
|
]
|
|
1148
1228
|
}
|
|
@@ -1164,9 +1244,26 @@ function createComponentView(options) {
|
|
|
1164
1244
|
});
|
|
1165
1245
|
}
|
|
1166
1246
|
}
|
|
1247
|
+
editComponent({ trigger, location, secondaryLocation }) {
|
|
1248
|
+
this.switchDocument();
|
|
1249
|
+
const editorSettings = this.model.get("editor_settings");
|
|
1250
|
+
trackComponentEvent({
|
|
1251
|
+
action: "edited",
|
|
1252
|
+
component_uid: editorSettings?.component_uid,
|
|
1253
|
+
component_name: editorSettings?.title,
|
|
1254
|
+
location,
|
|
1255
|
+
secondary_location: secondaryLocation,
|
|
1256
|
+
trigger
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1167
1259
|
handleDblClick(e) {
|
|
1168
1260
|
e.stopPropagation();
|
|
1169
|
-
this.
|
|
1261
|
+
const { triggers, locations, secondaryLocations } = this.eventsManagerConfig;
|
|
1262
|
+
this.editComponent({
|
|
1263
|
+
trigger: triggers.doubleClick,
|
|
1264
|
+
location: locations.canvas,
|
|
1265
|
+
secondaryLocation: secondaryLocations.canvasElement
|
|
1266
|
+
});
|
|
1170
1267
|
}
|
|
1171
1268
|
events() {
|
|
1172
1269
|
return {
|
|
@@ -1207,7 +1304,7 @@ function PopulateStore() {
|
|
|
1207
1304
|
|
|
1208
1305
|
// src/store/components-styles-provider.ts
|
|
1209
1306
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
1210
|
-
import { __getState as
|
|
1307
|
+
import { __getState as getState4, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
|
|
1211
1308
|
var componentsStylesProvider = createStylesProvider({
|
|
1212
1309
|
key: "components-styles",
|
|
1213
1310
|
priority: 100,
|
|
@@ -1219,10 +1316,10 @@ var componentsStylesProvider = createStylesProvider({
|
|
|
1219
1316
|
),
|
|
1220
1317
|
actions: {
|
|
1221
1318
|
all: () => {
|
|
1222
|
-
return selectFlatStyles(
|
|
1319
|
+
return selectFlatStyles(getState4());
|
|
1223
1320
|
},
|
|
1224
1321
|
get: (id) => {
|
|
1225
|
-
return selectFlatStyles(
|
|
1322
|
+
return selectFlatStyles(getState4()).find((style) => style.id === id) ?? null;
|
|
1226
1323
|
}
|
|
1227
1324
|
}
|
|
1228
1325
|
});
|
|
@@ -1236,12 +1333,12 @@ function removeComponentStyles(id) {
|
|
|
1236
1333
|
|
|
1237
1334
|
// src/sync/create-components-before-save.ts
|
|
1238
1335
|
import { updateElementSettings } from "@elementor/editor-elements";
|
|
1239
|
-
import { __dispatch as dispatch4, __getState as
|
|
1336
|
+
import { __dispatch as dispatch4, __getState as getState5 } from "@elementor/store";
|
|
1240
1337
|
async function createComponentsBeforeSave({
|
|
1241
1338
|
container,
|
|
1242
1339
|
status
|
|
1243
1340
|
}) {
|
|
1244
|
-
const unpublishedComponents = selectUnpublishedComponents(
|
|
1341
|
+
const unpublishedComponents = selectUnpublishedComponents(getState5());
|
|
1245
1342
|
if (!unpublishedComponents.length) {
|
|
1246
1343
|
return;
|
|
1247
1344
|
}
|
|
@@ -1356,6 +1453,7 @@ function init() {
|
|
|
1356
1453
|
}
|
|
1357
1454
|
return true;
|
|
1358
1455
|
});
|
|
1456
|
+
registerDataHook("after", "preview/drop", onElementDrop);
|
|
1359
1457
|
window.elementorCommon.__beforeSave = beforeSave;
|
|
1360
1458
|
injectTab({
|
|
1361
1459
|
id: "components",
|