@wordpress/edit-post 7.25.0 → 7.26.1-next.79a6196f.0
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 +6 -0
- package/LICENSE.md +1 -1
- package/build/components/browser-url/index.js +3 -2
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/header/index.js +25 -25
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +11 -8
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -20
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +33 -26
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +1 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/preferences-modal/index.js +25 -8
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +23 -23
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +3 -6
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +2 -3
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +1 -7
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/editor.js +19 -28
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +3 -10
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +16 -12
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/use-post-history.js +79 -0
- package/build/hooks/use-post-history.js.map +1 -0
- package/build/index.js +19 -16
- package/build/index.js.map +1 -1
- package/build/index.native.js +7 -1
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +59 -73
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -62
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +66 -38
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/browser-url/index.js +3 -2
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/header/index.js +25 -25
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +11 -8
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -20
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +33 -25
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +2 -2
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +25 -8
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +22 -23
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +3 -7
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +3 -4
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +2 -8
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/editor.js +19 -28
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -10
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +16 -12
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/use-post-history.js +73 -0
- package/build-module/hooks/use-post-history.js.map +1 -0
- package/build-module/index.js +17 -11
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +7 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +55 -69
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -60
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +58 -29
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +13 -284
- package/build-style/style.css +13 -284
- package/package.json +32 -32
- package/src/components/browser-url/index.js +4 -2
- package/src/components/header/index.js +24 -40
- package/src/components/header/style.scss +3 -3
- package/src/components/header/writing-menu/index.js +10 -8
- package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -15
- package/src/components/keyboard-shortcuts/index.js +1 -23
- package/src/components/layout/index.js +18 -27
- package/src/components/layout/index.native.js +6 -1
- package/src/components/meta-boxes/meta-box-visibility.js +2 -8
- package/src/components/preferences-modal/index.js +27 -9
- package/src/components/preferences-modal/options/enable-feature.js +26 -21
- package/src/components/preferences-modal/options/enable-panel.js +3 -7
- package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +187 -175
- package/src/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/src/components/sidebar/plugin-sidebar/index.js +1 -9
- package/src/components/sidebar/post-status/index.js +3 -3
- package/src/components/sidebar/settings-sidebar/index.js +15 -13
- package/src/components/text-editor/style.scss +0 -6
- package/src/editor.js +34 -33
- package/src/editor.native.js +2 -17
- package/src/hooks/commands/use-common-commands.js +14 -16
- package/src/hooks/use-post-history.js +73 -0
- package/src/index.js +22 -12
- package/src/index.native.js +8 -1
- package/src/store/actions.js +48 -85
- package/src/store/reducer.js +0 -60
- package/src/store/selectors.js +74 -46
- package/src/store/test/actions.js +10 -103
- package/src/store/test/reducer.js +1 -108
- package/src/store/test/selectors.js +0 -50
- package/src/style.scss +1 -5
- package/src/test/editor.native.js +17 -0
- package/build/components/header/header-toolbar/index.js +0 -160
- package/build/components/header/header-toolbar/index.js.map +0 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +0 -73
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-outline.js +0 -112
- package/build/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -148
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build/components/sidebar/discussion-panel/index.js +0 -59
- package/build/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build/components/sidebar/featured-image/index.js +0 -70
- package/build/components/sidebar/featured-image/index.js.map +0 -1
- package/build/components/sidebar/last-revision/index.js +0 -21
- package/build/components/sidebar/last-revision/index.js.map +0 -1
- package/build/components/sidebar/page-attributes/index.js +0 -65
- package/build/components/sidebar/page-attributes/index.js.map +0 -1
- package/build/components/sidebar/plugin-post-excerpt/index.js +0 -72
- package/build/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-excerpt/index.js +0 -54
- package/build/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/index.js +0 -30
- package/build/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -56
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
- package/build/components/view-link/index.js +0 -53
- package/build/components/view-link/index.js.map +0 -1
- package/build-module/components/header/header-toolbar/index.js +0 -152
- package/build-module/components/header/header-toolbar/index.js.map +0 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -66
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-outline.js +0 -105
- package/build-module/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -140
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build-module/components/sidebar/discussion-panel/index.js +0 -52
- package/build-module/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build-module/components/sidebar/featured-image/index.js +0 -63
- package/build-module/components/sidebar/featured-image/index.js.map +0 -1
- package/build-module/components/sidebar/last-revision/index.js +0 -13
- package/build-module/components/sidebar/last-revision/index.js.map +0 -1
- package/build-module/components/sidebar/page-attributes/index.js +0 -57
- package/build-module/components/sidebar/page-attributes/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-excerpt/index.js +0 -64
- package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-excerpt/index.js +0 -47
- package/build-module/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/index.js +0 -21
- package/build-module/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
- package/build-module/components/view-link/index.js +0 -46
- package/build-module/components/view-link/index.js.map +0 -1
- package/src/components/header/header-toolbar/index.js +0 -186
- package/src/components/header/header-toolbar/style.scss +0 -116
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +0 -929
- package/src/components/secondary-sidebar/inserter-sidebar.js +0 -71
- package/src/components/secondary-sidebar/list-view-outline.js +0 -98
- package/src/components/secondary-sidebar/list-view-sidebar.js +0 -170
- package/src/components/secondary-sidebar/style.scss +0 -120
- package/src/components/sidebar/discussion-panel/index.js +0 -62
- package/src/components/sidebar/featured-image/index.js +0 -67
- package/src/components/sidebar/last-revision/index.js +0 -17
- package/src/components/sidebar/last-revision/style.scss +0 -10
- package/src/components/sidebar/page-attributes/index.js +0 -65
- package/src/components/sidebar/plugin-post-excerpt/index.js +0 -61
- package/src/components/sidebar/plugin-post-excerpt/test/index.js +0 -36
- package/src/components/sidebar/post-excerpt/index.js +0 -59
- package/src/components/sidebar/post-taxonomies/index.js +0 -30
- package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- package/src/components/view-link/index.js +0 -48
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 7.26.0-next.0 (2024-01-11)
|
|
6
|
+
|
|
7
|
+
### Deprecations
|
|
8
|
+
|
|
9
|
+
- Move the panels visibility actions and selectors to the editor package deprecating `toggleEditorPanelEnabled`, `toggleEditorPanelOpened`, `removeEditorPanel`, `isEditorPanelRemoved`, `isEditorPanelOpened` and `isEditorPanelEnabled`.
|
|
10
|
+
|
|
5
11
|
## 7.25.0 (2023-12-13)
|
|
6
12
|
|
|
7
13
|
## 7.24.0 (2023-11-29)
|
package/LICENSE.md
CHANGED
|
@@ -55,7 +55,8 @@ class BrowserURL extends _element.Component {
|
|
|
55
55
|
postId,
|
|
56
56
|
postStatus,
|
|
57
57
|
postType,
|
|
58
|
-
isSavingPost
|
|
58
|
+
isSavingPost,
|
|
59
|
+
hasHistory
|
|
59
60
|
} = this.props;
|
|
60
61
|
const {
|
|
61
62
|
historyId
|
|
@@ -67,7 +68,7 @@ class BrowserURL extends _element.Component {
|
|
|
67
68
|
this.setTrashURL(postId, postType);
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
|
-
if ((postId !== prevProps.postId || postId !== historyId) && postStatus !== 'auto-draft' && postId) {
|
|
71
|
+
if ((postId !== prevProps.postId || postId !== historyId) && postStatus !== 'auto-draft' && postId && !hasHistory) {
|
|
71
72
|
this.setBrowserURL(postId);
|
|
72
73
|
}
|
|
73
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_url","_editor","getPostEditURL","postId","addQueryArgs","post","action","getPostTrashedURL","postType","trashed","post_type","ids","BrowserURL","Component","constructor","arguments","state","historyId","componentDidUpdate","prevProps","postStatus","isSavingPost","props","setTrashURL","setBrowserURL","window","location","href","history","replaceState","id","setState","render","exports","_default","withSelect","select","getCurrentPost","editorStore","status","type","isTemplate","includes","wp_id","default"],"sources":["@wordpress/edit-post/src/components/browser-url/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Returns the Post's Edit URL.\n *\n * @param {number} postId Post ID.\n *\n * @return {string} Post edit URL.\n */\nexport function getPostEditURL( postId ) {\n\treturn addQueryArgs( 'post.php', { post: postId, action: 'edit' } );\n}\n\n/**\n * Returns the Post's Trashed URL.\n *\n * @param {number} postId Post ID.\n * @param {string} postType Post Type.\n *\n * @return {string} Post trashed URL.\n */\nexport function getPostTrashedURL( postId, postType ) {\n\treturn addQueryArgs( 'edit.php', {\n\t\ttrashed: 1,\n\t\tpost_type: postType,\n\t\tids: postId,\n\t} );\n}\n\nexport class BrowserURL extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\thistoryId: null,\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { postId, postStatus, postType, isSavingPost }
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_url","_editor","getPostEditURL","postId","addQueryArgs","post","action","getPostTrashedURL","postType","trashed","post_type","ids","BrowserURL","Component","constructor","arguments","state","historyId","componentDidUpdate","prevProps","postStatus","isSavingPost","hasHistory","props","setTrashURL","setBrowserURL","window","location","href","history","replaceState","id","setState","render","exports","_default","withSelect","select","getCurrentPost","editorStore","status","type","isTemplate","includes","wp_id","default"],"sources":["@wordpress/edit-post/src/components/browser-url/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { withSelect } from '@wordpress/data';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Returns the Post's Edit URL.\n *\n * @param {number} postId Post ID.\n *\n * @return {string} Post edit URL.\n */\nexport function getPostEditURL( postId ) {\n\treturn addQueryArgs( 'post.php', { post: postId, action: 'edit' } );\n}\n\n/**\n * Returns the Post's Trashed URL.\n *\n * @param {number} postId Post ID.\n * @param {string} postType Post Type.\n *\n * @return {string} Post trashed URL.\n */\nexport function getPostTrashedURL( postId, postType ) {\n\treturn addQueryArgs( 'edit.php', {\n\t\ttrashed: 1,\n\t\tpost_type: postType,\n\t\tids: postId,\n\t} );\n}\n\nexport class BrowserURL extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\tthis.state = {\n\t\t\thistoryId: null,\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { postId, postStatus, postType, isSavingPost, hasHistory } =\n\t\t\tthis.props;\n\t\tconst { historyId } = this.state;\n\n\t\t// Posts are still dirty while saving so wait for saving to finish\n\t\t// to avoid the unsaved changes warning when trashing posts.\n\t\tif ( postStatus === 'trash' && ! isSavingPost ) {\n\t\t\tthis.setTrashURL( postId, postType );\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\t( postId !== prevProps.postId || postId !== historyId ) &&\n\t\t\tpostStatus !== 'auto-draft' &&\n\t\t\tpostId &&\n\t\t\t! hasHistory\n\t\t) {\n\t\t\tthis.setBrowserURL( postId );\n\t\t}\n\t}\n\n\t/**\n\t * Navigates the browser to the post trashed URL to show a notice about the trashed post.\n\t *\n\t * @param {number} postId Post ID.\n\t * @param {string} postType Post Type.\n\t */\n\tsetTrashURL( postId, postType ) {\n\t\twindow.location.href = getPostTrashedURL( postId, postType );\n\t}\n\n\t/**\n\t * Replaces the browser URL with a post editor link for the given post ID.\n\t *\n\t * Note it is important that, since this function may be called when the\n\t * editor first loads, the result generated `getPostEditURL` matches that\n\t * produced by the server. Otherwise, the URL will change unexpectedly.\n\t *\n\t * @param {number} postId Post ID for which to generate post editor URL.\n\t */\n\tsetBrowserURL( postId ) {\n\t\twindow.history.replaceState(\n\t\t\t{ id: postId },\n\t\t\t'Post ' + postId,\n\t\t\tgetPostEditURL( postId )\n\t\t);\n\n\t\tthis.setState( () => ( {\n\t\t\thistoryId: postId,\n\t\t} ) );\n\t}\n\n\trender() {\n\t\treturn null;\n\t}\n}\n\nexport default withSelect( ( select ) => {\n\tconst { getCurrentPost, isSavingPost } = select( editorStore );\n\tconst post = getCurrentPost();\n\tlet { id, status, type } = post;\n\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes( type );\n\tif ( isTemplate ) {\n\t\tid = post.wp_id;\n\t}\n\n\treturn {\n\t\tpostId: id,\n\t\tpostStatus: status,\n\t\tpostType: type,\n\t\tisSavingPost: isSavingPost(),\n\t};\n} )( BrowserURL );\n"],"mappings":";;;;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AANA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,cAAcA,CAAEC,MAAM,EAAG;EACxC,OAAO,IAAAC,iBAAY,EAAE,UAAU,EAAE;IAAEC,IAAI,EAAEF,MAAM;IAAEG,MAAM,EAAE;EAAO,CAAE,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,iBAAiBA,CAAEJ,MAAM,EAAEK,QAAQ,EAAG;EACrD,OAAO,IAAAJ,iBAAY,EAAE,UAAU,EAAE;IAChCK,OAAO,EAAE,CAAC;IACVC,SAAS,EAAEF,QAAQ;IACnBG,GAAG,EAAER;EACN,CAAE,CAAC;AACJ;AAEO,MAAMS,UAAU,SAASC,kBAAS,CAAC;EACzCC,WAAWA,CAAA,EAAG;IACb,KAAK,CAA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,GAEc,IAAAC,gBAAU,EAAIC,MAAM,IAAM;EACxC,MAAM;IAAEC,cAAc;IAAEjB;EAAa,CAAC,GAAGgB,MAAM,CAAEE,aAAY,CAAC;EAC9D,MAAMlC,IAAI,GAAGiC,cAAc,CAAC,CAAC;EAC7B,IAAI;IAAEP,EAAE;IAAES,MAAM;IAAEC;EAAK,CAAC,GAAGpC,IAAI;EAC/B,MAAMqC,UAAU,GAAG,CAAE,aAAa,EAAE,kBAAkB,CAAE,CAACC,QAAQ,CAAEF,IAAK,CAAC;EACzE,IAAKC,UAAU,EAAG;IACjBX,EAAE,GAAG1B,IAAI,CAACuC,KAAK;EAChB;EAEA,OAAO;IACNzC,MAAM,EAAE4B,EAAE;IACVX,UAAU,EAAEoB,MAAM;IAClBhC,QAAQ,EAAEiC,IAAI;IACdpB,YAAY,EAAEA,YAAY,CAAC;EAC5B,CAAC;AACF,CAAE,CAAC,CAAET,UAAW,CAAC;AAAAsB,OAAA,CAAAW,OAAA,GAAAV,QAAA"}
|
|
@@ -18,10 +18,8 @@ var _compose = require("@wordpress/compose");
|
|
|
18
18
|
var _components = require("@wordpress/components");
|
|
19
19
|
var _preferences = require("@wordpress/preferences");
|
|
20
20
|
var _fullscreenModeClose = _interopRequireDefault(require("./fullscreen-mode-close"));
|
|
21
|
-
var _headerToolbar = _interopRequireDefault(require("./header-toolbar"));
|
|
22
21
|
var _moreMenu = _interopRequireDefault(require("./more-menu"));
|
|
23
22
|
var _postPublishButtonOrToggle = _interopRequireDefault(require("./post-publish-button-or-toggle"));
|
|
24
|
-
var _viewLink = _interopRequireDefault(require("../view-link"));
|
|
25
23
|
var _mainDashboardButton = _interopRequireDefault(require("./main-dashboard-button"));
|
|
26
24
|
var _store = require("../../store");
|
|
27
25
|
var _lockUnlock = require("../../lock-unlock");
|
|
@@ -38,6 +36,8 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
38
36
|
*/
|
|
39
37
|
|
|
40
38
|
const {
|
|
39
|
+
DocumentTools,
|
|
40
|
+
PostViewLink,
|
|
41
41
|
PreviewDropdown
|
|
42
42
|
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
43
43
|
const slideY = {
|
|
@@ -71,40 +71,45 @@ const slideX = {
|
|
|
71
71
|
}
|
|
72
72
|
};
|
|
73
73
|
function Header({
|
|
74
|
-
setEntitiesSavedStatesCallback
|
|
75
|
-
setListViewToggleElement
|
|
74
|
+
setEntitiesSavedStatesCallback
|
|
76
75
|
}) {
|
|
77
76
|
const isWideViewport = (0, _compose.useViewportMatch)('large');
|
|
78
77
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
79
78
|
const blockToolbarRef = (0, _element.useRef)();
|
|
80
79
|
const {
|
|
81
|
-
|
|
80
|
+
isTextEditor,
|
|
81
|
+
hasBlockSelection,
|
|
82
82
|
hasActiveMetaboxes,
|
|
83
83
|
hasFixedToolbar,
|
|
84
84
|
isEditingTemplate,
|
|
85
85
|
isPublishSidebarOpened,
|
|
86
|
-
showIconLabels
|
|
86
|
+
showIconLabels,
|
|
87
|
+
hasHistory
|
|
87
88
|
} = (0, _data.useSelect)(select => {
|
|
88
89
|
const {
|
|
89
90
|
get: getPreference
|
|
90
91
|
} = select(_preferences.store);
|
|
92
|
+
const {
|
|
93
|
+
getEditorMode
|
|
94
|
+
} = select(_store.store);
|
|
91
95
|
return {
|
|
92
|
-
|
|
96
|
+
isTextEditor: getEditorMode() === 'text',
|
|
97
|
+
hasBlockSelection: !!select(_blockEditor.store).getBlockSelectionStart(),
|
|
93
98
|
hasActiveMetaboxes: select(_store.store).hasMetaBoxes(),
|
|
99
|
+
hasHistory: !!select(_editor.store).getEditorSettings().goBack,
|
|
94
100
|
isEditingTemplate: select(_editor.store).getRenderingMode() === 'template-only',
|
|
95
101
|
isPublishSidebarOpened: select(_store.store).isPublishSidebarOpened(),
|
|
96
|
-
hasFixedToolbar: getPreference('core
|
|
97
|
-
showIconLabels:
|
|
102
|
+
hasFixedToolbar: getPreference('core', 'fixedToolbar'),
|
|
103
|
+
showIconLabels: getPreference('core', 'showIconLabels')
|
|
98
104
|
};
|
|
99
105
|
}, []);
|
|
100
106
|
const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, _element.useState)(true);
|
|
101
|
-
const hasBlockSelected = !!blockSelectionStart;
|
|
102
107
|
(0, _element.useEffect)(() => {
|
|
103
108
|
// If we have a new block selection, show the block tools
|
|
104
|
-
if (
|
|
109
|
+
if (hasBlockSelection) {
|
|
105
110
|
setIsBlockToolsCollapsed(false);
|
|
106
111
|
}
|
|
107
|
-
}, [
|
|
112
|
+
}, [hasBlockSelection]);
|
|
108
113
|
return (0, _react.createElement)("div", {
|
|
109
114
|
className: "edit-post-header"
|
|
110
115
|
}, (0, _react.createElement)(_mainDashboardButton.default.Slot, null, (0, _react.createElement)(_components.__unstableMotion.div, {
|
|
@@ -122,9 +127,8 @@ function Header({
|
|
|
122
127
|
delay: 0.8
|
|
123
128
|
},
|
|
124
129
|
className: "edit-post-header__toolbar"
|
|
125
|
-
}, (0, _react.createElement)(
|
|
126
|
-
|
|
127
|
-
setListViewToggleElement: setListViewToggleElement
|
|
130
|
+
}, (0, _react.createElement)(DocumentTools, {
|
|
131
|
+
disableBlockTools: isTextEditor
|
|
128
132
|
}), hasFixedToolbar && isLargeViewport && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)("div", {
|
|
129
133
|
className: (0, _classnames.default)('selected-block-tools-wrapper', {
|
|
130
134
|
'is-collapsed': isEditingTemplate && isBlockToolsCollapsed
|
|
@@ -134,7 +138,7 @@ function Header({
|
|
|
134
138
|
})), (0, _react.createElement)(_components.Popover.Slot, {
|
|
135
139
|
ref: blockToolbarRef,
|
|
136
140
|
name: "block-toolbar"
|
|
137
|
-
}), isEditingTemplate &&
|
|
141
|
+
}), isEditingTemplate && hasBlockSelection && (0, _react.createElement)(_components.Button, {
|
|
138
142
|
className: "edit-post-header__block-tools-toggle",
|
|
139
143
|
icon: isBlockToolsCollapsed ? _icons.next : _icons.previous,
|
|
140
144
|
onClick: () => {
|
|
@@ -143,9 +147,9 @@ function Header({
|
|
|
143
147
|
label: isBlockToolsCollapsed ? (0, _i18n.__)('Show block tools') : (0, _i18n.__)('Hide block tools')
|
|
144
148
|
})), (0, _react.createElement)("div", {
|
|
145
149
|
className: (0, _classnames.default)('edit-post-header__center', {
|
|
146
|
-
'is-collapsed': isEditingTemplate &&
|
|
150
|
+
'is-collapsed': isEditingTemplate && hasBlockSelection && !isBlockToolsCollapsed && hasFixedToolbar && isLargeViewport
|
|
147
151
|
})
|
|
148
|
-
}, isEditingTemplate && (0, _react.createElement)(_editor.DocumentBar, null))), (0, _react.createElement)(_components.__unstableMotion.div, {
|
|
152
|
+
}, (isEditingTemplate || hasHistory) && (0, _react.createElement)(_editor.DocumentBar, null))), (0, _react.createElement)(_components.__unstableMotion.div, {
|
|
149
153
|
variants: slideY,
|
|
150
154
|
transition: {
|
|
151
155
|
type: 'tween',
|
|
@@ -159,23 +163,19 @@ function Header({
|
|
|
159
163
|
// We track that DOM node to return focus to the PostPublishButtonOrToggle
|
|
160
164
|
// when the publish sidebar has been closed.
|
|
161
165
|
(0, _react.createElement)(_editor.PostSavedState, {
|
|
162
|
-
forceIsDirty: hasActiveMetaboxes
|
|
163
|
-
showIconLabels: showIconLabels
|
|
166
|
+
forceIsDirty: hasActiveMetaboxes
|
|
164
167
|
}), (0, _react.createElement)(PreviewDropdown, {
|
|
165
|
-
showIconLabels: showIconLabels,
|
|
166
168
|
forceIsAutosaveable: hasActiveMetaboxes
|
|
167
169
|
}), (0, _react.createElement)(_editor.PostPreviewButton, {
|
|
168
170
|
className: "edit-post-header__post-preview-button",
|
|
169
171
|
forceIsAutosaveable: hasActiveMetaboxes
|
|
170
|
-
}), (0, _react.createElement)(
|
|
172
|
+
}), (0, _react.createElement)(PostViewLink, null), (0, _react.createElement)(_postPublishButtonOrToggle.default, {
|
|
171
173
|
forceIsDirty: hasActiveMetaboxes,
|
|
172
174
|
setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
|
|
173
|
-
}), (isWideViewport || !showIconLabels) && (0, _react.createElement)(
|
|
175
|
+
}), (isWideViewport || !showIconLabels) && (0, _react.createElement)(_interface.PinnedItems.Slot, {
|
|
174
176
|
scope: "core/edit-post"
|
|
175
177
|
}), (0, _react.createElement)(_moreMenu.default, {
|
|
176
178
|
showIconLabels: showIconLabels
|
|
177
|
-
})), showIconLabels && !isWideViewport && (0, _react.createElement)(_moreMenu.default, {
|
|
178
|
-
showIconLabels: showIconLabels
|
|
179
179
|
})));
|
|
180
180
|
}
|
|
181
181
|
var _default = Header;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_editor","_element","_data","_i18n","_icons","_interface","_compose","_components","_preferences","_fullscreenModeClose","_headerToolbar","_moreMenu","_postPublishButtonOrToggle","_viewLink","_mainDashboardButton","_store","_lockUnlock","PreviewDropdown","unlock","editorPrivateApis","slideY","hidden","y","distractionFreeInactive","hover","transition","type","delay","slideX","x","Header","setEntitiesSavedStatesCallback","setListViewToggleElement","isWideViewport","useViewportMatch","isLargeViewport","blockToolbarRef","useRef","blockSelectionStart","hasActiveMetaboxes","hasFixedToolbar","isEditingTemplate","isPublishSidebarOpened","showIconLabels","useSelect","select","get","getPreference","preferencesStore","blockEditorStore","getBlockSelectionStart","editPostStore","hasMetaBoxes","editorStore","getRenderingMode","isFeatureActive","isBlockToolsCollapsed","setIsBlockToolsCollapsed","useState","hasBlockSelected","useEffect","_react","createElement","className","default","Slot","__unstableMotion","div","variants","showTooltip","Fragment","classnames","BlockToolbar","hideDragHandle","Popover","ref","name","Button","icon","next","previous","onClick","collapsed","label","__","DocumentBar","PostSavedState","forceIsDirty","forceIsAutosaveable","PostPreviewButton","PinnedItems","scope","_default","exports"],"sources":["@wordpress/edit-post/src/components/header/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPostSavedState,\n\tPostPreviewButton,\n\tstore as editorStore,\n\tDocumentBar,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\tPopover,\n} from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport FullscreenModeClose from './fullscreen-mode-close';\nimport HeaderToolbar from './header-toolbar';\nimport MoreMenu from './more-menu';\nimport PostPublishButtonOrToggle from './post-publish-button-or-toggle';\nimport ViewLink from '../view-link';\nimport MainDashboardButton from './main-dashboard-button';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { PreviewDropdown } = unlock( editorPrivateApis );\n\nconst slideY = {\n\thidden: { y: '-50px' },\n\tdistractionFreeInactive: { y: 0 },\n\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nconst slideX = {\n\thidden: { x: '-100%' },\n\tdistractionFreeInactive: { x: 0 },\n\thover: { x: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nfunction Header( {\n\tsetEntitiesSavedStatesCallback,\n\tsetListViewToggleElement,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst blockToolbarRef = useRef();\n\tconst {\n\t\tblockSelectionStart,\n\t\thasActiveMetaboxes,\n\t\thasFixedToolbar,\n\t\tisEditingTemplate,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\n\t\treturn {\n\t\t\tblockSelectionStart:\n\t\t\t\tselect( blockEditorStore ).getBlockSelectionStart(),\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\tisEditingTemplate:\n\t\t\t\tselect( editorStore ).getRenderingMode() === 'template-only',\n\t\t\tisPublishSidebarOpened:\n\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\thasFixedToolbar: getPreference( 'core/edit-post', 'fixedToolbar' ),\n\t\t\tshowIconLabels:\n\t\t\t\tselect( editPostStore ).isFeatureActive( 'showIconLabels' ),\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasBlockSelected = !! blockSelectionStart;\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( blockSelectionStart ) {\n\t\t\tsetIsBlockToolsCollapsed( false );\n\t\t}\n\t}, [ blockSelectionStart ] );\n\n\treturn (\n\t\t<div className=\"edit-post-header\">\n\t\t\t<MainDashboardButton.Slot>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ slideX }\n\t\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\t>\n\t\t\t\t\t<FullscreenModeClose showTooltip />\n\t\t\t\t</motion.div>\n\t\t\t</MainDashboardButton.Slot>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__toolbar\"\n\t\t\t>\n\t\t\t\t<HeaderToolbar\n\t\t\t\t\thasFixedToolbar={ hasFixedToolbar }\n\t\t\t\t\tsetListViewToggleElement={ setListViewToggleElement }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'selected-block-tools-wrapper',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\t\t\t\tisEditingTemplate &&\n\t\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isEditingTemplate && hasBlockSelected && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-post-header__block-tools-toggle\"\n\t\t\t\t\t\t\t\ticon={ isBlockToolsCollapsed ? next : previous }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsBlockToolsCollapsed(\n\t\t\t\t\t\t\t\t\t\t( collapsed ) => ! collapsed\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed\n\t\t\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-post-header__center', {\n\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\tisEditingTemplate &&\n\t\t\t\t\t\t\thasBlockSelected &&\n\t\t\t\t\t\t\t! isBlockToolsCollapsed &&\n\t\t\t\t\t\t\thasFixedToolbar &&\n\t\t\t\t\t\t\tisLargeViewport,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ isEditingTemplate && <DocumentBar /> }\n\t\t\t\t</div>\n\t\t\t</motion.div>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState\n\t\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tshowIconLabels={ showIconLabels }\n\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"edit-post-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t/>\n\t\t\t\t<ViewLink />\n\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-post\" />\n\t\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ showIconLabels && ! isWideViewport && (\n\t\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t\t) }\n\t\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Y,EAAGhD,kBAAoB;IACnCI,cAAc,EAAGA;EAAgB,CACjC,CACD,EACD,IAAAkB,MAAA,CAAAC,aAAA,EAAC7C,eAAe;IACf0B,cAAc,EAAGA,cAAgB;IACjC6C,mBAAmB,EAAGjD;EAAoB,CAC1C,CAAC,EACF,IAAAsB,MAAA,CAAAC,aAAA,EAAC9D,OAAA,CAAAyF,iBAAiB;IACjB1B,SAAS,EAAC,uCAAuC;IACjDyB,mBAAmB,EAAGjD;EAAoB,CAC1C,CAAC,EACF,IAAAsB,MAAA,CAAAC,aAAA,EAACjD,SAAA,CAAAmD,OAAQ,MAAE,CAAC,EACZ,IAAAH,MAAA,CAAAC,aAAA,EAAClD,0BAAA,CAAAoD,OAAyB;IACzBuB,YAAY,EAAGhD,kBAAoB;IACnCR,8BAA8B,EAC7BA;EACA,CACD,CAAC,EACA,CAAEE,cAAc,IAAI,CAAEU,cAAc,KACrC,IAAAkB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAS,QAAA,QACC,IAAAT,MAAA,CAAAC,aAAA,EAACzD,UAAA,CAAAqF,WAAW,CAACzB,IAAI;IAAC0B,KAAK,EAAC;EAAgB,CAAE,CAAC,EAC3C,IAAA9B,MAAA,CAAAC,aAAA,EAACnD,SAAA,CAAAqD,OAAQ;IAACrB,cAAc,EAAGA;EAAgB,CAAE,CAC5C,CACF,EACCA,cAAc,IAAI,CAAEV,cAAc,IACnC,IAAA4B,MAAA,CAAAC,aAAA,EAACnD,SAAA,CAAAqD,OAAQ;IAACrB,cAAc,EAAGA;EAAgB,CAAE,CAEnC,CACR,CAAC;AAER;AAAC,IAAAiD,QAAA,GAEc9D,MAAM;AAAA+D,OAAA,CAAA7B,OAAA,GAAA4B,QAAA"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_blockEditor","_editor","_element","_data","_i18n","_icons","_interface","_compose","_components","_preferences","_fullscreenModeClose","_moreMenu","_postPublishButtonOrToggle","_mainDashboardButton","_store","_lockUnlock","DocumentTools","PostViewLink","PreviewDropdown","unlock","editorPrivateApis","slideY","hidden","y","distractionFreeInactive","hover","transition","type","delay","slideX","x","Header","setEntitiesSavedStatesCallback","isWideViewport","useViewportMatch","isLargeViewport","blockToolbarRef","useRef","isTextEditor","hasBlockSelection","hasActiveMetaboxes","hasFixedToolbar","isEditingTemplate","isPublishSidebarOpened","showIconLabels","hasHistory","useSelect","select","get","getPreference","preferencesStore","getEditorMode","editPostStore","blockEditorStore","getBlockSelectionStart","hasMetaBoxes","editorStore","getEditorSettings","goBack","getRenderingMode","isBlockToolsCollapsed","setIsBlockToolsCollapsed","useState","useEffect","_react","createElement","className","default","Slot","__unstableMotion","div","variants","showTooltip","disableBlockTools","Fragment","classnames","BlockToolbar","hideDragHandle","Popover","ref","name","Button","icon","next","previous","onClick","collapsed","label","__","DocumentBar","PostSavedState","forceIsDirty","forceIsAutosaveable","PostPreviewButton","PinnedItems","scope","_default","exports"],"sources":["@wordpress/edit-post/src/components/header/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockToolbar,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPostSavedState,\n\tPostPreviewButton,\n\tstore as editorStore,\n\tDocumentBar,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { next, previous } from '@wordpress/icons';\nimport { PinnedItems } from '@wordpress/interface';\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tButton,\n\t__unstableMotion as motion,\n\tPopover,\n} from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport FullscreenModeClose from './fullscreen-mode-close';\nimport MoreMenu from './more-menu';\nimport PostPublishButtonOrToggle from './post-publish-button-or-toggle';\nimport MainDashboardButton from './main-dashboard-button';\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { DocumentTools, PostViewLink, PreviewDropdown } =\n\tunlock( editorPrivateApis );\n\nconst slideY = {\n\thidden: { y: '-50px' },\n\tdistractionFreeInactive: { y: 0 },\n\thover: { y: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nconst slideX = {\n\thidden: { x: '-100%' },\n\tdistractionFreeInactive: { x: 0 },\n\thover: { x: 0, transition: { type: 'tween', delay: 0.2 } },\n};\n\nfunction Header( { setEntitiesSavedStatesCallback } ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst blockToolbarRef = useRef();\n\tconst {\n\t\tisTextEditor,\n\t\thasBlockSelection,\n\t\thasActiveMetaboxes,\n\t\thasFixedToolbar,\n\t\tisEditingTemplate,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasHistory,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\thasActiveMetaboxes: select( editPostStore ).hasMetaBoxes(),\n\t\t\thasHistory: !! select( editorStore ).getEditorSettings().goBack,\n\t\t\tisEditingTemplate:\n\t\t\t\tselect( editorStore ).getRenderingMode() === 'template-only',\n\t\t\tisPublishSidebarOpened:\n\t\t\t\tselect( editPostStore ).isPublishSidebarOpened(),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tuseEffect( () => {\n\t\t// If we have a new block selection, show the block tools\n\t\tif ( hasBlockSelection ) {\n\t\t\tsetIsBlockToolsCollapsed( false );\n\t\t}\n\t}, [ hasBlockSelection ] );\n\n\treturn (\n\t\t<div className=\"edit-post-header\">\n\t\t\t<MainDashboardButton.Slot>\n\t\t\t\t<motion.div\n\t\t\t\t\tvariants={ slideX }\n\t\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\t>\n\t\t\t\t\t<FullscreenModeClose showTooltip />\n\t\t\t\t</motion.div>\n\t\t\t</MainDashboardButton.Slot>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__toolbar\"\n\t\t\t>\n\t\t\t\t<DocumentTools disableBlockTools={ isTextEditor } />\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'selected-block-tools-wrapper',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\t\t\t\tisEditingTemplate &&\n\t\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockToolbar hideDragHandle />\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<Popover.Slot\n\t\t\t\t\t\t\tref={ blockToolbarRef }\n\t\t\t\t\t\t\tname=\"block-toolbar\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ isEditingTemplate && hasBlockSelection && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tclassName=\"edit-post-header__block-tools-toggle\"\n\t\t\t\t\t\t\t\ticon={ isBlockToolsCollapsed ? next : previous }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tsetIsBlockToolsCollapsed(\n\t\t\t\t\t\t\t\t\t\t( collapsed ) => ! collapsed\n\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\t\t\tisBlockToolsCollapsed\n\t\t\t\t\t\t\t\t\t\t? __( 'Show block tools' )\n\t\t\t\t\t\t\t\t\t\t: __( 'Hide block tools' )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div\n\t\t\t\t\tclassName={ classnames( 'edit-post-header__center', {\n\t\t\t\t\t\t'is-collapsed':\n\t\t\t\t\t\t\tisEditingTemplate &&\n\t\t\t\t\t\t\thasBlockSelection &&\n\t\t\t\t\t\t\t! isBlockToolsCollapsed &&\n\t\t\t\t\t\t\thasFixedToolbar &&\n\t\t\t\t\t\t\tisLargeViewport,\n\t\t\t\t\t} ) }\n\t\t\t\t>\n\t\t\t\t\t{ ( isEditingTemplate || hasHistory ) && <DocumentBar /> }\n\t\t\t\t</div>\n\t\t\t</motion.div>\n\t\t\t<motion.div\n\t\t\t\tvariants={ slideY }\n\t\t\t\ttransition={ { type: 'tween', delay: 0.8 } }\n\t\t\t\tclassName=\"edit-post-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ hasActiveMetaboxes } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown forceIsAutosaveable={ hasActiveMetaboxes } />\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"edit-post-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ hasActiveMetaboxes }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\tforceIsDirty={ hasActiveMetaboxes }\n\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core/edit-post\" />\n\t\t\t\t) }\n\t\t\t\t<MoreMenu showIconLabels={ showIconLabels } />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,YAAA,GAAAD,OAAA;AAIA,IAAAE,OAAA,GAAAF,OAAA;AAOA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,QAAA,GAAAR,OAAA;AACA,IAAAS,WAAA,GAAAT,OAAA;AAKA,IAAAU,YAAA,GAAAV,OAAA;AAKA,IAAAW,oBAAA,GAAAZ,sBAAA,CAAAC,OAAA;AACA,IAAAY,SAAA,GAAAb,sBAAA,CAAAC,OAAA;AACA,IAAAa,0BAAA,GAAAd,sBAAA,CAAAC,OAAA;AACA,IAAAc,oBAAA,GAAAf,sBAAA,CAAAC,OAAA;AACA,IAAAe,MAAA,GAAAf,OAAA;AACA,IAAAgB,WAAA,GAAAhB,OAAA;AAxCA;AACA;AACA;;AAGA;AACA;AACA;;AAyBA;AACA;AACA;;AAQA,MAAM;EAAEiB,aAAa;EAAEC,YAAY;EAAEC;AAAgB,CAAC,GACrD,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAE5B,MA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AA,GAAA6B,QAAA"}
|
|
@@ -11,6 +11,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
11
11
|
var _compose = require("@wordpress/compose");
|
|
12
12
|
var _keycodes = require("@wordpress/keycodes");
|
|
13
13
|
var _preferences = require("@wordpress/preferences");
|
|
14
|
+
var _editor = require("@wordpress/editor");
|
|
14
15
|
var _store = require("../../../store");
|
|
15
16
|
/**
|
|
16
17
|
* WordPress dependencies
|
|
@@ -23,23 +24,25 @@ var _store = require("../../../store");
|
|
|
23
24
|
function WritingMenu() {
|
|
24
25
|
const registry = (0, _data.useRegistry)();
|
|
25
26
|
const {
|
|
26
|
-
setIsInserterOpened,
|
|
27
|
-
setIsListViewOpened,
|
|
28
27
|
closeGeneralSidebar
|
|
29
28
|
} = (0, _data.useDispatch)(_store.store);
|
|
30
29
|
const {
|
|
31
30
|
set: setPreference
|
|
32
31
|
} = (0, _data.useDispatch)(_preferences.store);
|
|
32
|
+
const {
|
|
33
|
+
setIsInserterOpened,
|
|
34
|
+
setIsListViewOpened
|
|
35
|
+
} = (0, _data.useDispatch)(_editor.store);
|
|
33
36
|
const toggleDistractionFree = () => {
|
|
34
37
|
registry.batch(() => {
|
|
35
|
-
setPreference('core
|
|
38
|
+
setPreference('core', 'fixedToolbar', true);
|
|
36
39
|
setIsInserterOpened(false);
|
|
37
40
|
setIsListViewOpened(false);
|
|
38
41
|
closeGeneralSidebar();
|
|
39
42
|
});
|
|
40
43
|
};
|
|
41
44
|
const turnOffDistractionFree = () => {
|
|
42
|
-
setPreference('core
|
|
45
|
+
setPreference('core', 'distractionFree', false);
|
|
43
46
|
};
|
|
44
47
|
const isLargeViewport = (0, _compose.useViewportMatch)('medium');
|
|
45
48
|
if (!isLargeViewport) {
|
|
@@ -48,7 +51,7 @@ function WritingMenu() {
|
|
|
48
51
|
return (0, _react.createElement)(_components.MenuGroup, {
|
|
49
52
|
label: (0, _i18n._x)('View', 'noun')
|
|
50
53
|
}, (0, _react.createElement)(_preferences.PreferenceToggleMenuItem, {
|
|
51
|
-
scope: "core
|
|
54
|
+
scope: "core",
|
|
52
55
|
name: "fixedToolbar",
|
|
53
56
|
onToggle: turnOffDistractionFree,
|
|
54
57
|
label: (0, _i18n.__)('Top toolbar'),
|
|
@@ -56,7 +59,7 @@ function WritingMenu() {
|
|
|
56
59
|
messageActivated: (0, _i18n.__)('Top toolbar activated'),
|
|
57
60
|
messageDeactivated: (0, _i18n.__)('Top toolbar deactivated')
|
|
58
61
|
}), (0, _react.createElement)(_preferences.PreferenceToggleMenuItem, {
|
|
59
|
-
scope: "core
|
|
62
|
+
scope: "core",
|
|
60
63
|
name: "distractionFree",
|
|
61
64
|
onToggle: toggleDistractionFree,
|
|
62
65
|
label: (0, _i18n.__)('Distraction free'),
|
|
@@ -65,7 +68,7 @@ function WritingMenu() {
|
|
|
65
68
|
messageDeactivated: (0, _i18n.__)('Distraction free mode deactivated'),
|
|
66
69
|
shortcut: _keycodes.displayShortcut.primaryShift('\\')
|
|
67
70
|
}), (0, _react.createElement)(_preferences.PreferenceToggleMenuItem, {
|
|
68
|
-
scope: "core
|
|
71
|
+
scope: "core",
|
|
69
72
|
name: "focusMode",
|
|
70
73
|
label: (0, _i18n.__)('Spotlight mode'),
|
|
71
74
|
info: (0, _i18n.__)('Focus on one block at a time'),
|
|
@@ -75,7 +78,7 @@ function WritingMenu() {
|
|
|
75
78
|
scope: "core/edit-post",
|
|
76
79
|
name: "fullscreenMode",
|
|
77
80
|
label: (0, _i18n.__)('Fullscreen mode'),
|
|
78
|
-
info: (0, _i18n.__)('Show and hide admin
|
|
81
|
+
info: (0, _i18n.__)('Show and hide the admin user interface'),
|
|
79
82
|
messageActivated: (0, _i18n.__)('Fullscreen mode activated'),
|
|
80
83
|
messageDeactivated: (0, _i18n.__)('Fullscreen mode deactivated'),
|
|
81
84
|
shortcut: _keycodes.displayShortcut.secondary('f')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_components","_i18n","_compose","_keycodes","_preferences","_store","WritingMenu","registry","useRegistry","
|
|
1
|
+
{"version":3,"names":["_data","require","_components","_i18n","_compose","_keycodes","_preferences","_editor","_store","WritingMenu","registry","useRegistry","closeGeneralSidebar","useDispatch","postEditorStore","set","setPreference","preferencesStore","setIsInserterOpened","setIsListViewOpened","editorStore","toggleDistractionFree","batch","turnOffDistractionFree","isLargeViewport","useViewportMatch","_react","createElement","MenuGroup","label","_x","PreferenceToggleMenuItem","scope","name","onToggle","__","info","messageActivated","messageDeactivated","shortcut","displayShortcut","primaryShift","secondary","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/header/writing-menu/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { MenuGroup } from '@wordpress/components';\nimport { __, _x } from '@wordpress/i18n';\nimport { useViewportMatch } from '@wordpress/compose';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport {\n\tPreferenceToggleMenuItem,\n\tstore as preferencesStore,\n} from '@wordpress/preferences';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport { store as postEditorStore } from '../../../store';\n\nfunction WritingMenu() {\n\tconst registry = useRegistry();\n\n\tconst { closeGeneralSidebar } = useDispatch( postEditorStore );\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tconst { setIsInserterOpened, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\n\tconst toggleDistractionFree = () => {\n\t\tregistry.batch( () => {\n\t\t\tsetPreference( 'core', 'fixedToolbar', true );\n\t\t\tsetIsInserterOpened( false );\n\t\t\tsetIsListViewOpened( false );\n\t\t\tcloseGeneralSidebar();\n\t\t} );\n\t};\n\n\tconst turnOffDistractionFree = () => {\n\t\tsetPreference( 'core', 'distractionFree', false );\n\t};\n\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tif ( ! isLargeViewport ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<MenuGroup label={ _x( 'View', 'noun' ) }>\n\t\t\t<PreferenceToggleMenuItem\n\t\t\t\tscope=\"core\"\n\t\t\t\tname=\"fixedToolbar\"\n\t\t\t\tonToggle={ turnOffDistractionFree }\n\t\t\t\tlabel={ __( 'Top toolbar' ) }\n\t\t\t\tinfo={ __(\n\t\t\t\t\t'Access all block and document tools in a single place'\n\t\t\t\t) }\n\t\t\t\tmessageActivated={ __( 'Top toolbar activated' ) }\n\t\t\t\tmessageDeactivated={ __( 'Top toolbar deactivated' ) }\n\t\t\t/>\n\t\t\t<PreferenceToggleMenuItem\n\t\t\t\tscope=\"core\"\n\t\t\t\tname=\"distractionFree\"\n\t\t\t\tonToggle={ toggleDistractionFree }\n\t\t\t\tlabel={ __( 'Distraction free' ) }\n\t\t\t\tinfo={ __( 'Write with calmness' ) }\n\t\t\t\tmessageActivated={ __( 'Distraction free mode activated' ) }\n\t\t\t\tmessageDeactivated={ __( 'Distraction free mode deactivated' ) }\n\t\t\t\tshortcut={ displayShortcut.primaryShift( '\\\\' ) }\n\t\t\t/>\n\t\t\t<PreferenceToggleMenuItem\n\t\t\t\tscope=\"core\"\n\t\t\t\tname=\"focusMode\"\n\t\t\t\tlabel={ __( 'Spotlight mode' ) }\n\t\t\t\tinfo={ __( 'Focus on one block at a time' ) }\n\t\t\t\tmessageActivated={ __( 'Spotlight mode activated' ) }\n\t\t\t\tmessageDeactivated={ __( 'Spotlight mode deactivated' ) }\n\t\t\t/>\n\t\t\t<PreferenceToggleMenuItem\n\t\t\t\tscope=\"core/edit-post\"\n\t\t\t\tname=\"fullscreenMode\"\n\t\t\t\tlabel={ __( 'Fullscreen mode' ) }\n\t\t\t\tinfo={ __( 'Show and hide the admin user interface' ) }\n\t\t\t\tmessageActivated={ __( 'Fullscreen mode activated' ) }\n\t\t\t\tmessageDeactivated={ __( 'Fullscreen mode deactivated' ) }\n\t\t\t\tshortcut={ displayShortcut.secondary( 'f' ) }\n\t\t\t/>\n\t\t</MenuGroup>\n\t);\n}\n\nexport default WritingMenu;\n"],"mappings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,EAAC,gBAAgB;IACtBC,IAAI,EAAC,gBAAgB;IACrBJ,KAAK,EAAG,IAAAM,QAAE,EAAE,iBAAkB,CAAG;IACjCC,IAAI,EAAG,IAAAD,QAAE,EAAE,wCAAyC,CAAG;IACvDE,gBAAgB,EAAG,IAAAF,QAAE,EAAE,2BAA4B,CAAG;IACtDG,kBAAkB,EAAG,IAAAH,QAAE,EAAE,6BAA8B,CAAG;IAC1DI,QAAQ,EAAGC,yBAAe,CAACE,SAAS,CAAE,GAAI;EAAG,CAC7C,CACS,CAAC;AAEd;AAAC,IAAAC,QAAA,GAEclC,WAAW;AAAAmC,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
@@ -23,8 +23,7 @@ var _store = require("../../store");
|
|
|
23
23
|
function KeyboardShortcuts() {
|
|
24
24
|
const {
|
|
25
25
|
getEditorMode,
|
|
26
|
-
isEditorSidebarOpened
|
|
27
|
-
isListViewOpened
|
|
26
|
+
isEditorSidebarOpened
|
|
28
27
|
} = (0, _data.useSelect)(_store.store);
|
|
29
28
|
const isModeToggleDisabled = (0, _data.useSelect)(select => {
|
|
30
29
|
const {
|
|
@@ -38,7 +37,6 @@ function KeyboardShortcuts() {
|
|
|
38
37
|
openGeneralSidebar,
|
|
39
38
|
closeGeneralSidebar,
|
|
40
39
|
toggleFeature,
|
|
41
|
-
setIsListViewOpened,
|
|
42
40
|
toggleDistractionFree
|
|
43
41
|
} = (0, _data.useDispatch)(_store.store);
|
|
44
42
|
const {
|
|
@@ -103,15 +101,6 @@ function KeyboardShortcuts() {
|
|
|
103
101
|
character: 'f'
|
|
104
102
|
}
|
|
105
103
|
});
|
|
106
|
-
registerShortcut({
|
|
107
|
-
name: 'core/edit-post/toggle-list-view',
|
|
108
|
-
category: 'global',
|
|
109
|
-
description: (0, _i18n.__)('Open the block list view.'),
|
|
110
|
-
keyCombination: {
|
|
111
|
-
modifier: 'access',
|
|
112
|
-
character: 'o'
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
104
|
registerShortcut({
|
|
116
105
|
name: 'core/edit-post/toggle-sidebar',
|
|
117
106
|
category: 'global',
|
|
@@ -202,14 +191,6 @@ function KeyboardShortcuts() {
|
|
|
202
191
|
openGeneralSidebar(sidebarToOpen);
|
|
203
192
|
}
|
|
204
193
|
});
|
|
205
|
-
|
|
206
|
-
// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
|
|
207
|
-
(0, _keyboardShortcuts.useShortcut)('core/edit-post/toggle-list-view', event => {
|
|
208
|
-
if (!isListViewOpened()) {
|
|
209
|
-
event.preventDefault();
|
|
210
|
-
setIsListViewOpened(true);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
194
|
(0, _keyboardShortcuts.useShortcut)('core/edit-post/transform-heading-to-paragraph', event => handleTextLevelShortcut(event, 0));
|
|
214
195
|
[1, 2, 3, 4, 5, 6].forEach(level => {
|
|
215
196
|
//the loop is based off on a constant therefore
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_element","require","_data","_keyboardShortcuts","_i18n","_editor","_blockEditor","_blocks","_store","KeyboardShortcuts","getEditorMode","isEditorSidebarOpened","isListViewOpened","useSelect","editPostStore","isModeToggleDisabled","select","richEditingEnabled","codeEditingEnabled","editorStore","getEditorSettings","switchEditorMode","openGeneralSidebar","closeGeneralSidebar","toggleFeature","setIsListViewOpened","toggleDistractionFree","useDispatch","registerShortcut","keyboardShortcutsStore","replaceBlocks","blockEditorStore","getBlockName","getSelectedBlockClientId","getBlockAttributes","getBlockSelectionStart","handleTextLevelShortcut","event","level","preventDefault","destinationBlockName","currentClientId","blockName","attributes","textAlign","destinationTextAlign","createBlock","content","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","forEach","useShortcut","isDisabled","sidebarToOpen","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { getEditorMode, isEditorSidebarOpened, isListViewOpened } =\n\t\tuseSelect( editPostStore );\n\tconst isModeToggleDisabled = useSelect( ( select ) => {\n\t\tconst { richEditingEnabled, codeEditingEnabled } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\treturn ! richEditingEnabled || ! codeEditingEnabled;\n\t}, [] );\n\n\tconst {\n\t\tswitchEditorMode,\n\t\topenGeneralSidebar,\n\t\tcloseGeneralSidebar,\n\t\ttoggleFeature,\n\t\tsetIsListViewOpened,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editPostStore );\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockAttributes,\n\t\tgetBlockSelectionStart,\n\t} = useSelect( blockEditorStore );\n\n\tconst handleTextLevelShortcut = ( event, level ) => {\n\t\tevent.preventDefault();\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tif ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\t\tconst textAlign =\n\t\t\tblockName === 'core/paragraph' ? 'align' : 'textAlign';\n\t\tconst destinationTextAlign =\n\t\t\tdestinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, {\n\t\t\t\tlevel,\n\t\t\t\tcontent: attributes.content,\n\t\t\t\t...{ [ destinationTextAlign ]: attributes[ textAlign ] },\n\t\t\t} )\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-mode',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Switch between visual editor and code editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'm',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-distraction-free',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Toggle distraction free mode.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: '\\\\',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-fullscreen',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Toggle fullscreen mode.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'f',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-list-view',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Open the block list view.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'o',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-sidebar',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Show or hide the Settings sidebar.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: ',',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: `0`,\n\t\t\t},\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/edit-post/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [] );\n\n\tuseShortcut(\n\t\t'core/edit-post/toggle-mode',\n\t\t() => {\n\t\t\tswitchEditorMode(\n\t\t\t\tgetEditorMode() === 'visual' ? 'text' : 'visual'\n\t\t\t);\n\t\t},\n\t\t{\n\t\t\tisDisabled: isModeToggleDisabled,\n\t\t}\n\t);\n\n\tuseShortcut( 'core/edit-post/toggle-fullscreen', () => {\n\t\ttoggleFeature( 'fullscreenMode' );\n\t} );\n\n\tuseShortcut( 'core/edit-post/toggle-distraction-free', () => {\n\t\ttoggleDistractionFree();\n\t} );\n\n\tuseShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {\n\t\t// This shortcut has no known clashes, but use preventDefault to prevent any\n\t\t// obscure shortcuts from triggering.\n\t\tevent.preventDefault();\n\n\t\tif ( isEditorSidebarOpened() ) {\n\t\t\tcloseGeneralSidebar();\n\t\t} else {\n\t\t\tconst sidebarToOpen = getBlockSelectionStart()\n\t\t\t\t? 'edit-post/block'\n\t\t\t\t: 'edit-post/document';\n\t\t\topenGeneralSidebar( sidebarToOpen );\n\t\t}\n\t} );\n\n\t// Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.\n\tuseShortcut( 'core/edit-post/toggle-list-view', ( event ) => {\n\t\tif ( ! isListViewOpened() ) {\n\t\t\tevent.preventDefault();\n\t\t\tsetIsListViewOpened( true );\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-post/transform-heading-to-paragraph', ( event ) =>\n\t\thandleTextLevelShortcut( event, 0 )\n\t);\n\n\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t//the loop is based off on a constant therefore\n\t\t//the hook will execute the same way every time\n\t\t//eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tuseShortcut(\n\t\t\t`core/edit-post/transform-paragraph-to-heading-${ level }`,\n\t\t\t( event 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AC;EAEH,IAAAkC,8BAAW,EAAE,wCAAwC,EAAE,MAAM;IAC5DhC,qBAAqB,CAAC,CAAC;EACxB,CAAE,CAAC;EAEH,IAAAgC,8BAAW,EAAE,+BAA+B,EAAIrB,KAAK,IAAM;IAC1D;IACA;IACAA,KAAK,CAACE,cAAc,CAAC,CAAC;IAEtB,IAAK5B,qBAAqB,CAAC,CAAC,EAAG;MAC9BY,mBAAmB,CAAC,CAAC;IACtB,CAAC,MAAM;MACN,MAAMqC,aAAa,GAAGzB,sBAAsB,CAAC,CAAC,GAC3C,iBAAiB,GACjB,oBAAoB;MACvBb,kBAAkB,CAAEsC,aAAc,CAAC;IACpC;EACD,CAAE,CAAC;;EAEH;EACA,IAAAF,8BAAW,EAAE,iCAAiC,EAAIrB,KAAK,IAAM;IAC5D,IAAK,CAAEzB,gBAAgB,CAAC,CAAC,EAAG;MAC3ByB,KAAK,CAACE,cAAc,CAAC,CAAC;MACtBd,mBAAmB,CAAE,IAAK,CAAC;IAC5B;EACD,CAAE,CAAC;EAEH,IAAAiC,8BAAW,EAAE,+CAA+C,EAAIrB,KAAK,IACpED,uBAAuB,CAAEC,KAAK,EAAE,CAAE,CACnC,CAAC;EAED,CAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE,CAACoB,OAAO,CAAInB,KAAK,IAAM;IAC1C;IACA;IACA;IACA,IAAAoB,8BAAW,EACT,iDAAiDpB,KAAO,EAAC,EACxDD,KAAK,IAAMD,uBAAuB,CAAEC,KAAK,EAAEC,KAAM,CACpD,CAAC;EACF,CAAE,CAAC;EAEH,OAAO,IAAI;AACZ;AAAC,IAAAuB,QAAA,GAEcpD,iBAAiB;AAAAqD,OAAA,CAAAC,OAAA,GAAAF,QAAA"}
|
|
1
|
+
{"version":3,"names":["_element","require","_data","_keyboardShortcuts","_i18n","_editor","_blockEditor","_blocks","_store","KeyboardShortcuts","getEditorMode","isEditorSidebarOpened","useSelect","editPostStore","isModeToggleDisabled","select","richEditingEnabled","codeEditingEnabled","editorStore","getEditorSettings","switchEditorMode","openGeneralSidebar","closeGeneralSidebar","toggleFeature","toggleDistractionFree","useDispatch","registerShortcut","keyboardShortcutsStore","replaceBlocks","blockEditorStore","getBlockName","getSelectedBlockClientId","getBlockAttributes","getBlockSelectionStart","handleTextLevelShortcut","event","level","preventDefault","destinationBlockName","currentClientId","blockName","attributes","textAlign","destinationTextAlign","createBlock","content","useEffect","name","category","description","__","keyCombination","modifier","character","aliases","forEach","useShortcut","isDisabled","sidebarToOpen","_default","exports","default"],"sources":["@wordpress/edit-post/src/components/keyboard-shortcuts/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nfunction KeyboardShortcuts() {\n\tconst { getEditorMode, isEditorSidebarOpened } = useSelect( editPostStore );\n\tconst isModeToggleDisabled = useSelect( ( select ) => {\n\t\tconst { richEditingEnabled, codeEditingEnabled } =\n\t\t\tselect( editorStore ).getEditorSettings();\n\t\treturn ! richEditingEnabled || ! codeEditingEnabled;\n\t}, [] );\n\tconst {\n\t\tswitchEditorMode,\n\t\topenGeneralSidebar,\n\t\tcloseGeneralSidebar,\n\t\ttoggleFeature,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editPostStore );\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst {\n\t\tgetBlockName,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockAttributes,\n\t\tgetBlockSelectionStart,\n\t} = useSelect( blockEditorStore );\n\n\tconst handleTextLevelShortcut = ( event, level ) => {\n\t\tevent.preventDefault();\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tif ( blockName !== 'core/paragraph' && blockName !== 'core/heading' ) {\n\t\t\treturn;\n\t\t}\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\t\tconst textAlign =\n\t\t\tblockName === 'core/paragraph' ? 'align' : 'textAlign';\n\t\tconst destinationTextAlign =\n\t\t\tdestinationBlockName === 'core/paragraph' ? 'align' : 'textAlign';\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, {\n\t\t\t\tlevel,\n\t\t\t\tcontent: attributes.content,\n\t\t\t\t...{ [ destinationTextAlign ]: attributes[ textAlign ] },\n\t\t\t} )\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-mode',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Switch between visual editor and code editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'm',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-distraction-free',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Toggle distraction free mode.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: '\\\\',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-fullscreen',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Toggle fullscreen mode.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'secondary',\n\t\t\t\tcharacter: 'f',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/toggle-sidebar',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Show or hide the Settings sidebar.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'primaryShift',\n\t\t\t\tcharacter: ',',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/next-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the next part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrl',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'n',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/previous-region',\n\t\t\tcategory: 'global',\n\t\t\tdescription: __( 'Navigate to the previous part of the editor.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\tcharacter: '`',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: 'p',\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'ctrlShift',\n\t\t\t\t\tcharacter: '~',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/keyboard-shortcuts',\n\t\t\tcategory: 'main',\n\t\t\tdescription: __( 'Display these keyboard shortcuts.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: 'h',\n\t\t\t},\n\t\t} );\n\n\t\tregisterShortcut( {\n\t\t\tname: 'core/edit-post/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: `0`,\n\t\t\t},\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/edit-post/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [] );\n\n\tuseShortcut(\n\t\t'core/edit-post/toggle-mode',\n\t\t() => {\n\t\t\tswitchEditorMode(\n\t\t\t\tgetEditorMode() === 'visual' ? 'text' : 'visual'\n\t\t\t);\n\t\t},\n\t\t{\n\t\t\tisDisabled: isModeToggleDisabled,\n\t\t}\n\t);\n\n\tuseShortcut( 'core/edit-post/toggle-fullscreen', () => {\n\t\ttoggleFeature( 'fullscreenMode' );\n\t} );\n\n\tuseShortcut( 'core/edit-post/toggle-distraction-free', () => {\n\t\ttoggleDistractionFree();\n\t} );\n\n\tuseShortcut( 'core/edit-post/toggle-sidebar', ( event ) => {\n\t\t// This shortcut has no known clashes, but use preventDefault to prevent any\n\t\t// obscure shortcuts from triggering.\n\t\tevent.preventDefault();\n\n\t\tif ( isEditorSidebarOpened() ) {\n\t\t\tcloseGeneralSidebar();\n\t\t} else {\n\t\t\tconst sidebarToOpen = getBlockSelectionStart()\n\t\t\t\t? 'edit-post/block'\n\t\t\t\t: 'edit-post/document';\n\t\t\topenGeneralSidebar( sidebarToOpen );\n\t\t}\n\t} );\n\n\tuseShortcut( 'core/edit-post/transform-heading-to-paragraph', ( event ) =>\n\t\thandleTextLevelShortcut( event, 0 )\n\t);\n\n\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t//the loop is based off on a constant therefore\n\t\t//the hook will execute the same way every time\n\t\t//eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tuseShortcut(\n\t\t\t`core/edit-post/transform-paragraph-to-heading-${ level }`,\n\t\t\t( event ) => handleTextLevelShortcut( event, level )\n\t\t);\n\t} );\n\n\treturn null;\n}\n\nexport default KeyboardShortcuts;\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,kBAAA,GAAAF,OAAA;AAIA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,YAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAjBA;AACA;AACA;;AAYA;AACA;AACA;;AAGA,SAASQ,iBAAiBA,CAAA,EAAG;EAC5B,MAAM;IAAEC,aAAa;IAAEC;EAAsB,CAAC,GAAG,IAAAC,eAAS,EAAEC,YAAc,CAAC;EAC3E,MAAMC,oBAAoB,GAAG,IAAAF,eAAS,EAAIG,MAAM,IAAM;IACrD,MAAM;MAAEC,kBAAkB;MAAEC;IAAmB,CAAC,GAC/CF,MAAM,CAAEG,aAAY,CAAC,CAACC,iBAAiB,CAAC,CAAC;IAC1C,OAAO,CAAEH,kBAAkB,IAAI,CAAEC,kBAAkB;EACpD,CAAC,EAAE,EAAG,CAAC;EACP,MAAM;IACLG,gBAAgB;IAChBC,kBAAkB;IAClBC,mBAAmB;IACnBC,aAAa;IACbC;EACD,CAAC,GAAG,IAAAC,iBAAW,EAAEZ,YAAc,CAAC;EAChC,MAAM;IAAEa;EAAiB,CAAC,GAAG,IAAAD,iBAAW,EAAEE,wBAAuB,CAAC;EAClE,MAAM;IAAEC;EAAc,CAAC,GAAG,IAAAH,iBAAW,EAAEI,kBAAiB,CAAC;EACzD,MAAM;IACLC,YAAY;IACZC,wBAAwB;IACxBC,kBAAkB;IAClBC;EACD,CAAC,GAAG,IAAArB,eAAS,EAAEiB,kBAAiB,CAAC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