@elementor/editor-site-navigation 0.19.10 → 0.19.11

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 CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.19.11](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.10...@elementor/editor-site-navigation@0.19.11) (2024-01-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **editor-site-navigation:** fix state between title on pages panel and recent pages [ED-13273] ([#151](https://github.com/elementor/elementor-packages/issues/151)) ([dd9aeff](https://github.com/elementor/elementor-packages/commit/dd9aeff9adebef5322c43c12f7f7bd48269a7885))
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.19.10](https://github.com/elementor/elementor-packages/compare/@elementor/editor-site-navigation@0.19.9...@elementor/editor-site-navigation@0.19.10) (2024-01-02)
7
18
 
8
19
 
package/dist/index.js CHANGED
@@ -249,14 +249,7 @@ function RecentlyEdited() {
249
249
  variant: "popover",
250
250
  popupId: "elementor-v2-top-bar-recently-edited"
251
251
  });
252
- const getCurrentDocumentFromRecentPosts = () => {
253
- if (!document2) {
254
- return null;
255
- }
256
- return data?.find((post) => post.id === document2.id);
257
- };
258
- const currentDocumentFromRecentPosts = getCurrentDocumentFromRecentPosts();
259
- const documentTitle = useReverseHtmlEntities(currentDocumentFromRecentPosts ? currentDocumentFromRecentPosts.title : document2?.title);
252
+ const documentTitle = useReverseHtmlEntities(document2?.title);
260
253
  if (!document2) {
261
254
  return null;
262
255
  }
@@ -605,37 +598,68 @@ function CloseButton({ isLoading, closeButton }) {
605
598
  );
606
599
  }
607
600
 
601
+ // src/components/panel/posts-list/list-items/list-item-rename.tsx
602
+ var import_editor_documents4 = require("@elementor/editor-documents");
603
+
604
+ // src/hooks/use-rename-active-document.ts
605
+ var import_editor_v1_adapters = require("@elementor/editor-v1-adapters");
606
+ function getV1DocumentsManager() {
607
+ const documentsManager = window.elementor?.documents;
608
+ if (!documentsManager) {
609
+ throw new Error("Elementor Editor V1 documents manager not found");
610
+ }
611
+ return documentsManager;
612
+ }
613
+ function useRenameActiveDocument() {
614
+ return async (title) => {
615
+ const currentDocument = getV1DocumentsManager().getCurrent();
616
+ const container = currentDocument.container;
617
+ await (0, import_editor_v1_adapters.__privateRunCommand)("document/elements/settings", {
618
+ container,
619
+ settings: { post_title: title }
620
+ });
621
+ };
622
+ }
623
+
608
624
  // src/components/panel/posts-list/list-items/list-item-rename.tsx
609
625
  function ListItemRename({ post }) {
610
626
  const { type, resetEditMode } = usePostListContext();
611
627
  const { updatePost } = usePostActions(type);
612
628
  const { setError } = usePostListContext();
629
+ const activeDocument = (0, import_editor_documents4.__useActiveDocument)();
630
+ const rename = useRenameActiveDocument();
631
+ const isActive = activeDocument?.id === post.id;
632
+ const title = isActive ? activeDocument?.title : post.title.rendered;
613
633
  const renamePostCallback = async (inputValue) => {
614
- if (inputValue === post.title.rendered) {
634
+ if (inputValue === title) {
615
635
  resetEditMode();
616
636
  }
617
637
  try {
618
- await updatePost.mutateAsync({
619
- id: post.id,
620
- title: inputValue
621
- });
638
+ if (isActive) {
639
+ await rename(inputValue);
640
+ } else {
641
+ await updatePost.mutateAsync({
642
+ id: post.id,
643
+ title: inputValue
644
+ });
645
+ }
622
646
  } catch (e) {
623
647
  setError();
624
648
  } finally {
625
649
  resetEditMode();
626
650
  }
627
651
  };
628
- return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.isPending, callback: renamePostCallback });
652
+ return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: title, isLoading: updatePost.isPending, callback: renamePostCallback });
629
653
  }
630
654
 
631
655
  // src/components/panel/posts-list/list-items/list-item-create.tsx
632
656
  var React10 = __toESM(require("react"));
633
657
  var import_i18n5 = require("@wordpress/i18n");
634
- var import_editor_documents4 = require("@elementor/editor-documents");
658
+ var import_editor_documents5 = require("@elementor/editor-documents");
635
659
  function ListItemCreate() {
636
660
  const { type, resetEditMode } = usePostListContext();
637
661
  const { createPost } = usePostActions(type);
638
- const navigateToDocument = (0, import_editor_documents4.__useNavigateToDocument)();
662
+ const navigateToDocument = (0, import_editor_documents5.__useNavigateToDocument)();
639
663
  const { setError } = usePostListContext();
640
664
  const createPostCallback = async (inputValue) => {
641
665
  try {
@@ -656,10 +680,10 @@ function ListItemCreate() {
656
680
  // src/components/panel/posts-list/list-items/list-item-duplicate.tsx
657
681
  var React11 = __toESM(require("react"));
658
682
  var import_i18n6 = require("@wordpress/i18n");
659
- var import_editor_documents5 = require("@elementor/editor-documents");
683
+ var import_editor_documents6 = require("@elementor/editor-documents");
660
684
  function ListItemDuplicate() {
661
685
  const { type, editMode, resetEditMode } = usePostListContext();
662
- const navigateToDocument = (0, import_editor_documents5.__useNavigateToDocument)();
686
+ const navigateToDocument = (0, import_editor_documents6.__useNavigateToDocument)();
663
687
  const { duplicatePost } = usePostActions(type);
664
688
  const { setError } = usePostListContext();
665
689
  if ("duplicate" !== editMode.mode) {
@@ -685,7 +709,7 @@ function ListItemDuplicate() {
685
709
  var React19 = __toESM(require("react"));
686
710
  var import_ui12 = require("@elementor/ui");
687
711
  var import_icons12 = require("@elementor/icons");
688
- var import_editor_documents7 = require("@elementor/editor-documents");
712
+ var import_editor_documents8 = require("@elementor/editor-documents");
689
713
 
690
714
  // src/components/shared/page-title-and-status.tsx
691
715
  var React12 = __toESM(require("react"));
@@ -728,8 +752,8 @@ var PageTitle = ({ title }) => {
728
752
  modifiedTitle
729
753
  );
730
754
  };
731
- function PageTitleAndStatus({ page }) {
732
- return /* @__PURE__ */ React12.createElement(import_ui8.Box, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title: page.title.rendered }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status: page.status }));
755
+ function PageTitleAndStatus({ title, status }) {
756
+ return /* @__PURE__ */ React12.createElement(import_ui8.Box, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status }));
733
757
  }
734
758
 
735
759
  // src/components/panel/actions-menu/actions/rename.tsx
@@ -802,10 +826,10 @@ var import_icons9 = require("@elementor/icons");
802
826
  var import_i18n9 = require("@wordpress/i18n");
803
827
  var import_ui10 = require("@elementor/ui");
804
828
  var import_react6 = require("react");
805
- var import_editor_documents6 = require("@elementor/editor-documents");
829
+ var import_editor_documents7 = require("@elementor/editor-documents");
806
830
  function Delete({ post }) {
807
831
  const [isDialogOpen, setIsDialogOpen] = (0, import_react6.useState)(false);
808
- const activeDocument = (0, import_editor_documents6.__useActiveDocument)();
832
+ const activeDocument = (0, import_editor_documents7.__useActiveDocument)();
809
833
  const isPostActive = activeDocument?.id === post.id;
810
834
  return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
811
835
  ActionMenuItem,
@@ -957,14 +981,16 @@ function SetHome({ post, closeMenu }) {
957
981
  // src/components/panel/posts-list/list-items/list-item-view.tsx
958
982
  var import_i18n12 = require("@wordpress/i18n");
959
983
  function ListItemView({ post }) {
960
- const activeDocument = (0, import_editor_documents7.__useActiveDocument)();
961
- const navigateToDocument = (0, import_editor_documents7.__useNavigateToDocument)();
984
+ const activeDocument = (0, import_editor_documents8.__useActiveDocument)();
985
+ const navigateToDocument = (0, import_editor_documents8.__useNavigateToDocument)();
962
986
  const popupState = (0, import_ui12.usePopupState)({
963
987
  variant: "popover",
964
988
  popupId: "post-actions",
965
989
  disableAutoFocus: true
966
990
  });
967
991
  const isActive = activeDocument?.id === post.id;
992
+ const status = isActive ? activeDocument?.status.value : post.status;
993
+ const title = isActive ? activeDocument?.title : post.title.rendered;
968
994
  return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(
969
995
  import_ui12.ListItem,
970
996
  {
@@ -995,7 +1021,7 @@ function ListItemView({ post }) {
995
1021
  {
996
1022
  disableTypography: true
997
1023
  },
998
- /* @__PURE__ */ React19.createElement(PageTitleAndStatus, { page: post })
1024
+ /* @__PURE__ */ React19.createElement(PageTitleAndStatus, { title, status })
999
1025
  ),
1000
1026
  post.isHome && /* @__PURE__ */ React19.createElement(import_icons12.HomeIcon, { titleAccess: (0, import_i18n12.__)("Homepage", "elementor"), color: "disabled" })
1001
1027
  )
package/dist/index.mjs CHANGED
@@ -231,14 +231,7 @@ function RecentlyEdited() {
231
231
  variant: "popover",
232
232
  popupId: "elementor-v2-top-bar-recently-edited"
233
233
  });
234
- const getCurrentDocumentFromRecentPosts = () => {
235
- if (!document2) {
236
- return null;
237
- }
238
- return data?.find((post) => post.id === document2.id);
239
- };
240
- const currentDocumentFromRecentPosts = getCurrentDocumentFromRecentPosts();
241
- const documentTitle = useReverseHtmlEntities(currentDocumentFromRecentPosts ? currentDocumentFromRecentPosts.title : document2?.title);
234
+ const documentTitle = useReverseHtmlEntities(document2?.title);
242
235
  if (!document2) {
243
236
  return null;
244
237
  }
@@ -594,27 +587,58 @@ function CloseButton({ isLoading, closeButton }) {
594
587
  );
595
588
  }
596
589
 
590
+ // src/components/panel/posts-list/list-items/list-item-rename.tsx
591
+ import { __useActiveDocument as useActiveDocument2 } from "@elementor/editor-documents";
592
+
593
+ // src/hooks/use-rename-active-document.ts
594
+ import { __privateRunCommand as runCommand } from "@elementor/editor-v1-adapters";
595
+ function getV1DocumentsManager() {
596
+ const documentsManager = window.elementor?.documents;
597
+ if (!documentsManager) {
598
+ throw new Error("Elementor Editor V1 documents manager not found");
599
+ }
600
+ return documentsManager;
601
+ }
602
+ function useRenameActiveDocument() {
603
+ return async (title) => {
604
+ const currentDocument = getV1DocumentsManager().getCurrent();
605
+ const container = currentDocument.container;
606
+ await runCommand("document/elements/settings", {
607
+ container,
608
+ settings: { post_title: title }
609
+ });
610
+ };
611
+ }
612
+
597
613
  // src/components/panel/posts-list/list-items/list-item-rename.tsx
598
614
  function ListItemRename({ post }) {
599
615
  const { type, resetEditMode } = usePostListContext();
600
616
  const { updatePost } = usePostActions(type);
601
617
  const { setError } = usePostListContext();
618
+ const activeDocument = useActiveDocument2();
619
+ const rename = useRenameActiveDocument();
620
+ const isActive = activeDocument?.id === post.id;
621
+ const title = isActive ? activeDocument?.title : post.title.rendered;
602
622
  const renamePostCallback = async (inputValue) => {
603
- if (inputValue === post.title.rendered) {
623
+ if (inputValue === title) {
604
624
  resetEditMode();
605
625
  }
606
626
  try {
607
- await updatePost.mutateAsync({
608
- id: post.id,
609
- title: inputValue
610
- });
627
+ if (isActive) {
628
+ await rename(inputValue);
629
+ } else {
630
+ await updatePost.mutateAsync({
631
+ id: post.id,
632
+ title: inputValue
633
+ });
634
+ }
611
635
  } catch (e) {
612
636
  setError();
613
637
  } finally {
614
638
  resetEditMode();
615
639
  }
616
640
  };
617
- return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: post.title.rendered, isLoading: updatePost.isPending, callback: renamePostCallback });
641
+ return /* @__PURE__ */ React9.createElement(EditModeTemplate, { postTitle: title, isLoading: updatePost.isPending, callback: renamePostCallback });
618
642
  }
619
643
 
620
644
  // src/components/panel/posts-list/list-items/list-item-create.tsx
@@ -684,7 +708,7 @@ import {
684
708
  usePopupState as usePopupState2
685
709
  } from "@elementor/ui";
686
710
  import { DotsVerticalIcon, HomeIcon as HomeIcon2 } from "@elementor/icons";
687
- import { __useActiveDocument as useActiveDocument3, __useNavigateToDocument as useNavigateToDocument5 } from "@elementor/editor-documents";
711
+ import { __useActiveDocument as useActiveDocument4, __useNavigateToDocument as useNavigateToDocument5 } from "@elementor/editor-documents";
688
712
 
689
713
  // src/components/shared/page-title-and-status.tsx
690
714
  import * as React12 from "react";
@@ -727,8 +751,8 @@ var PageTitle = ({ title }) => {
727
751
  modifiedTitle
728
752
  );
729
753
  };
730
- function PageTitleAndStatus({ page }) {
731
- return /* @__PURE__ */ React12.createElement(Box2, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title: page.title.rendered }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status: page.status }));
754
+ function PageTitleAndStatus({ title, status }) {
755
+ return /* @__PURE__ */ React12.createElement(Box2, { display: "flex" }, /* @__PURE__ */ React12.createElement(PageTitle, { title }), "\xA0", /* @__PURE__ */ React12.createElement(PageStatus, { status }));
732
756
  }
733
757
 
734
758
  // src/components/panel/actions-menu/actions/rename.tsx
@@ -814,10 +838,10 @@ import {
814
838
  Divider as Divider3
815
839
  } from "@elementor/ui";
816
840
  import { useState as useState5 } from "react";
817
- import { __useActiveDocument as useActiveDocument2 } from "@elementor/editor-documents";
841
+ import { __useActiveDocument as useActiveDocument3 } from "@elementor/editor-documents";
818
842
  function Delete({ post }) {
819
843
  const [isDialogOpen, setIsDialogOpen] = useState5(false);
820
- const activeDocument = useActiveDocument2();
844
+ const activeDocument = useActiveDocument3();
821
845
  const isPostActive = activeDocument?.id === post.id;
822
846
  return /* @__PURE__ */ React16.createElement(React16.Fragment, null, /* @__PURE__ */ React16.createElement(
823
847
  ActionMenuItem,
@@ -969,7 +993,7 @@ function SetHome({ post, closeMenu }) {
969
993
  // src/components/panel/posts-list/list-items/list-item-view.tsx
970
994
  import { __ as __12 } from "@wordpress/i18n";
971
995
  function ListItemView({ post }) {
972
- const activeDocument = useActiveDocument3();
996
+ const activeDocument = useActiveDocument4();
973
997
  const navigateToDocument = useNavigateToDocument5();
974
998
  const popupState = usePopupState2({
975
999
  variant: "popover",
@@ -977,6 +1001,8 @@ function ListItemView({ post }) {
977
1001
  disableAutoFocus: true
978
1002
  });
979
1003
  const isActive = activeDocument?.id === post.id;
1004
+ const status = isActive ? activeDocument?.status.value : post.status;
1005
+ const title = isActive ? activeDocument?.title : post.title.rendered;
980
1006
  return /* @__PURE__ */ React19.createElement(React19.Fragment, null, /* @__PURE__ */ React19.createElement(
981
1007
  ListItem3,
982
1008
  {
@@ -1007,7 +1033,7 @@ function ListItemView({ post }) {
1007
1033
  {
1008
1034
  disableTypography: true
1009
1035
  },
1010
- /* @__PURE__ */ React19.createElement(PageTitleAndStatus, { page: post })
1036
+ /* @__PURE__ */ React19.createElement(PageTitleAndStatus, { title, status })
1011
1037
  ),
1012
1038
  post.isHome && /* @__PURE__ */ React19.createElement(HomeIcon2, { titleAccess: __12("Homepage", "elementor"), color: "disabled" })
1013
1039
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elementor/editor-site-navigation",
3
- "version": "0.19.10",
3
+ "version": "0.19.11",
4
4
  "private": false,
5
5
  "author": "Elementor Team",
6
6
  "homepage": "https://elementor.com/",
@@ -35,6 +35,7 @@
35
35
  "@elementor/editor-app-bar": "^0.9.7",
36
36
  "@elementor/editor-documents": "^0.10.1",
37
37
  "@elementor/editor-panels": "^0.4.6",
38
+ "@elementor/editor-v1-adapters": "^0.6.0",
38
39
  "@elementor/env": "^0.3.2",
39
40
  "@elementor/icons": "^0.7.2",
40
41
  "@elementor/query": "^0.1.6",
@@ -49,5 +50,5 @@
49
50
  "elementor": {
50
51
  "type": "extension"
51
52
  },
52
- "gitHead": "1d0f6576302b82c0375b768ec68ab9ed896f7865"
53
+ "gitHead": "82b8732700123fe0b916a2e7e78d91a55f5bb7e1"
53
54
  }
@@ -49,7 +49,7 @@ jest.mock( '@elementor/editor-documents', () => ( {
49
49
  describe( '@elementor/editor-site-navigation - PostsCollapsibleList', () => {
50
50
  beforeEach( () => {
51
51
  jest.mocked( useActiveDocument ).mockReturnValue( createMockDocument( ( {
52
- id: 2,
52
+ id: 3,
53
53
  } ) ) );
54
54
  } );
55
55
 
@@ -3,6 +3,8 @@ import { usePostListContext } from '../../../../contexts/post-list-context';
3
3
  import { usePostActions } from '../../../../hooks/use-posts-actions';
4
4
  import { Post } from '../../../../types';
5
5
  import EditModeTemplate from './edit-mode-template';
6
+ import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
7
+ import useRenameActiveDocument from '../../../../hooks/use-rename-active-document';
6
8
 
7
9
  type Props = {
8
10
  post: Post,
@@ -12,17 +14,26 @@ export default function ListItemRename( { post }: Props ) {
12
14
  const { type, resetEditMode } = usePostListContext();
13
15
  const { updatePost } = usePostActions( type );
14
16
  const { setError } = usePostListContext();
17
+ const activeDocument = useActiveDocument();
18
+ const rename = useRenameActiveDocument();
19
+
20
+ const isActive = activeDocument?.id === post.id;
21
+ const title = isActive ? activeDocument?.title : post.title.rendered;
15
22
 
16
23
  const renamePostCallback = async ( inputValue: string ) => {
17
- if ( inputValue === post.title.rendered ) {
24
+ if ( inputValue === title ) {
18
25
  resetEditMode();
19
26
  }
20
27
 
21
28
  try {
22
- await updatePost.mutateAsync( {
23
- id: post.id,
24
- title: inputValue,
25
- } );
29
+ if ( isActive ) {
30
+ await rename( inputValue );
31
+ } else {
32
+ await updatePost.mutateAsync( {
33
+ id: post.id,
34
+ title: inputValue,
35
+ } );
36
+ }
26
37
  } catch ( e ) {
27
38
  setError();
28
39
  } finally {
@@ -31,6 +42,6 @@ export default function ListItemRename( { post }: Props ) {
31
42
  };
32
43
 
33
44
  return (
34
- <EditModeTemplate postTitle={ post.title.rendered } isLoading={ updatePost.isPending } callback={ renamePostCallback } />
45
+ <EditModeTemplate postTitle={ title } isLoading={ updatePost.isPending } callback={ renamePostCallback } />
35
46
  );
36
47
  }
@@ -32,6 +32,8 @@ export default function ListItemView( { post }: { post: Post } ) {
32
32
  } );
33
33
 
34
34
  const isActive = activeDocument?.id === post.id;
35
+ const status = isActive ? activeDocument?.status.value : post.status;
36
+ const title = isActive ? activeDocument?.title : post.title.rendered;
35
37
 
36
38
  return (
37
39
  <>
@@ -59,7 +61,7 @@ export default function ListItemView( { post }: { post: Post } ) {
59
61
  <ListItemText
60
62
  disableTypography={ true }
61
63
  >
62
- <PageTitleAndStatus page={ post } />
64
+ <PageTitleAndStatus title={ title } status={ status } />
63
65
  </ListItemText>
64
66
  { post.isHome &&
65
67
  <HomeIcon titleAccess={ __( 'Homepage', 'elementor' ) } color="disabled" />
@@ -1,6 +1,5 @@
1
1
  import * as React from 'react';
2
2
  import { Box, Typography } from '@elementor/ui';
3
- import { Post } from '../../types';
4
3
  import { useReverseHtmlEntities } from '../../hooks/use-reverse-html-entities';
5
4
 
6
5
  const PageStatus = ( { status }: { status: string } ) => {
@@ -43,10 +42,10 @@ const PageTitle = ( { title }: { title: string } ) => {
43
42
  );
44
43
  };
45
44
 
46
- export default function PageTitleAndStatus( { page }: { page: Post } ) {
45
+ export default function PageTitleAndStatus( { title, status }: { title: string, status: string } ) {
47
46
  return (
48
47
  <Box display="flex">
49
- <PageTitle title={ page.title.rendered } />&nbsp;<PageStatus status={ page.status } />
48
+ <PageTitle title={ title } />&nbsp;<PageStatus status={ status } />
50
49
  </Box>
51
50
  );
52
51
  }
@@ -146,7 +146,7 @@ describe( '@elementor/recently-edited - Top bar Recently Edited', () => {
146
146
 
147
147
  const isLoading = false;
148
148
  const recentPosts: RecentPost[] = [ {
149
- id: 1,
149
+ id: 2,
150
150
  title: 'Test post',
151
151
  edit_url: 'some_url',
152
152
  type: {
@@ -43,16 +43,7 @@ export default function RecentlyEdited() {
43
43
  popupId: 'elementor-v2-top-bar-recently-edited',
44
44
  } );
45
45
 
46
- const getCurrentDocumentFromRecentPosts = () => {
47
- if ( ! document ) {
48
- return null;
49
- }
50
-
51
- return data?.find( ( post ) => post.id === document.id );
52
- };
53
- const currentDocumentFromRecentPosts = getCurrentDocumentFromRecentPosts();
54
-
55
- const documentTitle = useReverseHtmlEntities( currentDocumentFromRecentPosts ? currentDocumentFromRecentPosts.title : document?.title );
46
+ const documentTitle = useReverseHtmlEntities( document?.title );
56
47
 
57
48
  if ( ! document ) {
58
49
  return null;
@@ -0,0 +1,23 @@
1
+ import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
2
+ import { ExtendedWindow } from '@elementor/editor-documents';
3
+
4
+ function getV1DocumentsManager() {
5
+ const documentsManager = ( window as unknown as ExtendedWindow ).elementor?.documents;
6
+
7
+ if ( ! documentsManager ) {
8
+ throw new Error( 'Elementor Editor V1 documents manager not found' );
9
+ }
10
+
11
+ return documentsManager;
12
+ }
13
+
14
+ export default function useRenameActiveDocument() {
15
+ return async ( title: string ) => {
16
+ const currentDocument = getV1DocumentsManager().getCurrent();
17
+ const container = currentDocument.container;
18
+ await runCommand( 'document/elements/settings', {
19
+ container,
20
+ settings: { post_title: title },
21
+ } );
22
+ };
23
+ }