@wordpress/edit-post 7.24.1 → 7.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/LICENSE.md +1 -1
- package/build/components/browser-url/index.js +3 -2
- package/build/components/browser-url/index.js.map +1 -1
- package/build/components/header/index.js +35 -33
- package/build/components/header/index.js.map +1 -1
- package/build/components/header/mode-switcher/index.js +1 -1
- package/build/components/header/mode-switcher/index.js.map +1 -1
- package/build/components/header/more-menu/index.js +2 -1
- package/build/components/header/more-menu/index.js.map +1 -1
- package/build/components/header/writing-menu/index.js +22 -18
- package/build/components/header/writing-menu/index.js.map +1 -1
- package/build/components/keyboard-shortcuts/index.js +1 -20
- package/build/components/keyboard-shortcuts/index.js.map +1 -1
- package/build/components/layout/index.js +45 -38
- package/build/components/layout/index.js.map +1 -1
- package/build/components/layout/index.native.js +3 -1
- package/build/components/layout/index.native.js.map +1 -1
- package/build/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build/components/preferences-modal/index.js +87 -54
- package/build/components/preferences-modal/index.js.map +1 -1
- package/build/components/preferences-modal/options/enable-feature.js +23 -23
- package/build/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build/components/preferences-modal/options/enable-panel.js +3 -6
- package/build/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build/components/sidebar/post-status/index.js +3 -5
- package/build/components/sidebar/post-status/index.js.map +1 -1
- package/build/components/sidebar/settings-header/index.js +17 -43
- package/build/components/sidebar/settings-header/index.js.map +1 -1
- package/build/components/sidebar/settings-sidebar/index.js +80 -26
- package/build/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build/components/start-page-options/index.js +3 -3
- package/build/components/start-page-options/index.js.map +1 -1
- package/build/components/visual-editor/index.js +20 -257
- package/build/components/visual-editor/index.js.map +1 -1
- package/build/components/welcome-guide/index.js +6 -3
- package/build/components/welcome-guide/index.js.map +1 -1
- package/build/editor.js +20 -30
- package/build/editor.js.map +1 -1
- package/build/editor.native.js +3 -11
- package/build/editor.native.js.map +1 -1
- package/build/hooks/commands/use-common-commands.js +16 -12
- package/build/hooks/commands/use-common-commands.js.map +1 -1
- package/build/hooks/use-post-history.js +79 -0
- package/build/hooks/use-post-history.js.map +1 -0
- package/build/index.js +24 -20
- package/build/index.js.map +1 -1
- package/build/index.native.js +7 -1
- package/build/index.native.js.map +1 -1
- package/build/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build/store/actions.js +94 -112
- package/build/store/actions.js.map +1 -1
- package/build/store/reducer.js +1 -95
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +86 -48
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/browser-url/index.js +3 -2
- package/build-module/components/browser-url/index.js.map +1 -1
- package/build-module/components/header/index.js +37 -35
- package/build-module/components/header/index.js.map +1 -1
- package/build-module/components/header/mode-switcher/index.js +1 -1
- package/build-module/components/header/mode-switcher/index.js.map +1 -1
- package/build-module/components/header/more-menu/index.js +2 -1
- package/build-module/components/header/more-menu/index.js.map +1 -1
- package/build-module/components/header/writing-menu/index.js +23 -19
- package/build-module/components/header/writing-menu/index.js.map +1 -1
- package/build-module/components/keyboard-shortcuts/index.js +1 -20
- package/build-module/components/keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/layout/index.js +46 -38
- package/build-module/components/layout/index.js.map +1 -1
- package/build-module/components/layout/index.native.js +4 -2
- package/build-module/components/layout/index.native.js.map +1 -1
- package/build-module/components/meta-boxes/meta-box-visibility.js +2 -6
- package/build-module/components/meta-boxes/meta-box-visibility.js.map +1 -1
- package/build-module/components/preferences-modal/index.js +87 -54
- package/build-module/components/preferences-modal/index.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-feature.js +22 -23
- package/build-module/components/preferences-modal/options/enable-feature.js.map +1 -1
- package/build-module/components/preferences-modal/options/enable-panel.js +3 -7
- package/build-module/components/preferences-modal/options/enable-panel.js.map +1 -1
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/build-module/components/sidebar/plugin-document-setting-panel/index.js.map +1 -1
- package/build-module/components/sidebar/plugin-sidebar/index.js +2 -10
- package/build-module/components/sidebar/plugin-sidebar/index.js.map +1 -1
- package/build-module/components/sidebar/post-status/index.js +4 -6
- package/build-module/components/sidebar/post-status/index.js.map +1 -1
- package/build-module/components/sidebar/settings-header/index.js +20 -46
- package/build-module/components/sidebar/settings-header/index.js.map +1 -1
- package/build-module/components/sidebar/settings-sidebar/index.js +80 -27
- package/build-module/components/sidebar/settings-sidebar/index.js.map +1 -1
- package/build-module/components/start-page-options/index.js +3 -3
- package/build-module/components/start-page-options/index.js.map +1 -1
- package/build-module/components/visual-editor/index.js +24 -261
- package/build-module/components/visual-editor/index.js.map +1 -1
- package/build-module/components/welcome-guide/index.js +6 -3
- package/build-module/components/welcome-guide/index.js.map +1 -1
- package/build-module/editor.js +20 -30
- package/build-module/editor.js.map +1 -1
- package/build-module/editor.native.js +3 -11
- package/build-module/editor.native.js.map +1 -1
- package/build-module/hooks/commands/use-common-commands.js +16 -12
- package/build-module/hooks/commands/use-common-commands.js.map +1 -1
- package/build-module/hooks/use-post-history.js +73 -0
- package/build-module/hooks/use-post-history.js.map +1 -0
- package/build-module/index.js +19 -12
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +7 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/plugins/welcome-guide-menu-item/index.js +2 -6
- package/build-module/plugins/welcome-guide-menu-item/index.js.map +1 -1
- package/build-module/store/actions.js +86 -105
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/reducer.js +1 -92
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +76 -38
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +65 -473
- package/build-style/style.css +65 -473
- package/package.json +32 -32
- package/src/components/browser-url/index.js +4 -2
- package/src/components/header/index.js +45 -46
- package/src/components/header/mode-switcher/index.js +2 -1
- package/src/components/header/more-menu/index.js +1 -0
- package/src/components/header/style.scss +63 -37
- package/src/components/header/writing-menu/index.js +24 -24
- package/src/components/keyboard-shortcut-help-modal/test/index.js +0 -15
- package/src/components/keyboard-shortcuts/index.js +1 -23
- package/src/components/layout/index.js +31 -39
- package/src/components/layout/index.native.js +9 -1
- package/src/components/meta-boxes/meta-box-visibility.js +2 -8
- package/src/components/preferences-modal/index.js +128 -97
- package/src/components/preferences-modal/options/enable-feature.js +26 -21
- package/src/components/preferences-modal/options/enable-panel.js +3 -7
- package/src/components/preferences-modal/test/__snapshots__/meta-boxes-section.js.snap +187 -175
- package/src/components/preferences-modal/test/index.js +1 -52
- package/src/components/sidebar/plugin-document-setting-panel/index.js +3 -3
- package/src/components/sidebar/plugin-sidebar/index.js +1 -9
- package/src/components/sidebar/post-status/index.js +5 -5
- package/src/components/sidebar/settings-header/index.js +19 -71
- package/src/components/sidebar/settings-sidebar/index.js +125 -60
- package/src/components/sidebar/style.scss +4 -12
- package/src/components/start-page-options/index.js +3 -3
- package/src/components/text-editor/style.scss +0 -6
- package/src/components/visual-editor/index.js +26 -359
- package/src/components/visual-editor/style.scss +0 -15
- package/src/components/welcome-guide/index.js +4 -2
- package/src/editor.js +36 -35
- package/src/editor.native.js +2 -23
- package/src/hooks/commands/use-common-commands.js +14 -16
- package/src/hooks/use-post-history.js +73 -0
- package/src/index.js +24 -13
- package/src/index.native.js +8 -1
- package/src/plugins/welcome-guide-menu-item/index.js +3 -6
- package/src/store/actions.js +80 -131
- package/src/store/reducer.js +0 -93
- package/src/store/selectors.js +97 -55
- package/src/store/test/actions.js +10 -131
- package/src/store/test/reducer.js +1 -108
- package/src/store/test/selectors.js +0 -50
- package/src/style.scss +1 -8
- package/src/test/__snapshots__/editor.native.js.snap +21 -0
- package/src/test/editor.native.js +107 -56
- package/build/components/device-preview/index.js +0 -72
- package/build/components/device-preview/index.js.map +0 -1
- package/build/components/header/document-actions/index.js +0 -82
- package/build/components/header/document-actions/index.js.map +0 -1
- package/build/components/header/header-toolbar/index.js +0 -156
- package/build/components/header/header-toolbar/index.js.map +0 -1
- package/build/components/secondary-sidebar/inserter-sidebar.js +0 -73
- package/build/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-outline.js +0 -112
- package/build/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build/components/secondary-sidebar/list-view-sidebar.js +0 -148
- package/build/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build/components/sidebar/discussion-panel/index.js +0 -59
- package/build/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build/components/sidebar/featured-image/index.js +0 -70
- package/build/components/sidebar/featured-image/index.js.map +0 -1
- package/build/components/sidebar/last-revision/index.js +0 -21
- package/build/components/sidebar/last-revision/index.js.map +0 -1
- package/build/components/sidebar/page-attributes/index.js +0 -65
- package/build/components/sidebar/page-attributes/index.js.map +0 -1
- package/build/components/sidebar/plugin-post-excerpt/index.js +0 -72
- package/build/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-excerpt/index.js +0 -54
- package/build/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/index.js +0 -30
- package/build/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -56
- package/build/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
- package/build/components/sidebar/post-template/create-modal.js +0 -99
- package/build/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build/components/sidebar/post-template/form.js +0 -110
- package/build/components/sidebar/post-template/form.js.map +0 -1
- package/build/components/sidebar/post-template/index.js +0 -106
- package/build/components/sidebar/post-template/index.js.map +0 -1
- package/build/components/view-link/index.js +0 -53
- package/build/components/view-link/index.js.map +0 -1
- package/build-module/components/device-preview/index.js +0 -65
- package/build-module/components/device-preview/index.js.map +0 -1
- package/build-module/components/header/document-actions/index.js +0 -74
- package/build-module/components/header/document-actions/index.js.map +0 -1
- package/build-module/components/header/header-toolbar/index.js +0 -148
- package/build-module/components/header/header-toolbar/index.js.map +0 -1
- package/build-module/components/secondary-sidebar/inserter-sidebar.js +0 -66
- package/build-module/components/secondary-sidebar/inserter-sidebar.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-outline.js +0 -105
- package/build-module/components/secondary-sidebar/list-view-outline.js.map +0 -1
- package/build-module/components/secondary-sidebar/list-view-sidebar.js +0 -140
- package/build-module/components/secondary-sidebar/list-view-sidebar.js.map +0 -1
- package/build-module/components/sidebar/discussion-panel/index.js +0 -52
- package/build-module/components/sidebar/discussion-panel/index.js.map +0 -1
- package/build-module/components/sidebar/featured-image/index.js +0 -63
- package/build-module/components/sidebar/featured-image/index.js.map +0 -1
- package/build-module/components/sidebar/last-revision/index.js +0 -13
- package/build-module/components/sidebar/last-revision/index.js.map +0 -1
- package/build-module/components/sidebar/page-attributes/index.js +0 -57
- package/build-module/components/sidebar/page-attributes/index.js.map +0 -1
- package/build-module/components/sidebar/plugin-post-excerpt/index.js +0 -64
- package/build-module/components/sidebar/plugin-post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-excerpt/index.js +0 -47
- package/build-module/components/sidebar/post-excerpt/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/index.js +0 -21
- package/build-module/components/sidebar/post-taxonomies/index.js.map +0 -1
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- package/build-module/components/sidebar/post-taxonomies/taxonomy-panel.js.map +0 -1
- package/build-module/components/sidebar/post-template/create-modal.js +0 -92
- package/build-module/components/sidebar/post-template/create-modal.js.map +0 -1
- package/build-module/components/sidebar/post-template/form.js +0 -102
- package/build-module/components/sidebar/post-template/form.js.map +0 -1
- package/build-module/components/sidebar/post-template/index.js +0 -98
- package/build-module/components/sidebar/post-template/index.js.map +0 -1
- package/build-module/components/view-link/index.js +0 -46
- package/build-module/components/view-link/index.js.map +0 -1
- package/src/components/device-preview/index.js +0 -73
- package/src/components/header/document-actions/index.js +0 -82
- package/src/components/header/document-actions/style.scss +0 -64
- package/src/components/header/header-toolbar/index.js +0 -182
- package/src/components/header/header-toolbar/style.scss +0 -114
- package/src/components/keyboard-shortcut-help-modal/test/__snapshots__/index.js.snap +0 -929
- package/src/components/secondary-sidebar/inserter-sidebar.js +0 -71
- package/src/components/secondary-sidebar/list-view-outline.js +0 -98
- package/src/components/secondary-sidebar/list-view-sidebar.js +0 -170
- package/src/components/secondary-sidebar/style.scss +0 -120
- package/src/components/sidebar/discussion-panel/index.js +0 -62
- package/src/components/sidebar/featured-image/index.js +0 -67
- package/src/components/sidebar/last-revision/index.js +0 -17
- package/src/components/sidebar/last-revision/style.scss +0 -10
- package/src/components/sidebar/page-attributes/index.js +0 -65
- package/src/components/sidebar/plugin-post-excerpt/index.js +0 -61
- package/src/components/sidebar/plugin-post-excerpt/test/index.js +0 -36
- package/src/components/sidebar/post-excerpt/index.js +0 -59
- package/src/components/sidebar/post-taxonomies/index.js +0 -30
- package/src/components/sidebar/post-taxonomies/taxonomy-panel.js +0 -48
- package/src/components/sidebar/post-template/create-modal.js +0 -140
- package/src/components/sidebar/post-template/form.js +0 -141
- package/src/components/sidebar/post-template/index.js +0 -120
- package/src/components/sidebar/post-template/style.scss +0 -22
- package/src/components/sidebar/settings-header/style.scss +0 -74
- package/src/components/sidebar/template/style.scss +0 -35
- package/src/components/view-link/index.js +0 -48
|
@@ -8,13 +8,9 @@ exports.default = VisualEditor;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
10
10
|
var _editor = require("@wordpress/editor");
|
|
11
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
12
11
|
var _element = require("@wordpress/element");
|
|
13
|
-
var _components = require("@wordpress/components");
|
|
14
12
|
var _data = require("@wordpress/data");
|
|
15
|
-
var _compose = require("@wordpress/compose");
|
|
16
13
|
var _blocks = require("@wordpress/blocks");
|
|
17
|
-
var _coreData = require("@wordpress/core-data");
|
|
18
14
|
var _store = require("../../store");
|
|
19
15
|
var _lockUnlock = require("../../lock-unlock");
|
|
20
16
|
/**
|
|
@@ -30,296 +26,63 @@ var _lockUnlock = require("../../lock-unlock");
|
|
|
30
26
|
*/
|
|
31
27
|
|
|
32
28
|
const {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
useLayoutStyles,
|
|
36
|
-
ExperimentalBlockCanvas: BlockCanvas
|
|
37
|
-
} = (0, _lockUnlock.unlock)(_blockEditor.privateApis);
|
|
29
|
+
EditorCanvas
|
|
30
|
+
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
38
31
|
const isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Given an array of nested blocks, find the first Post Content
|
|
42
|
-
* block inside it, recursing through any nesting levels,
|
|
43
|
-
* and return its attributes.
|
|
44
|
-
*
|
|
45
|
-
* @param {Array} blocks A list of blocks.
|
|
46
|
-
*
|
|
47
|
-
* @return {Object | undefined} The Post Content block.
|
|
48
|
-
*/
|
|
49
|
-
function getPostContentAttributes(blocks) {
|
|
50
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
51
|
-
if (blocks[i].name === 'core/post-content') {
|
|
52
|
-
return blocks[i].attributes;
|
|
53
|
-
}
|
|
54
|
-
if (blocks[i].innerBlocks.length) {
|
|
55
|
-
const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
|
|
56
|
-
if (nestedPostContent) {
|
|
57
|
-
return nestedPostContent;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function checkForPostContentAtRootLevel(blocks) {
|
|
63
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
64
|
-
if (blocks[i].name === 'core/post-content') {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
32
|
function VisualEditor({
|
|
71
33
|
styles
|
|
72
34
|
}) {
|
|
73
35
|
const {
|
|
74
|
-
deviceType,
|
|
75
36
|
isWelcomeGuideVisible,
|
|
76
|
-
|
|
77
|
-
postContentAttributes,
|
|
78
|
-
editedPostTemplate = {},
|
|
79
|
-
wrapperBlockName,
|
|
80
|
-
wrapperUniqueId,
|
|
37
|
+
renderingMode,
|
|
81
38
|
isBlockBasedTheme,
|
|
82
39
|
hasV3BlocksOnly
|
|
83
40
|
} = (0, _data.useSelect)(select => {
|
|
84
41
|
const {
|
|
85
|
-
isFeatureActive
|
|
86
|
-
isEditingTemplate,
|
|
87
|
-
getEditedPostTemplate,
|
|
88
|
-
__experimentalGetPreviewDeviceType
|
|
42
|
+
isFeatureActive
|
|
89
43
|
} = select(_store.store);
|
|
90
44
|
const {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
getEditorSettings
|
|
45
|
+
getEditorSettings,
|
|
46
|
+
getRenderingMode
|
|
94
47
|
} = select(_editor.store);
|
|
95
48
|
const {
|
|
96
49
|
getBlockTypes
|
|
97
50
|
} = select(_blocks.store);
|
|
98
|
-
const _isTemplateMode = isEditingTemplate();
|
|
99
|
-
const postTypeSlug = getCurrentPostType();
|
|
100
|
-
let _wrapperBlockName;
|
|
101
|
-
if (postTypeSlug === 'wp_block') {
|
|
102
|
-
_wrapperBlockName = 'core/block';
|
|
103
|
-
} else if (!_isTemplateMode) {
|
|
104
|
-
_wrapperBlockName = 'core/post-content';
|
|
105
|
-
}
|
|
106
51
|
const editorSettings = getEditorSettings();
|
|
107
|
-
const supportsTemplateMode = editorSettings.supportsTemplateMode;
|
|
108
|
-
const postType = select(_coreData.store).getPostType(postTypeSlug);
|
|
109
|
-
const canEditTemplate = select(_coreData.store).canUser('create', 'templates');
|
|
110
52
|
return {
|
|
111
|
-
deviceType: __experimentalGetPreviewDeviceType(),
|
|
112
53
|
isWelcomeGuideVisible: isFeatureActive('welcomeGuide'),
|
|
113
|
-
|
|
114
|
-
postContentAttributes: getEditorSettings().postContentAttributes,
|
|
115
|
-
// Post template fetch returns a 404 on classic themes, which
|
|
116
|
-
// messes with e2e tests, so check it's a block theme first.
|
|
117
|
-
editedPostTemplate: postType?.viewable && supportsTemplateMode && canEditTemplate ? getEditedPostTemplate() : undefined,
|
|
118
|
-
wrapperBlockName: _wrapperBlockName,
|
|
119
|
-
wrapperUniqueId: getCurrentPostId(),
|
|
54
|
+
renderingMode: getRenderingMode(),
|
|
120
55
|
isBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,
|
|
121
56
|
hasV3BlocksOnly: getBlockTypes().every(type => {
|
|
122
57
|
return type.apiVersion >= 3;
|
|
123
58
|
})
|
|
124
59
|
};
|
|
125
60
|
}, []);
|
|
126
|
-
const {
|
|
127
|
-
isCleanNewPost
|
|
128
|
-
} = (0, _data.useSelect)(_editor.store);
|
|
129
61
|
const hasMetaBoxes = (0, _data.useSelect)(select => select(_store.store).hasMetaBoxes(), []);
|
|
130
|
-
const {
|
|
131
|
-
hasRootPaddingAwareAlignments,
|
|
132
|
-
isFocusMode,
|
|
133
|
-
themeHasDisabledLayoutStyles,
|
|
134
|
-
themeSupportsLayout
|
|
135
|
-
} = (0, _data.useSelect)(select => {
|
|
136
|
-
const _settings = select(_blockEditor.store).getSettings();
|
|
137
|
-
return {
|
|
138
|
-
themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
|
|
139
|
-
themeSupportsLayout: _settings.supportsLayout,
|
|
140
|
-
isFocusMode: _settings.focusMode,
|
|
141
|
-
hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments
|
|
142
|
-
};
|
|
143
|
-
}, []);
|
|
144
|
-
const desktopCanvasStyles = {
|
|
145
|
-
height: '100%',
|
|
146
|
-
width: '100%',
|
|
147
|
-
marginLeft: 'auto',
|
|
148
|
-
marginRight: 'auto',
|
|
149
|
-
display: 'flex',
|
|
150
|
-
flexFlow: 'column',
|
|
151
|
-
// Default background color so that grey
|
|
152
|
-
// .edit-post-editor-regions__content color doesn't show through.
|
|
153
|
-
background: 'white'
|
|
154
|
-
};
|
|
155
|
-
const templateModeStyles = {
|
|
156
|
-
...desktopCanvasStyles,
|
|
157
|
-
borderRadius: '2px 2px 0 0',
|
|
158
|
-
border: '1px solid #ddd',
|
|
159
|
-
borderBottom: 0
|
|
160
|
-
};
|
|
161
|
-
const resizedCanvasStyles = (0, _blockEditor.__experimentalUseResizeCanvas)(deviceType, isTemplateMode);
|
|
162
|
-
const [globalLayoutSettings] = (0, _blockEditor.useSettings)('layout');
|
|
163
|
-
const previewMode = 'is-' + deviceType.toLowerCase() + '-preview';
|
|
164
|
-
let animatedStyles = isTemplateMode ? templateModeStyles : desktopCanvasStyles;
|
|
165
|
-
if (resizedCanvasStyles) {
|
|
166
|
-
animatedStyles = resizedCanvasStyles;
|
|
167
|
-
}
|
|
168
62
|
let paddingBottom;
|
|
169
63
|
|
|
170
64
|
// Add a constant padding for the typewritter effect. When typing at the
|
|
171
65
|
// bottom, there needs to be room to scroll up.
|
|
172
|
-
if (!hasMetaBoxes &&
|
|
66
|
+
if (!hasMetaBoxes && renderingMode === 'post-only') {
|
|
173
67
|
paddingBottom = '40vh';
|
|
174
68
|
}
|
|
175
|
-
const ref = (0, _element.useRef)();
|
|
176
|
-
const contentRef = (0, _compose.useMergeRefs)([ref, (0, _blockEditor.__unstableUseTypewriter)()]);
|
|
177
|
-
|
|
178
|
-
// fallbackLayout is used if there is no Post Content,
|
|
179
|
-
// and for Post Title.
|
|
180
|
-
const fallbackLayout = (0, _element.useMemo)(() => {
|
|
181
|
-
if (isTemplateMode) {
|
|
182
|
-
return {
|
|
183
|
-
type: 'default'
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
if (themeSupportsLayout) {
|
|
187
|
-
// We need to ensure support for wide and full alignments,
|
|
188
|
-
// so we add the constrained type.
|
|
189
|
-
return {
|
|
190
|
-
...globalLayoutSettings,
|
|
191
|
-
type: 'constrained'
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
// Set default layout for classic themes so all alignments are supported.
|
|
195
|
-
return {
|
|
196
|
-
type: 'default'
|
|
197
|
-
};
|
|
198
|
-
}, [isTemplateMode, themeSupportsLayout, globalLayoutSettings]);
|
|
199
|
-
const newestPostContentAttributes = (0, _element.useMemo)(() => {
|
|
200
|
-
if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
|
|
201
|
-
return postContentAttributes;
|
|
202
|
-
}
|
|
203
|
-
// When in template editing mode, we can access the blocks directly.
|
|
204
|
-
if (editedPostTemplate?.blocks) {
|
|
205
|
-
return getPostContentAttributes(editedPostTemplate?.blocks);
|
|
206
|
-
}
|
|
207
|
-
// If there are no blocks, we have to parse the content string.
|
|
208
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
209
|
-
const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
|
|
210
|
-
return getPostContentAttributes((0, _blocks.parse)(parseableContent)) || {};
|
|
211
|
-
}, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
|
|
212
|
-
const hasPostContentAtRootLevel = (0, _element.useMemo)(() => {
|
|
213
|
-
if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
|
|
214
|
-
return false;
|
|
215
|
-
}
|
|
216
|
-
// When in template editing mode, we can access the blocks directly.
|
|
217
|
-
if (editedPostTemplate?.blocks) {
|
|
218
|
-
return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
|
|
219
|
-
}
|
|
220
|
-
// If there are no blocks, we have to parse the content string.
|
|
221
|
-
// Best double-check it's a string otherwise the parse function gets unhappy.
|
|
222
|
-
const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
|
|
223
|
-
return checkForPostContentAtRootLevel((0, _blocks.parse)(parseableContent)) || false;
|
|
224
|
-
}, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
|
|
225
|
-
const {
|
|
226
|
-
layout = {},
|
|
227
|
-
align = ''
|
|
228
|
-
} = newestPostContentAttributes || {};
|
|
229
|
-
const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
|
|
230
|
-
const blockListLayoutClass = (0, _classnames.default)({
|
|
231
|
-
'is-layout-flow': !themeSupportsLayout
|
|
232
|
-
}, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
|
|
233
|
-
const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
|
|
234
|
-
|
|
235
|
-
// Update type for blocks using legacy layouts.
|
|
236
|
-
const postContentLayout = (0, _element.useMemo)(() => {
|
|
237
|
-
return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
|
|
238
|
-
...globalLayoutSettings,
|
|
239
|
-
...layout,
|
|
240
|
-
type: 'constrained'
|
|
241
|
-
} : {
|
|
242
|
-
...globalLayoutSettings,
|
|
243
|
-
...layout,
|
|
244
|
-
type: 'default'
|
|
245
|
-
};
|
|
246
|
-
}, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
|
|
247
|
-
|
|
248
|
-
// If there is a Post Content block we use its layout for the block list;
|
|
249
|
-
// if not, this must be a classic theme, in which case we use the fallback layout.
|
|
250
|
-
const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
|
|
251
|
-
const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
|
|
252
|
-
const observeTypingRef = (0, _blockEditor.__unstableUseTypingObserver)();
|
|
253
|
-
const titleRef = (0, _element.useRef)();
|
|
254
|
-
(0, _element.useEffect)(() => {
|
|
255
|
-
if (isWelcomeGuideVisible || !isCleanNewPost()) {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
titleRef?.current?.focus();
|
|
259
|
-
}, [isWelcomeGuideVisible, isCleanNewPost]);
|
|
260
69
|
styles = (0, _element.useMemo)(() => [...styles, {
|
|
261
70
|
// We should move this in to future to the body.
|
|
262
|
-
css:
|
|
263
|
-
}], [styles]);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
|
|
267
|
-
.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
|
|
268
|
-
.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
|
|
269
|
-
.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
|
|
270
|
-
const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || isTemplateMode || deviceType === 'Tablet' || deviceType === 'Mobile';
|
|
271
|
-
return (0, _react.createElement)(_blockEditor.BlockTools, {
|
|
272
|
-
__unstableContentRef: ref,
|
|
71
|
+
css: paddingBottom ? `body{padding-bottom:${paddingBottom}}` : ''
|
|
72
|
+
}], [styles, paddingBottom]);
|
|
73
|
+
const isToBeIframed = (hasV3BlocksOnly || isGutenbergPlugin && isBlockBasedTheme) && !hasMetaBoxes || renderingMode === 'template-only';
|
|
74
|
+
return (0, _react.createElement)("div", {
|
|
273
75
|
className: (0, _classnames.default)('edit-post-visual-editor', {
|
|
274
|
-
'is-template-mode':
|
|
76
|
+
'is-template-mode': renderingMode === 'template-only',
|
|
275
77
|
'has-inline-canvas': !isToBeIframed
|
|
276
78
|
})
|
|
277
|
-
}, (0, _react.createElement)(
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}, (0, _react.createElement)(_components.__unstableMotion.div, {
|
|
283
|
-
animate: animatedStyles,
|
|
284
|
-
initial: desktopCanvasStyles,
|
|
285
|
-
className: previewMode
|
|
286
|
-
}, (0, _react.createElement)(BlockCanvas, {
|
|
287
|
-
shouldIframe: isToBeIframed,
|
|
288
|
-
contentRef: contentRef,
|
|
289
|
-
styles: styles,
|
|
290
|
-
height: "100%"
|
|
291
|
-
}, themeSupportsLayout && !themeHasDisabledLayoutStyles && !isTemplateMode && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(LayoutStyle, {
|
|
292
|
-
selector: ".edit-post-visual-editor__post-title-wrapper",
|
|
293
|
-
layout: fallbackLayout
|
|
294
|
-
}), (0, _react.createElement)(LayoutStyle, {
|
|
295
|
-
selector: ".block-editor-block-list__layout.is-root-container",
|
|
296
|
-
layout: postEditorLayout
|
|
297
|
-
}), align && (0, _react.createElement)(LayoutStyle, {
|
|
298
|
-
css: alignCSS
|
|
299
|
-
}), postContentLayoutStyles && (0, _react.createElement)(LayoutStyle, {
|
|
300
|
-
layout: postContentLayout,
|
|
301
|
-
css: postContentLayoutStyles
|
|
302
|
-
})), !isTemplateMode && (0, _react.createElement)("div", {
|
|
303
|
-
className: (0, _classnames.default)('edit-post-visual-editor__post-title-wrapper', {
|
|
304
|
-
'is-focus-mode': isFocusMode,
|
|
305
|
-
'has-global-padding': hasRootPaddingAwareAlignments
|
|
306
|
-
}),
|
|
307
|
-
contentEditable: false,
|
|
308
|
-
ref: observeTypingRef
|
|
309
|
-
}, (0, _react.createElement)(_editor.PostTitle, {
|
|
310
|
-
ref: titleRef
|
|
311
|
-
})), (0, _react.createElement)(_blockEditor.__experimentalRecursionProvider, {
|
|
312
|
-
blockName: wrapperBlockName,
|
|
313
|
-
uniqueId: wrapperUniqueId
|
|
314
|
-
}, (0, _react.createElement)(_blockEditor.BlockList, {
|
|
315
|
-
className: isTemplateMode ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
|
|
79
|
+
}, (0, _react.createElement)(EditorCanvas, {
|
|
80
|
+
disableIframe: !isToBeIframed,
|
|
81
|
+
styles: styles
|
|
82
|
+
// We should auto-focus the canvas (title) on load.
|
|
83
|
+
// eslint-disable-next-line jsx-a11y/no-autofocus
|
|
316
84
|
,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
dropZoneElement:
|
|
320
|
-
// When iframed, pass in the html element of the iframe to
|
|
321
|
-
// ensure the drop zone extends to the edges of the iframe.
|
|
322
|
-
isToBeIframed ? ref.current?.parentNode : ref.current
|
|
323
|
-
}))))));
|
|
85
|
+
autoFocus: !isWelcomeGuideVisible
|
|
86
|
+
}));
|
|
324
87
|
}
|
|
325
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_classnames","_interopRequireDefault","require","_editor","_blockEditor","_element","_components","_data","_compose","_blocks","_coreData","_store","_lockUnlock","LayoutStyle","useLayoutClasses","useLayoutStyles","ExperimentalBlockCanvas","BlockCanvas","unlock","blockEditorPrivateApis","isGutenbergPlugin","process","env","IS_GUTENBERG_PLUGIN","getPostContentAttributes","blocks","i","length","name","attributes","innerBlocks","nestedPostContent","checkForPostContentAtRootLevel","VisualEditor","styles","deviceType","isWelcomeGuideVisible","isTemplateMode","postContentAttributes","editedPostTemplate","wrapperBlockName","wrapperUniqueId","isBlockBasedTheme","hasV3BlocksOnly","useSelect","select","isFeatureActive","isEditingTemplate","getEditedPostTemplate","__experimentalGetPreviewDeviceType","editPostStore","getCurrentPostId","getCurrentPostType","getEditorSettings","editorStore","getBlockTypes","blocksStore","_isTemplateMode","postTypeSlug","_wrapperBlockName","editorSettings","supportsTemplateMode","postType","coreStore","getPostType","canEditTemplate","canUser","viewable","undefined","__unstableIsBlockBasedTheme","every","type","apiVersion","isCleanNewPost","hasMetaBoxes","hasRootPaddingAwareAlignments","isFocusMode","themeHasDisabledLayoutStyles","themeSupportsLayout","_settings","blockEditorStore","getSettings","disableLayoutStyles","supportsLayout","focusMode","__experimentalFeatures","useRootPaddingAwareAlignments","desktopCanvasStyles","height","width","marginLeft","marginRight","display","flexFlow","background","templateModeStyles","borderRadius","border","borderBottom","resizedCanvasStyles","useResizeCanvas","globalLayoutSettings","useSettings","previewMode","toLowerCase","animatedStyles","paddingBottom","ref","useRef","contentRef","useMergeRefs","useTypewriter","fallbackLayout","useMemo","newestPostContentAttributes","content","parseableContent","parse","hasPostContentAtRootLevel","layout","align","postContentLayoutClasses","blockListLayoutClass","classnames","postContentLayoutStyles","postContentLayout","inherit","contentSize","wideSize","blockListLayout","postEditorLayout","observeTypingRef","useTypingObserver","titleRef","useEffect","current","focus","css","alignCSS","isToBeIframed","_react","createElement","BlockTools","__unstableContentRef","className","__unstableMotion","div","animate","padding","initial","shouldIframe","Fragment","selector","contentEditable","PostTitle","__experimentalRecursionProvider","blockName","uniqueId","BlockList","dropZoneElement","parentNode"],"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { PostTitle, store as editorStore } from '@wordpress/editor';\nimport {\n\tBlockList,\n\tBlockTools,\n\tstore as blockEditorStore,\n\t__unstableUseTypewriter as useTypewriter,\n\t__unstableUseTypingObserver as useTypingObserver,\n\t__experimentalUseResizeCanvas as useResizeCanvas,\n\tuseSettings,\n\t__experimentalRecursionProvider as RecursionProvider,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useMemo } from '@wordpress/element';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { useMergeRefs } from '@wordpress/compose';\nimport { parse, store as blocksStore } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst {\n\tLayoutStyle,\n\tuseLayoutClasses,\n\tuseLayoutStyles,\n\tExperimentalBlockCanvas: BlockCanvas,\n} = unlock( blockEditorPrivateApis );\n\nconst isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;\n\n/**\n * Given an array of nested blocks, find the first Post Content\n * block inside it, recursing through any nesting levels,\n * and return its attributes.\n *\n * @param {Array} blocks A list of blocks.\n *\n * @return {Object | undefined} The Post Content block.\n */\nfunction getPostContentAttributes( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn blocks[ i ].attributes;\n\t\t}\n\t\tif ( blocks[ i ].innerBlocks.length ) {\n\t\t\tconst nestedPostContent = getPostContentAttributes(\n\t\t\t\tblocks[ i ].innerBlocks\n\t\t\t);\n\n\t\t\tif ( nestedPostContent ) {\n\t\t\t\treturn nestedPostContent;\n\t\t\t}\n\t\t}\n\t}\n}\n\nfunction checkForPostContentAtRootLevel( blocks ) {\n\tfor ( let i = 0; i < blocks.length; i++ ) {\n\t\tif ( blocks[ i ].name === 'core/post-content' ) {\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tdeviceType,\n\t\tisWelcomeGuideVisible,\n\t\tisTemplateMode,\n\t\tpostContentAttributes,\n\t\teditedPostTemplate = {},\n\t\twrapperBlockName,\n\t\twrapperUniqueId,\n\t\tisBlockBasedTheme,\n\t\thasV3BlocksOnly,\n\t} = useSelect( ( select ) => {\n\t\tconst {\n\t\t\tisFeatureActive,\n\t\t\tisEditingTemplate,\n\t\t\tgetEditedPostTemplate,\n\t\t\t__experimentalGetPreviewDeviceType,\n\t\t} = select( editPostStore );\n\t\tconst { getCurrentPostId, getCurrentPostType, getEditorSettings } =\n\t\t\tselect( editorStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\tconst _isTemplateMode = isEditingTemplate();\n\t\tconst postTypeSlug = getCurrentPostType();\n\t\tlet _wrapperBlockName;\n\n\t\tif ( postTypeSlug === 'wp_block' ) {\n\t\t\t_wrapperBlockName = 'core/block';\n\t\t} else if ( ! _isTemplateMode ) {\n\t\t\t_wrapperBlockName = 'core/post-content';\n\t\t}\n\n\t\tconst editorSettings = getEditorSettings();\n\t\tconst supportsTemplateMode = editorSettings.supportsTemplateMode;\n\t\tconst postType = select( coreStore ).getPostType( postTypeSlug );\n\t\tconst canEditTemplate = select( coreStore ).canUser(\n\t\t\t'create',\n\t\t\t'templates'\n\t\t);\n\n\t\treturn {\n\t\t\tdeviceType: __experimentalGetPreviewDeviceType(),\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t\tpostContentAttributes: getEditorSettings().postContentAttributes,\n\t\t\t// Post template fetch returns a 404 on classic themes, which\n\t\t\t// messes with e2e tests, so check it's a block theme first.\n\t\t\teditedPostTemplate:\n\t\t\t\tpostType?.viewable && supportsTemplateMode && canEditTemplate\n\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t: undefined,\n\t\t\twrapperBlockName: _wrapperBlockName,\n\t\t\twrapperUniqueId: getCurrentPostId(),\n\t\t\tisBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,\n\t\t\thasV3BlocksOnly: getBlockTypes().every( ( type ) => {\n\t\t\t\treturn type.apiVersion >= 3;\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst { isCleanNewPost } = useSelect( editorStore );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\tconst {\n\t\thasRootPaddingAwareAlignments,\n\t\tisFocusMode,\n\t\tthemeHasDisabledLayoutStyles,\n\t\tthemeSupportsLayout,\n\t} = useSelect( ( select ) => {\n\t\tconst _settings = select( blockEditorStore ).getSettings();\n\t\treturn {\n\t\t\tthemeHasDisabledLayoutStyles: _settings.disableLayoutStyles,\n\t\t\tthemeSupportsLayout: _settings.supportsLayout,\n\t\t\tisFocusMode: _settings.focusMode,\n\t\t\thasRootPaddingAwareAlignments:\n\t\t\t\t_settings.__experimentalFeatures?.useRootPaddingAwareAlignments,\n\t\t};\n\t}, [] );\n\tconst desktopCanvasStyles = {\n\t\theight: '100%',\n\t\twidth: '100%',\n\t\tmarginLeft: 'auto',\n\t\tmarginRight: 'auto',\n\t\tdisplay: 'flex',\n\t\tflexFlow: 'column',\n\t\t// Default background color so that grey\n\t\t// .edit-post-editor-regions__content color doesn't show through.\n\t\tbackground: 'white',\n\t};\n\tconst templateModeStyles = {\n\t\t...desktopCanvasStyles,\n\t\tborderRadius: '2px 2px 0 0',\n\t\tborder: '1px solid #ddd',\n\t\tborderBottom: 0,\n\t};\n\tconst resizedCanvasStyles = useResizeCanvas( deviceType, isTemplateMode );\n\tconst [ globalLayoutSettings ] = useSettings( 'layout' );\n\tconst previewMode = 'is-' + deviceType.toLowerCase() + '-preview';\n\n\tlet animatedStyles = isTemplateMode\n\t\t? templateModeStyles\n\t\t: desktopCanvasStyles;\n\tif ( resizedCanvasStyles ) {\n\t\tanimatedStyles = resizedCanvasStyles;\n\t}\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && ! resizedCanvasStyles && ! isTemplateMode ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tconst ref = useRef();\n\tconst contentRef = useMergeRefs( [ ref, useTypewriter() ] );\n\n\t// fallbackLayout is used if there is no Post Content,\n\t// and for Post Title.\n\tconst fallbackLayout = useMemo( () => {\n\t\tif ( isTemplateMode ) {\n\t\t\treturn { type: 'default' };\n\t\t}\n\n\t\tif ( themeSupportsLayout ) {\n\t\t\t// We need to ensure support for wide and full alignments,\n\t\t\t// so we add the constrained type.\n\t\t\treturn { ...globalLayoutSettings, type: 'constrained' };\n\t\t}\n\t\t// Set default layout for classic themes so all alignments are supported.\n\t\treturn { type: 'default' };\n\t}, [ isTemplateMode, themeSupportsLayout, globalLayoutSettings ] );\n\n\tconst newestPostContentAttributes = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn postContentAttributes;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn getPostContentAttributes( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn getPostContentAttributes( parse( parseableContent ) ) || {};\n\t}, [\n\t\teditedPostTemplate?.content,\n\t\teditedPostTemplate?.blocks,\n\t\tpostContentAttributes,\n\t] );\n\n\tconst hasPostContentAtRootLevel = useMemo( () => {\n\t\tif ( ! editedPostTemplate?.content && ! editedPostTemplate?.blocks ) {\n\t\t\treturn false;\n\t\t}\n\t\t// When in template editing mode, we can access the blocks directly.\n\t\tif ( editedPostTemplate?.blocks ) {\n\t\t\treturn checkForPostContentAtRootLevel( editedPostTemplate?.blocks );\n\t\t}\n\t\t// If there are no blocks, we have to parse the content string.\n\t\t// Best double-check it's a string otherwise the parse function gets unhappy.\n\t\tconst parseableContent =\n\t\t\ttypeof editedPostTemplate?.content === 'string'\n\t\t\t\t? editedPostTemplate?.content\n\t\t\t\t: '';\n\n\t\treturn (\n\t\t\tcheckForPostContentAtRootLevel( parse( parseableContent ) ) || false\n\t\t);\n\t}, [ editedPostTemplate?.content, editedPostTemplate?.blocks ] );\n\n\tconst { layout = {}, align = '' } = newestPostContentAttributes || {};\n\n\tconst postContentLayoutClasses = useLayoutClasses(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content'\n\t);\n\n\tconst blockListLayoutClass = classnames(\n\t\t{\n\t\t\t'is-layout-flow': ! themeSupportsLayout,\n\t\t},\n\t\tthemeSupportsLayout && postContentLayoutClasses,\n\t\talign && `align${ align }`\n\t);\n\n\tconst postContentLayoutStyles = useLayoutStyles(\n\t\tnewestPostContentAttributes,\n\t\t'core/post-content',\n\t\t'.block-editor-block-list__layout.is-root-container'\n\t);\n\n\t// Update type for blocks using legacy layouts.\n\tconst postContentLayout = useMemo( () => {\n\t\treturn layout &&\n\t\t\t( layout?.type === 'constrained' ||\n\t\t\t\tlayout?.inherit ||\n\t\t\t\tlayout?.contentSize ||\n\t\t\t\tlayout?.wideSize )\n\t\t\t? { ...globalLayoutSettings, ...layout, type: 'constrained' }\n\t\t\t: { ...globalLayoutSettings, ...layout, type: 'default' };\n\t}, [\n\t\tlayout?.type,\n\t\tlayout?.inherit,\n\t\tlayout?.contentSize,\n\t\tlayout?.wideSize,\n\t\tglobalLayoutSettings,\n\t] );\n\n\t// If there is a Post Content block we use its layout for the block list;\n\t// if not, this must be a classic theme, in which case we use the fallback layout.\n\tconst blockListLayout = postContentAttributes\n\t\t? postContentLayout\n\t\t: fallbackLayout;\n\n\tconst postEditorLayout =\n\t\tblockListLayout?.type === 'default' && ! hasPostContentAtRootLevel\n\t\t\t? fallbackLayout\n\t\t\t: blockListLayout;\n\n\tconst observeTypingRef = useTypingObserver();\n\tconst titleRef = useRef();\n\tuseEffect( () => {\n\t\tif ( isWelcomeGuideVisible || ! isCleanNewPost() ) {\n\t\t\treturn;\n\t\t}\n\t\ttitleRef?.current?.focus();\n\t}, [ isWelcomeGuideVisible, isCleanNewPost ] );\n\n\tstyles = useMemo(\n\t\t() => [\n\t\t\t...styles,\n\t\t\t{\n\t\t\t\t// We should move this in to future to the body.\n\t\t\t\tcss:\n\t\t\t\t\t`.edit-post-visual-editor__post-title-wrapper{margin-top:4rem}` +\n\t\t\t\t\t( paddingBottom\n\t\t\t\t\t\t? `body{padding-bottom:${ paddingBottom }}`\n\t\t\t\t\t\t: '' ),\n\t\t\t},\n\t\t],\n\t\t[ styles ]\n\t);\n\n\t// Add some styles for alignwide/alignfull Post Content and its children.\n\tconst alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}\n\t\t.is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}\n\t\t.is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;\n\n\tconst isToBeIframed =\n\t\t( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&\n\t\t\t! hasMetaBoxes ) ||\n\t\tisTemplateMode ||\n\t\tdeviceType === 'Tablet' ||\n\t\tdeviceType === 'Mobile';\n\n\treturn (\n\t\t<BlockTools\n\t\t\t__unstableContentRef={ ref }\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': isTemplateMode,\n\t\t\t\t'has-inline-canvas': ! isToBeIframed,\n\t\t\t} ) }\n\t\t>\n\t\t\t<motion.div\n\t\t\t\tclassName=\"edit-post-visual-editor__content-area\"\n\t\t\t\tanimate={ {\n\t\t\t\t\tpadding: isTemplateMode ? '48px 48px 0' : 0,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<motion.div\n\t\t\t\t\tanimate={ animatedStyles }\n\t\t\t\t\tinitial={ desktopCanvasStyles }\n\t\t\t\t\tclassName={ previewMode }\n\t\t\t\t>\n\t\t\t\t\t<BlockCanvas\n\t\t\t\t\t\tshouldIframe={ isToBeIframed }\n\t\t\t\t\t\tcontentRef={ contentRef }\n\t\t\t\t\t\tstyles={ styles }\n\t\t\t\t\t\theight=\"100%\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ themeSupportsLayout &&\n\t\t\t\t\t\t\t! themeHasDisabledLayoutStyles &&\n\t\t\t\t\t\t\t! isTemplateMode && (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".edit-post-visual-editor__post-title-wrapper\"\n\t\t\t\t\t\t\t\t\t\tlayout={ fallbackLayout }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\tselector=\".block-editor-block-list__layout.is-root-container\"\n\t\t\t\t\t\t\t\t\t\tlayout={ postEditorLayout }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t{ align && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle css={ alignCSS } />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t{ postContentLayoutStyles && (\n\t\t\t\t\t\t\t\t\t\t<LayoutStyle\n\t\t\t\t\t\t\t\t\t\t\tlayout={ postContentLayout }\n\t\t\t\t\t\t\t\t\t\t\tcss={ postContentLayoutStyles }\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t{ ! isTemplateMode && (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t\t'edit-post-visual-editor__post-title-wrapper',\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t'is-focus-mode': isFocusMode,\n\t\t\t\t\t\t\t\t\t\t'has-global-padding':\n\t\t\t\t\t\t\t\t\t\t\thasRootPaddingAwareAlignments,\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tcontentEditable={ false }\n\t\t\t\t\t\t\t\tref={ observeTypingRef }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<PostTitle ref={ titleRef } />\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<RecursionProvider\n\t\t\t\t\t\t\tblockName={ wrapperBlockName }\n\t\t\t\t\t\t\tuniqueId={ wrapperUniqueId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<BlockList\n\t\t\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\t\t\tisTemplateMode\n\t\t\t\t\t\t\t\t\t\t? 'wp-site-blocks'\n\t\t\t\t\t\t\t\t\t\t: `${ blockListLayoutClass } wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tlayout={ blockListLayout }\n\t\t\t\t\t\t\t\tdropZoneElement={\n\t\t\t\t\t\t\t\t\t// When iframed, pass in the html element of the iframe to\n\t\t\t\t\t\t\t\t\t// ensure the drop zone extends to the edges of the iframe.\n\t\t\t\t\t\t\t\t\tisToBeIframed\n\t\t\t\t\t\t\t\t\t\t? ref.current?.parentNode\n\t\t\t\t\t\t\t\t\t\t: ref.current\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</RecursionProvider>\n\t\t\t\t\t</BlockCanvas>\n\t\t\t\t</motion.div>\n\t\t\t</motion.div>\n\t\t</BlockTools>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAWA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,SAAA,GAAAR,OAAA;AAKA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,WAAA,GAAAV,OAAA;AA/BA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;;AAIA,MAAM;EACLW,WAAW;EACXC,gBAAgB;EAChBC,eAAe;EACfC,uBAAuB,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;IACvDjC,MAAM,EAAGP;EAAgB,CACzB,CAAC,EACF,IAAA4B,MAAA,CAAAC,aAAA,EAAChI,WAAW;IACX2I,QAAQ,EAAC,oDAAoD;IAC7DjC,MAAM,EAAGW;EAAkB,CAC3B,CAAC,EACAV,KAAK,IACN,IAAAoB,MAAA,CAAAC,aAAA,EAAChI,WAAW;IAAC4H,GAAG,EAAGC;EAAU,CAAE,CAC/B,EACCd,uBAAuB,IACxB,IAAAgB,MAAA,CAAAC,aAAA,EAAChI,WAAW;IACX0G,MAAM,EAAGM,iBAAmB;IAC5BY,GAAG,EAAGb;EAAyB,CAC/B,CAED,CACF,EACA,CAAEvF,cAAc,IACjB,IAAAuG,MAAA,CAAAC,aAAA;IACCG,SAAS,EAAG,IAAArB,mBAAU,EACrB,6CAA6C,EAC7C;MACC,eAAe,EAAE/C,WAAW;MAC5B,oBAAoB,EACnBD;IACF,CACD,CAAG;IACH8E,eAAe,EAAG,KAAO;IACzB9C,GAAG,EAAGwB;EAAkB,GAExB,IAAAS,MAAA,CAAAC,aAAA,EAAC1I,OAAA,CAAAuJ,SAAS;IAAC/C,GAAG,EAAG0B;EAAU,CAAE,CACzB,CACL,EACD,IAAAO,MAAA,CAAAC,aAAA,EAACzI,YAAA,CAAAuJ,+BAAiB;IACjBC,SAAS,EAAGpH,gBAAkB;IAC9BqH,QAAQ,EAAGpH;EAAiB,GAE5B,IAAAmG,MAAA,CAAAC,aAAA,EAACzI,YAAA,CAAA0J,SAAS;IACTd,SAAS,EACR3G,cAAc,GACX,gBAAgB,GACf,GAAGqF,oBAAsB,wBAAuB,CAAC;IACrD;;IACDH,MAAM,EAAGU,eAAiB;IAC1B8B,eAAe;IACd;IACA;IACApB,aAAa,GACVhC,GAAG,CAAC4B,OAAO,EAAEyB,UAAU,GACvBrD,GAAG,CAAC4B;EACP,CACD,CACiB,CACP,CACF,CACD,CACD,CAAC;AAEf"}
|
|
1
|
+
{"version":3,"names":["_classnames","_interopRequireDefault","require","_editor","_element","_data","_blocks","_store","_lockUnlock","EditorCanvas","unlock","editorPrivateApis","isGutenbergPlugin","process","env","IS_GUTENBERG_PLUGIN","VisualEditor","styles","isWelcomeGuideVisible","renderingMode","isBlockBasedTheme","hasV3BlocksOnly","useSelect","select","isFeatureActive","editPostStore","getEditorSettings","getRenderingMode","editorStore","getBlockTypes","blocksStore","editorSettings","__unstableIsBlockBasedTheme","every","type","apiVersion","hasMetaBoxes","paddingBottom","useMemo","css","isToBeIframed","_react","createElement","className","classnames","disableIframe","autoFocus"],"sources":["@wordpress/edit-post/src/components/visual-editor/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editPostStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { EditorCanvas } = unlock( editorPrivateApis );\n\nconst isGutenbergPlugin = process.env.IS_GUTENBERG_PLUGIN ? true : false;\n\nexport default function VisualEditor( { styles } ) {\n\tconst {\n\t\tisWelcomeGuideVisible,\n\t\trenderingMode,\n\t\tisBlockBasedTheme,\n\t\thasV3BlocksOnly,\n\t} = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getEditorSettings, getRenderingMode } = select( editorStore );\n\t\tconst { getBlockTypes } = select( blocksStore );\n\t\tconst editorSettings = getEditorSettings();\n\n\t\treturn {\n\t\t\tisWelcomeGuideVisible: isFeatureActive( 'welcomeGuide' ),\n\t\t\trenderingMode: getRenderingMode(),\n\t\t\tisBlockBasedTheme: editorSettings.__unstableIsBlockBasedTheme,\n\t\t\thasV3BlocksOnly: getBlockTypes().every( ( type ) => {\n\t\t\t\treturn type.apiVersion >= 3;\n\t\t\t} ),\n\t\t};\n\t}, [] );\n\tconst hasMetaBoxes = useSelect(\n\t\t( select ) => select( editPostStore ).hasMetaBoxes(),\n\t\t[]\n\t);\n\n\tlet paddingBottom;\n\n\t// Add a constant padding for the typewritter effect. When typing at the\n\t// bottom, there needs to be room to scroll up.\n\tif ( ! hasMetaBoxes && renderingMode === 'post-only' ) {\n\t\tpaddingBottom = '40vh';\n\t}\n\n\tstyles = useMemo(\n\t\t() => [\n\t\t\t...styles,\n\t\t\t{\n\t\t\t\t// We should move this in to future to the body.\n\t\t\t\tcss: paddingBottom\n\t\t\t\t\t? `body{padding-bottom:${ paddingBottom }}`\n\t\t\t\t\t: '',\n\t\t\t},\n\t\t],\n\t\t[ styles, paddingBottom ]\n\t);\n\n\tconst isToBeIframed =\n\t\t( ( hasV3BlocksOnly || ( isGutenbergPlugin && isBlockBasedTheme ) ) &&\n\t\t\t! hasMetaBoxes ) ||\n\t\trenderingMode === 'template-only';\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ classnames( 'edit-post-visual-editor', {\n\t\t\t\t'is-template-mode': renderingMode === 'template-only',\n\t\t\t\t'has-inline-canvas': ! isToBeIframed,\n\t\t\t} ) }\n\t\t>\n\t\t\t<EditorCanvas\n\t\t\t\tdisableIframe={ ! isToBeIframed }\n\t\t\t\tstyles={ styles }\n\t\t\t\t// We should auto-focus the canvas (title) on load.\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus={ ! isWelcomeGuideVisible }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,WAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AAIA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AApBA;AACA;AACA;;AAGA;AACA;AACA;;A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sB,GAAG,EAAEF,aAAa,GACd,uBAAuBA,aAAe,GAAE,GACzC;EACJ,CAAC,CACD,EACD,CAAEpB,MAAM,EAAEoB,aAAa,CACxB,CAAC;EAED,MAAMG,aAAa,GAChB,CAAEnB,eAAe,IAAMT,iBAAiB,IAAIQ,iBAAmB,KAChE,CAAEgB,YAAY,IACfjB,aAAa,KAAK,eAAe;EAElC,OACC,IAAAsB,MAAA,CAAAC,aAAA;IACCC,SAAS,EAAG,IAAAC,mBAAU,EAAE,yBAAyB,EAAE;MAClD,kBAAkB,EAAEzB,aAAa,KAAK,eAAe;MACrD,mBAAmB,EAAE,CAAEqB;IACxB,CAAE;EAAG,GAEL,IAAAC,MAAA,CAAAC,aAAA,EAACjC,YAAY;IACZoC,aAAa,EAAG,CAAEL,aAAe;IACjCvB,MAAM,EAAGA;IACT;IACA;IAAA;IACA6B,SAAS,EAAG,CAAE5B;EAAuB,CACrC,CACG,CAAC;AAER"}
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = WelcomeGuide;
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
|
+
var _editor = require("@wordpress/editor");
|
|
10
11
|
var _default = _interopRequireDefault(require("./default"));
|
|
11
12
|
var _template = _interopRequireDefault(require("./template"));
|
|
12
13
|
var _store = require("../../store");
|
|
@@ -24,10 +25,12 @@ function WelcomeGuide() {
|
|
|
24
25
|
isTemplateMode
|
|
25
26
|
} = (0, _data.useSelect)(select => {
|
|
26
27
|
const {
|
|
27
|
-
isFeatureActive
|
|
28
|
-
isEditingTemplate
|
|
28
|
+
isFeatureActive
|
|
29
29
|
} = select(_store.store);
|
|
30
|
-
const
|
|
30
|
+
const {
|
|
31
|
+
getRenderingMode
|
|
32
|
+
} = select(_editor.store);
|
|
33
|
+
const _isTemplateMode = getRenderingMode() === 'template-only';
|
|
31
34
|
const feature = _isTemplateMode ? 'welcomeGuideTemplate' : 'welcomeGuide';
|
|
32
35
|
return {
|
|
33
36
|
isActive: isFeatureActive(feature),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_default","_interopRequireDefault","_template","_store","WelcomeGuide","isActive","isTemplateMode","useSelect","select","isFeatureActive","
|
|
1
|
+
{"version":3,"names":["_data","require","_editor","_default","_interopRequireDefault","_template","_store","WelcomeGuide","isActive","isTemplateMode","useSelect","select","isFeatureActive","editPostStore","getRenderingMode","editorStore","_isTemplateMode","feature","_react","createElement","default"],"sources":["@wordpress/edit-post/src/components/welcome-guide/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { store as editorStore } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport WelcomeGuideDefault from './default';\nimport WelcomeGuideTemplate from './template';\nimport { store as editPostStore } from '../../store';\n\nexport default function WelcomeGuide() {\n\tconst { isActive, isTemplateMode } = useSelect( ( select ) => {\n\t\tconst { isFeatureActive } = select( editPostStore );\n\t\tconst { getRenderingMode } = select( editorStore );\n\t\tconst _isTemplateMode = getRenderingMode() === 'template-only';\n\t\tconst feature = _isTemplateMode\n\t\t\t? 'welcomeGuideTemplate'\n\t\t\t: 'welcomeGuide';\n\n\t\treturn {\n\t\t\tisActive: isFeatureActive( feature ),\n\t\t\tisTemplateMode: _isTemplateMode,\n\t\t};\n\t}, [] );\n\n\tif ( ! isActive ) {\n\t\treturn null;\n\t}\n\n\treturn isTemplateMode ? <WelcomeGuideTemplate /> : <WelcomeGuideDefault />;\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,QAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAXA;AACA;AACA;;AAIA;AACA;AACA;;AAKe,SAASM,YAAYA,CAAA,EAAG;EACtC,MAAM;IAAEC,QAAQ;IAAEC;EAAe,CAAC,GAAG,IAAAC,eAAS,EAAIC,MAAM,IAAM;IAC7D,MAAM;MAAEC;IAAgB,CAAC,GAAGD,MAAM,CAAEE,YAAc,CAAC;IACnD,MAAM;MAAEC;IAAiB,CAAC,GAAGH,MAAM,CAAEI,aAAY,CAAC;IAClD,MAAMC,eAAe,GAAGF,gBAAgB,CAAC,CAAC,KAAK,eAAe;IAC9D,MAAMG,OAAO,GAAGD,eAAe,GAC5B,sBAAsB,GACtB,cAAc;IAEjB,OAAO;MACNR,QAAQ,EAAEI,eAAe,CAAEK,OAAQ,CAAC;MACpCR,cAAc,EAAEO;IACjB,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,IAAK,CAAER,QAAQ,EAAG;IACjB,OAAO,IAAI;EACZ;EAEA,OAAOC,cAAc,GAAG,IAAAS,MAAA,CAAAC,aAAA,EAACd,SAAA,CAAAe,OAAoB,MAAE,CAAC,GAAG,IAAAF,MAAA,CAAAC,aAAA,EAAChB,QAAA,CAAAiB,OAAmB,MAAE,CAAC;AAC3E"}
|
package/build/editor.js
CHANGED
|
@@ -18,6 +18,7 @@ var _layout = _interopRequireDefault(require("./components/layout"));
|
|
|
18
18
|
var _editorInitialization = _interopRequireDefault(require("./components/editor-initialization"));
|
|
19
19
|
var _store = require("./store");
|
|
20
20
|
var _lockUnlock = require("./lock-unlock");
|
|
21
|
+
var _usePostHistory = _interopRequireDefault(require("./hooks/use-post-history"));
|
|
21
22
|
/**
|
|
22
23
|
* WordPress dependencies
|
|
23
24
|
*/
|
|
@@ -30,29 +31,28 @@ const {
|
|
|
30
31
|
ExperimentalEditorProvider
|
|
31
32
|
} = (0, _lockUnlock.unlock)(_editor.privateApis);
|
|
32
33
|
function Editor({
|
|
33
|
-
postId,
|
|
34
|
-
postType,
|
|
34
|
+
postId: initialPostId,
|
|
35
|
+
postType: initialPostType,
|
|
35
36
|
settings,
|
|
36
37
|
initialEdits,
|
|
37
38
|
...props
|
|
38
39
|
}) {
|
|
39
40
|
const {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
currentPost,
|
|
42
|
+
getPostLinkProps,
|
|
43
|
+
goBack
|
|
44
|
+
} = (0, _usePostHistory.default)(initialPostId, initialPostType);
|
|
45
|
+
const {
|
|
43
46
|
hasInlineToolbar,
|
|
44
47
|
post,
|
|
45
48
|
preferredStyleVariations,
|
|
46
49
|
hiddenBlockTypes,
|
|
47
50
|
blockTypes,
|
|
48
|
-
keepCaretInsideBlock,
|
|
49
|
-
isTemplateMode,
|
|
50
51
|
template
|
|
51
52
|
} = (0, _data.useSelect)(select => {
|
|
52
53
|
var _getPostType$viewable;
|
|
53
54
|
const {
|
|
54
55
|
isFeatureActive,
|
|
55
|
-
isEditingTemplate,
|
|
56
56
|
getEditedPostTemplate,
|
|
57
57
|
getHiddenBlockTypes
|
|
58
58
|
} = select(_store.store);
|
|
@@ -68,53 +68,43 @@ function Editor({
|
|
|
68
68
|
const {
|
|
69
69
|
getBlockTypes
|
|
70
70
|
} = select(_blocks.store);
|
|
71
|
-
const isTemplate = ['wp_template', 'wp_template_part'].includes(postType);
|
|
71
|
+
const isTemplate = ['wp_template', 'wp_template_part'].includes(currentPost.postType);
|
|
72
72
|
// Ideally the initializeEditor function should be called using the ID of the REST endpoint.
|
|
73
73
|
// to avoid the special case.
|
|
74
74
|
let postObject;
|
|
75
75
|
if (isTemplate) {
|
|
76
|
-
const posts = getEntityRecords('postType', postType, {
|
|
77
|
-
wp_id: postId
|
|
76
|
+
const posts = getEntityRecords('postType', currentPost.postType, {
|
|
77
|
+
wp_id: currentPost.postId
|
|
78
78
|
});
|
|
79
79
|
postObject = posts?.[0];
|
|
80
80
|
} else {
|
|
81
|
-
postObject = getEntityRecord('postType', postType, postId);
|
|
81
|
+
postObject = getEntityRecord('postType', currentPost.postType, currentPost.postId);
|
|
82
82
|
}
|
|
83
83
|
const supportsTemplateMode = getEditorSettings().supportsTemplateMode;
|
|
84
|
-
const isViewable = (_getPostType$viewable = getPostType(postType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
|
|
84
|
+
const isViewable = (_getPostType$viewable = getPostType(currentPost.postType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false;
|
|
85
85
|
const canEditTemplate = canUser('create', 'templates');
|
|
86
86
|
return {
|
|
87
|
-
hasFixedToolbar: isFeatureActive('fixedToolbar'),
|
|
88
|
-
focusMode: isFeatureActive('focusMode'),
|
|
89
|
-
isDistractionFree: isFeatureActive('distractionFree'),
|
|
90
87
|
hasInlineToolbar: isFeatureActive('inlineToolbar'),
|
|
91
88
|
preferredStyleVariations: select(_preferences.store).get('core/edit-post', 'preferredStyleVariations'),
|
|
92
89
|
hiddenBlockTypes: getHiddenBlockTypes(),
|
|
93
90
|
blockTypes: getBlockTypes(),
|
|
94
|
-
keepCaretInsideBlock: isFeatureActive('keepCaretInsideBlock'),
|
|
95
|
-
isTemplateMode: isEditingTemplate(),
|
|
96
91
|
template: supportsTemplateMode && isViewable && canEditTemplate ? getEditedPostTemplate() : null,
|
|
97
92
|
post: postObject
|
|
98
93
|
};
|
|
99
|
-
}, [postType, postId]);
|
|
94
|
+
}, [currentPost.postType, currentPost.postId]);
|
|
100
95
|
const {
|
|
101
|
-
updatePreferredStyleVariations
|
|
102
|
-
setIsInserterOpened
|
|
96
|
+
updatePreferredStyleVariations
|
|
103
97
|
} = (0, _data.useDispatch)(_store.store);
|
|
104
98
|
const editorSettings = (0, _element.useMemo)(() => {
|
|
105
99
|
const result = {
|
|
106
100
|
...settings,
|
|
101
|
+
getPostLinkProps,
|
|
102
|
+
goBack,
|
|
107
103
|
__experimentalPreferredStyleVariations: {
|
|
108
104
|
value: preferredStyleVariations,
|
|
109
105
|
onChange: updatePreferredStyleVariations
|
|
110
106
|
},
|
|
111
|
-
hasFixedToolbar,
|
|
112
|
-
focusMode,
|
|
113
|
-
isDistractionFree,
|
|
114
107
|
hasInlineToolbar,
|
|
115
|
-
// This is marked as experimental to give time for the quick inserter to mature.
|
|
116
|
-
__experimentalSetIsInserterOpened: setIsInserterOpened,
|
|
117
|
-
keepCaretInsideBlock,
|
|
118
108
|
// Keep a reference of the `allowedBlockTypes` from the server to handle use cases
|
|
119
109
|
// where we need to differentiate if a block is disabled by the user or some plugin.
|
|
120
110
|
defaultAllowedBlockTypes: settings.allowedBlockTypes
|
|
@@ -131,7 +121,7 @@ function Editor({
|
|
|
131
121
|
result.allowedBlockTypes = defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
|
|
132
122
|
}
|
|
133
123
|
return result;
|
|
134
|
-
}, [settings,
|
|
124
|
+
}, [settings, hasInlineToolbar, hiddenBlockTypes, blockTypes, preferredStyleVariations, updatePreferredStyleVariations, getPostLinkProps, goBack]);
|
|
135
125
|
if (!post) {
|
|
136
126
|
return null;
|
|
137
127
|
}
|
|
@@ -140,10 +130,10 @@ function Editor({
|
|
|
140
130
|
post: post,
|
|
141
131
|
initialEdits: initialEdits,
|
|
142
132
|
useSubRegistry: false,
|
|
143
|
-
__unstableTemplate:
|
|
133
|
+
__unstableTemplate: template,
|
|
144
134
|
...props
|
|
145
135
|
}, (0, _react.createElement)(_editor.ErrorBoundary, null, (0, _react.createElement)(_commands.CommandMenu, null), (0, _react.createElement)(_editorInitialization.default, {
|
|
146
|
-
postId: postId
|
|
136
|
+
postId: currentPost.postId
|
|
147
137
|
}), (0, _react.createElement)(_layout.default, null)), (0, _react.createElement)(_editor.PostLockedModal, null)));
|
|
148
138
|
}
|
|
149
139
|
var _default = Editor;
|
package/build/editor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_data","_editor","_element","_components","_coreData","_preferences","_commands","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","ExperimentalEditorProvider","unlock","editorPrivateApis","Editor","postId","postType","settings","initialEdits","props","hasFixedToolbar","focusMode","isDistractionFree","hasInlineToolbar","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","keepCaretInsideBlock","isTemplateMode","template","useSelect","select","_getPostType$viewable","isFeatureActive","isEditingTemplate","getEditedPostTemplate","getHiddenBlockTypes","editPostStore","getEntityRecord","getPostType","getEntityRecords","canUser","coreStore","getEditorSettings","editorStore","getBlockTypes","blocksStore","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","canEditTemplate","preferencesStore","get","updatePreferredStyleVariations","setIsInserterOpened","useDispatch","editorSettings","useMemo","result","__experimentalPreferredStyleVariations","value","onChange","__experimentalSetIsInserterOpened","defaultAllowedBlockTypes","allowedBlockTypes","length","map","name","filter","type","_react","createElement","SlotFillProvider","useSubRegistry","__unstableTemplate","undefined","ErrorBoundary","CommandMenu","default","PostLockedModal","_default","exports"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( { postId, postType, settings, initialEdits, ...props } ) {\n\tconst {\n\t\thasFixedToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thasInlineToolbar,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tkeepCaretInsideBlock,\n\t\tisTemplateMode,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\tisEditingTemplate,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords, canUser } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tpostType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords( 'postType', postType, {\n\t\t\t\t\twp_id: postId,\n\t\t\t\t} );\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord( 'postType', postType, postId );\n\t\t\t}\n\t\t\tconst supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable = getPostType( postType )?.viewable ?? false;\n\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\n\t\t\treturn {\n\t\t\t\thasFixedToolbar: isFeatureActive( 'fixedToolbar' ),\n\t\t\t\tfocusMode: isFeatureActive( 'focusMode' ),\n\t\t\t\tisDistractionFree: isFeatureActive( 'distractionFree' ),\n\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\tkeepCaretInsideBlock: isFeatureActive( 'keepCaretInsideBlock' ),\n\t\t\t\tisTemplateMode: isEditingTemplate(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable && canEditTemplate\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations, setIsInserterOpened } =\n\t\tuseDispatch( editPostStore );\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasFixedToolbar,\n\t\t\tfocusMode,\n\t\t\tisDistractionFree,\n\t\t\thasInlineToolbar,\n\n\t\t\t// This is marked as experimental to give time for the quick inserter to mature.\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t\tkeepCaretInsideBlock,\n\t\t\t// Keep a reference of the `allowedBlockTypes` from the server to handle use cases\n\t\t\t// where we need to differentiate if a block is disabled by the user or some plugin.\n\t\t\tdefaultAllowedBlockTypes: settings.allowedBlockTypes,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasFixedToolbar,\n\t\thasInlineToolbar,\n\t\tfocusMode,\n\t\tisDistractionFree,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tsetIsInserterOpened,\n\t\tupdatePreferredStyleVariations,\n\t\tkeepCaretInsideBlock,\n\t] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ isTemplateMode ? template : undefined }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ postId } />\n\t\t\t\t\t<Layout />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,OAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AAvBA;AACA;AACA;;AAeA;AACA;AACA;;AAMA,MAAM;EAAEa;AAA2B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAElE,SAASC,MAAMA,CAAE;EAAEC,MAAM;EAAEC,QAAQ;EAAEC,QAAQ;EAAEC,YAAY;EAAE,GAAGC;AAAM,C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,CAAC;AAErB;AAAC,IAAAC,QAAA,GAEcxE,MAAM;AAAAyE,OAAA,CAAAH,OAAA,GAAAE,QAAA"}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_editor","_element","_components","_coreData","_preferences","_commands","_layout","_interopRequireDefault","_editorInitialization","_store","_lockUnlock","_usePostHistory","ExperimentalEditorProvider","unlock","editorPrivateApis","Editor","postId","initialPostId","postType","initialPostType","settings","initialEdits","props","currentPost","getPostLinkProps","goBack","usePostHistory","hasInlineToolbar","post","preferredStyleVariations","hiddenBlockTypes","blockTypes","template","useSelect","select","_getPostType$viewable","isFeatureActive","getEditedPostTemplate","getHiddenBlockTypes","editPostStore","getEntityRecord","getPostType","getEntityRecords","canUser","coreStore","getEditorSettings","editorStore","getBlockTypes","blocksStore","isTemplate","includes","postObject","posts","wp_id","supportsTemplateMode","isViewable","viewable","canEditTemplate","preferencesStore","get","updatePreferredStyleVariations","useDispatch","editorSettings","useMemo","result","__experimentalPreferredStyleVariations","value","onChange","defaultAllowedBlockTypes","allowedBlockTypes","length","map","name","filter","type","_react","createElement","SlotFillProvider","useSubRegistry","__unstableTemplate","ErrorBoundary","CommandMenu","default","PostLockedModal","_default","exports"],"sources":["@wordpress/edit-post/src/editor.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tErrorBoundary,\n\tPostLockedModal,\n\tstore as editorStore,\n\tprivateApis as editorPrivateApis,\n} from '@wordpress/editor';\nimport { useMemo } from '@wordpress/element';\nimport { SlotFillProvider } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { CommandMenu } from '@wordpress/commands';\n\n/**\n * Internal dependencies\n */\nimport Layout from './components/layout';\nimport EditorInitialization from './components/editor-initialization';\nimport { store as editPostStore } from './store';\nimport { unlock } from './lock-unlock';\nimport usePostHistory from './hooks/use-post-history';\n\nconst { ExperimentalEditorProvider } = unlock( editorPrivateApis );\n\nfunction Editor( {\n\tpostId: initialPostId,\n\tpostType: initialPostType,\n\tsettings,\n\tinitialEdits,\n\t...props\n} ) {\n\tconst { currentPost, getPostLinkProps, goBack } = usePostHistory(\n\t\tinitialPostId,\n\t\tinitialPostType\n\t);\n\n\tconst {\n\t\thasInlineToolbar,\n\t\tpost,\n\t\tpreferredStyleVariations,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\ttemplate,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tisFeatureActive,\n\t\t\t\tgetEditedPostTemplate,\n\t\t\t\tgetHiddenBlockTypes,\n\t\t\t} = select( editPostStore );\n\t\t\tconst { getEntityRecord, getPostType, getEntityRecords, canUser } =\n\t\t\t\tselect( coreStore );\n\t\t\tconst { getEditorSettings } = select( editorStore );\n\t\t\tconst { getBlockTypes } = select( blocksStore );\n\t\t\tconst isTemplate = [ 'wp_template', 'wp_template_part' ].includes(\n\t\t\t\tcurrentPost.postType\n\t\t\t);\n\t\t\t// Ideally the initializeEditor function should be called using the ID of the REST endpoint.\n\t\t\t// to avoid the special case.\n\t\t\tlet postObject;\n\t\t\tif ( isTemplate ) {\n\t\t\t\tconst posts = getEntityRecords(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\t{\n\t\t\t\t\t\twp_id: currentPost.postId,\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\tpostObject = posts?.[ 0 ];\n\t\t\t} else {\n\t\t\t\tpostObject = getEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tcurrentPost.postType,\n\t\t\t\t\tcurrentPost.postId\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst supportsTemplateMode =\n\t\t\t\tgetEditorSettings().supportsTemplateMode;\n\t\t\tconst isViewable =\n\t\t\t\tgetPostType( currentPost.postType )?.viewable ?? false;\n\t\t\tconst canEditTemplate = canUser( 'create', 'templates' );\n\t\t\treturn {\n\t\t\t\thasInlineToolbar: isFeatureActive( 'inlineToolbar' ),\n\t\t\t\tpreferredStyleVariations: select( preferencesStore ).get(\n\t\t\t\t\t'core/edit-post',\n\t\t\t\t\t'preferredStyleVariations'\n\t\t\t\t),\n\t\t\t\thiddenBlockTypes: getHiddenBlockTypes(),\n\t\t\t\tblockTypes: getBlockTypes(),\n\t\t\t\ttemplate:\n\t\t\t\t\tsupportsTemplateMode && isViewable && canEditTemplate\n\t\t\t\t\t\t? getEditedPostTemplate()\n\t\t\t\t\t\t: null,\n\t\t\t\tpost: postObject,\n\t\t\t};\n\t\t},\n\t\t[ currentPost.postType, currentPost.postId ]\n\t);\n\n\tconst { updatePreferredStyleVariations } = useDispatch( editPostStore );\n\n\tconst editorSettings = useMemo( () => {\n\t\tconst result = {\n\t\t\t...settings,\n\t\t\tgetPostLinkProps,\n\t\t\tgoBack,\n\t\t\t__experimentalPreferredStyleVariations: {\n\t\t\t\tvalue: preferredStyleVariations,\n\t\t\t\tonChange: updatePreferredStyleVariations,\n\t\t\t},\n\t\t\thasInlineToolbar,\n\n\t\t\t// Keep a reference of the `allowedBlockTypes` from the server to handle use cases\n\t\t\t// where we need to differentiate if a block is disabled by the user or some plugin.\n\t\t\tdefaultAllowedBlockTypes: settings.allowedBlockTypes,\n\t\t};\n\n\t\t// Omit hidden block types if exists and non-empty.\n\t\tif ( hiddenBlockTypes.length > 0 ) {\n\t\t\t// Defer to passed setting for `allowedBlockTypes` if provided as\n\t\t\t// anything other than `true` (where `true` is equivalent to allow\n\t\t\t// all block types).\n\t\t\tconst defaultAllowedBlockTypes =\n\t\t\t\ttrue === settings.allowedBlockTypes\n\t\t\t\t\t? blockTypes.map( ( { name } ) => name )\n\t\t\t\t\t: settings.allowedBlockTypes || [];\n\n\t\t\tresult.allowedBlockTypes = defaultAllowedBlockTypes.filter(\n\t\t\t\t( type ) => ! hiddenBlockTypes.includes( type )\n\t\t\t);\n\t\t}\n\n\t\treturn result;\n\t}, [\n\t\tsettings,\n\t\thasInlineToolbar,\n\t\thiddenBlockTypes,\n\t\tblockTypes,\n\t\tpreferredStyleVariations,\n\t\tupdatePreferredStyleVariations,\n\t\tgetPostLinkProps,\n\t\tgoBack,\n\t] );\n\n\tif ( ! post ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<SlotFillProvider>\n\t\t\t<ExperimentalEditorProvider\n\t\t\t\tsettings={ editorSettings }\n\t\t\t\tpost={ post }\n\t\t\t\tinitialEdits={ initialEdits }\n\t\t\t\tuseSubRegistry={ false }\n\t\t\t\t__unstableTemplate={ template }\n\t\t\t\t{ ...props }\n\t\t\t>\n\t\t\t\t<ErrorBoundary>\n\t\t\t\t\t<CommandMenu />\n\t\t\t\t\t<EditorInitialization postId={ currentPost.postId } />\n\t\t\t\t\t<Layout />\n\t\t\t\t</ErrorBoundary>\n\t\t\t\t<PostLockedModal />\n\t\t\t</ExperimentalEditorProvider>\n\t\t</SlotFillProvider>\n\t);\n}\n\nexport default Editor;\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,WAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAKA,IAAAQ,OAAA,GAAAC,sBAAA,CAAAT,OAAA;AACA,IAAAU,qBAAA,GAAAD,sBAAA,CAAAT,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,eAAA,GAAAJ,sBAAA,CAAAT,OAAA;AAxBA;AACA;AACA;;AAeA;AACA;AACA;;AAOA,MAAM;EAAEc;AAA2B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;AAElE,SAASC,MAAMA,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