@wordpress/edit-post 8.32.0 → 8.32.1-next.ff1cebbba.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/build/commands/use-commands.js +54 -47
- package/build/commands/use-commands.js.map +7 -1
- package/build/components/back-button/fullscreen-mode-close.js +127 -118
- package/build/components/back-button/fullscreen-mode-close.js.map +7 -1
- package/build/components/back-button/index.js +56 -54
- package/build/components/back-button/index.js.map +7 -1
- package/build/components/browser-url/index.js +45 -44
- package/build/components/browser-url/index.js.map +7 -1
- package/build/components/editor-initialization/index.js +24 -18
- package/build/components/editor-initialization/index.js.map +7 -1
- package/build/components/editor-initialization/listener-hooks.js +42 -43
- package/build/components/editor-initialization/listener-hooks.js.map +7 -1
- package/build/components/init-pattern-modal/index.js +100 -79
- package/build/components/init-pattern-modal/index.js.map +7 -1
- package/build/components/keyboard-shortcuts/index.js +37 -33
- package/build/components/keyboard-shortcuts/index.js.map +7 -1
- package/build/components/layout/index.js +447 -467
- package/build/components/layout/index.js.map +7 -1
- package/build/components/layout/use-padding-appender.js +66 -59
- package/build/components/layout/use-padding-appender.js.map +7 -1
- package/build/components/layout/use-should-iframe.js +36 -30
- package/build/components/layout/use-should-iframe.js.map +7 -1
- package/build/components/meta-boxes/index.js +46 -33
- package/build/components/meta-boxes/index.js.map +7 -1
- package/build/components/meta-boxes/meta-box-visibility.js +37 -22
- package/build/components/meta-boxes/meta-box-visibility.js.map +7 -1
- package/build/components/meta-boxes/meta-boxes-area/index.js +62 -53
- package/build/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
- package/build/components/meta-boxes/use-meta-box-initialization.js +37 -32
- package/build/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
- package/build/components/more-menu/index.js +64 -44
- package/build/components/more-menu/index.js.map +7 -1
- package/build/components/more-menu/manage-patterns-menu-item.js +39 -37
- package/build/components/more-menu/manage-patterns-menu-item.js.map +7 -1
- package/build/components/more-menu/welcome-guide-menu-item.js +39 -21
- package/build/components/more-menu/welcome-guide-menu-item.js.map +7 -1
- package/build/components/preferences-modal/enable-custom-fields.js +76 -66
- package/build/components/preferences-modal/enable-custom-fields.js.map +7 -1
- package/build/components/preferences-modal/enable-panel.js +47 -43
- package/build/components/preferences-modal/enable-panel.js.map +7 -1
- package/build/components/preferences-modal/index.js +51 -39
- package/build/components/preferences-modal/index.js.map +7 -1
- package/build/components/preferences-modal/meta-boxes-section.js +65 -52
- package/build/components/preferences-modal/meta-boxes-section.js.map +7 -1
- package/build/components/welcome-guide/default.js +134 -97
- package/build/components/welcome-guide/default.js.map +7 -1
- package/build/components/welcome-guide/image.js +34 -23
- package/build/components/welcome-guide/image.js.map +7 -1
- package/build/components/welcome-guide/index.js +51 -38
- package/build/components/welcome-guide/index.js.map +7 -1
- package/build/components/welcome-guide/template.js +65 -45
- package/build/components/welcome-guide/template.js.map +7 -1
- package/build/deprecated.js +84 -110
- package/build/deprecated.js.map +7 -1
- package/build/hooks/use-navigate-to-entity-record.js +60 -78
- package/build/hooks/use-navigate-to-entity-record.js.map +7 -1
- package/build/index.js +101 -136
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/store/actions.js +239 -431
- package/build/store/actions.js.map +7 -1
- package/build/store/constants.js +33 -26
- package/build/store/constants.js.map +7 -1
- package/build/store/index.js +44 -32
- package/build/store/index.js.map +7 -1
- package/build/store/reducer.js +50 -57
- package/build/store/reducer.js.map +7 -1
- package/build/store/selectors.js +288 -459
- package/build/store/selectors.js.map +7 -1
- package/build/utils/meta-boxes.js +31 -19
- package/build/utils/meta-boxes.js.map +7 -1
- package/build-module/commands/use-commands.js +35 -40
- package/build-module/commands/use-commands.js.map +7 -1
- package/build-module/components/back-button/fullscreen-mode-close.js +102 -110
- package/build-module/components/back-button/fullscreen-mode-close.js.map +7 -1
- package/build-module/components/back-button/index.js +28 -47
- package/build-module/components/back-button/index.js.map +7 -1
- package/build-module/components/browser-url/index.js +23 -38
- package/build-module/components/browser-url/index.js.map +7 -1
- package/build-module/components/editor-initialization/index.js +6 -13
- package/build-module/components/editor-initialization/index.js.map +7 -1
- package/build-module/components/editor-initialization/listener-hooks.js +20 -34
- package/build-module/components/editor-initialization/listener-hooks.js.map +7 -1
- package/build-module/components/init-pattern-modal/index.js +90 -74
- package/build-module/components/init-pattern-modal/index.js.map +7 -1
- package/build-module/components/keyboard-shortcuts/index.js +21 -26
- package/build-module/components/keyboard-shortcuts/index.js.map +7 -1
- package/build-module/components/layout/index.js +439 -448
- package/build-module/components/layout/index.js.map +7 -1
- package/build-module/components/layout/use-padding-appender.js +44 -54
- package/build-module/components/layout/use-padding-appender.js.map +7 -1
- package/build-module/components/layout/use-should-iframe.js +15 -25
- package/build-module/components/layout/use-should-iframe.js.map +7 -1
- package/build-module/components/meta-boxes/index.js +18 -26
- package/build-module/components/meta-boxes/index.js.map +7 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +18 -15
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +7 -1
- package/build-module/components/meta-boxes/meta-boxes-area/index.js +30 -44
- package/build-module/components/meta-boxes/meta-boxes-area/index.js.map +7 -1
- package/build-module/components/meta-boxes/use-meta-box-initialization.js +14 -25
- package/build-module/components/meta-boxes/use-meta-box-initialization.js.map +7 -1
- package/build-module/components/more-menu/index.js +36 -37
- package/build-module/components/more-menu/index.js.map +7 -1
- package/build-module/components/more-menu/manage-patterns-menu-item.js +21 -31
- package/build-module/components/more-menu/manage-patterns-menu-item.js.map +7 -1
- package/build-module/components/more-menu/welcome-guide-menu-item.js +22 -16
- package/build-module/components/more-menu/welcome-guide-menu-item.js.map +7 -1
- package/build-module/components/preferences-modal/enable-custom-fields.js +51 -56
- package/build-module/components/preferences-modal/enable-custom-fields.js.map +7 -1
- package/build-module/components/preferences-modal/enable-panel.js +30 -38
- package/build-module/components/preferences-modal/enable-panel.js.map +7 -1
- package/build-module/components/preferences-modal/index.js +24 -34
- package/build-module/components/preferences-modal/index.js.map +7 -1
- package/build-module/components/preferences-modal/meta-boxes-section.js +34 -45
- package/build-module/components/preferences-modal/meta-boxes-section.js.map +7 -1
- package/build-module/components/welcome-guide/default.js +107 -91
- package/build-module/components/welcome-guide/default.js.map +7 -1
- package/build-module/components/welcome-guide/image.js +16 -18
- package/build-module/components/welcome-guide/image.js.map +7 -1
- package/build-module/components/welcome-guide/index.js +23 -31
- package/build-module/components/welcome-guide/index.js.map +7 -1
- package/build-module/components/welcome-guide/template.js +38 -39
- package/build-module/components/welcome-guide/template.js.map +7 -1
- package/build-module/deprecated.js +62 -103
- package/build-module/deprecated.js.map +7 -1
- package/build-module/hooks/use-navigate-to-entity-record.js +42 -73
- package/build-module/hooks/use-navigate-to-entity-record.js.map +7 -1
- package/build-module/index.js +70 -95
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/store/actions.js +158 -368
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/constants.js +9 -21
- package/build-module/store/constants.js.map +7 -1
- package/build-module/store/index.js +10 -22
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/reducer.js +28 -51
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/selectors.js +232 -442
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/utils/meta-boxes.js +9 -13
- package/build-module/utils/meta-boxes.js.map +7 -1
- package/build-style/classic-rtl.css +0 -154
- package/build-style/classic.css +0 -154
- package/build-style/style-rtl.css +135 -110
- package/build-style/style.css +135 -110
- package/package.json +39 -31
- package/src/classic.scss +3 -0
- package/src/components/back-button/style.scss +3 -0
- package/src/components/layout/index.js +3 -2
- package/src/components/layout/style.scss +4 -0
- package/src/components/meta-boxes/meta-boxes-area/style.scss +3 -0
- package/src/components/welcome-guide/style.scss +3 -0
- package/src/style.scss +8 -4
- package/build/components/header/header-toolbar/index.native.js +0 -204
- package/build/components/header/header-toolbar/index.native.js.map +0 -1
- package/build/components/header/index.native.js +0 -59
- package/build/components/header/index.native.js.map +0 -1
- package/build/components/layout/index.native.js +0 -166
- package/build/components/layout/index.native.js.map +0 -1
- package/build/components/visual-editor/header.native.js +0 -63
- package/build/components/visual-editor/header.native.js.map +0 -1
- package/build/components/visual-editor/index.native.js +0 -44
- package/build/components/visual-editor/index.native.js.map +0 -1
- package/build/editor.native.js +0 -157
- package/build/editor.native.js.map +0 -1
- package/build/index.native.js +0 -58
- package/build/index.native.js.map +0 -1
- package/build-module/components/header/header-toolbar/index.native.js +0 -196
- package/build-module/components/header/header-toolbar/index.native.js.map +0 -1
- package/build-module/components/header/index.native.js +0 -50
- package/build-module/components/header/index.native.js.map +0 -1
- package/build-module/components/layout/index.native.js +0 -158
- package/build-module/components/layout/index.native.js.map +0 -1
- package/build-module/components/visual-editor/header.native.js +0 -56
- package/build-module/components/visual-editor/header.native.js.map +0 -1
- package/build-module/components/visual-editor/index.native.js +0 -35
- package/build-module/components/visual-editor/index.native.js.map +0 -1
- package/build-module/editor.native.js +0 -149
- package/build-module/editor.native.js.map +0 -1
- package/build-module/index.native.js +0 -45
- package/build-module/index.native.js.map +0 -1
|
@@ -1,141 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import { store as
|
|
38
|
-
import {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import clsx from "clsx";
|
|
3
|
+
import { NavigableRegion } from "@wordpress/admin-ui";
|
|
4
|
+
import {
|
|
5
|
+
AutosaveMonitor,
|
|
6
|
+
LocalAutosaveMonitor,
|
|
7
|
+
UnsavedChangesWarning,
|
|
8
|
+
EditorKeyboardShortcutsRegister,
|
|
9
|
+
EditorSnackbars,
|
|
10
|
+
ErrorBoundary,
|
|
11
|
+
PostLockedModal,
|
|
12
|
+
store as editorStore,
|
|
13
|
+
privateApis as editorPrivateApis
|
|
14
|
+
} from "@wordpress/editor";
|
|
15
|
+
import { useSelect, useDispatch } from "@wordpress/data";
|
|
16
|
+
import {
|
|
17
|
+
privateApis as blockEditorPrivateApis,
|
|
18
|
+
store as blockEditorStore
|
|
19
|
+
} from "@wordpress/block-editor";
|
|
20
|
+
import { PluginArea } from "@wordpress/plugins";
|
|
21
|
+
import { __, sprintf } from "@wordpress/i18n";
|
|
22
|
+
import {
|
|
23
|
+
useCallback,
|
|
24
|
+
useEffect,
|
|
25
|
+
useMemo,
|
|
26
|
+
useId,
|
|
27
|
+
useRef,
|
|
28
|
+
useState
|
|
29
|
+
} from "@wordpress/element";
|
|
30
|
+
import { chevronDown, chevronUp } from "@wordpress/icons";
|
|
31
|
+
import { store as noticesStore } from "@wordpress/notices";
|
|
32
|
+
import { store as preferencesStore } from "@wordpress/preferences";
|
|
33
|
+
import { privateApis as commandsPrivateApis } from "@wordpress/commands";
|
|
34
|
+
import { privateApis as blockLibraryPrivateApis } from "@wordpress/block-library";
|
|
35
|
+
import { addQueryArgs } from "@wordpress/url";
|
|
36
|
+
import { decodeEntities } from "@wordpress/html-entities";
|
|
37
|
+
import { store as coreStore } from "@wordpress/core-data";
|
|
38
|
+
import {
|
|
39
|
+
Icon,
|
|
40
|
+
ResizableBox,
|
|
41
|
+
SlotFillProvider,
|
|
42
|
+
Tooltip,
|
|
43
|
+
VisuallyHidden,
|
|
44
|
+
__unstableUseNavigateRegions as useNavigateRegions
|
|
45
|
+
} from "@wordpress/components";
|
|
46
|
+
import {
|
|
47
|
+
useEvent,
|
|
48
|
+
useMediaQuery,
|
|
49
|
+
useRefEffect,
|
|
50
|
+
useViewportMatch
|
|
51
|
+
} from "@wordpress/compose";
|
|
52
|
+
import BackButton from "../back-button";
|
|
53
|
+
import EditorInitialization from "../editor-initialization";
|
|
54
|
+
import EditPostKeyboardShortcuts from "../keyboard-shortcuts";
|
|
55
|
+
import InitPatternModal from "../init-pattern-modal";
|
|
56
|
+
import BrowserURL from "../browser-url";
|
|
57
|
+
import MetaBoxes from "../meta-boxes";
|
|
58
|
+
import PostEditorMoreMenu from "../more-menu";
|
|
59
|
+
import WelcomeGuide from "../welcome-guide";
|
|
60
|
+
import { store as editPostStore } from "../../store";
|
|
61
|
+
import { unlock } from "../../lock-unlock";
|
|
62
|
+
import useEditPostCommands from "../../commands/use-commands";
|
|
63
|
+
import { usePaddingAppender } from "./use-padding-appender";
|
|
64
|
+
import { useShouldIframe } from "./use-should-iframe";
|
|
65
|
+
import useNavigateToEntityRecord from "../../hooks/use-navigate-to-entity-record";
|
|
66
|
+
import { useMetaBoxInitialization } from "../meta-boxes/use-meta-box-initialization";
|
|
67
|
+
const { getLayoutStyles } = unlock(blockEditorPrivateApis);
|
|
68
|
+
const { useCommandContext } = unlock(commandsPrivateApis);
|
|
69
|
+
const { Editor, FullscreenMode } = unlock(editorPrivateApis);
|
|
70
|
+
const { BlockKeyboardShortcuts } = unlock(blockLibraryPrivateApis);
|
|
71
|
+
const DESIGN_POST_TYPES = [
|
|
72
|
+
"wp_template",
|
|
73
|
+
"wp_template_part",
|
|
74
|
+
"wp_block",
|
|
75
|
+
"wp_navigation",
|
|
76
|
+
"wp_registered_template"
|
|
77
|
+
];
|
|
60
78
|
function useEditorStyles(...additionalStyles) {
|
|
61
|
-
const {
|
|
62
|
-
hasThemeStyleSupport,
|
|
63
|
-
editorSettings
|
|
64
|
-
} = useSelect(select => {
|
|
79
|
+
const { hasThemeStyleSupport, editorSettings } = useSelect((select) => {
|
|
65
80
|
return {
|
|
66
|
-
hasThemeStyleSupport: select(editPostStore).isFeatureActive(
|
|
81
|
+
hasThemeStyleSupport: select(editPostStore).isFeatureActive("themeStyles"),
|
|
67
82
|
editorSettings: select(editorStore).getEditorSettings()
|
|
68
83
|
};
|
|
69
84
|
}, []);
|
|
70
|
-
const addedStyles = additionalStyles.join(
|
|
71
|
-
|
|
72
|
-
// Compute the default styles.
|
|
85
|
+
const addedStyles = additionalStyles.join("\n");
|
|
73
86
|
return useMemo(() => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
// base layout styles are still present in the editor.
|
|
87
|
+
const presetStyles = editorSettings.styles?.filter(
|
|
88
|
+
(style) => style.__unstableType && style.__unstableType !== "theme"
|
|
89
|
+
) ?? [];
|
|
90
|
+
const defaultEditorStyles = [
|
|
91
|
+
...editorSettings?.defaultEditorStyles ?? [],
|
|
92
|
+
...presetStyles
|
|
93
|
+
];
|
|
94
|
+
const hasThemeStyles = hasThemeStyleSupport && presetStyles.length !== (editorSettings.styles?.length ?? 0);
|
|
83
95
|
if (!editorSettings.disableLayoutStyles && !hasThemeStyles) {
|
|
84
96
|
defaultEditorStyles.push({
|
|
85
97
|
css: getLayoutStyles({
|
|
86
98
|
style: {},
|
|
87
|
-
selector:
|
|
99
|
+
selector: "body",
|
|
88
100
|
hasBlockGapSupport: false,
|
|
89
101
|
hasFallbackGapSupport: true,
|
|
90
|
-
fallbackGapValue:
|
|
102
|
+
fallbackGapValue: "0.5em"
|
|
91
103
|
})
|
|
92
104
|
});
|
|
93
105
|
}
|
|
94
|
-
const baseStyles = hasThemeStyles ?
|
|
106
|
+
const baseStyles = hasThemeStyles ? editorSettings.styles ?? [] : defaultEditorStyles;
|
|
95
107
|
if (addedStyles) {
|
|
96
|
-
return [...baseStyles, {
|
|
97
|
-
css: addedStyles
|
|
98
|
-
}];
|
|
108
|
+
return [...baseStyles, { css: addedStyles }];
|
|
99
109
|
}
|
|
100
110
|
return baseStyles;
|
|
101
|
-
}, [
|
|
111
|
+
}, [
|
|
112
|
+
editorSettings.defaultEditorStyles,
|
|
113
|
+
editorSettings.disableLayoutStyles,
|
|
114
|
+
editorSettings.styles,
|
|
115
|
+
hasThemeStyleSupport,
|
|
116
|
+
addedStyles
|
|
117
|
+
]);
|
|
102
118
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
const {
|
|
113
|
-
get
|
|
114
|
-
} = select(preferencesStore);
|
|
115
|
-
const {
|
|
116
|
-
isMetaBoxLocationVisible
|
|
117
|
-
} = select(editPostStore);
|
|
118
|
-
return [!!get('core/edit-post', 'metaBoxesMainIsOpen'), get('core/edit-post', 'metaBoxesMainOpenHeight'), isMetaBoxLocationVisible('normal') || isMetaBoxLocationVisible('advanced') || isMetaBoxLocationVisible('side')];
|
|
119
|
+
function MetaBoxesMain({ isLegacy }) {
|
|
120
|
+
const [isOpen, openHeight, hasAnyVisible] = useSelect((select) => {
|
|
121
|
+
const { get } = select(preferencesStore);
|
|
122
|
+
const { isMetaBoxLocationVisible } = select(editPostStore);
|
|
123
|
+
return [
|
|
124
|
+
!!get("core/edit-post", "metaBoxesMainIsOpen"),
|
|
125
|
+
get("core/edit-post", "metaBoxesMainOpenHeight"),
|
|
126
|
+
isMetaBoxLocationVisible("normal") || isMetaBoxLocationVisible("advanced") || isMetaBoxLocationVisible("side")
|
|
127
|
+
];
|
|
119
128
|
}, []);
|
|
120
|
-
const {
|
|
121
|
-
set: setPreference
|
|
122
|
-
} = useDispatch(preferencesStore);
|
|
129
|
+
const { set: setPreference } = useDispatch(preferencesStore);
|
|
123
130
|
const metaBoxesMainRef = useRef();
|
|
124
|
-
const isShort = useMediaQuery(
|
|
125
|
-
const [{
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
// editor notices. The constraints are also used to derive the value for the
|
|
131
|
-
// aria-valuenow attribute on the separator.
|
|
132
|
-
const effectSizeConstraints = useRefEffect(node => {
|
|
133
|
-
const container = node.closest('.interface-interface-skeleton__content');
|
|
131
|
+
const isShort = useMediaQuery("(max-height: 549px)");
|
|
132
|
+
const [{ min, max }, setHeightConstraints] = useState(() => ({}));
|
|
133
|
+
const effectSizeConstraints = useRefEffect((node) => {
|
|
134
|
+
const container = node.closest(
|
|
135
|
+
".interface-interface-skeleton__content"
|
|
136
|
+
);
|
|
134
137
|
if (!container) {
|
|
135
138
|
return;
|
|
136
139
|
}
|
|
137
|
-
const noticeLists = container.querySelectorAll(
|
|
138
|
-
|
|
140
|
+
const noticeLists = container.querySelectorAll(
|
|
141
|
+
":scope > .components-notice-list"
|
|
142
|
+
);
|
|
143
|
+
const resizeHandle = container.querySelector(
|
|
144
|
+
".edit-post-meta-boxes-main__presenter"
|
|
145
|
+
);
|
|
139
146
|
const deriveConstraints = () => {
|
|
140
147
|
const fullHeight = container.offsetHeight;
|
|
141
148
|
let nextMax = fullHeight;
|
|
@@ -143,10 +150,7 @@ function MetaBoxesMain({
|
|
|
143
150
|
nextMax -= element.offsetHeight;
|
|
144
151
|
}
|
|
145
152
|
const nextMin = resizeHandle.offsetHeight;
|
|
146
|
-
setHeightConstraints({
|
|
147
|
-
min: nextMin,
|
|
148
|
-
max: nextMax
|
|
149
|
-
});
|
|
153
|
+
setHeightConstraints({ min: nextMin, max: nextMax });
|
|
150
154
|
};
|
|
151
155
|
const observer = new window.ResizeObserver(deriveConstraints);
|
|
152
156
|
observer.observe(container);
|
|
@@ -158,24 +162,19 @@ function MetaBoxesMain({
|
|
|
158
162
|
const resizeDataRef = useRef({});
|
|
159
163
|
const separatorRef = useRef();
|
|
160
164
|
const separatorHelpId = useId();
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* @param {boolean} isPersistent Whether to persist the height in preferences.
|
|
165
|
-
* @param {boolean} isInstant Whether to update the height in the DOM.
|
|
166
|
-
*/
|
|
167
|
-
const applyHeight = (candidateHeight = 'auto', isPersistent, isInstant) => {
|
|
168
|
-
if (candidateHeight === 'auto') {
|
|
169
|
-
isPersistent = false; // Just in case — “auto” should never persist.
|
|
165
|
+
const applyHeight = (candidateHeight = "auto", isPersistent, isInstant) => {
|
|
166
|
+
if (candidateHeight === "auto") {
|
|
167
|
+
isPersistent = false;
|
|
170
168
|
} else {
|
|
171
169
|
candidateHeight = Math.min(max, Math.max(min, candidateHeight));
|
|
172
170
|
}
|
|
173
171
|
if (isPersistent) {
|
|
174
|
-
setPreference(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
172
|
+
setPreference(
|
|
173
|
+
"core/edit-post",
|
|
174
|
+
"metaBoxesMainOpenHeight",
|
|
175
|
+
candidateHeight
|
|
176
|
+
);
|
|
177
|
+
} else if (!isShort) {
|
|
179
178
|
separatorRef.current.ariaValueNow = getAriaValueNow(candidateHeight);
|
|
180
179
|
}
|
|
181
180
|
if (isInstant) {
|
|
@@ -185,22 +184,15 @@ function MetaBoxesMain({
|
|
|
185
184
|
// if `width` is left unspecified a subsequent drag gesture applies a fixed
|
|
186
185
|
// width and the pane fails to widen/narrow with parent width changes from
|
|
187
186
|
// sidebars opening/closing or window resizes.
|
|
188
|
-
width:
|
|
187
|
+
width: "auto"
|
|
189
188
|
});
|
|
190
189
|
}
|
|
191
190
|
};
|
|
192
|
-
const getRenderValues = useEvent(() => ({
|
|
193
|
-
isOpen,
|
|
194
|
-
openHeight,
|
|
195
|
-
min
|
|
196
|
-
}));
|
|
197
|
-
// Sets the height to 'auto' when not resizable (isShort) and to the
|
|
198
|
-
// preferred height when resizable.
|
|
191
|
+
const getRenderValues = useEvent(() => ({ isOpen, openHeight, min }));
|
|
199
192
|
useEffect(() => {
|
|
200
193
|
const fresh = getRenderValues();
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
const usedOpenHeight = isShort ? 'auto' : fresh.openHeight;
|
|
194
|
+
if (fresh.min !== void 0 && metaBoxesMainRef.current) {
|
|
195
|
+
const usedOpenHeight = isShort ? "auto" : fresh.openHeight;
|
|
204
196
|
const usedHeight = fresh.isOpen ? usedOpenHeight : fresh.min;
|
|
205
197
|
applyHeight(usedHeight, false, true);
|
|
206
198
|
}
|
|
@@ -208,31 +200,26 @@ function MetaBoxesMain({
|
|
|
208
200
|
if (!hasAnyVisible) {
|
|
209
201
|
return;
|
|
210
202
|
}
|
|
211
|
-
const contents =
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
203
|
+
const contents = /* @__PURE__ */ jsxs(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
className: "edit-post-layout__metaboxes edit-post-meta-boxes-main__liner",
|
|
207
|
+
hidden: !isLegacy && !isOpen,
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ jsx(MetaBoxes, { location: "normal" }),
|
|
210
|
+
/* @__PURE__ */ jsx(MetaBoxes, { location: "advanced" })
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
);
|
|
221
214
|
if (isLegacy) {
|
|
222
215
|
return contents;
|
|
223
216
|
}
|
|
224
|
-
const isAutoHeight = openHeight ===
|
|
225
|
-
const getAriaValueNow = height => Math.round((height - min) / (max - min) * 100);
|
|
226
|
-
const usedAriaValueNow = max ===
|
|
227
|
-
const persistIsOpen = (to = !isOpen) => setPreference(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
// https://www.w3.org/WAI/ARIA/apg/patterns/windowsplitter/
|
|
231
|
-
const onSeparatorKeyDown = event => {
|
|
232
|
-
const delta = {
|
|
233
|
-
ArrowUp: 20,
|
|
234
|
-
ArrowDown: -20
|
|
235
|
-
}[event.key];
|
|
217
|
+
const isAutoHeight = openHeight === void 0;
|
|
218
|
+
const getAriaValueNow = (height) => Math.round((height - min) / (max - min) * 100);
|
|
219
|
+
const usedAriaValueNow = max === void 0 || isAutoHeight ? 50 : getAriaValueNow(openHeight);
|
|
220
|
+
const persistIsOpen = (to = !isOpen) => setPreference("core/edit-post", "metaBoxesMainIsOpen", to);
|
|
221
|
+
const onSeparatorKeyDown = (event) => {
|
|
222
|
+
const delta = { ArrowUp: 20, ArrowDown: -20 }[event.key];
|
|
236
223
|
if (delta) {
|
|
237
224
|
const pane = metaBoxesMainRef.current.resizable;
|
|
238
225
|
const fromHeight = isAutoHeight ? pane.offsetHeight : openHeight;
|
|
@@ -242,136 +229,107 @@ function MetaBoxesMain({
|
|
|
242
229
|
event.preventDefault();
|
|
243
230
|
}
|
|
244
231
|
};
|
|
245
|
-
const paneLabel = __(
|
|
246
|
-
const toggle =
|
|
247
|
-
"
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
isToggleInferred
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
232
|
+
const paneLabel = __("Meta Boxes");
|
|
233
|
+
const toggle = /* @__PURE__ */ jsxs(
|
|
234
|
+
"button",
|
|
235
|
+
{
|
|
236
|
+
"aria-expanded": isOpen,
|
|
237
|
+
onClick: ({ detail }) => {
|
|
238
|
+
const { isToggleInferred } = resizeDataRef.current;
|
|
239
|
+
if (isShort || !detail || isToggleInferred) {
|
|
240
|
+
persistIsOpen();
|
|
241
|
+
const usedOpenHeight = isShort ? "auto" : openHeight;
|
|
242
|
+
const usedHeight = isOpen ? min : usedOpenHeight;
|
|
243
|
+
applyHeight(usedHeight, false, true);
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
...isShort && {
|
|
247
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
248
|
+
onTouchStart: (event) => event.stopPropagation()
|
|
249
|
+
},
|
|
250
|
+
children: [
|
|
251
|
+
paneLabel,
|
|
252
|
+
/* @__PURE__ */ jsx(Icon, { icon: isOpen ? chevronUp : chevronDown })
|
|
253
|
+
]
|
|
260
254
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}),
|
|
267
|
-
children: [paneLabel, /*#__PURE__*/_jsx(Icon, {
|
|
268
|
-
icon: isOpen ? chevronUp : chevronDown
|
|
269
|
-
})]
|
|
270
|
-
});
|
|
271
|
-
const separator = !isShort && /*#__PURE__*/_jsxs(_Fragment, {
|
|
272
|
-
children: [/*#__PURE__*/_jsx(Tooltip, {
|
|
273
|
-
text: __('Drag to resize'),
|
|
274
|
-
children: /*#__PURE__*/_jsx("button", {
|
|
275
|
-
// eslint-disable-line jsx-a11y/role-supports-aria-props
|
|
255
|
+
);
|
|
256
|
+
const separator = !isShort && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
257
|
+
/* @__PURE__ */ jsx(Tooltip, { text: __("Drag to resize"), children: /* @__PURE__ */ jsx(
|
|
258
|
+
"button",
|
|
259
|
+
{
|
|
276
260
|
ref: separatorRef,
|
|
277
|
-
role: "separator"
|
|
278
|
-
,
|
|
261
|
+
role: "separator",
|
|
279
262
|
"aria-valuenow": usedAriaValueNow,
|
|
280
|
-
"aria-label": __(
|
|
263
|
+
"aria-label": __("Drag to resize"),
|
|
281
264
|
"aria-describedby": separatorHelpId,
|
|
282
265
|
onKeyDown: onSeparatorKeyDown
|
|
283
|
-
})
|
|
284
|
-
}), /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
285
|
-
id: separatorHelpId,
|
|
286
|
-
children: __('Use up and down arrow keys to resize the meta box panel.')
|
|
287
|
-
})]
|
|
288
|
-
});
|
|
289
|
-
const paneProps = /** @type {Parameters<typeof ResizableBox>[0]} */{
|
|
290
|
-
as: NavigableRegion,
|
|
291
|
-
ref: metaBoxesMainRef,
|
|
292
|
-
className: 'edit-post-meta-boxes-main',
|
|
293
|
-
defaultSize: {
|
|
294
|
-
height: isOpen ? openHeight : 0
|
|
295
|
-
},
|
|
296
|
-
minHeight: min,
|
|
297
|
-
maxHeight: max,
|
|
298
|
-
enable: {
|
|
299
|
-
top: true
|
|
300
|
-
},
|
|
301
|
-
handleClasses: {
|
|
302
|
-
top: 'edit-post-meta-boxes-main__presenter'
|
|
303
|
-
},
|
|
304
|
-
handleComponent: {
|
|
305
|
-
top: /*#__PURE__*/_jsxs(_Fragment, {
|
|
306
|
-
children: [toggle, separator]
|
|
307
|
-
})
|
|
308
|
-
},
|
|
309
|
-
// Avoids hiccups while dragging over objects like iframes and ensures that
|
|
310
|
-
// the event to end the drag is captured by the target (resize handle)
|
|
311
|
-
// whether or not it’s under the pointer.
|
|
312
|
-
onPointerDown: ({
|
|
313
|
-
pointerId,
|
|
314
|
-
target
|
|
315
|
-
}) => {
|
|
316
|
-
if (separatorRef.current?.parentElement.contains(target)) {
|
|
317
|
-
target.setPointerCapture(pointerId);
|
|
318
|
-
}
|
|
319
|
-
},
|
|
320
|
-
onResizeStart: ({
|
|
321
|
-
timeStamp
|
|
322
|
-
}, direction, elementRef) => {
|
|
323
|
-
if (isAutoHeight) {
|
|
324
|
-
// Sets the starting height to avoid visual jumps in height and
|
|
325
|
-
// aria-valuenow being `NaN` for the first (few) resize events.
|
|
326
|
-
applyHeight(elementRef.offsetHeight, false, true);
|
|
327
266
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
267
|
+
) }),
|
|
268
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { id: separatorHelpId, children: __(
|
|
269
|
+
"Use up and down arrow keys to resize the meta box panel."
|
|
270
|
+
) })
|
|
271
|
+
] });
|
|
272
|
+
const paneProps = (
|
|
273
|
+
/** @type {Parameters<typeof ResizableBox>[0]} */
|
|
274
|
+
{
|
|
275
|
+
as: NavigableRegion,
|
|
276
|
+
ref: metaBoxesMainRef,
|
|
277
|
+
className: "edit-post-meta-boxes-main",
|
|
278
|
+
defaultSize: { height: isOpen ? openHeight : 0 },
|
|
279
|
+
minHeight: min,
|
|
280
|
+
maxHeight: max,
|
|
281
|
+
enable: { top: true },
|
|
282
|
+
handleClasses: { top: "edit-post-meta-boxes-main__presenter" },
|
|
283
|
+
handleComponent: {
|
|
284
|
+
top: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
285
|
+
toggle,
|
|
286
|
+
separator
|
|
287
|
+
] })
|
|
288
|
+
},
|
|
289
|
+
// Avoids hiccups while dragging over objects like iframes and ensures that
|
|
290
|
+
// the event to end the drag is captured by the target (resize handle)
|
|
291
|
+
// whether or not it’s under the pointer.
|
|
292
|
+
onPointerDown: ({ pointerId, target }) => {
|
|
293
|
+
if (separatorRef.current?.parentElement.contains(target)) {
|
|
294
|
+
target.setPointerCapture(pointerId);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
onResizeStart: ({ timeStamp }, direction, elementRef) => {
|
|
298
|
+
if (isAutoHeight) {
|
|
299
|
+
applyHeight(elementRef.offsetHeight, false, true);
|
|
300
|
+
}
|
|
301
|
+
elementRef.classList.add("is-resizing");
|
|
302
|
+
resizeDataRef.current = { timeStamp, maxDelta: 0 };
|
|
303
|
+
},
|
|
304
|
+
onResize: (event, direction, elementRef, delta) => {
|
|
305
|
+
const { maxDelta } = resizeDataRef.current;
|
|
306
|
+
const newDelta = Math.abs(delta.height);
|
|
307
|
+
resizeDataRef.current.maxDelta = Math.max(maxDelta, newDelta);
|
|
308
|
+
applyHeight(metaBoxesMainRef.current.state.height);
|
|
309
|
+
},
|
|
310
|
+
onResizeStop: (event, direction, elementRef) => {
|
|
311
|
+
elementRef.classList.remove("is-resizing");
|
|
312
|
+
const duration = event.timeStamp - resizeDataRef.current.timeStamp;
|
|
313
|
+
const wasSeparator = event.target === separatorRef.current;
|
|
314
|
+
const { maxDelta } = resizeDataRef.current;
|
|
315
|
+
const isToggleInferred = maxDelta < 1 || duration < 144 && maxDelta < 5;
|
|
316
|
+
if (isShort || !wasSeparator && isToggleInferred) {
|
|
317
|
+
resizeDataRef.current.isToggleInferred = true;
|
|
318
|
+
} else {
|
|
319
|
+
const { height } = metaBoxesMainRef.current.state;
|
|
320
|
+
const nextIsOpen = height > min;
|
|
321
|
+
persistIsOpen(nextIsOpen);
|
|
322
|
+
if (nextIsOpen) {
|
|
323
|
+
applyHeight(height, true);
|
|
324
|
+
}
|
|
364
325
|
}
|
|
365
326
|
}
|
|
366
327
|
}
|
|
367
|
-
|
|
368
|
-
return
|
|
369
|
-
"
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
ref: effectSizeConstraints
|
|
373
|
-
}), contents]
|
|
374
|
-
});
|
|
328
|
+
);
|
|
329
|
+
return /* @__PURE__ */ jsxs(ResizableBox, { "aria-label": paneLabel, ...paneProps, children: [
|
|
330
|
+
/* @__PURE__ */ jsx("meta", { ref: effectSizeConstraints }),
|
|
331
|
+
contents
|
|
332
|
+
] });
|
|
375
333
|
}
|
|
376
334
|
function Layout({
|
|
377
335
|
postId: initialPostId,
|
|
@@ -381,18 +339,17 @@ function Layout({
|
|
|
381
339
|
}) {
|
|
382
340
|
useEditPostCommands();
|
|
383
341
|
const shouldIframe = useShouldIframe();
|
|
342
|
+
const { createErrorNotice } = useDispatch(noticesStore);
|
|
384
343
|
const {
|
|
385
|
-
|
|
386
|
-
} = useDispatch(noticesStore);
|
|
387
|
-
const {
|
|
388
|
-
currentPost: {
|
|
389
|
-
postId: currentPostId,
|
|
390
|
-
postType: currentPostType
|
|
391
|
-
},
|
|
344
|
+
currentPost: { postId: currentPostId, postType: currentPostType },
|
|
392
345
|
onNavigateToEntityRecord,
|
|
393
346
|
onNavigateToPreviousEntityRecord
|
|
394
|
-
} = useNavigateToEntityRecord(
|
|
395
|
-
|
|
347
|
+
} = useNavigateToEntityRecord(
|
|
348
|
+
initialPostId,
|
|
349
|
+
initialPostType,
|
|
350
|
+
"post-only"
|
|
351
|
+
);
|
|
352
|
+
const isEditingTemplate = currentPostType === "wp_template";
|
|
396
353
|
const {
|
|
397
354
|
mode,
|
|
398
355
|
isFullscreenActive,
|
|
@@ -406,177 +363,211 @@ function Layout({
|
|
|
406
363
|
templateId,
|
|
407
364
|
enablePaddingAppender,
|
|
408
365
|
isDevicePreview
|
|
409
|
-
} = useSelect(
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
366
|
+
} = useSelect(
|
|
367
|
+
(select) => {
|
|
368
|
+
const { get } = select(preferencesStore);
|
|
369
|
+
const { isFeatureActive, hasMetaBoxes } = select(editPostStore);
|
|
370
|
+
const { canUser, getPostType, getTemplateId } = unlock(
|
|
371
|
+
select(coreStore)
|
|
372
|
+
);
|
|
373
|
+
const supportsTemplateMode = settings.supportsTemplateMode;
|
|
374
|
+
const isViewable = getPostType(currentPostType)?.viewable ?? false;
|
|
375
|
+
const canViewTemplate = canUser("read", {
|
|
376
|
+
kind: "postType",
|
|
377
|
+
name: "wp_template"
|
|
378
|
+
});
|
|
379
|
+
const { getBlockSelectionStart, isZoomOut } = unlock(
|
|
380
|
+
select(blockEditorStore)
|
|
381
|
+
);
|
|
382
|
+
const {
|
|
383
|
+
getEditorMode,
|
|
384
|
+
getRenderingMode,
|
|
385
|
+
getDefaultRenderingMode,
|
|
386
|
+
getDeviceType
|
|
387
|
+
} = unlock(select(editorStore));
|
|
388
|
+
const isRenderingPostOnly = getRenderingMode() === "post-only";
|
|
389
|
+
const isNotDesignPostType = !DESIGN_POST_TYPES.includes(currentPostType);
|
|
390
|
+
const isDirectlyEditingPattern = currentPostType === "wp_block" && !onNavigateToPreviousEntityRecord;
|
|
391
|
+
const _templateId = getTemplateId(currentPostType, currentPostId);
|
|
392
|
+
const defaultMode = getDefaultRenderingMode(currentPostType);
|
|
393
|
+
return {
|
|
394
|
+
mode: getEditorMode(),
|
|
395
|
+
isFullscreenActive: isFeatureActive("fullscreenMode"),
|
|
396
|
+
hasActiveMetaboxes: hasMetaBoxes(),
|
|
397
|
+
hasResolvedMode: defaultMode === "template-locked" ? !!_templateId : defaultMode !== void 0,
|
|
398
|
+
hasBlockSelected: !!getBlockSelectionStart(),
|
|
399
|
+
showIconLabels: get("core", "showIconLabels"),
|
|
400
|
+
isDistractionFree: get("core", "distractionFree"),
|
|
401
|
+
showMetaBoxes: isNotDesignPostType && !isZoomOut() || isDirectlyEditingPattern,
|
|
402
|
+
isWelcomeGuideVisible: isFeatureActive("welcomeGuide"),
|
|
403
|
+
templateId: supportsTemplateMode && isViewable && canViewTemplate && !isEditingTemplate ? _templateId : null,
|
|
404
|
+
enablePaddingAppender: !isZoomOut() && isRenderingPostOnly && isNotDesignPostType,
|
|
405
|
+
isDevicePreview: getDeviceType() !== "Desktop"
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
[
|
|
409
|
+
currentPostType,
|
|
410
|
+
currentPostId,
|
|
411
|
+
isEditingTemplate,
|
|
412
|
+
settings.supportsTemplateMode,
|
|
413
|
+
onNavigateToPreviousEntityRecord
|
|
414
|
+
]
|
|
415
|
+
);
|
|
459
416
|
useMetaBoxInitialization(hasActiveMetaboxes && hasResolvedMode);
|
|
460
|
-
const editableResolvedTemplateId = useSelect(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
417
|
+
const editableResolvedTemplateId = useSelect(
|
|
418
|
+
(select) => {
|
|
419
|
+
if (typeof templateId !== "string") {
|
|
420
|
+
return templateId;
|
|
421
|
+
}
|
|
422
|
+
return unlock(select(coreStore)).getTemplateAutoDraftId(
|
|
423
|
+
templateId
|
|
424
|
+
);
|
|
425
|
+
},
|
|
426
|
+
[templateId]
|
|
427
|
+
);
|
|
428
|
+
const [paddingAppenderRef, paddingStyle] = usePaddingAppender(
|
|
429
|
+
enablePaddingAppender
|
|
430
|
+
);
|
|
431
|
+
const commandContext = hasBlockSelected ? "block-selection-edit" : "entity-edit";
|
|
470
432
|
useCommandContext(commandContext);
|
|
471
|
-
const editorSettings = useMemo(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
433
|
+
const editorSettings = useMemo(
|
|
434
|
+
() => ({
|
|
435
|
+
...settings,
|
|
436
|
+
onNavigateToEntityRecord,
|
|
437
|
+
onNavigateToPreviousEntityRecord,
|
|
438
|
+
defaultRenderingMode: "post-only"
|
|
439
|
+
}),
|
|
440
|
+
[settings, onNavigateToEntityRecord, onNavigateToPreviousEntityRecord]
|
|
441
|
+
);
|
|
477
442
|
const styles = useEditorStyles(paddingStyle);
|
|
478
|
-
|
|
479
|
-
// We need to add the show-icon-labels class to the body element so it is applied to modals.
|
|
480
443
|
if (showIconLabels) {
|
|
481
|
-
document.body.classList.add(
|
|
444
|
+
document.body.classList.add("show-icon-labels");
|
|
482
445
|
} else {
|
|
483
|
-
document.body.classList.remove(
|
|
446
|
+
document.body.classList.remove("show-icon-labels");
|
|
484
447
|
}
|
|
485
448
|
const navigateRegionsProps = useNavigateRegions();
|
|
486
|
-
const className = clsx(
|
|
487
|
-
|
|
449
|
+
const className = clsx("edit-post-layout", "is-mode-" + mode, {
|
|
450
|
+
"has-metaboxes": hasActiveMetaboxes
|
|
488
451
|
});
|
|
489
452
|
function onPluginAreaError(name) {
|
|
490
|
-
createErrorNotice(
|
|
491
|
-
|
|
453
|
+
createErrorNotice(
|
|
454
|
+
sprintf(
|
|
455
|
+
/* translators: %s: plugin name */
|
|
456
|
+
__(
|
|
457
|
+
'The "%s" plugin has encountered an error and cannot be rendered.'
|
|
458
|
+
),
|
|
459
|
+
name
|
|
460
|
+
)
|
|
461
|
+
);
|
|
492
462
|
}
|
|
493
|
-
const {
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
463
|
+
const { createSuccessNotice } = useDispatch(noticesStore);
|
|
464
|
+
const onActionPerformed = useCallback(
|
|
465
|
+
(actionId, items) => {
|
|
466
|
+
switch (actionId) {
|
|
467
|
+
case "move-to-trash":
|
|
468
|
+
{
|
|
469
|
+
document.location.href = addQueryArgs("edit.php", {
|
|
470
|
+
trashed: 1,
|
|
471
|
+
post_type: items[0].type,
|
|
472
|
+
ids: items[0].id
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
break;
|
|
476
|
+
case "duplicate-post":
|
|
477
|
+
{
|
|
478
|
+
const newItem = items[0];
|
|
479
|
+
const title = typeof newItem.title === "string" ? newItem.title : newItem.title?.rendered;
|
|
480
|
+
createSuccessNotice(
|
|
481
|
+
sprintf(
|
|
482
|
+
// translators: %s: Title of the created post or template, e.g: "Hello world".
|
|
483
|
+
__('"%s" successfully created.'),
|
|
484
|
+
decodeEntities(title) || __("(no title)")
|
|
485
|
+
),
|
|
486
|
+
{
|
|
487
|
+
type: "snackbar",
|
|
488
|
+
id: "duplicate-post-action",
|
|
489
|
+
actions: [
|
|
490
|
+
{
|
|
491
|
+
label: __("Edit"),
|
|
492
|
+
onClick: () => {
|
|
493
|
+
const postId = newItem.id;
|
|
494
|
+
document.location.href = addQueryArgs("post.php", {
|
|
495
|
+
post: postId,
|
|
496
|
+
action: "edit"
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
]
|
|
524
501
|
}
|
|
525
|
-
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
|
|
502
|
+
);
|
|
503
|
+
}
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
[createSuccessNotice]
|
|
508
|
+
);
|
|
531
509
|
const initialPost = useMemo(() => {
|
|
532
510
|
return {
|
|
533
511
|
type: initialPostType,
|
|
534
512
|
id: initialPostId
|
|
535
513
|
};
|
|
536
514
|
}, [initialPostType, initialPostId]);
|
|
537
|
-
const backButton = useViewportMatch(
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
children: [/*#__PURE__*/_jsx(WelcomeGuide, {
|
|
544
|
-
postType: currentPostType
|
|
545
|
-
}), /*#__PURE__*/_jsx("div", {
|
|
515
|
+
const backButton = useViewportMatch("medium") && isFullscreenActive ? /* @__PURE__ */ jsx(BackButton, { initialPost }) : null;
|
|
516
|
+
return /* @__PURE__ */ jsx(SlotFillProvider, { children: /* @__PURE__ */ jsxs(ErrorBoundary, { canCopyContent: true, children: [
|
|
517
|
+
/* @__PURE__ */ jsx(WelcomeGuide, { postType: currentPostType }),
|
|
518
|
+
/* @__PURE__ */ jsx(
|
|
519
|
+
"div",
|
|
520
|
+
{
|
|
546
521
|
className: navigateRegionsProps.className,
|
|
547
522
|
...navigateRegionsProps,
|
|
548
523
|
ref: navigateRegionsProps.ref,
|
|
549
|
-
children:
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
524
|
+
children: /* @__PURE__ */ jsxs(
|
|
525
|
+
Editor,
|
|
526
|
+
{
|
|
527
|
+
settings: editorSettings,
|
|
528
|
+
initialEdits,
|
|
529
|
+
postType: currentPostType,
|
|
530
|
+
postId: currentPostId,
|
|
531
|
+
templateId: editableResolvedTemplateId,
|
|
532
|
+
className,
|
|
533
|
+
styles,
|
|
534
|
+
forceIsDirty: hasActiveMetaboxes,
|
|
535
|
+
contentRef: paddingAppenderRef,
|
|
536
|
+
disableIframe: !shouldIframe,
|
|
537
|
+
autoFocus: !isWelcomeGuideVisible,
|
|
538
|
+
onActionPerformed,
|
|
539
|
+
extraSidebarPanels: showMetaBoxes && /* @__PURE__ */ jsx(MetaBoxes, { location: "side" }),
|
|
540
|
+
extraContent: !isDistractionFree && showMetaBoxes && /* @__PURE__ */ jsx(
|
|
541
|
+
MetaBoxesMain,
|
|
542
|
+
{
|
|
543
|
+
isLegacy: !shouldIframe || isDevicePreview
|
|
544
|
+
}
|
|
545
|
+
),
|
|
546
|
+
children: [
|
|
547
|
+
/* @__PURE__ */ jsx(PostLockedModal, {}),
|
|
548
|
+
/* @__PURE__ */ jsx(EditorInitialization, {}),
|
|
549
|
+
/* @__PURE__ */ jsx(FullscreenMode, { isActive: isFullscreenActive }),
|
|
550
|
+
/* @__PURE__ */ jsx(BrowserURL, {}),
|
|
551
|
+
/* @__PURE__ */ jsx(UnsavedChangesWarning, {}),
|
|
552
|
+
/* @__PURE__ */ jsx(AutosaveMonitor, {}),
|
|
553
|
+
/* @__PURE__ */ jsx(LocalAutosaveMonitor, {}),
|
|
554
|
+
/* @__PURE__ */ jsx(EditPostKeyboardShortcuts, {}),
|
|
555
|
+
/* @__PURE__ */ jsx(EditorKeyboardShortcutsRegister, {}),
|
|
556
|
+
/* @__PURE__ */ jsx(BlockKeyboardShortcuts, {}),
|
|
557
|
+
/* @__PURE__ */ jsx(InitPatternModal, {}),
|
|
558
|
+
/* @__PURE__ */ jsx(PluginArea, { onError: onPluginAreaError }),
|
|
559
|
+
/* @__PURE__ */ jsx(PostEditorMoreMenu, {}),
|
|
560
|
+
backButton,
|
|
561
|
+
/* @__PURE__ */ jsx(EditorSnackbars, {})
|
|
562
|
+
]
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
}
|
|
566
|
+
)
|
|
567
|
+
] }) });
|
|
580
568
|
}
|
|
581
|
-
|
|
582
|
-
|
|
569
|
+
var layout_default = Layout;
|
|
570
|
+
export {
|
|
571
|
+
layout_default as default
|
|
572
|
+
};
|
|
573
|
+
//# sourceMappingURL=index.js.map
|