@elementor/editor-app-bar 4.1.0-826 → 4.1.0-827

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-app-bar",
3
3
  "description": "App Bar extension for @elementor/editor",
4
- "version": "4.1.0-826",
4
+ "version": "4.1.0-827",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -40,16 +40,16 @@
40
40
  "dev": "tsup --config=../../tsup.dev.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@elementor/editor-ui": "4.1.0-826",
44
- "@elementor/http-client": "4.1.0-826",
45
- "@elementor/editor": "4.1.0-826",
46
- "@elementor/editor-documents": "4.1.0-826",
47
- "@elementor/editor-responsive": "4.1.0-826",
48
- "@elementor/editor-v1-adapters": "4.1.0-826",
43
+ "@elementor/editor-ui": "4.1.0-827",
44
+ "@elementor/http-client": "4.1.0-827",
45
+ "@elementor/editor": "4.1.0-827",
46
+ "@elementor/editor-documents": "4.1.0-827",
47
+ "@elementor/editor-responsive": "4.1.0-827",
48
+ "@elementor/editor-v1-adapters": "4.1.0-827",
49
49
  "@elementor/icons": "^1.68.0",
50
- "@elementor/locations": "4.1.0-826",
51
- "@elementor/menus": "4.1.0-826",
52
- "@elementor/events": "4.1.0-826",
50
+ "@elementor/locations": "4.1.0-827",
51
+ "@elementor/menus": "4.1.0-827",
52
+ "@elementor/events": "4.1.0-827",
53
53
  "@elementor/ui": "1.37.5",
54
54
  "@wordpress/i18n": "^5.13.0"
55
55
  },
@@ -0,0 +1,29 @@
1
+ import { __useActiveDocument as useActiveDocument } from '@elementor/editor-documents';
2
+ import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
3
+ import { EyeIcon } from '@elementor/icons';
4
+ import { __ } from '@wordpress/i18n';
5
+
6
+ export default function useDocumentViewAsMarkdownProps() {
7
+ const document = useActiveDocument();
8
+
9
+ return {
10
+ icon: EyeIcon,
11
+ title: __( 'View as Markdown', 'elementor' ),
12
+ onClick: async () => {
13
+ const baseUrl = document?.links?.wpPreview || document?.links?.permalink;
14
+
15
+ if ( ! baseUrl ) {
16
+ return;
17
+ }
18
+
19
+ if ( document?.isDirty ) {
20
+ await runCommand( 'document/save/auto', { force: true } );
21
+ }
22
+
23
+ const separator = baseUrl.includes( '?' ) ? '&' : '?';
24
+ const url = baseUrl + separator + 'format=markdown';
25
+
26
+ window.open( url, '_blank' );
27
+ },
28
+ };
29
+ }
@@ -3,6 +3,7 @@ import PrimaryAction from './components/primary-action';
3
3
  import useDocumentCopyAndShareProps from './hooks/use-document-copy-and-share-props';
4
4
  import useDocumentSaveDraftProps from './hooks/use-document-save-draft-props';
5
5
  import useDocumentSaveTemplateProps from './hooks/use-document-save-template-props';
6
+ import useDocumentViewAsMarkdownProps from './hooks/use-document-view-as-markdown-props';
6
7
  import useDocumentViewPageProps from './hooks/use-document-view-page-props';
7
8
  import { documentOptionsMenu } from './locations';
8
9
 
@@ -37,4 +38,10 @@ export function init() {
37
38
  priority: 50,
38
39
  useProps: useDocumentViewPageProps,
39
40
  } );
41
+
42
+ documentOptionsMenu.registerAction( {
43
+ id: 'document-view-as-markdown',
44
+ priority: 60,
45
+ useProps: useDocumentViewAsMarkdownProps,
46
+ } );
40
47
  }