@wordpress/editor 13.24.1 → 13.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/document-bar/index.js +164 -0
- package/build/components/document-bar/index.js.map +1 -0
- package/build/components/document-outline/index.js +82 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/document-tools/index.js +160 -0
- package/build/components/document-tools/index.js.map +1 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js +106 -0
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build/components/editor-canvas/index.js +298 -0
- package/build/components/editor-canvas/index.js.map +1 -0
- package/build/components/entities-saved-states/index.js +3 -1
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/index.js +12 -2
- package/build/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build/components/index.js +72 -8
- package/build/components/index.js.map +1 -1
- package/build/components/index.native.js +9 -1
- package/build/components/index.native.js.map +1 -1
- package/build/components/inserter-sidebar/index.js +77 -0
- package/build/components/inserter-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/index.js +150 -0
- package/build/components/list-view-sidebar/index.js.map +1 -0
- package/build/components/list-view-sidebar/list-view-outline.js +28 -0
- package/build/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build/components/offline-status/index.native.js +85 -0
- package/build/components/offline-status/index.native.js.map +1 -0
- package/build/components/page-attributes/panel.js +63 -0
- package/build/components/page-attributes/panel.js.map +1 -0
- package/build/components/post-discussion/panel.js +59 -0
- package/build/components/post-discussion/panel.js.map +1 -0
- package/build/components/post-excerpt/check.js +19 -0
- package/build/components/post-excerpt/check.js.map +1 -1
- package/build/components/post-excerpt/panel.js +55 -0
- package/build/components/post-excerpt/panel.js.map +1 -0
- package/build/components/post-excerpt/plugin.js +72 -0
- package/build/components/post-excerpt/plugin.js.map +1 -0
- package/build/components/post-featured-image/index.js +5 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +60 -0
- package/build/components/post-featured-image/panel.js.map +1 -0
- package/build/components/post-last-revision/panel.js +27 -0
- package/build/components/post-last-revision/panel.js.map +1 -0
- package/build/components/post-publish-button/index.js +1 -0
- package/build/components/post-publish-button/index.js.map +1 -1
- package/build/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build/components/post-saved-state/index.js +13 -8
- package/build/components/post-saved-state/index.js.map +1 -1
- package/build/components/post-schedule/panel.js +1 -1
- package/build/components/post-schedule/panel.js.map +1 -1
- package/build/components/post-taxonomies/panel.js +68 -0
- package/build/components/post-taxonomies/panel.js.map +1 -0
- package/build/components/post-template/block-theme.js +100 -0
- package/build/components/post-template/block-theme.js.map +1 -0
- package/build/components/post-template/classic-theme.js +171 -0
- package/build/components/post-template/classic-theme.js.map +1 -0
- package/build/components/post-template/create-new-template-modal.js +98 -0
- package/build/components/post-template/create-new-template-modal.js.map +1 -0
- package/build/components/post-template/create-new-template.js +55 -0
- package/build/components/post-template/create-new-template.js.map +1 -0
- package/build/components/post-template/hooks.js +88 -0
- package/build/components/post-template/hooks.js.map +1 -0
- package/build/components/post-template/panel.js +70 -0
- package/build/components/post-template/panel.js.map +1 -0
- package/build/components/post-template/reset-default-template.js +48 -0
- package/build/components/post-template/reset-default-template.js.map +1 -0
- package/build/components/post-template/swap-template-button.js +86 -0
- package/build/components/post-template/swap-template-button.js.map +1 -0
- package/build/components/post-title/index.native.js +25 -15
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/post-view-link/index.js +58 -0
- package/build/components/post-view-link/index.js.map +1 -0
- package/build/components/post-visibility/check.js +5 -17
- package/build/components/post-visibility/check.js.map +1 -1
- package/build/components/preview-dropdown/index.js +118 -0
- package/build/components/preview-dropdown/index.js.map +1 -0
- package/build/components/provider/index.js +24 -82
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/index.native.js +36 -8
- package/build/components/provider/index.native.js.map +1 -1
- package/build/components/provider/navigation-block-editing-mode.js +40 -0
- package/build/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build/components/provider/use-block-editor-settings.js +38 -15
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +1 -1
- package/build/hooks/pattern-partial-syncing.js +49 -0
- package/build/hooks/pattern-partial-syncing.js.map +1 -0
- package/build/private-apis.js +14 -0
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +161 -13
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +2 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/index.js +5 -0
- package/build/store/index.js.map +1 -1
- package/build/store/private-actions.js +52 -0
- package/build/store/private-actions.js.map +1 -0
- package/build/store/private-selectors.js +52 -0
- package/build/store/private-selectors.js.map +1 -0
- package/build/store/reducer.js +109 -27
- package/build/store/reducer.js.map +1 -1
- package/build/store/reducer.native.js +0 -1
- package/build/store/reducer.native.js.map +1 -1
- package/build/store/selectors.js +104 -9
- package/build/store/selectors.js.map +1 -1
- package/build/utils/media-upload/index.js +8 -2
- package/build/utils/media-upload/index.js.map +1 -1
- package/build-module/components/document-bar/index.js +156 -0
- package/build-module/components/document-bar/index.js.map +1 -0
- package/build-module/components/document-outline/index.js +82 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/document-tools/index.js +151 -0
- package/build-module/components/document-tools/index.js.map +1 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +100 -0
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -0
- package/build-module/components/editor-canvas/index.js +289 -0
- package/build-module/components/editor-canvas/index.js.map +1 -0
- package/build-module/components/entities-saved-states/index.js +3 -1
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/index.js +12 -2
- package/build-module/components/global-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js +9 -0
- package/build-module/components/global-keyboard-shortcuts/register-shortcuts.js.map +1 -1
- package/build-module/components/index.js +9 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/index.native.js +1 -0
- package/build-module/components/index.native.js.map +1 -1
- package/build-module/components/inserter-sidebar/index.js +70 -0
- package/build-module/components/inserter-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/index.js +142 -0
- package/build-module/components/list-view-sidebar/index.js.map +1 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js +20 -0
- package/build-module/components/list-view-sidebar/list-view-outline.js.map +1 -0
- package/build-module/components/offline-status/index.native.js +77 -0
- package/build-module/components/offline-status/index.native.js.map +1 -0
- package/build-module/components/page-attributes/panel.js +53 -0
- package/build-module/components/page-attributes/panel.js.map +1 -0
- package/build-module/components/post-discussion/panel.js +50 -0
- package/build-module/components/post-discussion/panel.js.map +1 -0
- package/build-module/components/post-excerpt/check.js +19 -0
- package/build-module/components/post-excerpt/check.js.map +1 -1
- package/build-module/components/post-excerpt/panel.js +48 -0
- package/build-module/components/post-excerpt/panel.js.map +1 -0
- package/build-module/components/post-excerpt/plugin.js +64 -0
- package/build-module/components/post-excerpt/plugin.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +5 -8
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +51 -0
- package/build-module/components/post-featured-image/panel.js.map +1 -0
- package/build-module/components/post-last-revision/panel.js +18 -0
- package/build-module/components/post-last-revision/panel.js.map +1 -0
- package/build-module/components/post-publish-button/index.js +1 -0
- package/build-module/components/post-publish-button/index.js.map +1 -1
- package/build-module/components/post-publish-panel/maybe-upload-media.js +2 -4
- package/build-module/components/post-publish-panel/maybe-upload-media.js.map +1 -1
- package/build-module/components/post-saved-state/index.js +13 -8
- package/build-module/components/post-saved-state/index.js.map +1 -1
- package/build-module/components/post-schedule/panel.js +1 -1
- package/build-module/components/post-schedule/panel.js.map +1 -1
- package/build-module/components/post-taxonomies/panel.js +59 -0
- package/build-module/components/post-taxonomies/panel.js.map +1 -0
- package/build-module/components/post-template/block-theme.js +92 -0
- package/build-module/components/post-template/block-theme.js.map +1 -0
- package/build-module/components/post-template/classic-theme.js +162 -0
- package/build-module/components/post-template/classic-theme.js.map +1 -0
- package/build-module/components/post-template/create-new-template-modal.js +91 -0
- package/build-module/components/post-template/create-new-template-modal.js.map +1 -0
- package/build-module/components/post-template/create-new-template.js +47 -0
- package/build-module/components/post-template/create-new-template.js.map +1 -0
- package/build-module/components/post-template/hooks.js +78 -0
- package/build-module/components/post-template/hooks.js.map +1 -0
- package/build-module/components/post-template/panel.js +62 -0
- package/build-module/components/post-template/panel.js.map +1 -0
- package/build-module/components/post-template/reset-default-template.js +41 -0
- package/build-module/components/post-template/reset-default-template.js.map +1 -0
- package/build-module/components/post-template/swap-template-button.js +79 -0
- package/build-module/components/post-template/swap-template-button.js.map +1 -0
- package/build-module/components/post-title/index.native.js +26 -16
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/post-view-link/index.js +51 -0
- package/build-module/components/post-view-link/index.js.map +1 -0
- package/build-module/components/post-visibility/check.js +6 -16
- package/build-module/components/post-visibility/check.js.map +1 -1
- package/build-module/components/preview-dropdown/index.js +110 -0
- package/build-module/components/preview-dropdown/index.js.map +1 -0
- package/build-module/components/provider/index.js +25 -83
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/index.native.js +37 -9
- package/build-module/components/provider/index.native.js.map +1 -1
- package/build-module/components/provider/navigation-block-editing-mode.js +34 -0
- package/build-module/components/provider/navigation-block-editing-mode.js.map +1 -0
- package/build-module/components/provider/use-block-editor-settings.js +38 -15
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +1 -1
- package/build-module/hooks/pattern-partial-syncing.js +46 -0
- package/build-module/hooks/pattern-partial-syncing.js.map +1 -0
- package/build-module/private-apis.js +14 -0
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +147 -9
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +2 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/index.js +5 -0
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-actions.js +44 -0
- package/build-module/store/private-actions.js.map +1 -0
- package/build-module/store/private-selectors.js +43 -0
- package/build-module/store/private-selectors.js.map +1 -0
- package/build-module/store/reducer.js +103 -26
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/reducer.native.js +1 -2
- package/build-module/store/reducer.native.js.map +1 -1
- package/build-module/store/selectors.js +93 -6
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/media-upload/index.js +8 -2
- package/build-module/utils/media-upload/index.js.map +1 -1
- package/build-style/style-rtl.css +433 -0
- package/build-style/style.css +433 -0
- package/package.json +32 -31
- package/src/components/document-bar/index.js +193 -0
- package/src/components/document-bar/style.scss +130 -0
- package/src/components/document-outline/index.js +48 -1
- package/src/components/document-outline/style.scss +12 -0
- package/src/components/document-tools/index.js +177 -0
- package/src/components/document-tools/style.scss +98 -0
- package/src/components/editor-canvas/edit-template-blocks-notification.js +108 -0
- package/src/components/editor-canvas/index.js +386 -0
- package/src/components/editor-canvas/style.scss +5 -0
- package/src/components/entities-saved-states/index.js +3 -1
- package/src/components/entities-saved-states/style.scss +4 -0
- package/src/components/global-keyboard-shortcuts/index.js +12 -2
- package/src/components/global-keyboard-shortcuts/register-shortcuts.js +10 -0
- package/src/components/index.js +9 -1
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +73 -0
- package/src/components/inserter-sidebar/style.scss +22 -0
- package/src/components/list-view-sidebar/index.js +169 -0
- package/src/components/list-view-sidebar/list-view-outline.js +37 -0
- package/src/components/list-view-sidebar/style.scss +84 -0
- package/src/components/offline-status/index.native.js +101 -0
- package/src/components/offline-status/style.native.scss +28 -0
- package/src/components/offline-status/test/index.native.js +108 -0
- package/src/components/page-attributes/panel.js +62 -0
- package/src/components/post-discussion/panel.js +57 -0
- package/src/components/post-excerpt/check.js +18 -0
- package/src/components/post-excerpt/panel.js +57 -0
- package/src/components/post-excerpt/plugin.js +61 -0
- package/src/components/post-excerpt/test/plugin.js +36 -0
- package/src/components/post-featured-image/index.js +3 -7
- package/src/components/post-featured-image/panel.js +55 -0
- package/src/components/post-last-revision/panel.js +22 -0
- package/src/components/post-last-revision/style.scss +10 -0
- package/src/components/post-publish-button/index.js +1 -0
- package/src/components/post-publish-panel/maybe-upload-media.js +3 -8
- package/src/components/post-saved-state/index.js +9 -8
- package/src/components/post-saved-state/test/__snapshots__/index.js.snap +2 -2
- package/src/components/post-schedule/panel.js +1 -1
- package/src/components/post-taxonomies/panel.js +66 -0
- package/src/components/post-template/block-theme.js +110 -0
- package/src/components/post-template/classic-theme.js +213 -0
- package/src/components/post-template/create-new-template-modal.js +139 -0
- package/src/components/post-template/create-new-template.js +50 -0
- package/src/components/post-template/hooks.js +95 -0
- package/src/components/post-template/panel.js +66 -0
- package/src/components/post-template/reset-default-template.js +43 -0
- package/src/components/post-template/style.scss +52 -0
- package/src/components/post-template/swap-template-button.js +86 -0
- package/src/components/post-title/index.native.js +32 -18
- package/src/components/post-title/style.scss +1 -0
- package/src/components/post-title/test/__snapshots__/index.native.js.snap +25 -0
- package/src/components/post-title/test/index.native.js +78 -0
- package/src/components/post-view-link/index.js +47 -0
- package/src/components/post-visibility/check.js +10 -15
- package/src/components/post-visibility/test/check.js +24 -13
- package/src/components/preview-dropdown/index.js +133 -0
- package/src/components/preview-dropdown/style.scss +5 -0
- package/src/components/provider/index.js +28 -118
- package/src/components/provider/index.native.js +55 -14
- package/src/components/provider/navigation-block-editing-mode.js +37 -0
- package/src/components/provider/use-block-editor-settings.js +42 -17
- package/src/hooks/index.js +1 -0
- package/src/hooks/pattern-partial-syncing.js +73 -0
- package/src/private-apis.js +14 -0
- package/src/store/actions.js +160 -9
- package/src/store/defaults.js +1 -0
- package/src/store/index.js +5 -0
- package/src/store/private-actions.js +61 -0
- package/src/store/private-selectors.js +51 -0
- package/src/store/reducer.js +103 -26
- package/src/store/reducer.native.js +0 -2
- package/src/store/selectors.js +144 -42
- package/src/store/test/actions.js +56 -0
- package/src/store/test/reducer.js +98 -0
- package/src/store/test/selectors.js +137 -147
- package/src/style.scss +7 -0
- package/src/utils/media-upload/index.js +9 -2
- package/build/components/post-template/index.js +0 -66
- package/build/components/post-template/index.js.map +0 -1
- package/build-module/components/post-template/index.js +0 -57
- package/build-module/components/post-template/index.js.map +0 -1
- package/src/components/post-template/index.js +0 -64
|
@@ -5,6 +5,8 @@ import { Platform, useMemo, useCallback } from '@wordpress/element';
|
|
|
5
5
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
6
|
import { store as coreStore, __experimentalFetchLinkSuggestions as fetchLinkSuggestions, __experimentalFetchUrlData as fetchUrlData } from '@wordpress/core-data';
|
|
7
7
|
import { __ } from '@wordpress/i18n';
|
|
8
|
+
import { store as preferencesStore } from '@wordpress/preferences';
|
|
9
|
+
import { useViewportMatch } from '@wordpress/compose';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Internal dependencies
|
|
@@ -13,7 +15,7 @@ import inserterMediaCategories from '../media-categories';
|
|
|
13
15
|
import { mediaUpload } from '../../utils';
|
|
14
16
|
import { store as editorStore } from '../../store';
|
|
15
17
|
const EMPTY_BLOCKS_LIST = [];
|
|
16
|
-
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '
|
|
18
|
+
const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__experimentalPreferredStyleVariations', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'getPostLinkProps', 'hasInlineToolbar', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'locale', 'maxWidth', 'onUpdateDefaultBlockStyles', 'postContentAttributes', 'postsPerPage', 'readOnly', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', '__experimentalArchiveTitleTypeLabel', '__experimentalArchiveTitleNameLabel'];
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* React hook used to compute the block editor settings to use for the post editor.
|
|
@@ -26,14 +28,22 @@ const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDi
|
|
|
26
28
|
*/
|
|
27
29
|
function useBlockEditorSettings(settings, postType, postId) {
|
|
28
30
|
var _settings$__experimen, _settings$__experimen2;
|
|
31
|
+
const isLargeViewport = useViewportMatch('medium');
|
|
29
32
|
const {
|
|
33
|
+
allowRightClickOverrides,
|
|
34
|
+
focusMode,
|
|
35
|
+
hasFixedToolbar,
|
|
36
|
+
isDistractionFree,
|
|
37
|
+
keepCaretInsideBlock,
|
|
30
38
|
reusableBlocks,
|
|
31
39
|
hasUploadPermissions,
|
|
32
40
|
canUseUnfilteredHTML,
|
|
33
41
|
userCanCreatePages,
|
|
34
42
|
pageOnFront,
|
|
35
43
|
pageForPosts,
|
|
36
|
-
userPatternCategories
|
|
44
|
+
userPatternCategories,
|
|
45
|
+
restBlockPatterns,
|
|
46
|
+
restBlockPatternCategories
|
|
37
47
|
} = useSelect(select => {
|
|
38
48
|
var _canUser;
|
|
39
49
|
const isWeb = Platform.OS === 'web';
|
|
@@ -42,11 +52,21 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
42
52
|
getRawEntityRecord,
|
|
43
53
|
getEntityRecord,
|
|
44
54
|
getUserPatternCategories,
|
|
45
|
-
getEntityRecords
|
|
55
|
+
getEntityRecords,
|
|
56
|
+
getBlockPatterns,
|
|
57
|
+
getBlockPatternCategories
|
|
46
58
|
} = select(coreStore);
|
|
59
|
+
const {
|
|
60
|
+
get
|
|
61
|
+
} = select(preferencesStore);
|
|
47
62
|
const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined;
|
|
48
63
|
return {
|
|
64
|
+
allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
|
|
49
65
|
canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
|
|
66
|
+
focusMode: get('core', 'focusMode'),
|
|
67
|
+
hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
|
|
68
|
+
isDistractionFree: get('core', 'distractionFree'),
|
|
69
|
+
keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
|
|
50
70
|
reusableBlocks: isWeb ? getEntityRecords('postType', 'wp_block', {
|
|
51
71
|
per_page: -1
|
|
52
72
|
}) : EMPTY_BLOCKS_LIST,
|
|
@@ -55,9 +75,11 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
55
75
|
userCanCreatePages: canUser('create', 'pages'),
|
|
56
76
|
pageOnFront: siteSettings?.page_on_front,
|
|
57
77
|
pageForPosts: siteSettings?.page_for_posts,
|
|
58
|
-
userPatternCategories: getUserPatternCategories()
|
|
78
|
+
userPatternCategories: getUserPatternCategories(),
|
|
79
|
+
restBlockPatterns: getBlockPatterns(),
|
|
80
|
+
restBlockPatternCategories: getBlockPatternCategories()
|
|
59
81
|
};
|
|
60
|
-
}, [postType, postId]);
|
|
82
|
+
}, [postType, postId, isLargeViewport]);
|
|
61
83
|
const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
|
|
62
84
|
// WP 6.0
|
|
63
85
|
settings.__experimentalBlockPatterns; // WP 5.9
|
|
@@ -65,13 +87,6 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
65
87
|
// WP 6.0
|
|
66
88
|
settings.__experimentalBlockPatternCategories; // WP 5.9
|
|
67
89
|
|
|
68
|
-
const {
|
|
69
|
-
restBlockPatterns,
|
|
70
|
-
restBlockPatternCategories
|
|
71
|
-
} = useSelect(select => ({
|
|
72
|
-
restBlockPatterns: select(coreStore).getBlockPatterns(),
|
|
73
|
-
restBlockPatternCategories: select(coreStore).getBlockPatternCategories()
|
|
74
|
-
}), []);
|
|
75
90
|
const blockPatterns = useMemo(() => [...(settingsBlockPatterns || []), ...(restBlockPatterns || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)).filter(({
|
|
76
91
|
postTypes
|
|
77
92
|
}) => {
|
|
@@ -79,7 +94,8 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
79
94
|
}), [settingsBlockPatterns, restBlockPatterns, postType]);
|
|
80
95
|
const blockPatternCategories = useMemo(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
|
|
81
96
|
const {
|
|
82
|
-
undo
|
|
97
|
+
undo,
|
|
98
|
+
setIsInserterOpened
|
|
83
99
|
} = useDispatch(editorStore);
|
|
84
100
|
const {
|
|
85
101
|
saveEntityRecord
|
|
@@ -100,8 +116,14 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
100
116
|
}
|
|
101
117
|
return saveEntityRecord('postType', 'page', options);
|
|
102
118
|
}, [saveEntityRecord, userCanCreatePages]);
|
|
119
|
+
const forceDisableFocusMode = settings.focusMode === false;
|
|
103
120
|
return useMemo(() => ({
|
|
104
121
|
...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
|
|
122
|
+
allowRightClickOverrides,
|
|
123
|
+
focusMode: focusMode && !forceDisableFocusMode,
|
|
124
|
+
hasFixedToolbar,
|
|
125
|
+
isDistractionFree,
|
|
126
|
+
keepCaretInsideBlock,
|
|
105
127
|
mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
|
|
106
128
|
__experimentalReusableBlocks: reusableBlocks,
|
|
107
129
|
__experimentalBlockPatterns: blockPatterns,
|
|
@@ -125,8 +147,9 @@ function useBlockEditorSettings(settings, postType, postId) {
|
|
|
125
147
|
pageForPosts,
|
|
126
148
|
__experimentalPreferPatternsOnRoot: postType === 'wp_template',
|
|
127
149
|
templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
|
|
128
|
-
template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template
|
|
129
|
-
|
|
150
|
+
template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
|
|
151
|
+
__experimentalSetIsInserterOpened: setIsInserterOpened
|
|
152
|
+
}), [allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, reusableBlocks, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened]);
|
|
130
153
|
}
|
|
131
154
|
export default useBlockEditorSettings;
|
|
132
155
|
//# sourceMappingURL=use-block-editor-settings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","useMemo","useCallback","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","postType","postId","_settings$__experimen","_settings$__experimen2","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","userPatternCategories","select","_canUser","isWeb","OS","canUser","getRawEntityRecord","getEntityRecord","getUserPatternCategories","getEntityRecords","siteSettings","undefined","_links","hasOwnProperty","per_page","page_on_front","page_for_posts","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","restBlockPatterns","restBlockPatternCategories","getBlockPatterns","getBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","saveEntityRecord","createPageEntity","options","Promise","reject","message","Object","fromEntries","entries","key","__experimentalReusableBlocks","__experimentalUserPatternCategories","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot","templateLock","template"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__experimentalSetIsInserterOpened',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'focusMode',\n\t'distractionFree',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'hasFixedToolbar',\n\t'hasInlineToolbar',\n\t'isDistractionFree',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'keepCaretInsideBlock',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n\t'__experimentalArchiveTitleTypeLabel',\n\t'__experimentalArchiveTitleNameLabel',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId ) {\n\tconst {\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetEntityRecords,\n\t\t\t} = select( coreStore );\n\n\t\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\treusableBlocks: isWeb\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst { restBlockPatterns, restBlockPatternCategories } = useSelect(\n\t\t( select ) => ( {\n\t\t\trestBlockPatterns: select( coreStore ).getBlockPatterns(),\n\t\t\trestBlockPatternCategories:\n\t\t\t\tselect( coreStore ).getBlockPatternCategories(),\n\t\t} ),\n\t\t[]\n\t);\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t} ),\n\t\t[\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tuserPatternCategories,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\tcreatePageEntity,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\tpostType,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,KAAK,IAAIC,SAAS,EAClBC,kCAAkC,IAAIC,oBAAoB,EAC1DC,0BAA0B,IAAIC,YAAY,QACpC,sBAAsB;AAC7B,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,uBAAuB,MAAM,qBAAqB;AACzD,SAASC,WAAW,QAAQ,aAAa;AACzC,SAASR,KAAK,IAAIS,WAAW,QAAQ,aAAa;AAElD,MAAMC,iBAAiB,GAAG,EAAE;AAE5B,MAAMC,qBAAqB,GAAG,CAC7B,8BAA8B,EAC9B,kCAAkC,EAClC,wBAAwB,EACxB,sCAAsC,EACtC,wCAAwC,EACxC,mCAAmC,EACnC,kCAAkC,EAClC,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,cAAc,EACd,qBAAqB,EACrB,oBAAoB,EACpB,QAAQ,EACR,qBAAqB,EACrB,wBAAwB,EACxB,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACrB,wBAAwB,EACxB,qBAAqB,EACrB,mBAAmB,EACnB,8BAA8B,EAC9B,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,cAAc,EACd,YAAY,EAC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,oBAAoB,GAAGX,WAAW,GAAG2B,SAAS;IAC3DwC,4BAA4B,EAAEzD,cAAc;IAC5CyB,2BAA2B,EAAEQ,aAAa;IAC1CL,oCAAoC,EAAEiB,sBAAsB;IAC5Da,mCAAmC,EAAEpD,qBAAqB;IAC1DtB,kCAAkC,EAAEA,CAAE2E,MAAM,EAAEC,aAAa,KAC1D3E,oBAAoB,CAAE0E,MAAM,EAAEC,aAAa,EAAEjE,QAAS,CAAC;IACxDN,uBAAuB;IACvBwE,8BAA8B,EAAE1E,YAAY;IAC5C;IACA;IACA2E,sCAAsC,EAAE5D,oBAAoB;IAC5D;IACA6D,kBAAkB,EAAEjB,IAAI;IACxB;IACA;IACAkB,WAAW,EAAEpE,QAAQ,KAAK,aAAa;IACvC;IACAqE,8BAA8B,EAAEjB,gBAAgB;IAChDkB,gCAAgC,EAAE/D,kBAAkB;IACpDC,WAAW;IACXC,YAAY;IACZ8D,kCAAkC,EAAEvE,QAAQ,KAAK,aAAa;IAC9DwE,YAAY,EACXxE,QAAQ,KAAK,eAAe,GAAG,QAAQ,GAAGD,QAAQ,CAACyE,YAAY;IAChEC,QAAQ,EACPzE,QAAQ,KAAK,eAAe,GACzB,CAAE,CAAE,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,CAAE,CAAE,GACjCD,QAAQ,CAAC0E;EACd,CAAC,CAAE,EACH,CACC1E,QAAQ,EACRM,oBAAoB,EACpBD,cAAc,EACdM,qBAAqB,EACrB2B,aAAa,EACbY,sBAAsB,EACtB3C,oBAAoB,EACpB4C,IAAI,EACJE,gBAAgB,EAChB7C,kBAAkB,EAClBC,WAAW,EACXC,YAAY,EACZT,QAAQ,CAEV,CAAC;AACF;AAEA,eAAeF,sBAAsB"}
|
|
1
|
+
{"version":3,"names":["Platform","useMemo","useCallback","useDispatch","useSelect","store","coreStore","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalFetchUrlData","fetchUrlData","__","preferencesStore","useViewportMatch","inserterMediaCategories","mediaUpload","editorStore","EMPTY_BLOCKS_LIST","BLOCK_EDITOR_SETTINGS","useBlockEditorSettings","settings","postType","postId","_settings$__experimen","_settings$__experimen2","isLargeViewport","allowRightClickOverrides","focusMode","hasFixedToolbar","isDistractionFree","keepCaretInsideBlock","reusableBlocks","hasUploadPermissions","canUseUnfilteredHTML","userCanCreatePages","pageOnFront","pageForPosts","userPatternCategories","restBlockPatterns","restBlockPatternCategories","select","_canUser","isWeb","OS","canUser","getRawEntityRecord","getEntityRecord","getUserPatternCategories","getEntityRecords","getBlockPatterns","getBlockPatternCategories","get","siteSettings","undefined","_links","hasOwnProperty","per_page","page_on_front","page_for_posts","settingsBlockPatterns","__experimentalAdditionalBlockPatterns","__experimentalBlockPatterns","settingsBlockPatternCategories","__experimentalAdditionalBlockPatternCategories","__experimentalBlockPatternCategories","blockPatterns","filter","x","index","arr","findIndex","y","name","postTypes","Array","isArray","includes","blockPatternCategories","undo","setIsInserterOpened","saveEntityRecord","createPageEntity","options","Promise","reject","message","forceDisableFocusMode","Object","fromEntries","entries","key","__experimentalReusableBlocks","__experimentalUserPatternCategories","search","searchOptions","__experimentalFetchRichUrlData","__experimentalCanUserUseUnfilteredHTML","__experimentalUndo","outlineMode","__experimentalCreatePageEntity","__experimentalUserCanCreatePages","__experimentalPreferPatternsOnRoot","templateLock","template","__experimentalSetIsInserterOpened"],"sources":["@wordpress/editor/src/components/provider/use-block-editor-settings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Platform, useMemo, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tstore as coreStore,\n\t__experimentalFetchLinkSuggestions as fetchLinkSuggestions,\n\t__experimentalFetchUrlData as fetchUrlData,\n} from '@wordpress/core-data';\nimport { __ } from '@wordpress/i18n';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useViewportMatch } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport inserterMediaCategories from '../media-categories';\nimport { mediaUpload } from '../../utils';\nimport { store as editorStore } from '../../store';\n\nconst EMPTY_BLOCKS_LIST = [];\n\nconst BLOCK_EDITOR_SETTINGS = [\n\t'__experimentalBlockDirectory',\n\t'__experimentalDiscussionSettings',\n\t'__experimentalFeatures',\n\t'__experimentalGlobalStylesBaseStyles',\n\t'__experimentalPreferredStyleVariations',\n\t'__unstableGalleryWithImageBlocks',\n\t'alignWide',\n\t'allowedBlockTypes',\n\t'blockInspectorTabs',\n\t'allowedMimeTypes',\n\t'bodyPlaceholder',\n\t'canLockBlocks',\n\t'capabilities',\n\t'clearBlockSelection',\n\t'codeEditingEnabled',\n\t'colors',\n\t'disableCustomColors',\n\t'disableCustomFontSizes',\n\t'disableCustomSpacingSizes',\n\t'disableCustomGradients',\n\t'disableLayoutStyles',\n\t'enableCustomLineHeight',\n\t'enableCustomSpacing',\n\t'enableCustomUnits',\n\t'enableOpenverseMediaCategory',\n\t'fontSizes',\n\t'gradients',\n\t'generateAnchors',\n\t'getPostLinkProps',\n\t'hasInlineToolbar',\n\t'imageDefaultSize',\n\t'imageDimensions',\n\t'imageEditing',\n\t'imageSizes',\n\t'isRTL',\n\t'locale',\n\t'maxWidth',\n\t'onUpdateDefaultBlockStyles',\n\t'postContentAttributes',\n\t'postsPerPage',\n\t'readOnly',\n\t'styles',\n\t'titlePlaceholder',\n\t'supportsLayout',\n\t'widgetTypesToHideFromLegacyWidgetBlock',\n\t'__unstableHasCustomAppender',\n\t'__unstableIsPreviewMode',\n\t'__unstableResolvedAssets',\n\t'__unstableIsBlockBasedTheme',\n\t'__experimentalArchiveTitleTypeLabel',\n\t'__experimentalArchiveTitleNameLabel',\n];\n\n/**\n * React hook used to compute the block editor settings to use for the post editor.\n *\n * @param {Object} settings EditorProvider settings prop.\n * @param {string} postType Editor root level post type.\n * @param {string} postId Editor root level post ID.\n *\n * @return {Object} Block Editor Settings.\n */\nfunction useBlockEditorSettings( settings, postType, postId ) {\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst {\n\t\tallowRightClickOverrides,\n\t\tfocusMode,\n\t\thasFixedToolbar,\n\t\tisDistractionFree,\n\t\tkeepCaretInsideBlock,\n\t\treusableBlocks,\n\t\thasUploadPermissions,\n\t\tcanUseUnfilteredHTML,\n\t\tuserCanCreatePages,\n\t\tpageOnFront,\n\t\tpageForPosts,\n\t\tuserPatternCategories,\n\t\trestBlockPatterns,\n\t\trestBlockPatternCategories,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst isWeb = Platform.OS === 'web';\n\t\t\tconst {\n\t\t\t\tcanUser,\n\t\t\t\tgetRawEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\tgetUserPatternCategories,\n\t\t\t\tgetEntityRecords,\n\t\t\t\tgetBlockPatterns,\n\t\t\t\tgetBlockPatternCategories,\n\t\t\t} = select( coreStore );\n\t\t\tconst { get } = select( preferencesStore );\n\n\t\t\tconst siteSettings = canUser( 'read', 'settings' )\n\t\t\t\t? getEntityRecord( 'root', 'site' )\n\t\t\t\t: undefined;\n\n\t\t\treturn {\n\t\t\t\tallowRightClickOverrides: get(\n\t\t\t\t\t'core',\n\t\t\t\t\t'allowRightClickOverrides'\n\t\t\t\t),\n\t\t\t\tcanUseUnfilteredHTML: getRawEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\tpostType,\n\t\t\t\t\tpostId\n\t\t\t\t)?._links?.hasOwnProperty( 'wp:action-unfiltered-html' ),\n\t\t\t\tfocusMode: get( 'core', 'focusMode' ),\n\t\t\t\thasFixedToolbar:\n\t\t\t\t\tget( 'core', 'fixedToolbar' ) || ! isLargeViewport,\n\t\t\t\tisDistractionFree: get( 'core', 'distractionFree' ),\n\t\t\t\tkeepCaretInsideBlock: get( 'core', 'keepCaretInsideBlock' ),\n\t\t\t\treusableBlocks: isWeb\n\t\t\t\t\t? getEntityRecords( 'postType', 'wp_block', {\n\t\t\t\t\t\t\tper_page: -1,\n\t\t\t\t\t } )\n\t\t\t\t\t: EMPTY_BLOCKS_LIST, // Reusable blocks are fetched in the native version of this hook.\n\t\t\t\thasUploadPermissions: canUser( 'create', 'media' ) ?? true,\n\t\t\t\tuserCanCreatePages: canUser( 'create', 'pages' ),\n\t\t\t\tpageOnFront: siteSettings?.page_on_front,\n\t\t\t\tpageForPosts: siteSettings?.page_for_posts,\n\t\t\t\tuserPatternCategories: getUserPatternCategories(),\n\t\t\t\trestBlockPatterns: getBlockPatterns(),\n\t\t\t\trestBlockPatternCategories: getBlockPatternCategories(),\n\t\t\t};\n\t\t},\n\t\t[ postType, postId, isLargeViewport ]\n\t);\n\n\tconst settingsBlockPatterns =\n\t\tsettings.__experimentalAdditionalBlockPatterns ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatterns; // WP 5.9\n\tconst settingsBlockPatternCategories =\n\t\tsettings.__experimentalAdditionalBlockPatternCategories ?? // WP 6.0\n\t\tsettings.__experimentalBlockPatternCategories; // WP 5.9\n\n\tconst blockPatterns = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatterns || [] ),\n\t\t\t\t...( restBlockPatterns || [] ),\n\t\t\t]\n\t\t\t\t.filter(\n\t\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t\t)\n\t\t\t\t.filter( ( { postTypes } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t! postTypes ||\n\t\t\t\t\t\t( Array.isArray( postTypes ) &&\n\t\t\t\t\t\t\tpostTypes.includes( postType ) )\n\t\t\t\t\t);\n\t\t\t\t} ),\n\t\t[ settingsBlockPatterns, restBlockPatterns, postType ]\n\t);\n\n\tconst blockPatternCategories = useMemo(\n\t\t() =>\n\t\t\t[\n\t\t\t\t...( settingsBlockPatternCategories || [] ),\n\t\t\t\t...( restBlockPatternCategories || [] ),\n\t\t\t].filter(\n\t\t\t\t( x, index, arr ) =>\n\t\t\t\t\tindex === arr.findIndex( ( y ) => x.name === y.name )\n\t\t\t),\n\t\t[ settingsBlockPatternCategories, restBlockPatternCategories ]\n\t);\n\n\tconst { undo, setIsInserterOpened } = useDispatch( editorStore );\n\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\t/**\n\t * Creates a Post entity.\n\t * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.\n\t *\n\t * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.\n\t * @return {Object} the post type object that was created.\n\t */\n\tconst createPageEntity = useCallback(\n\t\t( options ) => {\n\t\t\tif ( ! userCanCreatePages ) {\n\t\t\t\treturn Promise.reject( {\n\t\t\t\t\tmessage: __(\n\t\t\t\t\t\t'You do not have permission to create Pages.'\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t}\n\t\t\treturn saveEntityRecord( 'postType', 'page', options );\n\t\t},\n\t\t[ saveEntityRecord, userCanCreatePages ]\n\t);\n\n\tconst forceDisableFocusMode = settings.focusMode === false;\n\n\treturn useMemo(\n\t\t() => ( {\n\t\t\t...Object.fromEntries(\n\t\t\t\tObject.entries( settings ).filter( ( [ key ] ) =>\n\t\t\t\t\tBLOCK_EDITOR_SETTINGS.includes( key )\n\t\t\t\t)\n\t\t\t),\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode: focusMode && ! forceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tmediaUpload: hasUploadPermissions ? mediaUpload : undefined,\n\t\t\t__experimentalReusableBlocks: reusableBlocks,\n\t\t\t__experimentalBlockPatterns: blockPatterns,\n\t\t\t__experimentalBlockPatternCategories: blockPatternCategories,\n\t\t\t__experimentalUserPatternCategories: userPatternCategories,\n\t\t\t__experimentalFetchLinkSuggestions: ( search, searchOptions ) =>\n\t\t\t\tfetchLinkSuggestions( search, searchOptions, settings ),\n\t\t\tinserterMediaCategories,\n\t\t\t__experimentalFetchRichUrlData: fetchUrlData,\n\t\t\t// Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.\n\t\t\t// This might be better as a generic \"canUser\" selector.\n\t\t\t__experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,\n\t\t\t//Todo: this is only needed for native and should probably be removed.\n\t\t\t__experimentalUndo: undo,\n\t\t\t// Check whether we want all site editor frames to have outlines\n\t\t\t// including the navigation / pattern / parts editors.\n\t\t\toutlineMode: postType === 'wp_template',\n\t\t\t// Check these two properties: they were not present in the site editor.\n\t\t\t__experimentalCreatePageEntity: createPageEntity,\n\t\t\t__experimentalUserCanCreatePages: userCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\t__experimentalPreferPatternsOnRoot: postType === 'wp_template',\n\t\t\ttemplateLock:\n\t\t\t\tpostType === 'wp_navigation' ? 'insert' : settings.templateLock,\n\t\t\ttemplate:\n\t\t\t\tpostType === 'wp_navigation'\n\t\t\t\t\t? [ [ 'core/navigation', {}, [] ] ]\n\t\t\t\t\t: settings.template,\n\t\t\t__experimentalSetIsInserterOpened: setIsInserterOpened,\n\t\t} ),\n\t\t[\n\t\t\tallowRightClickOverrides,\n\t\t\tfocusMode,\n\t\t\tforceDisableFocusMode,\n\t\t\thasFixedToolbar,\n\t\t\tisDistractionFree,\n\t\t\tkeepCaretInsideBlock,\n\t\t\tsettings,\n\t\t\thasUploadPermissions,\n\t\t\treusableBlocks,\n\t\t\tuserPatternCategories,\n\t\t\tblockPatterns,\n\t\t\tblockPatternCategories,\n\t\t\tcanUseUnfilteredHTML,\n\t\t\tundo,\n\t\t\tcreatePageEntity,\n\t\t\tuserCanCreatePages,\n\t\t\tpageOnFront,\n\t\t\tpageForPosts,\n\t\t\tpostType,\n\t\t\tsetIsInserterOpened,\n\t\t]\n\t);\n}\n\nexport default useBlockEditorSettings;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,EAAEC,OAAO,EAAEC,WAAW,QAAQ,oBAAoB;AACnE,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACC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,oBAAoB,EACpBD,cAAc,EACdM,qBAAqB,EACrB4B,aAAa,EACbY,sBAAsB,EACtB5C,oBAAoB,EACpB6C,IAAI,EACJG,gBAAgB,EAChB/C,kBAAkB,EAClBC,WAAW,EACXC,YAAY,EACZf,QAAQ,EACR0D,mBAAmB,CAErB,CAAC;AACF;AAEA,eAAe5D,sBAAsB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,0CAA0C;AACjD,OAAO,0BAA0B"}
|
|
1
|
+
{"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-partial-syncing';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,0CAA0C;AACjD,OAAO,0BAA0B;AACjC,OAAO,2BAA2B"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createElement, Fragment } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* WordPress dependencies
|
|
4
|
+
*/
|
|
5
|
+
import { addFilter } from '@wordpress/hooks';
|
|
6
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
7
|
+
import { createHigherOrderComponent } from '@wordpress/compose';
|
|
8
|
+
import { useBlockEditingMode } from '@wordpress/block-editor';
|
|
9
|
+
import { hasBlockSupport } from '@wordpress/blocks';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { store as editorStore } from '../store';
|
|
16
|
+
import { unlock } from '../lock-unlock';
|
|
17
|
+
const {
|
|
18
|
+
PartialSyncingControls,
|
|
19
|
+
PATTERN_TYPES,
|
|
20
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS
|
|
21
|
+
} = unlock(patternsPrivateApis);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Override the default edit UI to include a new block inspector control for
|
|
25
|
+
* assigning a partial syncing controls to supported blocks in the pattern editor.
|
|
26
|
+
* Currently, only the `core/paragraph` block is supported.
|
|
27
|
+
*
|
|
28
|
+
* @param {Component} BlockEdit Original component.
|
|
29
|
+
*
|
|
30
|
+
* @return {Component} Wrapped component.
|
|
31
|
+
*/
|
|
32
|
+
const withPartialSyncingControls = createHigherOrderComponent(BlockEdit => props => {
|
|
33
|
+
const blockEditingMode = useBlockEditingMode();
|
|
34
|
+
const hasCustomFieldsSupport = hasBlockSupport(props.name, '__experimentalConnections', false);
|
|
35
|
+
const isEditingPattern = useSelect(select => select(editorStore).getCurrentPostType() === PATTERN_TYPES.user, []);
|
|
36
|
+
const shouldShowPartialSyncingControls = hasCustomFieldsSupport && props.isSelected && isEditingPattern && blockEditingMode === 'default' && Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
|
|
37
|
+
return createElement(Fragment, null, createElement(BlockEdit, {
|
|
38
|
+
...props
|
|
39
|
+
}), shouldShowPartialSyncingControls && createElement(PartialSyncingControls, {
|
|
40
|
+
...props
|
|
41
|
+
}));
|
|
42
|
+
});
|
|
43
|
+
if (window.__experimentalPatternPartialSyncing) {
|
|
44
|
+
addFilter('editor.BlockEdit', 'core/editor/with-partial-syncing-controls', withPartialSyncingControls);
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=pattern-partial-syncing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","hasBlockSupport","useSelect","store","editorStore","unlock","PartialSyncingControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","withPartialSyncingControls","BlockEdit","props","blockEditingMode","hasCustomFieldsSupport","name","isEditingPattern","select","getCurrentPostType","user","shouldShowPartialSyncingControls","isSelected","Object","keys","includes","createElement","Fragment","window","__experimentalPatternPartialSyncing"],"sources":["@wordpress/editor/src/hooks/pattern-partial-syncing.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { hasBlockSupport } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tPartialSyncingControls,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPartialSyncingControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst blockEditingMode = useBlockEditingMode();\n\t\tconst hasCustomFieldsSupport = hasBlockSupport(\n\t\t\tprops.name,\n\t\t\t'__experimentalConnections',\n\t\t\tfalse\n\t\t);\n\t\tconst isEditingPattern = useSelect(\n\t\t\t( select ) =>\n\t\t\t\tselect( editorStore ).getCurrentPostType() ===\n\t\t\t\tPATTERN_TYPES.user,\n\t\t\t[]\n\t\t);\n\n\t\tconst shouldShowPartialSyncingControls =\n\t\t\thasCustomFieldsSupport &&\n\t\t\tprops.isSelected &&\n\t\t\tisEditingPattern &&\n\t\t\tblockEditingMode === 'default' &&\n\t\t\tObject.keys( PARTIAL_SYNCING_SUPPORTED_BLOCKS ).includes(\n\t\t\t\tprops.name\n\t\t\t);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ shouldShowPartialSyncingControls && (\n\t\t\t\t\t<PartialSyncingControls { ...props } />\n\t\t\t\t) }\n\t\t\t</>\n\t\t);\n\t}\n);\n\nif ( window.__experimentalPatternPartialSyncing ) {\n\taddFilter(\n\t\t'editor.BlockEdit',\n\t\t'core/editor/with-partial-syncing-controls',\n\t\twithPartialSyncingControls\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AACxE,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EACLC,sBAAsB;EACtBC,aAAa;EACbC;AACD,CAAC,GAAGH,MAAM,CAAEP,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,0BAA0B,GAAGV,0BAA0B,CAC1DW,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GAAGZ,mBAAmB,CAAC,CAAC;EAC9C,MAAMa,sBAAsB,GAAGZ,eAAe,CAC7CU,KAAK,CAACG,IAAI,EACV,2BAA2B,EAC3B,KACD,CAAC;EACD,MAAMC,gBAAgB,GAAGb,SAAS,CAC/Bc,MAAM,IACPA,MAAM,CAAEZ,WAAY,CAAC,CAACa,kBAAkB,CAAC,CAAC,KAC1CV,aAAa,CAACW,IAAI,EACnB,EACD,CAAC;EAED,MAAMC,gCAAgC,GACrCN,sBAAsB,IACtBF,KAAK,CAACS,UAAU,IAChBL,gBAAgB,IAChBH,gBAAgB,KAAK,SAAS,IAC9BS,MAAM,CAACC,IAAI,CAAEd,gCAAiC,CAAC,CAACe,QAAQ,CACvDZ,KAAK,CAACG,IACP,CAAC;EAEF,OACCU,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACd,SAAS;IAAA,GAAMC;EAAK,CAAI,CAAC,EACxBQ,gCAAgC,IACjCK,aAAA,CAAClB,sBAAsB;IAAA,GAAMK;EAAK,CAAI,CAEtC,CAAC;AAEL,CACD,CAAC;AAED,IAAKe,MAAM,CAACC,mCAAmC,EAAG;EACjD/B,SAAS,CACR,kBAAkB,EAClB,2CAA2C,EAC3Ca,0BACD,CAAC;AACF"}
|
|
@@ -1,16 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
+
import EditorCanvas from './components/editor-canvas';
|
|
4
5
|
import { ExperimentalEditorProvider } from './components/provider';
|
|
5
6
|
import { lock } from './lock-unlock';
|
|
6
7
|
import { EntitiesSavedStatesExtensible } from './components/entities-saved-states';
|
|
7
8
|
import useBlockEditorSettings from './components/provider/use-block-editor-settings';
|
|
9
|
+
import DocumentTools from './components/document-tools';
|
|
10
|
+
import InserterSidebar from './components/inserter-sidebar';
|
|
11
|
+
import ListViewSidebar from './components/list-view-sidebar';
|
|
8
12
|
import PostPanelRow from './components/post-panel-row';
|
|
13
|
+
import PostViewLink from './components/post-view-link';
|
|
14
|
+
import PreviewDropdown from './components/preview-dropdown';
|
|
15
|
+
import PluginPostExcerpt from './components/post-excerpt/plugin';
|
|
9
16
|
export const privateApis = {};
|
|
10
17
|
lock(privateApis, {
|
|
18
|
+
DocumentTools,
|
|
19
|
+
EditorCanvas,
|
|
11
20
|
ExperimentalEditorProvider,
|
|
12
21
|
EntitiesSavedStatesExtensible,
|
|
22
|
+
InserterSidebar,
|
|
23
|
+
ListViewSidebar,
|
|
13
24
|
PostPanelRow,
|
|
25
|
+
PostViewLink,
|
|
26
|
+
PreviewDropdown,
|
|
27
|
+
PluginPostExcerpt,
|
|
14
28
|
// This is a temporary private API while we're updating the site editor to use EditorProvider.
|
|
15
29
|
useBlockEditorSettings
|
|
16
30
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ExperimentalEditorProvider","lock","EntitiesSavedStatesExtensible","useBlockEditorSettings","PostPanelRow","privateApis"],"sources":["@wordpress/editor/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { ExperimentalEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport useBlockEditorSettings from './components/provider/use-block-editor-settings';\nimport PostPanelRow from './components/post-panel-row';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tExperimentalEditorProvider,\n\tEntitiesSavedStatesExtensible,\n\tPostPanelRow,\n\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tuseBlockEditorSettings,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,
|
|
1
|
+
{"version":3,"names":["EditorCanvas","ExperimentalEditorProvider","lock","EntitiesSavedStatesExtensible","useBlockEditorSettings","DocumentTools","InserterSidebar","ListViewSidebar","PostPanelRow","PostViewLink","PreviewDropdown","PluginPostExcerpt","privateApis"],"sources":["@wordpress/editor/src/private-apis.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport EditorCanvas from './components/editor-canvas';\nimport { ExperimentalEditorProvider } from './components/provider';\nimport { lock } from './lock-unlock';\nimport { EntitiesSavedStatesExtensible } from './components/entities-saved-states';\nimport useBlockEditorSettings from './components/provider/use-block-editor-settings';\nimport DocumentTools from './components/document-tools';\nimport InserterSidebar from './components/inserter-sidebar';\nimport ListViewSidebar from './components/list-view-sidebar';\nimport PostPanelRow from './components/post-panel-row';\nimport PostViewLink from './components/post-view-link';\nimport PreviewDropdown from './components/preview-dropdown';\nimport PluginPostExcerpt from './components/post-excerpt/plugin';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tDocumentTools,\n\tEditorCanvas,\n\tExperimentalEditorProvider,\n\tEntitiesSavedStatesExtensible,\n\tInserterSidebar,\n\tListViewSidebar,\n\tPostPanelRow,\n\tPostViewLink,\n\tPreviewDropdown,\n\tPluginPostExcerpt,\n\n\t// This is a temporary private API while we're updating the site editor to use EditorProvider.\n\tuseBlockEditorSettings,\n} );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,YAAY,MAAM,4BAA4B;AACrD,SAASC,0BAA0B,QAAQ,uBAAuB;AAClE,SAASC,IAAI,QAAQ,eAAe;AACpC,SAASC,6BAA6B,QAAQ,oCAAoC;AAClF,OAAOC,sBAAsB,MAAM,iDAAiD;AACpF,OAAOC,aAAa,MAAM,6BAA6B;AACvD,OAAOC,eAAe,MAAM,+BAA+B;AAC3D,OAAOC,eAAe,MAAM,gCAAgC;AAC5D,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,eAAe,MAAM,+BAA+B;AAC3D,OAAOC,iBAAiB,MAAM,kCAAkC;AAEhE,OAAO,MAAMC,WAAW,GAAG,CAAC,CAAC;AAC7BV,IAAI,CAAEU,WAAW,EAAE;EAClBP,aAAa;EACbL,YAAY;EACZC,0BAA0B;EAC1BE,6BAA6B;EAC7BG,eAAe;EACfC,eAAe;EACfC,YAAY;EACZC,YAAY;EACZC,eAAe;EACfC,iBAAiB;EAEjB;EACAP;AACD,CAAE,CAAC"}
|
|
@@ -28,7 +28,7 @@ import { getNotificationArgumentsForSaveSuccess, getNotificationArgumentsForSave
|
|
|
28
28
|
export const setupEditor = (post, edits, template) => ({
|
|
29
29
|
dispatch
|
|
30
30
|
}) => {
|
|
31
|
-
dispatch.
|
|
31
|
+
dispatch.setEditedPost(post.type, post.id);
|
|
32
32
|
// Apply a template for new posts only, if exists.
|
|
33
33
|
const isNewPost = post.status === 'auto-draft';
|
|
34
34
|
if (isNewPost && template) {
|
|
@@ -59,11 +59,16 @@ export const setupEditor = (post, edits, template) => ({
|
|
|
59
59
|
* Returns an action object signalling that the editor is being destroyed and
|
|
60
60
|
* that any necessary state or side-effect cleanup should occur.
|
|
61
61
|
*
|
|
62
|
+
* @deprecated
|
|
63
|
+
*
|
|
62
64
|
* @return {Object} Action object.
|
|
63
65
|
*/
|
|
64
66
|
export function __experimentalTearDownEditor() {
|
|
67
|
+
deprecated("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
|
|
68
|
+
since: '6.5'
|
|
69
|
+
});
|
|
65
70
|
return {
|
|
66
|
-
type: '
|
|
71
|
+
type: 'DO_NOTHING'
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
|
|
@@ -102,17 +107,33 @@ export function updatePost() {
|
|
|
102
107
|
}
|
|
103
108
|
|
|
104
109
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
110
|
+
* Setup the editor state.
|
|
111
|
+
*
|
|
112
|
+
* @deprecated
|
|
107
113
|
*
|
|
108
114
|
* @param {Object} post Post object.
|
|
115
|
+
*/
|
|
116
|
+
export function setupEditorState(post) {
|
|
117
|
+
deprecated("wp.data.dispatch( 'core/editor' ).setupEditorState", {
|
|
118
|
+
since: '6.5',
|
|
119
|
+
alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
|
|
120
|
+
});
|
|
121
|
+
return setEditedPost(post.type, post.id);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Returns an action that sets the current post Type and post ID.
|
|
126
|
+
*
|
|
127
|
+
* @param {string} postType Post Type.
|
|
128
|
+
* @param {string} postId Post ID.
|
|
109
129
|
*
|
|
110
130
|
* @return {Object} Action object.
|
|
111
131
|
*/
|
|
112
|
-
export function
|
|
132
|
+
export function setEditedPost(postType, postId) {
|
|
113
133
|
return {
|
|
114
|
-
type: '
|
|
115
|
-
|
|
134
|
+
type: 'SET_EDITED_POST',
|
|
135
|
+
postType,
|
|
136
|
+
postId
|
|
116
137
|
};
|
|
117
138
|
}
|
|
118
139
|
|
|
@@ -546,15 +567,132 @@ export function updateEditorSettings(settings) {
|
|
|
546
567
|
*/
|
|
547
568
|
export const setRenderingMode = mode => ({
|
|
548
569
|
dispatch,
|
|
549
|
-
registry
|
|
570
|
+
registry,
|
|
571
|
+
select
|
|
550
572
|
}) => {
|
|
551
|
-
|
|
573
|
+
if (select.__unstableIsEditorReady()) {
|
|
574
|
+
// We clear the block selection but we also need to clear the selection from the core store.
|
|
575
|
+
registry.dispatch(blockEditorStore).clearSelectedBlock();
|
|
576
|
+
dispatch.editPost({
|
|
577
|
+
selection: undefined
|
|
578
|
+
}, {
|
|
579
|
+
undoIgnore: true
|
|
580
|
+
});
|
|
581
|
+
}
|
|
552
582
|
dispatch({
|
|
553
583
|
type: 'SET_RENDERING_MODE',
|
|
554
584
|
mode
|
|
555
585
|
});
|
|
556
586
|
};
|
|
557
587
|
|
|
588
|
+
/**
|
|
589
|
+
* Action that changes the width of the editing canvas.
|
|
590
|
+
*
|
|
591
|
+
* @param {string} deviceType
|
|
592
|
+
*
|
|
593
|
+
* @return {Object} Action object.
|
|
594
|
+
*/
|
|
595
|
+
export function setDeviceType(deviceType) {
|
|
596
|
+
return {
|
|
597
|
+
type: 'SET_DEVICE_TYPE',
|
|
598
|
+
deviceType
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* Returns an action object used to enable or disable a panel in the editor.
|
|
604
|
+
*
|
|
605
|
+
* @param {string} panelName A string that identifies the panel to enable or disable.
|
|
606
|
+
*
|
|
607
|
+
* @return {Object} Action object.
|
|
608
|
+
*/
|
|
609
|
+
export const toggleEditorPanelEnabled = panelName => ({
|
|
610
|
+
registry
|
|
611
|
+
}) => {
|
|
612
|
+
var _registry$select$get;
|
|
613
|
+
const inactivePanels = (_registry$select$get = registry.select(preferencesStore).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
|
|
614
|
+
const isPanelInactive = !!inactivePanels?.includes(panelName);
|
|
615
|
+
|
|
616
|
+
// If the panel is inactive, remove it to enable it, else add it to
|
|
617
|
+
// make it inactive.
|
|
618
|
+
let updatedInactivePanels;
|
|
619
|
+
if (isPanelInactive) {
|
|
620
|
+
updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
|
|
621
|
+
} else {
|
|
622
|
+
updatedInactivePanels = [...inactivePanels, panelName];
|
|
623
|
+
}
|
|
624
|
+
registry.dispatch(preferencesStore).set('core', 'inactivePanels', updatedInactivePanels);
|
|
625
|
+
};
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Opens a closed panel and closes an open panel.
|
|
629
|
+
*
|
|
630
|
+
* @param {string} panelName A string that identifies the panel to open or close.
|
|
631
|
+
*/
|
|
632
|
+
export const toggleEditorPanelOpened = panelName => ({
|
|
633
|
+
registry
|
|
634
|
+
}) => {
|
|
635
|
+
var _registry$select$get2;
|
|
636
|
+
const openPanels = (_registry$select$get2 = registry.select(preferencesStore).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
|
|
637
|
+
const isPanelOpen = !!openPanels?.includes(panelName);
|
|
638
|
+
|
|
639
|
+
// If the panel is open, remove it to close it, else add it to
|
|
640
|
+
// make it open.
|
|
641
|
+
let updatedOpenPanels;
|
|
642
|
+
if (isPanelOpen) {
|
|
643
|
+
updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
|
|
644
|
+
} else {
|
|
645
|
+
updatedOpenPanels = [...openPanels, panelName];
|
|
646
|
+
}
|
|
647
|
+
registry.dispatch(preferencesStore).set('core', 'openPanels', updatedOpenPanels);
|
|
648
|
+
};
|
|
649
|
+
|
|
650
|
+
/**
|
|
651
|
+
* Returns an action object used to remove a panel from the editor.
|
|
652
|
+
*
|
|
653
|
+
* @param {string} panelName A string that identifies the panel to remove.
|
|
654
|
+
*
|
|
655
|
+
* @return {Object} Action object.
|
|
656
|
+
*/
|
|
657
|
+
export function removeEditorPanel(panelName) {
|
|
658
|
+
return {
|
|
659
|
+
type: 'REMOVE_PANEL',
|
|
660
|
+
panelName
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/**
|
|
665
|
+
* Returns an action object used to open/close the inserter.
|
|
666
|
+
*
|
|
667
|
+
* @param {boolean|Object} value Whether the inserter should be
|
|
668
|
+
* opened (true) or closed (false).
|
|
669
|
+
* To specify an insertion point,
|
|
670
|
+
* use an object.
|
|
671
|
+
* @param {string} value.rootClientId The root client ID to insert at.
|
|
672
|
+
* @param {number} value.insertionIndex The index to insert at.
|
|
673
|
+
*
|
|
674
|
+
* @return {Object} Action object.
|
|
675
|
+
*/
|
|
676
|
+
export function setIsInserterOpened(value) {
|
|
677
|
+
return {
|
|
678
|
+
type: 'SET_IS_INSERTER_OPENED',
|
|
679
|
+
value
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* Returns an action object used to open/close the list view.
|
|
685
|
+
*
|
|
686
|
+
* @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
|
|
687
|
+
* @return {Object} Action object.
|
|
688
|
+
*/
|
|
689
|
+
export function setIsListViewOpened(isOpen) {
|
|
690
|
+
return {
|
|
691
|
+
type: 'SET_IS_LIST_VIEW_OPENED',
|
|
692
|
+
isOpen
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
|
|
558
696
|
/**
|
|
559
697
|
* Backward compatibility
|
|
560
698
|
*/
|