@wordpress/edit-post 7.34.0 → 8.0.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 +15 -2
- package/build/commands/use-commands.js +56 -0
- package/build/commands/use-commands.js.map +1 -0
- package/build/components/{header/fullscreen-mode-close/index.js → back-button/fullscreen-mode-close.js} +18 -16
- package/build/components/back-button/fullscreen-mode-close.js.map +1 -0
- package/build/components/back-button/index.js +57 -0
- package/build/components/back-button/index.js.map +1 -0
- package/build/components/header/header-toolbar/index.native.js +63 -62
- package/build/components/header/header-toolbar/index.native.js.map +1 -1
- package/build/components/header/index.native.js +2 -2
- package/build/components/header/index.native.js.map +1 -1
- package/build/components/init-pattern-modal/index.js +50 -43
- package/build/components/init-pattern-modal/index.js.map +1 -1
- package/build/components/layout/index.js +134 -156
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +28 -21
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/{visual-editor → layout}/use-padding-appender.js +6 -1
- package/build/components/layout/use-padding-appender.js.map +1 -0
- package/build/components/layout/use-should-iframe.js +46 -0
- package/build/components/layout/use-should-iframe.js.map +1 -0
- package/build/components/meta-boxes/index.js +10 -9
- package/build/components/meta-boxes/index.js.map +1 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +13 -13
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build/components/more-menu/index.js +49 -0
- package/build/components/more-menu/index.js.map +1 -0
- package/build/components/{header/more-menu → more-menu}/manage-patterns-menu-item.js +6 -5
- package/build/components/more-menu/manage-patterns-menu-item.js.map +1 -0
- package/build/components/{header/more-menu → more-menu}/welcome-guide-menu-item.js +2 -2
- package/build/components/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build/components/preferences-modal/enable-custom-fields.js +23 -18
- package/build/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build/components/preferences-modal/index.js +4 -4
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/meta-boxes-section.js +13 -13
- package/build/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build/components/visual-editor/header.native.js +11 -10
- package/build/components/visual-editor/header.native.js.map +1 -1
- package/build/components/visual-editor/index.native.js +3 -3
- package/build/components/visual-editor/index.native.js.map +1 -1
- package/build/components/welcome-guide/default.js +50 -33
- package/build/components/welcome-guide/default.js.map +1 -1
- package/build/components/welcome-guide/image.js +13 -12
- package/build/components/welcome-guide/image.js.map +1 -1
- package/build/components/welcome-guide/index.js +2 -2
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/components/welcome-guide/template.js +12 -8
- package/build/components/welcome-guide/template.js.map +1 -1
- package/build/deprecated.js +9 -9
- package/build/deprecated.js.map +1 -1
- package/build/editor.js +16 -11
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +18 -12
- package/build/editor.native.js.map +1 -1
- package/build/index.js +12 -13
- package/build/index.js.map +1 -1
- package/build/index.native.js +2 -2
- package/build/index.native.js.map +1 -1
- package/build/store/selectors.js +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/commands/use-commands.js +49 -0
- package/build-module/commands/use-commands.js.map +1 -0
- package/build-module/components/{header/fullscreen-mode-close/index.js → back-button/fullscreen-mode-close.js} +18 -16
- package/build-module/components/back-button/fullscreen-mode-close.js.map +1 -0
- package/build-module/components/back-button/index.js +49 -0
- package/build-module/components/back-button/index.js.map +1 -0
- package/build-module/components/header/header-toolbar/index.native.js +64 -62
- package/build-module/components/header/header-toolbar/index.native.js.map +1 -1
- package/build-module/components/header/index.native.js +2 -2
- package/build-module/components/header/index.native.js.map +1 -1
- package/build-module/components/init-pattern-modal/index.js +52 -43
- package/build-module/components/init-pattern-modal/index.js.map +1 -1
- package/build-module/components/layout/index.js +139 -159
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +30 -21
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/{visual-editor → layout}/use-padding-appender.js +6 -1
- package/build-module/components/layout/use-padding-appender.js.map +1 -0
- package/build-module/components/layout/use-should-iframe.js +39 -0
- package/build-module/components/layout/use-should-iframe.js.map +1 -0
- package/build-module/components/meta-boxes/index.js +12 -9
- package/build-module/components/meta-boxes/index.js.map +1 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +13 -11
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +1 -1
- package/build-module/components/more-menu/index.js +43 -0
- package/build-module/components/more-menu/index.js.map +1 -0
- package/build-module/components/{header/more-menu → more-menu}/manage-patterns-menu-item.js +6 -5
- package/build-module/components/more-menu/manage-patterns-menu-item.js.map +1 -0
- package/build-module/components/{header/more-menu → more-menu}/welcome-guide-menu-item.js +2 -2
- package/build-module/components/more-menu/welcome-guide-menu-item.js.map +1 -0
- package/build-module/components/preferences-modal/enable-custom-fields.js +25 -18
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +4 -4
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +14 -13
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +1 -1
- package/build-module/components/visual-editor/header.native.js +11 -10
- package/build-module/components/visual-editor/header.native.js.map +1 -1
- package/build-module/components/visual-editor/index.native.js +3 -3
- package/build-module/components/visual-editor/index.native.js.map +1 -1
- package/build-module/components/welcome-guide/default.js +52 -33
- package/build-module/components/welcome-guide/default.js.map +1 -1
- package/build-module/components/welcome-guide/image.js +14 -12
- package/build-module/components/welcome-guide/image.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +2 -2
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/components/welcome-guide/template.js +14 -8
- package/build-module/components/welcome-guide/template.js.map +1 -1
- package/build-module/deprecated.js +9 -9
- package/build-module/deprecated.js.map +1 -1
- package/build-module/editor.js +17 -11
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +18 -12
- package/build-module/editor.native.js.map +1 -1
- package/build-module/index.js +10 -7
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/store/selectors.js +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +31 -392
- package/build-style/style.css +31 -392
- package/package.json +33 -33
- package/src/commands/use-commands.js +48 -0
- package/src/components/{header/fullscreen-mode-close/index.js → back-button/fullscreen-mode-close.js} +3 -3
- package/src/components/back-button/index.js +34 -0
- package/src/components/{header/fullscreen-mode-close → back-button}/style.scss +16 -2
- package/src/components/{header/fullscreen-mode-close/test/index.js → back-button/test/fullscreen-mode-close.js} +1 -1
- package/src/components/layout/index.js +151 -207
- package/src/components/layout/style.scss +9 -17
- package/src/components/{visual-editor → layout}/use-padding-appender.js +7 -1
- package/src/components/layout/use-should-iframe.js +40 -0
- package/src/components/meta-boxes/meta-boxes-area/index.js +4 -8
- package/src/components/{header/more-menu → more-menu}/index.js +2 -2
- package/src/components/{header/more-menu → more-menu}/manage-patterns-menu-item.js +1 -1
- package/src/index.js +11 -6
- package/src/store/selectors.js +8 -5
- package/src/style.scss +3 -10
- package/src/test/__snapshots__/editor.native.js.snap +72 -0
- package/src/test/editor.native.js +77 -0
- package/build/components/header/fullscreen-mode-close/index.js.map +0 -1
- package/build/components/header/index.js +0 -158
- package/build/components/header/index.js.map +0 -1
- package/build/components/header/main-dashboard-button/index.js +0 -33
- package/build/components/header/main-dashboard-button/index.js.map +0 -1
- package/build/components/header/more-menu/index.js +0 -43
- package/build/components/header/more-menu/index.js.map +0 -1
- package/build/components/header/more-menu/manage-patterns-menu-item.js.map +0 -1
- package/build/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build/components/sidebar/post-format/index.js +0 -21
- package/build/components/sidebar/post-format/index.js.map +0 -1
- package/build/components/sidebar/post-pending-status/index.js +0 -26
- package/build/components/sidebar/post-pending-status/index.js.map +0 -1
- package/build/components/sidebar/post-slug/index.js +0 -21
- package/build/components/sidebar/post-slug/index.js.map +0 -1
- package/build/components/sidebar/post-status/index.js +0 -92
- package/build/components/sidebar/post-status/index.js.map +0 -1
- package/build/components/sidebar/post-sticky/index.js +0 -26
- package/build/components/sidebar/post-sticky/index.js.map +0 -1
- package/build/components/sidebar/post-trash/index.js +0 -16
- package/build/components/sidebar/post-trash/index.js.map +0 -1
- package/build/components/sidebar/post-visibility/index.js +0 -78
- package/build/components/sidebar/post-visibility/index.js.map +0 -1
- package/build/components/sidebar/settings-header/index.js +0 -53
- package/build/components/sidebar/settings-header/index.js.map +0 -1
- package/build/components/sidebar/settings-sidebar/index.js +0 -193
- package/build/components/sidebar/settings-sidebar/index.js.map +0 -1
- package/build/components/text-editor/index.js +0 -61
- package/build/components/text-editor/index.js.map +0 -1
- package/build/components/visual-editor/block-inspector-button.js +0 -55
- package/build/components/visual-editor/block-inspector-button.js.map +0 -1
- package/build/components/visual-editor/index.js +0 -92
- package/build/components/visual-editor/index.js.map +0 -1
- package/build/components/visual-editor/use-padding-appender.js.map +0 -1
- package/build/hooks/commands/use-common-commands.js +0 -119
- package/build/hooks/commands/use-common-commands.js.map +0 -1
- package/build/hooks/components/index.js +0 -11
- package/build/hooks/components/index.js.map +0 -1
- package/build/hooks/index.js +0 -5
- package/build/hooks/index.js.map +0 -1
- package/build/hooks/validate-multiple-use/index.js +0 -134
- package/build/hooks/validate-multiple-use/index.js.map +0 -1
- package/build-module/components/header/fullscreen-mode-close/index.js.map +0 -1
- package/build-module/components/header/index.js +0 -150
- package/build-module/components/header/index.js.map +0 -1
- package/build-module/components/header/main-dashboard-button/index.js +0 -26
- package/build-module/components/header/main-dashboard-button/index.js.map +0 -1
- package/build-module/components/header/more-menu/index.js +0 -35
- package/build-module/components/header/more-menu/index.js.map +0 -1
- package/build-module/components/header/more-menu/manage-patterns-menu-item.js.map +0 -1
- package/build-module/components/header/more-menu/welcome-guide-menu-item.js.map +0 -1
- package/build-module/components/sidebar/post-format/index.js +0 -13
- package/build-module/components/sidebar/post-format/index.js.map +0 -1
- package/build-module/components/sidebar/post-pending-status/index.js +0 -18
- package/build-module/components/sidebar/post-pending-status/index.js.map +0 -1
- package/build-module/components/sidebar/post-slug/index.js +0 -13
- package/build-module/components/sidebar/post-slug/index.js.map +0 -1
- package/build-module/components/sidebar/post-status/index.js +0 -84
- package/build-module/components/sidebar/post-status/index.js.map +0 -1
- package/build-module/components/sidebar/post-sticky/index.js +0 -18
- package/build-module/components/sidebar/post-sticky/index.js.map +0 -1
- package/build-module/components/sidebar/post-trash/index.js +0 -9
- package/build-module/components/sidebar/post-trash/index.js.map +0 -1
- package/build-module/components/sidebar/post-visibility/index.js +0 -70
- package/build-module/components/sidebar/post-visibility/index.js.map +0 -1
- package/build-module/components/sidebar/settings-header/index.js +0 -46
- package/build-module/components/sidebar/settings-header/index.js.map +0 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +0 -185
- package/build-module/components/sidebar/settings-sidebar/index.js.map +0 -1
- package/build-module/components/text-editor/index.js +0 -54
- package/build-module/components/text-editor/index.js.map +0 -1
- package/build-module/components/visual-editor/block-inspector-button.js +0 -47
- package/build-module/components/visual-editor/block-inspector-button.js.map +0 -1
- package/build-module/components/visual-editor/index.js +0 -84
- package/build-module/components/visual-editor/index.js.map +0 -1
- package/build-module/components/visual-editor/use-padding-appender.js.map +0 -1
- package/build-module/hooks/commands/use-common-commands.js +0 -112
- package/build-module/hooks/commands/use-common-commands.js.map +0 -1
- package/build-module/hooks/components/index.js +0 -8
- package/build-module/hooks/components/index.js.map +0 -1
- package/build-module/hooks/index.js +0 -6
- package/build-module/hooks/index.js.map +0 -1
- package/build-module/hooks/validate-multiple-use/index.js +0 -132
- package/build-module/hooks/validate-multiple-use/index.js.map +0 -1
- package/src/components/header/index.js +0 -156
- package/src/components/header/main-dashboard-button/index.js +0 -28
- package/src/components/header/style.scss +0 -251
- package/src/components/sidebar/post-format/index.js +0 -20
- package/src/components/sidebar/post-format/style.scss +0 -5
- package/src/components/sidebar/post-pending-status/index.js +0 -27
- package/src/components/sidebar/post-slug/index.js +0 -17
- package/src/components/sidebar/post-slug/style.scss +0 -5
- package/src/components/sidebar/post-status/index.js +0 -128
- package/src/components/sidebar/post-sticky/index.js +0 -27
- package/src/components/sidebar/post-trash/index.js +0 -12
- package/src/components/sidebar/post-visibility/index.js +0 -88
- package/src/components/sidebar/post-visibility/style.scss +0 -5
- package/src/components/sidebar/settings-header/index.js +0 -49
- package/src/components/sidebar/settings-sidebar/index.js +0 -247
- package/src/components/sidebar/style.scss +0 -18
- package/src/components/text-editor/index.js +0 -63
- package/src/components/text-editor/style.scss +0 -71
- package/src/components/visual-editor/block-inspector-button.js +0 -59
- package/src/components/visual-editor/index.js +0 -101
- package/src/components/visual-editor/style.scss +0 -53
- package/src/hooks/commands/use-common-commands.js +0 -126
- package/src/hooks/components/index.js +0 -13
- package/src/hooks/index.js +0 -5
- package/src/hooks/validate-multiple-use/index.js +0 -163
- /package/src/components/{header/fullscreen-mode-close/test/__snapshots__/index.js.snap → back-button/test/__snapshots__/fullscreen-mode-close.js.snap} +0 -0
- /package/src/components/{header/more-menu → more-menu}/welcome-guide-menu-item.js +0 -0
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { BlockInspector, store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
7
|
-
import { Platform, useCallback, useContext, useEffect, useRef } from '@wordpress/element';
|
|
8
|
-
import { isRTL, __, sprintf } from '@wordpress/i18n';
|
|
9
|
-
import { drawerLeft, drawerRight } from '@wordpress/icons';
|
|
10
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
11
|
-
import { store as editorStore, PageAttributesPanel, PluginDocumentSettingPanel, PluginSidebar, PostDiscussionPanel, PostLastRevisionPanel, PostTaxonomiesPanel, privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
12
|
-
import { addQueryArgs } from '@wordpress/url';
|
|
13
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import SettingsHeader from '../settings-header';
|
|
19
|
-
import PostStatus from '../post-status';
|
|
20
|
-
import MetaBoxes from '../../meta-boxes';
|
|
21
|
-
import { store as editPostStore } from '../../../store';
|
|
22
|
-
import { privateApis as componentsPrivateApis } from '@wordpress/components';
|
|
23
|
-
import { unlock } from '../../../lock-unlock';
|
|
24
|
-
const {
|
|
25
|
-
PostCardPanel,
|
|
26
|
-
PostActions,
|
|
27
|
-
interfaceStore
|
|
28
|
-
} = unlock(editorPrivateApis);
|
|
29
|
-
const {
|
|
30
|
-
Tabs
|
|
31
|
-
} = unlock(componentsPrivateApis);
|
|
32
|
-
const {
|
|
33
|
-
PatternOverridesPanel,
|
|
34
|
-
useAutoSwitchEditorSidebars
|
|
35
|
-
} = unlock(editorPrivateApis);
|
|
36
|
-
const SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select({
|
|
37
|
-
web: true,
|
|
38
|
-
native: false
|
|
39
|
-
});
|
|
40
|
-
export const sidebars = {
|
|
41
|
-
document: 'edit-post/document',
|
|
42
|
-
block: 'edit-post/block'
|
|
43
|
-
};
|
|
44
|
-
const SidebarContent = ({
|
|
45
|
-
tabName,
|
|
46
|
-
keyboardShortcut,
|
|
47
|
-
isEditingTemplate
|
|
48
|
-
}) => {
|
|
49
|
-
const tabListRef = useRef(null);
|
|
50
|
-
// Because `PluginSidebar` renders a `ComplementaryArea`, we
|
|
51
|
-
// need to forward the `Tabs` context so it can be passed through the
|
|
52
|
-
// underlying slot/fill.
|
|
53
|
-
const tabsContextValue = useContext(Tabs.Context);
|
|
54
|
-
|
|
55
|
-
// This effect addresses a race condition caused by tabbing from the last
|
|
56
|
-
// block in the editor into the settings sidebar. Without this effect, the
|
|
57
|
-
// selected tab and browser focus can become separated in an unexpected way
|
|
58
|
-
// (e.g the "block" tab is focused, but the "post" tab is selected).
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
|
|
61
|
-
const selectedTabElement = tabsElements.find(
|
|
62
|
-
// We are purposefully using a custom `data-tab-id` attribute here
|
|
63
|
-
// because we don't want rely on any assumptions about `Tabs`
|
|
64
|
-
// component internals.
|
|
65
|
-
element => element.getAttribute('data-tab-id') === tabName);
|
|
66
|
-
const activeElement = selectedTabElement?.ownerDocument.activeElement;
|
|
67
|
-
const tabsHasFocus = tabsElements.some(element => {
|
|
68
|
-
return activeElement && activeElement.id === element.id;
|
|
69
|
-
});
|
|
70
|
-
if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
|
|
71
|
-
selectedTabElement?.focus();
|
|
72
|
-
}
|
|
73
|
-
}, [tabName]);
|
|
74
|
-
const {
|
|
75
|
-
createSuccessNotice
|
|
76
|
-
} = useDispatch(noticesStore);
|
|
77
|
-
const onActionPerformed = useCallback((actionId, items) => {
|
|
78
|
-
switch (actionId) {
|
|
79
|
-
case 'move-to-trash':
|
|
80
|
-
{
|
|
81
|
-
const postType = items[0].type;
|
|
82
|
-
document.location.href = addQueryArgs('edit.php', {
|
|
83
|
-
post_type: postType
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
break;
|
|
87
|
-
case 'duplicate-post':
|
|
88
|
-
{
|
|
89
|
-
const newItem = items[0];
|
|
90
|
-
const title = typeof newItem.title === 'string' ? newItem.title : newItem.title?.rendered;
|
|
91
|
-
createSuccessNotice(sprintf(
|
|
92
|
-
// translators: %s: Title of the created post e.g: "Post 1".
|
|
93
|
-
__('"%s" successfully created.'), title), {
|
|
94
|
-
type: 'snackbar',
|
|
95
|
-
id: 'duplicate-post-action',
|
|
96
|
-
actions: [{
|
|
97
|
-
label: __('Edit'),
|
|
98
|
-
onClick: () => {
|
|
99
|
-
const postId = newItem.id;
|
|
100
|
-
document.location.href = addQueryArgs('post.php', {
|
|
101
|
-
post: postId,
|
|
102
|
-
action: 'edit'
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}]
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
}, [createSuccessNotice]);
|
|
111
|
-
return createElement(PluginSidebar, {
|
|
112
|
-
identifier: tabName,
|
|
113
|
-
header: createElement(Tabs.Context.Provider, {
|
|
114
|
-
value: tabsContextValue
|
|
115
|
-
}, createElement(SettingsHeader, {
|
|
116
|
-
ref: tabListRef
|
|
117
|
-
})),
|
|
118
|
-
closeLabel: __('Close Settings')
|
|
119
|
-
// This classname is added so we can apply a corrective negative
|
|
120
|
-
// margin to the panel.
|
|
121
|
-
// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
|
|
122
|
-
,
|
|
123
|
-
className: "edit-post-sidebar__panel",
|
|
124
|
-
headerClassName: "edit-post-sidebar__panel-tabs"
|
|
125
|
-
/* translators: button label text should, if possible, be under 16 characters. */,
|
|
126
|
-
title: __('Settings'),
|
|
127
|
-
toggleShortcut: keyboardShortcut,
|
|
128
|
-
icon: isRTL() ? drawerLeft : drawerRight,
|
|
129
|
-
isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT
|
|
130
|
-
}, createElement(Tabs.Context.Provider, {
|
|
131
|
-
value: tabsContextValue
|
|
132
|
-
}, createElement(Tabs.TabPanel, {
|
|
133
|
-
tabId: sidebars.document,
|
|
134
|
-
focusable: false
|
|
135
|
-
}, createElement(PostCardPanel, {
|
|
136
|
-
actions: createElement(PostActions, {
|
|
137
|
-
onActionPerformed: onActionPerformed
|
|
138
|
-
})
|
|
139
|
-
}), !isEditingTemplate && createElement(PostStatus, null), createElement(PluginDocumentSettingPanel.Slot, null), createElement(PostLastRevisionPanel, null), createElement(PostTaxonomiesPanel, null), createElement(PostDiscussionPanel, null), createElement(PageAttributesPanel, null), createElement(PatternOverridesPanel, null), !isEditingTemplate && createElement(MetaBoxes, {
|
|
140
|
-
location: "side"
|
|
141
|
-
})), createElement(Tabs.TabPanel, {
|
|
142
|
-
tabId: sidebars.block,
|
|
143
|
-
focusable: false
|
|
144
|
-
}, createElement(BlockInspector, null))));
|
|
145
|
-
};
|
|
146
|
-
const SettingsSidebar = () => {
|
|
147
|
-
useAutoSwitchEditorSidebars();
|
|
148
|
-
const {
|
|
149
|
-
tabName,
|
|
150
|
-
keyboardShortcut,
|
|
151
|
-
isEditingTemplate
|
|
152
|
-
} = useSelect(select => {
|
|
153
|
-
const shortcut = select(keyboardShortcutsStore).getShortcutRepresentation('core/editor/toggle-sidebar');
|
|
154
|
-
const sidebar = select(interfaceStore).getActiveComplementaryArea('core');
|
|
155
|
-
const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
|
|
156
|
-
let _tabName = sidebar;
|
|
157
|
-
if (!_isEditorSidebarOpened) {
|
|
158
|
-
_tabName = !!select(blockEditorStore).getBlockSelectionStart() ? sidebars.block : sidebars.document;
|
|
159
|
-
}
|
|
160
|
-
return {
|
|
161
|
-
tabName: _tabName,
|
|
162
|
-
keyboardShortcut: shortcut,
|
|
163
|
-
isEditingTemplate: select(editorStore).getCurrentPostType() === 'wp_template'
|
|
164
|
-
};
|
|
165
|
-
}, []);
|
|
166
|
-
const {
|
|
167
|
-
openGeneralSidebar
|
|
168
|
-
} = useDispatch(editPostStore);
|
|
169
|
-
const onTabSelect = useCallback(newSelectedTabId => {
|
|
170
|
-
if (!!newSelectedTabId) {
|
|
171
|
-
openGeneralSidebar(newSelectedTabId);
|
|
172
|
-
}
|
|
173
|
-
}, [openGeneralSidebar]);
|
|
174
|
-
return createElement(Tabs, {
|
|
175
|
-
selectedTabId: tabName,
|
|
176
|
-
onSelect: onTabSelect,
|
|
177
|
-
selectOnMove: false
|
|
178
|
-
}, createElement(SidebarContent, {
|
|
179
|
-
tabName: tabName,
|
|
180
|
-
keyboardShortcut: keyboardShortcut,
|
|
181
|
-
isEditingTemplate: isEditingTemplate
|
|
182
|
-
}));
|
|
183
|
-
};
|
|
184
|
-
export default SettingsSidebar;
|
|
185
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["BlockInspector","store","blockEditorStore","useSelect","useDispatch","Platform","useCallback","useContext","useEffect","useRef","isRTL","__","sprintf","drawerLeft","drawerRight","keyboardShortcutsStore","editorStore","PageAttributesPanel","PluginDocumentSettingPanel","PluginSidebar","PostDiscussionPanel","PostLastRevisionPanel","PostTaxonomiesPanel","privateApis","editorPrivateApis","addQueryArgs","noticesStore","SettingsHeader","PostStatus","MetaBoxes","editPostStore","componentsPrivateApis","unlock","PostCardPanel","PostActions","interfaceStore","Tabs","PatternOverridesPanel","useAutoSwitchEditorSidebars","SIDEBAR_ACTIVE_BY_DEFAULT","select","web","native","sidebars","document","block","SidebarContent","tabName","keyboardShortcut","isEditingTemplate","tabListRef","tabsContextValue","Context","tabsElements","Array","from","current","querySelectorAll","selectedTabElement","find","element","getAttribute","activeElement","ownerDocument","tabsHasFocus","some","id","focus","createSuccessNotice","onActionPerformed","actionId","items","postType","type","location","href","post_type","newItem","title","rendered","actions","label","onClick","postId","post","action","createElement","identifier","header","Provider","value","ref","closeLabel","className","headerClassName","toggleShortcut","icon","isActiveByDefault","TabPanel","tabId","focusable","Slot","SettingsSidebar","shortcut","getShortcutRepresentation","sidebar","getActiveComplementaryArea","_isEditorSidebarOpened","includes","_tabName","getBlockSelectionStart","getCurrentPostType","openGeneralSidebar","onTabSelect","newSelectedTabId","selectedTabId","onSelect","selectOnMove"],"sources":["@wordpress/edit-post/src/components/sidebar/settings-sidebar/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockInspector,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPlatform,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseRef,\n} from '@wordpress/element';\nimport { isRTL, __, sprintf } from '@wordpress/i18n';\nimport { drawerLeft, drawerRight } from '@wordpress/icons';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\nimport {\n\tstore as editorStore,\n\tPageAttributesPanel,\n\tPluginDocumentSettingPanel,\n\tPluginSidebar,\n\tPostDiscussionPanel,\n\tPostLastRevisionPanel,\n\tPostTaxonomiesPanel,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport SettingsHeader from '../settings-header';\nimport PostStatus from '../post-status';\nimport MetaBoxes from '../../meta-boxes';\nimport { store as editPostStore } from '../../../store';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { unlock } from '../../../lock-unlock';\n\nconst { PostCardPanel, PostActions, interfaceStore } =\n\tunlock( editorPrivateApis );\nconst { Tabs } = unlock( componentsPrivateApis );\nconst { PatternOverridesPanel, useAutoSwitchEditorSidebars } =\n\tunlock( editorPrivateApis );\n\nconst SIDEBAR_ACTIVE_BY_DEFAULT = Platform.select( {\n\tweb: true,\n\tnative: false,\n} );\nexport const sidebars = {\n\tdocument: 'edit-post/document',\n\tblock: 'edit-post/block',\n};\n\nconst SidebarContent = ( { tabName, keyboardShortcut, isEditingTemplate } ) => {\n\tconst tabListRef = useRef( null );\n\t// Because `PluginSidebar` renders a `ComplementaryArea`, we\n\t// need to forward the `Tabs` context so it can be passed through the\n\t// underlying slot/fill.\n\tconst tabsContextValue = useContext( Tabs.Context );\n\n\t// This effect addresses a race condition caused by tabbing from the last\n\t// block in the editor into the settings sidebar. Without this effect, the\n\t// selected tab and browser focus can become separated in an unexpected way\n\t// (e.g the \"block\" tab is focused, but the \"post\" tab is selected).\n\tuseEffect( () => {\n\t\tconst tabsElements = Array.from(\n\t\t\ttabListRef.current?.querySelectorAll( '[role=\"tab\"]' ) || []\n\t\t);\n\t\tconst selectedTabElement = tabsElements.find(\n\t\t\t// We are purposefully using a custom `data-tab-id` attribute here\n\t\t\t// because we don't want rely on any assumptions about `Tabs`\n\t\t\t// component internals.\n\t\t\t( element ) => element.getAttribute( 'data-tab-id' ) === tabName\n\t\t);\n\t\tconst activeElement = selectedTabElement?.ownerDocument.activeElement;\n\t\tconst tabsHasFocus = tabsElements.some( ( element ) => {\n\t\t\treturn activeElement && activeElement.id === element.id;\n\t\t} );\n\t\tif (\n\t\t\ttabsHasFocus &&\n\t\t\tselectedTabElement &&\n\t\t\tselectedTabElement.id !== activeElement?.id\n\t\t) {\n\t\t\tselectedTabElement?.focus();\n\t\t}\n\t}, [ tabName ] );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tconst onActionPerformed = useCallback(\n\t\t( actionId, items ) => {\n\t\t\tswitch ( actionId ) {\n\t\t\t\tcase 'move-to-trash':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst postType = items[ 0 ].type;\n\t\t\t\t\t\tdocument.location.href = addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: postType,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'duplicate-post':\n\t\t\t\t\t{\n\t\t\t\t\t\tconst newItem = items[ 0 ];\n\t\t\t\t\t\tconst title =\n\t\t\t\t\t\t\ttypeof newItem.title === 'string'\n\t\t\t\t\t\t\t\t? newItem.title\n\t\t\t\t\t\t\t\t: newItem.title?.rendered;\n\t\t\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t// translators: %s: Title of the created post e.g: \"Post 1\".\n\t\t\t\t\t\t\t\t__( '\"%s\" successfully created.' ),\n\t\t\t\t\t\t\t\ttitle\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\t\t\tid: 'duplicate-post-action',\n\t\t\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\tlabel: __( 'Edit' ),\n\t\t\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\t\t\tconst postId = newItem.id;\n\t\t\t\t\t\t\t\t\t\t\tdocument.location.href =\n\t\t\t\t\t\t\t\t\t\t\t\taddQueryArgs( 'post.php', {\n\t\t\t\t\t\t\t\t\t\t\t\t\tpost: postId,\n\t\t\t\t\t\t\t\t\t\t\t\t\taction: 'edit',\n\t\t\t\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t\t\t},\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}\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t},\n\t\t[ createSuccessNotice ]\n\t);\n\n\treturn (\n\t\t<PluginSidebar\n\t\t\tidentifier={ tabName }\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<SettingsHeader ref={ tabListRef } />\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t\tcloseLabel={ __( 'Close Settings' ) }\n\t\t\t// This classname is added so we can apply a corrective negative\n\t\t\t// margin to the panel.\n\t\t\t// see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049\n\t\t\tclassName=\"edit-post-sidebar__panel\"\n\t\t\theaderClassName=\"edit-post-sidebar__panel-tabs\"\n\t\t\t/* translators: button label text should, if possible, be under 16 characters. */\n\t\t\ttitle={ __( 'Settings' ) }\n\t\t\ttoggleShortcut={ keyboardShortcut }\n\t\t\ticon={ isRTL() ? drawerLeft : drawerRight }\n\t\t\tisActiveByDefault={ SIDEBAR_ACTIVE_BY_DEFAULT }\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.document } focusable={ false }>\n\t\t\t\t\t<PostCardPanel\n\t\t\t\t\t\tactions={\n\t\t\t\t\t\t\t<PostActions\n\t\t\t\t\t\t\t\tonActionPerformed={ onActionPerformed }\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\t{ ! isEditingTemplate && <PostStatus /> }\n\t\t\t\t\t<PluginDocumentSettingPanel.Slot />\n\t\t\t\t\t<PostLastRevisionPanel />\n\t\t\t\t\t<PostTaxonomiesPanel />\n\t\t\t\t\t<PostDiscussionPanel />\n\t\t\t\t\t<PageAttributesPanel />\n\t\t\t\t\t<PatternOverridesPanel />\n\t\t\t\t\t{ ! isEditingTemplate && <MetaBoxes location=\"side\" /> }\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t<Tabs.TabPanel tabId={ sidebars.block } focusable={ false }>\n\t\t\t\t\t<BlockInspector />\n\t\t\t\t</Tabs.TabPanel>\n\t\t\t</Tabs.Context.Provider>\n\t\t</PluginSidebar>\n\t);\n};\n\nconst SettingsSidebar = () => {\n\tuseAutoSwitchEditorSidebars();\n\tconst { tabName, keyboardShortcut, isEditingTemplate } = useSelect(\n\t\t( select ) => {\n\t\t\tconst shortcut = select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' );\n\n\t\t\tconst sidebar =\n\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea( 'core' );\n\t\t\tconst _isEditorSidebarOpened = [\n\t\t\t\tsidebars.block,\n\t\t\t\tsidebars.document,\n\t\t\t].includes( sidebar );\n\t\t\tlet _tabName = sidebar;\n\t\t\tif ( ! _isEditorSidebarOpened ) {\n\t\t\t\t_tabName = !! select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).getBlockSelectionStart()\n\t\t\t\t\t? sidebars.block\n\t\t\t\t\t: sidebars.document;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\ttabName: _tabName,\n\t\t\t\tkeyboardShortcut: shortcut,\n\t\t\t\tisEditingTemplate:\n\t\t\t\t\tselect( editorStore ).getCurrentPostType() ===\n\t\t\t\t\t'wp_template',\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { openGeneralSidebar } = useDispatch( editPostStore );\n\n\tconst onTabSelect = useCallback(\n\t\t( newSelectedTabId ) => {\n\t\t\tif ( !! newSelectedTabId ) {\n\t\t\t\topenGeneralSidebar( newSelectedTabId );\n\t\t\t}\n\t\t},\n\t\t[ openGeneralSidebar ]\n\t);\n\n\treturn (\n\t\t<Tabs\n\t\t\tselectedTabId={ tabName }\n\t\t\tonSelect={ onTabSelect }\n\t\t\tselectOnMove={ false }\n\t\t>\n\t\t\t<SidebarContent\n\t\t\t\ttabName={ tabName }\n\t\t\t\tkeyboardShortcut={ keyboardShortcut }\n\t\t\t\tisEditingTemplate={ isEditingTemplate }\n\t\t\t/>\n\t\t</Tabs>\n\t);\n};\n\nexport default SettingsSidebar;\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,cAAc,EACdC,KAAK,IAAIC,gBAAgB,QACnB,yBAAyB;AAChC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SACCC,QAAQ,EACRC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,MAAM,QACA,oBAAoB;AAC3B,SAASC,KAAK,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACpD,SAASC,UAAU,EAAEC,WAAW,QAAQ,kBAAkB;AAC1D,SAASb,KAAK,IAAIc,sBAAsB,QAAQ,+BAA+B;AAC/E,SACCd,KAAK,IAAIe,WAAW,EACpBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,aAAa,EACbC,mBAAmB,EACnBC,qBAAqB,EACrBC,mBAAmB,EACnBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASxB,KAAK,IAAIyB,YAAY,QAAQ,oBAAo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AEuD,QAAQ;MAC1BtD,iBAAiB,EAChBT,MAAM,CAAExB,WAAY,CAAC,CAAC+F,kBAAkB,CAAC,CAAC,KAC1C;IACF,CAAC;EACF,CAAC,EACD,EACD,CAAC;EAED,MAAM;IAAEC;EAAmB,CAAC,GAAG5G,WAAW,CAAE0B,aAAc,CAAC;EAE3D,MAAMmF,WAAW,GAAG3G,WAAW,CAC5B4G,gBAAgB,IAAM;IACvB,IAAK,CAAC,CAAEA,gBAAgB,EAAG;MAC1BF,kBAAkB,CAAEE,gBAAiB,CAAC;IACvC;EACD,CAAC,EACD,CAAEF,kBAAkB,CACrB,CAAC;EAED,OACC1B,aAAA,CAAClD,IAAI;IACJ+E,aAAa,EAAGpE,OAAS;IACzBqE,QAAQ,EAAGH,WAAa;IACxBI,YAAY,EAAG;EAAO,GAEtB/B,aAAA,CAACxC,cAAc;IACdC,OAAO,EAAGA,OAAS;IACnBC,gBAAgB,EAAGA,gBAAkB;IACrCC,iBAAiB,EAAGA;EAAmB,CACvC,CACI,CAAC;AAET,CAAC;AAED,eAAeqD,eAAe","ignoreList":[]}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { PostTextEditor, PostTitleRaw, store as editorStore } from '@wordpress/editor';
|
|
6
|
-
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
|
-
import { displayShortcut } from '@wordpress/keycodes';
|
|
10
|
-
import { useEffect, useRef } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as editPostStore } from '../../store';
|
|
16
|
-
export default function TextEditor() {
|
|
17
|
-
const isRichEditingEnabled = useSelect(select => {
|
|
18
|
-
return select(editorStore).getEditorSettings().richEditingEnabled;
|
|
19
|
-
}, []);
|
|
20
|
-
const {
|
|
21
|
-
switchEditorMode
|
|
22
|
-
} = useDispatch(editorStore);
|
|
23
|
-
const {
|
|
24
|
-
isWelcomeGuideVisible
|
|
25
|
-
} = useSelect(select => {
|
|
26
|
-
const {
|
|
27
|
-
isFeatureActive
|
|
28
|
-
} = select(editPostStore);
|
|
29
|
-
return {
|
|
30
|
-
isWelcomeGuideVisible: isFeatureActive('welcomeGuide')
|
|
31
|
-
};
|
|
32
|
-
}, []);
|
|
33
|
-
const titleRef = useRef();
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (isWelcomeGuideVisible) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
titleRef?.current?.focus();
|
|
39
|
-
}, [isWelcomeGuideVisible]);
|
|
40
|
-
return createElement("div", {
|
|
41
|
-
className: "edit-post-text-editor"
|
|
42
|
-
}, isRichEditingEnabled && createElement("div", {
|
|
43
|
-
className: "edit-post-text-editor__toolbar"
|
|
44
|
-
}, createElement("h2", null, __('Editing code')), createElement(Button, {
|
|
45
|
-
variant: "tertiary",
|
|
46
|
-
onClick: () => switchEditorMode('visual'),
|
|
47
|
-
shortcut: displayShortcut.secondary('m')
|
|
48
|
-
}, __('Exit code editor'))), createElement("div", {
|
|
49
|
-
className: "edit-post-text-editor__body"
|
|
50
|
-
}, createElement(PostTitleRaw, {
|
|
51
|
-
ref: titleRef
|
|
52
|
-
}), createElement(PostTextEditor, null)));
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["PostTextEditor","PostTitleRaw","store","editorStore","Button","useDispatch","useSelect","__","displayShortcut","useEffect","useRef","editPostStore","TextEditor","isRichEditingEnabled","select","getEditorSettings","richEditingEnabled","switchEditorMode","isWelcomeGuideVisible","isFeatureActive","titleRef","current","focus","createElement","className","variant","onClick","shortcut","secondary","ref"],"sources":["@wordpress/edit-post/src/components/text-editor/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tPostTextEditor,\n\tPostTitleRaw,\n\tstore as editorStore,\n} from '@wordpress/editor';\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { displayShortcut } from '@wordpress/keycodes';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nexport default function TextEditor() {\n\tconst isRichEditingEnabled = useSelect( ( select ) => {\n\t\treturn select( editorStore ).getEditorSettings().richEditingEnabled;\n\t}, [] );\n\tconst { switchEditorMode } = useDispatch( editorStore );\n\n\tconst { isWelcomeGuideVisible } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\n\t\treturn {\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t};\n\t}, [] );\n\n\tconst titleRef = useRef();\n\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible ] );\n\n\treturn (\n\t\t<div className=\"edit-post-text-editor\">\n\t\t\t{ isRichEditingEnabled && (\n\t\t\t\t<div className=\"edit-post-text-editor__toolbar\">\n\t\t\t\t\t<h2>{ __( 'Editing code' ) }</h2>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\tonClick={ () => switchEditorMode( 'visual' ) }\n\t\t\t\t\t\tshortcut={ displayShortcut.secondary( 'm' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Exit code editor' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t<div className=\"edit-post-text-editor__body\">\n\t\t\t\t<PostTitleRaw ref={ titleRef } />\n\t\t\t\t<PostTextEditor />\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAA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qB,OAAO,EAAC,UAAU;IAClBC,OAAO,EAAGA,CAAA,KAAMT,gBAAgB,CAAE,QAAS,CAAG;IAC9CU,QAAQ,EAAGnB,eAAe,CAACoB,SAAS,CAAE,GAAI;EAAG,GAE3CrB,EAAE,CAAE,kBAAmB,CAClB,CACJ,CACL,EACDgB,aAAA;IAAKC,SAAS,EAAC;EAA6B,GAC3CD,aAAA,CAACtB,YAAY;IAAC4B,GAAG,EAAGT;EAAU,CAAE,CAAC,EACjCG,aAAA,CAACvB,cAAc,MAAE,CACb,CACD,CAAC;AAER","ignoreList":[]}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* WordPress dependencies
|
|
4
|
-
*/
|
|
5
|
-
import { __ } from '@wordpress/i18n';
|
|
6
|
-
import { MenuItem } from '@wordpress/components';
|
|
7
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import { speak } from '@wordpress/a11y';
|
|
9
|
-
import { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
|
-
import { store as editPostStore } from '../../store';
|
|
15
|
-
const noop = () => {};
|
|
16
|
-
export function BlockInspectorButton({
|
|
17
|
-
onClick = noop,
|
|
18
|
-
small = false
|
|
19
|
-
}) {
|
|
20
|
-
const {
|
|
21
|
-
shortcut,
|
|
22
|
-
areAdvancedSettingsOpened
|
|
23
|
-
} = useSelect(select => ({
|
|
24
|
-
shortcut: select(keyboardShortcutsStore).getShortcutRepresentation('core/editor/toggle-sidebar'),
|
|
25
|
-
areAdvancedSettingsOpened: select(editPostStore).getActiveGeneralSidebarName() === 'edit-post/block'
|
|
26
|
-
}), []);
|
|
27
|
-
const {
|
|
28
|
-
openGeneralSidebar,
|
|
29
|
-
closeGeneralSidebar
|
|
30
|
-
} = useDispatch(editPostStore);
|
|
31
|
-
const label = areAdvancedSettingsOpened ? __('Hide more settings') : __('Show more settings');
|
|
32
|
-
return createElement(MenuItem, {
|
|
33
|
-
onClick: () => {
|
|
34
|
-
if (areAdvancedSettingsOpened) {
|
|
35
|
-
closeGeneralSidebar();
|
|
36
|
-
speak(__('Block settings closed'));
|
|
37
|
-
} else {
|
|
38
|
-
openGeneralSidebar('edit-post/block');
|
|
39
|
-
speak(__('Additional settings are now available in the Editor block settings sidebar'));
|
|
40
|
-
}
|
|
41
|
-
onClick();
|
|
42
|
-
},
|
|
43
|
-
shortcut: shortcut
|
|
44
|
-
}, !small && label);
|
|
45
|
-
}
|
|
46
|
-
export default BlockInspectorButton;
|
|
47
|
-
//# sourceMappingURL=block-inspector-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["__","MenuItem","useSelect","useDispatch","speak","store","keyboardShortcutsStore","editPostStore","noop","BlockInspectorButton","onClick","small","shortcut","areAdvancedSettingsOpened","select","getShortcutRepresentation","getActiveGeneralSidebarName","openGeneralSidebar","closeGeneralSidebar","label","createElement"],"sources":["@wordpress/edit-post/src/components/visual-editor/block-inspector-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { speak } from '@wordpress/a11y';\nimport { store as keyboardShortcutsStore } from '@wordpress/keyboard-shortcuts';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\n\nconst noop = () => {};\n\nexport function BlockInspectorButton( { onClick = noop, small = false } ) {\n\tconst { shortcut, areAdvancedSettingsOpened } = useSelect(\n\t\t( select ) => ( {\n\t\t\tshortcut: select(\n\t\t\t\tkeyboardShortcutsStore\n\t\t\t).getShortcutRepresentation( 'core/editor/toggle-sidebar' ),\n\t\t\tareAdvancedSettingsOpened:\n\t\t\t\tselect( editPostStore ).getActiveGeneralSidebarName() ===\n\t\t\t\t'edit-post/block',\n\t\t} ),\n\t\t[]\n\t);\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\n\tconst label = areAdvancedSettingsOpened\n\t\t? __( 'Hide more settings' )\n\t\t: __( 'Show more settings' );\n\n\treturn (\n\t\t<MenuItem\n\t\t\tonClick={ () => {\n\t\t\t\tif ( areAdvancedSettingsOpened ) {\n\t\t\t\t\tcloseGeneralSidebar();\n\t\t\t\t\tspeak( __( 'Block settings closed' ) );\n\t\t\t\t} else {\n\t\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t\t\tspeak(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Additional settings are now available in the Editor block settings sidebar'\n\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tonClick();\n\t\t\t} }\n\t\t\tshortcut={ shortcut }\n\t\t>\n\t\t\t{ ! small && label }\n\t\t</MenuItem>\n\t);\n}\n\nexport default BlockInspectorButton;\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,QAAQ,iBAAiB;AACvC,SAASC,KAAK,IAAIC,sBAAsB,QAAQ,+BAA+B;;AAE/E;AACA;AACA;AACA,SAASD,KAAK,IAAIE,aAAa,QAAQ,aAAa;AAEpD,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,OAAO,SAASC,oBAAoBA,CAAE;EAAEC,OAAO,GAAGF,IAAI;EAAEG,KAAK,GAAG;AAAM,CAAC,EAAG;EACzE,MAAM;IAAEC,QAAQ;IAAEC;EAA0B,CAAC,GAAGX,SAAS,CACtDY,MAAM,KAAQ;IACfF,QAAQ,EAAEE,MAAM,CACfR,sBACD,CAAC,CAACS,yBAAyB,CAAE,4BAA6B,CAAC;IAC3DF,yBAAyB,EACxBC,MAAM,CAAEP,aAAc,CAAC,CAACS,2BAA2B,CAAC,CAAC,KACrD;EACF,CAAC,CAAE,EACH,EACD,CAAC;EACD,MAAM;IAAEC,kBAAkB;IAAEC;EAAoB,CAAC,GAChDf,WAAW,CAAEI,aAAc,CAAC;EAE7B,MAAMY,KAAK,GAAGN,yBAAyB,GACpCb,EAAE,CAAE,oBAAqB,CAAC,GAC1BA,EAAE,CAAE,oBAAqB,CAAC;EAE7B,OACCoB,aAAA,CAACnB,QAAQ;IACRS,OAAO,EAAGA,CAAA,KAAM;MACf,IAAKG,yBAAyB,EAAG;QAChCK,mBAAmB,CAAC,CAAC;QACrBd,KAAK,CAAEJ,EAAE,CAAE,uBAAwB,CAAE,CAAC;MACvC,CAAC,MAAM;QACNiB,kBAAkB,CAAE,iBAAkB,CAAC;QACvCb,KAAK,CACJJ,EAAE,CACD,4EACD,CACD,CAAC;MACF;MACAU,OAAO,CAAC,CAAC;IACV,CAAG;IACHE,QAAQ,EAAGA;EAAU,GAEnB,CAAED,KAAK,IAAIQ,KACJ,CAAC;AAEb;AAEA,eAAeV,oBAAoB","ignoreList":[]}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { createElement } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import classnames from 'classnames';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
11
|
-
import { useMemo } from '@wordpress/element';
|
|
12
|
-
import { useSelect } from '@wordpress/data';
|
|
13
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Internal dependencies
|
|
17
|
-
*/
|
|
18
|
-
import { store as editPostStore } from '../../store';
|
|
19
|
-
import { unlock } from '../../lock-unlock';
|
|
20
|
-
import { usePaddingAppender } from './use-padding-appender';
|
|
21
|
-
const {
|
|
22
|
-
EditorCanvas
|
|
23
|
-
} = unlock(editorPrivateApis);
|
|
24
|
-
const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
|
|
25
|
-
export default function VisualEditor({
|
|
26
|
-
styles
|
|
27
|
-
}) {
|
|
28
|
-
const {
|
|
29
|
-
isWelcomeGuideVisible,
|
|
30
|
-
renderingMode,
|
|
31
|
-
isBlockBasedTheme,
|
|
32
|
-
hasV3BlocksOnly,
|
|
33
|
-
isEditingTemplate
|
|
34
|
-
} = useSelect(select => {
|
|
35
|
-
const {
|
|
36
|
-
isFeatureActive
|
|
37
|
-
} = select(editPostStore);
|
|
38
|
-
const {
|
|
39
|
-
getEditorSettings,
|
|
40
|
-
getRenderingMode
|
|
41
|
-
} = select(editorStore);
|
|
42
|
-
const {
|
|
43
|
-
getBlockTypes
|
|
44
|
-
} = select(blocksStore);
|
|
45
|
-
const editorSettings = getEditorSettings();
|
|
46
|
-
return {
|
|
47
|
-
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
48
|
-
renderingMode: getRenderingMode(),
|
|
49
|
-
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
|
|
50
|
-
hasV3BlocksOnly: getBlockTypes().every(type => {
|
|
51
|
-
return type.apiVersion >= 3;
|
|
52
|
-
}),
|
|
53
|
-
isEditingTemplate: select(editorStore).getCurrentPostType() === 'wp_template'
|
|
54
|
-
};
|
|
55
|
-
}, []);
|
|
56
|
-
const hasMetaBoxes = useSelect(select => select(editPostStore).hasMetaBoxes(), []);
|
|
57
|
-
const paddingAppenderRef = usePaddingAppender();
|
|
58
|
-
let paddingBottom;
|
|
59
|
-
|
|
60
|
-
// Add a constant padding for the typewritter effect. When typing at the
|
|
61
|
-
// bottom, there needs to be room to scroll up.
|
|
62
|
-
if (!hasMetaBoxes && renderingMode === 'post-only') {
|
|
63
|
-
paddingBottom = '40vh';
|
|
64
|
-
}
|
|
65
|
-
styles = useMemo(() => [...styles, {
|
|
66
|
-
// We should move this in to future to the body.
|
|
67
|
-
css: paddingBottom ? `body{padding-bottom:${paddingBottom}}` : ''
|
|
68
|
-
}], [styles, paddingBottom]);
|
|
69
|
-
const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || isEditingTemplate;
|
|
70
|
-
return createElement("div", {
|
|
71
|
-
className: classnames('edit-post-visual-editor', {
|
|
72
|
-
'has-inline-canvas': !isToBeIframed
|
|
73
|
-
})
|
|
74
|
-
}, createElement(EditorCanvas, {
|
|
75
|
-
disableIframe: !isToBeIframed,
|
|
76
|
-
styles: styles
|
|
77
|
-
// We should auto-focus the canvas (title) on load.
|
|
78
|
-
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
79
|
-
,
|
|
80
|
-
autoFocus: !isWelcomeGuideVisible,
|
|
81
|
-
contentRef: paddingAppenderRef
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","store","editorStore","privateApis","editorPrivateApis","useMemo","useSelect","blocksStore","editPostStore","unlock","usePaddingAppender","EditorCanvas","isGutenbergPlugin","process","env","IS_GUTENBERG_PLUGIN","VisualEditor","styles","isWelcomeGuideVisible","renderingMode","isBlockBasedTheme","hasV3BlocksOnly","isEditingTemplate","select","isFeatureActive","getEditorSettings","getRenderingMode","getBlockTypes","editorSettings","__unstableIsBlockBasedTheme","every","type","apiVersion","getCurrentPostType","hasMetaBoxes","paddingAppenderRef","paddingBottom","css","isToBeIframed","createElement","className","disableIframe","autoFocus","contentRef"],"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { usePaddingAppender } from './use-padding-appender';\n\nconst { EditorCanvas } = unlock( editorPrivateApis );\n\nconst isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tisWelcomeGuideVisible,\n\t\trenderingMode,\n\t\tisBlockBasedTheme,\n\t\thasV3BlocksOnly,\n\t\tisEditingTemplate,\n\t} = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getEditorSettings, getRenderingMode } = select( editorStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\treturn {\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\trenderingMode: getRenderingMode(),\n\t\t\tisBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,\n\t\t\thasV3BlocksOnly: getBlockTypes().every( ( type ) => {\n\t\t\t\treturn type.apiVersion >= 3;\n\t\t\t} ),\n\t\t\tisEditingTemplate:\n\t\t\t\tselect( editorStore ).getCurrentPostType() === 'wp_template',\n\t\t};\n\t}, [] );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\n\tconst paddingAppenderRef = usePaddingAppender();\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && renderingMode === 'post-only' ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tstyles = useMemo(\n\t\t() => [\n\t\t\t...styles,\n\t\t\t{\n\t\t\t\t// We should move this in to future to the body.\n\t\t\t\tcss: paddingBottom\n\t\t\t\t\t? `body{padding-bottom:${ paddingBottom }}`\n\t\t\t\t\t: '',\n\t\t\t},\n\t\t],\n\t\t[ styles, paddingBottom ]\n\t);\n\n\tconst isToBeIframed =\n\t\t( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&\n\t\t\t! hasMetaBoxes ) ||\n\t\tisEditingTemplate;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'has-inline-canvas': ! isToBeIframed,\n\t\t\t} ) }\n\t\t>\n\t\t\t<EditorCanvas\n\t\t\t\tdisableIframe={ ! isToBeIframed }\n\t\t\t\tstyles={ styles }\n\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t\tcontentRef={ paddingAppenderRef }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SACCC,KAAK,IAAIC,WAAW,EACpBC,WAAW,IAAIC,iBAAiB,QAC1B,mBAAmB;AAC1B,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASL,KAAK,IAAIM,WAAW,QAAQ,mBAAmB;;AAExD;AACA;AACA;AACA,SAASN,KAAK,IAAIO,aAAa,QAAQ,aAAa;AACpD,SAASC,MAAM,QAAQ,mBAAmB;AAC1C,SAASC,kBAAkB,QAAQ,wBAAwB;AAE3D,MAAM;EAAEC;AAAa,CAAC,GAAGF,MAAM,CAAEL,iBAAkB,CAAC;AAEpD,MAAMQ,iBAAiB,GAAGC,OAAO,CAACC,GAAG,CAACC,mBAAmB,GAAG,IAAI,GAAG,KAAK;AAExE,eAAe,SAASC,YAAYA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAClD,MAAM;IACLC,qBAAqB;IACrBC,aAAa;IACbC,iBAAiB;IACjBC,eAAe;IACfC;EACD,CAAC,GAAGhB,S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Q,iBAAmB,KAChE,CAAEc,YAAY,IACfZ,iBAAiB;EAElB,OACCiB,aAAA;IACCC,SAAS,EAAGxC,UAAU,CAAE,yBAAyB,EAAE;MAClD,mBAAmB,EAAE,CAAEsC;IACxB,CAAE;EAAG,GAELC,aAAA,CAAC5B,YAAY;IACZ8B,aAAa,EAAG,CAAEH,aAAe;IACjCrB,MAAM,EAAGA;IACT;IACA;IAAA;IACAyB,SAAS,EAAG,CAAExB,qBAAuB;IACrCyB,UAAU,EAAGR;EAAoB,CACjC,CACG,CAAC;AAER","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useRegistry","useRefEffect","store","blockEditorStore","isUnmodifiedDefaultBlock","usePaddingAppender","registry","node","onMouseDown","event","target","ownerDocument","defaultView","paddingBottom","parseInt","getComputedStyle","lastChild","lastElementChild","lastChildRect","getBoundingClientRect","clientY","bottom","preventDefault","blockOrder","select","getBlockOrder","lastBlockClientId","length","lastBlock","getBlock","selectBlock","insertDefaultBlock","dispatch","addEventListener","removeEventListener"],"sources":["@wordpress/edit-post/src/components/visual-editor/use-padding-appender.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { isUnmodifiedDefaultBlock } from '@wordpress/blocks';\n\nexport function usePaddingAppender() {\n\tconst registry = useRegistry();\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tfunction onMouseDown( event ) {\n\t\t\t\tif ( event.target !== node ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { ownerDocument } = node;\n\t\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\t\tconst paddingBottom = defaultView.parseInt(\n\t\t\t\t\tdefaultView.getComputedStyle( node ).paddingBottom,\n\t\t\t\t\t10\n\t\t\t\t);\n\n\t\t\t\tif ( ! paddingBottom ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// only handle clicks under the last child\n\t\t\t\tconst lastChild = node.lastElementChild;\n\t\t\t\tif ( ! lastChild ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst lastChildRect = lastChild.getBoundingClientRect();\n\t\t\t\tif ( event.clientY < lastChildRect.bottom ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tconst blockOrder = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlockOrder( '' );\n\t\t\t\tconst lastBlockClientId = blockOrder[ blockOrder.length - 1 ];\n\t\t\t\tconst lastBlock = registry\n\t\t\t\t\t.select( blockEditorStore )\n\t\t\t\t\t.getBlock( lastBlockClientId );\n\t\t\t\tconst { selectBlock, insertDefaultBlock } =\n\t\t\t\t\tregistry.dispatch( blockEditorStore );\n\n\t\t\t\tif ( isUnmodifiedDefaultBlock( lastBlock ) ) {\n\t\t\t\t\tselectBlock( lastBlockClientId );\n\t\t\t\t} else {\n\t\t\t\t\tinsertDefaultBlock();\n\t\t\t\t}\n\t\t\t}\n\t\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\t\treturn () => {\n\t\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\t};\n\t\t},\n\t\t[ registry ]\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,iBAAiB;AAC7C,SAASC,YAAY,QAAQ,oBAAoB;AACjD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,wBAAwB,QAAQ,mBAAmB;AAE5D,OAAO,SAASC,kBAAkBA,CAAA,EAAG;EACpC,MAAMC,QAAQ,GAAGN,WAAW,CAAC,CAAC;EAC9B,OAAOC,YAAY,CAChBM,IAAI,IAAM;IACX,SAASC,WAAWA,CAAEC,KAAK,EAAG;MAC7B,IAAKA,KAAK,CAACC,MAAM,KAAKH,IAAI,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AAC,EACD,CAAEF,QAAQ,CACX,CAAC;AACF","ignoreList":[]}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { useSelect, useDispatch } from '@wordpress/data';
|
|
5
|
-
import { __, isRTL } from '@wordpress/i18n';
|
|
6
|
-
import { drawerLeft, drawerRight, blockDefault, fullscreen, formatListBullets } from '@wordpress/icons';
|
|
7
|
-
import { useCommand } from '@wordpress/commands';
|
|
8
|
-
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
|
-
import { store as editorStore, privateApis as editorPrivateApis } from '@wordpress/editor';
|
|
10
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
import { store as editPostStore } from '../../store';
|
|
16
|
-
import { unlock } from '../../lock-unlock';
|
|
17
|
-
const {
|
|
18
|
-
interfaceStore
|
|
19
|
-
} = unlock(editorPrivateApis);
|
|
20
|
-
export default function useCommonCommands() {
|
|
21
|
-
const {
|
|
22
|
-
openGeneralSidebar,
|
|
23
|
-
closeGeneralSidebar
|
|
24
|
-
} = useDispatch(editPostStore);
|
|
25
|
-
const {
|
|
26
|
-
activeSidebar,
|
|
27
|
-
isFullscreen,
|
|
28
|
-
isPublishSidebarEnabled
|
|
29
|
-
} = useSelect(select => {
|
|
30
|
-
const {
|
|
31
|
-
get
|
|
32
|
-
} = select(preferencesStore);
|
|
33
|
-
return {
|
|
34
|
-
activeSidebar: select(interfaceStore).getActiveComplementaryArea('core'),
|
|
35
|
-
isPublishSidebarEnabled: select(editorStore).isPublishSidebarEnabled(),
|
|
36
|
-
isFullscreen: get('core/edit-post', 'fullscreenMode')
|
|
37
|
-
};
|
|
38
|
-
}, []);
|
|
39
|
-
const {
|
|
40
|
-
toggle
|
|
41
|
-
} = useDispatch(preferencesStore);
|
|
42
|
-
const {
|
|
43
|
-
createInfoNotice
|
|
44
|
-
} = useDispatch(noticesStore);
|
|
45
|
-
useCommand({
|
|
46
|
-
name: 'core/open-settings-sidebar',
|
|
47
|
-
label: __('Toggle settings sidebar'),
|
|
48
|
-
icon: isRTL() ? drawerLeft : drawerRight,
|
|
49
|
-
callback: ({
|
|
50
|
-
close
|
|
51
|
-
}) => {
|
|
52
|
-
close();
|
|
53
|
-
if (activeSidebar === 'edit-post/document') {
|
|
54
|
-
closeGeneralSidebar();
|
|
55
|
-
} else {
|
|
56
|
-
openGeneralSidebar('edit-post/document');
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
useCommand({
|
|
61
|
-
name: 'core/open-block-inspector',
|
|
62
|
-
label: __('Toggle block inspector'),
|
|
63
|
-
icon: blockDefault,
|
|
64
|
-
callback: ({
|
|
65
|
-
close
|
|
66
|
-
}) => {
|
|
67
|
-
close();
|
|
68
|
-
if (activeSidebar === 'edit-post/block') {
|
|
69
|
-
closeGeneralSidebar();
|
|
70
|
-
} else {
|
|
71
|
-
openGeneralSidebar('edit-post/block');
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
useCommand({
|
|
76
|
-
name: 'core/toggle-fullscreen-mode',
|
|
77
|
-
label: isFullscreen ? __('Exit fullscreen') : __('Enter fullscreen'),
|
|
78
|
-
icon: fullscreen,
|
|
79
|
-
callback: ({
|
|
80
|
-
close
|
|
81
|
-
}) => {
|
|
82
|
-
toggle('core/edit-post', 'fullscreenMode');
|
|
83
|
-
close();
|
|
84
|
-
createInfoNotice(isFullscreen ? __('Fullscreen off.') : __('Fullscreen on.'), {
|
|
85
|
-
id: 'core/edit-post/toggle-fullscreen-mode/notice',
|
|
86
|
-
type: 'snackbar',
|
|
87
|
-
actions: [{
|
|
88
|
-
label: __('Undo'),
|
|
89
|
-
onClick: () => {
|
|
90
|
-
toggle('core/edit-post', 'fullscreenMode');
|
|
91
|
-
}
|
|
92
|
-
}]
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
useCommand({
|
|
97
|
-
name: 'core/toggle-publish-sidebar',
|
|
98
|
-
label: isPublishSidebarEnabled ? __('Disable pre-publish checks') : __('Enable pre-publish checks'),
|
|
99
|
-
icon: formatListBullets,
|
|
100
|
-
callback: ({
|
|
101
|
-
close
|
|
102
|
-
}) => {
|
|
103
|
-
close();
|
|
104
|
-
toggle('core', 'isPublishSidebarEnabled');
|
|
105
|
-
createInfoNotice(isPublishSidebarEnabled ? __('Pre-publish checks disabled.') : __('Pre-publish checks enabled.'), {
|
|
106
|
-
id: 'core/editor/publish-sidebar/notice',
|
|
107
|
-
type: 'snackbar'
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=use-common-commands.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["useSelect","useDispatch","__","isRTL","drawerLeft","drawerRight","blockDefault","fullscreen","formatListBullets","useCommand","store","preferencesStore","editorStore","privateApis","editorPrivateApis","noticesStore","editPostStore","unlock","interfaceStore","useCommonCommands","openGeneralSidebar","closeGeneralSidebar","activeSidebar","isFullscreen","isPublishSidebarEnabled","select","get","getActiveComplementaryArea","toggle","createInfoNotice","name","label","icon","callback","close","id","type","actions","onClick"],"sources":["@wordpress/edit-post/src/hooks/commands/use-common-commands.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { __, isRTL } from '@wordpress/i18n';\nimport {\n\tdrawerLeft,\n\tdrawerRight,\n\tblockDefault,\n\tfullscreen,\n\tformatListBullets,\n} from '@wordpress/icons';\nimport { useCommand } from '@wordpress/commands';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { interfaceStore } = unlock( editorPrivateApis );\n\nexport default function useCommonCommands() {\n\tconst { openGeneralSidebar, closeGeneralSidebar } =\n\t\tuseDispatch( editPostStore );\n\tconst { activeSidebar, isFullscreen, isPublishSidebarEnabled } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { get } = select( preferencesStore );\n\n\t\t\treturn {\n\t\t\t\tactiveSidebar:\n\t\t\t\t\tselect( interfaceStore ).getActiveComplementaryArea(\n\t\t\t\t\t\t'core'\n\t\t\t\t\t),\n\t\t\t\tisPublishSidebarEnabled:\n\t\t\t\t\tselect( editorStore ).isPublishSidebarEnabled(),\n\t\t\t\tisFullscreen: get( 'core/edit-post', 'fullscreenMode' ),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\tconst { toggle } = useDispatch( preferencesStore );\n\tconst { createInfoNotice } = useDispatch( noticesStore );\n\n\tuseCommand( {\n\t\tname: 'core/open-settings-sidebar',\n\t\tlabel: __( 'Toggle settings sidebar' ),\n\t\ticon: isRTL() ? drawerLeft : drawerRight,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/document' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/document' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/open-block-inspector',\n\t\tlabel: __( 'Toggle block inspector' ),\n\t\ticon: blockDefault,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\tif ( activeSidebar === 'edit-post/block' ) {\n\t\t\t\tcloseGeneralSidebar();\n\t\t\t} else {\n\t\t\t\topenGeneralSidebar( 'edit-post/block' );\n\t\t\t}\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-fullscreen-mode',\n\t\tlabel: isFullscreen\n\t\t\t? __( 'Exit fullscreen' )\n\t\t\t: __( 'Enter fullscreen' ),\n\t\ticon: fullscreen,\n\t\tcallback: ( { close } ) => {\n\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\tclose();\n\t\t\tcreateInfoNotice(\n\t\t\t\tisFullscreen ? __( 'Fullscreen off.' ) : __( 'Fullscreen on.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/edit-post/toggle-fullscreen-mode/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\tactions: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\ttoggle( 'core/edit-post', 'fullscreenMode' );\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n\n\tuseCommand( {\n\t\tname: 'core/toggle-publish-sidebar',\n\t\tlabel: isPublishSidebarEnabled\n\t\t\t? __( 'Disable pre-publish checks' )\n\t\t\t: __( 'Enable pre-publish checks' ),\n\t\ticon: formatListBullets,\n\t\tcallback: ( { close } ) => {\n\t\t\tclose();\n\t\t\ttoggle( 'core', 'isPublishSidebarEnabled' );\n\t\t\tcreateInfoNotice(\n\t\t\t\tisPublishSidebarEnabled\n\t\t\t\t\t? __( 'Pre-publish checks disabled.' )\n\t\t\t\t\t: __( 'Pre-publish checks enabled.' ),\n\t\t\t\t{\n\t\t\t\t\tid: 'core/editor/publish-sidebar/notice',\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t},\n\t} );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,EAAE,EAAEC,KAAK,QAAQ,iBAAiB;AAC3C,SACCC,UAAU,EACVC,WAAW,EACXC,YAAY,EACZC,UAAU,EACVC,iBAAiB,QACX,kBAAkB;AACzB,SAASC,UAAU,QAAQ,qBAAqB;AAChD,SAASC,KAAK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EP,uBAAuB,GAC3BtB,EAAE,CAAE,4BAA6B,CAAC,GAClCA,EAAE,CAAE,2BAA4B,CAAC;IACpC8B,IAAI,EAAExB,iBAAiB;IACvByB,QAAQ,EAAEA,CAAE;MAAEC;IAAM,CAAC,KAAM;MAC1BA,KAAK,CAAC,CAAC;MACPN,MAAM,CAAE,MAAM,EAAE,yBAA0B,CAAC;MAC3CC,gBAAgB,CACfL,uBAAuB,GACpBtB,EAAE,CAAE,8BAA+B,CAAC,GACpCA,EAAE,CAAE,6BAA8B,CAAC,EACtC;QACCiC,EAAE,EAAE,oCAAoC;QACxCC,IAAI,EAAE;MACP,CACD,CAAC;IACF;EACD,CAAE,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { addFilter } from '@wordpress/hooks';
|
|
5
|
-
import { MediaUpload } from '@wordpress/media-utils';
|
|
6
|
-
const replaceMediaUpload = () => MediaUpload;
|
|
7
|
-
addFilter('editor.MediaUpload', 'core/edit-post/replace-media-upload', replaceMediaUpload);
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["addFilter","MediaUpload","replaceMediaUpload"],"sources":["@wordpress/edit-post/src/hooks/components/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { MediaUpload } from '@wordpress/media-utils';\n\nconst replaceMediaUpload = () => MediaUpload;\n\naddFilter(\n\t'editor.MediaUpload',\n\t'core/edit-post/replace-media-upload',\n\treplaceMediaUpload\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,QAAQ,wBAAwB;AAEpD,MAAMC,kBAAkB,GAAGA,CAAA,KAAMD,WAAW;AAE5CD,SAAS,CACR,oBAAoB,EACpB,qCAAqC,EACrCE,kBACD,CAAC","ignoreList":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/edit-post/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './components';\nimport './validate-multiple-use';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,cAAc;AACrB,OAAO,yBAAyB","ignoreList":[]}
|