@wordpress/block-library 8.18.1-next.5a1d1283.0 → 8.19.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/README.md +1 -1
- package/build/block/edit.js +53 -2
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +7 -4
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +11 -2
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +10 -4
- package/build/button/save.js.map +1 -1
- package/build/buttons/edit.js +12 -3
- package/build/buttons/edit.js.map +1 -1
- package/build/code/edit.js +8 -2
- package/build/code/edit.js.map +1 -1
- package/build/code/index.js +7 -1
- package/build/code/index.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/index.js +2 -0
- package/build/columns/index.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/index.js +2 -1
- package/build/file/index.js.map +1 -1
- package/build/file/utils/index.js +1 -15
- package/build/file/utils/index.js.map +1 -1
- package/build/file/view.js +14 -1
- package/build/file/view.js.map +1 -1
- package/build/footnotes/edit.js +12 -2
- package/build/footnotes/edit.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/group/edit.js +0 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +4 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +0 -1
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +2 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +3 -6
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +191 -7
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +27 -12
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +75 -40
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -4
- package/build/image/index.js.map +1 -1
- package/build/image/{view-interactivity.js → view.js} +1 -1
- package/build/image/view.js.map +1 -0
- package/build/list/deprecated.js +93 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +10 -10
- package/build/list/edit.js.map +1 -1
- package/build/list/ordered-list-settings.js +10 -10
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list/save.js +4 -2
- package/build/list/save.js.map +1 -1
- package/build/list/utils.js +21 -2
- package/build/list/utils.js.map +1 -1
- package/build/navigation/constants.js +1 -1
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/index.js +4 -2
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/view.js +168 -82
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +3 -9
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/transforms.js +24 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/page-list/edit.js +2 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +10 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +5 -3
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-content/edit.js +8 -7
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +3 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/overlay.js +2 -1
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/preformatted/edit.js +4 -1
- package/build/preformatted/edit.js.map +1 -1
- package/build/preformatted/index.js +1 -1
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/deprecated.js +6 -7
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +56 -0
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +42 -0
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +8 -25
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +8 -2
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/utils.js +19 -0
- package/build/query/utils.js.map +1 -1
- package/build/query/view.js +4 -5
- package/build/query/view.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/search/view.js +81 -150
- package/build/search/view.js.map +1 -1
- package/build/social-link/edit.native.js +3 -1
- package/build/social-link/edit.native.js.map +1 -1
- package/build/table/edit.js +7 -7
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -130
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/hooks.js +145 -0
- package/build/table-of-contents/hooks.js.map +1 -0
- package/build/table-of-contents/index.js +2 -1
- package/build/table-of-contents/index.js.map +1 -1
- package/build/verse/edit.js +4 -1
- package/build/verse/edit.js.map +1 -1
- package/build/verse/index.js +1 -1
- package/build/verse/index.js.map +1 -1
- package/build-module/block/edit.js +54 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +7 -4
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +11 -2
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +10 -4
- package/build-module/button/save.js.map +1 -1
- package/build-module/buttons/edit.js +12 -3
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/code/edit.js +8 -2
- package/build-module/code/edit.js.map +1 -1
- package/build-module/code/index.js +7 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/index.js +2 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/index.js +2 -1
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/utils/index.js +0 -13
- package/build-module/file/utils/index.js.map +1 -1
- package/build-module/file/view.js +14 -2
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/edit.js +12 -2
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/group/edit.js +0 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +4 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +0 -1
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +2 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +3 -6
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +191 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +27 -12
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +77 -42
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -4
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/{view-interactivity.js → view.js} +1 -1
- package/build-module/image/view.js.map +1 -0
- package/build-module/list/deprecated.js +95 -3
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +10 -10
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +10 -10
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list/save.js +4 -2
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/utils.js +20 -2
- package/build-module/list/utils.js.map +1 -1
- package/build-module/navigation/constants.js +1 -1
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/index.js +4 -2
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/view.js +168 -83
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +3 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/transforms.js +24 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/page-list/edit.js +2 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +10 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +5 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-content/edit.js +8 -7
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +3 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +2 -1
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/preformatted/edit.js +4 -1
- package/build-module/preformatted/edit.js.map +1 -1
- package/build-module/preformatted/index.js +1 -1
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +6 -7
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +50 -0
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +35 -0
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +9 -26
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +8 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/utils.js +17 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query/view.js +4 -5
- package/build-module/query/view.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/search/view.js +81 -151
- package/build-module/search/view.js.map +1 -1
- package/build-module/social-link/edit.native.js +3 -1
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/table/edit.js +7 -7
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +3 -131
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/hooks.js +137 -0
- package/build-module/table-of-contents/hooks.js.map +1 -0
- package/build-module/table-of-contents/index.js +2 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/verse/edit.js +4 -1
- package/build-module/verse/edit.js.map +1 -1
- package/build-module/verse/index.js +1 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-style/cover/style-rtl.css +9 -0
- package/build-style/cover/style.css +9 -0
- package/build-style/editor-rtl.css +15 -9
- package/build-style/editor.css +15 -9
- package/build-style/file/style-rtl.css +5 -0
- package/build-style/file/style.css +5 -0
- package/build-style/heading/style-rtl.css +13 -0
- package/build-style/heading/style.css +13 -0
- package/build-style/navigation-link/editor-rtl.css +0 -9
- package/build-style/navigation-link/editor.css +0 -9
- package/build-style/paragraph/editor-rtl.css +5 -0
- package/build-style/paragraph/editor.css +5 -0
- package/build-style/paragraph/style-rtl.css +5 -0
- package/build-style/paragraph/style.css +5 -0
- package/build-style/post-navigation-link/style-rtl.css +3 -0
- package/build-style/post-navigation-link/style.css +3 -0
- package/build-style/query/editor-rtl.css +10 -0
- package/build-style/query/editor.css +10 -0
- package/build-style/query/style-rtl.css +1 -1
- package/build-style/query/style.css +1 -1
- package/build-style/reset-rtl.css +27 -27
- package/build-style/reset.css +27 -27
- package/build-style/style-rtl.css +35 -0
- package/build-style/style.css +35 -0
- package/package.json +32 -33
- package/src/audio/test/__snapshots__/edit.native.js.snap +78 -106
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +58 -2
- package/src/block/test/edit.native.js +2 -3
- package/src/button/block.json +11 -2
- package/src/button/edit.js +27 -11
- package/src/button/save.js +10 -4
- package/src/buttons/edit.js +13 -3
- package/src/buttons/test/edit.native.js +28 -24
- package/src/calendar/index.php +2 -2
- package/src/code/block.json +2 -1
- package/src/code/edit.js +13 -1
- package/src/code/index.js +5 -0
- package/src/column/block.json +1 -0
- package/src/columns/block.json +2 -0
- package/src/comment-template/index.php +1 -1
- package/src/comments-pagination-next/index.php +1 -1
- package/src/comments-pagination-previous/index.php +1 -1
- package/src/cover/style.scss +12 -1
- package/src/cover/test/edit.js +7 -7
- package/src/cover/test/edit.native.js +18 -27
- package/src/embed/test/index.native.js +30 -45
- package/src/file/block.json +2 -1
- package/src/file/edit.native.js +1 -1
- package/src/file/index.php +19 -21
- package/src/file/style.scss +6 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +162 -218
- package/src/file/utils/index.js +0 -15
- package/src/file/view.js +14 -5
- package/src/footnotes/edit.js +13 -1
- package/src/gallery/edit.js +1 -1
- package/src/gallery/index.php +1 -1
- package/src/group/block.json +4 -0
- package/src/group/edit.js +0 -1
- package/src/heading/block.json +2 -0
- package/src/heading/edit.js +0 -1
- package/src/heading/style.scss +4 -0
- package/src/heading/transforms.js +1 -6
- package/src/image/block.json +7 -4
- package/src/image/deprecated.js +210 -7
- package/src/image/edit.js +43 -29
- package/src/image/image.js +86 -43
- package/src/image/index.php +251 -28
- package/src/latest-posts/index.php +1 -1
- package/src/list/deprecated.js +84 -3
- package/src/list/edit.js +6 -3
- package/src/list/ordered-list-settings.js +20 -5
- package/src/list/save.js +10 -1
- package/src/list/test/edit.native.js +2 -4
- package/src/list/utils.js +22 -1
- package/src/navigation/block.json +4 -2
- package/src/navigation/constants.js +1 -0
- package/src/navigation/index.php +85 -123
- package/src/navigation/view.js +192 -96
- package/src/navigation-link/edit.js +21 -36
- package/src/navigation-link/editor.scss +0 -8
- package/src/navigation-link/transforms.js +22 -0
- package/src/page-list/edit.js +2 -1
- package/src/paragraph/editor.scss +5 -0
- package/src/paragraph/style.scss +5 -0
- package/src/pattern/index.php +2 -2
- package/src/post-comments-form/edit.js +10 -0
- package/src/post-comments-form/form.js +7 -1
- package/src/post-content/block.json +3 -0
- package/src/post-content/edit.js +14 -6
- package/src/post-excerpt/index.php +2 -2
- package/src/post-featured-image/index.php +2 -2
- package/src/post-featured-image/overlay.js +1 -0
- package/src/post-navigation-link/index.php +0 -5
- package/src/post-navigation-link/style.scss +4 -0
- package/src/post-template/index.php +1 -1
- package/src/post-terms/index.php +5 -2
- package/src/preformatted/edit.js +5 -0
- package/src/preformatted/index.js +1 -1
- package/src/pullquote/deprecated.js +8 -13
- package/src/query/edit/enhanced-pagination-modal.js +65 -0
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +49 -0
- package/src/query/edit/inspector-controls/index.js +9 -45
- package/src/query/edit/query-content.js +8 -0
- package/src/query/editor.scss +10 -0
- package/src/query/index.php +29 -16
- package/src/query/style.scss +2 -2
- package/src/query/utils.js +22 -0
- package/src/query/view.js +5 -5
- package/src/query-pagination-next/index.php +1 -1
- package/src/query-pagination-previous/index.php +1 -1
- package/src/reset.scss +1 -1
- package/src/search/block.json +1 -0
- package/src/search/index.php +45 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +265 -363
- package/src/search/view.js +70 -169
- package/src/social-link/edit.native.js +1 -1
- package/src/social-link/editor.native.scss +4 -0
- package/src/table/edit.js +21 -19
- package/src/table-of-contents/block.json +2 -1
- package/src/table-of-contents/edit.js +5 -162
- package/src/table-of-contents/hooks.js +156 -0
- package/src/verse/edit.js +5 -0
- package/src/verse/index.js +1 -1
- package/src/verse/test/edit.native.js +2 -3
- package/build/file/view-interactivity.js +0 -22
- package/build/file/view-interactivity.js.map +0 -1
- package/build/image/view-interactivity.js.map +0 -1
- package/build/navigation/view-interactivity.js +0 -172
- package/build/navigation/view-interactivity.js.map +0 -1
- package/build/navigation/view-modal.js +0 -115
- package/build/navigation/view-modal.js.map +0 -1
- package/build-module/file/view-interactivity.js +0 -18
- package/build-module/file/view-interactivity.js.map +0 -1
- package/build-module/image/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-interactivity.js +0 -169
- package/build-module/navigation/view-interactivity.js.map +0 -1
- package/build-module/navigation/view-modal.js +0 -112
- package/build-module/navigation/view-modal.js.map +0 -1
- package/src/file/view-interactivity.js +0 -18
- package/src/navigation/view-interactivity.js +0 -196
- package/src/navigation/view-modal.js +0 -127
- /package/src/image/{view-interactivity.js → view.js} +0 -0
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
-
/**
|
|
3
|
-
* External dependencies
|
|
4
|
-
*/
|
|
5
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
6
|
-
|
|
7
2
|
/**
|
|
8
3
|
* WordPress dependencies
|
|
9
4
|
*/
|
|
@@ -11,10 +6,8 @@ import { BlockControls, BlockIcon, InspectorControls, store as blockEditorStore,
|
|
|
11
6
|
import { createBlock } from '@wordpress/blocks';
|
|
12
7
|
import { PanelBody, Placeholder, ToggleControl, ToolbarButton, ToolbarGroup } from '@wordpress/components';
|
|
13
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
|
-
import {
|
|
15
|
-
import { renderToString, useEffect } from '@wordpress/element';
|
|
9
|
+
import { renderToString } from '@wordpress/element';
|
|
16
10
|
import { __ } from '@wordpress/i18n';
|
|
17
|
-
import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
18
11
|
|
|
19
12
|
/**
|
|
20
13
|
* Internal dependencies
|
|
@@ -22,6 +15,7 @@ import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
|
22
15
|
import icon from './icon';
|
|
23
16
|
import TableOfContentsList from './list';
|
|
24
17
|
import { linearToNestedHeadingList } from './utils';
|
|
18
|
+
import { useObserveHeadings } from './hooks';
|
|
25
19
|
|
|
26
20
|
/** @typedef {import('./utils').HeadingData} HeadingData */
|
|
27
21
|
|
|
@@ -45,6 +39,7 @@ export default function TableOfContentsEdit({
|
|
|
45
39
|
clientId,
|
|
46
40
|
setAttributes
|
|
47
41
|
}) {
|
|
42
|
+
useObserveHeadings(clientId);
|
|
48
43
|
const blockProps = useBlockProps();
|
|
49
44
|
const canInsertList = useSelect(select => {
|
|
50
45
|
const {
|
|
@@ -55,131 +50,8 @@ export default function TableOfContentsEdit({
|
|
|
55
50
|
return canInsertBlockType('core/list', rootClientId);
|
|
56
51
|
}, [clientId]);
|
|
57
52
|
const {
|
|
58
|
-
__unstableMarkNextChangeAsNotPersistent,
|
|
59
53
|
replaceBlocks
|
|
60
54
|
} = useDispatch(blockEditorStore);
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The latest heading data, or null if the new data deeply equals the saved
|
|
64
|
-
* headings attribute.
|
|
65
|
-
*
|
|
66
|
-
* Since useSelect forces a re-render when its return value is shallowly
|
|
67
|
-
* inequal to its prior call, we would be re-rendering this block every time
|
|
68
|
-
* the stores change, even if the latest headings were deeply equal to the
|
|
69
|
-
* ones saved in the block attributes.
|
|
70
|
-
*
|
|
71
|
-
* By returning null when they're equal, we reduce that to 2 renders: one
|
|
72
|
-
* when there are new latest headings (and so it returns them), and one when
|
|
73
|
-
* they haven't changed (so it returns null). As long as the latest heading
|
|
74
|
-
* data remains the same, further calls of the useSelect callback will
|
|
75
|
-
* continue to return null, thus preventing any forced re-renders.
|
|
76
|
-
*/
|
|
77
|
-
const latestHeadings = useSelect(select => {
|
|
78
|
-
var _editorSelectors$getP;
|
|
79
|
-
const {
|
|
80
|
-
getBlockAttributes,
|
|
81
|
-
getBlockName,
|
|
82
|
-
getClientIdsWithDescendants,
|
|
83
|
-
__experimentalGetGlobalBlocksByName: getGlobalBlocksByName
|
|
84
|
-
} = select(blockEditorStore);
|
|
85
|
-
|
|
86
|
-
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
87
|
-
// Blocks can be loaded into a *non-post* block editor, so to avoid
|
|
88
|
-
// declaring @wordpress/editor as a dependency, we must access its
|
|
89
|
-
// store by string. When the store is not available, editorSelectors
|
|
90
|
-
// will be null, and the block's saved markup will lack permalinks.
|
|
91
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
92
|
-
const editorSelectors = select('core/editor');
|
|
93
|
-
const pageBreakClientIds = getGlobalBlocksByName('core/nextpage');
|
|
94
|
-
const isPaginated = pageBreakClientIds.length !== 0;
|
|
95
|
-
|
|
96
|
-
// Get the client ids of all blocks in the editor.
|
|
97
|
-
const allBlockClientIds = getClientIdsWithDescendants();
|
|
98
|
-
|
|
99
|
-
// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.
|
|
100
|
-
let tocPage = 1;
|
|
101
|
-
if (isPaginated && onlyIncludeCurrentPage) {
|
|
102
|
-
// We can't use getBlockIndex because it only returns the index
|
|
103
|
-
// relative to sibling blocks.
|
|
104
|
-
const tocIndex = allBlockClientIds.indexOf(clientId);
|
|
105
|
-
for (const [blockIndex, blockClientId] of allBlockClientIds.entries()) {
|
|
106
|
-
// If we've reached blocks after the Table of Contents, we've
|
|
107
|
-
// finished calculating which page the block is on.
|
|
108
|
-
if (blockIndex >= tocIndex) {
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
if (getBlockName(blockClientId) === 'core/nextpage') {
|
|
112
|
-
tocPage++;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
const _latestHeadings = [];
|
|
117
|
-
|
|
118
|
-
/** The page (of a paginated post) a heading will be part of. */
|
|
119
|
-
let headingPage = 1;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* A permalink to the current post. If the core/editor store is
|
|
123
|
-
* unavailable, this variable will be null.
|
|
124
|
-
*/
|
|
125
|
-
const permalink = (_editorSelectors$getP = editorSelectors?.getPermalink()) !== null && _editorSelectors$getP !== void 0 ? _editorSelectors$getP : null;
|
|
126
|
-
let headingPageLink = null;
|
|
127
|
-
|
|
128
|
-
// If the core/editor store is available, we can add permalinks to the
|
|
129
|
-
// generated table of contents.
|
|
130
|
-
if (typeof permalink === 'string') {
|
|
131
|
-
headingPageLink = isPaginated ? addQueryArgs(permalink, {
|
|
132
|
-
page: headingPage
|
|
133
|
-
}) : permalink;
|
|
134
|
-
}
|
|
135
|
-
for (const blockClientId of allBlockClientIds) {
|
|
136
|
-
const blockName = getBlockName(blockClientId);
|
|
137
|
-
if (blockName === 'core/nextpage') {
|
|
138
|
-
headingPage++;
|
|
139
|
-
|
|
140
|
-
// If we're only including headings from the current page (of
|
|
141
|
-
// a paginated post), then exit the loop if we've reached the
|
|
142
|
-
// pages after the one with the Table of Contents block.
|
|
143
|
-
if (onlyIncludeCurrentPage && headingPage > tocPage) {
|
|
144
|
-
break;
|
|
145
|
-
}
|
|
146
|
-
if (typeof permalink === 'string') {
|
|
147
|
-
headingPageLink = addQueryArgs(removeQueryArgs(permalink, ['page']), {
|
|
148
|
-
page: headingPage
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// If we're including all headings or we've reached headings on
|
|
153
|
-
// the same page as the Table of Contents block, add them to the
|
|
154
|
-
// list.
|
|
155
|
-
else if (!onlyIncludeCurrentPage || headingPage === tocPage) {
|
|
156
|
-
if (blockName === 'core/heading') {
|
|
157
|
-
const headingAttributes = getBlockAttributes(blockClientId);
|
|
158
|
-
const canBeLinked = typeof headingPageLink === 'string' && typeof headingAttributes.anchor === 'string' && headingAttributes.anchor !== '';
|
|
159
|
-
_latestHeadings.push({
|
|
160
|
-
// Convert line breaks to spaces, and get rid of HTML tags in the headings.
|
|
161
|
-
content: stripHTML(headingAttributes.content.replace(/(<br *\/?>)+/g, ' ')),
|
|
162
|
-
level: headingAttributes.level,
|
|
163
|
-
link: canBeLinked ? `${headingPageLink}#${headingAttributes.anchor}` : null
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
if (fastDeepEqual(headings, _latestHeadings)) {
|
|
169
|
-
return null;
|
|
170
|
-
}
|
|
171
|
-
return _latestHeadings;
|
|
172
|
-
}, [clientId, onlyIncludeCurrentPage, headings]);
|
|
173
|
-
useEffect(() => {
|
|
174
|
-
if (latestHeadings !== null) {
|
|
175
|
-
// This is required to keep undo working and not create 2 undo steps
|
|
176
|
-
// for each heading change.
|
|
177
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
178
|
-
setAttributes({
|
|
179
|
-
headings: latestHeadings
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}, [latestHeadings]);
|
|
183
55
|
const headingTree = linearToNestedHeadingList(headings);
|
|
184
56
|
const toolbarControls = canInsertList && createElement(BlockControls, null, createElement(ToolbarGroup, null, createElement(ToolbarButton, {
|
|
185
57
|
onClick: () => replaceBlocks(clientId, createBlock('core/list', {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fastDeepEqual","BlockControls","BlockIcon","InspectorControls","store","blockEditorStore","useBlockProps","createBlock","PanelBody","Placeholder","ToggleControl","ToolbarButton","ToolbarGroup","useDispatch","useSelect","__unstableStripHTML","stripHTML","renderToString","useEffect","__","addQueryArgs","removeQueryArgs","icon","TableOfContentsList","linearToNestedHeadingList","TableOfContentsEdit","attributes","headings","onlyIncludeCurrentPage","clientId","setAttributes","blockProps","canInsertList","select","getBlockRootClientId","canInsertBlockType","rootClientId","__unstableMarkNextChangeAsNotPersistent","replaceBlocks","latestHeadings","_editorSelectors$getP","getBlockAttributes","getBlockName","getClientIdsWithDescendants","__experimentalGetGlobalBlocksByName","getGlobalBlocksByName","editorSelectors","pageBreakClientIds","isPaginated","length","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","_latestHeadings","headingPage","permalink","getPermalink","headingPageLink","page","blockName","headingAttributes","canBeLinked","anchor","push","content","replace","level","link","headingTree","toolbarControls","createElement","onClick","ordered","values","nestedHeadingList","inspectorControls","title","__nextHasNoMarginBottom","label","checked","onChange","value","help","Fragment","instructions","inert"],"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { renderToString, useEffect } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport icon from './icon';\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {string} props.clientId\n * @param {(attributes: Object) => void} props.setAttributes\n *\n * @return {WPComponent} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { headings = [], onlyIncludeCurrentPage },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t/**\n\t * The latest heading data, or null if the new data deeply equals the saved\n\t * headings attribute.\n\t *\n\t * Since useSelect forces a re-render when its return value is shallowly\n\t * inequal to its prior call, we would be re-rendering this block every time\n\t * the stores change, even if the latest headings were deeply equal to the\n\t * ones saved in the block attributes.\n\t *\n\t * By returning null when they're equal, we reduce that to 2 renders: one\n\t * when there are new latest headings (and so it returns them), and one when\n\t * they haven't changed (so it returns null). As long as the latest heading\n\t * data remains the same, further calls of the useSelect callback will\n\t * continue to return null, thus preventing any forced re-renders.\n\t */\n\tconst latestHeadings = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockAttributes,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetClientIdsWithDescendants,\n\t\t\t\t__experimentalGetGlobalBlocksByName: getGlobalBlocksByName,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t\t\t// declaring @wordpress/editor as a dependency, we must access its\n\t\t\t// store by string. When the store is not available, editorSelectors\n\t\t\t// will be null, and the block's saved markup will lack permalinks.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst editorSelectors = select( 'core/editor' );\n\n\t\t\tconst pageBreakClientIds = getGlobalBlocksByName( 'core/nextpage' );\n\n\t\t\tconst isPaginated = pageBreakClientIds.length !== 0;\n\n\t\t\t// Get the client ids of all blocks in the editor.\n\t\t\tconst allBlockClientIds = getClientIdsWithDescendants();\n\n\t\t\t// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.\n\t\t\tlet tocPage = 1;\n\n\t\t\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t\t\t// We can't use getBlockIndex because it only returns the index\n\t\t\t\t// relative to sibling blocks.\n\t\t\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\t\t\tfor ( const [\n\t\t\t\t\tblockIndex,\n\t\t\t\t\tblockClientId,\n\t\t\t\t] of allBlockClientIds.entries() ) {\n\t\t\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t\t\t// finished calculating which page the block is on.\n\t\t\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\t\t\ttocPage++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst _latestHeadings = [];\n\n\t\t\t/** The page (of a paginated post) a heading will be part of. */\n\t\t\tlet headingPage = 1;\n\n\t\t\t/**\n\t\t\t * A permalink to the current post. If the core/editor store is\n\t\t\t * unavailable, this variable will be null.\n\t\t\t */\n\t\t\tconst permalink = editorSelectors?.getPermalink() ?? null;\n\n\t\t\tlet headingPageLink = null;\n\n\t\t\t// If the core/editor store is available, we can add permalinks to the\n\t\t\t// generated table of contents.\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = isPaginated\n\t\t\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t\t\t: permalink;\n\t\t\t}\n\n\t\t\tfor ( const blockClientId of allBlockClientIds ) {\n\t\t\t\tconst blockName = getBlockName( blockClientId );\n\t\t\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\t\t\theadingPage++;\n\n\t\t\t\t\t// If we're only including headings from the current page (of\n\t\t\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t\t\t// pages after the one with the Table of Contents block.\n\t\t\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t\t\t{ page: headingPage }\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// If we're including all headings or we've reached headings on\n\t\t\t\t// the same page as the Table of Contents block, add them to the\n\t\t\t\t// list.\n\t\t\t\telse if (\n\t\t\t\t\t! onlyIncludeCurrentPage ||\n\t\t\t\t\theadingPage === tocPage\n\t\t\t\t) {\n\t\t\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\t\t\tconst headingAttributes =\n\t\t\t\t\t\t\tgetBlockAttributes( blockClientId );\n\n\t\t\t\t\t\tconst canBeLinked =\n\t\t\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\t\t\t_latestHeadings.push( {\n\t\t\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\n\t\t\t\t\t\t\t\t\t' '\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t\t\t: null,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif ( fastDeepEqual( headings, _latestHeadings ) ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn _latestHeadings;\n\t\t},\n\t\t[ clientId, onlyIncludeCurrentPage, headings ]\n\t);\n\n\tuseEffect( () => {\n\t\tif ( latestHeadings !== null ) {\n\t\t\t// This is required to keep undo working and not create 2 undo steps\n\t\t\t// for each heading change.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { headings: latestHeadings } );\n\t\t}\n\t}, [ latestHeadings ] );\n\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = canInsertList && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tordered: true,\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={\n\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Toggle to only include headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel={ __( 'Table of Contents' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ol inert=\"true\">\n\t\t\t\t\t<TableOfContentsList nestedHeadingList={ headingTree } />\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,aAAa,MAAM,qBAAqB;;AAE/C;AACA;AACA;AACA,SACCC,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SACCC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,YAAY,QACN,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,mBAAmB,IAAIC,SAAS,QAAQ,gBAAgB;AACjE,SAASC,cAAc,EAAEC,SAAS,QAAQ,oBAAoB;AAC9D,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,YAAY,EAAEC,eAAe,QAAQ,gBAAgB;;AAE9D;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,mBAAmB,MAAM,QAAQ;AACxC,SAASC,yBAAyB,QAAQ,SAAS;;AAEnD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAE;EAC5CC,UAAU,EAAE;IAAEC,QAAQ,GAAG,EAAE;IAAEC;EAAuB,CAAC;EACrDC,QAAQ;EACRC;AACD,CAAC,EAAG;EACH,MAAMC,UAAU,GAAGzB,aAAa,CAAC,CAAC;EAElC,MAAM0B,aAAa,GAAGlB,SAAS,CAC5BmB,MAAM,IAAM;IACb,MAAM;MAAEC,oBAAoB;MAAEC;IAAmB,CAAC,GACjDF,MAAM,CAAE5B,gBAAiB,CAAC;IAC3B,MAAM+B,YAAY,GAAGF,oBAAoB,CAAEL,QAAS,CAAC;IAErD,OAAOM,kBAAkB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AAa,CAAE;MAAEF,sBAAsB,EAAEyD;IAAM,CAAE,CACjD;IACDC,IAAI,EACH1D,sBAAsB,GACnBT,EAAE,CACF,2EACA,CAAC,GACDA,EAAE,CACF,mFACA;EACH,CACD,CACS,CACO,CACnB;;EAED;EACA;EACA;EACA,IAAKQ,QAAQ,CAACsB,MAAM,KAAK,CAAC,EAAG;IAC5B,OACCyB,aAAA,CAAAa,QAAA,QACCb,aAAA;MAAA,GAAU3C;IAAU,GACnB2C,aAAA,CAACjE,WAAW;MACXa,IAAI,EAAGoD,aAAA,CAACxE,SAAS;QAACoB,IAAI,EAAGA;MAAM,CAAE,CAAG;MACpC4D,KAAK,EAAG/D,EAAE,CAAE,mBAAoB,CAAG;MACnCqE,YAAY,EAAGrE,EAAE,CAChB,4GACD;IAAG,CACH,CACG,CAAC,EACJ4D,iBACD,CAAC;EAEL;EAEA,OACCL,aAAA,CAAAa,QAAA,QACCb,aAAA;IAAA,GAAU3C;EAAU,GACnB2C,aAAA;IAAIe,KAAK,EAAC;EAAM,GACff,aAAA,CAACnD,mBAAmB;IAACuD,iBAAiB,EAAGN;EAAa,CAAE,CACrD,CACA,CAAC,EACJC,eAAe,EACfM,iBACD,CAAC;AAEL"}
|
|
1
|
+
{"version":3,"names":["BlockControls","BlockIcon","InspectorControls","store","blockEditorStore","useBlockProps","createBlock","PanelBody","Placeholder","ToggleControl","ToolbarButton","ToolbarGroup","useDispatch","useSelect","renderToString","__","icon","TableOfContentsList","linearToNestedHeadingList","useObserveHeadings","TableOfContentsEdit","attributes","headings","onlyIncludeCurrentPage","clientId","setAttributes","blockProps","canInsertList","select","getBlockRootClientId","canInsertBlockType","rootClientId","replaceBlocks","headingTree","toolbarControls","createElement","onClick","ordered","values","nestedHeadingList","inspectorControls","title","__nextHasNoMarginBottom","label","checked","onChange","value","help","length","Fragment","instructions","inert"],"sources":["@wordpress/block-library/src/table-of-contents/edit.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tstore as blockEditorStore,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock } from '@wordpress/blocks';\nimport {\n\tPanelBody,\n\tPlaceholder,\n\tToggleControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { renderToString } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport icon from './icon';\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\nimport { useObserveHeadings } from './hooks';\n\n/** @typedef {import('./utils').HeadingData} HeadingData */\n\n/**\n * Table of Contents block edit component.\n *\n * @param {Object} props The props.\n * @param {Object} props.attributes The block attributes.\n * @param {HeadingData[]} props.attributes.headings A list of data for each heading in the post.\n * @param {boolean} props.attributes.onlyIncludeCurrentPage Whether to only include headings from the current page (if the post is paginated).\n * @param {string} props.clientId\n * @param {(attributes: Object) => void} props.setAttributes\n *\n * @return {WPComponent} The component.\n */\nexport default function TableOfContentsEdit( {\n\tattributes: { headings = [], onlyIncludeCurrentPage },\n\tclientId,\n\tsetAttributes,\n} ) {\n\tuseObserveHeadings( clientId );\n\n\tconst blockProps = useBlockProps();\n\n\tconst canInsertList = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockRootClientId, canInsertBlockType } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn canInsertBlockType( 'core/list', rootClientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\n\tconst headingTree = linearToNestedHeadingList( headings );\n\n\tconst toolbarControls = canInsertList && (\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t<ToolbarButton\n\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\treplaceBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlock( 'core/list', {\n\t\t\t\t\t\t\t\tordered: true,\n\t\t\t\t\t\t\t\tvalues: renderToString(\n\t\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\t\tnestedHeadingList={ headingTree }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Convert to static list' ) }\n\t\t\t\t</ToolbarButton>\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\tlabel={ __( 'Only include current page' ) }\n\t\t\t\t\tchecked={ onlyIncludeCurrentPage }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { onlyIncludeCurrentPage: value } )\n\t\t\t\t\t}\n\t\t\t\t\thelp={\n\t\t\t\t\t\tonlyIncludeCurrentPage\n\t\t\t\t\t\t\t? __(\n\t\t\t\t\t\t\t\t\t'Only including headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t'Toggle to only include headings from the current page (if the post is paginated).'\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\t// If there are no headings or the only heading is empty.\n\t// Note that the toolbar controls are intentionally omitted since the\n\t// \"Convert to static list\" option is useless to the placeholder state.\n\tif ( headings.length === 0 ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<div { ...blockProps }>\n\t\t\t\t\t<Placeholder\n\t\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\t\tlabel={ __( 'Table of Contents' ) }\n\t\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t\t'Start adding Heading blocks to create a table of contents. Headings with HTML anchors will be linked here.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t\t{ inspectorControls }\n\t\t\t</>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<nav { ...blockProps }>\n\t\t\t\t<ol inert=\"true\">\n\t\t\t\t\t<TableOfContentsList nestedHeadingList={ headingTree } />\n\t\t\t\t</ol>\n\t\t\t</nav>\n\t\t\t{ toolbarControls }\n\t\t\t{ inspectorControls }\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SACCA,aAAa,EACbC,SAAS,EACTC,iBAAiB,EACjBC,KAAK,IAAIC,gBAAgB,EACzBC,aAAa,QACP,yBAAyB;AAChC,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SACCC,SAAS,EACTC,WAAW,EACXC,aAAa,EACbC,aAAa,EACbC,YAAY,QACN,uBAAuB;AAC9B,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,EAAE,QAAQ,iBAAiB;;AAEpC;AACA;AACA;AACA,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,mBAAmB,MAAM,QAAQ;AACxC,SAASC,yBAAyB,QAAQ,SAAS;AACnD,SAASC,kBAAkB,QAAQ,SAAS;;AAE5C;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,mBAAmBA,CAAE;EAC5CC,UAAU,EAAE;IAAEC,QAAQ,GAAG,EAAE;IAAEC;EAAuB,CAAC;EACrDC,QAAQ;EACRC;AACD,CAAC,EAAG;EACHN,kBAAkB,CAAEK,QAAS,CAAC;EAE9B,MAAME,UAAU,GAAGrB,aAAa,CAAC,CAAC;EAElC,MAAMsB,aAAa,GAAGd,SAAS,CAC5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KO,QAAQ,CAAC0B,MAAM,KAAK,CAAC,EAAG;IAC5B,OACCb,aAAA,CAAAc,QAAA,QACCd,aAAA;MAAA,GAAUT;IAAU,GACnBS,aAAA,CAAC3B,WAAW;MACXQ,IAAI,EAAGmB,aAAA,CAAClC,SAAS;QAACe,IAAI,EAAGA;MAAM,CAAE,CAAG;MACpC2B,KAAK,EAAG5B,EAAE,CAAE,mBAAoB,CAAG;MACnCmC,YAAY,EAAGnC,EAAE,CAChB,4GACD;IAAG,CACH,CACG,CAAC,EACJyB,iBACD,CAAC;EAEL;EAEA,OACCL,aAAA,CAAAc,QAAA,QACCd,aAAA;IAAA,GAAUT;EAAU,GACnBS,aAAA;IAAIgB,KAAK,EAAC;EAAM,GACfhB,aAAA,CAAClB,mBAAmB;IAACsB,iBAAiB,EAAGN;EAAa,CAAE,CACrD,CACA,CAAC,EACJC,eAAe,EACfM,iBACD,CAAC;AAEL"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useRegistry } from '@wordpress/data';
|
|
10
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
11
|
+
import { useEffect } from '@wordpress/element';
|
|
12
|
+
import { addQueryArgs, removeQueryArgs } from '@wordpress/url';
|
|
13
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
14
|
+
function getLatestHeadings(select, clientId) {
|
|
15
|
+
var _select$getPermalink, _getBlockAttributes;
|
|
16
|
+
const {
|
|
17
|
+
getBlockAttributes,
|
|
18
|
+
getBlockName,
|
|
19
|
+
getClientIdsWithDescendants,
|
|
20
|
+
__experimentalGetGlobalBlocksByName: getGlobalBlocksByName
|
|
21
|
+
} = select(blockEditorStore);
|
|
22
|
+
|
|
23
|
+
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
24
|
+
// Blocks can be loaded into a *non-post* block editor, so to avoid
|
|
25
|
+
// declaring @wordpress/editor as a dependency, we must access its
|
|
26
|
+
// store by string. When the store is not available, editorSelectors
|
|
27
|
+
// will be null, and the block's saved markup will lack permalinks.
|
|
28
|
+
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
29
|
+
const permalink = (_select$getPermalink = select('core/editor').getPermalink()) !== null && _select$getPermalink !== void 0 ? _select$getPermalink : null;
|
|
30
|
+
const isPaginated = getGlobalBlocksByName('core/nextpage').length !== 0;
|
|
31
|
+
const {
|
|
32
|
+
onlyIncludeCurrentPage
|
|
33
|
+
} = (_getBlockAttributes = getBlockAttributes(clientId)) !== null && _getBlockAttributes !== void 0 ? _getBlockAttributes : {};
|
|
34
|
+
|
|
35
|
+
// Get the client ids of all blocks in the editor.
|
|
36
|
+
const allBlockClientIds = getClientIdsWithDescendants();
|
|
37
|
+
|
|
38
|
+
// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.
|
|
39
|
+
let tocPage = 1;
|
|
40
|
+
if (isPaginated && onlyIncludeCurrentPage) {
|
|
41
|
+
// We can't use getBlockIndex because it only returns the index
|
|
42
|
+
// relative to sibling blocks.
|
|
43
|
+
const tocIndex = allBlockClientIds.indexOf(clientId);
|
|
44
|
+
for (const [blockIndex, blockClientId] of allBlockClientIds.entries()) {
|
|
45
|
+
// If we've reached blocks after the Table of Contents, we've
|
|
46
|
+
// finished calculating which page the block is on.
|
|
47
|
+
if (blockIndex >= tocIndex) {
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
if (getBlockName(blockClientId) === 'core/nextpage') {
|
|
51
|
+
tocPage++;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const latestHeadings = [];
|
|
56
|
+
|
|
57
|
+
/** The page (of a paginated post) a heading will be part of. */
|
|
58
|
+
let headingPage = 1;
|
|
59
|
+
let headingPageLink = null;
|
|
60
|
+
|
|
61
|
+
// If the core/editor store is available, we can add permalinks to the
|
|
62
|
+
// generated table of contents.
|
|
63
|
+
if (typeof permalink === 'string') {
|
|
64
|
+
headingPageLink = isPaginated ? addQueryArgs(permalink, {
|
|
65
|
+
page: headingPage
|
|
66
|
+
}) : permalink;
|
|
67
|
+
}
|
|
68
|
+
for (const blockClientId of allBlockClientIds) {
|
|
69
|
+
const blockName = getBlockName(blockClientId);
|
|
70
|
+
if (blockName === 'core/nextpage') {
|
|
71
|
+
headingPage++;
|
|
72
|
+
|
|
73
|
+
// If we're only including headings from the current page (of
|
|
74
|
+
// a paginated post), then exit the loop if we've reached the
|
|
75
|
+
// pages after the one with the Table of Contents block.
|
|
76
|
+
if (onlyIncludeCurrentPage && headingPage > tocPage) {
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
if (typeof permalink === 'string') {
|
|
80
|
+
headingPageLink = addQueryArgs(removeQueryArgs(permalink, ['page']), {
|
|
81
|
+
page: headingPage
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// If we're including all headings or we've reached headings on
|
|
86
|
+
// the same page as the Table of Contents block, add them to the
|
|
87
|
+
// list.
|
|
88
|
+
else if (!onlyIncludeCurrentPage || headingPage === tocPage) {
|
|
89
|
+
if (blockName === 'core/heading') {
|
|
90
|
+
const headingAttributes = getBlockAttributes(blockClientId);
|
|
91
|
+
const canBeLinked = typeof headingPageLink === 'string' && typeof headingAttributes.anchor === 'string' && headingAttributes.anchor !== '';
|
|
92
|
+
latestHeadings.push({
|
|
93
|
+
// Convert line breaks to spaces, and get rid of HTML tags in the headings.
|
|
94
|
+
content: stripHTML(headingAttributes.content.replace(/(<br *\/?>)+/g, ' ')),
|
|
95
|
+
level: headingAttributes.level,
|
|
96
|
+
link: canBeLinked ? `${headingPageLink}#${headingAttributes.anchor}` : null
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return latestHeadings;
|
|
102
|
+
}
|
|
103
|
+
function observeCallback(select, dispatch, clientId) {
|
|
104
|
+
const {
|
|
105
|
+
getBlockAttributes
|
|
106
|
+
} = select(blockEditorStore);
|
|
107
|
+
const {
|
|
108
|
+
updateBlockAttributes,
|
|
109
|
+
__unstableMarkNextChangeAsNotPersistent
|
|
110
|
+
} = dispatch(blockEditorStore);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* If the block no longer exists in the store, skip the update.
|
|
114
|
+
* The "undo" action recreates the block and provides a new `clientId`.
|
|
115
|
+
* The hook still might be observing the changes while the old block unmounts.
|
|
116
|
+
*/
|
|
117
|
+
const attributes = getBlockAttributes(clientId);
|
|
118
|
+
if (attributes === null) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const headings = getLatestHeadings(select, clientId);
|
|
122
|
+
if (!fastDeepEqual(headings, attributes.headings)) {
|
|
123
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
124
|
+
updateBlockAttributes(clientId, {
|
|
125
|
+
headings
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export function useObserveHeadings(clientId) {
|
|
130
|
+
const registry = useRegistry();
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
// Todo: Limit subscription to block editor store when data no longer depends on `getPermalink`.
|
|
133
|
+
// See: https://github.com/WordPress/gutenberg/pull/45513
|
|
134
|
+
return registry.subscribe(() => observeCallback(registry.select, registry.dispatch, clientId));
|
|
135
|
+
}, [registry, clientId]);
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["fastDeepEqual","useRegistry","__unstableStripHTML","stripHTML","useEffect","addQueryArgs","removeQueryArgs","store","blockEditorStore","getLatestHeadings","select","clientId","_select$getPermalink","_getBlockAttributes","getBlockAttributes","getBlockName","getClientIdsWithDescendants","__experimentalGetGlobalBlocksByName","getGlobalBlocksByName","permalink","getPermalink","isPaginated","length","onlyIncludeCurrentPage","allBlockClientIds","tocPage","tocIndex","indexOf","blockIndex","blockClientId","entries","latestHeadings","headingPage","headingPageLink","page","blockName","headingAttributes","canBeLinked","anchor","push","content","replace","level","link","observeCallback","dispatch","updateBlockAttributes","__unstableMarkNextChangeAsNotPersistent","attributes","headings","useObserveHeadings","registry","subscribe"],"sources":["@wordpress/block-library/src/table-of-contents/hooks.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport fastDeepEqual from 'fast-deep-equal/es6';\n\n/**\n * WordPress dependencies\n */\nimport { useRegistry } from '@wordpress/data';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { useEffect } from '@wordpress/element';\nimport { addQueryArgs, removeQueryArgs } from '@wordpress/url';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction getLatestHeadings( select, clientId ) {\n\tconst {\n\t\tgetBlockAttributes,\n\t\tgetBlockName,\n\t\tgetClientIdsWithDescendants,\n\t\t__experimentalGetGlobalBlocksByName: getGlobalBlocksByName,\n\t} = select( blockEditorStore );\n\n\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t// Blocks can be loaded into a *non-post* block editor, so to avoid\n\t// declaring @wordpress/editor as a dependency, we must access its\n\t// store by string. When the store is not available, editorSelectors\n\t// will be null, and the block's saved markup will lack permalinks.\n\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\tconst permalink = select( 'core/editor' ).getPermalink() ?? null;\n\n\tconst isPaginated = getGlobalBlocksByName( 'core/nextpage' ).length !== 0;\n\tconst { onlyIncludeCurrentPage } = getBlockAttributes( clientId ) ?? {};\n\n\t// Get the client ids of all blocks in the editor.\n\tconst allBlockClientIds = getClientIdsWithDescendants();\n\n\t// If onlyIncludeCurrentPage is true, calculate the page (of a paginated post) this block is part of, so we know which headings to include; otherwise, skip the calculation.\n\tlet tocPage = 1;\n\n\tif ( isPaginated && onlyIncludeCurrentPage ) {\n\t\t// We can't use getBlockIndex because it only returns the index\n\t\t// relative to sibling blocks.\n\t\tconst tocIndex = allBlockClientIds.indexOf( clientId );\n\n\t\tfor ( const [\n\t\t\tblockIndex,\n\t\t\tblockClientId,\n\t\t] of allBlockClientIds.entries() ) {\n\t\t\t// If we've reached blocks after the Table of Contents, we've\n\t\t\t// finished calculating which page the block is on.\n\t\t\tif ( blockIndex >= tocIndex ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif ( getBlockName( blockClientId ) === 'core/nextpage' ) {\n\t\t\t\ttocPage++;\n\t\t\t}\n\t\t}\n\t}\n\n\tconst latestHeadings = [];\n\n\t/** The page (of a paginated post) a heading will be part of. */\n\tlet headingPage = 1;\n\tlet headingPageLink = null;\n\n\t// If the core/editor store is available, we can add permalinks to the\n\t// generated table of contents.\n\tif ( typeof permalink === 'string' ) {\n\t\theadingPageLink = isPaginated\n\t\t\t? addQueryArgs( permalink, { page: headingPage } )\n\t\t\t: permalink;\n\t}\n\n\tfor ( const blockClientId of allBlockClientIds ) {\n\t\tconst blockName = getBlockName( blockClientId );\n\t\tif ( blockName === 'core/nextpage' ) {\n\t\t\theadingPage++;\n\n\t\t\t// If we're only including headings from the current page (of\n\t\t\t// a paginated post), then exit the loop if we've reached the\n\t\t\t// pages after the one with the Table of Contents block.\n\t\t\tif ( onlyIncludeCurrentPage && headingPage > tocPage ) {\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tif ( typeof permalink === 'string' ) {\n\t\t\t\theadingPageLink = addQueryArgs(\n\t\t\t\t\tremoveQueryArgs( permalink, [ 'page' ] ),\n\t\t\t\t\t{ page: headingPage }\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\t// If we're including all headings or we've reached headings on\n\t\t// the same page as the Table of Contents block, add them to the\n\t\t// list.\n\t\telse if ( ! onlyIncludeCurrentPage || headingPage === tocPage ) {\n\t\t\tif ( blockName === 'core/heading' ) {\n\t\t\t\tconst headingAttributes = getBlockAttributes( blockClientId );\n\n\t\t\t\tconst canBeLinked =\n\t\t\t\t\ttypeof headingPageLink === 'string' &&\n\t\t\t\t\ttypeof headingAttributes.anchor === 'string' &&\n\t\t\t\t\theadingAttributes.anchor !== '';\n\n\t\t\t\tlatestHeadings.push( {\n\t\t\t\t\t// Convert line breaks to spaces, and get rid of HTML tags in the headings.\n\t\t\t\t\tcontent: stripHTML(\n\t\t\t\t\t\theadingAttributes.content.replace(\n\t\t\t\t\t\t\t/(<br *\\/?>)+/g,\n\t\t\t\t\t\t\t' '\n\t\t\t\t\t\t)\n\t\t\t\t\t),\n\t\t\t\t\tlevel: headingAttributes.level,\n\t\t\t\t\tlink: canBeLinked\n\t\t\t\t\t\t? `${ headingPageLink }#${ headingAttributes.anchor }`\n\t\t\t\t\t\t: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn latestHeadings;\n}\n\nfunction observeCallback( select, dispatch, clientId ) {\n\tconst { getBlockAttributes } = select( blockEditorStore );\n\tconst { updateBlockAttributes, __unstableMarkNextChangeAsNotPersistent } =\n\t\tdispatch( blockEditorStore );\n\n\t/**\n\t * If the block no longer exists in the store, skip the update.\n\t * The \"undo\" action recreates the block and provides a new `clientId`.\n\t * The hook still might be observing the changes while the old block unmounts.\n\t */\n\tconst attributes = getBlockAttributes( clientId );\n\tif ( attributes === null ) {\n\t\treturn;\n\t}\n\n\tconst headings = getLatestHeadings( select, clientId );\n\tif ( ! fastDeepEqual( headings, attributes.headings ) ) {\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tupdateBlockAttributes( clientId, { headings } );\n\t}\n}\n\nexport function useObserveHeadings( clientId ) {\n\tconst registry = useRegistry();\n\tuseEffect( () => {\n\t\t// Todo: Limit subscription to block editor store when data no longer depends on `getPermalink`.\n\t\t// See: https://github.com/WordPress/gutenberg/pull/45513\n\t\treturn registry.subscribe( () =>\n\t\t\tobserveCallback( registry.select, registry.dispatch, clientId )\n\t\t);\n\t}, [ registry, clientId ] );\n}\n"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__experimental","name","title","category","description","keywords","textdomain","attributes","headings","type","items","onlyIncludeCurrentPage","supports","html","color","text","background","gradients","link","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","example","edit","icon","save","settings","init"],"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport icon from './icon';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,QAAA;MAAAC,IAAA;MAAAC,KAAA;QAAAD,IAAA;MAAA;IAAA;IAAAE,sBAAA;MAAAF,IAAA;MAAA;IAAA;EAAA;EAAAG,QAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,UAAA;MAAAC,SAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAC,6BAAA;QAAAR,QAAA;MAAA;IAAA;EAAA;EAAAS,OAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAElC;AAAK,CAAC,GAAGJ,QAAQ;AAEzB,SAASA,QAAQ,EAAEI,IAAI;AAEvB,OAAO,MAAMmC,QAAQ,GAAG;EACvBF,IAAI;EACJD,IAAI;EACJE;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMzC,SAAS,CAAE;EAAEK,IAAI;EAAEJ,QAAQ;EAAEuC;AAAS,CAAE,CAAC"}
|
|
1
|
+
{"version":3,"names":["initBlock","metadata","$schema","apiVersion","__experimental","name","title","category","description","keywords","textdomain","attributes","headings","type","items","onlyIncludeCurrentPage","supports","html","color","text","background","gradients","link","spacing","margin","padding","typography","fontSize","lineHeight","__experimentalFontFamily","__experimentalFontWeight","__experimentalFontStyle","__experimentalTextTransform","__experimentalTextDecoration","__experimentalLetterSpacing","__experimentalDefaultControls","example","edit","icon","save","settings","init"],"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport icon from './icon';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,SAAS,MAAM,qBAAqB;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,cAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,QAAA;MAAAC,IAAA;MAAAC,KAAA;QAAAD,IAAA;MAAA;MAAA;IAAA;IAAAE,sBAAA;MAAAF,IAAA;MAAA;IAAA;EAAA;EAAAG,QAAA;IAAAC,IAAA;IAAAC,KAAA;MAAAC,IAAA;MAAAC,UAAA;MAAAC,SAAA;MAAAC,IAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,UAAA;MAAAC,wBAAA;MAAAC,wBAAA;MAAAC,uBAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAC,2BAAA;MAAAC,6BAAA;QAAAR,QAAA;MAAA;IAAA;EAAA;EAAAS,OAAA;AAAA;AAE5C,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,IAAI,MAAM,QAAQ;AAEzB,MAAM;EAAElC;AAAK,CAAC,GAAGJ,QAAQ;AAEzB,SAASA,QAAQ,EAAEI,IAAI;AAEvB,OAAO,MAAMmC,QAAQ,GAAG;EACvBF,IAAI;EACJD,IAAI;EACJE;AACD,CAAC;AAED,OAAO,MAAME,IAAI,GAAGA,CAAA,KAAMzC,SAAS,CAAE;EAAEK,IAAI;EAAEJ,QAAQ;EAAEuC;AAAS,CAAE,CAAC"}
|
|
@@ -9,11 +9,13 @@ import classnames from 'classnames';
|
|
|
9
9
|
*/
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { RichText, BlockControls, AlignmentToolbar, useBlockProps } from '@wordpress/block-editor';
|
|
12
|
+
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
12
13
|
export default function VerseEdit({
|
|
13
14
|
attributes,
|
|
14
15
|
setAttributes,
|
|
15
16
|
mergeBlocks,
|
|
16
17
|
onRemove,
|
|
18
|
+
insertBlocksAfter,
|
|
17
19
|
style
|
|
18
20
|
}) {
|
|
19
21
|
const {
|
|
@@ -49,7 +51,8 @@ export default function VerseEdit({
|
|
|
49
51
|
onMerge: mergeBlocks,
|
|
50
52
|
textAlign: textAlign,
|
|
51
53
|
...blockProps,
|
|
52
|
-
__unstablePastePlainText: true
|
|
54
|
+
__unstablePastePlainText: true,
|
|
55
|
+
__unstableOnSplitAtDoubleLineEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
|
|
53
56
|
}));
|
|
54
57
|
}
|
|
55
58
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["classnames","__","RichText","BlockControls","AlignmentToolbar","useBlockProps","VerseEdit","attributes","setAttributes","mergeBlocks","onRemove","style","textAlign","content","blockProps","className","createElement","Fragment","value","onChange","nextAlign","tagName","identifier","preserveWhiteSpace","nextContent","placeholder","onMerge","__unstablePastePlainText"],"sources":["@wordpress/block-library/src/verse/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tBlockControls,\n\tAlignmentToolbar,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nexport default function VerseEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonRemove,\n\tstyle,\n} ) {\n\tconst { textAlign, content } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t\tstyle,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<AlignmentToolbar\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<RichText\n\t\t\t\ttagName=\"pre\"\n\t\t\t\tidentifier=\"content\"\n\t\t\t\tpreserveWhiteSpace\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( nextContent ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: nextContent,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Verse text' ) }\n\t\t\t\tplaceholder={ __( 'Write verse…' ) }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\ttextAlign={ textAlign }\n\t\t\t\t{ ...blockProps }\n\t\t\t\t__unstablePastePlainText\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,QACP,yBAAyB;
|
|
1
|
+
{"version":3,"names":["classnames","__","RichText","BlockControls","AlignmentToolbar","useBlockProps","createBlock","getDefaultBlockName","VerseEdit","attributes","setAttributes","mergeBlocks","onRemove","insertBlocksAfter","style","textAlign","content","blockProps","className","createElement","Fragment","value","onChange","nextAlign","tagName","identifier","preserveWhiteSpace","nextContent","placeholder","onMerge","__unstablePastePlainText","__unstableOnSplitAtDoubleLineEnd"],"sources":["@wordpress/block-library/src/verse/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tRichText,\n\tBlockControls,\n\tAlignmentToolbar,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { createBlock, getDefaultBlockName } from '@wordpress/blocks';\n\nexport default function VerseEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonRemove,\n\tinsertBlocksAfter,\n\tstyle,\n} ) {\n\tconst { textAlign, content } = attributes;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t\tstyle,\n\t} );\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls>\n\t\t\t\t<AlignmentToolbar\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<RichText\n\t\t\t\ttagName=\"pre\"\n\t\t\t\tidentifier=\"content\"\n\t\t\t\tpreserveWhiteSpace\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( nextContent ) => {\n\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\tcontent: nextContent,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\taria-label={ __( 'Verse text' ) }\n\t\t\t\tplaceholder={ __( 'Write verse…' ) }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\ttextAlign={ textAlign }\n\t\t\t\t{ ...blockProps }\n\t\t\t\t__unstablePastePlainText\n\t\t\t\t__unstableOnSplitAtDoubleLineEnd={ () =>\n\t\t\t\t\tinsertBlocksAfter( createBlock( getDefaultBlockName() ) )\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,OAAOA,UAAU,MAAM,YAAY;;AAEnC;AACA;AACA;AACA,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SACCC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,QACP,yBAAyB;AAChC,SAASC,WAAW,EAAEC,mBAAmB,QAAQ,mBAAmB;AAEpE,eAAe,SAASC,SAASA,CAAE;EAClCC,UAAU;EACVC,aAAa;EACbC,WAAW;EACXC,QAAQ;EACRC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,MAAM;IAAEC,SAAS;IAAEC;EAAQ,CAAC,GAAGP,UAAU;EACzC,MAAMQ,UAAU,GAAGZ,aAAa,CAAE;IACjCa,SAAS,EAAElB,UAAU,CAAE;MACtB,CAAG,kBAAkBe,SAAW,EAAC,GAAIA;IACtC,CAAE,CAAC;IACHD;EACD,CAAE,CAAC;EAEH,OACCK,aAAA,CAAAC,QAAA,QACCD,aAAA,CAAChB,aAAa,QACbgB,aAAA,CAACf,gBAAgB;IAChBiB,KAAK,EAAGN,SAAW;IACnBO,QAAQ,EAAKC,SAAS,IAAM;MAC3Bb,aAAa,CAAE;QAAEK,SAAS,EAAEQ;MAAU,CAAE,CAAC;IAC1C;EAAG,CACH,CACa,CAAC,EAChBJ,aAAA,CAACjB,QAAQ;IACRsB,OAAO,EAAC,KAAK;IACbC,UAAU,EAAC,SAAS;IACpBC,kBAAkB;IAClBL,KAAK,EAAGL,OAAS;IACjBM,QAAQ,EAAKK,WAAW,IAAM;MAC7BjB,aAAa,CAAE;QACdM,OAAO,EAAEW;MACV,CAAE,CAAC;IACJ,CAAG;IACH,cAAa1B,EAAE,CAAE,YAAa,CAAG;IACjC2B,WAAW,EAAG3B,EAAE,CAAE,cAAe,CAAG;IACpCW,QAAQ,EAAGA,QAAU;IACrBiB,OAAO,EAAGlB,WAAa;IACvBI,SAAS,EAAGA,SAAW;IAAA,GAClBE,UAAU;IACfa,wBAAwB;IACxBC,gCAAgC,EAAGA,CAAA,KAClClB,iBAAiB,CAAEP,WAAW,CAAEC,mBAAmB,CAAC,CAAE,CAAE;EACxD,CACD,CACA,CAAC;AAEL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","verse","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","textAlign","supports","anchor","color","gradients","link","__experimentalDefaultControls","background","text","typography","fontSize","__experimentalFontFamily","lineHeight","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","fontAppearance","spacing","margin","padding","__experimentalBorder","radius","width","style","editorStyle","save","transforms","settings","example","merge","attributesToMerge","init"],"sources":["@wordpress/block-library/src/verse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { verse as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Verse block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'WHAT was he doing, the great god Pan,\\n\tDown in the reeds by the river?\\nSpreading ruin and scattering ban,\\nSplashing and paddling with hoofs of a goat,\\nAnd breaking the golden lilies afloat\\n With the dragon-fly on the river.'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;;AAEhD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAA;MAAAC,4BAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAL,IAAA;IAAA;EAAA;EAAAM,QAAA;IAAAC,MAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,wBAAA;MAAAC,UAAA;MAAAC,uBAAA;MAAAC,wBAAA;MAAAC,2BAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAX,6BAAA;QAAAI,QAAA;QAAAQ,cAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAf,6BAAA;QAAAc,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,oBAAA;MAAAC,MAAA;MAAAC,KAAA;MAAArB,KAAA;MAAAsB,KAAA;IAAA;EAAA;EAAAA,KAAA;EAAAC,WAAA;AAAA;AAE1B,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAEzC;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM0C,QAAQ,GAAG;EACvBjD,IAAI;EACJkD,OAAO,EAAE;IACRrC,UAAU,EAAE;MACX;MACA;MACAC,OAAO,EAAEhB,EAAE,CACV,yOACD;MACA;IACD;EACD,CAAC;;EACDkD,UAAU;EACV9C,UAAU;EACViD,KAAKA,CAAEtC,UAAU,EAAEuC,iBAAiB,EAAG;IACtC,OAAO;MACNtC,OAAO,EAAED,UAAU,CAACC,OAAO,GAAGsC,iBAAiB,CAACtC;
|
|
1
|
+
{"version":3,"names":["__","verse","icon","initBlock","deprecated","edit","metadata","$schema","apiVersion","name","title","category","description","keywords","textdomain","attributes","content","type","source","selector","__unstablePreserveWhiteSpace","__experimentalRole","textAlign","supports","anchor","color","gradients","link","__experimentalDefaultControls","background","text","typography","fontSize","__experimentalFontFamily","lineHeight","__experimentalFontStyle","__experimentalFontWeight","__experimentalLetterSpacing","__experimentalTextTransform","__experimentalTextDecoration","fontAppearance","spacing","margin","padding","__experimentalBorder","radius","width","style","editorStyle","save","transforms","settings","example","merge","attributesToMerge","init"],"sources":["@wordpress/block-library/src/verse/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { verse as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\t/* eslint-disable @wordpress/i18n-no-collapsible-whitespace */\n\t\t\t// translators: Sample content for the Verse block. Can be replaced with a more locale-adequate work.\n\t\t\tcontent: __(\n\t\t\t\t'WHAT was he doing, the great god Pan,\\n\tDown in the reeds by the river?\\nSpreading ruin and scattering ban,\\nSplashing and paddling with hoofs of a goat,\\nAnd breaking the golden lilies afloat\\n With the dragon-fly on the river.'\n\t\t\t),\n\t\t\t/* eslint-enable @wordpress/i18n-no-collapsible-whitespace */\n\t\t},\n\t},\n\ttransforms,\n\tdeprecated,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\tcontent: attributes.content + '\\n\\n' + attributesToMerge.content,\n\t\t};\n\t},\n\tedit,\n\tsave,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,KAAK,IAAIC,IAAI,QAAQ,kBAAkB;;AAEhD;AACA;AACA;AACA,OAAOC,SAAS,MAAM,qBAAqB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,IAAI,MAAM,QAAQ;AAAC,MAAAC,QAAA;EAAAC,OAAA;EAAAC,UAAA;EAAAC,IAAA;EAAAC,KAAA;EAAAC,QAAA;EAAAC,WAAA;EAAAC,QAAA;EAAAC,UAAA;EAAAC,UAAA;IAAAC,OAAA;MAAAC,IAAA;MAAAC,MAAA;MAAAC,QAAA;MAAA;MAAAC,4BAAA;MAAAC,kBAAA;IAAA;IAAAC,SAAA;MAAAL,IAAA;IAAA;EAAA;EAAAM,QAAA;IAAAC,MAAA;IAAAC,KAAA;MAAAC,SAAA;MAAAC,IAAA;MAAAC,6BAAA;QAAAC,UAAA;QAAAC,IAAA;MAAA;IAAA;IAAAC,UAAA;MAAAC,QAAA;MAAAC,wBAAA;MAAAC,UAAA;MAAAC,uBAAA;MAAAC,wBAAA;MAAAC,2BAAA;MAAAC,2BAAA;MAAAC,4BAAA;MAAAX,6BAAA;QAAAI,QAAA;QAAAQ,cAAA;MAAA;IAAA;IAAAC,OAAA;MAAAC,MAAA;MAAAC,OAAA;MAAAf,6BAAA;QAAAc,MAAA;QAAAC,OAAA;MAAA;IAAA;IAAAC,oBAAA;MAAAC,MAAA;MAAAC,KAAA;MAAArB,KAAA;MAAAsB,KAAA;IAAA;EAAA;EAAAA,KAAA;EAAAC,WAAA;AAAA;AAE1B,OAAOC,IAAI,MAAM,QAAQ;AACzB,OAAOC,UAAU,MAAM,cAAc;AAErC,MAAM;EAAEzC;AAAK,CAAC,GAAGH,QAAQ;AAEzB,SAASA,QAAQ,EAAEG,IAAI;AAEvB,OAAO,MAAM0C,QAAQ,GAAG;EACvBjD,IAAI;EACJkD,OAAO,EAAE;IACRrC,UAAU,EAAE;MACX;MACA;MACAC,OAAO,EAAEhB,EAAE,CACV,yOACD;MACA;IACD;EACD,CAAC;;EACDkD,UAAU;EACV9C,UAAU;EACViD,KAAKA,CAAEtC,UAAU,EAAEuC,iBAAiB,EAAG;IACtC,OAAO;MACNtC,OAAO,EAAED,UAAU,CAACC,OAAO,GAAG,MAAM,GAAGsC,iBAAiB,CAACtC;IAC1D,CAAC;EACF,CAAC;EACDX,IAAI;EACJ4C;AACD,CAAC;AAED,OAAO,MAAMM,IAAI,GAAGA,CAAA,KAAMpD,SAAS,CAAE;EAAEM,IAAI;EAAEH,QAAQ;EAAE6C;AAAS,CAAE,CAAC"}
|
|
@@ -379,6 +379,15 @@
|
|
|
379
379
|
.wp-block-cover-image.has-custom-content-position.has-custom-content-position .wp-block-cover__inner-container,
|
|
380
380
|
.wp-block-cover.has-custom-content-position.has-custom-content-position .wp-block-cover__inner-container {
|
|
381
381
|
margin: 0;
|
|
382
|
+
}
|
|
383
|
+
.wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-top-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-top-right .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-center-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-center-right .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-bottom-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-bottom-right .wp-block-cover__inner-container,
|
|
384
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-top-left .wp-block-cover__inner-container,
|
|
385
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-top-right .wp-block-cover__inner-container,
|
|
386
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-center-left .wp-block-cover__inner-container,
|
|
387
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-center-right .wp-block-cover__inner-container,
|
|
388
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-bottom-left .wp-block-cover__inner-container,
|
|
389
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-bottom-right .wp-block-cover__inner-container {
|
|
390
|
+
margin: 0;
|
|
382
391
|
width: auto;
|
|
383
392
|
}
|
|
384
393
|
.wp-block-cover-image .wp-block-cover__image-background,
|
|
@@ -381,6 +381,15 @@
|
|
|
381
381
|
.wp-block-cover-image.has-custom-content-position.has-custom-content-position .wp-block-cover__inner-container,
|
|
382
382
|
.wp-block-cover.has-custom-content-position.has-custom-content-position .wp-block-cover__inner-container {
|
|
383
383
|
margin: 0;
|
|
384
|
+
}
|
|
385
|
+
.wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-top-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-top-right .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-center-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-center-right .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-bottom-left .wp-block-cover__inner-container, .wp-block-cover-image.has-custom-content-position.has-custom-content-position.is-position-bottom-right .wp-block-cover__inner-container,
|
|
386
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-top-left .wp-block-cover__inner-container,
|
|
387
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-top-right .wp-block-cover__inner-container,
|
|
388
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-center-left .wp-block-cover__inner-container,
|
|
389
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-center-right .wp-block-cover__inner-container,
|
|
390
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-bottom-left .wp-block-cover__inner-container,
|
|
391
|
+
.wp-block-cover.has-custom-content-position.has-custom-content-position.is-position-bottom-right .wp-block-cover__inner-container {
|
|
392
|
+
margin: 0;
|
|
384
393
|
width: auto;
|
|
385
394
|
}
|
|
386
395
|
.wp-block-cover-image .wp-block-cover__image-background,
|
|
@@ -2101,15 +2101,6 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2101
2101
|
color: #000;
|
|
2102
2102
|
}
|
|
2103
2103
|
|
|
2104
|
-
.wp-block-navigation-link__missing_text-tooltip {
|
|
2105
|
-
position: absolute;
|
|
2106
|
-
width: 1px;
|
|
2107
|
-
height: 1px;
|
|
2108
|
-
padding: 0;
|
|
2109
|
-
margin: -1px;
|
|
2110
|
-
overflow: hidden;
|
|
2111
|
-
}
|
|
2112
|
-
|
|
2113
2104
|
/**
|
|
2114
2105
|
* Menu item setup state. Is shown when a menu item has no URL configured.
|
|
2115
2106
|
*/
|
|
@@ -2288,6 +2279,11 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2288
2279
|
opacity: 0;
|
|
2289
2280
|
}
|
|
2290
2281
|
|
|
2282
|
+
.block-editor-block-list__block[data-type="core/paragraph"].has-text-align-right[style*="writing-mode: vertical-rl"],
|
|
2283
|
+
.block-editor-block-list__block[data-type="core/paragraph"].has-text-align-left[style*="writing-mode: vertical-lr"] {
|
|
2284
|
+
rotate: 180deg;
|
|
2285
|
+
}
|
|
2286
|
+
|
|
2291
2287
|
.wp-block-post-excerpt .wp-block-post-excerpt__excerpt.is-inline {
|
|
2292
2288
|
display: inline;
|
|
2293
2289
|
}
|
|
@@ -2898,6 +2894,16 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2898
2894
|
margin-bottom: 24px;
|
|
2899
2895
|
}
|
|
2900
2896
|
|
|
2897
|
+
@media (min-width: 600px) {
|
|
2898
|
+
.wp-block-query__enhanced-pagination-modal {
|
|
2899
|
+
max-width: 480px;
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
.wp-block-query__enhanced-pagination-notice {
|
|
2904
|
+
margin: 0;
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2901
2907
|
.wp-block[data-align=center] > .wp-block-query-pagination {
|
|
2902
2908
|
justify-content: center;
|
|
2903
2909
|
}
|
package/build-style/editor.css
CHANGED
|
@@ -2109,15 +2109,6 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2109
2109
|
color: #000;
|
|
2110
2110
|
}
|
|
2111
2111
|
|
|
2112
|
-
.wp-block-navigation-link__missing_text-tooltip {
|
|
2113
|
-
position: absolute;
|
|
2114
|
-
width: 1px;
|
|
2115
|
-
height: 1px;
|
|
2116
|
-
padding: 0;
|
|
2117
|
-
margin: -1px;
|
|
2118
|
-
overflow: hidden;
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
2112
|
/**
|
|
2122
2113
|
* Menu item setup state. Is shown when a menu item has no URL configured.
|
|
2123
2114
|
*/
|
|
@@ -2296,6 +2287,11 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2296
2287
|
opacity: 0;
|
|
2297
2288
|
}
|
|
2298
2289
|
|
|
2290
|
+
.block-editor-block-list__block[data-type="core/paragraph"].has-text-align-right[style*="writing-mode: vertical-rl"],
|
|
2291
|
+
.block-editor-block-list__block[data-type="core/paragraph"].has-text-align-left[style*="writing-mode: vertical-lr"] {
|
|
2292
|
+
rotate: 180deg;
|
|
2293
|
+
}
|
|
2294
|
+
|
|
2299
2295
|
.wp-block-post-excerpt .wp-block-post-excerpt__excerpt.is-inline {
|
|
2300
2296
|
display: inline;
|
|
2301
2297
|
}
|
|
@@ -2906,6 +2902,16 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
2906
2902
|
margin-bottom: 24px;
|
|
2907
2903
|
}
|
|
2908
2904
|
|
|
2905
|
+
@media (min-width: 600px) {
|
|
2906
|
+
.wp-block-query__enhanced-pagination-modal {
|
|
2907
|
+
max-width: 480px;
|
|
2908
|
+
}
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
.wp-block-query__enhanced-pagination-notice {
|
|
2912
|
+
margin: 0;
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2909
2915
|
.wp-block[data-align=center] > .wp-block-query-pagination {
|
|
2910
2916
|
justify-content: center;
|
|
2911
2917
|
}
|