@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,627 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var style_book_exports = {};
|
|
30
|
+
__export(style_book_exports, {
|
|
31
|
+
StyleBookBody: () => StyleBookBody,
|
|
32
|
+
StyleBookPreview: () => StyleBookPreview,
|
|
33
|
+
default: () => style_book_default,
|
|
34
|
+
getExamplesForSinglePageUse: () => getExamplesForSinglePageUse
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(style_book_exports);
|
|
37
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
38
|
+
var import_clsx = __toESM(require("clsx"));
|
|
39
|
+
var import_components = require("@wordpress/components");
|
|
40
|
+
var import_i18n = require("@wordpress/i18n");
|
|
41
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
42
|
+
var import_data = require("@wordpress/data");
|
|
43
|
+
var import_global_styles_engine = require("@wordpress/global-styles-engine");
|
|
44
|
+
var import_element = require("@wordpress/element");
|
|
45
|
+
var import_keycodes = require("@wordpress/keycodes");
|
|
46
|
+
var import_media_utils = require("@wordpress/media-utils");
|
|
47
|
+
var import_core_data = require("@wordpress/core-data");
|
|
48
|
+
var import_lock_unlock = require("../../lock-unlock");
|
|
49
|
+
var import_constants = require("./constants");
|
|
50
|
+
var import_categories = require("./categories");
|
|
51
|
+
var import_examples = require("./examples");
|
|
52
|
+
var import_global_styles_renderer = require("../global-styles-renderer");
|
|
53
|
+
var import_constants2 = require("../style-book/constants");
|
|
54
|
+
var import_use_global_styles_output = require("../../hooks/use-global-styles-output");
|
|
55
|
+
var import_global_styles = require("../global-styles");
|
|
56
|
+
var import_store = require("../../store");
|
|
57
|
+
const { ExperimentalBlockEditorProvider } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
58
|
+
const { Tabs } = (0, import_lock_unlock.unlock)(import_components.privateApis);
|
|
59
|
+
function isObjectEmpty(object) {
|
|
60
|
+
return !object || Object.keys(object).length === 0;
|
|
61
|
+
}
|
|
62
|
+
const scrollToSection = (anchorId, iframe) => {
|
|
63
|
+
if (!anchorId || !iframe || !iframe?.contentDocument) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const element = anchorId === "top" ? iframe.contentDocument.body : iframe.contentDocument.getElementById(anchorId);
|
|
67
|
+
if (element) {
|
|
68
|
+
element.scrollIntoView({
|
|
69
|
+
behavior: "smooth"
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const getStyleBookNavigationFromPath = (path) => {
|
|
74
|
+
if (path && typeof path === "string") {
|
|
75
|
+
if (path === "/" || path.startsWith("/typography") || path.startsWith("/colors") || path.startsWith("/blocks")) {
|
|
76
|
+
return {
|
|
77
|
+
top: true
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
function useMultiOriginPalettes() {
|
|
84
|
+
const { colors, gradients } = (0, import_block_editor.__experimentalUseMultipleOriginColorsAndGradients)();
|
|
85
|
+
const [
|
|
86
|
+
shouldDisplayDefaultDuotones,
|
|
87
|
+
customDuotones,
|
|
88
|
+
themeDuotones,
|
|
89
|
+
defaultDuotones
|
|
90
|
+
] = (0, import_block_editor.useSettings)(
|
|
91
|
+
"color.defaultDuotone",
|
|
92
|
+
"color.duotone.custom",
|
|
93
|
+
"color.duotone.theme",
|
|
94
|
+
"color.duotone.default"
|
|
95
|
+
);
|
|
96
|
+
const palettes = (0, import_element.useMemo)(() => {
|
|
97
|
+
const result = { colors, gradients, duotones: [] };
|
|
98
|
+
if (themeDuotones && themeDuotones.length) {
|
|
99
|
+
result.duotones.push({
|
|
100
|
+
name: (0, import_i18n._x)(
|
|
101
|
+
"Theme",
|
|
102
|
+
"Indicates these duotone filters come from the theme."
|
|
103
|
+
),
|
|
104
|
+
slug: "theme",
|
|
105
|
+
duotones: themeDuotones
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (shouldDisplayDefaultDuotones && defaultDuotones && defaultDuotones.length) {
|
|
109
|
+
result.duotones.push({
|
|
110
|
+
name: (0, import_i18n._x)(
|
|
111
|
+
"Default",
|
|
112
|
+
"Indicates these duotone filters come from WordPress."
|
|
113
|
+
),
|
|
114
|
+
slug: "default",
|
|
115
|
+
duotones: defaultDuotones
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (customDuotones && customDuotones.length) {
|
|
119
|
+
result.duotones.push({
|
|
120
|
+
name: (0, import_i18n._x)(
|
|
121
|
+
"Custom",
|
|
122
|
+
"Indicates these doutone filters are created by the user."
|
|
123
|
+
),
|
|
124
|
+
slug: "custom",
|
|
125
|
+
duotones: customDuotones
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return result;
|
|
129
|
+
}, [
|
|
130
|
+
colors,
|
|
131
|
+
gradients,
|
|
132
|
+
customDuotones,
|
|
133
|
+
themeDuotones,
|
|
134
|
+
defaultDuotones,
|
|
135
|
+
shouldDisplayDefaultDuotones
|
|
136
|
+
]);
|
|
137
|
+
return palettes;
|
|
138
|
+
}
|
|
139
|
+
function getExamplesForSinglePageUse(examples) {
|
|
140
|
+
const examplesForSinglePageUse = [];
|
|
141
|
+
const overviewCategoryExamples = (0, import_categories.getExamplesByCategory)(
|
|
142
|
+
{ slug: "overview" },
|
|
143
|
+
examples
|
|
144
|
+
);
|
|
145
|
+
examplesForSinglePageUse.push(...overviewCategoryExamples.examples);
|
|
146
|
+
const otherExamples = examples.filter((example) => {
|
|
147
|
+
return example.category !== "overview" && !overviewCategoryExamples.examples.find(
|
|
148
|
+
(overviewExample) => overviewExample.name === example.name
|
|
149
|
+
);
|
|
150
|
+
});
|
|
151
|
+
examplesForSinglePageUse.push(...otherExamples);
|
|
152
|
+
return examplesForSinglePageUse;
|
|
153
|
+
}
|
|
154
|
+
function applyBlockVariationsToExamples(examples, variation) {
|
|
155
|
+
if (!variation) {
|
|
156
|
+
return examples;
|
|
157
|
+
}
|
|
158
|
+
return examples.map((example) => {
|
|
159
|
+
return {
|
|
160
|
+
...example,
|
|
161
|
+
variation,
|
|
162
|
+
blocks: Array.isArray(example.blocks) ? example.blocks.map((block) => ({
|
|
163
|
+
...block,
|
|
164
|
+
attributes: {
|
|
165
|
+
...block.attributes,
|
|
166
|
+
style: void 0,
|
|
167
|
+
className: `is-style-${variation}`
|
|
168
|
+
}
|
|
169
|
+
})) : {
|
|
170
|
+
...example.blocks,
|
|
171
|
+
attributes: {
|
|
172
|
+
...example.blocks.attributes,
|
|
173
|
+
style: void 0,
|
|
174
|
+
className: `is-style-${variation}`
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
function StyleBook({
|
|
181
|
+
isSelected,
|
|
182
|
+
onClick,
|
|
183
|
+
onSelect,
|
|
184
|
+
showTabs = true,
|
|
185
|
+
userConfig = {},
|
|
186
|
+
path = ""
|
|
187
|
+
}, ref) {
|
|
188
|
+
const textColor = (0, import_global_styles.useStyle)("color.text");
|
|
189
|
+
const backgroundColor = (0, import_global_styles.useStyle)("color.background");
|
|
190
|
+
const colors = useMultiOriginPalettes();
|
|
191
|
+
const examples = (0, import_element.useMemo)(() => (0, import_examples.getExamples)(colors), [colors]);
|
|
192
|
+
const tabs = (0, import_element.useMemo)(
|
|
193
|
+
() => (0, import_categories.getTopLevelStyleBookCategories)().filter(
|
|
194
|
+
(category) => examples.some(
|
|
195
|
+
(example) => example.category === category.slug
|
|
196
|
+
)
|
|
197
|
+
),
|
|
198
|
+
[examples]
|
|
199
|
+
);
|
|
200
|
+
const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
|
|
201
|
+
const { base: baseConfig } = (0, import_global_styles.useGlobalStyles)();
|
|
202
|
+
const goTo = getStyleBookNavigationFromPath(path);
|
|
203
|
+
const mergedConfig = (0, import_element.useMemo)(() => {
|
|
204
|
+
if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
|
|
205
|
+
return (0, import_global_styles_engine.mergeGlobalStyles)(baseConfig, userConfig);
|
|
206
|
+
}
|
|
207
|
+
return {};
|
|
208
|
+
}, [baseConfig, userConfig]);
|
|
209
|
+
const originalSettings = (0, import_data.useSelect)(
|
|
210
|
+
(select) => select(import_block_editor.store).getSettings(),
|
|
211
|
+
[]
|
|
212
|
+
);
|
|
213
|
+
const [globalStyles] = (0, import_use_global_styles_output.useGlobalStylesOutputWithConfig)(mergedConfig);
|
|
214
|
+
const settings = (0, import_element.useMemo)(
|
|
215
|
+
() => ({
|
|
216
|
+
...originalSettings,
|
|
217
|
+
styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : originalSettings.styles,
|
|
218
|
+
isPreviewMode: true
|
|
219
|
+
}),
|
|
220
|
+
[globalStyles, originalSettings, userConfig]
|
|
221
|
+
);
|
|
222
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
223
|
+
"div",
|
|
224
|
+
{
|
|
225
|
+
ref,
|
|
226
|
+
className: (0, import_clsx.default)("editor-style-book", {
|
|
227
|
+
"is-button": !!onClick
|
|
228
|
+
}),
|
|
229
|
+
style: {
|
|
230
|
+
color: textColor,
|
|
231
|
+
background: backgroundColor
|
|
232
|
+
},
|
|
233
|
+
children: showTabs ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tabs, { children: [
|
|
234
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-style-book__tablist-container", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tabs.Tab, { tabId: tab.slug, children: tab.title }, tab.slug)) }) }),
|
|
235
|
+
tabs.map((tab) => {
|
|
236
|
+
const categoryDefinition = tab.slug ? (0, import_categories.getTopLevelStyleBookCategories)().find(
|
|
237
|
+
(_category) => _category.slug === tab.slug
|
|
238
|
+
) : null;
|
|
239
|
+
const filteredExamples = categoryDefinition ? (0, import_categories.getExamplesByCategory)(
|
|
240
|
+
categoryDefinition,
|
|
241
|
+
examples
|
|
242
|
+
) : { examples };
|
|
243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
244
|
+
Tabs.TabPanel,
|
|
245
|
+
{
|
|
246
|
+
tabId: tab.slug,
|
|
247
|
+
focusable: false,
|
|
248
|
+
className: "editor-style-book__tabpanel",
|
|
249
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
250
|
+
StyleBookBody,
|
|
251
|
+
{
|
|
252
|
+
category: tab.slug,
|
|
253
|
+
examples: filteredExamples,
|
|
254
|
+
isSelected,
|
|
255
|
+
onSelect,
|
|
256
|
+
settings,
|
|
257
|
+
title: tab.title,
|
|
258
|
+
goTo
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
},
|
|
262
|
+
tab.slug
|
|
263
|
+
);
|
|
264
|
+
})
|
|
265
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
266
|
+
StyleBookBody,
|
|
267
|
+
{
|
|
268
|
+
examples: { examples: examplesForSinglePageUse },
|
|
269
|
+
isSelected,
|
|
270
|
+
onClick,
|
|
271
|
+
onSelect,
|
|
272
|
+
settings,
|
|
273
|
+
goTo
|
|
274
|
+
}
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
const StyleBookPreview = ({
|
|
280
|
+
userConfig = {},
|
|
281
|
+
isStatic = false,
|
|
282
|
+
path,
|
|
283
|
+
onPathChange
|
|
284
|
+
}) => {
|
|
285
|
+
const editorSettings = (0, import_data.useSelect)(
|
|
286
|
+
(select) => select(import_store.store).getEditorSettings(),
|
|
287
|
+
[]
|
|
288
|
+
);
|
|
289
|
+
const canUserUploadMedia = (0, import_data.useSelect)(
|
|
290
|
+
(select) => select(import_core_data.store).canUser("create", {
|
|
291
|
+
kind: "postType",
|
|
292
|
+
name: "attachment"
|
|
293
|
+
}),
|
|
294
|
+
[]
|
|
295
|
+
);
|
|
296
|
+
(0, import_element.useEffect)(() => {
|
|
297
|
+
(0, import_data.dispatch)(import_block_editor.store).updateSettings({
|
|
298
|
+
...editorSettings,
|
|
299
|
+
mediaUpload: canUserUploadMedia ? import_media_utils.uploadMedia : void 0
|
|
300
|
+
});
|
|
301
|
+
}, [editorSettings, canUserUploadMedia]);
|
|
302
|
+
const [internalPath, setInternalPath] = (0, import_element.useState)("/");
|
|
303
|
+
const section = path ?? internalPath;
|
|
304
|
+
const onChangeSection = onPathChange ?? setInternalPath;
|
|
305
|
+
const isSelected = (blockName) => {
|
|
306
|
+
return section === `/blocks/${encodeURIComponent(blockName)}` || section.startsWith(
|
|
307
|
+
`/blocks/${encodeURIComponent(blockName)}/`
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
const onSelect = (blockName, isBlockVariation = false) => {
|
|
311
|
+
if (import_constants2.STYLE_BOOK_COLOR_GROUPS.find(
|
|
312
|
+
(group) => group.slug === blockName
|
|
313
|
+
)) {
|
|
314
|
+
onChangeSection("/colors/palette");
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if (blockName === "typography") {
|
|
318
|
+
onChangeSection("/typography");
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
if (isBlockVariation) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
onChangeSection(`/blocks/${encodeURIComponent(blockName)}`);
|
|
325
|
+
};
|
|
326
|
+
const colors = useMultiOriginPalettes();
|
|
327
|
+
const examples = (0, import_examples.getExamples)(colors);
|
|
328
|
+
const examplesForSinglePageUse = getExamplesForSinglePageUse(examples);
|
|
329
|
+
let previewCategory = null;
|
|
330
|
+
let blockVariation = null;
|
|
331
|
+
if (section.includes("/colors")) {
|
|
332
|
+
previewCategory = "colors";
|
|
333
|
+
} else if (section.includes("/typography")) {
|
|
334
|
+
previewCategory = "text";
|
|
335
|
+
} else if (section.includes("/blocks")) {
|
|
336
|
+
previewCategory = "blocks";
|
|
337
|
+
let blockName = decodeURIComponent(section).split("/blocks/")[1];
|
|
338
|
+
if (blockName?.includes("/variations")) {
|
|
339
|
+
[blockName, blockVariation] = blockName.split("/variations/");
|
|
340
|
+
}
|
|
341
|
+
if (blockName && examples.find((example) => example.name === blockName)) {
|
|
342
|
+
previewCategory = blockName;
|
|
343
|
+
}
|
|
344
|
+
} else if (!isStatic) {
|
|
345
|
+
previewCategory = "overview";
|
|
346
|
+
}
|
|
347
|
+
const categoryDefinition = import_constants2.STYLE_BOOK_PREVIEW_CATEGORIES.find(
|
|
348
|
+
(category) => category.slug === previewCategory
|
|
349
|
+
);
|
|
350
|
+
const filteredExamples = (0, import_element.useMemo)(() => {
|
|
351
|
+
if (!categoryDefinition) {
|
|
352
|
+
return {
|
|
353
|
+
examples: [
|
|
354
|
+
examples.find(
|
|
355
|
+
(example) => example.name === previewCategory
|
|
356
|
+
)
|
|
357
|
+
]
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return (0, import_categories.getExamplesByCategory)(categoryDefinition, examples);
|
|
361
|
+
}, [categoryDefinition, examples, previewCategory]);
|
|
362
|
+
const displayedExamples = (0, import_element.useMemo)(() => {
|
|
363
|
+
if (!previewCategory) {
|
|
364
|
+
return { examples: examplesForSinglePageUse };
|
|
365
|
+
}
|
|
366
|
+
if (blockVariation) {
|
|
367
|
+
return {
|
|
368
|
+
examples: applyBlockVariationsToExamples(
|
|
369
|
+
filteredExamples.examples,
|
|
370
|
+
blockVariation
|
|
371
|
+
)
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
return filteredExamples;
|
|
375
|
+
}, [
|
|
376
|
+
previewCategory,
|
|
377
|
+
examplesForSinglePageUse,
|
|
378
|
+
blockVariation,
|
|
379
|
+
filteredExamples
|
|
380
|
+
]);
|
|
381
|
+
const { base: baseConfig } = (0, import_global_styles.useGlobalStyles)();
|
|
382
|
+
const goTo = getStyleBookNavigationFromPath(section);
|
|
383
|
+
const mergedConfig = (0, import_element.useMemo)(() => {
|
|
384
|
+
if (!isObjectEmpty(userConfig) && !isObjectEmpty(baseConfig)) {
|
|
385
|
+
return (0, import_global_styles_engine.mergeGlobalStyles)(baseConfig, userConfig);
|
|
386
|
+
}
|
|
387
|
+
return {};
|
|
388
|
+
}, [baseConfig, userConfig]);
|
|
389
|
+
const [globalStyles] = (0, import_use_global_styles_output.useGlobalStylesOutputWithConfig)(mergedConfig);
|
|
390
|
+
const settings = (0, import_element.useMemo)(
|
|
391
|
+
() => ({
|
|
392
|
+
...editorSettings,
|
|
393
|
+
styles: !isObjectEmpty(globalStyles) && !isObjectEmpty(userConfig) ? globalStyles : editorSettings.styles,
|
|
394
|
+
isPreviewMode: true
|
|
395
|
+
}),
|
|
396
|
+
[globalStyles, editorSettings, userConfig]
|
|
397
|
+
);
|
|
398
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "editor-style-book", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_block_editor.BlockEditorProvider, { settings, children: [
|
|
399
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_global_styles_renderer.GlobalStylesRenderer, { disableRootPadding: true }),
|
|
400
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
401
|
+
StyleBookBody,
|
|
402
|
+
{
|
|
403
|
+
examples: displayedExamples,
|
|
404
|
+
settings,
|
|
405
|
+
goTo,
|
|
406
|
+
isSelected: !isStatic ? isSelected : null,
|
|
407
|
+
onSelect: !isStatic ? onSelect : null
|
|
408
|
+
}
|
|
409
|
+
)
|
|
410
|
+
] }) });
|
|
411
|
+
};
|
|
412
|
+
const StyleBookBody = ({
|
|
413
|
+
examples,
|
|
414
|
+
isSelected,
|
|
415
|
+
onClick,
|
|
416
|
+
onSelect,
|
|
417
|
+
settings,
|
|
418
|
+
title,
|
|
419
|
+
goTo
|
|
420
|
+
}) => {
|
|
421
|
+
const [isFocused, setIsFocused] = (0, import_element.useState)(false);
|
|
422
|
+
const [hasIframeLoaded, setHasIframeLoaded] = (0, import_element.useState)(false);
|
|
423
|
+
const iframeRef = (0, import_element.useRef)(null);
|
|
424
|
+
const buttonModeProps = {
|
|
425
|
+
role: "button",
|
|
426
|
+
onFocus: () => setIsFocused(true),
|
|
427
|
+
onBlur: () => setIsFocused(false),
|
|
428
|
+
onKeyDown: (event) => {
|
|
429
|
+
if (event.defaultPrevented) {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
const { keyCode } = event;
|
|
433
|
+
if (onClick && (keyCode === import_keycodes.ENTER || keyCode === import_keycodes.SPACE)) {
|
|
434
|
+
event.preventDefault();
|
|
435
|
+
onClick(event);
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
onClick: (event) => {
|
|
439
|
+
if (event.defaultPrevented) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
if (onClick) {
|
|
443
|
+
event.preventDefault();
|
|
444
|
+
onClick(event);
|
|
445
|
+
}
|
|
446
|
+
},
|
|
447
|
+
readonly: true
|
|
448
|
+
};
|
|
449
|
+
const handleLoad = () => setHasIframeLoaded(true);
|
|
450
|
+
(0, import_element.useLayoutEffect)(() => {
|
|
451
|
+
if (hasIframeLoaded && iframeRef?.current) {
|
|
452
|
+
if (goTo?.top) {
|
|
453
|
+
scrollToSection("top", iframeRef?.current);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}, [iframeRef?.current, goTo, scrollToSection, hasIframeLoaded]);
|
|
457
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
458
|
+
import_block_editor.__unstableIframe,
|
|
459
|
+
{
|
|
460
|
+
onLoad: handleLoad,
|
|
461
|
+
ref: iframeRef,
|
|
462
|
+
className: (0, import_clsx.default)("editor-style-book__iframe", {
|
|
463
|
+
"is-focused": isFocused && !!onClick,
|
|
464
|
+
"is-button": !!onClick
|
|
465
|
+
}),
|
|
466
|
+
name: "style-book-canvas",
|
|
467
|
+
tabIndex: 0,
|
|
468
|
+
...onClick ? buttonModeProps : {},
|
|
469
|
+
children: [
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableEditorStyles, { styles: settings.styles }),
|
|
471
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("style", { children: [
|
|
472
|
+
import_constants.STYLE_BOOK_IFRAME_STYLES,
|
|
473
|
+
!!onClick && "body { cursor: pointer; } body * { pointer-events: none; }"
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
476
|
+
Examples,
|
|
477
|
+
{
|
|
478
|
+
className: "editor-style-book__examples",
|
|
479
|
+
filteredExamples: examples,
|
|
480
|
+
label: title ? (0, import_i18n.sprintf)(
|
|
481
|
+
// translators: %s: Category of blocks, e.g. Text.
|
|
482
|
+
(0, import_i18n.__)("Examples of blocks in the %s category"),
|
|
483
|
+
title
|
|
484
|
+
) : (0, import_i18n.__)("Examples of blocks"),
|
|
485
|
+
isSelected,
|
|
486
|
+
onSelect
|
|
487
|
+
},
|
|
488
|
+
title
|
|
489
|
+
)
|
|
490
|
+
]
|
|
491
|
+
}
|
|
492
|
+
);
|
|
493
|
+
};
|
|
494
|
+
const Examples = (0, import_element.memo)(
|
|
495
|
+
({ className, filteredExamples, label, isSelected, onSelect }) => {
|
|
496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
497
|
+
import_components.Composite,
|
|
498
|
+
{
|
|
499
|
+
orientation: "vertical",
|
|
500
|
+
className,
|
|
501
|
+
"aria-label": label,
|
|
502
|
+
role: "grid",
|
|
503
|
+
children: [
|
|
504
|
+
!!filteredExamples?.examples?.length && filteredExamples.examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
505
|
+
Example,
|
|
506
|
+
{
|
|
507
|
+
id: `example-${example.name}`,
|
|
508
|
+
title: example.title,
|
|
509
|
+
content: example.content,
|
|
510
|
+
blocks: example.blocks,
|
|
511
|
+
isSelected: isSelected?.(example.name),
|
|
512
|
+
onClick: !!onSelect ? () => onSelect(
|
|
513
|
+
example.name,
|
|
514
|
+
!!example.variation
|
|
515
|
+
) : null
|
|
516
|
+
},
|
|
517
|
+
example.name
|
|
518
|
+
)),
|
|
519
|
+
!!filteredExamples?.subcategories?.length && filteredExamples.subcategories.map((subcategory) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
520
|
+
import_components.Composite.Group,
|
|
521
|
+
{
|
|
522
|
+
className: "editor-style-book__subcategory",
|
|
523
|
+
children: [
|
|
524
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Composite.GroupLabel, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "editor-style-book__subcategory-title", children: subcategory.title }) }),
|
|
525
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
526
|
+
Subcategory,
|
|
527
|
+
{
|
|
528
|
+
examples: subcategory.examples,
|
|
529
|
+
isSelected,
|
|
530
|
+
onSelect
|
|
531
|
+
}
|
|
532
|
+
)
|
|
533
|
+
]
|
|
534
|
+
},
|
|
535
|
+
`subcategory-${subcategory.slug}`
|
|
536
|
+
))
|
|
537
|
+
]
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
);
|
|
542
|
+
const Subcategory = ({ examples, isSelected, onSelect }) => {
|
|
543
|
+
return !!examples?.length && examples.map((example) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
544
|
+
Example,
|
|
545
|
+
{
|
|
546
|
+
id: `example-${example.name}`,
|
|
547
|
+
title: example.title,
|
|
548
|
+
content: example.content,
|
|
549
|
+
blocks: example.blocks,
|
|
550
|
+
isSelected: isSelected?.(example.name),
|
|
551
|
+
onClick: !!onSelect ? () => onSelect(example.name) : null
|
|
552
|
+
},
|
|
553
|
+
example.name
|
|
554
|
+
));
|
|
555
|
+
};
|
|
556
|
+
const disabledExamples = ["example-duotones"];
|
|
557
|
+
const Example = ({ id, title, blocks, isSelected, onClick, content }) => {
|
|
558
|
+
const originalSettings = (0, import_data.useSelect)(
|
|
559
|
+
(select) => select(import_block_editor.store).getSettings(),
|
|
560
|
+
[]
|
|
561
|
+
);
|
|
562
|
+
const settings = (0, import_element.useMemo)(
|
|
563
|
+
() => ({
|
|
564
|
+
...originalSettings,
|
|
565
|
+
focusMode: false,
|
|
566
|
+
// Disable "Spotlight mode".
|
|
567
|
+
isPreviewMode: true
|
|
568
|
+
}),
|
|
569
|
+
[originalSettings]
|
|
570
|
+
);
|
|
571
|
+
const renderedBlocks = (0, import_element.useMemo)(
|
|
572
|
+
() => Array.isArray(blocks) ? blocks : [blocks],
|
|
573
|
+
[blocks]
|
|
574
|
+
);
|
|
575
|
+
const disabledProps = disabledExamples.includes(id) || !onClick ? {
|
|
576
|
+
disabled: true,
|
|
577
|
+
accessibleWhenDisabled: !!onClick
|
|
578
|
+
} : {};
|
|
579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "row", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "gridcell", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
580
|
+
import_components.Composite.Item,
|
|
581
|
+
{
|
|
582
|
+
className: (0, import_clsx.default)("editor-style-book__example", {
|
|
583
|
+
"is-selected": isSelected,
|
|
584
|
+
"is-disabled-example": !!disabledProps?.disabled
|
|
585
|
+
}),
|
|
586
|
+
id,
|
|
587
|
+
"aria-label": !!onClick ? (0, import_i18n.sprintf)(
|
|
588
|
+
// translators: %s: Title of a block, e.g. Heading.
|
|
589
|
+
(0, import_i18n.__)("Open %s styles in Styles panel"),
|
|
590
|
+
title
|
|
591
|
+
) : void 0,
|
|
592
|
+
render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {}),
|
|
593
|
+
role: !!onClick ? "button" : null,
|
|
594
|
+
onClick,
|
|
595
|
+
...disabledProps,
|
|
596
|
+
children: [
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "editor-style-book__example-title", children: title }),
|
|
598
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
599
|
+
"div",
|
|
600
|
+
{
|
|
601
|
+
className: "editor-style-book__example-preview",
|
|
602
|
+
"aria-hidden": true,
|
|
603
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.Disabled, { className: "editor-style-book__example-preview__content", children: content ? content : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
604
|
+
ExperimentalBlockEditorProvider,
|
|
605
|
+
{
|
|
606
|
+
value: renderedBlocks,
|
|
607
|
+
settings,
|
|
608
|
+
children: [
|
|
609
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableEditorStyles, {}),
|
|
610
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.BlockList, { renderAppender: false })
|
|
611
|
+
]
|
|
612
|
+
}
|
|
613
|
+
) })
|
|
614
|
+
}
|
|
615
|
+
)
|
|
616
|
+
]
|
|
617
|
+
}
|
|
618
|
+
) }) });
|
|
619
|
+
};
|
|
620
|
+
var style_book_default = (0, import_element.forwardRef)(StyleBook);
|
|
621
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
622
|
+
0 && (module.exports = {
|
|
623
|
+
StyleBookBody,
|
|
624
|
+
StyleBookPreview,
|
|
625
|
+
getExamplesForSinglePageUse
|
|
626
|
+
});
|
|
627
|
+
//# sourceMappingURL=index.js.map
|