@elementor/editor-components 3.35.0-419 → 3.35.0-420

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.mjs CHANGED
@@ -2203,8 +2203,8 @@ function getSelectedElementContainer() {
2203
2203
 
2204
2204
  // src/components/create-component-form/utils/replace-element-with-component.ts
2205
2205
  import { replaceElement } from "@elementor/editor-elements";
2206
- var replaceElementWithComponent = (element, component) => {
2207
- replaceElement({
2206
+ var replaceElementWithComponent = async (element, component) => {
2207
+ return await replaceElement({
2208
2208
  currentElement: element,
2209
2209
  newElement: createComponentModel2(component),
2210
2210
  withHistory: false
@@ -2567,6 +2567,7 @@ import { getElementLabel } from "@elementor/editor-elements";
2567
2567
  import { notify as notify2 } from "@elementor/editor-notifications";
2568
2568
  import { Form as FormElement, ThemeProvider as ThemeProvider3 } from "@elementor/editor-ui";
2569
2569
  import { StarIcon } from "@elementor/icons";
2570
+ import { __getState as getState15 } from "@elementor/store";
2570
2571
  import { Alert as Alert2, Button as Button3, FormLabel as FormLabel2, Grid as Grid2, Popover as Popover3, Snackbar, Stack as Stack11, TextField as TextField3, Typography as Typography9 } from "@elementor/ui";
2571
2572
  import { __ as __18 } from "@wordpress/i18n";
2572
2573
 
@@ -2688,7 +2689,7 @@ function findNonAtomicElementsInElement(element) {
2688
2689
  import { __privateRunCommand as runCommand3 } from "@elementor/editor-v1-adapters";
2689
2690
  import { __dispatch as dispatch11 } from "@elementor/store";
2690
2691
  import { generateUniqueId as generateUniqueId3 } from "@elementor/utils";
2691
- function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
2692
+ async function createUnpublishedComponent(name, element, eventData, overridableProps, uid) {
2692
2693
  const generatedUid = uid ?? generateUniqueId3("component");
2693
2694
  const componentBase = { uid: generatedUid, name, overridableProps };
2694
2695
  dispatch11(
@@ -2698,15 +2699,15 @@ function createUnpublishedComponent(name, element, eventData, overridableProps,
2698
2699
  })
2699
2700
  );
2700
2701
  dispatch11(slice.actions.addCreatedThisSession(generatedUid));
2701
- replaceElementWithComponent(element, componentBase);
2702
+ const componentInstance = await replaceElementWithComponent(element, componentBase);
2702
2703
  trackComponentEvent({
2703
2704
  action: "created",
2704
2705
  component_uid: generatedUid,
2705
2706
  component_name: name,
2706
2707
  ...eventData
2707
2708
  });
2708
- runCommand3("document/save/auto");
2709
- return generatedUid;
2709
+ await runCommand3("document/save/auto");
2710
+ return { uid: generatedUid, instanceId: componentInstance.id };
2710
2711
  }
2711
2712
 
2712
2713
  // src/components/create-component-form/hooks/use-form.ts
@@ -2821,12 +2822,22 @@ function CreateComponentForm() {
2821
2822
  window.removeEventListener(OPEN_SAVE_AS_COMPONENT_FORM_EVENT, openPopup);
2822
2823
  };
2823
2824
  }, []);
2824
- const handleSave = (values) => {
2825
+ const handleSave = async (values) => {
2825
2826
  try {
2826
2827
  if (!element) {
2827
2828
  throw new Error(`Can't save element as component: element not found`);
2828
2829
  }
2829
- const uid = createUnpublishedComponent(values.componentName, element.element, eventData.current);
2830
+ const { uid, instanceId } = await createUnpublishedComponent(
2831
+ values.componentName,
2832
+ element.element,
2833
+ eventData.current
2834
+ );
2835
+ const publishedComponentId = selectComponentByUid(getState15(), uid)?.id;
2836
+ if (publishedComponentId) {
2837
+ switchToComponent(publishedComponentId, instanceId);
2838
+ } else {
2839
+ throw new Error("Failed to find published component");
2840
+ }
2830
2841
  setResultNotification({
2831
2842
  show: true,
2832
2843
  // Translators: %1$s: Component name, %2$s: Component UID
@@ -3386,9 +3397,9 @@ function getControlsByBind(controls) {
3386
3397
  }
3387
3398
 
3388
3399
  // src/store/actions/update-overridable-prop.ts
3389
- import { __dispatch as dispatch12, __getState as getState15 } from "@elementor/store";
3400
+ import { __dispatch as dispatch12, __getState as getState16 } from "@elementor/store";
3390
3401
  function updateOverridableProp(componentId, propValue, originPropFields) {
3391
- const overridableProps = selectOverridableProps(getState15(), componentId);
3402
+ const overridableProps = selectOverridableProps(getState16(), componentId);
3392
3403
  if (!overridableProps) {
3393
3404
  return;
3394
3405
  }
@@ -3700,7 +3711,7 @@ import { bindPopover as bindPopover2, bindTrigger as bindTrigger4, Popover as Po
3700
3711
  import { __ as __24 } from "@wordpress/i18n";
3701
3712
 
3702
3713
  // src/store/actions/set-overridable-prop.ts
3703
- import { __dispatch as dispatch13, __getState as getState16 } from "@elementor/store";
3714
+ import { __dispatch as dispatch13, __getState as getState17 } from "@elementor/store";
3704
3715
  import { generateUniqueId as generateUniqueId4 } from "@elementor/utils";
3705
3716
  function setOverridableProp({
3706
3717
  componentId,
@@ -3714,7 +3725,7 @@ function setOverridableProp({
3714
3725
  originValue,
3715
3726
  originPropFields
3716
3727
  }) {
3717
- const overridableProps = selectOverridableProps(getState16(), componentId);
3728
+ const overridableProps = selectOverridableProps(getState17(), componentId);
3718
3729
  if (!overridableProps) {
3719
3730
  return;
3720
3731
  }
@@ -3834,12 +3845,12 @@ var Indicator2 = forwardRef2(({ isOpen, isOverridable, ...props }, ref) => /* @_
3834
3845
  )));
3835
3846
 
3836
3847
  // src/components/overridable-props/utils/get-overridable-prop.ts
3837
- import { __getState as getState17 } from "@elementor/store";
3848
+ import { __getState as getState18 } from "@elementor/store";
3838
3849
  function getOverridableProp({
3839
3850
  componentId,
3840
3851
  overrideKey
3841
3852
  }) {
3842
- const overridableProps = selectOverridableProps(getState17(), componentId);
3853
+ const overridableProps = selectOverridableProps(getState18(), componentId);
3843
3854
  if (!overridableProps) {
3844
3855
  return void 0;
3845
3856
  }
@@ -4361,7 +4372,7 @@ function PopulateStore() {
4361
4372
  import { getAllDescendants as getAllDescendants3 } from "@elementor/editor-elements";
4362
4373
  import { notify as notify3 } from "@elementor/editor-notifications";
4363
4374
  import { blockCommand as blockCommand2 } from "@elementor/editor-v1-adapters";
4364
- import { __getState as getState18 } from "@elementor/store";
4375
+ import { __getState as getState19 } from "@elementor/store";
4365
4376
  import { __ as __25 } from "@wordpress/i18n";
4366
4377
  var COMPONENT_TYPE = "e-component";
4367
4378
  var COMPONENT_CIRCULAR_NESTING_ALERT = {
@@ -4387,7 +4398,7 @@ function wouldCreateCircularNesting(componentIdToAdd) {
4387
4398
  if (componentIdToAdd === void 0) {
4388
4399
  return false;
4389
4400
  }
4390
- const state = getState18();
4401
+ const state = getState19();
4391
4402
  const currentComponentId = selectCurrentComponentId(state);
4392
4403
  const path = selectPath(state);
4393
4404
  if (currentComponentId === null) {
@@ -4493,7 +4504,7 @@ function removeComponentStyles(id2) {
4493
4504
 
4494
4505
  // src/store/components-styles-provider.ts
4495
4506
  import { createStylesProvider } from "@elementor/editor-styles-repository";
4496
- import { __getState as getState19, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
4507
+ import { __getState as getState20, __subscribeWithSelector as subscribeWithSelector } from "@elementor/store";
4497
4508
  var componentsStylesProvider = createStylesProvider({
4498
4509
  key: "components-styles",
4499
4510
  priority: 100,
@@ -4505,22 +4516,22 @@ var componentsStylesProvider = createStylesProvider({
4505
4516
  ),
4506
4517
  actions: {
4507
4518
  all: () => {
4508
- return selectFlatStyles(getState19());
4519
+ return selectFlatStyles(getState20());
4509
4520
  },
4510
4521
  get: (id2) => {
4511
- return selectFlatStyles(getState19()).find((style) => style.id === id2) ?? null;
4522
+ return selectFlatStyles(getState20()).find((style) => style.id === id2) ?? null;
4512
4523
  }
4513
4524
  }
4514
4525
  });
4515
4526
 
4516
4527
  // src/sync/create-components-before-save.ts
4517
4528
  import { updateElementSettings as updateElementSettings3 } from "@elementor/editor-elements";
4518
- import { __dispatch as dispatch16, __getState as getState20 } from "@elementor/store";
4529
+ import { __dispatch as dispatch16, __getState as getState21 } from "@elementor/store";
4519
4530
  async function createComponentsBeforeSave({
4520
4531
  elements,
4521
4532
  status
4522
4533
  }) {
4523
- const unpublishedComponents = selectUnpublishedComponents(getState20());
4534
+ const unpublishedComponents = selectUnpublishedComponents(getState21());
4524
4535
  if (!unpublishedComponents.length) {
4525
4536
  return;
4526
4537
  }
@@ -4597,7 +4608,7 @@ function updateElementComponentId(elementId, componentId) {
4597
4608
  }
4598
4609
 
4599
4610
  // src/sync/set-component-overridable-props-settings-before-save.ts
4600
- import { __getState as getState21 } from "@elementor/store";
4611
+ import { __getState as getState22 } from "@elementor/store";
4601
4612
  var setComponentOverridablePropsSettingsBeforeSave = ({
4602
4613
  container
4603
4614
  }) => {
@@ -4605,7 +4616,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
4605
4616
  if (!currentDocument || currentDocument.config.type !== COMPONENT_DOCUMENT_TYPE) {
4606
4617
  return;
4607
4618
  }
4608
- const overridableProps = selectOverridableProps(getState21(), currentDocument.id);
4619
+ const overridableProps = selectOverridableProps(getState22(), currentDocument.id);
4609
4620
  if (overridableProps) {
4610
4621
  container.settings.set("overridable_props", overridableProps);
4611
4622
  }
@@ -4613,7 +4624,7 @@ var setComponentOverridablePropsSettingsBeforeSave = ({
4613
4624
 
4614
4625
  // src/sync/update-archived-component-before-save.ts
4615
4626
  import { notify as notify4 } from "@elementor/editor-notifications";
4616
- import { __getState as getState22 } from "@elementor/store";
4627
+ import { __getState as getState23 } from "@elementor/store";
4617
4628
  var failedNotification = (message) => ({
4618
4629
  type: "error",
4619
4630
  message: `Failed to archive components: ${message}`,
@@ -4626,7 +4637,7 @@ var successNotification = (message) => ({
4626
4637
  });
4627
4638
  var updateArchivedComponentBeforeSave = async () => {
4628
4639
  try {
4629
- const archivedComponents = selectArchivedComponents(getState22());
4640
+ const archivedComponents = selectArchivedComponents(getState23());
4630
4641
  if (!archivedComponents.length) {
4631
4642
  return;
4632
4643
  }
@@ -4647,9 +4658,9 @@ var updateArchivedComponentBeforeSave = async () => {
4647
4658
  };
4648
4659
 
4649
4660
  // src/sync/update-component-title-before-save.ts
4650
- import { __dispatch as dispatch17, __getState as getState23 } from "@elementor/store";
4661
+ import { __dispatch as dispatch17, __getState as getState24 } from "@elementor/store";
4651
4662
  var updateComponentTitleBeforeSave = async () => {
4652
- const updatedComponentNames = selectUpdatedComponentNames(getState23());
4663
+ const updatedComponentNames = selectUpdatedComponentNames(getState24());
4653
4664
  if (!updatedComponentNames.length) {
4654
4665
  return;
4655
4666
  }