@wordpress/edit-post 7.28.5 → 7.30.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 +4 -0
- package/build/components/editor-initialization/index.js +3 -6
- package/build/components/editor-initialization/index.js.map +1 -1
- package/build/components/editor-initialization/listener-hooks.js +6 -10
- package/build/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.js +13 -7
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +16 -4
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +2 -6
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -38
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +2 -3
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +2 -5
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/text-editor/index.js +1 -1
- package/build/components/text-editor/index.js.map +1 -1
- package/build/editor.js +3 -31
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +2 -3
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +2 -135
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/index.js +0 -30
- package/build/index.js.map +1 -1
- package/build/index.native.js +0 -1
- package/build/index.native.js.map +1 -1
- package/build/store/actions.js +24 -77
- package/build/store/actions.js.map +1 -1
- package/build/store/selectors.js +0 -12
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/editor-initialization/index.js +3 -6
- package/build-module/components/editor-initialization/index.js.map +1 -1
- package/build-module/components/editor-initialization/listener-hooks.js +6 -10
- package/build-module/components/editor-initialization/listener-hooks.js.map +1 -1
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.js +14 -8
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +17 -5
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +2 -6
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -38
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +3 -4
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +2 -5
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/text-editor/index.js +1 -1
- package/build-module/components/text-editor/index.js.map +1 -1
- package/build-module/editor.js +4 -32
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -4
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +3 -136
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/index.js +0 -30
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +0 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/actions.js +23 -75
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/selectors.js +0 -12
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +10 -38
- package/build-style/style.css +10 -38
- package/package.json +32 -32
- package/src/components/editor-initialization/index.js +3 -4
- package/src/components/editor-initialization/listener-hooks.js +20 -22
- package/src/components/editor-initialization/test/listener-hooks.js +8 -8
- package/src/components/header/header-toolbar/index.native.js +1 -1
- package/src/components/header/index.js +23 -23
- package/src/components/header/more-menu/index.js +17 -10
- package/src/components/header/style.scss +4 -0
- package/src/components/header/test/index.js +4 -14
- package/src/components/header/writing-menu/index.js +2 -6
- package/src/components/keyboard-shortcuts/index.js +3 -50
- package/src/components/layout/index.js +3 -4
- package/src/components/layout/index.native.js +1 -3
- package/src/components/sidebar/plugin-post-publish-panel/test/index.js +1 -1
- package/src/components/text-editor/index.js +1 -1
- package/src/editor.js +32 -65
- package/src/editor.native.js +3 -4
- package/src/hooks/commands/use-common-commands.js +17 -170
- package/src/index.js +0 -44
- package/src/index.native.js +0 -1
- package/src/store/actions.js +24 -126
- package/src/store/selectors.js +0 -18
- package/src/store/test/actions.js +0 -146
- package/src/style.scss +1 -2
- package/build/components/header/mode-switcher/index.js +0 -87
- package/build/components/header/mode-switcher/index.js.map +0 -1
- package/build-module/components/header/mode-switcher/index.js +0 -81
- package/build-module/components/header/mode-switcher/index.js.map +0 -1
- package/src/components/header/mode-switcher/index.js +0 -91
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PostTextEditor","PostTitleRaw","store","editorStore","Button","useDispatch","useSelect","__","displayShortcut","useEffect","useRef","editPostStore","TextEditor","isRichEditingEnabled","select","getEditorSettings","richEditingEnabled","switchEditorMode","isWelcomeGuideVisible","isFeatureActive","titleRef","current","focus","createElement","className","variant","onClick","shortcut","secondary","ref"],"sources":["@wordpress/edit-post/src/components/text-editor/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPostTextEditor,\n\tPostTitleRaw,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function TextEditor() {\n\tconst isRichEditingEnabled = useSelect( ( select ) => {\n\t\treturn select( editorStore ).getEditorSettings().richEditingEnabled;\n\t}, [] );\n\tconst { switchEditorMode } = useDispatch(
|
|
1
|
+
{"version":3,"names":["PostTextEditor","PostTitleRaw","store","editorStore","Button","useDispatch","useSelect","__","displayShortcut","useEffect","useRef","editPostStore","TextEditor","isRichEditingEnabled","select","getEditorSettings","richEditingEnabled","switchEditorMode","isWelcomeGuideVisible","isFeatureActive","titleRef","current","focus","createElement","className","variant","onClick","shortcut","secondary","ref"],"sources":["@wordpress/edit-post/src/components/text-editor/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPostTextEditor,\n\tPostTitleRaw,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function TextEditor() {\n\tconst isRichEditingEnabled = useSelect( ( select ) => {\n\t\treturn select( editorStore ).getEditorSettings().richEditingEnabled;\n\t}, [] );\n\tconst { switchEditorMode } = useDispatch( editorStore );\n\n\tconst { isWelcomeGuideVisible } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn {\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t};\n\t}, [] );\n\n\tconst titleRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible ] );\n\n\treturn (\n\t\t<div className=\"edit-post-text-editor\">\n\t\t\t{ isRichEditingEnabled && (\n\t\t\t\t<div className=\"edit-post-text-editor__toolbar\">\n\t\t\t\t\t<h2>{ __( 'Editing code' ) }</h2>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => switchEditorMode( 'visual' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.secondary( 'm' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Exit code editor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"edit-post-text-editor__body\">\n\t\t\t\t<PostTitleRaw ref={ titleRef } />\n\t\t\t\t<PostTextEditor />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AAC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EAAC,UAAU;IAClBC,OAAO,EAAGA,CAAA,KAAMT,gBAAgB,CAAE,QAAS,CAAG;IAC9CU,QAAQ,EAAGnB,eAAe,CAACoB,SAAS,CAAE,GAAI;EAAG,GAE3CrB,EAAE,CAAE,kBAAmB,CAClB,CACJ,CACL,EACDgB,aAAA;IAAKC,SAAS,EAAC;EAA6B,GAC3CD,aAAA,CAACtB,YAAY;IAAC4B,GAAG,EAAGT;EAAU,CAAE,CAAC,EACjCG,aAAA,CAACvB,cAAc,MAAE,CACb,CACD,CAAC;AAER"}
|
package/build-module/editor.js
CHANGED
|
@@ -2,15 +2,12 @@ import { createElement } from "react";
|
|
|
2
2
|
/**
|
|
3
3
|
* WordPress dependencies
|
|
4
4
|
*/
|
|
5
|
-
import { useSelect
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { ErrorBoundary, PostLockedModal, store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
7
7
|
import { useMemo } from '@wordpress/element';
|
|
8
8
|
import { SlotFillProvider } from '@wordpress/components';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
10
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
11
10
|
import { CommandMenu } from '@wordpress/commands';
|
|
12
|
-
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
14
11
|
|
|
15
12
|
/**
|
|
16
13
|
* Internal dependencies
|
|
@@ -23,14 +20,6 @@ import useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';
|
|
|
23
20
|
const {
|
|
24
21
|
ExperimentalEditorProvider
|
|
25
22
|
} = unlock(editorPrivateApis);
|
|
26
|
-
const {
|
|
27
|
-
BlockRemovalWarningModal
|
|
28
|
-
} = unlock(blockEditorPrivateApis);
|
|
29
|
-
// Prevent accidental removal of certain blocks, asking the user for
|
|
30
|
-
// confirmation.
|
|
31
|
-
const blockRemovalRules = {
|
|
32
|
-
'bindings/core/pattern-overrides': __('Blocks from synced patterns that can have overriden content.')
|
|
33
|
-
};
|
|
34
23
|
function Editor({
|
|
35
24
|
postId: initialPostId,
|
|
36
25
|
postType: initialPostType,
|
|
@@ -45,14 +34,11 @@ function Editor({
|
|
|
45
34
|
onNavigateToPreviousEntityRecord
|
|
46
35
|
} = useNavigateToEntityRecord(initialPostId, initialPostType);
|
|
47
36
|
const {
|
|
48
|
-
hasInlineToolbar,
|
|
49
37
|
post,
|
|
50
|
-
preferredStyleVariations,
|
|
51
38
|
template
|
|
52
39
|
} = useSelect(select => {
|
|
53
40
|
var _getPostType$viewable;
|
|
54
41
|
const {
|
|
55
|
-
isFeatureActive,
|
|
56
42
|
getEditedPostTemplate
|
|
57
43
|
} = select(editPostStore);
|
|
58
44
|
const {
|
|
@@ -68,26 +54,16 @@ function Editor({
|
|
|
68
54
|
const isViewable = (_getPostType$viewable = getPostType(currentPost.postType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
|
|
69
55
|
const canEditTemplate = canUser('create', 'templates');
|
|
70
56
|
return {
|
|
71
|
-
hasInlineToolbar: isFeatureActive('inlineToolbar'),
|
|
72
|
-
preferredStyleVariations: select(preferencesStore).get('core/edit-post', 'preferredStyleVariations'),
|
|
73
57
|
template: supportsTemplateMode && isViewable && canEditTemplate && currentPost.postType !== 'wp_template' ? getEditedPostTemplate() : null,
|
|
74
58
|
post: postObject
|
|
75
59
|
};
|
|
76
60
|
}, [currentPost.postType, currentPost.postId]);
|
|
77
|
-
const {
|
|
78
|
-
updatePreferredStyleVariations
|
|
79
|
-
} = useDispatch(editPostStore);
|
|
80
61
|
const editorSettings = useMemo(() => ({
|
|
81
62
|
...settings,
|
|
82
63
|
onNavigateToEntityRecord,
|
|
83
64
|
onNavigateToPreviousEntityRecord,
|
|
84
|
-
defaultRenderingMode: 'post-only'
|
|
85
|
-
|
|
86
|
-
value: preferredStyleVariations,
|
|
87
|
-
onChange: updatePreferredStyleVariations
|
|
88
|
-
},
|
|
89
|
-
hasInlineToolbar
|
|
90
|
-
}), [settings, hasInlineToolbar, preferredStyleVariations, updatePreferredStyleVariations, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
|
|
65
|
+
defaultRenderingMode: 'post-only'
|
|
66
|
+
}), [settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]);
|
|
91
67
|
if (!post) {
|
|
92
68
|
return null;
|
|
93
69
|
}
|
|
@@ -98,12 +74,8 @@ function Editor({
|
|
|
98
74
|
useSubRegistry: false,
|
|
99
75
|
__unstableTemplate: template,
|
|
100
76
|
...props
|
|
101
|
-
}, createElement(ErrorBoundary, null, createElement(CommandMenu, null), createElement(EditorInitialization, {
|
|
102
|
-
postId: currentPost.postId
|
|
103
|
-
}), createElement(Layout, {
|
|
77
|
+
}, createElement(ErrorBoundary, null, createElement(CommandMenu, null), createElement(EditorInitialization, null), createElement(Layout, {
|
|
104
78
|
initialPost: initialPost
|
|
105
|
-
}), createElement(BlockRemovalWarningModal, {
|
|
106
|
-
rules: blockRemovalRules
|
|
107
79
|
})), createElement(PostLockedModal, null)));
|
|
108
80
|
}
|
|
109
81
|
export default Editor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","
|
|
1
|
+
{"version":3,"names":["useSelect","ErrorBoundary","PostLockedModal","store","editorStore","privateApis","editorPrivateApis","useMemo","SlotFillProvider","coreStore","CommandMenu","Layout","EditorInitialization","editPostStore","unlock","useNavigateToEntityRecord","ExperimentalEditorProvider","Editor","postId","initialPostId","postType","initialPostType","settings","initialEdits","props","initialPost","currentPost","onNavigateToEntityRecord","onNavigateToPreviousEntityRecord","post","template","select","_getPostType$viewable","getEditedPostTemplate","getEntityRecord","getPostType","canUser","getEditorSettings","postObject","supportsTemplateMode","isViewable","viewable","canEditTemplate","editorSettings","defaultRenderingMode","createElement","useSubRegistry","__unstableTemplate"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\nimport useNavigateToEntityRecord from './hooks/use-navigate-to-entity-record';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n\t...props\n} ) {\n\tconst {\n\t\tinitialPost,\n\t\tcurrentPost,\n\t\tonNavigateToEntityRecord,\n\t\tonNavigateToPreviousEntityRecord,\n\t} = useNavigateToEntityRecord( initialPostId, initialPostType );\n\n\tconst { post, template } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedPostTemplate } = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, canUser } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\n\t\t\tconst postObject = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\tcurrentPost.postType,\n\t\t\t\tcurrentPost.postId\n\t\t\t);\n\n\t\t\tconst supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPost.postType )?.viewable ?? false;\n\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\treturn {\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode &&\n\t\t\t\t\tisViewable &&\n\t\t\t\t\tcanEditTemplate &&\n\t\t\t\t\tcurrentPost.postType !== 'wp_template'\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ currentPost.postType, currentPost.postId ]\n\t);\n\n\tconst editorSettings = useMemo(\n\t\t() => ( {\n\t\t\t...settings,\n\t\t\tonNavigateToEntityRecord,\n\t\t\tonNavigateToPreviousEntityRecord,\n\t\t\tdefaultRenderingMode: 'post-only',\n\t\t} ),\n\t\t[ settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord ]\n\t);\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization />\n\t\t\t\t\t<Layout initialPost={ initialPost } />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,iBAAiB;AAC3C,SACCC,aAAa,EACbC,eAAe,EACfC,KAAK,IAAIC,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAASL,KAAK,IAAIM,SAAS,QAAQ,sBAAsB;AACzD,SAASC,WAAW,QAAQ,qBAAqB;;AAEjD;AACA;AACA;AACA,OAAOC,MAAM,MAAM,qBAAqB;AACxC,OAAOC,oBAAoB,MAAM,oCAAoC;AACrE,SAAST,KAAK,IAAIU,aAAa,QAAQ,SAAS;AAChD,SAASC,MAAM,QAAQ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ACF,CAAC,EACD,CAAEZ,WAAW,CAACN,QAAQ,EAAEM,WAAW,CAACR,MAAM,CAC3C,CAAC;EAED,MAAMyB,cAAc,GAAGpC,OAAO,CAC7B,OAAQ;IACP,GAAGe,QAAQ;IACXK,wBAAwB;IACxBC,gCAAgC;IAChCgB,oBAAoB,EAAE;EACvB,CAAC,CAAE,EACH,CAAEtB,QAAQ,EAAEK,wBAAwB,EAAEC,gCAAgC,CACvE,CAAC;EAED,IAAK,CAAEC,IAAI,EAAG;IACb,OAAO,IAAI;EACZ;EAEA,OACCgB,aAAA,CAACrC,gBAAgB,QAChBqC,aAAA,CAAC7B,0BAA0B;IAC1BM,QAAQ,EAAGqB,cAAgB;IAC3Bd,IAAI,EAAGA,IAAM;IACbN,YAAY,EAAGA,YAAc;IAC7BuB,cAAc,EAAG,KAAO;IACxBC,kBAAkB,EAAGjB,QAAU;IAAA,GAC1BN;EAAK,GAEVqB,aAAA,CAAC5C,aAAa,QACb4C,aAAA,CAACnC,WAAW,MAAE,CAAC,EACfmC,aAAA,CAACjC,oBAAoB,MAAE,CAAC,EACxBiC,aAAA,CAAClC,MAAM;IAACc,WAAW,EAAGA;EAAa,CAAE,CACvB,CAAC,EAChBoB,aAAA,CAAC3C,eAAe,MAAE,CACS,CACX,CAAC;AAErB;AAEA,eAAee,MAAM"}
|
|
@@ -10,7 +10,7 @@ import { GestureHandlerRootView } from 'react-native-gesture-handler';
|
|
|
10
10
|
* WordPress dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
|
-
import { EditorProvider } from '@wordpress/editor';
|
|
13
|
+
import { EditorProvider, store as editorStore } from '@wordpress/editor';
|
|
14
14
|
import { parse, serialize } from '@wordpress/blocks';
|
|
15
15
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
16
16
|
import { compose } from '@wordpress/compose';
|
|
@@ -22,7 +22,6 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
22
22
|
* Internal dependencies
|
|
23
23
|
*/
|
|
24
24
|
import Layout from './components/layout';
|
|
25
|
-
import { store as editPostStore } from './store';
|
|
26
25
|
class Editor extends Component {
|
|
27
26
|
constructor(props) {
|
|
28
27
|
super(...arguments);
|
|
@@ -132,14 +131,14 @@ class Editor extends Component {
|
|
|
132
131
|
export default compose([withSelect(select => {
|
|
133
132
|
const {
|
|
134
133
|
getEditorMode
|
|
135
|
-
} = select(
|
|
134
|
+
} = select(editorStore);
|
|
136
135
|
return {
|
|
137
136
|
mode: getEditorMode()
|
|
138
137
|
};
|
|
139
138
|
}), withDispatch(dispatch => {
|
|
140
139
|
const {
|
|
141
140
|
switchEditorMode
|
|
142
|
-
} = dispatch(
|
|
141
|
+
} = dispatch(editorStore);
|
|
143
142
|
const {
|
|
144
143
|
editEntityRecord
|
|
145
144
|
} = dispatch(coreStore);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memize","I18nManager","GestureHandlerRootView","Component","EditorProvider","parse","serialize","withDispatch","withSelect","compose","subscribeSetFocusOnTitle","subscribeFeaturedImageIdNativeUpdated","SlotFillProvider","
|
|
1
|
+
{"version":3,"names":["memize","I18nManager","GestureHandlerRootView","Component","EditorProvider","store","editorStore","parse","serialize","withDispatch","withSelect","compose","subscribeSetFocusOnTitle","subscribeFeaturedImageIdNativeUpdated","SlotFillProvider","coreStore","Layout","Editor","constructor","props","arguments","galleryWithImageBlocks","window","wp","galleryBlockV2Enabled","initialHtmlModeEnabled","mode","switchEditorMode","getEditorSettings","maxSize","setTitleRef","bind","settings","isRTL","componentDidMount","editEntityRecord","postType","postId","subscriptionParentSetFocusOnTitle","postTitleRef","focus","focusTitleWhenAvailable","subscriptionParentFeaturedImageIdNativeUpdated","payload","featured_media","featuredImageId","undoIgnore","componentWillUnmount","remove","titleRef","render","initialEdits","post","initialHtml","editorSettings","normalizedPost","id","title","raw","initialTitle","content","type","status","meta","createElement","style","flex","useSubRegistry","select","getEditorMode","dispatch"],"sources":["@wordpress/edit-post/src/editor.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { I18nManager } from 'react-native';\nimport { GestureHandlerRootView } from 'react-native-gesture-handler';\n\n/**\n * WordPress dependencies\n */\nimport { Component } from '@wordpress/element';\nimport { EditorProvider, store as editorStore } from '@wordpress/editor';\nimport { parse, serialize } from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport {\n\tsubscribeSetFocusOnTitle,\n\tsubscribeFeaturedImageIdNativeUpdated,\n} from '@wordpress/react-native-bridge';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\n\nclass Editor extends Component {\n\tconstructor( props ) {\n\t\tsuper( ...arguments );\n\n\t\t// need to set this globally to avoid race with deprecations\n\t\t// defaulting to true to avoid issues with a not-yet-cached value\n\t\tconst { galleryWithImageBlocks = true } = props;\n\t\twindow.wp.galleryBlockV2Enabled = galleryWithImageBlocks;\n\n\t\tif ( props.initialHtmlModeEnabled && props.mode === 'visual' ) {\n\t\t\t// Enable html mode if the initial mode the parent wants it but we're not already in it.\n\t\t\tthis.props.switchEditorMode( 'text' );\n\t\t}\n\n\t\tthis.getEditorSettings = memize( this.getEditorSettings, {\n\t\t\tmaxSize: 1,\n\t\t} );\n\n\t\tthis.setTitleRef = this.setTitleRef.bind( this );\n\t}\n\n\tgetEditorSettings( settings ) {\n\t\tsettings = {\n\t\t\t...settings,\n\t\t\tisRTL: I18nManager.isRTL,\n\t\t};\n\n\t\treturn settings;\n\t}\n\n\tcomponentDidMount() {\n\t\tconst { editEntityRecord, postType, postId } = this.props;\n\n\t\tthis.subscriptionParentSetFocusOnTitle = subscribeSetFocusOnTitle(\n\t\t\t() => {\n\t\t\t\tif ( this.postTitleRef ) {\n\t\t\t\t\tthis.postTitleRef.focus();\n\t\t\t\t} else {\n\t\t\t\t\t// If the post title ref is not available, we postpone setting focus to when it's available.\n\t\t\t\t\tthis.focusTitleWhenAvailable = true;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentFeaturedImageIdNativeUpdated =\n\t\t\tsubscribeFeaturedImageIdNativeUpdated( ( payload ) => {\n\t\t\t\teditEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId,\n\t\t\t\t\t{ featured_media: payload.featuredImageId },\n\t\t\t\t\t{\n\t\t\t\t\t\tundoIgnore: true,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentSetFocusOnTitle ) {\n\t\t\tthis.subscriptionParentSetFocusOnTitle.remove();\n\t\t}\n\n\t\tif ( this.subscribeFeaturedImageIdNativeUpdated ) {\n\t\t\tthis.subscribeFeaturedImageIdNativeUpdated.remove();\n\t\t}\n\t}\n\n\tsetTitleRef( titleRef ) {\n\t\tif ( this.focusTitleWhenAvailable && ! this.postTitleRef ) {\n\t\t\tthis.focusTitleWhenAvailable = false;\n\t\t\ttitleRef.focus();\n\t\t}\n\n\t\tthis.postTitleRef = titleRef;\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tsettings,\n\t\t\tinitialEdits,\n\t\t\tpost,\n\t\t\tpostId,\n\t\t\tpostType,\n\t\t\tfeaturedImageId,\n\t\t\tinitialHtml,\n\t\t\t...props\n\t\t} = this.props;\n\n\t\tconst editorSettings = this.getEditorSettings( settings );\n\n\t\tconst normalizedPost = post || {\n\t\t\tid: postId,\n\t\t\ttitle: {\n\t\t\t\traw: props.initialTitle || '',\n\t\t\t},\n\t\t\tfeatured_media: featuredImageId,\n\t\t\tcontent: {\n\t\t\t\t// Make sure the post content is in sync with gutenberg store\n\t\t\t\t// to avoid marking the post as modified when simply loaded\n\t\t\t\t// For now, let's assume: serialize( parse( html ) ) !== html.\n\t\t\t\traw: serialize( parse( initialHtml || '' ) ),\n\t\t\t},\n\t\t\ttype: postType,\n\t\t\tstatus: 'draft',\n\t\t\tmeta: [],\n\t\t};\n\n\t\treturn (\n\t\t\t<GestureHandlerRootView style={ { flex: 1 } }>\n\t\t\t\t<SlotFillProvider>\n\t\t\t\t\t<EditorProvider\n\t\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t\tpost={ normalizedPost }\n\t\t\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t{ ...props }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Layout setTitleRef={ this.setTitleRef } />\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</SlotFillProvider>\n\t\t\t</GestureHandlerRootView>\n\t\t);\n\t}\n}\n\nexport default compose( [\n\twithSelect( ( select ) => {\n\t\tconst { getEditorMode } = select( editorStore );\n\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { switchEditorMode } = dispatch( editorStore );\n\t\tconst { editEntityRecord } = dispatch( coreStore );\n\t\treturn {\n\t\t\tswitchEditorMode,\n\t\t\teditEntityRecord,\n\t\t};\n\t} ),\n] )( Editor );\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,QAAQ;AAC3B,SAASC,WAAW,QAAQ,cAAc;AAC1C,SAASC,sBAAsB,QAAQ,8BAA8B;;AAErE;AACA;AACA;AACA,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,cAAc,EAAEC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxE,SAASC,KAAK,EAAEC,SAAS,QAAQ,mBAAmB;AACpD,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SACCC,wBAAwB,EACxBC,qCAAqC,QAC/B,gCAAgC;AACvC,SAASC,gBAAgB,QAAQ,uBAAuB;AACxD,SAAST,KAAK,IAAIU,SAAS,QAAQ,sBA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AsB;MAAC+D,KAAK,EAAG;QAAEC,IAAI,EAAE;MAAE;IAAG,GAC5CF,aAAA,CAAClD,gBAAgB,QAChBkD,aAAA,CAAC5D,cAAc;MACd4B,QAAQ,EAAGsB,cAAgB;MAC3BF,IAAI,EAAGG,cAAgB;MACvBJ,YAAY,EAAGA,YAAc;MAC7BgB,cAAc,EAAG,KAAO;MAAA,GACnBhD;IAAK,GAEV6C,aAAA,CAAChD,MAAM;MAACc,WAAW,EAAG,IAAI,CAACA;IAAa,CAAE,CAC3B,CACC,CACK,CAAC;EAE3B;AACD;AAEA,eAAenB,OAAO,CAAE,CACvBD,UAAU,CAAI0D,MAAM,IAAM;EACzB,MAAM;IAAEC;EAAc,CAAC,GAAGD,MAAM,CAAE9D,WAAY,CAAC;EAE/C,OAAO;IACNoB,IAAI,EAAE2C,aAAa,CAAC;EACrB,CAAC;AACF,CAAE,CAAC,EACH5D,YAAY,CAAI6D,QAAQ,IAAM;EAC7B,MAAM;IAAE3C;EAAiB,CAAC,GAAG2C,QAAQ,CAAEhE,WAAY,CAAC;EACpD,MAAM;IAAE6B;EAAiB,CAAC,GAAGmC,QAAQ,CAAEvD,SAAU,CAAC;EAClD,OAAO;IACNY,gBAAgB;IAChBQ;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAElB,MAAO,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
5
|
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import {
|
|
6
|
+
import { drawerLeft, drawerRight, blockDefault, keyboard, fullscreen, formatListBullets } from '@wordpress/icons';
|
|
7
7
|
import { useCommand } from '@wordpress/commands';
|
|
8
8
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
9
|
import { store as interfaceStore } from '@wordpress/interface';
|
|
@@ -19,42 +19,22 @@ import { store as editPostStore } from '../../store';
|
|
|
19
19
|
export default function useCommonCommands() {
|
|
20
20
|
const {
|
|
21
21
|
openGeneralSidebar,
|
|
22
|
-
closeGeneralSidebar
|
|
23
|
-
switchEditorMode,
|
|
24
|
-
toggleDistractionFree
|
|
22
|
+
closeGeneralSidebar
|
|
25
23
|
} = useDispatch(editPostStore);
|
|
26
24
|
const {
|
|
27
25
|
openModal
|
|
28
26
|
} = useDispatch(interfaceStore);
|
|
29
27
|
const {
|
|
30
|
-
editorMode,
|
|
31
28
|
activeSidebar,
|
|
32
|
-
isListViewOpen,
|
|
33
29
|
isFullscreen,
|
|
34
|
-
isPublishSidebarEnabled
|
|
35
|
-
showBlockBreadcrumbs,
|
|
36
|
-
isDistractionFree,
|
|
37
|
-
isTopToolbar,
|
|
38
|
-
isFocusMode
|
|
30
|
+
isPublishSidebarEnabled
|
|
39
31
|
} = useSelect(select => {
|
|
40
32
|
const {
|
|
41
33
|
get
|
|
42
34
|
} = select(preferencesStore);
|
|
43
|
-
const {
|
|
44
|
-
getEditorMode
|
|
45
|
-
} = select(editPostStore);
|
|
46
|
-
const {
|
|
47
|
-
isListViewOpened
|
|
48
|
-
} = select(editorStore);
|
|
49
35
|
return {
|
|
50
36
|
activeSidebar: select(interfaceStore).getActiveComplementaryArea(editPostStore.name),
|
|
51
|
-
editorMode: getEditorMode(),
|
|
52
|
-
isListViewOpen: isListViewOpened(),
|
|
53
37
|
isPublishSidebarEnabled: select(editorStore).isPublishSidebarEnabled(),
|
|
54
|
-
showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
|
|
55
|
-
isDistractionFree: get('core', 'distractionFree'),
|
|
56
|
-
isFocusMode: get('core', 'focusMode'),
|
|
57
|
-
isTopToolbar: get('core', 'fixedToolbar'),
|
|
58
38
|
isFullscreen: get('core/edit-post', 'fullscreenMode')
|
|
59
39
|
};
|
|
60
40
|
}, []);
|
|
@@ -64,13 +44,6 @@ export default function useCommonCommands() {
|
|
|
64
44
|
const {
|
|
65
45
|
createInfoNotice
|
|
66
46
|
} = useDispatch(noticesStore);
|
|
67
|
-
const {
|
|
68
|
-
__unstableSaveForPreview,
|
|
69
|
-
setIsListViewOpened
|
|
70
|
-
} = useDispatch(editorStore);
|
|
71
|
-
const {
|
|
72
|
-
getCurrentPostId
|
|
73
|
-
} = useSelect(editorStore);
|
|
74
47
|
useCommand({
|
|
75
48
|
name: 'core/open-settings-sidebar',
|
|
76
49
|
label: __('Toggle settings sidebar'),
|
|
@@ -101,36 +74,6 @@ export default function useCommonCommands() {
|
|
|
101
74
|
}
|
|
102
75
|
}
|
|
103
76
|
});
|
|
104
|
-
useCommand({
|
|
105
|
-
name: 'core/toggle-distraction-free',
|
|
106
|
-
label: isDistractionFree ? __('Exit Distraction Free') : __('Enter Distraction Free '),
|
|
107
|
-
callback: ({
|
|
108
|
-
close
|
|
109
|
-
}) => {
|
|
110
|
-
toggleDistractionFree();
|
|
111
|
-
close();
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
useCommand({
|
|
115
|
-
name: 'core/toggle-spotlight-mode',
|
|
116
|
-
label: __('Toggle spotlight'),
|
|
117
|
-
callback: ({
|
|
118
|
-
close
|
|
119
|
-
}) => {
|
|
120
|
-
toggle('core', 'focusMode');
|
|
121
|
-
close();
|
|
122
|
-
createInfoNotice(isFocusMode ? __('Spotlight off.') : __('Spotlight on.'), {
|
|
123
|
-
id: 'core/edit-post/toggle-spotlight-mode/notice',
|
|
124
|
-
type: 'snackbar',
|
|
125
|
-
actions: [{
|
|
126
|
-
label: __('Undo'),
|
|
127
|
-
onClick: () => {
|
|
128
|
-
toggle('core', 'focusMode');
|
|
129
|
-
}
|
|
130
|
-
}]
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
77
|
useCommand({
|
|
135
78
|
name: 'core/toggle-fullscreen-mode',
|
|
136
79
|
label: isFullscreen ? __('Exit fullscreen') : __('Enter fullscreen'),
|
|
@@ -152,55 +95,6 @@ export default function useCommonCommands() {
|
|
|
152
95
|
});
|
|
153
96
|
}
|
|
154
97
|
});
|
|
155
|
-
useCommand({
|
|
156
|
-
name: 'core/toggle-list-view',
|
|
157
|
-
label: isListViewOpen ? __('Close List View') : __('Open List View'),
|
|
158
|
-
icon: listView,
|
|
159
|
-
callback: ({
|
|
160
|
-
close
|
|
161
|
-
}) => {
|
|
162
|
-
setIsListViewOpened(!isListViewOpen);
|
|
163
|
-
close();
|
|
164
|
-
createInfoNotice(isListViewOpen ? __('List View off.') : __('List View on.'), {
|
|
165
|
-
id: 'core/edit-post/toggle-list-view/notice',
|
|
166
|
-
type: 'snackbar'
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
useCommand({
|
|
171
|
-
name: 'core/toggle-top-toolbar',
|
|
172
|
-
label: __('Toggle top toolbar'),
|
|
173
|
-
callback: ({
|
|
174
|
-
close
|
|
175
|
-
}) => {
|
|
176
|
-
toggle('core', 'fixedToolbar');
|
|
177
|
-
if (isDistractionFree) {
|
|
178
|
-
toggleDistractionFree();
|
|
179
|
-
}
|
|
180
|
-
close();
|
|
181
|
-
createInfoNotice(isTopToolbar ? __('Top toolbar off.') : __('Top toolbar on.'), {
|
|
182
|
-
id: 'core/edit-post/toggle-top-toolbar/notice',
|
|
183
|
-
type: 'snackbar',
|
|
184
|
-
actions: [{
|
|
185
|
-
label: __('Undo'),
|
|
186
|
-
onClick: () => {
|
|
187
|
-
toggle('core', 'fixedToolbar');
|
|
188
|
-
}
|
|
189
|
-
}]
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
useCommand({
|
|
194
|
-
name: 'core/toggle-code-editor',
|
|
195
|
-
label: editorMode === 'visual' ? __('Open code editor') : __('Exit code editor'),
|
|
196
|
-
icon: code,
|
|
197
|
-
callback: ({
|
|
198
|
-
close
|
|
199
|
-
}) => {
|
|
200
|
-
switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
|
|
201
|
-
close();
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
98
|
useCommand({
|
|
205
99
|
name: 'core/open-preferences',
|
|
206
100
|
label: __('Editor preferences'),
|
|
@@ -216,20 +110,6 @@ export default function useCommonCommands() {
|
|
|
216
110
|
openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
|
|
217
111
|
}
|
|
218
112
|
});
|
|
219
|
-
useCommand({
|
|
220
|
-
name: 'core/toggle-breadcrumbs',
|
|
221
|
-
label: showBlockBreadcrumbs ? __('Hide block breadcrumbs') : __('Show block breadcrumbs'),
|
|
222
|
-
callback: ({
|
|
223
|
-
close
|
|
224
|
-
}) => {
|
|
225
|
-
toggle('core', 'showBlockBreadcrumbs');
|
|
226
|
-
close();
|
|
227
|
-
createInfoNotice(showBlockBreadcrumbs ? __('Breadcrumbs hidden.') : __('Breadcrumbs visible.'), {
|
|
228
|
-
id: 'core/edit-post/toggle-breadcrumbs/notice',
|
|
229
|
-
type: 'snackbar'
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
});
|
|
233
113
|
useCommand({
|
|
234
114
|
name: 'core/toggle-publish-sidebar',
|
|
235
115
|
label: isPublishSidebarEnabled ? __('Disable pre-publish checks') : __('Enable pre-publish checks'),
|
|
@@ -245,18 +125,5 @@ export default function useCommonCommands() {
|
|
|
245
125
|
});
|
|
246
126
|
}
|
|
247
127
|
});
|
|
248
|
-
useCommand({
|
|
249
|
-
name: 'core/preview-link',
|
|
250
|
-
label: __('Preview in a new tab'),
|
|
251
|
-
icon: external,
|
|
252
|
-
callback: async ({
|
|
253
|
-
close
|
|
254
|
-
}) => {
|
|
255
|
-
close();
|
|
256
|
-
const postId = getCurrentPostId();
|
|
257
|
-
const link = await __unstableSaveForPreview();
|
|
258
|
-
window.open(link, `wp-preview-${postId}`);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
128
|
}
|
|
262
129
|
//# sourceMappingURL=use-common-commands.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","isRTL","code","drawerLeft","drawerRight","blockDefault","keyboard","fullscreen","listView","external","formatListBullets","useCommand","store","preferencesStore","interfaceStore","editorStore","noticesStore","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","PREFERENCES_MODAL_NAME","editPostStore","useCommonCommands","openGeneralSidebar","closeGeneralSidebar","switchEditorMode","toggleDistractionFree","openModal","editorMode","activeSidebar","isListViewOpen","isFullscreen","isPublishSidebarEnabled","showBlockBreadcrumbs","isDistractionFree","isTopToolbar","isFocusMode","select","get","getEditorMode","isListViewOpened","getActiveComplementaryArea","name","toggle","createInfoNotice","__unstableSaveForPreview","setIsListViewOpened","getCurrentPostId","label","icon","callback","close","id","type","actions","onClick","postId","link","window","open"],"sources":["@wordpress/edit-post/src/hooks/commands/use-common-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tcode,\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n\tkeyboard,\n\tfullscreen,\n\tlistView,\n\texternal,\n\tformatListBullets,\n} from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\nimport { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';\nimport { store as editPostStore } from '../../store';\n\nexport default function useCommonCommands() {\n\tconst {\n\t\topenGeneralSidebar,\n\t\tcloseGeneralSidebar,\n\t\tswitchEditorMode,\n\t\ttoggleDistractionFree,\n\t} = useDispatch( editPostStore );\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst {\n\t\teditorMode,\n\t\tactiveSidebar,\n\t\tisListViewOpen,\n\t\tisFullscreen,\n\t\tisPublishSidebarEnabled,\n\t\tshowBlockBreadcrumbs,\n\t\tisDistractionFree,\n\t\tisTopToolbar,\n\t\tisFocusMode,\n\t} = useSelect( ( select ) => {\n\t\tconst { get } = select( preferencesStore );\n\t\tconst { getEditorMode } = select( editPostStore );\n\t\tconst { isListViewOpened } = select( editorStore );\n\n\t\treturn {\n\t\t\tactiveSidebar: select( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\teditPostStore.name\n\t\t\t),\n\t\t\teditorMode: getEditorMode(),\n\t\t\tisListViewOpen: isListViewOpened(),\n\t\t\tisPublishSidebarEnabled:\n\t\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\t\tshowBlockBreadcrumbs: get( 'core', 'showBlockBreadcrumbs' ),\n\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\tisFocusMode: get( 'core', 'focusMode' ),\n\t\t\tisTopToolbar: get( 'core', 'fixedToolbar' ),\n\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t};\n\t}, [] );\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\tconst { __unstableSaveForPreview, setIsListViewOpened } =\n\t\tuseDispatch( editorStore );\n\tconst { getCurrentPostId } = useSelect( editorStore );\n\n\tuseCommand( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/document' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/document' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/block' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-distraction-free',\n\t\tlabel: isDistractionFree\n\t\t\t? __( 'Exit Distraction Free' )\n\t\t\t: __( 'Enter Distraction Free ' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggleDistractionFree();\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-spotlight-mode',\n\t\tlabel: __( 'Toggle spotlight' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'focusMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFocusMode ? __( 'Spotlight off.' ) : __( 'Spotlight on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-spotlight-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'focusMode' );\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);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-list-view',\n\t\tlabel: isListViewOpen\n\t\t\t? __( 'Close List View' )\n\t\t\t: __( 'Open List View' ),\n\t\ticon: listView,\n\t\tcallback: ( { close } ) => {\n\t\t\tsetIsListViewOpened( ! isListViewOpen );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisListViewOpen ? __( 'List View off.' ) : __( 'List View on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-list-view/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-top-toolbar',\n\t\tlabel: __( 'Toggle top toolbar' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'fixedToolbar' );\n\t\t\tif ( isDistractionFree ) {\n\t\t\t\ttoggleDistractionFree();\n\t\t\t}\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisTopToolbar\n\t\t\t\t\t? __( 'Top toolbar off.' )\n\t\t\t\t\t: __( 'Top toolbar on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-top-toolbar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core', 'fixedToolbar' );\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);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-code-editor',\n\t\tlabel:\n\t\t\teditorMode === 'visual'\n\t\t\t\t? __( 'Open code editor' )\n\t\t\t\t: __( 'Exit code editor' ),\n\t\ticon: code,\n\t\tcallback: ( { close } ) => {\n\t\t\tswitchEditorMode( editorMode === 'visual' ? 'text' : 'visual' );\n\t\t\tclose();\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-preferences',\n\t\tlabel: __( 'Editor preferences' ),\n\t\tcallback: () => {\n\t\t\topenModal( PREFERENCES_MODAL_NAME );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-shortcut-help',\n\t\tlabel: __( 'Keyboard shortcuts' ),\n\t\ticon: keyboard,\n\t\tcallback: () => {\n\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-breadcrumbs',\n\t\tlabel: showBlockBreadcrumbs\n\t\t\t? __( 'Hide block breadcrumbs' )\n\t\t\t: __( 'Show block breadcrumbs' ),\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core', 'showBlockBreadcrumbs' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tshowBlockBreadcrumbs\n\t\t\t\t\t? __( 'Breadcrumbs hidden.' )\n\t\t\t\t\t: __( 'Breadcrumbs visible.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-breadcrumbs/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-publish-sidebar',\n\t\tlabel: isPublishSidebarEnabled\n\t\t\t? __( 'Disable pre-publish checks' )\n\t\t\t: __( 'Enable pre-publish checks' ),\n\t\ticon: formatListBullets,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\ttoggle( 'core/edit-post', 'isPublishSidebarEnabled' );\n\t\t\tcreateInfoNotice(\n\t\t\t\tisPublishSidebarEnabled\n\t\t\t\t\t? __( 'Pre-publish checks disabled.' )\n\t\t\t\t\t: __( 'Pre-publish checks enabled.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/publish-sidebar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/preview-link',\n\t\tlabel: __( 'Preview in a new tab' ),\n\t\ticon: external,\n\t\tcallback: async ( { close } ) => {\n\t\t\tclose();\n\t\t\tconst postId = getCurrentPostId();\n\t\t\tconst link = await __unstableSaveForPreview();\n\t\t\twindow.open( link, `wp-preview-${ postId }` );\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,IAAI,EACJC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,UAAU,EACVC,QAAQ,EACRC,QAAQ,EACRC,iBAAiB,QACX,kBAAkB;AACzB,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,cAAc,QAAQ,sBAAsB;AAC9D,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;AACxD,SAASH,KAAK,IAAII,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASC,iCAAiC,QAAQ,+CAA+C;AACjG,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASN,KAAK,IAAIO,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IACLC,kBAAkB;IAClBC,mBAAmB;IACnBC,gBAAgB;IAChBC;EACD,CAAC,GAAGzB,WAAW,CAAEoB,a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AEA,CAAE;MAAEC;IAAM,CAAC,KAAM;MAC1BA,KAAK,CAAC,CAAC;MACPR,MAAM,CAAE,gBAAgB,EAAE,yBAA0B,CAAC;MACrDC,gBAAgB,CACfZ,uBAAuB,GACpB9B,EAAE,CAAE,8BAA+B,CAAC,GACpCA,EAAE,CAAE,6BAA8B,CAAC,EACtC;QACCkD,EAAE,EAAE,uCAAuC;QAC3CC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;EAEHxC,UAAU,CAAE;IACX6B,IAAI,EAAE,mBAAmB;IACzBM,KAAK,EAAE9C,EAAE,CAAE,sBAAuB,CAAC;IACnC+C,IAAI,EAAEtC,QAAQ;IACduC,QAAQ,EAAE,MAAAA,CAAQ;MAAEC;IAAM,CAAC,KAAM;MAChCA,KAAK,CAAC,CAAC;MACP,MAAMK,MAAM,GAAGT,gBAAgB,CAAC,CAAC;MACjC,MAAMU,IAAI,GAAG,MAAMZ,wBAAwB,CAAC,CAAC;MAC7Ca,MAAM,CAACC,IAAI,CAAEF,IAAI,EAAG,cAAcD,MAAQ,EAAE,CAAC;IAC9C;EACD,CAAE,CAAC;AACJ"}
|
|
1
|
+
{"version":3,"names":["useSelect","useDispatch","__","isRTL","drawerLeft","drawerRight","blockDefault","keyboard","fullscreen","formatListBullets","useCommand","store","preferencesStore","interfaceStore","editorStore","noticesStore","KEYBOARD_SHORTCUT_HELP_MODAL_NAME","PREFERENCES_MODAL_NAME","editPostStore","useCommonCommands","openGeneralSidebar","closeGeneralSidebar","openModal","activeSidebar","isFullscreen","isPublishSidebarEnabled","select","get","getActiveComplementaryArea","name","toggle","createInfoNotice","label","icon","callback","close","id","type","actions","onClick"],"sources":["@wordpress/edit-post/src/hooks/commands/use-common-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n\tkeyboard,\n\tfullscreen,\n\tformatListBullets,\n} from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { store as interfaceStore } from '@wordpress/interface';\nimport { store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { KEYBOARD_SHORTCUT_HELP_MODAL_NAME } from '../../components/keyboard-shortcut-help-modal';\nimport { PREFERENCES_MODAL_NAME } from '../../components/preferences-modal';\nimport { store as editPostStore } from '../../store';\n\nexport default function useCommonCommands() {\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\tconst { openModal } = useDispatch( interfaceStore );\n\tconst { activeSidebar, isFullscreen, isPublishSidebarEnabled } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\n\t\t\treturn {\n\t\t\t\tactiveSidebar: select(\n\t\t\t\t\tinterfaceStore\n\t\t\t\t).getActiveComplementaryArea( editPostStore.name ),\n\t\t\t\tisPublishSidebarEnabled:\n\t\t\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/document' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/document' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/block' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\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);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-preferences',\n\t\tlabel: __( 'Editor preferences' ),\n\t\tcallback: () => {\n\t\t\topenModal( PREFERENCES_MODAL_NAME );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-shortcut-help',\n\t\tlabel: __( 'Keyboard shortcuts' ),\n\t\ticon: keyboard,\n\t\tcallback: () => {\n\t\t\topenModal( KEYBOARD_SHORTCUT_HELP_MODAL_NAME );\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-publish-sidebar',\n\t\tlabel: isPublishSidebarEnabled\n\t\t\t? __( 'Disable pre-publish checks' )\n\t\t\t: __( 'Enable pre-publish checks' ),\n\t\ticon: formatListBullets,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\ttoggle( 'core/edit-post', 'isPublishSidebarEnabled' );\n\t\t\tcreateInfoNotice(\n\t\t\t\tisPublishSidebarEnabled\n\t\t\t\t\t? __( 'Pre-publish checks disabled.' )\n\t\t\t\t\t: __( 'Pre-publish checks enabled.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/publish-sidebar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,QAAQ,EACRC,UAAU,EACVC,iBAAiB,QACX,kBAAkB;AACzB,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,wBAAwB;AAClE,SAASD,KAAK,IAAIE,cAAc,QAAQ,sBAAsB;AAC9D,SAASF,KAAK,IAAIG,WAAW,QAAQ,mBAAmB;AACxD,SAASH,KAAK,IAAII,YAAY,QAAQ,oBAAoB;;AAE1D;AACA;AACA;AACA,SAASC,iCAAiC,QAAQ,+CAA+C;AACjG,SAASC,sBAAsB,QAAQ,oCAAoC;AAC3E,SAASN,KAAK,IAAIO,aAAa,QAAQ,aAAa;AAEpD,eAAe,SAASC,iBAAiBA,CAAA,EAAG;EAC3C,MAAM;IAAEC,kBAAkB;IAAEC;EAAoB,CAAC,GAChDpB,WAAW,CAAEiB,aAAc,CAAC;EAC7B,MAAM;IAAEI;EAAU,CAAC,GAAGrB,WAAW,CAAEY,cAAe,CAAC;EACnD,MAAM;IAAEU,aAAa;IAAEC,YAAY;IAAEC;EAAwB,CAAC,GAAGzB,SAAS,CACvE0B,MAAM,IAAM;IACb,MAAM;MAAEC;IA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,CAAE;MAAEC;IAAM,CAAC,KAAM;MAC1BA,KAAK,CAAC,CAAC;MACPL,MAAM,CAAE,gBAAgB,EAAE,yBAA0B,CAAC;MACrDC,gBAAgB,CACfN,uBAAuB,GACpBvB,EAAE,CAAE,8BAA+B,CAAC,GACpCA,EAAE,CAAE,6BAA8B,CAAC,EACtC;QACCkC,EAAE,EAAE,uCAAuC;QAC3CC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;AACJ"}
|
package/build-module/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import { registerCoreBlocks, __experimentalRegisterExperimentalCoreBlocks } from
|
|
|
7
7
|
import deprecated from '@wordpress/deprecated';
|
|
8
8
|
import { createRoot } from '@wordpress/element';
|
|
9
9
|
import { dispatch, select } from '@wordpress/data';
|
|
10
|
-
import { addFilter } from '@wordpress/hooks';
|
|
11
10
|
import { store as preferencesStore } from '@wordpress/preferences';
|
|
12
11
|
import { registerLegacyWidgetBlock, registerWidgetGroupBlock } from '@wordpress/widgets';
|
|
13
12
|
import { privateApis as editorPrivateApis, store as editorStore } from '@wordpress/editor';
|
|
@@ -41,7 +40,6 @@ export function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
41
40
|
dispatch(preferencesStore).setDefaults('core/edit-post', {
|
|
42
41
|
fullscreenMode: true,
|
|
43
42
|
isPublishSidebarEnabled: true,
|
|
44
|
-
preferredStyleVariations: {},
|
|
45
43
|
themeStyles: true,
|
|
46
44
|
welcomeGuide: true,
|
|
47
45
|
welcomeGuideTemplate: true
|
|
@@ -78,34 +76,6 @@ export function initializeEditor(id, postType, postId, settings, initialEdits) {
|
|
|
78
76
|
});
|
|
79
77
|
}
|
|
80
78
|
|
|
81
|
-
/*
|
|
82
|
-
* Prevent adding template part in the post editor.
|
|
83
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
84
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
85
|
-
* so that common filters in the block library are not overwritten.
|
|
86
|
-
*/
|
|
87
|
-
addFilter('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
|
|
88
|
-
if (blockType.name === 'core/template-part') {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
return canInsert;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
/*
|
|
95
|
-
* Prevent adding post content block (except in query block) in the post editor.
|
|
96
|
-
* Only add the filter when the post editor is initialized, not imported.
|
|
97
|
-
* Also only add the filter(s) after registerCoreBlocks()
|
|
98
|
-
* so that common filters in the block library are not overwritten.
|
|
99
|
-
*/
|
|
100
|
-
addFilter('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
|
|
101
|
-
getBlockParentsByBlockName
|
|
102
|
-
}) => {
|
|
103
|
-
if (blockType.name === 'core/post-content') {
|
|
104
|
-
return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
|
|
105
|
-
}
|
|
106
|
-
return canInsert;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
79
|
// Show a console log warning if the browser is not in Standards rendering mode.
|
|
110
80
|
const documentMode = document.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';
|
|
111
81
|
if (documentMode !== 'Standards') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","deprecated","createRoot","dispatch","select","addFilter","preferencesStore","registerLegacyWidgetBlock","registerWidgetGroupBlock","privateApis","editorPrivateApis","editorStore","Editor","unlock","PluginPostExcerpt","__experimentalPluginPostExcerpt","initializeEditor","id","postType","postId","settings","initialEdits","isMediumOrBigger","window","matchMedia","matches","target","document","getElementById","root","setDefaults","fullscreenMode","isPublishSidebarEnabled","preferredStyleVariations","themeStyles","welcomeGuide","welcomeGuideTemplate","allowRightClickOverrides","editorMode","fixedToolbar","hiddenBlockTypes","inactivePanels","openPanels","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","reapplyBlockTypeFilters","get","setIsListViewOpened","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","canInsert","blockType","name","rootClientId","getBlockParentsByBlockName","length","documentMode","compatMode","console","warn","isIphone","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","render","createElement","reinitializeEditor","since","version","default","PluginBlockSettingsMenuItem","PluginDocumentSettingPanel","PluginMoreMenuItem","PluginPostPublishPanel","PluginPostStatusInfo","PluginPrePublishPanel","PluginSidebar","PluginSidebarMoreMenuItem","__experimentalFullscreenModeClose","__experimentalMainDashboardButton"],"sources":["@wordpress/edit-post/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { addFilter } from '@wordpress/hooks';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { unlock } from './lock-unlock';\n\nconst { PluginPostExcerpt: __experimentalPluginPostExcerpt } =\n\tunlock( editorPrivateApis );\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tisPublishSidebarEnabled: true,\n\t\tpreferredStyleVariations: {},\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t/*\n\t * Prevent adding template part in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removeTemplatePartsFromInserter',\n\t\t( canInsert, blockType ) => {\n\t\t\tif ( blockType.name === 'core/template-part' ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t/*\n\t * Prevent adding post content block (except in query block) in the post editor.\n\t * Only add the filter when the post editor is initialized, not imported.\n\t * Also only add the filter(s) after registerCoreBlocks()\n\t * so that common filters in the block library are not overwritten.\n\t */\n\taddFilter(\n\t\t'blockEditor.__unstableCanInsertBlockType',\n\t\t'removePostContentFromInserter',\n\t\t(\n\t\t\tcanInsert,\n\t\t\tblockType,\n\t\t\trootClientId,\n\t\t\t{ getBlockParentsByBlockName }\n\t\t) => {\n\t\t\tif ( blockType.name === 'core/post-content' ) {\n\t\t\t\treturn (\n\t\t\t\t\tgetBlockParentsByBlockName( rootClientId, 'core/query' )\n\t\t\t\t\t\t.length > 0\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn canInsert;\n\t\t}\n\t);\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { __experimentalPluginPostExcerpt };\nexport { store } from './store';\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SACCC,kBAAkB,EAClBC,4CAA4C,QACtC,0BAA0B;AACjC,OAAOC,UAAU,MAAM,uBAAuB;AAC9C,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,QAAQ,EAAEC,MAAM,QAAQ,iBAAiB;AAClD,SAASC,SAAS,QAAQ,kBAAkB;AAC5C,SAASR,KAAK,IAAIS,gBAAgB,QAAQ,wBAAwB;AAClE,SACCC,yBAAyB,EACzBC,wBAAwB,QAClB,oBAAoB;AAC3B,SACCC,WAAW,IAAIC,iBAAiB,EAChCb,KAAK,IAAIc,WAAW,QACd,mBAAmB;;AAE1B;AACA;AACA;AACA,OAAO,SAAS;AAChB,OAAO,WAAW;AAClB,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,MAAM,QAAQ,eAAe;AAEtC,MAAM;EAAEC,iBAAiB,EAAEC;AAAgC,CAAC,GAC3DF,MAAM,CAAEH,iBAAkB,CAAC;;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,gBAAgBA,CAC/BC,EAAE,EACFC,QAAQ,EACRC,MAAM,EACNC,QAAQ,EACRC,YAAY,EACX;EACD,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,UAAU,CAAE,oBAAqB,CAAC,CAACC,OAAO;EAC1E,MAAMC,MAAM,GAAGC,QAAQ,CAACC,cAAc,CAAEX,EAAG,CAAC;EAC5C,MAAMY,IAAI,GAAG3B,UAAU,CAAEwB,MA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C,QAAQ,2CAA2C;AACxG,SAAST,OAAO,IAAIU,iCAAiC,QAAQ,2CAA2C;AACxG,SAAS9E,+BAA+B;AACxC,SAASlB,KAAK,QAAQ,SAAS"}
|
|
1
|
+
{"version":3,"names":["store","blocksStore","registerCoreBlocks","__experimentalRegisterExperimentalCoreBlocks","deprecated","createRoot","dispatch","select","preferencesStore","registerLegacyWidgetBlock","registerWidgetGroupBlock","privateApis","editorPrivateApis","editorStore","Editor","unlock","PluginPostExcerpt","__experimentalPluginPostExcerpt","initializeEditor","id","postType","postId","settings","initialEdits","isMediumOrBigger","window","matchMedia","matches","target","document","getElementById","root","setDefaults","fullscreenMode","isPublishSidebarEnabled","themeStyles","welcomeGuide","welcomeGuideTemplate","allowRightClickOverrides","editorMode","fixedToolbar","hiddenBlockTypes","inactivePanels","openPanels","showBlockBreadcrumbs","showIconLabels","showListViewByDefault","reapplyBlockTypeFilters","get","setIsListViewOpened","inserter","process","env","IS_GUTENBERG_PLUGIN","enableFSEBlocks","__unstableEnableFullSiteEditingBlocks","documentMode","compatMode","console","warn","isIphone","navigator","userAgent","indexOf","addEventListener","event","editorScrollContainer","getElementsByClassName","scrollY","scrollTop","scrollTo","e","preventDefault","render","createElement","reinitializeEditor","since","version","default","PluginBlockSettingsMenuItem","PluginDocumentSettingPanel","PluginMoreMenuItem","PluginPostPublishPanel","PluginPostStatusInfo","PluginPrePublishPanel","PluginSidebar","PluginSidebarMoreMenuItem","__experimentalFullscreenModeClose","__experimentalMainDashboardButton"],"sources":["@wordpress/edit-post/src/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport {\n\tregisterCoreBlocks,\n\t__experimentalRegisterExperimentalCoreBlocks,\n} from '@wordpress/block-library';\nimport deprecated from '@wordpress/deprecated';\nimport { createRoot } from '@wordpress/element';\nimport { dispatch, select } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tregisterLegacyWidgetBlock,\n\tregisterWidgetGroupBlock,\n} from '@wordpress/widgets';\nimport {\n\tprivateApis as editorPrivateApis,\n\tstore as editorStore,\n} from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport './hooks';\nimport './plugins';\nimport Editor from './editor';\nimport { unlock } from './lock-unlock';\n\nconst { PluginPostExcerpt: __experimentalPluginPostExcerpt } =\n\tunlock( editorPrivateApis );\n\n/**\n * Initializes and returns an instance of Editor.\n *\n * @param {string} id Unique identifier for editor instance.\n * @param {string} postType Post type of the post to edit.\n * @param {Object} postId ID of the post to edit.\n * @param {?Object} settings Editor settings object.\n * @param {Object} initialEdits Programmatic edits to apply initially, to be\n * considered as non-user-initiated (bypass for\n * unsaved changes prompt).\n */\nexport function initializeEditor(\n\tid,\n\tpostType,\n\tpostId,\n\tsettings,\n\tinitialEdits\n) {\n\tconst isMediumOrBigger = window.matchMedia( '(min-width: 782px)' ).matches;\n\tconst target = document.getElementById( id );\n\tconst root = createRoot( target );\n\n\tdispatch( preferencesStore ).setDefaults( 'core/edit-post', {\n\t\tfullscreenMode: true,\n\t\tisPublishSidebarEnabled: true,\n\t\tthemeStyles: true,\n\t\twelcomeGuide: true,\n\t\twelcomeGuideTemplate: true,\n\t} );\n\n\tdispatch( preferencesStore ).setDefaults( 'core', {\n\t\tallowRightClickOverrides: true,\n\t\teditorMode: 'visual',\n\t\tfixedToolbar: false,\n\t\thiddenBlockTypes: [],\n\t\tinactivePanels: [],\n\t\topenPanels: [ 'post-status' ],\n\t\tshowBlockBreadcrumbs: true,\n\t\tshowIconLabels: false,\n\t\tshowListViewByDefault: false,\n\t} );\n\n\tdispatch( blocksStore ).reapplyBlockTypeFilters();\n\n\t// Check if the block list view should be open by default.\n\t// If `distractionFree` mode is enabled, the block list view should not be open.\n\t// This behavior is disabled for small viewports.\n\tif (\n\t\tisMediumOrBigger &&\n\t\tselect( preferencesStore ).get( 'core', 'showListViewByDefault' ) &&\n\t\t! select( preferencesStore ).get( 'core', 'distractionFree' )\n\t) {\n\t\tdispatch( editorStore ).setIsListViewOpened( true );\n\t}\n\n\tregisterCoreBlocks();\n\tregisterLegacyWidgetBlock( { inserter: false } );\n\tregisterWidgetGroupBlock( { inserter: false } );\n\tif ( process.env.IS_GUTENBERG_PLUGIN ) {\n\t\t__experimentalRegisterExperimentalCoreBlocks( {\n\t\t\tenableFSEBlocks: settings.__unstableEnableFullSiteEditingBlocks,\n\t\t} );\n\t}\n\n\t// Show a console log warning if the browser is not in Standards rendering mode.\n\tconst documentMode =\n\t\tdocument.compatMode === 'CSS1Compat' ? 'Standards' : 'Quirks';\n\tif ( documentMode !== 'Standards' ) {\n\t\t// eslint-disable-next-line no-console\n\t\tconsole.warn(\n\t\t\t\"Your browser is using Quirks Mode. \\nThis can cause rendering issues such as blocks overlaying meta boxes in the editor. Quirks Mode can be triggered by PHP errors or HTML code appearing before the opening <!DOCTYPE html>. Try checking the raw page source or your site's PHP error log and resolving errors there, removing any HTML before the doctype, or disabling plugins.\"\n\t\t);\n\t}\n\n\t// This is a temporary fix for a couple of issues specific to Webkit on iOS.\n\t// Without this hack the browser scrolls the mobile toolbar off-screen.\n\t// Once supported in Safari we can replace this in favor of preventScroll.\n\t// For details see issue #18632 and PR #18686\n\t// Specifically, we scroll `interface-interface-skeleton__body` to enable a fixed top toolbar.\n\t// But Mobile Safari forces the `html` element to scroll upwards, hiding the toolbar.\n\n\tconst isIphone = window.navigator.userAgent.indexOf( 'iPhone' ) !== -1;\n\tif ( isIphone ) {\n\t\twindow.addEventListener( 'scroll', ( event ) => {\n\t\t\tconst editorScrollContainer = document.getElementsByClassName(\n\t\t\t\t'interface-interface-skeleton__body'\n\t\t\t)[ 0 ];\n\t\t\tif ( event.target === document ) {\n\t\t\t\t// Scroll element into view by scrolling the editor container by the same amount\n\t\t\t\t// that Mobile Safari tried to scroll the html element upwards.\n\t\t\t\tif ( window.scrollY > 100 ) {\n\t\t\t\t\teditorScrollContainer.scrollTop =\n\t\t\t\t\t\teditorScrollContainer.scrollTop + window.scrollY;\n\t\t\t\t}\n\t\t\t\t// Undo unwanted scroll on html element, but only in the visual editor.\n\t\t\t\tif (\n\t\t\t\t\tdocument.getElementsByClassName( 'is-mode-visual' )[ 0 ]\n\t\t\t\t) {\n\t\t\t\t\twindow.scrollTo( 0, 0 );\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t}\n\n\t// Prevent the default browser action for files dropped outside of dropzones.\n\twindow.addEventListener( 'dragover', ( e ) => e.preventDefault(), false );\n\twindow.addEventListener( 'drop', ( e ) => e.preventDefault(), false );\n\n\troot.render(\n\t\t<Editor\n\t\t\tsettings={ settings }\n\t\t\tpostId={ postId }\n\t\t\tpostType={ postType }\n\t\t\tinitialEdits={ initialEdits }\n\t\t/>\n\t);\n\n\treturn root;\n}\n\n/**\n * Used to reinitialize the editor after an error. Now it's a deprecated noop function.\n */\nexport function reinitializeEditor() {\n\tdeprecated( 'wp.editPost.reinitializeEditor', {\n\t\tsince: '6.2',\n\t\tversion: '6.3',\n\t} );\n}\n\nexport { default as PluginBlockSettingsMenuItem } from './components/block-settings-menu/plugin-block-settings-menu-item';\nexport { default as PluginDocumentSettingPanel } from './components/sidebar/plugin-document-setting-panel';\nexport { default as PluginMoreMenuItem } from './components/header/plugin-more-menu-item';\nexport { default as PluginPostPublishPanel } from './components/sidebar/plugin-post-publish-panel';\nexport { default as PluginPostStatusInfo } from './components/sidebar/plugin-post-status-info';\nexport { default as PluginPrePublishPanel } from './components/sidebar/plugin-pre-publish-panel';\nexport { default as PluginSidebar } from './components/sidebar/plugin-sidebar';\nexport { default as PluginSidebarMoreMenuItem } from './components/header/plugin-sidebar-more-menu-item';\nexport { default as __experimentalFullscreenModeClose } from './components/header/fullscreen-mode-close';\nexport { default as __experimentalMainDashboardButton } from './components/header/main-dashboard-button';\nexport { __experimentalPluginPostExcerpt };\nexport { store } from './store';\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SACCC,kBAAkB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