@wordpress/block-library 8.24.0 → 8.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/audio/edit.js +7 -52
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +1 -1
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/index.js +2 -2
- package/build/block/edit.js +102 -11
- package/build/block/edit.js.map +1 -1
- package/build/block/index.js +3 -2
- package/build/block/index.js.map +1 -1
- package/build/block/v1/edit.js +116 -0
- package/build/block/v1/edit.js.map +1 -0
- package/build/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/build/block/v1/edit.native.js.map +1 -0
- package/build/button/index.js +2 -2
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/code/edit.native.js +13 -14
- package/build/code/edit.native.js.map +1 -1
- package/build/code/index.js +2 -2
- package/build/code/save.js +6 -2
- package/build/code/save.js.map +1 -1
- package/build/details/index.js +2 -2
- package/build/embed/deprecated.js +2 -2
- package/build/embed/embed-preview.native.js +1 -1
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/embed/icons.js +1 -1
- package/build/embed/icons.js.map +1 -1
- package/build/embed/index.js +2 -2
- package/build/embed/transforms.js +2 -2
- package/build/embed/util.js +2 -2
- package/build/file/edit.js +1 -1
- package/build/file/edit.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 +4 -4
- package/build/file/save.js +4 -1
- package/build/file/save.js.map +1 -1
- package/build/form-input/deprecated.js +147 -0
- package/build/form-input/deprecated.js.map +1 -0
- package/build/form-input/edit.js +1 -1
- package/build/form-input/edit.js.map +1 -1
- package/build/form-input/index.js +4 -2
- package/build/form-input/index.js.map +1 -1
- package/build/form-input/save.js +7 -9
- package/build/form-input/save.js.map +1 -1
- package/build/gallery/edit.js +2 -41
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +18 -24
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -1
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/index.js +4 -4
- package/build/gallery/v1/gallery.native.js +1 -1
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/group/edit.js +6 -1
- package/build/group/edit.js.map +1 -1
- package/build/heading/index.js +3 -6
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +14 -51
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -2
- package/build/image/save.js +3 -1
- package/build/image/save.js.map +1 -1
- package/build/list-item/index.js +10 -3
- package/build/list-item/index.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +2 -2
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/paragraph/edit.js +54 -32
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +2 -3
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +2 -3
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-title/index.js +1 -3
- package/build/post-title/index.js.map +1 -1
- package/build/preformatted/index.js +2 -3
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/index.js +5 -7
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query-title/index.js +1 -3
- package/build/query-title/index.js.map +1 -1
- package/build/quote/index.js +3 -5
- package/build/quote/index.js.map +1 -1
- package/build/quote/transforms.js +7 -6
- package/build/quote/transforms.js.map +1 -1
- package/build/site-title/index.js +1 -5
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/icons/gravatar.js +22 -0
- package/build/social-link/icons/gravatar.js.map +1 -0
- package/build/social-link/icons/index.js +11 -0
- package/build/social-link/icons/index.js.map +1 -1
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/table/edit.js +3 -1
- package/build/table/edit.js.map +1 -1
- package/build/table/index.js +9 -10
- package/build/table/index.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -2
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +5 -2
- package/build/table-of-contents/index.js.map +1 -1
- package/build/utils/caption.js +90 -0
- package/build/utils/caption.js.map +1 -0
- package/build/utils/remove-anchor-tag.js +2 -1
- package/build/utils/remove-anchor-tag.js.map +1 -1
- package/build/verse/index.js +3 -5
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +2 -2
- package/build/video/edit.js +8 -52
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build/video/index.js +2 -2
- package/build-module/audio/edit.js +11 -56
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +2 -2
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/index.js +2 -2
- package/build-module/block/edit.js +104 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/index.js +3 -2
- package/build-module/block/index.js.map +1 -1
- package/build-module/block/v1/edit.js +108 -0
- package/build-module/block/v1/edit.js.map +1 -0
- package/build-module/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/build-module/block/v1/edit.native.js.map +1 -0
- package/build-module/button/index.js +2 -2
- package/build-module/button/save.js +1 -1
- package/build-module/button/save.js.map +1 -1
- package/build-module/code/edit.native.js +14 -16
- package/build-module/code/edit.native.js.map +1 -1
- package/build-module/code/index.js +2 -2
- package/build-module/code/save.js +6 -2
- package/build-module/code/save.js.map +1 -1
- package/build-module/details/index.js +2 -2
- package/build-module/embed/deprecated.js +2 -2
- package/build-module/embed/embed-preview.native.js +2 -2
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/embed/icons.js +1 -1
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/embed/index.js +2 -2
- package/build-module/embed/transforms.js +2 -2
- package/build-module/embed/util.js +2 -2
- package/build-module/file/edit.js +1 -1
- package/build-module/file/edit.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 +4 -4
- package/build-module/file/save.js +4 -1
- package/build-module/file/save.js.map +1 -1
- package/build-module/form-input/deprecated.js +138 -0
- package/build-module/form-input/deprecated.js.map +1 -0
- package/build-module/form-input/edit.js +1 -1
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/form-input/index.js +4 -2
- package/build-module/form-input/index.js.map +1 -1
- package/build-module/form-input/save.js +8 -10
- package/build-module/form-input/save.js.map +1 -1
- package/build-module/gallery/edit.js +5 -44
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +17 -21
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gallery.native.js +2 -2
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/index.js +4 -4
- package/build-module/gallery/v1/gallery.native.js +2 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/group/edit.js +6 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/heading/index.js +3 -6
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.native.js +2 -2
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +19 -56
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -2
- package/build-module/image/save.js +3 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/list-item/index.js +10 -3
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +2 -2
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/paragraph/edit.js +54 -32
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +2 -3
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +2 -3
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-title/index.js +1 -3
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/preformatted/index.js +2 -3
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/index.js +5 -7
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query-title/index.js +1 -3
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/quote/index.js +3 -5
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/transforms.js +7 -6
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/site-title/index.js +1 -5
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/icons/gravatar.js +14 -0
- package/build-module/social-link/icons/gravatar.js.map +1 -0
- package/build-module/social-link/icons/index.js +1 -0
- package/build-module/social-link/icons/index.js.map +1 -1
- package/build-module/social-link/variations.js +8 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/table/edit.js +3 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/index.js +9 -10
- package/build-module/table/index.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +5 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/utils/caption.js +82 -0
- package/build-module/utils/caption.js.map +1 -0
- package/build-module/utils/remove-anchor-tag.js +2 -1
- package/build-module/utils/remove-anchor-tag.js.map +1 -1
- package/build-module/verse/index.js +3 -5
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +2 -2
- package/build-module/video/edit.js +13 -57
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +2 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/index.js +2 -2
- package/build-style/editor-rtl.css +1 -11
- package/build-style/editor.css +1 -11
- package/build-style/social-links/style-rtl.css +14 -2
- package/build-style/social-links/style.css +14 -2
- package/build-style/style-rtl.css +14 -2
- package/build-style/style.css +14 -2
- package/build-style/table/editor-rtl.css +1 -11
- package/build-style/table/editor.css +1 -11
- package/package.json +32 -32
- package/src/audio/block.json +2 -2
- package/src/audio/edit.js +11 -74
- package/src/audio/edit.native.js +2 -1
- package/src/block/edit.js +143 -16
- package/src/block/index.js +3 -2
- package/src/block/index.php +48 -0
- package/src/block/v1/edit.js +163 -0
- package/src/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/src/button/block.json +2 -2
- package/src/button/save.js +1 -1
- package/src/code/block.json +2 -2
- package/src/code/edit.native.js +11 -13
- package/src/code/save.js +4 -1
- package/src/code/test/edit.native.js +2 -2
- package/src/cover/test/edit.native.js +7 -1
- package/src/details/block.json +2 -2
- package/src/embed/block.json +2 -2
- package/src/embed/embed-preview.native.js +2 -1
- package/src/embed/icons.js +1 -1
- package/src/file/block.json +4 -4
- package/src/file/edit.js +1 -1
- package/src/file/edit.native.js +1 -1
- package/src/file/save.js +5 -1
- package/src/form-input/block.json +2 -2
- package/src/form-input/deprecated.js +142 -0
- package/src/form-input/edit.js +1 -1
- package/src/form-input/index.js +2 -0
- package/src/form-input/save.js +27 -24
- package/src/gallery/block.json +4 -4
- package/src/gallery/edit.js +4 -59
- package/src/gallery/gallery.js +19 -36
- package/src/gallery/gallery.native.js +6 -2
- package/src/gallery/v1/gallery.native.js +2 -1
- package/src/group/edit.js +4 -1
- package/src/heading/block.json +3 -6
- package/src/image/block.json +2 -2
- package/src/image/edit.native.js +2 -3
- package/src/image/image.js +24 -93
- package/src/image/save.js +3 -1
- package/src/list-item/block.json +10 -3
- package/src/navigation/edit/index.js +7 -2
- package/src/navigation/index.php +1 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +6 -3
- package/src/page-list/convert-to-links-modal.js +2 -2
- package/src/paragraph/block.json +2 -3
- package/src/paragraph/edit.js +53 -40
- package/src/post-title/block.json +1 -3
- package/src/preformatted/block.json +2 -3
- package/src/pullquote/block.json +5 -7
- package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/src/query-title/block.json +1 -3
- package/src/quote/block.json +3 -5
- package/src/quote/transforms.js +12 -11
- package/src/site-title/block.json +1 -5
- package/src/social-link/icons/gravatar.js +10 -0
- package/src/social-link/icons/index.js +1 -0
- package/src/social-link/index.php +4 -0
- package/src/social-link/socials-with-bg.scss +5 -0
- package/src/social-link/socials-without-bg.scss +4 -0
- package/src/social-link/variations.js +7 -0
- package/src/social-links/style.scss +14 -8
- package/src/table/block.json +9 -10
- package/src/table/edit.js +3 -1
- package/src/table/editor.scss +1 -14
- package/src/table-of-contents/edit.js +1 -1
- package/src/table-of-contents/index.js +5 -1
- package/src/utils/caption.js +108 -0
- package/src/utils/remove-anchor-tag.js +2 -1
- package/src/verse/block.json +3 -5
- package/src/video/block.json +2 -2
- package/src/video/edit.js +12 -74
- package/src/video/edit.native.js +2 -1
- package/build/block/edit.native.js.map +0 -1
- package/build/table-of-contents/icon.js +0 -22
- package/build/table-of-contents/icon.js.map +0 -1
- package/build-module/block/edit.native.js.map +0 -1
- package/build-module/table-of-contents/icon.js +0 -15
- package/build-module/table-of-contents/icon.js.map +0 -1
- package/src/table-of-contents/icon.js +0 -18
package/src/code/edit.native.js
CHANGED
|
@@ -6,7 +6,7 @@ import { View } from 'react-native';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
9
|
+
import { RichText } from '@wordpress/block-editor';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
11
|
import { usePreferredColorSchemeStyle } from '@wordpress/compose';
|
|
12
12
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
@@ -20,14 +20,11 @@ import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
|
20
20
|
*/
|
|
21
21
|
import styles from './theme.scss';
|
|
22
22
|
|
|
23
|
-
// Note: styling is applied directly to the (nested) PlainText component. Web-side components
|
|
24
|
-
// apply it to the container 'div' but we don't have a proper proposal for cascading styling yet.
|
|
25
23
|
export function CodeEdit( props ) {
|
|
26
24
|
const {
|
|
27
25
|
attributes,
|
|
28
26
|
setAttributes,
|
|
29
|
-
|
|
30
|
-
onBlur,
|
|
27
|
+
onRemove,
|
|
31
28
|
style,
|
|
32
29
|
insertBlocksAfter,
|
|
33
30
|
mergeBlocks,
|
|
@@ -37,30 +34,31 @@ export function CodeEdit( props ) {
|
|
|
37
34
|
styles.blockCode,
|
|
38
35
|
styles.blockCodeDark
|
|
39
36
|
),
|
|
40
|
-
...( style?.fontSize && { fontSize: style.fontSize } ),
|
|
41
37
|
};
|
|
42
38
|
|
|
39
|
+
const textStyle = style?.fontSize ? { fontSize: style.fontSize } : {};
|
|
40
|
+
|
|
43
41
|
const placeholderStyle = usePreferredColorSchemeStyle(
|
|
44
42
|
styles.placeholder,
|
|
45
43
|
styles.placeholderDark
|
|
46
44
|
);
|
|
47
45
|
|
|
48
46
|
return (
|
|
49
|
-
<View>
|
|
50
|
-
<
|
|
47
|
+
<View style={ codeStyle }>
|
|
48
|
+
<RichText
|
|
49
|
+
tagName="pre"
|
|
51
50
|
value={ attributes.content }
|
|
52
51
|
identifier="content"
|
|
53
|
-
style={
|
|
54
|
-
multiline={ true }
|
|
52
|
+
style={ textStyle }
|
|
55
53
|
underlineColorAndroid="transparent"
|
|
56
54
|
onChange={ ( content ) => setAttributes( { content } ) }
|
|
57
55
|
onMerge={ mergeBlocks }
|
|
56
|
+
onRemove={ onRemove }
|
|
58
57
|
placeholder={ __( 'Write code…' ) }
|
|
59
58
|
aria-label={ __( 'Code' ) }
|
|
60
|
-
isSelected={ props.isSelected }
|
|
61
|
-
onFocus={ onFocus }
|
|
62
|
-
onBlur={ onBlur }
|
|
63
59
|
placeholderTextColor={ placeholderStyle.color }
|
|
60
|
+
preserveWhiteSpace
|
|
61
|
+
__unstablePastePlainText
|
|
64
62
|
__unstableOnSplitAtDoubleLineEnd={ () =>
|
|
65
63
|
insertBlocksAfter( createBlock( getDefaultBlockName() ) )
|
|
66
64
|
}
|
package/src/code/save.js
CHANGED
|
@@ -13,7 +13,10 @@ export default function save( { attributes } ) {
|
|
|
13
13
|
<pre { ...useBlockProps.save() }>
|
|
14
14
|
<RichText.Content
|
|
15
15
|
tagName="code"
|
|
16
|
-
|
|
16
|
+
// To do: `escape` encodes characters in shortcodes and URLs to
|
|
17
|
+
// prevent embedding in PHP. Ideally checks for the code block,
|
|
18
|
+
// or pre/code tags, should be made on the PHP side?
|
|
19
|
+
value={ escape( attributes.content.toString() ) }
|
|
17
20
|
/>
|
|
18
21
|
</pre>
|
|
19
22
|
);
|
|
@@ -49,7 +49,7 @@ describe( 'Code', () => {
|
|
|
49
49
|
const screen = await initializeEditor( {
|
|
50
50
|
initialHtml,
|
|
51
51
|
} );
|
|
52
|
-
const {
|
|
52
|
+
const { findByPlaceholderText } = screen;
|
|
53
53
|
|
|
54
54
|
// Get block
|
|
55
55
|
const codeBlock = await getBlock( screen, 'Code' );
|
|
@@ -57,7 +57,7 @@ describe( 'Code', () => {
|
|
|
57
57
|
fireEvent.press( codeBlock );
|
|
58
58
|
|
|
59
59
|
// Get initial text
|
|
60
|
-
const codeBlockText =
|
|
60
|
+
const codeBlockText = await findByPlaceholderText( 'Write code…' );
|
|
61
61
|
expect( codeBlockText ).toBeVisible();
|
|
62
62
|
|
|
63
63
|
expect( getEditorHtml() ).toMatchSnapshot();
|
|
@@ -80,7 +80,13 @@ const MEDIA_OPTIONS = [
|
|
|
80
80
|
// Simplified tree to render Cover edit within slot.
|
|
81
81
|
const CoverEdit = ( props ) => (
|
|
82
82
|
<SlotFillProvider>
|
|
83
|
-
<BlockEdit
|
|
83
|
+
<BlockEdit
|
|
84
|
+
isSelected
|
|
85
|
+
mayDisplayControls
|
|
86
|
+
name={ cover.name }
|
|
87
|
+
clientId={ 0 }
|
|
88
|
+
{ ...props }
|
|
89
|
+
/>
|
|
84
90
|
<BottomSheetSettings isVisible />
|
|
85
91
|
</SlotFillProvider>
|
|
86
92
|
);
|
package/src/details/block.json
CHANGED
package/src/embed/block.json
CHANGED
|
@@ -10,6 +10,7 @@ import classnames from 'classnames/dedupe';
|
|
|
10
10
|
import { View } from '@wordpress/primitives';
|
|
11
11
|
import {
|
|
12
12
|
BlockCaption,
|
|
13
|
+
RichText,
|
|
13
14
|
store as blockEditorStore,
|
|
14
15
|
} from '@wordpress/block-editor';
|
|
15
16
|
import { __, sprintf } from '@wordpress/i18n';
|
|
@@ -51,7 +52,7 @@ const EmbedPreview = ( {
|
|
|
51
52
|
styles[ `embed-preview__sandbox--align-${ align }` ];
|
|
52
53
|
|
|
53
54
|
function accessibilityLabelCreator( caption ) {
|
|
54
|
-
return
|
|
55
|
+
return RichText.isEmpty( caption )
|
|
55
56
|
? /* translators: accessibility text. Empty Embed caption. */
|
|
56
57
|
__( 'Embed caption. Empty' )
|
|
57
58
|
: sprintf(
|
package/src/embed/icons.js
CHANGED
|
@@ -137,7 +137,7 @@ export const embedAnimotoIcon = (
|
|
|
137
137
|
export const embedDailymotionIcon = (
|
|
138
138
|
<SVG viewBox="0 0 24 24">
|
|
139
139
|
<Path
|
|
140
|
-
d="
|
|
140
|
+
d="M11.903 16.568c-1.82 0-3.124-1.281-3.124-2.967a2.987 2.987 0 0 1 2.989-2.989c1.663 0 2.944 1.304 2.944 3.034 0 1.663-1.281 2.922-2.81 2.922ZM17.997 3l-3.308.73v5.107c-.809-1.034-2.045-1.37-3.505-1.37-1.529 0-2.9.561-4.023 1.662-1.259 1.214-1.933 2.764-1.933 4.495 0 1.888.72 3.506 2.113 4.742 1.056.944 2.314 1.415 3.775 1.415 1.438 0 2.517-.382 3.573-1.415v1.415h3.308V3Z"
|
|
141
141
|
fill="#333436"
|
|
142
142
|
/>
|
|
143
143
|
</SVG>
|
package/src/file/block.json
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"attribute": "id"
|
|
22
22
|
},
|
|
23
23
|
"fileName": {
|
|
24
|
-
"type": "
|
|
25
|
-
"source": "
|
|
24
|
+
"type": "rich-text",
|
|
25
|
+
"source": "rich-text",
|
|
26
26
|
"selector": "a:not([download])"
|
|
27
27
|
},
|
|
28
28
|
"textLinkHref": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"default": true
|
|
43
43
|
},
|
|
44
44
|
"downloadButtonText": {
|
|
45
|
-
"type": "
|
|
46
|
-
"source": "
|
|
45
|
+
"type": "rich-text",
|
|
46
|
+
"source": "rich-text",
|
|
47
47
|
"selector": "a[download]"
|
|
48
48
|
},
|
|
49
49
|
"displayPreview": {
|
package/src/file/edit.js
CHANGED
|
@@ -102,7 +102,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
102
102
|
revokeBlobURL( href );
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
if ( downloadButtonText
|
|
105
|
+
if ( RichText.isEmpty( downloadButtonText ) ) {
|
|
106
106
|
setAttributes( {
|
|
107
107
|
downloadButtonText: _x( 'Download', 'button label' ),
|
|
108
108
|
} );
|
package/src/file/edit.native.js
CHANGED
|
@@ -97,7 +97,7 @@ export class FileEdit extends Component {
|
|
|
97
97
|
const { attributes, setAttributes } = this.props;
|
|
98
98
|
const { downloadButtonText } = attributes;
|
|
99
99
|
|
|
100
|
-
if (
|
|
100
|
+
if ( RichText.isEmpty( downloadButtonText ) ) {
|
|
101
101
|
setAttributes( {
|
|
102
102
|
downloadButtonText: _x( 'Download', 'button label' ),
|
|
103
103
|
} );
|
package/src/file/save.js
CHANGED
|
@@ -25,7 +25,11 @@ export default function save( { attributes } ) {
|
|
|
25
25
|
previewHeight,
|
|
26
26
|
} = attributes;
|
|
27
27
|
|
|
28
|
-
const pdfEmbedLabel = RichText.isEmpty( fileName )
|
|
28
|
+
const pdfEmbedLabel = RichText.isEmpty( fileName )
|
|
29
|
+
? 'PDF embed'
|
|
30
|
+
: // To do: use toPlainText, but we need ensure it's RichTextData. See
|
|
31
|
+
// https://github.com/WordPress/gutenberg/pull/56710.
|
|
32
|
+
fileName.toString();
|
|
29
33
|
|
|
30
34
|
const hasFilename = ! RichText.isEmpty( fileName );
|
|
31
35
|
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
"type": "string"
|
|
20
20
|
},
|
|
21
21
|
"label": {
|
|
22
|
-
"type": "
|
|
22
|
+
"type": "rich-text",
|
|
23
23
|
"default": "Label",
|
|
24
24
|
"selector": ".wp-block-form-input__label-content",
|
|
25
|
-
"source": "
|
|
25
|
+
"source": "rich-text",
|
|
26
26
|
"__experimentalRole": "content"
|
|
27
27
|
},
|
|
28
28
|
"inlineLabel": {
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import removeAccents from 'remove-accents';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
RichText,
|
|
12
|
+
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
13
|
+
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
14
|
+
} from '@wordpress/block-editor';
|
|
15
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
16
|
+
|
|
17
|
+
const getNameFromLabelV1 = ( content ) => {
|
|
18
|
+
return (
|
|
19
|
+
removeAccents( stripHTML( content ) )
|
|
20
|
+
// Convert anything that's not a letter or number to a hyphen.
|
|
21
|
+
.replace( /[^\p{L}\p{N}]+/gu, '-' )
|
|
22
|
+
// Convert to lowercase
|
|
23
|
+
.toLowerCase()
|
|
24
|
+
// Remove any remaining leading or trailing hyphens.
|
|
25
|
+
.replace( /(^-+)|(-+$)/g, '' )
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// Version without wrapper div in saved markup
|
|
30
|
+
// See: https://github.com/WordPress/gutenberg/pull/56507
|
|
31
|
+
const v1 = {
|
|
32
|
+
attributes: {
|
|
33
|
+
type: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
default: 'text',
|
|
36
|
+
},
|
|
37
|
+
name: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
label: {
|
|
41
|
+
type: 'string',
|
|
42
|
+
default: 'Label',
|
|
43
|
+
selector: '.wp-block-form-input__label-content',
|
|
44
|
+
source: 'html',
|
|
45
|
+
__experimentalRole: 'content',
|
|
46
|
+
},
|
|
47
|
+
inlineLabel: {
|
|
48
|
+
type: 'boolean',
|
|
49
|
+
default: false,
|
|
50
|
+
},
|
|
51
|
+
required: {
|
|
52
|
+
type: 'boolean',
|
|
53
|
+
default: false,
|
|
54
|
+
selector: '.wp-block-form-input__input',
|
|
55
|
+
source: 'attribute',
|
|
56
|
+
attribute: 'required',
|
|
57
|
+
},
|
|
58
|
+
placeholder: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
selector: '.wp-block-form-input__input',
|
|
61
|
+
source: 'attribute',
|
|
62
|
+
attribute: 'placeholder',
|
|
63
|
+
__experimentalRole: 'content',
|
|
64
|
+
},
|
|
65
|
+
value: {
|
|
66
|
+
type: 'string',
|
|
67
|
+
default: '',
|
|
68
|
+
selector: 'input',
|
|
69
|
+
source: 'attribute',
|
|
70
|
+
attribute: 'value',
|
|
71
|
+
},
|
|
72
|
+
visibilityPermissions: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
default: 'all',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
supports: {
|
|
78
|
+
className: false,
|
|
79
|
+
anchor: true,
|
|
80
|
+
reusable: false,
|
|
81
|
+
spacing: {
|
|
82
|
+
margin: [ 'top', 'bottom' ],
|
|
83
|
+
},
|
|
84
|
+
__experimentalBorder: {
|
|
85
|
+
radius: true,
|
|
86
|
+
__experimentalSkipSerialization: true,
|
|
87
|
+
__experimentalDefaultControls: {
|
|
88
|
+
radius: true,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
save( { attributes } ) {
|
|
93
|
+
const { type, name, label, inlineLabel, required, placeholder, value } =
|
|
94
|
+
attributes;
|
|
95
|
+
|
|
96
|
+
const borderProps = getBorderClassesAndStyles( attributes );
|
|
97
|
+
const colorProps = getColorClassesAndStyles( attributes );
|
|
98
|
+
|
|
99
|
+
const inputStyle = {
|
|
100
|
+
...borderProps.style,
|
|
101
|
+
...colorProps.style,
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const inputClasses = classNames(
|
|
105
|
+
'wp-block-form-input__input',
|
|
106
|
+
colorProps.className,
|
|
107
|
+
borderProps.className
|
|
108
|
+
);
|
|
109
|
+
const TagName = type === 'textarea' ? 'textarea' : 'input';
|
|
110
|
+
|
|
111
|
+
if ( 'hidden' === type ) {
|
|
112
|
+
return <input type={ type } name={ name } value={ value } />;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
116
|
+
return (
|
|
117
|
+
<label
|
|
118
|
+
className={ classNames( 'wp-block-form-input__label', {
|
|
119
|
+
'is-label-inline': inlineLabel,
|
|
120
|
+
} ) }
|
|
121
|
+
>
|
|
122
|
+
<span className="wp-block-form-input__label-content">
|
|
123
|
+
<RichText.Content value={ label } />
|
|
124
|
+
</span>
|
|
125
|
+
<TagName
|
|
126
|
+
className={ inputClasses }
|
|
127
|
+
type={ 'textarea' === type ? undefined : type }
|
|
128
|
+
name={ name || getNameFromLabelV1( label ) }
|
|
129
|
+
required={ required }
|
|
130
|
+
aria-required={ required }
|
|
131
|
+
placeholder={ placeholder || undefined }
|
|
132
|
+
style={ inputStyle }
|
|
133
|
+
/>
|
|
134
|
+
</label>
|
|
135
|
+
);
|
|
136
|
+
/* eslint-enable jsx-a11y/label-has-associated-control */
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const deprecated = [ v1 ];
|
|
141
|
+
|
|
142
|
+
export default deprecated;
|
package/src/form-input/edit.js
CHANGED
|
@@ -59,7 +59,7 @@ function InputFieldBlock( { attributes, setAttributes, className } ) {
|
|
|
59
59
|
</PanelBody>
|
|
60
60
|
</InspectorControls>
|
|
61
61
|
) }
|
|
62
|
-
<InspectorControls
|
|
62
|
+
<InspectorControls group="advanced">
|
|
63
63
|
<TextControl
|
|
64
64
|
autoComplete="off"
|
|
65
65
|
label={ __( 'Name' ) }
|
package/src/form-input/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
4
|
import initBlock from '../utils/init-block';
|
|
5
|
+
import deprecated from './deprecated';
|
|
5
6
|
import edit from './edit';
|
|
6
7
|
import metadata from './block.json';
|
|
7
8
|
import save from './save';
|
|
@@ -12,6 +13,7 @@ const { name } = metadata;
|
|
|
12
13
|
export { metadata, name };
|
|
13
14
|
|
|
14
15
|
export const settings = {
|
|
16
|
+
deprecated,
|
|
15
17
|
edit,
|
|
16
18
|
save,
|
|
17
19
|
variations,
|
package/src/form-input/save.js
CHANGED
|
@@ -9,9 +9,11 @@ import removeAccents from 'remove-accents';
|
|
|
9
9
|
*/
|
|
10
10
|
import {
|
|
11
11
|
RichText,
|
|
12
|
+
useBlockProps,
|
|
12
13
|
__experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
|
|
13
14
|
__experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
|
|
14
15
|
} from '@wordpress/block-editor';
|
|
16
|
+
import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
15
17
|
|
|
16
18
|
/**
|
|
17
19
|
* Get the name attribute from a content string.
|
|
@@ -21,11 +23,8 @@ import {
|
|
|
21
23
|
* @return {string} Returns the slug.
|
|
22
24
|
*/
|
|
23
25
|
const getNameFromLabel = ( content ) => {
|
|
24
|
-
const dummyElement = document.createElement( 'div' );
|
|
25
|
-
dummyElement.innerHTML = content;
|
|
26
|
-
// Get the slug.
|
|
27
26
|
return (
|
|
28
|
-
removeAccents(
|
|
27
|
+
removeAccents( stripHTML( content ) )
|
|
29
28
|
// Convert anything that's not a letter or number to a hyphen.
|
|
30
29
|
.replace( /[^\p{L}\p{N}]+/gu, '-' )
|
|
31
30
|
// Convert to lowercase
|
|
@@ -54,30 +53,34 @@ export default function save( { attributes } ) {
|
|
|
54
53
|
);
|
|
55
54
|
const TagName = type === 'textarea' ? 'textarea' : 'input';
|
|
56
55
|
|
|
56
|
+
const blockProps = useBlockProps.save();
|
|
57
|
+
|
|
57
58
|
if ( 'hidden' === type ) {
|
|
58
59
|
return <input type={ type } name={ name } value={ value } />;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
/* eslint-disable jsx-a11y/label-has-associated-control */
|
|
62
62
|
return (
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
63
|
+
<div { ...blockProps }>
|
|
64
|
+
{ /* eslint-disable jsx-a11y/label-has-associated-control */ }
|
|
65
|
+
<label
|
|
66
|
+
className={ classNames( 'wp-block-form-input__label', {
|
|
67
|
+
'is-label-inline': inlineLabel,
|
|
68
|
+
} ) }
|
|
69
|
+
>
|
|
70
|
+
<span className="wp-block-form-input__label-content">
|
|
71
|
+
<RichText.Content value={ label } />
|
|
72
|
+
</span>
|
|
73
|
+
<TagName
|
|
74
|
+
className={ inputClasses }
|
|
75
|
+
type={ 'textarea' === type ? undefined : type }
|
|
76
|
+
name={ name || getNameFromLabel( label ) }
|
|
77
|
+
required={ required }
|
|
78
|
+
aria-required={ required }
|
|
79
|
+
placeholder={ placeholder || undefined }
|
|
80
|
+
style={ inputStyle }
|
|
81
|
+
/>
|
|
82
|
+
</label>
|
|
83
|
+
{ /* eslint-enable jsx-a11y/label-has-associated-control */ }
|
|
84
|
+
</div>
|
|
81
85
|
);
|
|
82
|
-
/* eslint-enable jsx-a11y/label-has-associated-control */
|
|
83
86
|
}
|
package/src/gallery/block.json
CHANGED
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"attribute": "data-id"
|
|
47
47
|
},
|
|
48
48
|
"caption": {
|
|
49
|
-
"type": "
|
|
50
|
-
"source": "
|
|
49
|
+
"type": "rich-text",
|
|
50
|
+
"source": "rich-text",
|
|
51
51
|
"selector": ".blocks-gallery-item__caption"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"maximum": 8
|
|
73
73
|
},
|
|
74
74
|
"caption": {
|
|
75
|
-
"type": "
|
|
76
|
-
"source": "
|
|
75
|
+
"type": "rich-text",
|
|
76
|
+
"source": "rich-text",
|
|
77
77
|
"selector": ".blocks-gallery-caption"
|
|
78
78
|
},
|
|
79
79
|
"imageCrop": {
|
package/src/gallery/edit.js
CHANGED
|
@@ -6,7 +6,7 @@ import classnames from 'classnames';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { compose
|
|
9
|
+
import { compose } from '@wordpress/compose';
|
|
10
10
|
import {
|
|
11
11
|
BaseControl,
|
|
12
12
|
PanelBody,
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
ToggleControl,
|
|
15
15
|
RangeControl,
|
|
16
16
|
Spinner,
|
|
17
|
-
ToolbarButton,
|
|
18
17
|
} from '@wordpress/components';
|
|
19
18
|
import {
|
|
20
19
|
store as blockEditorStore,
|
|
@@ -25,13 +24,7 @@ import {
|
|
|
25
24
|
BlockControls,
|
|
26
25
|
MediaReplaceFlow,
|
|
27
26
|
} from '@wordpress/block-editor';
|
|
28
|
-
import {
|
|
29
|
-
Platform,
|
|
30
|
-
useCallback,
|
|
31
|
-
useEffect,
|
|
32
|
-
useState,
|
|
33
|
-
useMemo,
|
|
34
|
-
} from '@wordpress/element';
|
|
27
|
+
import { Platform, useEffect, useMemo } from '@wordpress/element';
|
|
35
28
|
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
36
29
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
37
30
|
import { withViewportMatch } from '@wordpress/viewport';
|
|
@@ -39,7 +32,6 @@ import { View } from '@wordpress/primitives';
|
|
|
39
32
|
import { createBlock } from '@wordpress/blocks';
|
|
40
33
|
import { createBlobURL } from '@wordpress/blob';
|
|
41
34
|
import { store as noticesStore } from '@wordpress/notices';
|
|
42
|
-
import { caption as captionIcon } from '@wordpress/icons';
|
|
43
35
|
|
|
44
36
|
/**
|
|
45
37
|
* Internal dependencies
|
|
@@ -94,34 +86,7 @@ function GalleryEdit( props ) {
|
|
|
94
86
|
onFocus,
|
|
95
87
|
} = props;
|
|
96
88
|
|
|
97
|
-
const { columns, imageCrop, linkTarget, linkTo, sizeSlug
|
|
98
|
-
attributes;
|
|
99
|
-
const [ showCaption, setShowCaption ] = useState( !! caption );
|
|
100
|
-
const prevCaption = usePrevious( caption );
|
|
101
|
-
|
|
102
|
-
// We need to show the caption when changes come from
|
|
103
|
-
// history navigation(undo/redo).
|
|
104
|
-
useEffect( () => {
|
|
105
|
-
if ( caption && ! prevCaption ) {
|
|
106
|
-
setShowCaption( true );
|
|
107
|
-
}
|
|
108
|
-
}, [ caption, prevCaption ] );
|
|
109
|
-
|
|
110
|
-
useEffect( () => {
|
|
111
|
-
if ( ! isSelected && ! caption ) {
|
|
112
|
-
setShowCaption( false );
|
|
113
|
-
}
|
|
114
|
-
}, [ isSelected, caption ] );
|
|
115
|
-
|
|
116
|
-
// Focus the caption when we click to add one.
|
|
117
|
-
const captionRef = useCallback(
|
|
118
|
-
( node ) => {
|
|
119
|
-
if ( node && ! caption ) {
|
|
120
|
-
node.focus();
|
|
121
|
-
}
|
|
122
|
-
},
|
|
123
|
-
[ caption ]
|
|
124
|
-
);
|
|
89
|
+
const { columns, imageCrop, linkTarget, linkTo, sizeSlug } = attributes;
|
|
125
90
|
|
|
126
91
|
const {
|
|
127
92
|
__unstableMarkNextChangeAsNotPersistent,
|
|
@@ -620,25 +585,6 @@ function GalleryEdit( props ) {
|
|
|
620
585
|
</InspectorControls>
|
|
621
586
|
{ Platform.isWeb && (
|
|
622
587
|
<>
|
|
623
|
-
<BlockControls group="block">
|
|
624
|
-
{ ! isContentLocked && (
|
|
625
|
-
<ToolbarButton
|
|
626
|
-
onClick={ () => {
|
|
627
|
-
setShowCaption( ! showCaption );
|
|
628
|
-
if ( showCaption && caption ) {
|
|
629
|
-
setAttributes( { caption: undefined } );
|
|
630
|
-
}
|
|
631
|
-
} }
|
|
632
|
-
icon={ captionIcon }
|
|
633
|
-
isPressed={ showCaption }
|
|
634
|
-
label={
|
|
635
|
-
showCaption
|
|
636
|
-
? __( 'Remove caption' )
|
|
637
|
-
: __( 'Add caption' )
|
|
638
|
-
}
|
|
639
|
-
/>
|
|
640
|
-
) }
|
|
641
|
-
</BlockControls>
|
|
642
588
|
<BlockControls group="other">
|
|
643
589
|
<MediaReplaceFlow
|
|
644
590
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
@@ -661,8 +607,7 @@ function GalleryEdit( props ) {
|
|
|
661
607
|
) }
|
|
662
608
|
<Gallery
|
|
663
609
|
{ ...props }
|
|
664
|
-
|
|
665
|
-
ref={ Platform.isWeb ? captionRef : undefined }
|
|
610
|
+
isContentLocked={ isContentLocked }
|
|
666
611
|
images={ images }
|
|
667
612
|
mediaPlaceholder={
|
|
668
613
|
! hasImages || Platform.isNative
|