@wordpress/block-library 10.4.0 → 10.5.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 +36 -0
- package/build/accordion/view.cjs +2 -5
- package/build/accordion/view.cjs.map +2 -2
- package/build/accordion-heading/block.json +1 -0
- package/build/audio/edit.cjs.map +2 -2
- package/build/avatar/edit.cjs.map +2 -2
- package/build/block/block.json +2 -1
- package/build/column/edit.cjs +1 -1
- package/build/column/edit.cjs.map +2 -2
- package/build/columns/edit.cjs.map +2 -2
- package/build/columns/transforms.cjs +161 -2
- package/build/columns/transforms.cjs.map +2 -2
- package/build/cover/edit/block-controls.cjs +1 -1
- package/build/cover/edit/block-controls.cjs.map +2 -2
- package/build/cover/edit/index.cjs +1 -1
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs.map +3 -3
- package/build/embed/embed-placeholder.cjs.map +2 -2
- package/build/gallery/transforms.cjs +8 -0
- package/build/gallery/transforms.cjs.map +2 -2
- package/build/group/block.json +1 -1
- package/build/heading/transforms.cjs +36 -0
- package/build/heading/transforms.cjs.map +2 -2
- package/build/heading/variations.cjs +13 -1
- package/build/heading/variations.cjs.map +2 -2
- package/build/home-link/edit.cjs.map +3 -3
- package/build/icon/edit.cjs +7 -1
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +1 -1
- package/build/image/image.cjs.map +3 -3
- package/build/list/block.json +1 -0
- package/build/math/edit.cjs +4 -5
- package/build/math/edit.cjs.map +3 -3
- package/build/media-text/edit.cjs.map +3 -3
- package/build/more/block.json +1 -1
- package/build/navigation-link/shared/controls.cjs.map +3 -3
- package/build/playlist/block.json +0 -1
- package/build/playlist/edit.cjs +46 -22
- package/build/playlist/edit.cjs.map +2 -2
- package/build/playlist-track/block.json +16 -8
- package/build/playlist-track/edit.cjs +74 -67
- package/build/playlist-track/edit.cjs.map +3 -3
- package/build/post-template/edit.cjs +5 -1
- package/build/post-template/edit.cjs.map +2 -2
- package/build/post-title/edit.cjs +3 -8
- package/build/post-title/edit.cjs.map +2 -2
- package/build/private-apis.cjs +0 -12
- package/build/private-apis.cjs.map +3 -3
- package/build/query/block.json +3 -0
- package/build/query-no-results/block.json +16 -1
- package/build/rss/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +1 -1
- package/build/site-logo/edit.cjs.map +2 -2
- package/build/site-title/edit.cjs +2 -6
- package/build/site-title/edit.cjs.map +2 -2
- package/build/table-of-contents/block.json +2 -1
- package/build/table-of-contents/deprecated.cjs +165 -0
- package/build/table-of-contents/deprecated.cjs.map +7 -0
- package/build/table-of-contents/index.cjs +2 -2
- package/build/table-of-contents/index.cjs.map +3 -3
- package/build/tabs/view.cjs +32 -2
- package/build/tabs/view.cjs.map +2 -2
- package/build/term-template/edit.cjs +5 -1
- package/build/term-template/edit.cjs.map +2 -2
- package/build-module/accordion/view.mjs +2 -5
- package/build-module/accordion/view.mjs.map +2 -2
- package/build-module/accordion-heading/block.json +1 -0
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/edit.mjs.map +2 -2
- package/build-module/block/block.json +2 -1
- package/build-module/column/edit.mjs +1 -1
- package/build-module/column/edit.mjs.map +2 -2
- package/build-module/columns/edit.mjs.map +2 -2
- package/build-module/columns/transforms.mjs +164 -3
- package/build-module/columns/transforms.mjs.map +2 -2
- package/build-module/cover/edit/block-controls.mjs +1 -1
- package/build-module/cover/edit/block-controls.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +1 -1
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +2 -2
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/embed/embed-placeholder.mjs +2 -2
- package/build-module/embed/embed-placeholder.mjs.map +1 -1
- package/build-module/gallery/transforms.mjs +8 -0
- package/build-module/gallery/transforms.mjs.map +2 -2
- package/build-module/group/block.json +1 -1
- package/build-module/heading/transforms.mjs +36 -0
- package/build-module/heading/transforms.mjs.map +2 -2
- package/build-module/heading/variations.mjs +13 -1
- package/build-module/heading/variations.mjs.map +2 -2
- package/build-module/home-link/edit.mjs +2 -2
- package/build-module/home-link/edit.mjs.map +2 -2
- package/build-module/icon/edit.mjs +7 -1
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +4 -4
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/list/block.json +1 -0
- package/build-module/math/edit.mjs +4 -8
- package/build-module/math/edit.mjs.map +2 -2
- package/build-module/media-text/edit.mjs +2 -2
- package/build-module/media-text/edit.mjs.map +2 -2
- package/build-module/more/block.json +1 -1
- package/build-module/navigation-link/shared/controls.mjs +2 -2
- package/build-module/navigation-link/shared/controls.mjs.map +2 -2
- package/build-module/playlist/block.json +0 -1
- package/build-module/playlist/edit.mjs +46 -22
- package/build-module/playlist/edit.mjs.map +2 -2
- package/build-module/playlist-track/block.json +16 -8
- package/build-module/playlist-track/edit.mjs +76 -69
- package/build-module/playlist-track/edit.mjs.map +2 -2
- package/build-module/post-template/edit.mjs +5 -1
- package/build-module/post-template/edit.mjs.map +2 -2
- package/build-module/post-title/edit.mjs +3 -8
- package/build-module/post-title/edit.mjs.map +2 -2
- package/build-module/private-apis.mjs +0 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/query/block.json +3 -0
- package/build-module/query-no-results/block.json +16 -1
- package/build-module/rss/edit.mjs +2 -2
- package/build-module/rss/edit.mjs.map +1 -1
- package/build-module/site-logo/edit.mjs +1 -1
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/site-title/edit.mjs +2 -6
- package/build-module/site-title/edit.mjs.map +2 -2
- package/build-module/table-of-contents/block.json +2 -1
- package/build-module/table-of-contents/deprecated.mjs +144 -0
- package/build-module/table-of-contents/deprecated.mjs.map +7 -0
- package/build-module/table-of-contents/index.mjs +2 -2
- package/build-module/table-of-contents/index.mjs.map +2 -2
- package/build-module/tabs/view.mjs +32 -2
- package/build-module/tabs/view.mjs.map +2 -2
- package/build-module/term-template/edit.mjs +5 -1
- package/build-module/term-template/edit.mjs.map +2 -2
- package/build-style/categories/style-rtl.css +2 -1
- package/build-style/categories/style.css +2 -1
- package/build-style/comments/editor-rtl.css +8 -10
- package/build-style/comments/editor.css +8 -10
- package/build-style/comments/style-rtl.css +8 -7
- package/build-style/comments/style.css +8 -7
- package/build-style/editor-rtl.css +8 -10
- package/build-style/editor.css +8 -10
- package/build-style/form-input/style-rtl.css +7 -7
- package/build-style/form-input/style.css +7 -7
- package/build-style/post-comments-form/style-rtl.css +7 -6
- package/build-style/post-comments-form/style.css +7 -6
- package/build-style/query-no-results/style-rtl.css +3 -0
- package/build-style/query-no-results/style.css +3 -0
- package/build-style/search/style-rtl.css +1 -1
- package/build-style/search/style.css +1 -1
- package/build-style/search/theme-rtl.css +1 -1
- package/build-style/search/theme.css +1 -1
- package/build-style/style-rtl.css +34 -23
- package/build-style/style.css +34 -23
- package/build-style/tab-panel/style-rtl.css +5 -1
- package/build-style/tab-panel/style.css +5 -1
- package/build-style/theme-rtl.css +1 -1
- package/build-style/theme.css +1 -1
- package/package.json +43 -43
- package/src/accordion/view.js +2 -5
- package/src/accordion-heading/README.md +1 -0
- package/src/accordion-heading/block.json +1 -0
- package/src/audio/edit.js +13 -0
- package/src/avatar/edit.js +78 -0
- package/src/block/README.md +1 -0
- package/src/block/block.json +2 -1
- package/src/categories/style.scss +4 -4
- package/src/column/edit.js +15 -1
- package/src/columns/edit.js +18 -0
- package/src/columns/test/transforms.js +517 -1
- package/src/columns/transforms.js +207 -2
- package/src/comments/style.scss +7 -10
- package/src/cover/edit/block-controls.js +1 -1
- package/src/cover/edit/index.js +1 -1
- package/src/cover/edit/inspector-controls.js +2 -2
- package/src/embed/embed-placeholder.js +2 -2
- package/src/form-input/style.scss +2 -2
- package/src/gallery/test/edit.js +57 -0
- package/src/gallery/test/transforms.js +57 -0
- package/src/gallery/transforms.js +8 -0
- package/src/group/README.md +1 -1
- package/src/group/block.json +1 -1
- package/src/heading/transforms.js +36 -0
- package/src/heading/variations.js +12 -0
- package/src/home-link/edit.js +2 -2
- package/src/icon/edit.js +9 -1
- package/src/image/image.js +4 -4
- package/src/list/README.md +1 -0
- package/src/list/block.json +1 -0
- package/src/math/edit.js +4 -9
- package/src/media-text/edit.js +2 -2
- package/src/more/README.md +1 -1
- package/src/more/block.json +1 -1
- package/src/navigation/index.php +8 -2
- package/src/navigation-link/shared/controls.js +2 -2
- package/src/playlist/block.json +0 -1
- package/src/playlist/edit.js +54 -21
- package/src/playlist/test/edit-component.js +78 -27
- package/src/playlist-track/README.md +8 -8
- package/src/playlist-track/block.json +16 -8
- package/src/playlist-track/edit.js +56 -27
- package/src/playlist-track/test/edit.js +145 -41
- package/src/post-comments-form/style.scss +7 -9
- package/src/post-template/edit.js +10 -1
- package/src/post-title/edit.js +2 -9
- package/src/private-apis.js +0 -2
- package/src/query/README.md +2 -0
- package/src/query/block.json +3 -0
- package/src/query-no-results/README.md +3 -0
- package/src/query-no-results/block.json +16 -1
- package/src/query-no-results/style.scss +5 -0
- package/src/rss/edit.js +2 -2
- package/src/search/style.scss +1 -1
- package/src/search/theme.scss +2 -4
- package/src/site-logo/edit.js +1 -1
- package/src/site-title/edit.js +1 -10
- package/src/social-link/index.php +6 -13
- package/src/style.scss +1 -0
- package/src/tab-panel/index.php +14 -5
- package/src/tab-panel/style.scss +7 -1
- package/src/table-of-contents/README.md +6 -6
- package/src/table-of-contents/block.json +2 -1
- package/src/table-of-contents/deprecated.js +173 -0
- package/src/table-of-contents/index.js +2 -2
- package/src/table-of-contents/index.php +16 -3
- package/src/tabs/index.php +5 -5
- package/src/tabs/view.js +32 -2
- package/src/term-description/index.php +1 -1
- package/src/term-template/edit.js +10 -1
- package/src/utils/test/waveform-player-dependency.js +0 -74
- package/build/block-keyboard-shortcuts/index.cjs +0 -131
- package/build/block-keyboard-shortcuts/index.cjs.map +0 -7
- package/build/table-of-contents/save.cjs +0 -55
- package/build/table-of-contents/save.cjs.map +0 -7
- package/build-module/block-keyboard-shortcuts/index.mjs +0 -113
- package/build-module/block-keyboard-shortcuts/index.mjs.map +0 -7
- package/build-module/table-of-contents/save.mjs +0 -24
- package/build-module/table-of-contents/save.mjs.map +0 -7
- package/src/block-keyboard-shortcuts/index.js +0 -135
- package/src/table-of-contents/save.js +0 -22
|
@@ -8,7 +8,7 @@ Summarize your post with a list of headings. Add HTML anchors to Heading blocks
|
|
|
8
8
|
- **Name:** `core/table-of-contents`
|
|
9
9
|
- **Category:** [design](https://developer.wordpress.org/block-editor/reference-guides/core-blocks/core-blocks-design/)
|
|
10
10
|
- **API Version:** [3](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-api-versions/)
|
|
11
|
-
- **Block Type:** [
|
|
11
|
+
- **Block Type:** [Dynamic](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/) (server-rendered)
|
|
12
12
|
- **Keywords:** `document outline`, `summary`
|
|
13
13
|
|
|
14
14
|
## Attributes
|
|
@@ -17,7 +17,7 @@ _Defined via the [`attributes`](https://developer.wordpress.org/block-editor/ref
|
|
|
17
17
|
|
|
18
18
|
| Attribute | [Type](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#type-validation) | [Default](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#default-value) | Description |
|
|
19
19
|
|-----------|------|---------|-------------|
|
|
20
|
-
| `headings` | `array` | `[]` |
|
|
20
|
+
| `headings` | `array` | `[]` | [Role](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#role): `local` |
|
|
21
21
|
| `onlyIncludeCurrentPage` | `boolean` | `false` | — |
|
|
22
22
|
| `maxLevel` | `number` | — | — |
|
|
23
23
|
| `ordered` | `boolean` | `true` | — |
|
|
@@ -45,12 +45,12 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
45
45
|
|
|
46
46
|
## Block Markup
|
|
47
47
|
|
|
48
|
-
This is a [**
|
|
48
|
+
This is a [**dynamic block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/). It is rendered on the server and does not save HTML in post content.
|
|
49
|
+
|
|
50
|
+
In post content, it is stored as a block comment:
|
|
49
51
|
|
|
50
52
|
```html
|
|
51
|
-
<!-- wp:table-of-contents {"
|
|
52
|
-
<nav class="wp-block-table-of-contents"><ol><li><a class="wp-block-table-of-contents__entry" href="#heading-id-1">Heading text</a><ol><li><a class="wp-block-table-of-contents__entry" href="#heading-id-2">A sub-heading</a></li></ol></li></ol></nav>
|
|
53
|
-
<!-- /wp:table-of-contents -->
|
|
53
|
+
<!-- wp:table-of-contents {"maxLevel":3,"ordered":false} /-->
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
## Source
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { useBlockProps } from '@wordpress/block-editor';
|
|
2
|
+
|
|
3
|
+
const ENTRY_CLASS_NAME = 'wp-block-table-of-contents__entry';
|
|
4
|
+
|
|
5
|
+
const attributes = {
|
|
6
|
+
headings: {
|
|
7
|
+
type: 'array',
|
|
8
|
+
items: {
|
|
9
|
+
type: 'object',
|
|
10
|
+
},
|
|
11
|
+
default: [],
|
|
12
|
+
},
|
|
13
|
+
onlyIncludeCurrentPage: {
|
|
14
|
+
type: 'boolean',
|
|
15
|
+
default: false,
|
|
16
|
+
},
|
|
17
|
+
maxLevel: {
|
|
18
|
+
type: 'number',
|
|
19
|
+
},
|
|
20
|
+
ordered: {
|
|
21
|
+
type: 'boolean',
|
|
22
|
+
default: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const supports = {
|
|
27
|
+
anchor: true,
|
|
28
|
+
ariaLabel: true,
|
|
29
|
+
html: false,
|
|
30
|
+
color: {
|
|
31
|
+
text: true,
|
|
32
|
+
background: true,
|
|
33
|
+
gradients: true,
|
|
34
|
+
link: true,
|
|
35
|
+
},
|
|
36
|
+
spacing: {
|
|
37
|
+
margin: true,
|
|
38
|
+
padding: true,
|
|
39
|
+
},
|
|
40
|
+
typography: {
|
|
41
|
+
fontSize: true,
|
|
42
|
+
lineHeight: true,
|
|
43
|
+
__experimentalFontFamily: true,
|
|
44
|
+
__experimentalFontWeight: true,
|
|
45
|
+
__experimentalFontStyle: true,
|
|
46
|
+
__experimentalTextTransform: true,
|
|
47
|
+
__experimentalTextDecoration: true,
|
|
48
|
+
__experimentalLetterSpacing: true,
|
|
49
|
+
__experimentalDefaultControls: {
|
|
50
|
+
fontSize: true,
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
interactivity: {
|
|
54
|
+
clientNavigation: true,
|
|
55
|
+
},
|
|
56
|
+
__experimentalBorder: {
|
|
57
|
+
radius: true,
|
|
58
|
+
color: true,
|
|
59
|
+
width: true,
|
|
60
|
+
style: true,
|
|
61
|
+
__experimentalDefaultControls: {
|
|
62
|
+
radius: true,
|
|
63
|
+
color: true,
|
|
64
|
+
width: true,
|
|
65
|
+
style: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function linearToNestedHeadingList( headingList ) {
|
|
71
|
+
const nestedHeadingList = [];
|
|
72
|
+
|
|
73
|
+
headingList.forEach( ( heading, key ) => {
|
|
74
|
+
if ( heading.content === '' ) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ( heading.level === headingList[ 0 ].level ) {
|
|
79
|
+
if ( headingList[ key + 1 ]?.level > heading.level ) {
|
|
80
|
+
let endOfSlice = headingList.length;
|
|
81
|
+
for ( let i = key + 1; i < headingList.length; i++ ) {
|
|
82
|
+
if ( headingList[ i ].level === heading.level ) {
|
|
83
|
+
endOfSlice = i;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
nestedHeadingList.push( {
|
|
89
|
+
heading,
|
|
90
|
+
children: linearToNestedHeadingList(
|
|
91
|
+
headingList.slice( key + 1, endOfSlice )
|
|
92
|
+
),
|
|
93
|
+
} );
|
|
94
|
+
} else {
|
|
95
|
+
nestedHeadingList.push( {
|
|
96
|
+
heading,
|
|
97
|
+
children: null,
|
|
98
|
+
} );
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
return nestedHeadingList;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function TableOfContentsList( { nestedHeadingList, ordered = true } ) {
|
|
107
|
+
return (
|
|
108
|
+
<>
|
|
109
|
+
{ nestedHeadingList.map( ( node, index ) => {
|
|
110
|
+
const { content, link } = node.heading;
|
|
111
|
+
|
|
112
|
+
const entry = link ? (
|
|
113
|
+
<a className={ ENTRY_CLASS_NAME } href={ link }>
|
|
114
|
+
{ content }
|
|
115
|
+
</a>
|
|
116
|
+
) : (
|
|
117
|
+
<span className={ ENTRY_CLASS_NAME }>{ content }</span>
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
const NestedListTag = ordered ? 'ol' : 'ul';
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<li key={ index }>
|
|
124
|
+
{ entry }
|
|
125
|
+
{ node.children ? (
|
|
126
|
+
<NestedListTag>
|
|
127
|
+
<TableOfContentsList
|
|
128
|
+
nestedHeadingList={ node.children }
|
|
129
|
+
ordered={ ordered }
|
|
130
|
+
/>
|
|
131
|
+
</NestedListTag>
|
|
132
|
+
) : null }
|
|
133
|
+
</li>
|
|
134
|
+
);
|
|
135
|
+
} ) }
|
|
136
|
+
</>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const hasOwn = ( object, key ) =>
|
|
141
|
+
Object.prototype.hasOwnProperty.call( object, key );
|
|
142
|
+
|
|
143
|
+
const v1 = {
|
|
144
|
+
attributes,
|
|
145
|
+
supports,
|
|
146
|
+
isEligible: ( blockAttributes, innerBlocks, { blockNode } = {} ) => {
|
|
147
|
+
return (
|
|
148
|
+
hasOwn( blockAttributes, 'headings' ) ||
|
|
149
|
+
blockNode?.innerHTML?.includes( 'wp-block-table-of-contents' )
|
|
150
|
+
);
|
|
151
|
+
},
|
|
152
|
+
migrate: ( { headings, ...persistentAttributes } ) => persistentAttributes,
|
|
153
|
+
save( { attributes: { headings = [], ordered = true } } ) {
|
|
154
|
+
if ( headings.length === 0 ) {
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const ListTag = ordered ? 'ol' : 'ul';
|
|
158
|
+
return (
|
|
159
|
+
<nav { ...useBlockProps.save() }>
|
|
160
|
+
<ListTag>
|
|
161
|
+
<TableOfContentsList
|
|
162
|
+
nestedHeadingList={ linearToNestedHeadingList(
|
|
163
|
+
headings
|
|
164
|
+
) }
|
|
165
|
+
ordered={ ordered }
|
|
166
|
+
/>
|
|
167
|
+
</ListTag>
|
|
168
|
+
</nav>
|
|
169
|
+
);
|
|
170
|
+
},
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export default [ v1 ];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { tableOfContents as icon } from '@wordpress/icons';
|
|
3
3
|
import initBlock from '../utils/init-block';
|
|
4
|
+
import deprecated from './deprecated';
|
|
4
5
|
import metadata from './block.json';
|
|
5
6
|
import edit from './edit';
|
|
6
|
-
import save from './save';
|
|
7
7
|
|
|
8
8
|
const { name } = metadata;
|
|
9
9
|
|
|
@@ -11,8 +11,8 @@ export { metadata, name };
|
|
|
11
11
|
|
|
12
12
|
export const settings = {
|
|
13
13
|
icon,
|
|
14
|
+
deprecated,
|
|
14
15
|
edit,
|
|
15
|
-
save,
|
|
16
16
|
example: {
|
|
17
17
|
innerBlocks: [
|
|
18
18
|
{
|
|
@@ -363,14 +363,27 @@ function block_core_table_of_contents_build_list_items( $nested_headings, $list_
|
|
|
363
363
|
/**
|
|
364
364
|
* Renders the table of contents block from current post headings.
|
|
365
365
|
*
|
|
366
|
-
* @param array
|
|
367
|
-
* @param string
|
|
366
|
+
* @param array $attributes Attributes of the block being rendered.
|
|
367
|
+
* @param string $content Content of the block being rendered.
|
|
368
|
+
* @param WP_Block|null $block Block instance.
|
|
368
369
|
*
|
|
369
370
|
* @return string The content of the block being rendered.
|
|
370
371
|
*/
|
|
371
|
-
function block_core_table_of_contents_render( $attributes, $content ) {
|
|
372
|
+
function block_core_table_of_contents_render( $attributes, $content, $block = null ) {
|
|
372
373
|
global $wp_current_filter;
|
|
373
374
|
|
|
375
|
+
// Preserve legacy saved markup for old posts that have not been edited and migrated yet.
|
|
376
|
+
$legacy_content = $content;
|
|
377
|
+
if ( '' === trim( $legacy_content ) && ! empty( $block->parsed_block['innerHTML'] ) ) {
|
|
378
|
+
$legacy_content = $block->parsed_block['innerHTML'];
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// Once a post is edited and saved, the block migrates to dynamic rendering.
|
|
382
|
+
if ( '' !== trim( $legacy_content ) ) {
|
|
383
|
+
return block_core_table_of_contents_add_aria_label( $attributes, $legacy_content );
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// Outside post content rendering, there is no reliable current post to scan.
|
|
374
387
|
if ( ! is_array( $wp_current_filter ) || ! in_array( 'the_content', $wp_current_filter, true ) ) {
|
|
375
388
|
return block_core_table_of_contents_add_aria_label( $attributes, $content );
|
|
376
389
|
}
|
package/src/tabs/index.php
CHANGED
|
@@ -21,7 +21,7 @@ function block_core_tabs_generate_tabs_list( array $innerblocks = array(), strin
|
|
|
21
21
|
// Find tab-panel block
|
|
22
22
|
foreach ( $innerblocks as $inner_block ) {
|
|
23
23
|
if ( 'core/tab-panels' === ( $inner_block['blockName'] ?? '' ) ) {
|
|
24
|
-
$
|
|
24
|
+
$tab_number = 1;
|
|
25
25
|
foreach ( $inner_block['innerBlocks'] ?? array() as $tab_block ) {
|
|
26
26
|
if ( 'core/tab-panel' === ( $tab_block['blockName'] ?? '' ) ) {
|
|
27
27
|
$attrs = $tab_block['attrs'] ?? array();
|
|
@@ -29,11 +29,11 @@ function block_core_tabs_generate_tabs_list( array $innerblocks = array(), strin
|
|
|
29
29
|
$tab_id = ! empty( $attrs['anchor'] )
|
|
30
30
|
? $attrs['anchor']
|
|
31
31
|
: ( ! empty( $tabs_id )
|
|
32
|
-
? $tabs_id . '-tab-' . $
|
|
33
|
-
: 'tab-' . $
|
|
32
|
+
? $tabs_id . '-tab-' . $tab_number
|
|
33
|
+
: 'tab-' . $tab_number );
|
|
34
34
|
|
|
35
35
|
$tabs_list[] = esc_attr( $tab_id );
|
|
36
|
-
++$
|
|
36
|
+
++$tab_number;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
break;
|
|
@@ -59,7 +59,7 @@ function block_core_tabs_provide_context( array $context, array $parsed_block ):
|
|
|
59
59
|
if ( 'core/tabs' === $parsed_block['blockName'] ) {
|
|
60
60
|
// Generate a unique ID for the tabs instance first, so it can be used
|
|
61
61
|
// to derive stable tab IDs.
|
|
62
|
-
$tabs_id = $parsed_block['attrs']['anchor'] ??
|
|
62
|
+
$tabs_id = $parsed_block['attrs']['anchor'] ?? wp_unique_prefixed_id( 'tabs_' );
|
|
63
63
|
$tabs_list = block_core_tabs_generate_tabs_list( $parsed_block['innerBlocks'] ?? array(), $tabs_id );
|
|
64
64
|
$context['core/tabs-list'] = $tabs_list;
|
|
65
65
|
$context['core/tabs-id'] = $tabs_id;
|
package/src/tabs/view.js
CHANGED
|
@@ -47,8 +47,26 @@ const { actions, state } = store(
|
|
|
47
47
|
return activeTabIndex === tabIndex;
|
|
48
48
|
},
|
|
49
49
|
/**
|
|
50
|
-
* The value of the
|
|
51
|
-
*
|
|
50
|
+
* The value of the hidden attribute for tab panels.
|
|
51
|
+
*
|
|
52
|
+
* Inactive panels use the `until-found` state rather than being
|
|
53
|
+
* hidden outright, so their content stays reachable by the
|
|
54
|
+
* browser's find-in-page and by fragment navigation. The browser
|
|
55
|
+
* fires `beforematch` on the panel before revealing it, which is
|
|
56
|
+
* where the matching tab gets activated.
|
|
57
|
+
*
|
|
58
|
+
* @type {string|null}
|
|
59
|
+
*/
|
|
60
|
+
get isHidden() {
|
|
61
|
+
return state.isActiveTab ? null : 'until-found';
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* The value of the tabindex attribute for tab buttons and tab
|
|
65
|
+
* panels. Only the active tab should be in the tab sequence.
|
|
66
|
+
*
|
|
67
|
+
* An inactive panel is hidden with `until-found`, which leaves it
|
|
68
|
+
* in the layout, so it stays focusable unless it is taken out of
|
|
69
|
+
* the tab sequence here.
|
|
52
70
|
*
|
|
53
71
|
* @type {number}
|
|
54
72
|
*/
|
|
@@ -96,6 +114,18 @@ const { actions, state } = store(
|
|
|
96
114
|
actions.setActiveTab( tabIndex );
|
|
97
115
|
}
|
|
98
116
|
} ),
|
|
117
|
+
/**
|
|
118
|
+
* Activates the tab whose panel the browser is about to reveal.
|
|
119
|
+
*
|
|
120
|
+
* Fired on a panel hidden with `until-found` when find-in-page or
|
|
121
|
+
* a fragment navigation matches content inside it.
|
|
122
|
+
*/
|
|
123
|
+
handleBeforeMatch: () => {
|
|
124
|
+
const { tabIndex } = state;
|
|
125
|
+
if ( tabIndex !== null ) {
|
|
126
|
+
actions.setActiveTab( tabIndex );
|
|
127
|
+
}
|
|
128
|
+
},
|
|
99
129
|
/**
|
|
100
130
|
* Moves focus to a specific tab without activating it.
|
|
101
131
|
*
|
|
@@ -23,7 +23,7 @@ function render_block_core_term_description( $attributes, $content, $block ) {
|
|
|
23
23
|
if ( isset( $block->context['termId'] ) && isset( $block->context['taxonomy'] ) ) {
|
|
24
24
|
$term = get_term( $block->context['termId'], $block->context['taxonomy'] );
|
|
25
25
|
if ( $term && ! is_wp_error( $term ) ) {
|
|
26
|
-
$term_description = $term
|
|
26
|
+
$term_description = get_term_field( 'description', $term );
|
|
27
27
|
}
|
|
28
28
|
} elseif ( is_category() || is_tag() || is_tax() ) {
|
|
29
29
|
$term_description = term_description();
|
|
@@ -14,10 +14,19 @@ import {
|
|
|
14
14
|
} from '@wordpress/block-editor';
|
|
15
15
|
import { useEntityRecords } from '@wordpress/core-data';
|
|
16
16
|
|
|
17
|
+
// The Term Template's layout attribute arranges the term items, not the
|
|
18
|
+
// blocks of the template, which always stack vertically inside each term
|
|
19
|
+
// item. Override the inherited layout so inner block UI (movers, inserters,
|
|
20
|
+
// grid controls) doesn't follow the term items' grid.
|
|
21
|
+
const INNER_BLOCKS_LAYOUT = { type: 'default' };
|
|
22
|
+
|
|
17
23
|
function TermTemplateInnerBlocks( { classList } ) {
|
|
18
24
|
const innerBlocksProps = useInnerBlocksProps(
|
|
19
25
|
{ className: clsx( 'wp-block-term', classList ) },
|
|
20
|
-
{
|
|
26
|
+
{
|
|
27
|
+
__unstableDisableLayoutClassNames: true,
|
|
28
|
+
layout: INNER_BLOCKS_LAYOUT,
|
|
29
|
+
}
|
|
21
30
|
);
|
|
22
31
|
return <li { ...innerBlocksProps } />;
|
|
23
32
|
}
|
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import '@testing-library/jest-dom';
|
|
2
2
|
|
|
3
|
-
const DEFAULT_PLAYBACK_RATES = [
|
|
4
|
-
'0.5x',
|
|
5
|
-
'0.75x',
|
|
6
|
-
'1x',
|
|
7
|
-
'1.25x',
|
|
8
|
-
'1.5x',
|
|
9
|
-
'1.75x',
|
|
10
|
-
'2x',
|
|
11
|
-
];
|
|
12
3
|
const FIXTURE_ATTRIBUTE = 'data-player-fixture';
|
|
13
4
|
|
|
14
5
|
function createDeclarativePlayer( attributes = {} ) {
|
|
@@ -33,10 +24,6 @@ function loadWaveformPlayer() {
|
|
|
33
24
|
return WaveformPlayer;
|
|
34
25
|
}
|
|
35
26
|
|
|
36
|
-
function getFragmentedAttributeValue( prefix = '' ) {
|
|
37
|
-
return `${ prefix }" ${ FIXTURE_ATTRIBUTE }="sample`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
27
|
describe( 'Waveform Player dependency', () => {
|
|
41
28
|
let WaveformPlayer;
|
|
42
29
|
let originalReadyState;
|
|
@@ -102,43 +89,6 @@ describe( 'Waveform Player dependency', () => {
|
|
|
102
89
|
).not.toBeNull();
|
|
103
90
|
} );
|
|
104
91
|
|
|
105
|
-
it( 'uses the default alignment when a declarative alignment value is unsupported', () => {
|
|
106
|
-
const element = createDeclarativePlayer( {
|
|
107
|
-
'data-button-align': getFragmentedAttributeValue( 'center' ),
|
|
108
|
-
} );
|
|
109
|
-
|
|
110
|
-
WaveformPlayer = loadWaveformPlayer();
|
|
111
|
-
WaveformPlayer.init();
|
|
112
|
-
|
|
113
|
-
const track = element.querySelector( '.waveform-track' );
|
|
114
|
-
expect( track ).toHaveClass( 'waveform-align-center' );
|
|
115
|
-
expect( track ).not.toHaveAttribute( FIXTURE_ATTRIBUTE );
|
|
116
|
-
} );
|
|
117
|
-
|
|
118
|
-
it( 'uses the default playback rates when a declarative rate list is unsupported', () => {
|
|
119
|
-
const element = createDeclarativePlayer( {
|
|
120
|
-
'data-show-playback-speed': 'true',
|
|
121
|
-
'data-playback-rates': JSON.stringify( [
|
|
122
|
-
1,
|
|
123
|
-
getFragmentedAttributeValue( '1' ),
|
|
124
|
-
1.5,
|
|
125
|
-
] ),
|
|
126
|
-
} );
|
|
127
|
-
|
|
128
|
-
WaveformPlayer = loadWaveformPlayer();
|
|
129
|
-
WaveformPlayer.init();
|
|
130
|
-
|
|
131
|
-
const options = [ ...element.querySelectorAll( '.speed-option' ) ];
|
|
132
|
-
expect( options.map( ( option ) => option.textContent ) ).toEqual(
|
|
133
|
-
DEFAULT_PLAYBACK_RATES
|
|
134
|
-
);
|
|
135
|
-
expect(
|
|
136
|
-
options.some( ( option ) =>
|
|
137
|
-
option.hasAttribute( FIXTURE_ATTRIBUTE )
|
|
138
|
-
)
|
|
139
|
-
).toBe( false );
|
|
140
|
-
} );
|
|
141
|
-
|
|
142
92
|
it( 'supports custom control icons passed to the constructor', () => {
|
|
143
93
|
const element = document.createElement( 'div' );
|
|
144
94
|
const icon = document.createElementNS(
|
|
@@ -158,30 +108,6 @@ describe( 'Waveform Player dependency', () => {
|
|
|
158
108
|
).not.toBeNull();
|
|
159
109
|
} );
|
|
160
110
|
|
|
161
|
-
it( 'skips programmatic players during explicit declarative scans', () => {
|
|
162
|
-
const element = createDeclarativePlayer();
|
|
163
|
-
const icon = document.createElementNS(
|
|
164
|
-
'http://www.w3.org/2000/svg',
|
|
165
|
-
'svg'
|
|
166
|
-
);
|
|
167
|
-
icon.setAttribute( FIXTURE_ATTRIBUTE, 'constructor-scan' );
|
|
168
|
-
|
|
169
|
-
WaveformPlayer = loadWaveformPlayer();
|
|
170
|
-
const player = new WaveformPlayer( element, {
|
|
171
|
-
playIcon: icon.outerHTML,
|
|
172
|
-
} );
|
|
173
|
-
|
|
174
|
-
WaveformPlayer.init();
|
|
175
|
-
|
|
176
|
-
expect( WaveformPlayer.getAllInstances() ).toHaveLength( 1 );
|
|
177
|
-
expect( WaveformPlayer.getInstance( element ) ).toBe( player );
|
|
178
|
-
expect(
|
|
179
|
-
element.querySelector(
|
|
180
|
-
`[${ FIXTURE_ATTRIBUTE }="constructor-scan"]`
|
|
181
|
-
)
|
|
182
|
-
).not.toBeNull();
|
|
183
|
-
} );
|
|
184
|
-
|
|
185
111
|
it( 'initializes declarative players only after an explicit request', () => {
|
|
186
112
|
const element = createDeclarativePlayer();
|
|
187
113
|
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// packages/block-library/src/block-keyboard-shortcuts/index.js
|
|
21
|
-
var block_keyboard_shortcuts_exports = {};
|
|
22
|
-
__export(block_keyboard_shortcuts_exports, {
|
|
23
|
-
default: () => block_keyboard_shortcuts_default
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(block_keyboard_shortcuts_exports);
|
|
26
|
-
var import_element = require("@wordpress/element");
|
|
27
|
-
var import_data = require("@wordpress/data");
|
|
28
|
-
var import_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
|
|
29
|
-
var import_i18n = require("@wordpress/i18n");
|
|
30
|
-
var import_blocks = require("@wordpress/blocks");
|
|
31
|
-
var import_block_editor = require("@wordpress/block-editor");
|
|
32
|
-
function BlockKeyboardShortcuts() {
|
|
33
|
-
const { registerShortcut } = (0, import_data.useDispatch)(import_keyboard_shortcuts.store);
|
|
34
|
-
const { replaceBlocks } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
35
|
-
const { getBlockName, getSelectedBlockClientId, getBlockAttributes } = (0, import_data.useSelect)(import_block_editor.store);
|
|
36
|
-
const handleTransformHeadingAndParagraph = (event, level) => {
|
|
37
|
-
event.preventDefault();
|
|
38
|
-
const currentClientId = getSelectedBlockClientId();
|
|
39
|
-
if (currentClientId === null) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const blockName = getBlockName(currentClientId);
|
|
43
|
-
const isParagraph = blockName === "core/paragraph";
|
|
44
|
-
const isHeading = blockName === "core/heading";
|
|
45
|
-
if (!isParagraph && !isHeading) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const destinationBlockName = level === 0 ? "core/paragraph" : "core/heading";
|
|
49
|
-
const attributes = getBlockAttributes(currentClientId);
|
|
50
|
-
if (isParagraph && level === 0 || isHeading && attributes.level === level) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const newAttributes = {
|
|
54
|
-
content: attributes.content
|
|
55
|
-
};
|
|
56
|
-
const sourceTextAlign = attributes.textAlign || attributes.style?.typography?.textAlign;
|
|
57
|
-
if (destinationBlockName === "core/heading") {
|
|
58
|
-
newAttributes.level = level;
|
|
59
|
-
}
|
|
60
|
-
if (sourceTextAlign) {
|
|
61
|
-
newAttributes.style = {
|
|
62
|
-
typography: {
|
|
63
|
-
textAlign: sourceTextAlign
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
replaceBlocks(
|
|
68
|
-
currentClientId,
|
|
69
|
-
(0, import_blocks.createBlock)(destinationBlockName, newAttributes)
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
(0, import_element.useEffect)(() => {
|
|
73
|
-
registerShortcut({
|
|
74
|
-
name: "core/block-editor/transform-heading-to-paragraph",
|
|
75
|
-
category: "block-library",
|
|
76
|
-
description: (0, import_i18n.__)("Transform heading to paragraph."),
|
|
77
|
-
keyCombination: {
|
|
78
|
-
modifier: "access",
|
|
79
|
-
character: "0"
|
|
80
|
-
},
|
|
81
|
-
aliases: [
|
|
82
|
-
{
|
|
83
|
-
modifier: "access",
|
|
84
|
-
character: "7"
|
|
85
|
-
}
|
|
86
|
-
]
|
|
87
|
-
});
|
|
88
|
-
[1, 2, 3, 4, 5, 6].forEach((level) => {
|
|
89
|
-
registerShortcut({
|
|
90
|
-
name: `core/block-editor/transform-paragraph-to-heading-${level}`,
|
|
91
|
-
category: "block-library",
|
|
92
|
-
description: (0, import_i18n.__)("Transform paragraph to heading."),
|
|
93
|
-
keyCombination: {
|
|
94
|
-
modifier: "access",
|
|
95
|
-
character: `${level}`
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}, [registerShortcut]);
|
|
100
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
101
|
-
"core/block-editor/transform-heading-to-paragraph",
|
|
102
|
-
(event) => handleTransformHeadingAndParagraph(event, 0)
|
|
103
|
-
);
|
|
104
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
105
|
-
"core/block-editor/transform-paragraph-to-heading-1",
|
|
106
|
-
(event) => handleTransformHeadingAndParagraph(event, 1)
|
|
107
|
-
);
|
|
108
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
109
|
-
"core/block-editor/transform-paragraph-to-heading-2",
|
|
110
|
-
(event) => handleTransformHeadingAndParagraph(event, 2)
|
|
111
|
-
);
|
|
112
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
113
|
-
"core/block-editor/transform-paragraph-to-heading-3",
|
|
114
|
-
(event) => handleTransformHeadingAndParagraph(event, 3)
|
|
115
|
-
);
|
|
116
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
117
|
-
"core/block-editor/transform-paragraph-to-heading-4",
|
|
118
|
-
(event) => handleTransformHeadingAndParagraph(event, 4)
|
|
119
|
-
);
|
|
120
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
121
|
-
"core/block-editor/transform-paragraph-to-heading-5",
|
|
122
|
-
(event) => handleTransformHeadingAndParagraph(event, 5)
|
|
123
|
-
);
|
|
124
|
-
(0, import_keyboard_shortcuts.useShortcut)(
|
|
125
|
-
"core/block-editor/transform-paragraph-to-heading-6",
|
|
126
|
-
(event) => handleTransformHeadingAndParagraph(event, 6)
|
|
127
|
-
);
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
var block_keyboard_shortcuts_default = BlockKeyboardShortcuts;
|
|
131
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/block-keyboard-shortcuts/index.js"],
|
|
4
|
-
"sourcesContent": ["import { useEffect } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseShortcut,\n\tstore as keyboardShortcutsStore,\n} from '@wordpress/keyboard-shortcuts';\nimport { __ } from '@wordpress/i18n';\nimport { createBlock } from '@wordpress/blocks';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nfunction BlockKeyboardShortcuts() {\n\tconst { registerShortcut } = useDispatch( keyboardShortcutsStore );\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlockName, getSelectedBlockClientId, getBlockAttributes } =\n\t\tuseSelect( blockEditorStore );\n\n\tconst handleTransformHeadingAndParagraph = ( event, level ) => {\n\t\tevent.preventDefault();\n\n\t\tconst currentClientId = getSelectedBlockClientId();\n\t\tif ( currentClientId === null ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst blockName = getBlockName( currentClientId );\n\t\tconst isParagraph = blockName === 'core/paragraph';\n\t\tconst isHeading = blockName === 'core/heading';\n\n\t\tif ( ! isParagraph && ! isHeading ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst destinationBlockName =\n\t\t\tlevel === 0 ? 'core/paragraph' : 'core/heading';\n\n\t\tconst attributes = getBlockAttributes( currentClientId );\n\n\t\t// Avoid unnecessary block transform when attempting to transform to\n\t\t// the same block type and/or same level.\n\t\tif (\n\t\t\t( isParagraph && level === 0 ) ||\n\t\t\t( isHeading && attributes.level === level )\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst newAttributes = {\n\t\t\tcontent: attributes.content,\n\t\t};\n\n\t\t// Read textAlign from source block (could be in old or new format)\n\t\tconst sourceTextAlign =\n\t\t\tattributes.textAlign || attributes.style?.typography?.textAlign;\n\n\t\t// When destination is heading, set the level\n\t\tif ( destinationBlockName === 'core/heading' ) {\n\t\t\tnewAttributes.level = level;\n\t\t}\n\n\t\tif ( sourceTextAlign ) {\n\t\t\tnewAttributes.style = {\n\t\t\t\ttypography: {\n\t\t\t\t\ttextAlign: sourceTextAlign,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\n\t\treplaceBlocks(\n\t\t\tcurrentClientId,\n\t\t\tcreateBlock( destinationBlockName, newAttributes )\n\t\t);\n\t};\n\n\tuseEffect( () => {\n\t\tregisterShortcut( {\n\t\t\tname: 'core/block-editor/transform-heading-to-paragraph',\n\t\t\tcategory: 'block-library',\n\t\t\tdescription: __( 'Transform heading to paragraph.' ),\n\t\t\tkeyCombination: {\n\t\t\t\tmodifier: 'access',\n\t\t\t\tcharacter: '0',\n\t\t\t},\n\t\t\taliases: [\n\t\t\t\t{\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: '7',\n\t\t\t\t},\n\t\t\t],\n\t\t} );\n\n\t\t[ 1, 2, 3, 4, 5, 6 ].forEach( ( level ) => {\n\t\t\tregisterShortcut( {\n\t\t\t\tname: `core/block-editor/transform-paragraph-to-heading-${ level }`,\n\t\t\t\tcategory: 'block-library',\n\t\t\t\tdescription: __( 'Transform paragraph to heading.' ),\n\t\t\t\tkeyCombination: {\n\t\t\t\t\tmodifier: 'access',\n\t\t\t\t\tcharacter: `${ level }`,\n\t\t\t\t},\n\t\t\t} );\n\t\t} );\n\t}, [ registerShortcut ] );\n\n\tuseShortcut(\n\t\t'core/block-editor/transform-heading-to-paragraph',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 0 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-1',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 1 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-2',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 2 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-3',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 3 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-4',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 4 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-5',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 5 )\n\t);\n\tuseShortcut(\n\t\t'core/block-editor/transform-paragraph-to-heading-6',\n\t\t( event ) => handleTransformHeadingAndParagraph( event, 6 )\n\t);\n\n\treturn null;\n}\n\nexport default BlockKeyboardShortcuts;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAA0B;AAC1B,kBAAuC;AACvC,gCAGO;AACP,kBAAmB;AACnB,oBAA4B;AAC5B,0BAA0C;AAE1C,SAAS,yBAAyB;AACjC,QAAM,EAAE,iBAAiB,QAAI,yBAAa,0BAAAA,KAAuB;AACjE,QAAM,EAAE,cAAc,QAAI,yBAAa,oBAAAC,KAAiB;AACxD,QAAM,EAAE,cAAc,0BAA0B,mBAAmB,QAClE,uBAAW,oBAAAA,KAAiB;AAE7B,QAAM,qCAAqC,CAAE,OAAO,UAAW;AAC9D,UAAM,eAAe;AAErB,UAAM,kBAAkB,yBAAyB;AACjD,QAAK,oBAAoB,MAAO;AAC/B;AAAA,IACD;AAEA,UAAM,YAAY,aAAc,eAAgB;AAChD,UAAM,cAAc,cAAc;AAClC,UAAM,YAAY,cAAc;AAEhC,QAAK,CAAE,eAAe,CAAE,WAAY;AACnC;AAAA,IACD;AAEA,UAAM,uBACL,UAAU,IAAI,mBAAmB;AAElC,UAAM,aAAa,mBAAoB,eAAgB;AAIvD,QACG,eAAe,UAAU,KACzB,aAAa,WAAW,UAAU,OACnC;AACD;AAAA,IACD;AACA,UAAM,gBAAgB;AAAA,MACrB,SAAS,WAAW;AAAA,IACrB;AAGA,UAAM,kBACL,WAAW,aAAa,WAAW,OAAO,YAAY;AAGvD,QAAK,yBAAyB,gBAAiB;AAC9C,oBAAc,QAAQ;AAAA,IACvB;AAEA,QAAK,iBAAkB;AACtB,oBAAc,QAAQ;AAAA,QACrB,YAAY;AAAA,UACX,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD;AAEA;AAAA,MACC;AAAA,UACA,2BAAa,sBAAsB,aAAc;AAAA,IAClD;AAAA,EACD;AAEA,gCAAW,MAAM;AAChB,qBAAkB;AAAA,MACjB,MAAM;AAAA,MACN,UAAU;AAAA,MACV,iBAAa,gBAAI,iCAAkC;AAAA,MACnD,gBAAgB;AAAA,QACf,UAAU;AAAA,QACV,WAAW;AAAA,MACZ;AAAA,MACA,SAAS;AAAA,QACR;AAAA,UACC,UAAU;AAAA,UACV,WAAW;AAAA,QACZ;AAAA,MACD;AAAA,IACD,CAAE;AAEF,KAAE,GAAG,GAAG,GAAG,GAAG,GAAG,CAAE,EAAE,QAAS,CAAE,UAAW;AAC1C,uBAAkB;AAAA,QACjB,MAAM,oDAAqD,KAAM;AAAA,QACjE,UAAU;AAAA,QACV,iBAAa,gBAAI,iCAAkC;AAAA,QACnD,gBAAgB;AAAA,UACf,UAAU;AAAA,UACV,WAAW,GAAI,KAAM;AAAA,QACtB;AAAA,MACD,CAAE;AAAA,IACH,CAAE;AAAA,EACH,GAAG,CAAE,gBAAiB,CAAE;AAExB;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AACA;AAAA,IACC;AAAA,IACA,CAAE,UAAW,mCAAoC,OAAO,CAAE;AAAA,EAC3D;AAEA,SAAO;AACR;AAEA,IAAO,mCAAQ;",
|
|
6
|
-
"names": ["keyboardShortcutsStore", "blockEditorStore"]
|
|
7
|
-
}
|