@wordpress/editor 13.24.1 → 13.25.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 +2 -0
- package/build/components/document-bar/index.js +152 -0
- package/build/components/document-bar/index.js.map +1 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build/components/editor-canvas/index.js +292 -0
- package/build/components/editor-canvas/index.js.map +1 -0
- package/build/components/index.js +24 -8
- package/build/components/index.js.map +1 -1
- package/build/components/post-publish-button/index.js +1 -0
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-saved-state/index.js +1 -0
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-template/block-theme.js +99 -0
- package/build/components/post-template/block-theme.js.map +1 -0
- package/build/components/post-template/classic-theme.js +171 -0
- package/build/components/post-template/classic-theme.js.map +1 -0
- package/build/components/post-template/create-new-template-modal.js +98 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -0
- package/build/components/post-template/create-new-template.js +55 -0
- package/build/components/post-template/create-new-template.js.map +1 -0
- package/build/components/post-template/hooks.js +88 -0
- package/build/components/post-template/hooks.js.map +1 -0
- package/build/components/post-template/panel.js +71 -0
- package/build/components/post-template/panel.js.map +1 -0
- package/build/components/post-template/reset-default-template.js +48 -0
- package/build/components/post-template/reset-default-template.js.map +1 -0
- package/build/components/post-template/swap-template-button.js +84 -0
- package/build/components/post-template/swap-template-button.js.map +1 -0
- package/build/components/post-title/index.native.js +0 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/preview-dropdown/index.js +113 -0
- package/build/components/preview-dropdown/index.js.map +1 -0
- package/build/components/provider/index.js +24 -82
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +17 -8
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/navigation-block-editing-mode.js +40 -0
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +9 -10
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +49 -0
- package/build/hooks/pattern-partial-syncing.js.map +1 -0
- package/build/private-apis.js +4 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +59 -11
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +3 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +52 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/reducer.js +32 -27
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +31 -10
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/document-bar/index.js +144 -0
- package/build-module/components/document-bar/index.js.map +1 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +283 -0
- package/build-module/components/editor-canvas/index.js.map +1 -0
- package/build-module/components/index.js +3 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/post-publish-button/index.js +1 -0
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +1 -0
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +1 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-template/block-theme.js +91 -0
- package/build-module/components/post-template/block-theme.js.map +1 -0
- package/build-module/components/post-template/classic-theme.js +162 -0
- package/build-module/components/post-template/classic-theme.js.map +1 -0
- package/build-module/components/post-template/create-new-template-modal.js +91 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
- package/build-module/components/post-template/create-new-template.js +47 -0
- package/build-module/components/post-template/create-new-template.js.map +1 -0
- package/build-module/components/post-template/hooks.js +78 -0
- package/build-module/components/post-template/hooks.js.map +1 -0
- package/build-module/components/post-template/panel.js +63 -0
- package/build-module/components/post-template/panel.js.map +1 -0
- package/build-module/components/post-template/reset-default-template.js +41 -0
- package/build-module/components/post-template/reset-default-template.js.map +1 -0
- package/build-module/components/post-template/swap-template-button.js +77 -0
- package/build-module/components/post-template/swap-template-button.js.map +1 -0
- package/build-module/components/post-title/index.native.js +0 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +105 -0
- package/build-module/components/preview-dropdown/index.js.map +1 -0
- package/build-module/components/provider/index.js +25 -83
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +18 -9
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +9 -10
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +46 -0
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
- package/build-module/private-apis.js +4 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +53 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +3 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +44 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/reducer.js +30 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +26 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +182 -0
- package/build-style/style.css +182 -0
- package/package.json +32 -31
- package/src/components/document-bar/index.js +182 -0
- package/src/components/document-bar/style.scss +130 -0
- package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
- package/src/components/editor-canvas/index.js +381 -0
- package/src/components/index.js +3 -1
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
- package/src/components/post-saved-state/index.js +1 -0
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-template/block-theme.js +109 -0
- package/src/components/post-template/classic-theme.js +213 -0
- package/src/components/post-template/create-new-template-modal.js +139 -0
- package/src/components/post-template/create-new-template.js +50 -0
- package/src/components/post-template/hooks.js +95 -0
- package/src/components/post-template/panel.js +67 -0
- package/src/components/post-template/reset-default-template.js +43 -0
- package/src/components/post-template/style.scss +52 -0
- package/src/components/post-template/swap-template-button.js +83 -0
- package/src/components/post-title/index.native.js +0 -1
- package/src/components/preview-dropdown/index.js +136 -0
- package/src/components/preview-dropdown/style.scss +5 -0
- package/src/components/provider/index.js +28 -118
- package/src/components/provider/index.native.js +26 -12
- package/src/components/provider/navigation-block-editing-mode.js +37 -0
- package/src/components/provider/use-block-editor-settings.js +6 -9
- package/src/hooks/index.js +1 -0
- package/src/hooks/pattern-partial-syncing.js +73 -0
- package/src/private-apis.js +4 -0
- package/src/store/actions.js +51 -9
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +3 -0
- package/src/store/private-actions.js +61 -0
- package/src/store/reducer.js +32 -27
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +64 -42
- package/src/store/test/selectors.js +88 -147
- package/src/style.scss +3 -0
- package/build/components/post-template/index.js +0 -66
- package/build/components/post-template/index.js.map +0 -1
- package/build-module/components/post-template/index.js +0 -57
- package/build-module/components/post-template/index.js.map +0 -1
- package/src/components/post-template/index.js +0 -64
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
6
|
+
import { DropdownMenu, MenuGroup, MenuItem, VisuallyHidden, Icon } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { check, desktop, mobile, tablet, external } from '@wordpress/icons';
|
|
9
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { store as editorStore } from '../../store';
|
|
16
|
+
import PostPreviewButton from '../post-preview-button';
|
|
17
|
+
export default function PreviewDropdown({
|
|
18
|
+
showIconLabels,
|
|
19
|
+
forceIsAutosaveable,
|
|
20
|
+
disabled
|
|
21
|
+
}) {
|
|
22
|
+
const {
|
|
23
|
+
deviceType,
|
|
24
|
+
homeUrl,
|
|
25
|
+
isTemplate,
|
|
26
|
+
isViewable
|
|
27
|
+
} = useSelect(select => {
|
|
28
|
+
var _getPostType$viewable;
|
|
29
|
+
const {
|
|
30
|
+
getDeviceType,
|
|
31
|
+
getCurrentPostType
|
|
32
|
+
} = select(editorStore);
|
|
33
|
+
const {
|
|
34
|
+
getUnstableBase,
|
|
35
|
+
getPostType
|
|
36
|
+
} = select(coreStore);
|
|
37
|
+
const _currentPostType = getCurrentPostType();
|
|
38
|
+
return {
|
|
39
|
+
deviceType: getDeviceType(),
|
|
40
|
+
homeUrl: getUnstableBase()?.home,
|
|
41
|
+
isTemplate: _currentPostType === 'wp_template',
|
|
42
|
+
isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
const {
|
|
46
|
+
setDeviceType
|
|
47
|
+
} = useDispatch(editorStore);
|
|
48
|
+
const isMobile = useViewportMatch('medium', '<');
|
|
49
|
+
if (isMobile) return null;
|
|
50
|
+
const popoverProps = {
|
|
51
|
+
placement: 'bottom-end'
|
|
52
|
+
};
|
|
53
|
+
const toggleProps = {
|
|
54
|
+
className: 'editor-preview-dropdown__toggle',
|
|
55
|
+
size: 'compact',
|
|
56
|
+
showTooltip: !showIconLabels,
|
|
57
|
+
disabled,
|
|
58
|
+
__experimentalIsFocusable: disabled
|
|
59
|
+
};
|
|
60
|
+
const menuProps = {
|
|
61
|
+
'aria-label': __('View options')
|
|
62
|
+
};
|
|
63
|
+
const deviceIcons = {
|
|
64
|
+
mobile,
|
|
65
|
+
tablet,
|
|
66
|
+
desktop
|
|
67
|
+
};
|
|
68
|
+
return createElement(DropdownMenu, {
|
|
69
|
+
className: "editor-preview-dropdown",
|
|
70
|
+
popoverProps: popoverProps,
|
|
71
|
+
toggleProps: toggleProps,
|
|
72
|
+
menuProps: menuProps,
|
|
73
|
+
icon: deviceIcons[deviceType.toLowerCase()],
|
|
74
|
+
label: __('View'),
|
|
75
|
+
disableOpenOnArrowDown: disabled
|
|
76
|
+
}, ({
|
|
77
|
+
onClose
|
|
78
|
+
}) => createElement(Fragment, null, createElement(MenuGroup, null, createElement(MenuItem, {
|
|
79
|
+
onClick: () => setDeviceType('Desktop'),
|
|
80
|
+
icon: deviceType === 'Desktop' && check
|
|
81
|
+
}, __('Desktop')), createElement(MenuItem, {
|
|
82
|
+
onClick: () => setDeviceType('Tablet'),
|
|
83
|
+
icon: deviceType === 'Tablet' && check
|
|
84
|
+
}, __('Tablet')), createElement(MenuItem, {
|
|
85
|
+
onClick: () => setDeviceType('Mobile'),
|
|
86
|
+
icon: deviceType === 'Mobile' && check
|
|
87
|
+
}, __('Mobile'))), isTemplate && createElement(MenuGroup, null, createElement(MenuItem, {
|
|
88
|
+
href: homeUrl,
|
|
89
|
+
target: "_blank",
|
|
90
|
+
icon: external,
|
|
91
|
+
onClick: onClose
|
|
92
|
+
}, __('View site'), createElement(VisuallyHidden, {
|
|
93
|
+
as: "span"
|
|
94
|
+
}, /* translators: accessibility text */
|
|
95
|
+
__('(opens in a new tab)')))), isViewable && createElement(MenuGroup, null, createElement(PostPreviewButton, {
|
|
96
|
+
className: "editor-preview-dropdown__button-external",
|
|
97
|
+
role: "menuitem",
|
|
98
|
+
forceIsAutosaveable: forceIsAutosaveable,
|
|
99
|
+
textContent: createElement(Fragment, null, __('Preview in new tab'), createElement(Icon, {
|
|
100
|
+
icon: external
|
|
101
|
+
})),
|
|
102
|
+
onPreview: onClose
|
|
103
|
+
}))));
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useViewportMatch","DropdownMenu","MenuGroup","MenuItem","VisuallyHidden","Icon","__","check","desktop","mobile","tablet","external","useSelect","useDispatch","store","coreStore","editorStore","PostPreviewButton","PreviewDropdown","showIconLabels","forceIsAutosaveable","disabled","deviceType","homeUrl","isTemplate","isViewable","select","_getPostType$viewable","getDeviceType","getCurrentPostType","getUnstableBase","getPostType","_currentPostType","home","viewable","setDeviceType","isMobile","popoverProps","placement","toggleProps","className","size","showTooltip","__experimentalIsFocusable","menuProps","deviceIcons","createElement","icon","toLowerCase","label","disableOpenOnArrowDown","onClose","Fragment","onClick","href","target","as","role","textContent","onPreview"],"sources":["@wordpress/editor/src/components/preview-dropdown/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useViewportMatch } from '@wordpress/compose';\nimport {\n\tDropdownMenu,\n\tMenuGroup,\n\tMenuItem,\n\tVisuallyHidden,\n\tIcon,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { check, desktop, mobile, tablet, external } from '@wordpress/icons';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\nimport PostPreviewButton from '../post-preview-button';\n\nexport default function PreviewDropdown( {\n\tshowIconLabels,\n\tforceIsAutosaveable,\n\tdisabled,\n} ) {\n\tconst { deviceType, homeUrl, isTemplate, isViewable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDeviceType, getCurrentPostType } = select( editorStore );\n\t\t\tconst { getUnstableBase, getPostType } = select( coreStore );\n\t\t\tconst _currentPostType = getCurrentPostType();\n\t\t\treturn {\n\t\t\t\tdeviceType: getDeviceType(),\n\t\t\t\thomeUrl: getUnstableBase()?.home,\n\t\t\t\tisTemplate: _currentPostType === 'wp_template',\n\t\t\t\tisViewable: getPostType( _currentPostType )?.viewable ?? false,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { setDeviceType } = useDispatch( editorStore );\n\tconst isMobile = useViewportMatch( 'medium', '<' );\n\tif ( isMobile ) return null;\n\n\tconst popoverProps = {\n\t\tplacement: 'bottom-end',\n\t};\n\tconst toggleProps = {\n\t\tclassName: 'editor-preview-dropdown__toggle',\n\t\tsize: 'compact',\n\t\tshowTooltip: ! showIconLabels,\n\t\tdisabled,\n\t\t__experimentalIsFocusable: disabled,\n\t};\n\tconst menuProps = {\n\t\t'aria-label': __( 'View options' ),\n\t};\n\n\tconst deviceIcons = {\n\t\tmobile,\n\t\ttablet,\n\t\tdesktop,\n\t};\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"editor-preview-dropdown\"\n\t\t\tpopoverProps={ popoverProps }\n\t\t\ttoggleProps={ toggleProps }\n\t\t\tmenuProps={ menuProps }\n\t\t\ticon={ deviceIcons[ deviceType.toLowerCase() ] }\n\t\t\tlabel={ __( 'View' ) }\n\t\t\tdisableOpenOnArrowDown={ disabled }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Desktop' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Desktop' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Desktop' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Tablet' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Tablet' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Tablet' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\tonClick={ () => setDeviceType( 'Mobile' ) }\n\t\t\t\t\t\t\ticon={ deviceType === 'Mobile' && check }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Mobile' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t{ isTemplate && (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\thref={ homeUrl }\n\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\ticon={ external }\n\t\t\t\t\t\t\t\tonClick={ onClose }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'View site' ) }\n\t\t\t\t\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t/* translators: accessibility text */\n\t\t\t\t\t\t\t\t\t\t__( '(opens in a new tab)' )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t{ isViewable && (\n\t\t\t\t\t\t<MenuGroup>\n\t\t\t\t\t\t\t<PostPreviewButton\n\t\t\t\t\t\t\t\tclassName=\"editor-preview-dropdown__button-external\"\n\t\t\t\t\t\t\t\trole=\"menuitem\"\n\t\t\t\t\t\t\t\tforceIsAutosaveable={ forceIsAutosaveable }\n\t\t\t\t\t\t\t\ttextContent={\n\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Preview in new tab' ) }\n\t\t\t\t\t\t\t\t\t\t<Icon icon={ external } />\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\tonPreview={ onClose }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,gBAAgB,QAAQ,oBAAoB;AACrD,SACCC,YAAY,EACZC,SAAS,EACTC,QAAQ,EACRC,cAAc,EACdC,IAAI,QACE,uBAAuB;AAC9B,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,EAAEC,OAAO,EAAEC,MAAM,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,kBAAkB;AAC3E,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,aAAa;AAClD,OAAOC,iBAAiB,MAAM,wBAAwB;AAEtD,eAAe,SAASC,eAAeA,CAAE;EACxCC,cAAc;EACdC,mBAAmB;EACnBC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,UAAU;IAAEC,OAAO;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGb,SAAS,CAC9Dc,MAAM,IAAM;IAAA,IAAAC,qBAAA;IACb,MAAM;MA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AAAM,QAAA,QACG9C,EAAE,CAAE,oBAAqB,CAAC,EAC5BwC,aAAA,CAACzC,IAAI;MAAC0C,IAAI,EAAGpC;IAAU,CAAE,CACxB,CACF;IACDgD,SAAS,EAAGR;EAAS,CACrB,CACS,CAEX,CAEU,CAAC;AAEjB"}
|
|
@@ -6,7 +6,7 @@ import { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';
|
|
|
6
6
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
8
|
import { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';
|
|
9
|
-
import { BlockEditorProvider, BlockContextProvider, privateApis as blockEditorPrivateApis
|
|
9
|
+
import { BlockEditorProvider, BlockContextProvider, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
10
10
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
11
|
import { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';
|
|
12
12
|
import { createBlock } from '@wordpress/blocks';
|
|
@@ -19,7 +19,7 @@ import { store as editorStore } from '../../store';
|
|
|
19
19
|
import useBlockEditorSettings from './use-block-editor-settings';
|
|
20
20
|
import { unlock } from '../../lock-unlock';
|
|
21
21
|
import DisableNonPageContentBlocks from './disable-non-page-content-blocks';
|
|
22
|
-
import
|
|
22
|
+
import NavigationBlockEditingMode from './navigation-block-editing-mode';
|
|
23
23
|
const {
|
|
24
24
|
ExperimentalBlockEditorProvider
|
|
25
25
|
} = unlock(blockEditorPrivateApis);
|
|
@@ -28,56 +28,6 @@ const {
|
|
|
28
28
|
} = unlock(editPatternsPrivateApis);
|
|
29
29
|
const noop = () => {};
|
|
30
30
|
|
|
31
|
-
/**
|
|
32
|
-
* For the Navigation block editor, we need to force the block editor to contentOnly for that block.
|
|
33
|
-
*
|
|
34
|
-
* Set block editing mode to contentOnly when entering Navigation focus mode.
|
|
35
|
-
* this ensures that non-content controls on the block will be hidden and thus
|
|
36
|
-
* the user can focus on editing the Navigation Menu content only.
|
|
37
|
-
*
|
|
38
|
-
* @param {string} navigationBlockClientId ClientId.
|
|
39
|
-
*/
|
|
40
|
-
function useForceFocusModeForNavigation(navigationBlockClientId) {
|
|
41
|
-
const {
|
|
42
|
-
setBlockEditingMode,
|
|
43
|
-
unsetBlockEditingMode
|
|
44
|
-
} = useDispatch(blockEditorStore);
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
if (!navigationBlockClientId) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
setBlockEditingMode(navigationBlockClientId, 'contentOnly');
|
|
50
|
-
return () => {
|
|
51
|
-
unsetBlockEditingMode(navigationBlockClientId);
|
|
52
|
-
};
|
|
53
|
-
}, [navigationBlockClientId, unsetBlockEditingMode, setBlockEditingMode]);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Helper method to extract the post content block types from a template.
|
|
58
|
-
*
|
|
59
|
-
* @param {Array} blocks Template blocks.
|
|
60
|
-
*
|
|
61
|
-
* @return {Array} Flattened object.
|
|
62
|
-
*/
|
|
63
|
-
function extractPageContentBlockTypesFromTemplateBlocks(blocks) {
|
|
64
|
-
const result = [];
|
|
65
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
66
|
-
// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,
|
|
67
|
-
// we skip it because we only want to render stand-alone page content blocks in the block list.
|
|
68
|
-
if (blocks[i].name === 'core/query') {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (PAGE_CONTENT_BLOCK_TYPES.includes(blocks[i].name)) {
|
|
72
|
-
result.push(createBlock(blocks[i].name));
|
|
73
|
-
}
|
|
74
|
-
if (blocks[i].innerBlocks.length) {
|
|
75
|
-
result.push(...extractPageContentBlockTypesFromTemplateBlocks(blocks[i].innerBlocks));
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return result;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
31
|
/**
|
|
82
32
|
* Depending on the post, template and template mode,
|
|
83
33
|
* returns the appropriate blocks and change handlers for the block editor provider.
|
|
@@ -106,23 +56,6 @@ function useBlockEditorProps(post, template, mode) {
|
|
|
106
56
|
})];
|
|
107
57
|
}
|
|
108
58
|
}, [post.type, post.id]);
|
|
109
|
-
const maybePostOnlyBlocks = useMemo(() => {
|
|
110
|
-
if (mode === 'post-only') {
|
|
111
|
-
const postContentBlocks = extractPageContentBlockTypesFromTemplateBlocks(templateBlocks);
|
|
112
|
-
return [createBlock('core/group', {
|
|
113
|
-
layout: {
|
|
114
|
-
type: 'constrained'
|
|
115
|
-
},
|
|
116
|
-
style: {
|
|
117
|
-
spacing: {
|
|
118
|
-
margin: {
|
|
119
|
-
top: '4em' // Mimics the post editor.
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
}, postContentBlocks.length ? postContentBlocks : [createBlock('core/post-title'), createBlock('core/post-content')])];
|
|
124
|
-
}
|
|
125
|
-
}, [templateBlocks, mode]);
|
|
126
59
|
|
|
127
60
|
// It is important that we don't create a new instance of blocks on every change
|
|
128
61
|
// We should only create a new instance if the blocks them selves change, not a dependency of them.
|
|
@@ -130,21 +63,16 @@ function useBlockEditorProps(post, template, mode) {
|
|
|
130
63
|
if (maybeNavigationBlocks) {
|
|
131
64
|
return maybeNavigationBlocks;
|
|
132
65
|
}
|
|
133
|
-
if (maybePostOnlyBlocks) {
|
|
134
|
-
return maybePostOnlyBlocks;
|
|
135
|
-
}
|
|
136
66
|
if (rootLevelPost === 'template') {
|
|
137
67
|
return templateBlocks;
|
|
138
68
|
}
|
|
139
69
|
return postBlocks;
|
|
140
|
-
}, [maybeNavigationBlocks,
|
|
70
|
+
}, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
|
|
141
71
|
|
|
142
72
|
// Handle fallback to postBlocks outside of the above useMemo, to ensure
|
|
143
73
|
// that constructed block templates that call `createBlock` are not generated
|
|
144
74
|
// too frequently. This ensures that clientIds are stable.
|
|
145
|
-
const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation'
|
|
146
|
-
const navigationBlockClientId = post.type === 'wp_navigation' && blocks && blocks[0]?.clientId;
|
|
147
|
-
useForceFocusModeForNavigation(navigationBlockClientId);
|
|
75
|
+
const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
|
|
148
76
|
if (disableRootLevelChanges) {
|
|
149
77
|
return [blocks, noop, noop];
|
|
150
78
|
}
|
|
@@ -198,13 +126,14 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
198
126
|
updatePostLock,
|
|
199
127
|
setupEditor,
|
|
200
128
|
updateEditorSettings,
|
|
201
|
-
|
|
202
|
-
|
|
129
|
+
setCurrentTemplateId,
|
|
130
|
+
setEditedPost,
|
|
131
|
+
setRenderingMode
|
|
132
|
+
} = unlock(useDispatch(editorStore));
|
|
203
133
|
const {
|
|
204
134
|
createWarningNotice
|
|
205
135
|
} = useDispatch(noticesStore);
|
|
206
136
|
|
|
207
|
-
// Initialize and tear down the editor.
|
|
208
137
|
// Ideally this should be synced on each change and not just something you do once.
|
|
209
138
|
useLayoutEffect(() => {
|
|
210
139
|
// Assume that we don't need to initialize in the case of an error recovery.
|
|
@@ -222,15 +151,28 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
222
151
|
}]
|
|
223
152
|
});
|
|
224
153
|
}
|
|
225
|
-
return () => {
|
|
226
|
-
__experimentalTearDownEditor();
|
|
227
|
-
};
|
|
228
154
|
}, []);
|
|
229
155
|
|
|
156
|
+
// Synchronizes the active post with the state
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
setEditedPost(post.type, post.id);
|
|
159
|
+
}, [post.type, post.id]);
|
|
160
|
+
|
|
230
161
|
// Synchronize the editor settings as they change.
|
|
231
162
|
useEffect(() => {
|
|
232
163
|
updateEditorSettings(settings);
|
|
233
164
|
}, [settings, updateEditorSettings]);
|
|
165
|
+
|
|
166
|
+
// Synchronizes the active template with the state.
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
setCurrentTemplateId(template?.id);
|
|
169
|
+
}, [template?.id, setCurrentTemplateId]);
|
|
170
|
+
|
|
171
|
+
// Sets the right rendering mode when loading the editor.
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
var _settings$defaultRend;
|
|
174
|
+
setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only');
|
|
175
|
+
}, [settings.defaultRenderingMode, setRenderingMode]);
|
|
234
176
|
if (!isReady) {
|
|
235
177
|
return null;
|
|
236
178
|
}
|
|
@@ -250,7 +192,7 @@ export const ExperimentalEditorProvider = withRegistryProvider(({
|
|
|
250
192
|
selection: selection,
|
|
251
193
|
settings: blockEditorSettings,
|
|
252
194
|
useSubRegistry: false
|
|
253
|
-
}, children, createElement(PatternsMenuItems, null),
|
|
195
|
+
}, children, createElement(PatternsMenuItems, null), mode === 'template-locked' && createElement(DisableNonPageContentBlocks, null), type === 'wp_navigation' && createElement(NavigationBlockEditingMode, null)))));
|
|
254
196
|
});
|
|
255
197
|
export function EditorProvider(props) {
|
|
256
198
|
return createElement(ExperimentalEditorProvider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","blockEditorStore","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","PAGE_CONTENT_BLOCK_TYPES","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","useForceFocusModeForNavigation","navigationBlockClientId","setBlockEditingMode","unsetBlockEditingMode","extractPageContentBlockTypesFromTemplateBlocks","blocks","result","i","length","name","includes","push","innerBlocks","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","ref","templateLock","maybePostOnlyBlocks","postContentBlocks","layout","style","spacing","margin","top","disableRootLevelChanges","clientId","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","__experimentalTearDownEditor","createWarningNotice","postLock","autosave","actions","label","url","editLink","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport { PAGE_CONTENT_BLOCK_TYPES } from './constants';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * For the Navigation block editor, we need to force the block editor to contentOnly for that block.\n *\n * Set block editing mode to contentOnly when entering Navigation focus mode.\n * this ensures that non-content controls on the block will be hidden and thus\n * the user can focus on editing the Navigation Menu content only.\n *\n * @param {string} navigationBlockClientId ClientId.\n */\nfunction useForceFocusModeForNavigation( navigationBlockClientId ) {\n\tconst { setBlockEditingMode, unsetBlockEditingMode } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( ! navigationBlockClientId ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetBlockEditingMode( navigationBlockClientId, 'contentOnly' );\n\n\t\treturn () => {\n\t\t\tunsetBlockEditingMode( navigationBlockClientId );\n\t\t};\n\t}, [\n\t\tnavigationBlockClientId,\n\t\tunsetBlockEditingMode,\n\t\tsetBlockEditingMode,\n\t] );\n}\n\n/**\n * Helper method to extract the post content block types from a template.\n *\n * @param {Array} blocks Template blocks.\n *\n * @return {Array} Flattened object.\n */\nfunction extractPageContentBlockTypesFromTemplateBlocks( blocks ) {\n\tconst result = [];\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\t// Since the Query Block could contain PAGE_CONTENT_BLOCK_TYPES block types,\n\t\t// we skip it because we only want to render stand-alone page content blocks in the block list.\n\t\tif ( blocks[ i ].name === 'core/query' ) {\n\t\t\tcontinue;\n\t\t}\n\t\tif ( PAGE_CONTENT_BLOCK_TYPES.includes( blocks[ i ].name ) ) {\n\t\t\tresult.push( createBlock( blocks[ i ].name ) );\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tresult.push(\n\t\t\t\t...extractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t}\n\n\treturn result;\n}\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\tconst maybePostOnlyBlocks = useMemo( () => {\n\t\tif ( mode === 'post-only' ) {\n\t\t\tconst postContentBlocks =\n\t\t\t\textractPageContentBlockTypesFromTemplateBlocks(\n\t\t\t\t\ttemplateBlocks\n\t\t\t\t);\n\t\t\treturn [\n\t\t\t\tcreateBlock(\n\t\t\t\t\t'core/group',\n\t\t\t\t\t{\n\t\t\t\t\t\tlayout: { type: 'constrained' },\n\t\t\t\t\t\tstyle: {\n\t\t\t\t\t\t\tspacing: {\n\t\t\t\t\t\t\t\tmargin: {\n\t\t\t\t\t\t\t\t\ttop: '4em', // Mimics the post editor.\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\tpostContentBlocks.length\n\t\t\t\t\t\t? postContentBlocks\n\t\t\t\t\t\t: [\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-title' ),\n\t\t\t\t\t\t\t\tcreateBlock( 'core/post-content' ),\n\t\t\t\t\t\t ]\n\t\t\t\t),\n\t\t\t];\n\t\t}\n\t}, [ templateBlocks, mode ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( maybePostOnlyBlocks ) {\n\t\t\treturn maybePostOnlyBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [\n\t\tmaybeNavigationBlocks,\n\t\tmaybePostOnlyBlocks,\n\t\trootLevelPost,\n\t\ttemplateBlocks,\n\t\tpostBlocks,\n\t] );\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation' ||\n\t\tmode === 'post-only';\n\tconst navigationBlockClientId =\n\t\tpost.type === 'wp_navigation' && blocks && blocks[ 0 ]?.clientId;\n\tuseForceFocusModeForNavigation( navigationBlockClientId );\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\t__experimentalTearDownEditor,\n\t\t} = useDispatch( editorStore );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Initialize and tear down the editor.\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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\n\t\t\treturn () => {\n\t\t\t\t__experimentalTearDownEditor();\n\t\t\t};\n\t\t}, [] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ [ 'post-only', 'template-locked' ].includes(\n\t\t\t\t\t\t\t\tmode\n\t\t\t\t\t\t\t) && <DisableNonPageContentBlocks /> }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC3E,SACCC,mBAAmB,EACnBC,oBAAoB,EACpBC,WAAW,IAAIC,sBAAsB,EACrCC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASD,KAAK,IAAIE,YAAY,QAAQ,oBAAoB;AAC1D,SAASJ,WAAW,IAAIK,uBAAuB,QAAQ,qBAAqB;AAC5E,SAASC,WAAW,QAAQ,mBAAmB;;AAE/C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,0BAA0B;AAC3D,SAASL,KAAK,IAAIM,WAAW,QAAQ,aAAa;AAClD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,OAAOC,2BAA2B,MAAM,mCAAmC;AAC3E,SAASC,wBAAwB,QAAQ,aAAa;AAEtD,MAAM;EAAEC;AAAgC,CAAC,GAAGH,MAAM,CAAET,sBAAuB,CAAC;AAC5E,MAAM;EAAEa;AAAkB,CAAC,GAAGJ,MAAM,CAAEL,uBAAwB,CAAC;AAE/D,MAAMU,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB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AAU;IACfrD,IAAI,EAAGP,IAAI,CAACO,IAAM;IAClBC,EAAE,EAAGR,IAAI,CAACQ;EAAI,GAEdmD,aAAA,CAAC1F,oBAAoB;IAAC4F,KAAK,EAAG3B;EAAqB,GAClDyB,aAAA,CAAC9B,4BAA4B;IAC5BgC,KAAK,EAAGtE,MAAQ;IAChBe,QAAQ,EAAGA,QAAU;IACrBD,OAAO,EAAGA,OAAS;IACnBqC,SAAS,EAAGA,SAAW;IACvBjB,QAAQ,EAAGsB,mBAAqB;IAChCe,cAAc,EAAG;EAAO,GAEtBlC,QAAQ,EACV+B,aAAA,CAAC3E,iBAAiB,MAAE,CAAC,EACnB,CAAE,WAAW,EAAE,iBAAiB,CAAE,CAACY,QAAQ,CAC5CM,IACD,CAAC,IAAIyD,aAAA,CAAC9E,2BAA2B,MAAE,CACN,CACT,CACP,CACD,CAAC;AAEnB,CACD,CAAC;AAED,OAAO,SAASkF,cAAcA,CAAEC,KAAK,EAAG;EACvC,OACCL,aAAA,CAACnC,0BAA0B;IAAA,GACrBwC,KAAK;IACVnC,4BAA4B,EAAG7D;EAAqB,GAElDgG,KAAK,CAACpC,QACmB,CAAC;AAE/B;AAEA,eAAemC,cAAc"}
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useMemo","useDispatch","useSelect","__","EntityProvider","useEntityBlockEditor","BlockEditorProvider","BlockContextProvider","privateApis","blockEditorPrivateApis","store","noticesStore","editPatternsPrivateApis","createBlock","withRegistryProvider","editorStore","useBlockEditorSettings","unlock","DisableNonPageContentBlocks","NavigationBlockEditingMode","ExperimentalBlockEditorProvider","PatternsMenuItems","noop","useBlockEditorProps","post","template","mode","rootLevelPost","postBlocks","onInput","onChange","type","id","templateBlocks","onInputTemplate","onChangeTemplate","maybeNavigationBlocks","ref","templateLock","blocks","disableRootLevelChanges","ExperimentalEditorProvider","settings","recovery","initialEdits","children","BlockEditorProviderComponent","__unstableTemplate","select","getRenderingMode","shouldRenderTemplate","defaultBlockContext","postContext","postId","postType","templateSlug","slug","undefined","editorSettings","selection","isReady","getEditorSettings","getEditorSelection","__unstableIsEditorReady","blockEditorSettings","updatePostLock","setupEditor","updateEditorSettings","setCurrentTemplateId","setEditedPost","setRenderingMode","createWarningNotice","postLock","autosave","actions","label","url","editLink","_settings$defaultRend","defaultRenderingMode","createElement","kind","value","useSubRegistry","EditorProvider","props"],"sources":["@wordpress/editor/src/components/provider/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEffect, useLayoutEffect, useMemo } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { EntityProvider, useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tBlockEditorProvider,\n\tBlockContextProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { privateApis as editPatternsPrivateApis } from '@wordpress/patterns';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport withRegistryProvider from './with-registry-provider';\nimport { store as editorStore } from '../../store';\nimport useBlockEditorSettings from './use-block-editor-settings';\nimport { unlock } from '../../lock-unlock';\nimport DisableNonPageContentBlocks from './disable-non-page-content-blocks';\nimport NavigationBlockEditingMode from './navigation-block-editing-mode';\n\nconst { ExperimentalBlockEditorProvider } = unlock( blockEditorPrivateApis );\nconst { PatternsMenuItems } = unlock( editPatternsPrivateApis );\n\nconst noop = () => {};\n\n/**\n * Depending on the post, template and template mode,\n * returns the appropriate blocks and change handlers for the block editor provider.\n *\n * @param {Array} post Block list.\n * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.\n * @param {string} mode Rendering mode.\n * @return {Array} Block editor props.\n */\nfunction useBlockEditorProps( post, template, mode ) {\n\tconst rootLevelPost =\n\t\tmode === 'post-only' || ! template ? 'post' : 'template';\n\tconst [ postBlocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\tpost.type,\n\t\t{ id: post.id }\n\t);\n\tconst [ templateBlocks, onInputTemplate, onChangeTemplate ] =\n\t\tuseEntityBlockEditor( 'postType', template?.type, {\n\t\t\tid: template?.id,\n\t\t} );\n\tconst maybeNavigationBlocks = useMemo( () => {\n\t\tif ( post.type === 'wp_navigation' ) {\n\t\t\treturn [\n\t\t\t\tcreateBlock( 'core/navigation', {\n\t\t\t\t\tref: post.id,\n\t\t\t\t\t// As the parent editor is locked with `templateLock`, the template locking\n\t\t\t\t\t// must be explicitly \"unset\" on the block itself to allow the user to modify\n\t\t\t\t\t// the block's content.\n\t\t\t\t\ttemplateLock: false,\n\t\t\t\t} ),\n\t\t\t];\n\t\t}\n\t}, [ post.type, post.id ] );\n\n\t// It is important that we don't create a new instance of blocks on every change\n\t// We should only create a new instance if the blocks them selves change, not a dependency of them.\n\tconst blocks = useMemo( () => {\n\t\tif ( maybeNavigationBlocks ) {\n\t\t\treturn maybeNavigationBlocks;\n\t\t}\n\n\t\tif ( rootLevelPost === 'template' ) {\n\t\t\treturn templateBlocks;\n\t\t}\n\n\t\treturn postBlocks;\n\t}, [ maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks ] );\n\n\t// Handle fallback to postBlocks outside of the above useMemo, to ensure\n\t// that constructed block templates that call `createBlock` are not generated\n\t// too frequently. This ensures that clientIds are stable.\n\tconst disableRootLevelChanges =\n\t\t( !! template && mode === 'template-locked' ) ||\n\t\tpost.type === 'wp_navigation';\n\tif ( disableRootLevelChanges ) {\n\t\treturn [ blocks, noop, noop ];\n\t}\n\n\treturn [\n\t\tblocks,\n\t\trootLevelPost === 'post' ? onInput : onInputTemplate,\n\t\trootLevelPost === 'post' ? onChange : onChangeTemplate,\n\t];\n}\n\nexport const ExperimentalEditorProvider = withRegistryProvider(\n\t( {\n\t\tpost,\n\t\tsettings,\n\t\trecovery,\n\t\tinitialEdits,\n\t\tchildren,\n\t\tBlockEditorProviderComponent = ExperimentalBlockEditorProvider,\n\t\t__unstableTemplate: template,\n\t} ) => {\n\t\tconst mode = useSelect(\n\t\t\t( select ) => select( editorStore ).getRenderingMode(),\n\t\t\t[]\n\t\t);\n\t\tconst shouldRenderTemplate = !! template && mode !== 'post-only';\n\t\tconst rootLevelPost = shouldRenderTemplate ? template : post;\n\t\tconst defaultBlockContext = useMemo( () => {\n\t\t\tconst postContext =\n\t\t\t\trootLevelPost.type !== 'wp_template' ||\n\t\t\t\t( shouldRenderTemplate && mode !== 'template-only' )\n\t\t\t\t\t? { postId: post.id, postType: post.type }\n\t\t\t\t\t: {};\n\n\t\t\treturn {\n\t\t\t\t...postContext,\n\t\t\t\ttemplateSlug:\n\t\t\t\t\trootLevelPost.type === 'wp_template'\n\t\t\t\t\t\t? rootLevelPost.slug\n\t\t\t\t\t\t: undefined,\n\t\t\t};\n\t\t}, [\n\t\t\tmode,\n\t\t\tpost.id,\n\t\t\tpost.type,\n\t\t\trootLevelPost.type,\n\t\t\trootLevelPost?.slug,\n\t\t\tshouldRenderTemplate,\n\t\t] );\n\t\tconst { editorSettings, selection, isReady } = useSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEditorSettings,\n\t\t\t\t\tgetEditorSelection,\n\t\t\t\t\t__unstableIsEditorReady,\n\t\t\t\t} = select( editorStore );\n\t\t\t\treturn {\n\t\t\t\t\teditorSettings: getEditorSettings(),\n\t\t\t\t\tisReady: __unstableIsEditorReady(),\n\t\t\t\t\tselection: getEditorSelection(),\n\t\t\t\t};\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t\tconst { id, type } = rootLevelPost;\n\t\tconst blockEditorSettings = useBlockEditorSettings(\n\t\t\teditorSettings,\n\t\t\ttype,\n\t\t\tid\n\t\t);\n\t\tconst [ blocks, onInput, onChange ] = useBlockEditorProps(\n\t\t\tpost,\n\t\t\ttemplate,\n\t\t\tmode\n\t\t);\n\n\t\tconst {\n\t\t\tupdatePostLock,\n\t\t\tsetupEditor,\n\t\t\tupdateEditorSettings,\n\t\t\tsetCurrentTemplateId,\n\t\t\tsetEditedPost,\n\t\t\tsetRenderingMode,\n\t\t} = unlock( useDispatch( editorStore ) );\n\t\tconst { createWarningNotice } = useDispatch( noticesStore );\n\n\t\t// Ideally this should be synced on each change and not just something you do once.\n\t\tuseLayoutEffect( () => {\n\t\t\t// Assume that we don't need to initialize in the case of an error recovery.\n\t\t\tif ( recovery ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tupdatePostLock( settings.postLock );\n\t\t\tsetupEditor( post, initialEdits, settings.template );\n\t\t\tif ( settings.autosave ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'There is an autosave of this post that is more recent than the version below.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\tid: 'autosave-exists',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'View the autosave' ),\n\t\t\t\t\t\t\t\turl: settings.autosave.editLink,\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\n\t\t// Synchronizes the active post with the state\n\t\tuseEffect( () => {\n\t\t\tsetEditedPost( post.type, post.id );\n\t\t}, [ post.type, post.id ] );\n\n\t\t// Synchronize the editor settings as they change.\n\t\tuseEffect( () => {\n\t\t\tupdateEditorSettings( settings );\n\t\t}, [ settings, updateEditorSettings ] );\n\n\t\t// Synchronizes the active template with the state.\n\t\tuseEffect( () => {\n\t\t\tsetCurrentTemplateId( template?.id );\n\t\t}, [ template?.id, setCurrentTemplateId ] );\n\n\t\t// Sets the right rendering mode when loading the editor.\n\t\tuseEffect( () => {\n\t\t\tsetRenderingMode( settings.defaultRenderingMode ?? 'post-only' );\n\t\t}, [ settings.defaultRenderingMode, setRenderingMode ] );\n\n\t\tif ( ! isReady ) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn (\n\t\t\t<EntityProvider kind=\"root\" type=\"site\">\n\t\t\t\t<EntityProvider\n\t\t\t\t\tkind=\"postType\"\n\t\t\t\t\ttype={ post.type }\n\t\t\t\t\tid={ post.id }\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ defaultBlockContext }>\n\t\t\t\t\t\t<BlockEditorProviderComponent\n\t\t\t\t\t\t\tvalue={ blocks }\n\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\tonInput={ onInput }\n\t\t\t\t\t\t\tselection={ selection }\n\t\t\t\t\t\t\tsettings={ blockEditorSettings }\n\t\t\t\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t<PatternsMenuItems />\n\t\t\t\t\t\t\t{ mode === 'template-locked' && (\n\t\t\t\t\t\t\t\t<DisableNonPageContentBlocks />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t{ type === 'wp_navigation' && (\n\t\t\t\t\t\t\t\t<NavigationBlockEditingMode />\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BlockEditorProviderComponent>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</EntityProvider>\n\t\t\t</EntityProvider>\n\t\t);\n\t}\n);\n\nexport function EditorProvider( props ) {\n\treturn (\n\t\t<ExperimentalEditorProvider\n\t\t\t{ ...props }\n\t\t\tBlockEditorProviderComponent={ BlockEditorProvider }\n\t\t>\n\t\t\t{ props.children }\n\t\t</ExperimentalEditorProvider>\n\t);\n}\n\nexport default EditorProvider;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,eAAe,EAAEC,OAAO,QAAQ,oBAAoB;AACxE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,cAAc,EAAEC,oBAAoB,QAAQ,sBAAsB;AAC3E,SACCC,mBAAmB,EACnBC,oBAAoB,EACpBC,WAAW,IAAIC,sBA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|
@@ -11,13 +11,14 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|
|
11
11
|
import RNReactNativeGutenbergBridge, { requestBlockTypeImpressions, setBlockTypeImpressions, subscribeParentGetHtml, subscribeParentToggleHTMLMode, subscribeUpdateHtml, subscribeSetTitle, subscribeMediaAppend, subscribeReplaceBlock, subscribeUpdateEditorSettings, subscribeUpdateCapabilities, subscribeShowNotice, subscribeShowEditorHelp } from '@wordpress/react-native-bridge';
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
13
|
import { count as wordCount } from '@wordpress/wordcount';
|
|
14
|
-
import { parse, serialize, getUnregisteredTypeHandlerName, createBlock } from '@wordpress/blocks';
|
|
14
|
+
import { parse, serialize, getUnregisteredTypeHandlerName, getBlockType, createBlock } from '@wordpress/blocks';
|
|
15
15
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
16
16
|
import { compose } from '@wordpress/compose';
|
|
17
17
|
import { applyFilters } from '@wordpress/hooks';
|
|
18
18
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
19
19
|
import { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';
|
|
20
20
|
import { NEW_BLOCK_TYPES } from '@wordpress/block-library';
|
|
21
|
+
import { __ } from '@wordpress/i18n';
|
|
21
22
|
const postTypeEntities = [{
|
|
22
23
|
name: 'post',
|
|
23
24
|
baseURL: '/wp/v2/posts'
|
|
@@ -73,6 +74,7 @@ class NativeEditorProvider extends Component {
|
|
|
73
74
|
componentDidMount() {
|
|
74
75
|
const {
|
|
75
76
|
capabilities,
|
|
77
|
+
createErrorNotice,
|
|
76
78
|
locale,
|
|
77
79
|
hostAppNamespace,
|
|
78
80
|
updateEditorSettings,
|
|
@@ -101,13 +103,18 @@ class NativeEditorProvider extends Component {
|
|
|
101
103
|
});
|
|
102
104
|
this.subscriptionParentMediaAppend = subscribeMediaAppend(payload => {
|
|
103
105
|
const blockName = 'core/' + payload.mediaType;
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
106
|
+
const blockType = getBlockType(blockName);
|
|
107
|
+
if (blockType && blockType?.name) {
|
|
108
|
+
const newBlock = createBlock(blockType.name, {
|
|
109
|
+
id: payload.mediaId,
|
|
110
|
+
[payload.mediaType === 'image' ? 'url' : 'src']: payload.mediaUrl
|
|
111
|
+
});
|
|
112
|
+
const indexAfterSelected = this.props.selectedBlockIndex + 1;
|
|
113
|
+
const insertionIndex = indexAfterSelected || this.props.blockCount;
|
|
114
|
+
this.props.insertBlock(newBlock, insertionIndex);
|
|
115
|
+
} else {
|
|
116
|
+
createErrorNotice(__('File type not supported as a media file.'));
|
|
117
|
+
}
|
|
111
118
|
});
|
|
112
119
|
this.subscriptionParentUpdateEditorSettings = subscribeUpdateEditorSettings(({
|
|
113
120
|
galleryWithImageBlocks,
|
|
@@ -329,7 +336,8 @@ const ComposedNativeProvider = compose([withSelect(select => {
|
|
|
329
336
|
receiveEntityRecords
|
|
330
337
|
} = dispatch(coreStore);
|
|
331
338
|
const {
|
|
332
|
-
createSuccessNotice
|
|
339
|
+
createSuccessNotice,
|
|
340
|
+
createErrorNotice
|
|
333
341
|
} = dispatch(noticesStore);
|
|
334
342
|
return {
|
|
335
343
|
updateBlockEditorSettings: updateSettings,
|
|
@@ -337,6 +345,7 @@ const ComposedNativeProvider = compose([withSelect(select => {
|
|
|
337
345
|
addEntities,
|
|
338
346
|
insertBlock,
|
|
339
347
|
createSuccessNotice,
|
|
348
|
+
createErrorNotice,
|
|
340
349
|
editTitle(title) {
|
|
341
350
|
editPost({
|
|
342
351
|
title
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["memize","SafeAreaProvider","RNReactNativeGutenbergBridge","requestBlockTypeImpressions","setBlockTypeImpressions","subscribeParentGetHtml","subscribeParentToggleHTMLMode","subscribeUpdateHtml","subscribeSetTitle","subscribeMediaAppend","subscribeReplaceBlock","subscribeUpdateEditorSettings","subscribeUpdateCapabilities","subscribeShowNotice","subscribeShowEditorHelp","Component","count","wordCount","parse","serialize","getUnregisteredTypeHandlerName","createBlock","withDispatch","withSelect","compose","applyFilters","store","blockEditorStore","getGlobalStyles","getColorsAndGradients","NEW_BLOCK_TYPES","postTypeEntities","name","baseURL","map","postTypeEntity","kind","transientEdits","blocks","selection","mergedEdits","meta","rawAttributes","EditorHelpTopics","editorStore","noticesStore","coreStore","editPostStore","EditorProvider","NativeEditorProvider","constructor","arguments","post","props","addEntities","receiveEntityRecords","type","getEditorSettings","settings","capabilities","maxSize","state","isHelpVisible","componentDidMount","locale","hostAppNamespace","updateEditorSettings","updateBlockEditorSettings","getThemeColors","subscriptionParentGetHtml","serializeToNativeAction","subscriptionParentToggleHTMLMode","toggleMode","subscriptionParentSetTitle","payload","editTitle","title","subscriptionParentUpdateHtml","updateHtmlAction","html","subscriptionParentReplaceBlock","replaceBlockAction","clientId","subscriptionParentMediaAppend","blockName","mediaType","newBlock","id","mediaId","mediaUrl","indexAfterSelected","selectedBlockIndex","insertionIndex","blockCount","insertBlock","subscriptionParentUpdateEditorSettings","galleryWithImageBlocks","editorSettings","window","wp","galleryBlockV2Enabled","subscriptionParentUpdateCapabilities","updateCapabilitiesAction","subscriptionParentShowNotice","createSuccessNotice","message","subscriptionParentShowEditorHelp","setState","storedImpressions","impressions","storedImpressionKeys","Object","keys","storedImpressionsCurrent","every","newKey","includes","componentWillUnmount","remove","rawStyles","rawFeatures","defaultEditorColors","defaultEditorGradients","componentDidUpdate","prevProps","isReady","isUnsupportedBlock","unsupportedBlockNames","filter","block","attributes","originalName","editorDidMount","mode","hasChanges","raw","content","contentInfo","characterCount","paragraphCount","provideToNative_Html","parsed","resetEditorBlocksWithoutUndoLevel","blockClientId","replaceBlock","switchMode","render","children","createElement","Fragment","isVisible","onClose","close","showSupport","supportSection","ComposedNativeProvider","select","_settings$colors","_settings$gradients","__unstableIsEditorReady","isEditorReady","getEditorBlocks","getEditedPostAttribute","getEditedPostContent","getEditorMode","getBlockIndex","getSelectedBlockClientId","getGlobalBlockCount","colors","gradients","selectedBlockClientId","dispatch","editPost","resetEditorBlocks","updateSettings","switchEditorMode","__unstableShouldCreateUndoLevel","ExperimentalEditorProvider"],"sources":["@wordpress/editor/src/components/provider/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\n/**\n * WordPress dependencies\n */\nimport RNReactNativeGutenbergBridge, {\n\trequestBlockTypeImpressions,\n\tsetBlockTypeImpressions,\n\tsubscribeParentGetHtml,\n\tsubscribeParentToggleHTMLMode,\n\tsubscribeUpdateHtml,\n\tsubscribeSetTitle,\n\tsubscribeMediaAppend,\n\tsubscribeReplaceBlock,\n\tsubscribeUpdateEditorSettings,\n\tsubscribeUpdateCapabilities,\n\tsubscribeShowNotice,\n\tsubscribeShowEditorHelp,\n} from '@wordpress/react-native-bridge';\nimport { Component } from '@wordpress/element';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport {\n\tparse,\n\tserialize,\n\tgetUnregisteredTypeHandlerName,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';\nimport { NEW_BLOCK_TYPES } from '@wordpress/block-library';\n\nconst postTypeEntities = [\n\t{ name: 'post', baseURL: '/wp/v2/posts' },\n\t{ name: 'page', baseURL: '/wp/v2/pages' },\n\t{ name: 'attachment', baseURL: '/wp/v2/media' },\n\t{ name: 'wp_block', baseURL: '/wp/v2/blocks' },\n].map( ( postTypeEntity ) => ( {\n\tkind: 'postType',\n\t...postTypeEntity,\n\ttransientEdits: {\n\t\tblocks: true,\n\t\tselection: true,\n\t},\n\tmergedEdits: {\n\t\tmeta: true,\n\t},\n\trawAttributes: [ 'title', 'excerpt', 'content' ],\n} ) );\nimport { EditorHelpTopics, store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n// eslint-disable-next-line no-restricted-imports\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport EditorProvider from './index.js';\n\nclass NativeEditorProvider extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\t// Keep a local reference to `post` to detect changes.\n\t\tthis.post = this.props.post;\n\t\tthis.props.addEntities( postTypeEntities );\n\t\tthis.props.receiveEntityRecords(\n\t\t\t'postType',\n\t\t\tthis.post.type,\n\t\t\tthis.post\n\t\t);\n\n\t\tthis.getEditorSettings = memize(\n\t\t\t( settings, capabilities ) => ( {\n\t\t\t\t...settings,\n\t\t\t\tcapabilities,\n\t\t\t} ),\n\t\t\t{\n\t\t\t\tmaxSize: 1,\n\t\t\t}\n\t\t);\n\t\tthis.state = {\n\t\t\tisHelpVisible: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst {\n\t\t\tcapabilities,\n\t\t\tlocale,\n\t\t\thostAppNamespace,\n\t\t\tupdateEditorSettings,\n\t\t\tupdateBlockEditorSettings,\n\t\t} = this.props;\n\n\t\tupdateEditorSettings( {\n\t\t\tcapabilities,\n\t\t\t...this.getThemeColors( this.props ),\n\t\t\tlocale,\n\t\t\thostAppNamespace,\n\t\t} );\n\n\t\tthis.subscriptionParentGetHtml = subscribeParentGetHtml( () => {\n\t\t\tthis.serializeToNativeAction();\n\t\t} );\n\n\t\tthis.subscriptionParentToggleHTMLMode = subscribeParentToggleHTMLMode(\n\t\t\t() => {\n\t\t\t\tthis.toggleMode();\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentSetTitle = subscribeSetTitle( ( payload ) => {\n\t\t\tthis.props.editTitle( payload.title );\n\t\t} );\n\n\t\tthis.subscriptionParentUpdateHtml = subscribeUpdateHtml(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateHtmlAction( payload.html );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentReplaceBlock = subscribeReplaceBlock(\n\t\t\t( payload ) => {\n\t\t\t\tthis.replaceBlockAction( payload.html, payload.clientId );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentMediaAppend = subscribeMediaAppend(\n\t\t\t( payload ) => {\n\t\t\t\tconst blockName = 'core/' + payload.mediaType;\n\t\t\t\tconst newBlock = createBlock( blockName, {\n\t\t\t\t\tid: payload.mediaId,\n\t\t\t\t\t[ payload.mediaType === 'image' ? 'url' : 'src' ]:\n\t\t\t\t\t\tpayload.mediaUrl,\n\t\t\t\t} );\n\n\t\t\t\tconst indexAfterSelected = this.props.selectedBlockIndex + 1;\n\t\t\t\tconst insertionIndex =\n\t\t\t\t\tindexAfterSelected || this.props.blockCount;\n\n\t\t\t\tthis.props.insertBlock( newBlock, insertionIndex );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateEditorSettings =\n\t\t\tsubscribeUpdateEditorSettings(\n\t\t\t\t( { galleryWithImageBlocks, ...editorSettings } ) => {\n\t\t\t\t\tif ( typeof galleryWithImageBlocks === 'boolean' ) {\n\t\t\t\t\t\twindow.wp.galleryBlockV2Enabled =\n\t\t\t\t\t\t\tgalleryWithImageBlocks;\n\t\t\t\t\t}\n\t\t\t\t\tupdateEditorSettings(\n\t\t\t\t\t\tthis.getThemeColors( editorSettings )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\tthis.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateCapabilitiesAction( payload );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowNotice = subscribeShowNotice(\n\t\t\t( payload ) => {\n\t\t\t\tthis.props.createSuccessNotice( payload.message );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {\n\t\t\tthis.setState( { isHelpVisible: true } );\n\t\t} );\n\n\t\t// Request current block impressions from native app.\n\t\trequestBlockTypeImpressions( ( storedImpressions ) => {\n\t\t\tconst impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };\n\n\t\t\t// Persist impressions to JavaScript store.\n\t\t\tupdateBlockEditorSettings( { impressions } );\n\n\t\t\t// Persist impressions to native store if they do not include latest\n\t\t\t// `NEW_BLOCK_TYPES` configuration.\n\t\t\tconst storedImpressionKeys = Object.keys( storedImpressions );\n\t\t\tconst storedImpressionsCurrent = Object.keys(\n\t\t\t\tNEW_BLOCK_TYPES\n\t\t\t).every( ( newKey ) => storedImpressionKeys.includes( newKey ) );\n\t\t\tif ( ! storedImpressionsCurrent ) {\n\t\t\t\tsetBlockTypeImpressions( impressions );\n\t\t\t}\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentGetHtml ) {\n\t\t\tthis.subscriptionParentGetHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentToggleHTMLMode ) {\n\t\t\tthis.subscriptionParentToggleHTMLMode.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentSetTitle ) {\n\t\t\tthis.subscriptionParentSetTitle.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateHtml ) {\n\t\t\tthis.subscriptionParentUpdateHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentReplaceBlock ) {\n\t\t\tthis.subscriptionParentReplaceBlock.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentMediaAppend ) {\n\t\t\tthis.subscriptionParentMediaAppend.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateEditorSettings ) {\n\t\t\tthis.subscriptionParentUpdateEditorSettings.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateCapabilities ) {\n\t\t\tthis.subscriptionParentUpdateCapabilities.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowNotice ) {\n\t\t\tthis.subscriptionParentShowNotice.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowEditorHelp ) {\n\t\t\tthis.subscriptionParentShowEditorHelp.remove();\n\t\t}\n\t}\n\n\tgetThemeColors( { rawStyles, rawFeatures } ) {\n\t\tconst { defaultEditorColors, defaultEditorGradients } = this.props;\n\n\t\tif ( rawStyles && rawFeatures ) {\n\t\t\treturn getGlobalStyles( rawStyles, rawFeatures );\n\t\t}\n\n\t\treturn getColorsAndGradients(\n\t\t\tdefaultEditorColors,\n\t\t\tdefaultEditorGradients,\n\t\t\trawFeatures\n\t\t);\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! prevProps.isReady && this.props.isReady ) {\n\t\t\tconst blocks = this.props.blocks;\n\t\t\tconst isUnsupportedBlock = ( { name } ) =>\n\t\t\t\tname === getUnregisteredTypeHandlerName();\n\t\t\tconst unsupportedBlockNames = blocks\n\t\t\t\t.filter( isUnsupportedBlock )\n\t\t\t\t.map( ( block ) => block.attributes.originalName );\n\t\t\tRNReactNativeGutenbergBridge.editorDidMount(\n\t\t\t\tunsupportedBlockNames\n\t\t\t);\n\t\t}\n\t}\n\n\tserializeToNativeAction() {\n\t\tconst title = this.props.title;\n\t\tlet html;\n\n\t\tif ( this.props.mode === 'text' ) {\n\t\t\t// The HTMLTextInput component does not update the store when user is doing changes\n\t\t\t// Let's request the HTML from the component's state directly.\n\t\t\thtml = applyFilters( 'native.persist-html' );\n\t\t} else {\n\t\t\thtml = serialize( this.props.blocks );\n\t\t}\n\n\t\tconst hasChanges =\n\t\t\ttitle !== this.post.title.raw || html !== this.post.content.raw;\n\n\t\t// Variable to store the content structure metrics.\n\t\tconst contentInfo = {};\n\t\tcontentInfo.characterCount = wordCount(\n\t\t\thtml,\n\t\t\t'characters_including_spaces'\n\t\t);\n\t\tcontentInfo.wordCount = wordCount( html, 'words' );\n\t\tcontentInfo.paragraphCount = this.props.paragraphCount;\n\t\tcontentInfo.blockCount = this.props.blockCount;\n\t\tRNReactNativeGutenbergBridge.provideToNative_Html(\n\t\t\thtml,\n\t\t\ttitle,\n\t\t\thasChanges,\n\t\t\tcontentInfo\n\t\t);\n\n\t\tif ( hasChanges ) {\n\t\t\tthis.post.title.raw = title;\n\t\t\tthis.post.content.raw = html;\n\t\t}\n\t}\n\n\tupdateHtmlAction( html ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.resetEditorBlocksWithoutUndoLevel( parsed );\n\t}\n\n\treplaceBlockAction( html, blockClientId ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.replaceBlock( blockClientId, parsed );\n\t}\n\n\ttoggleMode() {\n\t\tconst { mode, switchMode } = this.props;\n\t\t// Refresh html content first.\n\t\tthis.serializeToNativeAction();\n\t\tswitchMode( mode === 'visual' ? 'text' : 'visual' );\n\t}\n\n\tupdateCapabilitiesAction( capabilities ) {\n\t\tthis.props.updateEditorSettings( { capabilities } );\n\t}\n\n\trender() {\n\t\tconst { children, post, capabilities, settings, ...props } = this.props;\n\t\tconst editorSettings = this.getEditorSettings( settings, capabilities );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ this.post }\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<SafeAreaProvider>{ children }</SafeAreaProvider>\n\t\t\t\t</EditorProvider>\n\t\t\t\t<EditorHelpTopics\n\t\t\t\t\tisVisible={ this.state.isHelpVisible }\n\t\t\t\t\tonClose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t\tclose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t\tshowSupport={ capabilities?.supportSection === true }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nconst ComposedNativeProvider = compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\t__unstableIsEditorReady: isEditorReady,\n\t\t\tgetEditorBlocks,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostContent,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\tconst { getBlockIndex, getSelectedBlockClientId, getGlobalBlockCount } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst settings = getEditorSettings();\n\t\tconst defaultEditorColors = settings?.colors ?? [];\n\t\tconst defaultEditorGradients = settings?.gradients ?? [];\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t\tisReady: isEditorReady(),\n\t\t\tblocks: getEditorBlocks(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tgetEditedPostContent,\n\t\t\tdefaultEditorColors,\n\t\t\tdefaultEditorGradients,\n\t\t\tselectedBlockIndex: getBlockIndex( selectedBlockClientId ),\n\t\t\tblockCount: getGlobalBlockCount(),\n\t\t\tparagraphCount: getGlobalBlockCount( 'core/paragraph' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, resetEditorBlocks, updateEditorSettings } =\n\t\t\tdispatch( editorStore );\n\t\tconst { updateSettings, insertBlock, replaceBlock } =\n\t\t\tdispatch( blockEditorStore );\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { addEntities, receiveEntityRecords } = dispatch( coreStore );\n\t\tconst { createSuccessNotice } = dispatch( noticesStore );\n\n\t\treturn {\n\t\t\tupdateBlockEditorSettings: updateSettings,\n\t\t\tupdateEditorSettings,\n\t\t\taddEntities,\n\t\t\tinsertBlock,\n\t\t\tcreateSuccessNotice,\n\t\t\teditTitle( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\treceiveEntityRecords,\n\t\t\tresetEditorBlocksWithoutUndoLevel( blocks ) {\n\t\t\t\tresetEditorBlocks( blocks, {\n\t\t\t\t\t__unstableShouldCreateUndoLevel: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tswitchMode( mode ) {\n\t\t\t\tswitchEditorMode( mode );\n\t\t\t},\n\t\t\treplaceBlock,\n\t\t};\n\t} ),\n] )( NativeEditorProvider );\n\nexport default ComposedNativeProvider;\nexport { ComposedNativeProvider as ExperimentalEditorProvider };\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ,gCAAgC;;AAEjE;AACA;AACA;AACA,OAAOC,4BAA4B,IAClCC,2BAA2B,EAC3BC,uBAAuB,EACvBC,sBAAsB,EACtBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,iBAAiB,EACjBC,oBAAoB,EACpBC,qBAAqB,EACrBC,6BAA6B,EAC7BC,2BAA2B,EAC3BC,mBAAmB,EACnBC,uBAAuB,QACjB,gCAAgC;AACvC,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,KAAK,EACLC,SAAS,EACTC,8BAA8B,EAC9BC,WAAW,QACL,mBAAmB;AAC1B,SAASC,YAAY,EAAEC,UAAU,QAAQ,iBAAiB;AAC1D,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,eAAe,EAAEC,qBAAqB,QAAQ,uBAAuB;AAC9E,SAASC,eAAe,QAAQ,0BAA0B;AAE1D,MAAMC,gBAAgB,GAAG,CACxB;EAAEC,IAAI,EAAE,MAAM;EAAEC,OAAO,EAAE;AAAe,CAAC,EACzC;EAAED,IAAI,EAAE,MAAM;EAAEC,OAAO,EAAE;AAAe,CAAC,EACzC;EAAED,IAAI,EAAE,YAAY;EAAEC,OAAO,EAAE;AAAe,CAAC,EAC/C;EAAED,IAAI,EAAE,UAAU;EAAEC,OAAO,EAAE;AAAgB,CAAC,CAC9C,CAACC,GAAG,CAAIC,cAAc,KAAQ;EAC9BC,IAAI,EAAE,UAAU;EAChB,GAAGD,cAAc;EACj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KAAK,EAAG;MAClBgG,QAAQ,CAAE;QAAEhG;MAAM,CAAE,CAAC;IACtB,CAAC;IACDrB,oBAAoB;IACpBuF,iCAAiCA,CAAExG,MAAM,EAAG;MAC3CuI,iBAAiB,CAAEvI,MAAM,EAAE;QAC1B0I,+BAA+B,EAAE;MAClC,CAAE,CAAC;IACJ,CAAC;IACD/B,UAAUA,CAAEZ,IAAI,EAAG;MAClB0C,gBAAgB,CAAE1C,IAAK,CAAC;IACzB,CAAC;IACDW;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAE/F,oBAAqB,CAAC;AAE3B,eAAe0G,sBAAsB;AACrC,SAASA,sBAAsB,IAAIsB,0BAA0B"}
|
|
1
|
+
{"version":3,"names":["memize","SafeAreaProvider","RNReactNativeGutenbergBridge","requestBlockTypeImpressions","setBlockTypeImpressions","subscribeParentGetHtml","subscribeParentToggleHTMLMode","subscribeUpdateHtml","subscribeSetTitle","subscribeMediaAppend","subscribeReplaceBlock","subscribeUpdateEditorSettings","subscribeUpdateCapabilities","subscribeShowNotice","subscribeShowEditorHelp","Component","count","wordCount","parse","serialize","getUnregisteredTypeHandlerName","getBlockType","createBlock","withDispatch","withSelect","compose","applyFilters","store","blockEditorStore","getGlobalStyles","getColorsAndGradients","NEW_BLOCK_TYPES","__","postTypeEntities","name","baseURL","map","postTypeEntity","kind","transientEdits","blocks","selection","mergedEdits","meta","rawAttributes","EditorHelpTopics","editorStore","noticesStore","coreStore","editPostStore","EditorProvider","NativeEditorProvider","constructor","arguments","post","props","addEntities","receiveEntityRecords","type","getEditorSettings","settings","capabilities","maxSize","state","isHelpVisible","componentDidMount","createErrorNotice","locale","hostAppNamespace","updateEditorSettings","updateBlockEditorSettings","getThemeColors","subscriptionParentGetHtml","serializeToNativeAction","subscriptionParentToggleHTMLMode","toggleMode","subscriptionParentSetTitle","payload","editTitle","title","subscriptionParentUpdateHtml","updateHtmlAction","html","subscriptionParentReplaceBlock","replaceBlockAction","clientId","subscriptionParentMediaAppend","blockName","mediaType","blockType","newBlock","id","mediaId","mediaUrl","indexAfterSelected","selectedBlockIndex","insertionIndex","blockCount","insertBlock","subscriptionParentUpdateEditorSettings","galleryWithImageBlocks","editorSettings","window","wp","galleryBlockV2Enabled","subscriptionParentUpdateCapabilities","updateCapabilitiesAction","subscriptionParentShowNotice","createSuccessNotice","message","subscriptionParentShowEditorHelp","setState","storedImpressions","impressions","storedImpressionKeys","Object","keys","storedImpressionsCurrent","every","newKey","includes","componentWillUnmount","remove","rawStyles","rawFeatures","defaultEditorColors","defaultEditorGradients","componentDidUpdate","prevProps","isReady","isUnsupportedBlock","unsupportedBlockNames","filter","block","attributes","originalName","editorDidMount","mode","hasChanges","raw","content","contentInfo","characterCount","paragraphCount","provideToNative_Html","parsed","resetEditorBlocksWithoutUndoLevel","blockClientId","replaceBlock","switchMode","render","children","createElement","Fragment","isVisible","onClose","close","showSupport","supportSection","ComposedNativeProvider","select","_settings$colors","_settings$gradients","__unstableIsEditorReady","isEditorReady","getEditorBlocks","getEditedPostAttribute","getEditedPostContent","getEditorMode","getBlockIndex","getSelectedBlockClientId","getGlobalBlockCount","colors","gradients","selectedBlockClientId","dispatch","editPost","resetEditorBlocks","updateSettings","switchEditorMode","__unstableShouldCreateUndoLevel","ExperimentalEditorProvider"],"sources":["@wordpress/editor/src/components/provider/index.native.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport memize from 'memize';\nimport { SafeAreaProvider } from 'react-native-safe-area-context';\n\n/**\n * WordPress dependencies\n */\nimport RNReactNativeGutenbergBridge, {\n\trequestBlockTypeImpressions,\n\tsetBlockTypeImpressions,\n\tsubscribeParentGetHtml,\n\tsubscribeParentToggleHTMLMode,\n\tsubscribeUpdateHtml,\n\tsubscribeSetTitle,\n\tsubscribeMediaAppend,\n\tsubscribeReplaceBlock,\n\tsubscribeUpdateEditorSettings,\n\tsubscribeUpdateCapabilities,\n\tsubscribeShowNotice,\n\tsubscribeShowEditorHelp,\n} from '@wordpress/react-native-bridge';\nimport { Component } from '@wordpress/element';\nimport { count as wordCount } from '@wordpress/wordcount';\nimport {\n\tparse,\n\tserialize,\n\tgetUnregisteredTypeHandlerName,\n\tgetBlockType,\n\tcreateBlock,\n} from '@wordpress/blocks';\nimport { withDispatch, withSelect } from '@wordpress/data';\nimport { compose } from '@wordpress/compose';\nimport { applyFilters } from '@wordpress/hooks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { getGlobalStyles, getColorsAndGradients } from '@wordpress/components';\nimport { NEW_BLOCK_TYPES } from '@wordpress/block-library';\nimport { __ } from '@wordpress/i18n';\n\nconst postTypeEntities = [\n\t{ name: 'post', baseURL: '/wp/v2/posts' },\n\t{ name: 'page', baseURL: '/wp/v2/pages' },\n\t{ name: 'attachment', baseURL: '/wp/v2/media' },\n\t{ name: 'wp_block', baseURL: '/wp/v2/blocks' },\n].map( ( postTypeEntity ) => ( {\n\tkind: 'postType',\n\t...postTypeEntity,\n\ttransientEdits: {\n\t\tblocks: true,\n\t\tselection: true,\n\t},\n\tmergedEdits: {\n\t\tmeta: true,\n\t},\n\trawAttributes: [ 'title', 'excerpt', 'content' ],\n} ) );\nimport { EditorHelpTopics, store as editorStore } from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { store as coreStore } from '@wordpress/core-data';\n// eslint-disable-next-line no-restricted-imports\nimport { store as editPostStore } from '@wordpress/edit-post';\n\n/**\n * Internal dependencies\n */\nimport EditorProvider from './index.js';\n\nclass NativeEditorProvider extends Component {\n\tconstructor() {\n\t\tsuper( ...arguments );\n\n\t\t// Keep a local reference to `post` to detect changes.\n\t\tthis.post = this.props.post;\n\t\tthis.props.addEntities( postTypeEntities );\n\t\tthis.props.receiveEntityRecords(\n\t\t\t'postType',\n\t\t\tthis.post.type,\n\t\t\tthis.post\n\t\t);\n\n\t\tthis.getEditorSettings = memize(\n\t\t\t( settings, capabilities ) => ( {\n\t\t\t\t...settings,\n\t\t\t\tcapabilities,\n\t\t\t} ),\n\t\t\t{\n\t\t\t\tmaxSize: 1,\n\t\t\t}\n\t\t);\n\t\tthis.state = {\n\t\t\tisHelpVisible: false,\n\t\t};\n\t}\n\n\tcomponentDidMount() {\n\t\tconst {\n\t\t\tcapabilities,\n\t\t\tcreateErrorNotice,\n\t\t\tlocale,\n\t\t\thostAppNamespace,\n\t\t\tupdateEditorSettings,\n\t\t\tupdateBlockEditorSettings,\n\t\t} = this.props;\n\n\t\tupdateEditorSettings( {\n\t\t\tcapabilities,\n\t\t\t...this.getThemeColors( this.props ),\n\t\t\tlocale,\n\t\t\thostAppNamespace,\n\t\t} );\n\n\t\tthis.subscriptionParentGetHtml = subscribeParentGetHtml( () => {\n\t\t\tthis.serializeToNativeAction();\n\t\t} );\n\n\t\tthis.subscriptionParentToggleHTMLMode = subscribeParentToggleHTMLMode(\n\t\t\t() => {\n\t\t\t\tthis.toggleMode();\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentSetTitle = subscribeSetTitle( ( payload ) => {\n\t\t\tthis.props.editTitle( payload.title );\n\t\t} );\n\n\t\tthis.subscriptionParentUpdateHtml = subscribeUpdateHtml(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateHtmlAction( payload.html );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentReplaceBlock = subscribeReplaceBlock(\n\t\t\t( payload ) => {\n\t\t\t\tthis.replaceBlockAction( payload.html, payload.clientId );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentMediaAppend = subscribeMediaAppend(\n\t\t\t( payload ) => {\n\t\t\t\tconst blockName = 'core/' + payload.mediaType;\n\t\t\t\tconst blockType = getBlockType( blockName );\n\n\t\t\t\tif ( blockType && blockType?.name ) {\n\t\t\t\t\tconst newBlock = createBlock( blockType.name, {\n\t\t\t\t\t\tid: payload.mediaId,\n\t\t\t\t\t\t[ payload.mediaType === 'image' ? 'url' : 'src' ]:\n\t\t\t\t\t\t\tpayload.mediaUrl,\n\t\t\t\t\t} );\n\n\t\t\t\t\tconst indexAfterSelected =\n\t\t\t\t\t\tthis.props.selectedBlockIndex + 1;\n\t\t\t\t\tconst insertionIndex =\n\t\t\t\t\t\tindexAfterSelected || this.props.blockCount;\n\n\t\t\t\t\tthis.props.insertBlock( newBlock, insertionIndex );\n\t\t\t\t} else {\n\t\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t\t__( 'File type not supported as a media file.' )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentUpdateEditorSettings =\n\t\t\tsubscribeUpdateEditorSettings(\n\t\t\t\t( { galleryWithImageBlocks, ...editorSettings } ) => {\n\t\t\t\t\tif ( typeof galleryWithImageBlocks === 'boolean' ) {\n\t\t\t\t\t\twindow.wp.galleryBlockV2Enabled =\n\t\t\t\t\t\t\tgalleryWithImageBlocks;\n\t\t\t\t\t}\n\t\t\t\t\tupdateEditorSettings(\n\t\t\t\t\t\tthis.getThemeColors( editorSettings )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t);\n\n\t\tthis.subscriptionParentUpdateCapabilities = subscribeUpdateCapabilities(\n\t\t\t( payload ) => {\n\t\t\t\tthis.updateCapabilitiesAction( payload );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowNotice = subscribeShowNotice(\n\t\t\t( payload ) => {\n\t\t\t\tthis.props.createSuccessNotice( payload.message );\n\t\t\t}\n\t\t);\n\n\t\tthis.subscriptionParentShowEditorHelp = subscribeShowEditorHelp( () => {\n\t\t\tthis.setState( { isHelpVisible: true } );\n\t\t} );\n\n\t\t// Request current block impressions from native app.\n\t\trequestBlockTypeImpressions( ( storedImpressions ) => {\n\t\t\tconst impressions = { ...NEW_BLOCK_TYPES, ...storedImpressions };\n\n\t\t\t// Persist impressions to JavaScript store.\n\t\t\tupdateBlockEditorSettings( { impressions } );\n\n\t\t\t// Persist impressions to native store if they do not include latest\n\t\t\t// `NEW_BLOCK_TYPES` configuration.\n\t\t\tconst storedImpressionKeys = Object.keys( storedImpressions );\n\t\t\tconst storedImpressionsCurrent = Object.keys(\n\t\t\t\tNEW_BLOCK_TYPES\n\t\t\t).every( ( newKey ) => storedImpressionKeys.includes( newKey ) );\n\t\t\tif ( ! storedImpressionsCurrent ) {\n\t\t\t\tsetBlockTypeImpressions( impressions );\n\t\t\t}\n\t\t} );\n\t}\n\n\tcomponentWillUnmount() {\n\t\tif ( this.subscriptionParentGetHtml ) {\n\t\t\tthis.subscriptionParentGetHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentToggleHTMLMode ) {\n\t\t\tthis.subscriptionParentToggleHTMLMode.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentSetTitle ) {\n\t\t\tthis.subscriptionParentSetTitle.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateHtml ) {\n\t\t\tthis.subscriptionParentUpdateHtml.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentReplaceBlock ) {\n\t\t\tthis.subscriptionParentReplaceBlock.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentMediaAppend ) {\n\t\t\tthis.subscriptionParentMediaAppend.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateEditorSettings ) {\n\t\t\tthis.subscriptionParentUpdateEditorSettings.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentUpdateCapabilities ) {\n\t\t\tthis.subscriptionParentUpdateCapabilities.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowNotice ) {\n\t\t\tthis.subscriptionParentShowNotice.remove();\n\t\t}\n\n\t\tif ( this.subscriptionParentShowEditorHelp ) {\n\t\t\tthis.subscriptionParentShowEditorHelp.remove();\n\t\t}\n\t}\n\n\tgetThemeColors( { rawStyles, rawFeatures } ) {\n\t\tconst { defaultEditorColors, defaultEditorGradients } = this.props;\n\n\t\tif ( rawStyles && rawFeatures ) {\n\t\t\treturn getGlobalStyles( rawStyles, rawFeatures );\n\t\t}\n\n\t\treturn getColorsAndGradients(\n\t\t\tdefaultEditorColors,\n\t\t\tdefaultEditorGradients,\n\t\t\trawFeatures\n\t\t);\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tif ( ! prevProps.isReady && this.props.isReady ) {\n\t\t\tconst blocks = this.props.blocks;\n\t\t\tconst isUnsupportedBlock = ( { name } ) =>\n\t\t\t\tname === getUnregisteredTypeHandlerName();\n\t\t\tconst unsupportedBlockNames = blocks\n\t\t\t\t.filter( isUnsupportedBlock )\n\t\t\t\t.map( ( block ) => block.attributes.originalName );\n\t\t\tRNReactNativeGutenbergBridge.editorDidMount(\n\t\t\t\tunsupportedBlockNames\n\t\t\t);\n\t\t}\n\t}\n\n\tserializeToNativeAction() {\n\t\tconst title = this.props.title;\n\t\tlet html;\n\n\t\tif ( this.props.mode === 'text' ) {\n\t\t\t// The HTMLTextInput component does not update the store when user is doing changes\n\t\t\t// Let's request the HTML from the component's state directly.\n\t\t\thtml = applyFilters( 'native.persist-html' );\n\t\t} else {\n\t\t\thtml = serialize( this.props.blocks );\n\t\t}\n\n\t\tconst hasChanges =\n\t\t\ttitle !== this.post.title.raw || html !== this.post.content.raw;\n\n\t\t// Variable to store the content structure metrics.\n\t\tconst contentInfo = {};\n\t\tcontentInfo.characterCount = wordCount(\n\t\t\thtml,\n\t\t\t'characters_including_spaces'\n\t\t);\n\t\tcontentInfo.wordCount = wordCount( html, 'words' );\n\t\tcontentInfo.paragraphCount = this.props.paragraphCount;\n\t\tcontentInfo.blockCount = this.props.blockCount;\n\t\tRNReactNativeGutenbergBridge.provideToNative_Html(\n\t\t\thtml,\n\t\t\ttitle,\n\t\t\thasChanges,\n\t\t\tcontentInfo\n\t\t);\n\n\t\tif ( hasChanges ) {\n\t\t\tthis.post.title.raw = title;\n\t\t\tthis.post.content.raw = html;\n\t\t}\n\t}\n\n\tupdateHtmlAction( html ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.resetEditorBlocksWithoutUndoLevel( parsed );\n\t}\n\n\treplaceBlockAction( html, blockClientId ) {\n\t\tconst parsed = parse( html );\n\t\tthis.props.replaceBlock( blockClientId, parsed );\n\t}\n\n\ttoggleMode() {\n\t\tconst { mode, switchMode } = this.props;\n\t\t// Refresh html content first.\n\t\tthis.serializeToNativeAction();\n\t\tswitchMode( mode === 'visual' ? 'text' : 'visual' );\n\t}\n\n\tupdateCapabilitiesAction( capabilities ) {\n\t\tthis.props.updateEditorSettings( { capabilities } );\n\t}\n\n\trender() {\n\t\tconst { children, post, capabilities, settings, ...props } = this.props;\n\t\tconst editorSettings = this.getEditorSettings( settings, capabilities );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<EditorProvider\n\t\t\t\t\tpost={ this.post }\n\t\t\t\t\tsettings={ editorSettings }\n\t\t\t\t\t{ ...props }\n\t\t\t\t>\n\t\t\t\t\t<SafeAreaProvider>{ children }</SafeAreaProvider>\n\t\t\t\t</EditorProvider>\n\t\t\t\t<EditorHelpTopics\n\t\t\t\t\tisVisible={ this.state.isHelpVisible }\n\t\t\t\t\tonClose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t\tclose={ () => this.setState( { isHelpVisible: false } ) }\n\t\t\t\t\tshowSupport={ capabilities?.supportSection === true }\n\t\t\t\t/>\n\t\t\t</>\n\t\t);\n\t}\n}\n\nconst ComposedNativeProvider = compose( [\n\twithSelect( ( select ) => {\n\t\tconst {\n\t\t\t__unstableIsEditorReady: isEditorReady,\n\t\t\tgetEditorBlocks,\n\t\t\tgetEditedPostAttribute,\n\t\t\tgetEditedPostContent,\n\t\t\tgetEditorSettings,\n\t\t} = select( editorStore );\n\t\tconst { getEditorMode } = select( editPostStore );\n\n\t\tconst { getBlockIndex, getSelectedBlockClientId, getGlobalBlockCount } =\n\t\t\tselect( blockEditorStore );\n\n\t\tconst settings = getEditorSettings();\n\t\tconst defaultEditorColors = settings?.colors ?? [];\n\t\tconst defaultEditorGradients = settings?.gradients ?? [];\n\n\t\tconst selectedBlockClientId = getSelectedBlockClientId();\n\t\treturn {\n\t\t\tmode: getEditorMode(),\n\t\t\tisReady: isEditorReady(),\n\t\t\tblocks: getEditorBlocks(),\n\t\t\ttitle: getEditedPostAttribute( 'title' ),\n\t\t\tgetEditedPostContent,\n\t\t\tdefaultEditorColors,\n\t\t\tdefaultEditorGradients,\n\t\t\tselectedBlockIndex: getBlockIndex( selectedBlockClientId ),\n\t\t\tblockCount: getGlobalBlockCount(),\n\t\t\tparagraphCount: getGlobalBlockCount( 'core/paragraph' ),\n\t\t};\n\t} ),\n\twithDispatch( ( dispatch ) => {\n\t\tconst { editPost, resetEditorBlocks, updateEditorSettings } =\n\t\t\tdispatch( editorStore );\n\t\tconst { updateSettings, insertBlock, replaceBlock } =\n\t\t\tdispatch( blockEditorStore );\n\t\tconst { switchEditorMode } = dispatch( editPostStore );\n\t\tconst { addEntities, receiveEntityRecords } = dispatch( coreStore );\n\t\tconst { createSuccessNotice, createErrorNotice } =\n\t\t\tdispatch( noticesStore );\n\n\t\treturn {\n\t\t\tupdateBlockEditorSettings: updateSettings,\n\t\t\tupdateEditorSettings,\n\t\t\taddEntities,\n\t\t\tinsertBlock,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateErrorNotice,\n\t\t\teditTitle( title ) {\n\t\t\t\teditPost( { title } );\n\t\t\t},\n\t\t\treceiveEntityRecords,\n\t\t\tresetEditorBlocksWithoutUndoLevel( blocks ) {\n\t\t\t\tresetEditorBlocks( blocks, {\n\t\t\t\t\t__unstableShouldCreateUndoLevel: false,\n\t\t\t\t} );\n\t\t\t},\n\t\t\tswitchMode( mode ) {\n\t\t\t\tswitchEditorMode( mode );\n\t\t\t},\n\t\t\treplaceBlock,\n\t\t};\n\t} ),\n] )( NativeEditorProvider );\n\nexport default ComposedNativeProvider;\nexport { ComposedNativeProvider as ExperimentalEditorProvider };\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,MAAM,MAAM,QAAQ;AAC3B,SAASC,gBAAgB,QAAQ,gCAAgC;;AAEjE;AACA;AACA;AACA,OAAOC,4BAA4B,IAClCC,2BAA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,mBAAmB;IACnB1C,iBAAiB;IACjBY,SAASA,CAAEC,KAAK,EAAG;MAClBiG,QAAQ,CAAE;QAAEjG;MAAM,CAAE,CAAC;IACtB,CAAC;IACDtB,oBAAoB;IACpByF,iCAAiCA,CAAE1G,MAAM,EAAG;MAC3CyI,iBAAiB,CAAEzI,MAAM,EAAE;QAC1B4I,+BAA+B,EAAE;MAClC,CAAE,CAAC;IACJ,CAAC;IACD/B,UAAUA,CAAEZ,IAAI,EAAG;MAClB0C,gBAAgB,CAAE1C,IAAK,CAAC;IACzB,CAAC;IACDW;EACD,CAAC;AACF,CAAE,CAAC,CACF,CAAC,CAAEjG,oBAAqB,CAAC;AAE3B,eAAe4G,sBAAsB;AACrC,SAASA,sBAAsB,IAAIsB,0BAA0B"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useEffect } from '@wordpress/element';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* For the Navigation block editor, we need to force the block editor to contentOnly for that block.
|
|
10
|
+
*
|
|
11
|
+
* Set block editing mode to contentOnly when entering Navigation focus mode.
|
|
12
|
+
* this ensures that non-content controls on the block will be hidden and thus
|
|
13
|
+
* the user can focus on editing the Navigation Menu content only.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export default function NavigationBlockEditingMode() {
|
|
17
|
+
// In the navigation block editor,
|
|
18
|
+
// the navigation block is the only root block.
|
|
19
|
+
const blockClientId = useSelect(select => select(blockEditorStore).getBlockOrder()?.[0], []);
|
|
20
|
+
const {
|
|
21
|
+
setBlockEditingMode,
|
|
22
|
+
unsetBlockEditingMode
|
|
23
|
+
} = useDispatch(blockEditorStore);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (!blockClientId) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setBlockEditingMode(blockClientId, 'contentOnly');
|
|
29
|
+
return () => {
|
|
30
|
+
unsetBlockEditingMode(blockClientId);
|
|
31
|
+
};
|
|
32
|
+
}, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=navigation-block-editing-mode.js.map
|