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