@wordpress/editor 14.33.3 → 14.34.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 +2 -0
- package/build/components/collab-sidebar/comment-author-info.js +26 -14
- package/build/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build/components/document-bar/index.js +16 -3
- package/build/components/document-bar/index.js.map +2 -2
- package/build/components/editor/index.js +23 -4
- package/build/components/editor/index.js.map +3 -3
- package/build/components/editor-interface/index.js +15 -10
- package/build/components/editor-interface/index.js.map +3 -3
- package/build/components/entities-saved-states/entity-type-list.js +19 -15
- package/build/components/entities-saved-states/entity-type-list.js.map +3 -3
- package/build/components/global-styles/block-link.js +70 -0
- package/build/components/global-styles/block-link.js.map +7 -0
- package/build/components/global-styles/header.js +54 -0
- package/build/components/global-styles/header.js.map +7 -0
- package/build/components/global-styles/hooks.js +176 -0
- package/build/components/global-styles/hooks.js.map +7 -0
- package/build/components/global-styles/index.js +138 -0
- package/build/components/global-styles/index.js.map +7 -0
- package/build/components/global-styles/menu.js +95 -0
- package/build/components/global-styles/menu.js.map +7 -0
- package/build/components/global-styles-provider/index.js +3 -49
- package/build/components/global-styles-provider/index.js.map +3 -3
- package/build/components/global-styles-renderer/index.js +55 -0
- package/build/components/global-styles-renderer/index.js.map +7 -0
- package/build/components/global-styles-sidebar/default-sidebar.js +66 -0
- package/build/components/global-styles-sidebar/default-sidebar.js.map +7 -0
- package/build/components/global-styles-sidebar/index.js +182 -0
- package/build/components/global-styles-sidebar/index.js.map +7 -0
- package/build/components/global-styles-sidebar/welcome-guide-image.js +37 -0
- package/build/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
- package/build/components/global-styles-sidebar/welcome-guide.js +143 -0
- package/build/components/global-styles-sidebar/welcome-guide.js.map +7 -0
- package/build/components/header/index.js +12 -9
- package/build/components/header/index.js.map +2 -2
- package/build/components/post-featured-image/index.js +32 -1
- package/build/components/post-featured-image/index.js.map +3 -3
- package/build/components/provider/index.js +0 -2
- package/build/components/provider/index.js.map +3 -3
- package/build/components/style-book/categories.js +86 -0
- package/build/components/style-book/categories.js.map +7 -0
- package/build/components/style-book/color-examples.js +64 -0
- package/build/components/style-book/color-examples.js.map +7 -0
- package/build/components/style-book/constants.js +319 -0
- package/build/components/style-book/constants.js.map +7 -0
- package/build/components/style-book/duotone-examples.js +68 -0
- package/build/components/style-book/duotone-examples.js.map +7 -0
- package/build/components/style-book/examples.js +237 -0
- package/build/components/style-book/examples.js.map +7 -0
- package/build/components/style-book/index.js +627 -0
- package/build/components/style-book/index.js.map +7 -0
- package/build/components/style-book/types.js +17 -0
- package/build/components/style-book/types.js.map +7 -0
- package/build/components/styles-canvas/index.js +138 -0
- package/build/components/styles-canvas/index.js.map +7 -0
- package/build/components/styles-canvas/revisions.js +121 -0
- package/build/components/styles-canvas/revisions.js.map +7 -0
- package/build/components/styles-canvas/style-book.js +68 -0
- package/build/components/styles-canvas/style-book.js.map +7 -0
- package/build/components/visual-editor/index.js +4 -3
- package/build/components/visual-editor/index.js.map +2 -2
- package/build/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
- package/build/hooks/index.js +1 -0
- package/build/hooks/index.js.map +2 -2
- package/build/hooks/media-upload.js +15 -4
- package/build/hooks/media-upload.js.map +3 -3
- package/build/hooks/push-changes-to-global-styles/index.js +322 -0
- package/build/hooks/push-changes-to-global-styles/index.js.map +7 -0
- package/build/hooks/use-global-styles-output.js +74 -0
- package/build/hooks/use-global-styles-output.js.map +7 -0
- package/build/private-apis.js +10 -5
- package/build/private-apis.js.map +3 -3
- package/build/store/private-actions.js +23 -0
- package/build/store/private-actions.js.map +2 -2
- package/build/store/private-selectors.js +10 -0
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/reducer.js +24 -0
- package/build/store/reducer.js.map +2 -2
- package/build/{components/editor-interface/content-slot-fill.js → utils/set-nested-value.js} +24 -10
- package/build/utils/set-nested-value.js.map +7 -0
- package/build-module/components/collab-sidebar/comment-author-info.js +26 -14
- package/build-module/components/collab-sidebar/comment-author-info.js.map +2 -2
- package/build-module/components/document-bar/index.js +16 -3
- package/build-module/components/document-bar/index.js.map +2 -2
- package/build-module/components/editor/index.js +23 -4
- package/build-module/components/editor/index.js.map +2 -2
- package/build-module/components/editor-interface/index.js +15 -10
- package/build-module/components/editor-interface/index.js.map +2 -2
- package/build-module/components/entities-saved-states/entity-type-list.js +18 -14
- package/build-module/components/entities-saved-states/entity-type-list.js.map +2 -2
- package/build-module/components/global-styles/block-link.js +46 -0
- package/build-module/components/global-styles/block-link.js.map +7 -0
- package/build-module/components/global-styles/header.js +41 -0
- package/build-module/components/global-styles/header.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +154 -0
- package/build-module/components/global-styles/hooks.js.map +7 -0
- package/build-module/components/global-styles/index.js +112 -0
- package/build-module/components/global-styles/index.js.map +7 -0
- package/build-module/components/global-styles/menu.js +71 -0
- package/build-module/components/global-styles/menu.js.map +7 -0
- package/build-module/components/global-styles-provider/index.js +3 -37
- package/build-module/components/global-styles-provider/index.js.map +2 -2
- package/build-module/components/global-styles-renderer/index.js +31 -0
- package/build-module/components/global-styles-renderer/index.js.map +7 -0
- package/build-module/components/global-styles-sidebar/default-sidebar.js +49 -0
- package/build-module/components/global-styles-sidebar/default-sidebar.js.map +7 -0
- package/build-module/components/global-styles-sidebar/index.js +152 -0
- package/build-module/components/global-styles-sidebar/index.js.map +7 -0
- package/build-module/components/global-styles-sidebar/welcome-guide-image.js +17 -0
- package/build-module/components/global-styles-sidebar/welcome-guide-image.js.map +7 -0
- package/build-module/components/global-styles-sidebar/welcome-guide.js +113 -0
- package/build-module/components/global-styles-sidebar/welcome-guide.js.map +7 -0
- package/build-module/components/header/index.js +12 -9
- package/build-module/components/header/index.js.map +2 -2
- package/build-module/components/post-featured-image/index.js +35 -3
- package/build-module/components/post-featured-image/index.js.map +2 -2
- package/build-module/components/provider/index.js +0 -2
- package/build-module/components/provider/index.js.map +2 -2
- package/build-module/components/style-book/categories.js +64 -0
- package/build-module/components/style-book/categories.js.map +7 -0
- package/build-module/components/style-book/color-examples.js +37 -0
- package/build-module/components/style-book/color-examples.js.map +7 -0
- package/build-module/components/style-book/constants.js +290 -0
- package/build-module/components/style-book/constants.js.map +7 -0
- package/build-module/components/style-book/duotone-examples.js +48 -0
- package/build-module/components/style-book/duotone-examples.js.map +7 -0
- package/build-module/components/style-book/examples.js +208 -0
- package/build-module/components/style-book/examples.js.map +7 -0
- package/build-module/components/style-book/index.js +618 -0
- package/build-module/components/style-book/index.js.map +7 -0
- package/build-module/components/style-book/types.js +1 -0
- package/build-module/components/style-book/types.js.map +7 -0
- package/build-module/components/styles-canvas/index.js +104 -0
- package/build-module/components/styles-canvas/index.js.map +7 -0
- package/build-module/components/styles-canvas/revisions.js +107 -0
- package/build-module/components/styles-canvas/revisions.js.map +7 -0
- package/build-module/components/styles-canvas/style-book.js +38 -0
- package/build-module/components/styles-canvas/style-book.js.map +7 -0
- package/build-module/components/visual-editor/index.js +4 -3
- package/build-module/components/visual-editor/index.js.map +2 -2
- package/build-module/dataviews/fields/content-preview/content-preview-view.js.map +2 -2
- package/build-module/hooks/index.js +1 -0
- package/build-module/hooks/index.js.map +2 -2
- package/build-module/hooks/media-upload.js +19 -5
- package/build-module/hooks/media-upload.js.map +2 -2
- package/build-module/hooks/push-changes-to-global-styles/index.js +309 -0
- package/build-module/hooks/push-changes-to-global-styles/index.js.map +7 -0
- package/build-module/hooks/use-global-styles-output.js +49 -0
- package/build-module/hooks/use-global-styles-output.js.map +7 -0
- package/build-module/private-apis.js +10 -8
- package/build-module/private-apis.js.map +2 -2
- package/build-module/store/private-actions.js +20 -0
- package/build-module/store/private-actions.js.map +2 -2
- package/build-module/store/private-selectors.js +8 -0
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/reducer.js +22 -0
- package/build-module/store/reducer.js.map +2 -2
- package/build-module/utils/set-nested-value.js +23 -0
- package/build-module/utils/set-nested-value.js.map +7 -0
- package/build-style/style-rtl.css +3017 -11
- package/build-style/style.css +3018 -11
- package/build-types/components/collab-sidebar/comment-author-info.d.ts +5 -16
- package/build-types/components/collab-sidebar/comment-author-info.d.ts.map +1 -1
- package/build-types/components/document-bar/index.d.ts +2 -2
- package/build-types/components/document-bar/index.d.ts.map +1 -1
- package/build-types/components/editor/index.d.ts.map +1 -1
- package/build-types/components/editor-interface/index.d.ts +1 -3
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/entities-saved-states/entity-type-list.d.ts.map +1 -1
- package/build-types/components/global-styles/block-link.d.ts +12 -0
- package/build-types/components/global-styles/block-link.d.ts.map +1 -0
- package/build-types/components/global-styles/header.d.ts +7 -0
- package/build-types/components/global-styles/header.d.ts.map +1 -0
- package/build-types/components/global-styles/hooks.d.ts +24 -0
- package/build-types/components/global-styles/hooks.d.ts.map +1 -0
- package/build-types/components/global-styles/index.d.ts +6 -0
- package/build-types/components/global-styles/index.d.ts.map +1 -0
- package/build-types/components/global-styles/menu.d.ts +13 -0
- package/build-types/components/global-styles/menu.d.ts.map +1 -0
- package/build-types/components/global-styles-provider/index.d.ts +1 -5
- package/build-types/components/global-styles-provider/index.d.ts.map +1 -1
- package/build-types/components/global-styles-renderer/index.d.ts +4 -0
- package/build-types/components/global-styles-renderer/index.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts +13 -0
- package/build-types/components/global-styles-sidebar/default-sidebar.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/index.d.ts +2 -0
- package/build-types/components/global-styles-sidebar/index.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts +5 -0
- package/build-types/components/global-styles-sidebar/welcome-guide-image.d.ts.map +1 -0
- package/build-types/components/global-styles-sidebar/welcome-guide.d.ts +2 -0
- package/build-types/components/global-styles-sidebar/welcome-guide.d.ts.map +1 -0
- package/build-types/components/header/index.d.ts +1 -3
- package/build-types/components/header/index.d.ts.map +1 -1
- package/build-types/components/provider/index.d.ts.map +1 -1
- package/build-types/components/style-book/categories.d.ts +18 -0
- package/build-types/components/style-book/categories.d.ts.map +1 -0
- package/build-types/components/style-book/color-examples.d.ts +7 -0
- package/build-types/components/style-book/color-examples.d.ts.map +1 -0
- package/build-types/components/style-book/constants.d.ts +11 -0
- package/build-types/components/style-book/constants.d.ts.map +1 -0
- package/build-types/components/style-book/duotone-examples.d.ts +9 -0
- package/build-types/components/style-book/duotone-examples.d.ts.map +1 -0
- package/build-types/components/style-book/examples.d.ts +12 -0
- package/build-types/components/style-book/examples.d.ts.map +1 -0
- package/build-types/components/style-book/index.d.ts +31 -0
- package/build-types/components/style-book/index.d.ts.map +1 -0
- package/build-types/components/style-book/types.d.ts +72 -0
- package/build-types/components/style-book/types.d.ts.map +1 -0
- package/build-types/components/styles-canvas/index.d.ts +16 -0
- package/build-types/components/styles-canvas/index.d.ts.map +1 -0
- package/build-types/components/styles-canvas/revisions.d.ts +5 -0
- package/build-types/components/styles-canvas/revisions.d.ts.map +1 -0
- package/build-types/components/styles-canvas/style-book.d.ts +6 -0
- package/build-types/components/styles-canvas/style-book.d.ts.map +1 -0
- package/build-types/components/visual-editor/index.d.ts +1 -2
- package/build-types/components/visual-editor/index.d.ts.map +1 -1
- package/build-types/dataviews/fields/content-preview/content-preview-view.d.ts.map +1 -1
- package/build-types/hooks/push-changes-to-global-styles/index.d.ts +2 -0
- package/build-types/hooks/push-changes-to-global-styles/index.d.ts.map +1 -0
- package/build-types/hooks/use-global-styles-output.d.ts +18 -0
- package/build-types/hooks/use-global-styles-output.d.ts.map +1 -0
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/store/private-actions.d.ts +20 -0
- package/build-types/store/private-actions.d.ts.map +1 -1
- package/build-types/store/private-selectors.d.ts +14 -0
- package/build-types/store/private-selectors.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +20 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/utils/set-nested-value.d.ts +20 -0
- package/build-types/utils/set-nested-value.d.ts.map +1 -0
- package/package.json +40 -40
- package/src/components/collab-sidebar/comment-author-info.js +32 -25
- package/src/components/collab-sidebar/style.scss +1 -1
- package/src/components/document-bar/index.js +18 -3
- package/src/components/editor/index.js +25 -1
- package/src/components/editor-help/style.scss +1 -1
- package/src/components/editor-interface/index.js +40 -39
- package/src/components/entities-saved-states/entity-type-list.js +19 -17
- package/src/components/global-styles/block-link.js +65 -0
- package/src/components/global-styles/header.js +48 -0
- package/src/components/global-styles/hooks.js +216 -0
- package/src/components/global-styles/index.js +125 -0
- package/src/components/global-styles/menu.js +101 -0
- package/src/components/global-styles/style.scss +11 -0
- package/src/components/global-styles-provider/index.js +3 -45
- package/src/components/global-styles-renderer/index.js +39 -0
- package/src/components/global-styles-sidebar/default-sidebar.js +46 -0
- package/src/components/global-styles-sidebar/index.js +177 -0
- package/src/components/global-styles-sidebar/style.scss +119 -0
- package/src/components/global-styles-sidebar/welcome-guide-image.js +11 -0
- package/src/components/global-styles-sidebar/welcome-guide.js +136 -0
- package/src/components/header/index.js +11 -6
- package/src/components/post-featured-image/index.js +44 -1
- package/src/components/post-last-revision/style.scss +1 -1
- package/src/components/post-panel-row/style.scss +1 -0
- package/src/components/post-publish-panel/style.scss +1 -1
- package/src/components/post-publish-panel/test/__snapshots__/index.js.snap +2 -2
- package/src/components/provider/index.js +0 -2
- package/src/components/style-book/categories.ts +97 -0
- package/src/components/style-book/color-examples.tsx +56 -0
- package/src/components/style-book/constants.ts +308 -0
- package/src/components/style-book/duotone-examples.tsx +56 -0
- package/src/components/style-book/examples.tsx +273 -0
- package/src/components/style-book/index.js +794 -0
- package/src/components/style-book/style.scss +44 -0
- package/src/components/style-book/test/categories.js +166 -0
- package/src/components/style-book/types.ts +80 -0
- package/src/components/styles-canvas/index.js +126 -0
- package/src/components/styles-canvas/revisions.js +144 -0
- package/src/components/styles-canvas/style-book.js +57 -0
- package/src/components/styles-canvas/style.scss +40 -0
- package/src/components/visual-editor/index.js +2 -1
- package/src/dataviews/fields/content-preview/content-preview-view.tsx +2 -0
- package/src/hooks/index.js +1 -0
- package/src/hooks/media-upload.js +25 -5
- package/src/hooks/push-changes-to-global-styles/index.js +391 -0
- package/src/hooks/push-changes-to-global-styles/style.scss +4 -0
- package/src/hooks/use-global-styles-output.js +76 -0
- package/src/private-apis.js +10 -8
- package/src/store/private-actions.js +37 -0
- package/src/store/private-selectors.js +20 -0
- package/src/store/reducer.js +36 -0
- package/src/style.scss +7 -1
- package/src/utils/set-nested-value.js +39 -0
- package/tsconfig.json +3 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/block-settings-menu/content-only-settings-menu.js +0 -186
- package/build/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
- package/build/components/editor-interface/content-slot-fill.js.map +0 -7
- package/build-module/components/block-settings-menu/content-only-settings-menu.js +0 -161
- package/build-module/components/block-settings-menu/content-only-settings-menu.js.map +0 -7
- package/build-module/components/editor-interface/content-slot-fill.js +0 -9
- package/build-module/components/editor-interface/content-slot-fill.js.map +0 -7
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts +0 -2
- package/build-types/components/block-settings-menu/content-only-settings-menu.d.ts.map +0 -1
- package/build-types/components/editor-interface/content-slot-fill.d.ts +0 -14
- package/build-types/components/editor-interface/content-slot-fill.d.ts.map +0 -1
- package/src/components/block-settings-menu/content-only-settings-menu.js +0 -185
- package/src/components/block-settings-menu/content-only-settings-menu.native.js +0 -4
- package/src/components/block-settings-menu/style.scss +0 -6
- package/src/components/editor-interface/content-slot-fill.js +0 -10
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
// @wordpress/blocks imports are not typed.
|
|
5
|
+
// @ts-expect-error
|
|
6
|
+
import { getCategories } from '@wordpress/blocks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import type {
|
|
12
|
+
BlockExample,
|
|
13
|
+
StyleBookCategory,
|
|
14
|
+
CategoryExamples,
|
|
15
|
+
} from './types';
|
|
16
|
+
import {
|
|
17
|
+
STYLE_BOOK_CATEGORIES,
|
|
18
|
+
STYLE_BOOK_THEME_SUBCATEGORIES,
|
|
19
|
+
} from './constants';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Returns category examples for a given category definition and list of examples.
|
|
23
|
+
* @param {StyleBookCategory} categoryDefinition The category definition.
|
|
24
|
+
* @param {BlockExample[]} examples An array of block examples.
|
|
25
|
+
* @return {CategoryExamples|undefined} An object containing the category examples.
|
|
26
|
+
*/
|
|
27
|
+
export function getExamplesByCategory(
|
|
28
|
+
categoryDefinition: StyleBookCategory,
|
|
29
|
+
examples: BlockExample[]
|
|
30
|
+
): CategoryExamples | undefined {
|
|
31
|
+
if ( ! categoryDefinition?.slug || ! examples?.length ) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
const categories: CategoryExamples[] =
|
|
35
|
+
categoryDefinition?.subcategories ?? [];
|
|
36
|
+
if ( categories.length ) {
|
|
37
|
+
return categories.reduce(
|
|
38
|
+
( acc, subcategoryDefinition ) => {
|
|
39
|
+
const subcategoryExamples = getExamplesByCategory(
|
|
40
|
+
subcategoryDefinition,
|
|
41
|
+
examples
|
|
42
|
+
);
|
|
43
|
+
if ( subcategoryExamples ) {
|
|
44
|
+
if ( ! acc.subcategories ) {
|
|
45
|
+
acc.subcategories = [];
|
|
46
|
+
}
|
|
47
|
+
acc.subcategories = [
|
|
48
|
+
...acc.subcategories,
|
|
49
|
+
subcategoryExamples,
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
return acc;
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
title: categoryDefinition.title,
|
|
56
|
+
slug: categoryDefinition.slug,
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const blocksToInclude = categoryDefinition?.blocks || [];
|
|
62
|
+
const blocksToExclude = categoryDefinition?.exclude || [];
|
|
63
|
+
const categoryExamples = examples.filter( ( example ) => {
|
|
64
|
+
return (
|
|
65
|
+
! blocksToExclude.includes( example.name ) &&
|
|
66
|
+
( example.category === categoryDefinition.slug ||
|
|
67
|
+
blocksToInclude.includes( example.name ) )
|
|
68
|
+
);
|
|
69
|
+
} );
|
|
70
|
+
|
|
71
|
+
if ( ! categoryExamples.length ) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
title: categoryDefinition.title,
|
|
77
|
+
slug: categoryDefinition.slug,
|
|
78
|
+
examples: categoryExamples,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns category examples for a given category definition and list of examples.
|
|
84
|
+
*
|
|
85
|
+
* @return {StyleBookCategory[]} An array of top-level category definitions.
|
|
86
|
+
*/
|
|
87
|
+
export function getTopLevelStyleBookCategories(): StyleBookCategory[] {
|
|
88
|
+
const reservedCategories = [
|
|
89
|
+
...STYLE_BOOK_THEME_SUBCATEGORIES,
|
|
90
|
+
...STYLE_BOOK_CATEGORIES,
|
|
91
|
+
].map( ( { slug } ) => slug );
|
|
92
|
+
const extraCategories: StyleBookCategory[] = getCategories();
|
|
93
|
+
const extraCategoriesFiltered = extraCategories.filter(
|
|
94
|
+
( { slug } ) => ! reservedCategories.includes( slug )
|
|
95
|
+
);
|
|
96
|
+
return [ ...STYLE_BOOK_CATEGORIES, ...extraCategoriesFiltered ];
|
|
97
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import clsx from 'clsx';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __experimentalGrid as Grid } from '@wordpress/components';
|
|
10
|
+
import {
|
|
11
|
+
getColorClassName,
|
|
12
|
+
__experimentalGetGradientClass,
|
|
13
|
+
// @wordpress/block-editor imports are not typed.
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
} from '@wordpress/block-editor';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Internal dependencies
|
|
19
|
+
*/
|
|
20
|
+
import type { Color, Gradient, ColorExampleProps } from './types';
|
|
21
|
+
|
|
22
|
+
const ColorExamples = ( {
|
|
23
|
+
colors,
|
|
24
|
+
type,
|
|
25
|
+
templateColumns = '1fr 1fr',
|
|
26
|
+
itemHeight = '52px',
|
|
27
|
+
}: ColorExampleProps ): JSX.Element | null => {
|
|
28
|
+
if ( ! colors ) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<Grid templateColumns={ templateColumns } rowGap={ 8 } columnGap={ 16 }>
|
|
34
|
+
{ colors.map( ( color: Color | Gradient ) => {
|
|
35
|
+
const className =
|
|
36
|
+
type === 'gradients'
|
|
37
|
+
? __experimentalGetGradientClass( color.slug )
|
|
38
|
+
: getColorClassName( 'background-color', color.slug );
|
|
39
|
+
const classes = clsx(
|
|
40
|
+
'editor-style-book__color-example',
|
|
41
|
+
className
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
key={ color.slug }
|
|
47
|
+
className={ classes }
|
|
48
|
+
style={ { height: itemHeight } }
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
} ) }
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default ColorExamples;
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { StyleBookCategory, StyleBookColorGroup } from './types';
|
|
10
|
+
|
|
11
|
+
export const STYLE_BOOK_COLOR_GROUPS: StyleBookColorGroup[] = [
|
|
12
|
+
{
|
|
13
|
+
slug: 'theme-colors',
|
|
14
|
+
title: __( 'Theme Colors' ),
|
|
15
|
+
origin: 'theme',
|
|
16
|
+
type: 'colors',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
slug: 'theme-gradients',
|
|
20
|
+
title: __( 'Theme Gradients' ),
|
|
21
|
+
origin: 'theme',
|
|
22
|
+
type: 'gradients',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
slug: 'custom-colors',
|
|
26
|
+
title: __( 'Custom Colors' ),
|
|
27
|
+
origin: 'custom',
|
|
28
|
+
type: 'colors',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
slug: 'custom-gradients',
|
|
32
|
+
title: __( 'Custom Gradients' ),
|
|
33
|
+
origin: 'custom', // User.
|
|
34
|
+
type: 'gradients',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
slug: 'duotones',
|
|
38
|
+
title: __( 'Duotones' ),
|
|
39
|
+
origin: 'theme',
|
|
40
|
+
type: 'duotones',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
slug: 'default-colors',
|
|
44
|
+
title: __( 'Default Colors' ),
|
|
45
|
+
origin: 'default',
|
|
46
|
+
type: 'colors',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
slug: 'default-gradients',
|
|
50
|
+
title: __( 'Default Gradients' ),
|
|
51
|
+
origin: 'default',
|
|
52
|
+
type: 'gradients',
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export const STYLE_BOOK_THEME_SUBCATEGORIES: Omit<
|
|
57
|
+
StyleBookCategory,
|
|
58
|
+
'subcategories'
|
|
59
|
+
>[] = [
|
|
60
|
+
{
|
|
61
|
+
slug: 'site-identity',
|
|
62
|
+
title: __( 'Site Identity' ),
|
|
63
|
+
blocks: [ 'core/site-logo', 'core/site-title', 'core/site-tagline' ],
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
slug: 'design',
|
|
67
|
+
title: __( 'Design' ),
|
|
68
|
+
blocks: [ 'core/navigation', 'core/avatar', 'core/post-time-to-read' ],
|
|
69
|
+
exclude: [ 'core/home-link', 'core/navigation-link' ],
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
slug: 'posts',
|
|
73
|
+
title: __( 'Posts' ),
|
|
74
|
+
blocks: [
|
|
75
|
+
'core/post-title',
|
|
76
|
+
'core/post-excerpt',
|
|
77
|
+
'core/post-author',
|
|
78
|
+
'core/post-author-name',
|
|
79
|
+
'core/post-author-biography',
|
|
80
|
+
'core/post-date',
|
|
81
|
+
'core/post-terms',
|
|
82
|
+
'core/term-description',
|
|
83
|
+
'core/query-title',
|
|
84
|
+
'core/query-no-results',
|
|
85
|
+
'core/query-pagination',
|
|
86
|
+
'core/query-numbers',
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
slug: 'comments',
|
|
91
|
+
title: __( 'Comments' ),
|
|
92
|
+
blocks: [
|
|
93
|
+
'core/comments-title',
|
|
94
|
+
'core/comments-pagination',
|
|
95
|
+
'core/comments-pagination-numbers',
|
|
96
|
+
'core/comments',
|
|
97
|
+
'core/comments-author-name',
|
|
98
|
+
'core/comment-content',
|
|
99
|
+
'core/comment-date',
|
|
100
|
+
'core/comment-edit-link',
|
|
101
|
+
'core/comment-reply-link',
|
|
102
|
+
'core/comment-template',
|
|
103
|
+
'core/post-comments-count',
|
|
104
|
+
'core/post-comments-link',
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
|
|
109
|
+
export const STYLE_BOOK_CATEGORIES: StyleBookCategory[] = [
|
|
110
|
+
{
|
|
111
|
+
slug: 'overview',
|
|
112
|
+
title: __( 'Overview' ),
|
|
113
|
+
blocks: [],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
slug: 'text',
|
|
117
|
+
title: __( 'Text' ),
|
|
118
|
+
blocks: [
|
|
119
|
+
'core/post-content',
|
|
120
|
+
'core/home-link',
|
|
121
|
+
'core/navigation-link',
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
slug: 'colors',
|
|
126
|
+
title: __( 'Colors' ),
|
|
127
|
+
blocks: [],
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
slug: 'theme',
|
|
131
|
+
title: __( 'Theme' ),
|
|
132
|
+
subcategories: STYLE_BOOK_THEME_SUBCATEGORIES,
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
slug: 'media',
|
|
136
|
+
title: __( 'Media' ),
|
|
137
|
+
blocks: [ 'core/post-featured-image' ],
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
slug: 'widgets',
|
|
141
|
+
title: __( 'Widgets' ),
|
|
142
|
+
blocks: [],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
slug: 'embed',
|
|
146
|
+
title: __( 'Embeds' ),
|
|
147
|
+
include: [],
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
|
|
151
|
+
// Style book preview subcategories for all blocks section.
|
|
152
|
+
export const STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES: StyleBookCategory[] = [
|
|
153
|
+
...STYLE_BOOK_THEME_SUBCATEGORIES,
|
|
154
|
+
{
|
|
155
|
+
slug: 'media',
|
|
156
|
+
title: __( 'Media' ),
|
|
157
|
+
blocks: [ 'core/post-featured-image' ],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
slug: 'widgets',
|
|
161
|
+
title: __( 'Widgets' ),
|
|
162
|
+
blocks: [],
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
slug: 'embed',
|
|
166
|
+
title: __( 'Embeds' ),
|
|
167
|
+
include: [],
|
|
168
|
+
},
|
|
169
|
+
];
|
|
170
|
+
|
|
171
|
+
// Style book preview categories are organized slightly differently to the editor ones.
|
|
172
|
+
export const STYLE_BOOK_PREVIEW_CATEGORIES: StyleBookCategory[] = [
|
|
173
|
+
{
|
|
174
|
+
slug: 'overview',
|
|
175
|
+
title: __( 'Overview' ),
|
|
176
|
+
blocks: [],
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
slug: 'text',
|
|
180
|
+
title: __( 'Text' ),
|
|
181
|
+
blocks: [
|
|
182
|
+
'core/post-content',
|
|
183
|
+
'core/home-link',
|
|
184
|
+
'core/navigation-link',
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
slug: 'colors',
|
|
189
|
+
title: __( 'Colors' ),
|
|
190
|
+
blocks: [],
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
slug: 'blocks',
|
|
194
|
+
title: __( 'All Blocks' ),
|
|
195
|
+
blocks: [],
|
|
196
|
+
subcategories: STYLE_BOOK_ALL_BLOCKS_SUBCATEGORIES,
|
|
197
|
+
},
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
// Forming a "block formatting context" to prevent margin collapsing.
|
|
201
|
+
// @see https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Block_formatting_context
|
|
202
|
+
const ROOT_CONTAINER = `
|
|
203
|
+
.is-root-container {
|
|
204
|
+
display: flow-root;
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
// The content area of the Style Book is rendered within an iframe so that global styles
|
|
208
|
+
// are applied to elements within the entire content area. To support elements that are
|
|
209
|
+
// not part of the block previews, such as headings and layout for the block previews,
|
|
210
|
+
// additional CSS rules need to be passed into the iframe. These are hard-coded below.
|
|
211
|
+
// Note that button styles are unset, and then focus rules from the `Button` component are
|
|
212
|
+
// applied to the `button` element, targeted via `.editor-style-book__example`.
|
|
213
|
+
// This is to ensure that browser default styles for buttons are not applied to the previews.
|
|
214
|
+
export const STYLE_BOOK_IFRAME_STYLES = `
|
|
215
|
+
body {
|
|
216
|
+
position: relative;
|
|
217
|
+
padding: 32px !important;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
${ ROOT_CONTAINER }
|
|
221
|
+
|
|
222
|
+
.editor-style-book__examples {
|
|
223
|
+
max-width: 1200px;
|
|
224
|
+
margin: 0 auto;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.editor-style-book__example {
|
|
228
|
+
max-width: 900px;
|
|
229
|
+
border-radius: 2px;
|
|
230
|
+
cursor: pointer;
|
|
231
|
+
display: flex;
|
|
232
|
+
flex-direction: column;
|
|
233
|
+
gap: 40px;
|
|
234
|
+
padding: 16px;
|
|
235
|
+
width: 100%;
|
|
236
|
+
box-sizing: border-box;
|
|
237
|
+
scroll-margin-top: 32px;
|
|
238
|
+
scroll-margin-bottom: 32px;
|
|
239
|
+
margin: 0 auto 40px auto;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.editor-style-book__example.is-selected {
|
|
243
|
+
box-shadow: 0 0 0 1px var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.editor-style-book__example.is-disabled-example {
|
|
247
|
+
pointer-events: none;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.editor-style-book__example:focus:not(:disabled) {
|
|
251
|
+
box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
|
|
252
|
+
outline: 3px solid transparent;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
.editor-style-book__duotone-example > div:first-child {
|
|
256
|
+
display: flex;
|
|
257
|
+
aspect-ratio: 16 / 9;
|
|
258
|
+
grid-row: span 1;
|
|
259
|
+
grid-column: span 2;
|
|
260
|
+
}
|
|
261
|
+
.editor-style-book__duotone-example img {
|
|
262
|
+
width: 100%;
|
|
263
|
+
height: 100%;
|
|
264
|
+
object-fit: cover;
|
|
265
|
+
}
|
|
266
|
+
.editor-style-book__duotone-example > div:not(:first-child) {
|
|
267
|
+
height: 20px;
|
|
268
|
+
border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.editor-style-book__color-example {
|
|
272
|
+
border: 1px solid color-mix( in srgb, currentColor 10%, transparent );
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.editor-style-book__subcategory-title,
|
|
276
|
+
.editor-style-book__example-title {
|
|
277
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
|
|
278
|
+
font-size: 13px;
|
|
279
|
+
font-weight: normal;
|
|
280
|
+
line-height: normal;
|
|
281
|
+
margin: 0;
|
|
282
|
+
text-align: left;
|
|
283
|
+
padding-top: 8px;
|
|
284
|
+
border-top: 1px solid color-mix( in srgb, currentColor 10%, transparent );
|
|
285
|
+
color: color-mix( in srgb, currentColor 60%, transparent );
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.editor-style-book__subcategory-title {
|
|
289
|
+
font-size: 16px;
|
|
290
|
+
margin-bottom: 40px;
|
|
291
|
+
padding-bottom: 8px;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.editor-style-book__example-preview {
|
|
295
|
+
width: 100%;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.editor-style-book__example-preview .block-editor-block-list__insertion-point,
|
|
299
|
+
.editor-style-book__example-preview .block-list-appender {
|
|
300
|
+
display: none;
|
|
301
|
+
}
|
|
302
|
+
:where(.is-root-container > .wp-block:first-child) {
|
|
303
|
+
margin-top: 0;
|
|
304
|
+
}
|
|
305
|
+
:where(.is-root-container > .wp-block:last-child) {
|
|
306
|
+
margin-bottom: 0;
|
|
307
|
+
}
|
|
308
|
+
`;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { __experimentalGrid as Grid } from '@wordpress/components';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import type { Duotone } from './types';
|
|
10
|
+
|
|
11
|
+
const DuotoneExamples = ( {
|
|
12
|
+
duotones,
|
|
13
|
+
}: {
|
|
14
|
+
duotones: Duotone[];
|
|
15
|
+
} ): JSX.Element | null => {
|
|
16
|
+
if ( ! duotones ) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<Grid columns={ 2 } rowGap={ 16 } columnGap={ 16 }>
|
|
22
|
+
{ duotones.map( ( duotone: Duotone ) => {
|
|
23
|
+
return (
|
|
24
|
+
<Grid
|
|
25
|
+
key={ duotone.slug }
|
|
26
|
+
className="editor-style-book__duotone-example"
|
|
27
|
+
columns={ 2 }
|
|
28
|
+
rowGap={ 8 }
|
|
29
|
+
columnGap={ 8 }
|
|
30
|
+
>
|
|
31
|
+
<div>
|
|
32
|
+
<img
|
|
33
|
+
alt={ `Duotone example: ${ duotone.slug }` }
|
|
34
|
+
src="https://s.w.org/images/core/5.3/MtBlanc1.jpg"
|
|
35
|
+
style={ {
|
|
36
|
+
filter: `url(#wp-duotone-${ duotone.slug })`,
|
|
37
|
+
} }
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
40
|
+
{ duotone.colors.map( ( color ) => {
|
|
41
|
+
return (
|
|
42
|
+
<div
|
|
43
|
+
key={ color }
|
|
44
|
+
className="editor-style-book__color-example"
|
|
45
|
+
style={ { backgroundColor: color } }
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
} ) }
|
|
49
|
+
</Grid>
|
|
50
|
+
);
|
|
51
|
+
} ) }
|
|
52
|
+
</Grid>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default DuotoneExamples;
|