@wordpress/editor 13.30.0 → 13.32.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 +4 -0
- package/README.md +857 -0
- package/build/bindings/index.js +3 -1
- package/build/bindings/index.js.map +1 -1
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js +107 -0
- package/build/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
- package/build/components/commands/index.js +1 -1
- package/build/components/commands/index.js.map +1 -1
- package/build/components/deprecated.js +158 -0
- package/build/components/deprecated.js.map +1 -1
- package/build/components/document-bar/index.js +7 -10
- package/build/components/document-bar/index.js.map +1 -1
- package/build/components/document-outline/index.js +1 -1
- package/build/components/document-outline/index.js.map +1 -1
- package/build/components/editor-canvas/edit-template-blocks-notification.js +2 -39
- package/build/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build/components/editor-canvas/index.js +3 -0
- package/build/components/editor-canvas/index.js.map +1 -1
- package/build/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
- package/build/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build/components/entities-saved-states/index.js +28 -88
- package/build/components/entities-saved-states/index.js.map +1 -1
- package/build/components/error-boundary/index.native.js +133 -0
- package/build/components/error-boundary/index.native.js.map +1 -0
- package/build/components/index.js +33 -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 +5 -1
- package/build/components/inserter-sidebar/index.js.map +1 -1
- package/build/components/list-view-sidebar/index.js +2 -1
- package/build/components/list-view-sidebar/index.js.map +1 -1
- package/build/components/pattern-overrides-panel/index.js +30 -0
- package/build/components/pattern-overrides-panel/index.js.map +1 -0
- package/build/components/plugin-document-setting-panel/index.js +123 -0
- package/build/components/plugin-document-setting-panel/index.js.map +1 -0
- package/build/components/plugin-post-publish-panel/index.js +68 -0
- package/build/components/plugin-post-publish-panel/index.js.map +1 -0
- package/build/components/plugin-pre-publish-panel/index.js +71 -0
- package/build/components/plugin-pre-publish-panel/index.js.map +1 -0
- package/build/components/post-actions/actions.js +455 -0
- package/build/components/post-actions/actions.js.map +1 -0
- package/build/components/post-card-panel/index.js +93 -0
- package/build/components/post-card-panel/index.js.map +1 -0
- package/build/components/post-featured-image/index.js +3 -8
- package/build/components/post-featured-image/index.js.map +1 -1
- package/build/components/post-featured-image/panel.js +7 -3
- package/build/components/post-featured-image/panel.js.map +1 -1
- package/build/components/post-sync-status/index.js +0 -72
- package/build/components/post-sync-status/index.js.map +1 -1
- package/build/components/post-taxonomies/flat-term-selector.js +7 -3
- package/build/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build/components/post-title/index.native.js +1 -1
- package/build/components/post-title/index.native.js.map +1 -1
- package/build/components/provider/disable-non-page-content-blocks.js +36 -20
- package/build/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build/components/provider/index.js +1 -1
- package/build/components/provider/index.js.map +1 -1
- package/build/components/provider/use-block-editor-settings.js +8 -9
- package/build/components/provider/use-block-editor-settings.js.map +1 -1
- package/build/components/provider/use-hide-blocks-from-inserter.js +4 -3
- package/build/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build/components/template-areas/index.js +70 -0
- package/build/components/template-areas/index.js.map +1 -0
- package/build/hooks/use-select-nearest-editable-block.js +87 -0
- package/build/hooks/use-select-nearest-editable-block.js.map +1 -0
- package/build/private-apis.js +6 -2
- package/build/private-apis.js.map +1 -1
- package/build/store/actions.js +46 -6
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js +3 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/private-actions.js +80 -1
- package/build/store/private-actions.js.map +1 -1
- package/build/store/private-selectors.js +56 -3
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +14 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +21 -11
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils/get-filtered-template-parts.js +71 -0
- package/build/store/utils/get-filtered-template-parts.js.map +1 -0
- package/build-module/bindings/index.js +3 -1
- package/build-module/bindings/index.js.map +1 -1
- package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js +100 -0
- package/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js.map +1 -0
- package/build-module/components/commands/index.js +1 -1
- package/build-module/components/commands/index.js.map +1 -1
- package/build-module/components/deprecated.js +159 -0
- package/build-module/components/deprecated.js.map +1 -1
- package/build-module/components/document-bar/index.js +8 -11
- package/build-module/components/document-bar/index.js.map +1 -1
- package/build-module/components/document-outline/index.js +1 -1
- package/build-module/components/document-outline/index.js.map +1 -1
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js +4 -41
- package/build-module/components/editor-canvas/edit-template-blocks-notification.js.map +1 -1
- package/build-module/components/editor-canvas/index.js +3 -0
- package/build-module/components/editor-canvas/index.js.map +1 -1
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js +10 -16
- package/build-module/components/entities-saved-states/hooks/use-is-dirty.js.map +1 -1
- package/build-module/components/entities-saved-states/index.js +29 -89
- package/build-module/components/entities-saved-states/index.js.map +1 -1
- package/build-module/components/error-boundary/index.native.js +125 -0
- package/build-module/components/error-boundary/index.native.js.map +1 -0
- package/build-module/components/index.js +5 -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 +5 -1
- package/build-module/components/inserter-sidebar/index.js.map +1 -1
- package/build-module/components/list-view-sidebar/index.js +2 -1
- package/build-module/components/list-view-sidebar/index.js.map +1 -1
- package/build-module/components/pattern-overrides-panel/index.js +23 -0
- package/build-module/components/pattern-overrides-panel/index.js.map +1 -0
- package/build-module/components/plugin-document-setting-panel/index.js +115 -0
- package/build-module/components/plugin-document-setting-panel/index.js.map +1 -0
- package/build-module/components/plugin-post-publish-panel/index.js +61 -0
- package/build-module/components/plugin-post-publish-panel/index.js.map +1 -0
- package/build-module/components/plugin-pre-publish-panel/index.js +64 -0
- package/build-module/components/plugin-pre-publish-panel/index.js.map +1 -0
- package/build-module/components/post-actions/actions.js +444 -0
- package/build-module/components/post-actions/actions.js.map +1 -0
- package/build-module/components/post-card-panel/index.js +85 -0
- package/build-module/components/post-card-panel/index.js.map +1 -0
- package/build-module/components/post-featured-image/index.js +4 -9
- package/build-module/components/post-featured-image/index.js.map +1 -1
- package/build-module/components/post-featured-image/panel.js +6 -2
- package/build-module/components/post-featured-image/panel.js.map +1 -1
- package/build-module/components/post-sync-status/index.js +2 -73
- package/build-module/components/post-sync-status/index.js.map +1 -1
- package/build-module/components/post-taxonomies/flat-term-selector.js +7 -3
- package/build-module/components/post-taxonomies/flat-term-selector.js.map +1 -1
- package/build-module/components/post-title/index.native.js +1 -1
- package/build-module/components/post-title/index.native.js.map +1 -1
- package/build-module/components/provider/disable-non-page-content-blocks.js +36 -20
- package/build-module/components/provider/disable-non-page-content-blocks.js.map +1 -1
- package/build-module/components/provider/index.js +1 -1
- package/build-module/components/provider/index.js.map +1 -1
- package/build-module/components/provider/use-block-editor-settings.js +9 -10
- package/build-module/components/provider/use-block-editor-settings.js.map +1 -1
- package/build-module/components/provider/use-hide-blocks-from-inserter.js +4 -3
- package/build-module/components/provider/use-hide-blocks-from-inserter.js.map +1 -1
- package/build-module/components/template-areas/index.js +63 -0
- package/build-module/components/template-areas/index.js.map +1 -0
- package/build-module/hooks/use-select-nearest-editable-block.js +80 -0
- package/build-module/hooks/use-select-nearest-editable-block.js.map +1 -0
- package/build-module/private-apis.js +6 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/actions.js +37 -3
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js +2 -0
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/private-actions.js +78 -0
- package/build-module/store/private-actions.js.map +1 -1
- package/build-module/store/private-selectors.js +54 -3
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +13 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +19 -10
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils/get-filtered-template-parts.js +64 -0
- package/build-module/store/utils/get-filtered-template-parts.js.map +1 -0
- package/build-style/style-rtl.css +76 -33
- package/build-style/style.css +76 -33
- package/package.json +35 -33
- package/src/bindings/index.js +4 -1
- package/src/components/block-settings-menu/plugin-block-settings-menu-item.js +108 -0
- package/src/components/commands/index.js +1 -1
- package/src/components/deprecated.js +157 -0
- package/src/components/document-bar/index.js +12 -17
- package/src/components/document-bar/style.scss +9 -12
- package/src/components/document-outline/index.js +2 -1
- package/src/components/document-tools/style.scss +4 -11
- package/src/components/editor-canvas/edit-template-blocks-notification.js +6 -56
- package/src/components/editor-canvas/index.js +4 -0
- package/src/components/entities-saved-states/hooks/use-is-dirty.js +18 -22
- package/src/components/entities-saved-states/index.js +45 -121
- package/src/components/entities-saved-states/test/use-is-dirty.js +3 -0
- package/src/components/error-boundary/index.native.js +192 -0
- package/src/components/error-boundary/style.native.scss +116 -0
- package/src/components/index.js +5 -4
- package/src/components/index.native.js +1 -0
- package/src/components/inserter-sidebar/index.js +7 -1
- package/src/components/list-view-sidebar/index.js +1 -0
- package/src/components/list-view-sidebar/style.scss +1 -1
- package/src/components/pattern-overrides-panel/index.js +26 -0
- package/src/components/plugin-document-setting-panel/index.js +121 -0
- package/src/components/plugin-post-publish-panel/index.js +64 -0
- package/src/components/plugin-post-publish-panel/test/__snapshots__/index.js.snap +39 -0
- package/src/components/plugin-post-publish-panel/test/index.js +33 -0
- package/src/components/plugin-pre-publish-panel/index.js +67 -0
- package/src/components/plugin-pre-publish-panel/test/index.js +33 -0
- package/src/components/post-actions/actions.js +582 -0
- package/src/components/post-card-panel/index.js +108 -0
- package/src/components/post-card-panel/style.scss +32 -0
- package/src/components/post-featured-image/index.js +6 -15
- package/src/components/post-featured-image/panel.js +9 -3
- package/src/components/post-featured-image/style.scss +9 -13
- package/src/components/post-sync-status/index.js +1 -94
- package/src/components/post-taxonomies/flat-term-selector.js +13 -8
- package/src/components/post-title/index.native.js +1 -1
- package/src/components/provider/disable-non-page-content-blocks.js +40 -20
- package/src/components/provider/index.js +1 -1
- package/src/components/provider/test/disable-non-page-content-blocks.js +35 -14
- package/src/components/provider/use-block-editor-settings.js +11 -11
- package/src/components/provider/use-hide-blocks-from-inserter.js +5 -3
- package/src/components/template-areas/index.js +85 -0
- package/src/components/template-areas/style.scss +23 -0
- package/src/hooks/use-select-nearest-editable-block.js +95 -0
- package/src/private-apis.js +6 -2
- package/src/store/actions.js +37 -3
- package/src/store/constants.js +2 -0
- package/src/store/private-actions.js +111 -0
- package/src/store/private-selectors.js +105 -17
- package/src/store/reducer.js +13 -0
- package/src/store/selectors.js +50 -40
- package/src/store/utils/get-filtered-template-parts.js +69 -0
- package/src/store/utils/test/get-filtered-template-parts.js +189 -0
- package/src/style.scss +2 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.error-boundary__scroll {
|
|
2
|
+
height: 100%;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.error-boundary__scroll-container {
|
|
7
|
+
flex-grow: 1;
|
|
8
|
+
max-height: 580px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
.error-boundary__container {
|
|
15
|
+
width: 100%;
|
|
16
|
+
max-width: 600px;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
align-items: center;
|
|
19
|
+
padding: 0 24px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.error-boundary__icon-container {
|
|
23
|
+
$size: 40px;
|
|
24
|
+
|
|
25
|
+
width: $size;
|
|
26
|
+
height: $size;
|
|
27
|
+
align-items: center;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
margin-bottom: 8px;
|
|
30
|
+
background-color: rgba(60, 60, 67, 0.3);
|
|
31
|
+
border-radius: $size/2;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.error-boundary__icon-container--dark {
|
|
35
|
+
background-color: rgba(235, 235, 245, 0.3);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.error-boundary__icon {
|
|
39
|
+
width: 24px;
|
|
40
|
+
height: 24px;
|
|
41
|
+
fill: $white;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.error-boundary__title {
|
|
45
|
+
font-size: 20px;
|
|
46
|
+
font-weight: 600;
|
|
47
|
+
line-height: 25px;
|
|
48
|
+
color: $black;
|
|
49
|
+
text-align: center;
|
|
50
|
+
margin-bottom: 8px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.error-boundary__title--dark {
|
|
54
|
+
color: $white;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.error-boundary__message {
|
|
58
|
+
font-size: 16px;
|
|
59
|
+
font-weight: 400;
|
|
60
|
+
line-height: 21px;
|
|
61
|
+
color: rgba(60, 60, 67, 0.6);
|
|
62
|
+
text-align: center;
|
|
63
|
+
margin-bottom: 16px;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.error-boundary__message--dark {
|
|
67
|
+
color: rgba(235, 235, 245, 0.6);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.error-boundary__actions-container {
|
|
71
|
+
width: 100%;
|
|
72
|
+
max-width: 400px;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
gap: 12px;
|
|
75
|
+
padding-top: 16px;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.copy-button__container {
|
|
79
|
+
border-radius: 5px;
|
|
80
|
+
padding: $grid-unit $grid-unit-20;
|
|
81
|
+
background-color: $light-primary;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.copy-button__container--dark {
|
|
85
|
+
background-color: $white;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.copy-button__container--secondary {
|
|
89
|
+
border: 1px #c6c6c8;
|
|
90
|
+
background-color: $white;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.copy-button__container--secondary-dark {
|
|
94
|
+
border-color: rgba(255, 255, 255, 0.3);
|
|
95
|
+
background-color: $black;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.copy-button__text {
|
|
99
|
+
font-size: 17px;
|
|
100
|
+
font-weight: 400;
|
|
101
|
+
line-height: 22px;
|
|
102
|
+
text-align: center;
|
|
103
|
+
color: $white;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.copy-button__text--dark {
|
|
107
|
+
color: $background-dark-secondary;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.copy-button__text--secondary {
|
|
111
|
+
color: $black;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.copy-button__text--secondary-dark {
|
|
115
|
+
color: $white;
|
|
116
|
+
}
|
package/src/components/index.js
CHANGED
|
@@ -26,6 +26,10 @@ export { default as PageAttributesOrder } from './page-attributes/order';
|
|
|
26
26
|
export { default as PageAttributesPanel } from './page-attributes/panel';
|
|
27
27
|
export { default as PageAttributesParent } from './page-attributes/parent';
|
|
28
28
|
export { default as PageTemplate } from './post-template/classic-theme';
|
|
29
|
+
export { default as PluginDocumentSettingPanel } from './plugin-document-setting-panel';
|
|
30
|
+
export { default as PluginBlockSettingsMenuItem } from './block-settings-menu/plugin-block-settings-menu-item';
|
|
31
|
+
export { default as PluginPostPublishPanel } from './plugin-post-publish-panel';
|
|
32
|
+
export { default as PluginPrePublishPanel } from './plugin-pre-publish-panel';
|
|
29
33
|
export { default as PostTemplatePanel } from './post-template/panel';
|
|
30
34
|
export { default as PostAuthor } from './post-author';
|
|
31
35
|
export { default as PostAuthorCheck } from './post-author/check';
|
|
@@ -64,10 +68,7 @@ export { default as PostSlugCheck } from './post-slug/check';
|
|
|
64
68
|
export { default as PostSticky } from './post-sticky';
|
|
65
69
|
export { default as PostStickyCheck } from './post-sticky/check';
|
|
66
70
|
export { default as PostSwitchToDraftButton } from './post-switch-to-draft-button';
|
|
67
|
-
export {
|
|
68
|
-
default as PostSyncStatus,
|
|
69
|
-
PostSyncStatusModal,
|
|
70
|
-
} from './post-sync-status';
|
|
71
|
+
export { default as PostSyncStatus } from './post-sync-status';
|
|
71
72
|
export { default as PostTaxonomies } from './post-taxonomies';
|
|
72
73
|
export { FlatTermSelector as PostTaxonomiesFlatTermSelector } from './post-taxonomies/flat-term-selector';
|
|
73
74
|
export { HierarchicalTermSelector as PostTaxonomiesHierarchicalTermSelector } from './post-taxonomies/hierarchical-term-selector';
|
|
@@ -10,5 +10,6 @@ export { default as EditorProvider } from './provider';
|
|
|
10
10
|
// Other Components.
|
|
11
11
|
export { default as EditorHelpTopics } from './editor-help';
|
|
12
12
|
export { default as OfflineStatus } from './offline-status';
|
|
13
|
+
export { default as ErrorBoundary } from './error-boundary';
|
|
13
14
|
|
|
14
15
|
export * from './deprecated';
|
|
@@ -19,7 +19,10 @@ import { store as preferencesStore } from '@wordpress/preferences';
|
|
|
19
19
|
import { unlock } from '../../lock-unlock';
|
|
20
20
|
import { store as editorStore } from '../../store';
|
|
21
21
|
|
|
22
|
-
export default function InserterSidebar(
|
|
22
|
+
export default function InserterSidebar( {
|
|
23
|
+
closeGeneralSidebar,
|
|
24
|
+
isRightSidebarOpen,
|
|
25
|
+
} ) {
|
|
23
26
|
const { insertionPoint, showMostUsedBlocks } = useSelect( ( select ) => {
|
|
24
27
|
const { getInsertionPoint } = unlock( select( editorStore ) );
|
|
25
28
|
const { get } = select( preferencesStore );
|
|
@@ -65,6 +68,9 @@ export default function InserterSidebar() {
|
|
|
65
68
|
insertionPoint.insertionIndex
|
|
66
69
|
}
|
|
67
70
|
__experimentalFilterValue={ insertionPoint.filterValue }
|
|
71
|
+
__experimentalOnPatternCategorySelection={
|
|
72
|
+
isRightSidebarOpen ? closeGeneralSidebar : undefined
|
|
73
|
+
}
|
|
68
74
|
ref={ libraryRef }
|
|
69
75
|
/>
|
|
70
76
|
</div>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useSelect } from '@wordpress/data';
|
|
5
|
+
import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { store as editorStore } from '../../store';
|
|
11
|
+
import { unlock } from '../../lock-unlock';
|
|
12
|
+
|
|
13
|
+
const { OverridesPanel } = unlock( patternsPrivateApis );
|
|
14
|
+
|
|
15
|
+
export default function PatternOverridesPanel() {
|
|
16
|
+
const supportsPatternOverridesPanel = useSelect(
|
|
17
|
+
( select ) => select( editorStore ).getCurrentPostType() === 'wp_block',
|
|
18
|
+
[]
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
if ( ! supportsPatternOverridesPanel ) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return <OverridesPanel />;
|
|
26
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createSlotFill, PanelBody } from '@wordpress/components';
|
|
5
|
+
import { usePluginContext } from '@wordpress/plugins';
|
|
6
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
7
|
+
import warning from '@wordpress/warning';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import EnablePluginDocumentSettingPanelOption from '../preferences-modal/enable-plugin-document-setting-panel';
|
|
13
|
+
import { store as editorStore } from '../../store';
|
|
14
|
+
|
|
15
|
+
const { Fill, Slot } = createSlotFill( 'PluginDocumentSettingPanel' );
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Renders items below the Status & Availability panel in the Document Sidebar.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props Component properties.
|
|
21
|
+
* @param {string} props.name Required. A machine-friendly name for the panel.
|
|
22
|
+
* @param {string} [props.className] An optional class name added to the row.
|
|
23
|
+
* @param {string} [props.title] The title of the panel
|
|
24
|
+
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
|
|
25
|
+
* @param {Element} props.children Children to be rendered
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```js
|
|
29
|
+
* // Using ES5 syntax
|
|
30
|
+
* var el = React.createElement;
|
|
31
|
+
* var __ = wp.i18n.__;
|
|
32
|
+
* var registerPlugin = wp.plugins.registerPlugin;
|
|
33
|
+
* var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
|
|
34
|
+
*
|
|
35
|
+
* function MyDocumentSettingPlugin() {
|
|
36
|
+
* return el(
|
|
37
|
+
* PluginDocumentSettingPanel,
|
|
38
|
+
* {
|
|
39
|
+
* className: 'my-document-setting-plugin',
|
|
40
|
+
* title: 'My Panel',
|
|
41
|
+
* name: 'my-panel',
|
|
42
|
+
* },
|
|
43
|
+
* __( 'My Document Setting Panel' )
|
|
44
|
+
* );
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* registerPlugin( 'my-document-setting-plugin', {
|
|
48
|
+
* render: MyDocumentSettingPlugin
|
|
49
|
+
* } );
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```jsx
|
|
54
|
+
* // Using ESNext syntax
|
|
55
|
+
* import { registerPlugin } from '@wordpress/plugins';
|
|
56
|
+
* import { PluginDocumentSettingPanel } from '@wordpress/editor';
|
|
57
|
+
*
|
|
58
|
+
* const MyDocumentSettingTest = () => (
|
|
59
|
+
* <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
|
|
60
|
+
* <p>My Document Setting Panel</p>
|
|
61
|
+
* </PluginDocumentSettingPanel>
|
|
62
|
+
* );
|
|
63
|
+
*
|
|
64
|
+
* registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @return {Component} The component to be rendered.
|
|
68
|
+
*/
|
|
69
|
+
const PluginDocumentSettingPanel = ( {
|
|
70
|
+
name,
|
|
71
|
+
className,
|
|
72
|
+
title,
|
|
73
|
+
icon,
|
|
74
|
+
children,
|
|
75
|
+
} ) => {
|
|
76
|
+
const { name: pluginName } = usePluginContext();
|
|
77
|
+
const panelName = `${ pluginName }/${ name }`;
|
|
78
|
+
const { opened, isEnabled } = useSelect(
|
|
79
|
+
( select ) => {
|
|
80
|
+
const { isEditorPanelOpened, isEditorPanelEnabled } =
|
|
81
|
+
select( editorStore );
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
opened: isEditorPanelOpened( panelName ),
|
|
85
|
+
isEnabled: isEditorPanelEnabled( panelName ),
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
[ panelName ]
|
|
89
|
+
);
|
|
90
|
+
const { toggleEditorPanelOpened } = useDispatch( editorStore );
|
|
91
|
+
|
|
92
|
+
if ( undefined === name ) {
|
|
93
|
+
warning( 'PluginDocumentSettingPanel requires a name property.' );
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<EnablePluginDocumentSettingPanelOption
|
|
99
|
+
label={ title }
|
|
100
|
+
panelName={ panelName }
|
|
101
|
+
/>
|
|
102
|
+
<Fill>
|
|
103
|
+
{ isEnabled && (
|
|
104
|
+
<PanelBody
|
|
105
|
+
className={ className }
|
|
106
|
+
title={ title }
|
|
107
|
+
icon={ icon }
|
|
108
|
+
opened={ opened }
|
|
109
|
+
onToggle={ () => toggleEditorPanelOpened( panelName ) }
|
|
110
|
+
>
|
|
111
|
+
{ children }
|
|
112
|
+
</PanelBody>
|
|
113
|
+
) }
|
|
114
|
+
</Fill>
|
|
115
|
+
</>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
PluginDocumentSettingPanel.Slot = Slot;
|
|
120
|
+
|
|
121
|
+
export default PluginDocumentSettingPanel;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { usePluginContext } from '@wordpress/plugins';
|
|
5
|
+
import { createSlotFill, PanelBody } from '@wordpress/components';
|
|
6
|
+
|
|
7
|
+
const { Fill, Slot } = createSlotFill( 'PluginPostPublishPanel' );
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders provided content to the post-publish panel in the publish flow
|
|
11
|
+
* (side panel that opens after a user publishes the post).
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} props Component properties.
|
|
14
|
+
* @param {string} [props.className] An optional class name added to the panel.
|
|
15
|
+
* @param {string} [props.title] Title displayed at the top of the panel.
|
|
16
|
+
* @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
|
|
17
|
+
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
|
|
18
|
+
* @param {Element} props.children Children to be rendered
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```jsx
|
|
22
|
+
* // Using ESNext syntax
|
|
23
|
+
* import { __ } from '@wordpress/i18n';
|
|
24
|
+
* import { PluginPostPublishPanel } from '@wordpress/edit-post';
|
|
25
|
+
*
|
|
26
|
+
* const MyPluginPostPublishPanel = () => (
|
|
27
|
+
* <PluginPostPublishPanel
|
|
28
|
+
* className="my-plugin-post-publish-panel"
|
|
29
|
+
* title={ __( 'My panel title' ) }
|
|
30
|
+
* initialOpen={ true }
|
|
31
|
+
* >
|
|
32
|
+
* { __( 'My panel content' ) }
|
|
33
|
+
* </PluginPostPublishPanel>
|
|
34
|
+
* );
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @return {Component} The component to be rendered.
|
|
38
|
+
*/
|
|
39
|
+
const PluginPostPublishPanel = ( {
|
|
40
|
+
children,
|
|
41
|
+
className,
|
|
42
|
+
title,
|
|
43
|
+
initialOpen = false,
|
|
44
|
+
icon,
|
|
45
|
+
} ) => {
|
|
46
|
+
const { icon: pluginIcon } = usePluginContext();
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Fill>
|
|
50
|
+
<PanelBody
|
|
51
|
+
className={ className }
|
|
52
|
+
initialOpen={ initialOpen || ! title }
|
|
53
|
+
title={ title }
|
|
54
|
+
icon={ icon ?? pluginIcon }
|
|
55
|
+
>
|
|
56
|
+
{ children }
|
|
57
|
+
</PanelBody>
|
|
58
|
+
</Fill>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
PluginPostPublishPanel.Slot = Slot;
|
|
63
|
+
|
|
64
|
+
export default PluginPostPublishPanel;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`PluginPostPublishPanel renders fill properly 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<div
|
|
6
|
+
class="components-panel__body my-plugin-post-publish-panel is-opened"
|
|
7
|
+
>
|
|
8
|
+
<h2
|
|
9
|
+
class="components-panel__body-title"
|
|
10
|
+
>
|
|
11
|
+
<button
|
|
12
|
+
aria-expanded="true"
|
|
13
|
+
class="components-button components-panel__body-toggle"
|
|
14
|
+
type="button"
|
|
15
|
+
>
|
|
16
|
+
<span
|
|
17
|
+
aria-hidden="true"
|
|
18
|
+
>
|
|
19
|
+
<svg
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
class="components-panel__arrow"
|
|
22
|
+
focusable="false"
|
|
23
|
+
height="24"
|
|
24
|
+
viewBox="0 0 24 24"
|
|
25
|
+
width="24"
|
|
26
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
27
|
+
>
|
|
28
|
+
<path
|
|
29
|
+
d="M6.5 12.4L12 8l5.5 4.4-.9 1.2L12 10l-4.5 3.6-1-1.2z"
|
|
30
|
+
/>
|
|
31
|
+
</svg>
|
|
32
|
+
</span>
|
|
33
|
+
My panel title
|
|
34
|
+
</button>
|
|
35
|
+
</h2>
|
|
36
|
+
My panel content
|
|
37
|
+
</div>
|
|
38
|
+
</div>
|
|
39
|
+
`;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import PluginPostPublishPanel from '../';
|
|
15
|
+
|
|
16
|
+
describe( 'PluginPostPublishPanel', () => {
|
|
17
|
+
test( 'renders fill properly', () => {
|
|
18
|
+
const { container } = render(
|
|
19
|
+
<SlotFillProvider>
|
|
20
|
+
<PluginPostPublishPanel
|
|
21
|
+
className="my-plugin-post-publish-panel"
|
|
22
|
+
title="My panel title"
|
|
23
|
+
initialOpen
|
|
24
|
+
>
|
|
25
|
+
My panel content
|
|
26
|
+
</PluginPostPublishPanel>
|
|
27
|
+
<PluginPostPublishPanel.Slot />
|
|
28
|
+
</SlotFillProvider>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect( container ).toMatchSnapshot();
|
|
32
|
+
} );
|
|
33
|
+
} );
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { createSlotFill, PanelBody } from '@wordpress/components';
|
|
5
|
+
import { usePluginContext } from '@wordpress/plugins';
|
|
6
|
+
|
|
7
|
+
const { Fill, Slot } = createSlotFill( 'PluginPrePublishPanel' );
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders provided content to the pre-publish side panel in the publish flow
|
|
11
|
+
* (side panel that opens when a user first pushes "Publish" from the main editor).
|
|
12
|
+
*
|
|
13
|
+
* @param {Object} props Component props.
|
|
14
|
+
* @param {string} [props.className] An optional class name added to the panel.
|
|
15
|
+
* @param {string} [props.title] Title displayed at the top of the panel.
|
|
16
|
+
* @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
|
|
17
|
+
* When no title is provided it is always opened.
|
|
18
|
+
* @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
|
|
19
|
+
* icon slug string, or an SVG WP element, to be rendered when
|
|
20
|
+
* the sidebar is pinned to toolbar.
|
|
21
|
+
* @param {Element} props.children Children to be rendered
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```jsx
|
|
25
|
+
* // Using ESNext syntax
|
|
26
|
+
* import { __ } from '@wordpress/i18n';
|
|
27
|
+
* import { PluginPrePublishPanel } from '@wordpress/edit-post';
|
|
28
|
+
*
|
|
29
|
+
* const MyPluginPrePublishPanel = () => (
|
|
30
|
+
* <PluginPrePublishPanel
|
|
31
|
+
* className="my-plugin-pre-publish-panel"
|
|
32
|
+
* title={ __( 'My panel title' ) }
|
|
33
|
+
* initialOpen={ true }
|
|
34
|
+
* >
|
|
35
|
+
* { __( 'My panel content' ) }
|
|
36
|
+
* </PluginPrePublishPanel>
|
|
37
|
+
* );
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @return {Component} The component to be rendered.
|
|
41
|
+
*/
|
|
42
|
+
const PluginPrePublishPanel = ( {
|
|
43
|
+
children,
|
|
44
|
+
className,
|
|
45
|
+
title,
|
|
46
|
+
initialOpen = false,
|
|
47
|
+
icon,
|
|
48
|
+
} ) => {
|
|
49
|
+
const { icon: pluginIcon } = usePluginContext();
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Fill>
|
|
53
|
+
<PanelBody
|
|
54
|
+
className={ className }
|
|
55
|
+
initialOpen={ initialOpen || ! title }
|
|
56
|
+
title={ title }
|
|
57
|
+
icon={ icon ?? pluginIcon }
|
|
58
|
+
>
|
|
59
|
+
{ children }
|
|
60
|
+
</PanelBody>
|
|
61
|
+
</Fill>
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
PluginPrePublishPanel.Slot = Slot;
|
|
66
|
+
|
|
67
|
+
export default PluginPrePublishPanel;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { SlotFillProvider } from '@wordpress/components';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Internal dependencies
|
|
13
|
+
*/
|
|
14
|
+
import PluginPrePublishPanel from '../';
|
|
15
|
+
|
|
16
|
+
describe( 'PluginPrePublishPanel', () => {
|
|
17
|
+
test( 'renders fill properly', () => {
|
|
18
|
+
render(
|
|
19
|
+
<SlotFillProvider>
|
|
20
|
+
<PluginPrePublishPanel
|
|
21
|
+
className="my-plugin-pre-publish-panel"
|
|
22
|
+
title="My panel title"
|
|
23
|
+
initialOpen
|
|
24
|
+
>
|
|
25
|
+
My panel content
|
|
26
|
+
</PluginPrePublishPanel>
|
|
27
|
+
<PluginPrePublishPanel.Slot />
|
|
28
|
+
</SlotFillProvider>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
expect( screen.getByText( 'My panel title' ) ).toBeVisible();
|
|
32
|
+
} );
|
|
33
|
+
} );
|