@wordpress/block-editor 8.0.11 → 8.0.12-next.33ec3857e2.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/README.md +4 -0
- package/build/components/block-caption/index.native.js +14 -3
- package/build/components/block-caption/index.native.js.map +1 -1
- package/build/components/block-inspector/index.js +12 -23
- package/build/components/block-inspector/index.js.map +1 -1
- package/build/components/block-list-appender/index.js +3 -11
- package/build/components/block-list-appender/index.js.map +1 -1
- package/build/components/block-preview/auto.js +10 -2
- package/build/components/block-preview/auto.js.map +1 -1
- package/build/components/block-preview/index.js +51 -0
- package/build/components/block-preview/index.js.map +1 -1
- package/build/components/block-settings/container.native.js +2 -1
- package/build/components/block-settings/container.native.js.map +1 -1
- package/build/components/block-styles/index.js +110 -134
- package/build/components/block-styles/index.js.map +1 -1
- package/build/components/block-styles/menu-items.js +63 -0
- package/build/components/block-styles/menu-items.js.map +1 -0
- package/build/components/block-styles/preview-panel.js +45 -0
- package/build/components/block-styles/preview-panel.js.map +1 -0
- package/build/components/block-styles/use-styles-for-block.js +119 -0
- package/build/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build/components/block-styles/utils.js +39 -0
- package/build/components/block-styles/utils.js.map +1 -1
- package/build/components/block-switcher/block-styles-menu.js +3 -23
- package/build/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build/components/block-tools/back-compat.js +2 -1
- package/build/components/block-tools/back-compat.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +11 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/button-block-appender/index.js +2 -1
- package/build/components/button-block-appender/index.js.map +1 -1
- package/build/components/colors-gradients/panel-color-gradient-settings.js +51 -10
- package/build/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build/components/default-block-appender/index.js +16 -19
- package/build/components/default-block-appender/index.js.map +1 -1
- package/build/components/default-style-picker/index.js +18 -3
- package/build/components/default-style-picker/index.js.map +1 -1
- package/build/components/iframe/index.js +3 -4
- package/build/components/iframe/index.js.map +1 -1
- package/build/components/index.js +17 -10
- package/build/components/index.js.map +1 -1
- package/build/components/inner-blocks/default-block-appender.js +2 -4
- package/build/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build/components/inserter/index.native.js +1 -1
- package/build/components/inserter/index.native.js.map +1 -1
- package/build/components/inserter/tabs.native.js +7 -4
- package/build/components/inserter/tabs.native.js.map +1 -1
- package/build/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build/components/inspector-controls/fill.native.js +3 -5
- package/build/components/inspector-controls/fill.native.js.map +1 -1
- package/build/components/inspector-controls/groups.js +2 -0
- package/build/components/inspector-controls/groups.js.map +1 -1
- package/build/components/inspector-controls/slot.js +1 -3
- package/build/components/inspector-controls/slot.js.map +1 -1
- package/build/components/letter-spacing-control/index.js +6 -6
- package/build/components/letter-spacing-control/index.js.map +1 -1
- package/build/components/list-view/block-select-button.js +23 -3
- package/build/components/list-view/block-select-button.js.map +1 -1
- package/build/components/media-placeholder/index.js +2 -0
- package/build/components/media-placeholder/index.js.map +1 -1
- package/build/components/media-replace-flow/index.js +2 -0
- package/build/components/media-replace-flow/index.js.map +1 -1
- package/build/components/rich-text/file-paste-handler.js +1 -1
- package/build/components/rich-text/file-paste-handler.js.map +1 -1
- package/build/components/rich-text/prevent-event-discovery.js +33 -0
- package/build/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build/components/rich-text/use-input-rules.js +3 -1
- package/build/components/rich-text/use-input-rules.js.map +1 -1
- package/build/components/selection-scroll-into-view/index.js +2 -1
- package/build/components/selection-scroll-into-view/index.js.map +1 -1
- package/build/components/use-display-block-controls/index.native.js +45 -0
- package/build/components/use-display-block-controls/index.native.js.map +1 -0
- package/build/components/use-on-block-drop/index.js +7 -3
- package/build/components/use-on-block-drop/index.js.map +1 -1
- package/build/components/writing-flow/use-multi-selection.js +3 -1
- package/build/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build/hooks/border-color.js +63 -5
- package/build/hooks/border-color.js.map +1 -1
- package/build/hooks/border-radius.js +47 -0
- package/build/hooks/border-radius.js.map +1 -1
- package/build/hooks/border-style.js +41 -0
- package/build/hooks/border-style.js.map +1 -1
- package/build/hooks/border-width.js +70 -31
- package/build/hooks/border-width.js.map +1 -1
- package/build/hooks/border.js +81 -11
- package/build/hooks/border.js.map +1 -1
- package/build/hooks/letter-spacing.js +1 -1
- package/build/hooks/letter-spacing.js.map +1 -1
- package/build/hooks/typography.js +1 -1
- package/build/hooks/typography.js.map +1 -1
- package/build/store/actions.js +1 -2
- package/build/store/actions.js.map +1 -1
- package/build/store/defaults.js +5 -1
- package/build/store/defaults.js.map +1 -1
- package/build/store/selectors.js +25 -7
- package/build/store/selectors.js.map +1 -1
- package/build/utils/get-paste-event-data.js +1 -1
- package/build/utils/get-paste-event-data.js.map +1 -1
- package/build/utils/parse-css-unit-to-px.js +1 -1
- package/build/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-module/components/block-caption/index.native.js +13 -3
- package/build-module/components/block-caption/index.native.js.map +1 -1
- package/build-module/components/block-inspector/index.js +12 -23
- package/build-module/components/block-inspector/index.js.map +1 -1
- package/build-module/components/block-list-appender/index.js +3 -10
- package/build-module/components/block-list-appender/index.js.map +1 -1
- package/build-module/components/block-preview/auto.js +10 -2
- package/build-module/components/block-preview/auto.js.map +1 -1
- package/build-module/components/block-preview/index.js +46 -0
- package/build-module/components/block-preview/index.js.map +1 -1
- package/build-module/components/block-settings/container.native.js +2 -1
- package/build-module/components/block-settings/container.native.js.map +1 -1
- package/build-module/components/block-styles/index.js +112 -133
- package/build-module/components/block-styles/index.js.map +1 -1
- package/build-module/components/block-styles/menu-items.js +50 -0
- package/build-module/components/block-styles/menu-items.js.map +1 -0
- package/build-module/components/block-styles/preview-panel.js +35 -0
- package/build-module/components/block-styles/preview-panel.js.map +1 -0
- package/build-module/components/block-styles/use-styles-for-block.js +107 -0
- package/build-module/components/block-styles/use-styles-for-block.js.map +1 -0
- package/build-module/components/block-styles/utils.js +34 -0
- package/build-module/components/block-styles/utils.js.map +1 -1
- package/build-module/components/block-switcher/block-styles-menu.js +3 -21
- package/build-module/components/block-switcher/block-styles-menu.js.map +1 -1
- package/build-module/components/block-tools/back-compat.js +2 -1
- package/build-module/components/block-tools/back-compat.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +11 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/button-block-appender/index.js +2 -1
- package/build-module/components/button-block-appender/index.js.map +1 -1
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js +54 -13
- package/build-module/components/colors-gradients/panel-color-gradient-settings.js.map +1 -1
- package/build-module/components/default-block-appender/index.js +15 -18
- package/build-module/components/default-block-appender/index.js.map +1 -1
- package/build-module/components/default-style-picker/index.js +17 -3
- package/build-module/components/default-style-picker/index.js.map +1 -1
- package/build-module/components/iframe/index.js +3 -4
- package/build-module/components/iframe/index.js.map +1 -1
- package/build-module/components/index.js +2 -2
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/inner-blocks/default-block-appender.js +2 -4
- package/build-module/components/inner-blocks/default-block-appender.js.map +1 -1
- package/build-module/components/inserter/index.native.js +2 -2
- package/build-module/components/inserter/index.native.js.map +1 -1
- package/build-module/components/inserter/tabs.native.js +7 -4
- package/build-module/components/inserter/tabs.native.js.map +1 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js +2 -1
- package/build-module/components/inspector-controls/block-support-slot-container.js.map +1 -1
- package/build-module/components/inspector-controls/fill.native.js +3 -5
- package/build-module/components/inspector-controls/fill.native.js.map +1 -1
- package/build-module/components/inspector-controls/groups.js +2 -0
- package/build-module/components/inspector-controls/groups.js.map +1 -1
- package/build-module/components/inspector-controls/slot.js +1 -3
- package/build-module/components/inspector-controls/slot.js.map +1 -1
- package/build-module/components/letter-spacing-control/index.js +6 -6
- package/build-module/components/letter-spacing-control/index.js.map +1 -1
- package/build-module/components/list-view/block-select-button.js +22 -3
- package/build-module/components/list-view/block-select-button.js.map +1 -1
- package/build-module/components/media-placeholder/index.js +2 -0
- package/build-module/components/media-placeholder/index.js.map +1 -1
- package/build-module/components/media-replace-flow/index.js +2 -0
- package/build-module/components/media-replace-flow/index.js.map +1 -1
- package/build-module/components/rich-text/file-paste-handler.js +1 -1
- package/build-module/components/rich-text/file-paste-handler.js.map +1 -1
- package/build-module/components/rich-text/prevent-event-discovery.js +25 -0
- package/build-module/components/rich-text/prevent-event-discovery.js.map +1 -0
- package/build-module/components/rich-text/use-input-rules.js +2 -1
- package/build-module/components/rich-text/use-input-rules.js.map +1 -1
- package/build-module/components/selection-scroll-into-view/index.js +2 -1
- package/build-module/components/selection-scroll-into-view/index.js.map +1 -1
- package/build-module/components/use-display-block-controls/index.native.js +34 -0
- package/build-module/components/use-display-block-controls/index.native.js.map +1 -0
- package/build-module/components/use-on-block-drop/index.js +7 -3
- package/build-module/components/use-on-block-drop/index.js.map +1 -1
- package/build-module/components/writing-flow/use-multi-selection.js +3 -4
- package/build-module/components/writing-flow/use-multi-selection.js.map +1 -1
- package/build-module/hooks/border-color.js +61 -7
- package/build-module/hooks/border-color.js.map +1 -1
- package/build-module/hooks/border-radius.js +42 -0
- package/build-module/hooks/border-radius.js.map +1 -1
- package/build-module/hooks/border-style.js +36 -0
- package/build-module/hooks/border-style.js.map +1 -1
- package/build-module/hooks/border-width.js +66 -32
- package/build-module/hooks/border-width.js.map +1 -1
- package/build-module/hooks/border.js +80 -12
- package/build-module/hooks/border.js.map +1 -1
- package/build-module/hooks/letter-spacing.js +1 -1
- package/build-module/hooks/letter-spacing.js.map +1 -1
- package/build-module/hooks/typography.js +1 -1
- package/build-module/hooks/typography.js.map +1 -1
- package/build-module/store/actions.js +1 -2
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/defaults.js +5 -1
- package/build-module/store/defaults.js.map +1 -1
- package/build-module/store/selectors.js +24 -7
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/utils/get-paste-event-data.js +1 -1
- package/build-module/utils/get-paste-event-data.js.map +1 -1
- package/build-module/utils/parse-css-unit-to-px.js +1 -1
- package/build-module/utils/parse-css-unit-to-px.js.map +1 -1
- package/build-style/style-rtl.css +226 -180
- package/build-style/style.css +226 -180
- package/package.json +27 -27
- package/src/components/block-caption/index.native.js +22 -4
- package/src/components/block-inspector/index.js +14 -17
- package/src/components/block-list-appender/index.js +5 -21
- package/src/components/block-preview/auto.js +7 -2
- package/src/components/block-preview/index.js +60 -0
- package/src/components/block-preview/style.scss +23 -0
- package/src/components/block-preview/test/index.js +114 -0
- package/src/components/block-settings/container.native.js +1 -0
- package/src/components/block-styles/index.js +125 -145
- package/src/components/block-styles/menu-items.js +49 -0
- package/src/components/block-styles/preview-panel.js +36 -0
- package/src/components/block-styles/style.scss +59 -51
- package/src/components/block-styles/test/{index.js → utils.js} +60 -1
- package/src/components/block-styles/use-styles-for-block.js +99 -0
- package/src/components/block-styles/utils.js +39 -0
- package/src/components/block-switcher/block-styles-menu.js +3 -38
- package/src/components/block-tools/back-compat.js +1 -0
- package/src/components/block-tools/insertion-point.js +10 -1
- package/src/components/border-style-control/style.scss +0 -1
- package/src/components/button-block-appender/index.js +1 -0
- package/src/components/colors-gradients/panel-color-gradient-settings.js +75 -19
- package/src/components/colors-gradients/style.scss +42 -5
- package/src/components/default-block-appender/index.js +17 -24
- package/src/components/default-block-appender/style.scss +4 -0
- package/src/components/default-block-appender/test/__snapshots__/index.js.snap +12 -24
- package/src/components/default-block-appender/test/index.js +4 -14
- package/src/components/default-style-picker/index.js +18 -6
- package/src/components/iframe/index.js +6 -3
- package/src/components/index.js +5 -2
- package/src/components/inner-blocks/README.md +2 -0
- package/src/components/inner-blocks/default-block-appender.js +2 -7
- package/src/components/inserter/index.native.js +2 -2
- package/src/components/inserter/tabs.native.js +5 -4
- package/src/components/inspector-controls/block-support-slot-container.js +3 -1
- package/src/components/inspector-controls/fill.native.js +4 -3
- package/src/components/inspector-controls/groups.js +2 -0
- package/src/components/inspector-controls/slot.js +2 -7
- package/src/components/letter-spacing-control/index.js +6 -6
- package/src/components/link-control/README.md +1 -1
- package/src/components/link-control/test/index.js +2 -0
- package/src/components/list-view/block-select-button.js +20 -1
- package/src/components/media-placeholder/index.js +2 -0
- package/src/components/media-replace-flow/index.js +2 -0
- package/src/components/rich-text/file-paste-handler.js +3 -1
- package/src/components/rich-text/prevent-event-discovery.js +23 -0
- package/src/components/rich-text/use-input-rules.js +2 -1
- package/src/components/selection-scroll-into-view/index.js +1 -0
- package/src/components/url-input/README.md +5 -0
- package/src/components/use-display-block-controls/index.native.js +38 -0
- package/src/components/use-on-block-drop/index.js +7 -3
- package/src/components/writing-flow/test/use-multi-selection.js +36 -0
- package/src/components/writing-flow/use-multi-selection.js +12 -9
- package/src/hooks/border-color.js +55 -3
- package/src/hooks/border-radius.js +32 -0
- package/src/hooks/border-style.js +26 -0
- package/src/hooks/border-width.js +56 -32
- package/src/hooks/border.js +115 -20
- package/src/hooks/border.scss +3 -17
- package/src/hooks/dimensions.scss +5 -0
- package/src/hooks/letter-spacing.js +1 -1
- package/src/hooks/typography.js +1 -1
- package/src/store/actions.js +1 -2
- package/src/store/defaults.js +2 -0
- package/src/store/selectors.js +37 -7
- package/src/style.scss +4 -3
- package/src/utils/get-paste-event-data.js +1 -1
- package/src/utils/parse-css-unit-to-px.js +1 -1
- package/src/utils/test/parse-css-unit-to-px.js +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/components/use-canvas-click-redirect/index.js +0 -66
- package/build/components/use-canvas-click-redirect/index.js.map +0 -1
- package/build-module/components/use-canvas-click-redirect/index.js +0 -54
- package/build-module/components/use-canvas-click-redirect/index.js.map +0 -1
- package/src/components/use-canvas-click-redirect/index.js +0 -57
|
@@ -8,9 +8,9 @@ import classnames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { compose } from '@wordpress/compose';
|
|
11
|
-
import { getDefaultBlockName } from '@wordpress/blocks';
|
|
12
11
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
12
|
import { withSelect, withDispatch } from '@wordpress/data';
|
|
13
|
+
import { ENTER, SPACE } from '@wordpress/keycodes';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Internal dependencies
|
|
@@ -26,13 +26,12 @@ export const ZWNBSP = '\ufeff';
|
|
|
26
26
|
|
|
27
27
|
export function DefaultBlockAppender( {
|
|
28
28
|
isLocked,
|
|
29
|
-
isVisible,
|
|
30
29
|
onAppend,
|
|
31
30
|
showPrompt,
|
|
32
31
|
placeholder,
|
|
33
32
|
rootClientId,
|
|
34
33
|
} ) {
|
|
35
|
-
if ( isLocked
|
|
34
|
+
if ( isLocked ) {
|
|
36
35
|
return null;
|
|
37
36
|
}
|
|
38
37
|
|
|
@@ -48,20 +47,23 @@ export function DefaultBlockAppender( {
|
|
|
48
47
|
>
|
|
49
48
|
<p
|
|
50
49
|
tabIndex="0"
|
|
51
|
-
// Only necessary for `useCanvasClickRedirect` to consider it
|
|
52
|
-
// as a target. Ideally it should consider any tabbable target,
|
|
53
|
-
// but the inserter is rendered in place while it should be
|
|
54
|
-
// rendered in a popover, just like it does for an empty
|
|
55
|
-
// paragraph block.
|
|
56
|
-
contentEditable
|
|
57
|
-
suppressContentEditableWarning
|
|
58
50
|
// We want this element to be styled as a paragraph by themes.
|
|
59
51
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role
|
|
60
52
|
role="button"
|
|
61
|
-
aria-label={ __( 'Add block' ) }
|
|
53
|
+
aria-label={ __( 'Add default block' ) }
|
|
62
54
|
// A wrapping container for this one already has the wp-block className.
|
|
63
55
|
className="block-editor-default-block-appender__content"
|
|
64
|
-
|
|
56
|
+
onKeyDown={ ( event ) => {
|
|
57
|
+
if ( ENTER === event.keyCode || SPACE === event.keyCode ) {
|
|
58
|
+
onAppend();
|
|
59
|
+
}
|
|
60
|
+
} }
|
|
61
|
+
onClick={ () => onAppend() }
|
|
62
|
+
onFocus={ () => {
|
|
63
|
+
if ( showPrompt ) {
|
|
64
|
+
onAppend();
|
|
65
|
+
}
|
|
66
|
+
} }
|
|
65
67
|
>
|
|
66
68
|
{ showPrompt ? value : ZWNBSP }
|
|
67
69
|
</p>
|
|
@@ -77,23 +79,14 @@ export function DefaultBlockAppender( {
|
|
|
77
79
|
|
|
78
80
|
export default compose(
|
|
79
81
|
withSelect( ( select, ownProps ) => {
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isBlockValid,
|
|
84
|
-
getSettings,
|
|
85
|
-
getTemplateLock,
|
|
86
|
-
} = select( blockEditorStore );
|
|
82
|
+
const { getBlockCount, getSettings, getTemplateLock } = select(
|
|
83
|
+
blockEditorStore
|
|
84
|
+
);
|
|
87
85
|
|
|
88
86
|
const isEmpty = ! getBlockCount( ownProps.rootClientId );
|
|
89
|
-
const isLastBlockDefault =
|
|
90
|
-
getBlockName( ownProps.lastBlockClientId ) ===
|
|
91
|
-
getDefaultBlockName();
|
|
92
|
-
const isLastBlockValid = isBlockValid( ownProps.lastBlockClientId );
|
|
93
87
|
const { bodyPlaceholder } = getSettings();
|
|
94
88
|
|
|
95
89
|
return {
|
|
96
|
-
isVisible: isEmpty || ! isLastBlockDefault || ! isLastBlockValid,
|
|
97
90
|
showPrompt: isEmpty,
|
|
98
91
|
isLocked: !! getTemplateLock( ownProps.rootClientId ),
|
|
99
92
|
placeholder: bodyPlaceholder,
|
|
@@ -6,24 +6,12 @@ exports[`DefaultBlockAppender should append a default block when input focused 1
|
|
|
6
6
|
data-root-client-id=""
|
|
7
7
|
>
|
|
8
8
|
<p
|
|
9
|
-
aria-label="Add block"
|
|
9
|
+
aria-label="Add default block"
|
|
10
10
|
className="block-editor-default-block-appender__content"
|
|
11
|
-
|
|
12
|
-
onFocus={
|
|
13
|
-
|
|
14
|
-
"calls": Array [
|
|
15
|
-
Array [],
|
|
16
|
-
],
|
|
17
|
-
"results": Array [
|
|
18
|
-
Object {
|
|
19
|
-
"type": "return",
|
|
20
|
-
"value": undefined,
|
|
21
|
-
},
|
|
22
|
-
],
|
|
23
|
-
}
|
|
24
|
-
}
|
|
11
|
+
onClick={[Function]}
|
|
12
|
+
onFocus={[Function]}
|
|
13
|
+
onKeyDown={[Function]}
|
|
25
14
|
role="button"
|
|
26
|
-
suppressContentEditableWarning={true}
|
|
27
15
|
tabIndex="0"
|
|
28
16
|
>
|
|
29
17
|
Type / to choose a block
|
|
@@ -42,12 +30,12 @@ exports[`DefaultBlockAppender should match snapshot 1`] = `
|
|
|
42
30
|
data-root-client-id=""
|
|
43
31
|
>
|
|
44
32
|
<p
|
|
45
|
-
aria-label="Add block"
|
|
33
|
+
aria-label="Add default block"
|
|
46
34
|
className="block-editor-default-block-appender__content"
|
|
47
|
-
|
|
48
|
-
onFocus={[
|
|
35
|
+
onClick={[Function]}
|
|
36
|
+
onFocus={[Function]}
|
|
37
|
+
onKeyDown={[Function]}
|
|
49
38
|
role="button"
|
|
50
|
-
suppressContentEditableWarning={true}
|
|
51
39
|
tabIndex="0"
|
|
52
40
|
>
|
|
53
41
|
Type / to choose a block
|
|
@@ -66,12 +54,12 @@ exports[`DefaultBlockAppender should optionally show without prompt 1`] = `
|
|
|
66
54
|
data-root-client-id=""
|
|
67
55
|
>
|
|
68
56
|
<p
|
|
69
|
-
aria-label="Add block"
|
|
57
|
+
aria-label="Add default block"
|
|
70
58
|
className="block-editor-default-block-appender__content"
|
|
71
|
-
|
|
72
|
-
onFocus={[
|
|
59
|
+
onClick={[Function]}
|
|
60
|
+
onFocus={[Function]}
|
|
61
|
+
onKeyDown={[Function]}
|
|
73
62
|
role="button"
|
|
74
|
-
suppressContentEditableWarning={true}
|
|
75
63
|
tabIndex="0"
|
|
76
64
|
>
|
|
77
65
|
|
|
@@ -14,16 +14,10 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
14
14
|
expect( onAppend ).toHaveBeenCalledWith();
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
it( 'should render nothing if not visible', () => {
|
|
18
|
-
const wrapper = shallow( <DefaultBlockAppender /> );
|
|
19
|
-
|
|
20
|
-
expect( wrapper.type() ).toBe( null );
|
|
21
|
-
} );
|
|
22
|
-
|
|
23
17
|
it( 'should match snapshot', () => {
|
|
24
18
|
const onAppend = jest.fn();
|
|
25
19
|
const wrapper = shallow(
|
|
26
|
-
<DefaultBlockAppender
|
|
20
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
27
21
|
);
|
|
28
22
|
|
|
29
23
|
expect( wrapper ).toMatchSnapshot();
|
|
@@ -32,10 +26,10 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
32
26
|
it( 'should append a default block when input focused', () => {
|
|
33
27
|
const onAppend = jest.fn();
|
|
34
28
|
const wrapper = shallow(
|
|
35
|
-
<DefaultBlockAppender
|
|
29
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt />
|
|
36
30
|
);
|
|
37
31
|
|
|
38
|
-
wrapper.find( 'p' ).simulate( '
|
|
32
|
+
wrapper.find( 'p' ).simulate( 'click' );
|
|
39
33
|
|
|
40
34
|
expect( wrapper ).toMatchSnapshot();
|
|
41
35
|
|
|
@@ -45,11 +39,7 @@ describe( 'DefaultBlockAppender', () => {
|
|
|
45
39
|
it( 'should optionally show without prompt', () => {
|
|
46
40
|
const onAppend = jest.fn();
|
|
47
41
|
const wrapper = shallow(
|
|
48
|
-
<DefaultBlockAppender
|
|
49
|
-
isVisible
|
|
50
|
-
onAppend={ onAppend }
|
|
51
|
-
showPrompt={ false }
|
|
52
|
-
/>
|
|
42
|
+
<DefaultBlockAppender onAppend={ onAppend } showPrompt={ false } />
|
|
53
43
|
);
|
|
54
44
|
const input = wrapper.find( 'p' );
|
|
55
45
|
|
|
@@ -11,6 +11,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import { getDefaultStyle } from '../block-styles/utils';
|
|
14
15
|
|
|
15
16
|
export default function DefaultStylePicker( { blockName } ) {
|
|
16
17
|
const {
|
|
@@ -38,6 +39,9 @@ export default function DefaultStylePicker( { blockName } ) {
|
|
|
38
39
|
],
|
|
39
40
|
[ styles ]
|
|
40
41
|
);
|
|
42
|
+
const defaultStyleName = useMemo( () => getDefaultStyle( styles )?.name, [
|
|
43
|
+
styles,
|
|
44
|
+
] );
|
|
41
45
|
const selectOnChange = useCallback(
|
|
42
46
|
( blockStyle ) => {
|
|
43
47
|
onUpdatePreferredStyleVariations( blockName, blockStyle );
|
|
@@ -45,14 +49,22 @@ export default function DefaultStylePicker( { blockName } ) {
|
|
|
45
49
|
[ blockName, onUpdatePreferredStyleVariations ]
|
|
46
50
|
);
|
|
47
51
|
|
|
52
|
+
// Until the functionality is migrated to global styles,
|
|
53
|
+
// only show the default style picker if a non-default style has already been selected.
|
|
54
|
+
if ( ! preferredStyle || preferredStyle === defaultStyleName ) {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
onUpdatePreferredStyleVariations && (
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
<div className="default-style-picker__default-switcher">
|
|
61
|
+
<SelectControl
|
|
62
|
+
options={ selectOptions }
|
|
63
|
+
value={ preferredStyle || '' }
|
|
64
|
+
label={ __( 'Default Style' ) }
|
|
65
|
+
onChange={ selectOnChange }
|
|
66
|
+
/>
|
|
67
|
+
</div>
|
|
56
68
|
)
|
|
57
69
|
);
|
|
58
70
|
}
|
|
@@ -164,12 +164,15 @@ async function loadScript( head, { id, src } ) {
|
|
|
164
164
|
} );
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function Iframe(
|
|
167
|
+
function Iframe(
|
|
168
|
+
{ contentRef, children, head, tabIndex = 0, assets, ...props },
|
|
169
|
+
ref
|
|
170
|
+
) {
|
|
168
171
|
const [ , forceRender ] = useReducer( () => ( {} ) );
|
|
169
172
|
const [ iframeDocument, setIframeDocument ] = useState();
|
|
170
173
|
const [ bodyClasses, setBodyClasses ] = useState( [] );
|
|
171
|
-
const styles = useParsedAssets(
|
|
172
|
-
const scripts = useParsedAssets(
|
|
174
|
+
const styles = useParsedAssets( assets?.styles );
|
|
175
|
+
const scripts = useParsedAssets( assets?.scripts );
|
|
173
176
|
const clearerRef = useBlockSelectionClearer();
|
|
174
177
|
const [ before, writingFlowRef, after ] = useWritingFlow();
|
|
175
178
|
const setRef = useRefEffect( ( node ) => {
|
package/src/components/index.js
CHANGED
|
@@ -24,6 +24,7 @@ export { default as BlockColorsStyleSelector } from './color-style-selector';
|
|
|
24
24
|
export { default as BlockEdit, useBlockEditContext } from './block-edit';
|
|
25
25
|
export { default as BlockIcon } from './block-icon';
|
|
26
26
|
export { default as BlockNavigationDropdown } from './block-navigation/dropdown';
|
|
27
|
+
export { default as BlockStyles } from './block-styles';
|
|
27
28
|
export { default as __experimentalBlockVariationPicker } from './block-variation-picker';
|
|
28
29
|
export { default as __experimentalBlockPatternSetup } from './block-pattern-setup';
|
|
29
30
|
export { default as __experimentalBlockVariationTransforms } from './block-variation-transforms';
|
|
@@ -103,7 +104,10 @@ export { default as BlockList } from './block-list';
|
|
|
103
104
|
export { useBlockProps } from './block-list/use-block-props';
|
|
104
105
|
export { LayoutStyle as __experimentalLayoutStyle } from './block-list/layout';
|
|
105
106
|
export { default as BlockMover } from './block-mover';
|
|
106
|
-
export {
|
|
107
|
+
export {
|
|
108
|
+
default as BlockPreview,
|
|
109
|
+
useBlockPreview as __experimentalUseBlockPreview,
|
|
110
|
+
} from './block-preview';
|
|
107
111
|
export {
|
|
108
112
|
default as BlockSelectionClearer,
|
|
109
113
|
useBlockSelectionClearer as __unstableUseBlockSelectionClearer,
|
|
@@ -137,7 +141,6 @@ export {
|
|
|
137
141
|
} from './typewriter';
|
|
138
142
|
export { default as Warning } from './warning';
|
|
139
143
|
export { default as WritingFlow } from './writing-flow';
|
|
140
|
-
export { useCanvasClickRedirect as __unstableUseCanvasClickRedirect } from './use-canvas-click-redirect';
|
|
141
144
|
export { default as useBlockDisplayInformation } from './use-block-display-information';
|
|
142
145
|
export { default as __unstableIframe } from './iframe';
|
|
143
146
|
export { default as __experimentalUseNoRecursiveRenders } from './use-no-recursive-renders';
|
|
@@ -41,6 +41,8 @@ _Note:_ A block can render at most a single `InnerBlocks` and `InnerBlocks.Conte
|
|
|
41
41
|
|
|
42
42
|
_Note:_ Because the save step will automatically apply props to the element returned by `save`, it is important to include the wrapping `div` in the above simple example even though we are applying no props of our own. In a real-world example, you may have your own attributes to apply to the saved markup, or sibling content adjacent to the rendered nested blocks.
|
|
43
43
|
|
|
44
|
+
_Note:_ Inner blocks, by default, are not visible inside a WordPress excerpt. If you wish your block to appear then it needs to be returned from the `excerpt_allowed_wrapper_blocks` filter. More details can be found on the [filter reference page](https://developer.wordpress.org/reference/hooks/excerpt_allowed_wrapper_blocks/) page, as well as the [excerpt_remove_blocks](https://developer.wordpress.org/reference/functions/excerpt_remove_blocks/) page.
|
|
45
|
+
|
|
44
46
|
## Props
|
|
45
47
|
|
|
46
48
|
### `allowedBlocks`
|
|
@@ -16,13 +16,8 @@ import BaseDefaultBlockAppender from '../default-block-appender';
|
|
|
16
16
|
import withClientId from './with-client-id';
|
|
17
17
|
import { store as blockEditorStore } from '../../store';
|
|
18
18
|
|
|
19
|
-
export const DefaultBlockAppender = ( { clientId
|
|
20
|
-
return
|
|
21
|
-
<BaseDefaultBlockAppender
|
|
22
|
-
rootClientId={ clientId }
|
|
23
|
-
lastBlockClientId={ lastBlockClientId }
|
|
24
|
-
/>
|
|
25
|
-
);
|
|
19
|
+
export const DefaultBlockAppender = ( { clientId } ) => {
|
|
20
|
+
return <BaseDefaultBlockAppender rootClientId={ clientId } />;
|
|
26
21
|
};
|
|
27
22
|
|
|
28
23
|
export default compose( [
|
|
@@ -7,7 +7,7 @@ import { delay } from 'lodash';
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { __, _x } from '@wordpress/i18n';
|
|
11
11
|
import { Dropdown, ToolbarButton, Picker } from '@wordpress/components';
|
|
12
12
|
import { Component } from '@wordpress/element';
|
|
13
13
|
import { withDispatch, withSelect } from '@wordpress/data';
|
|
@@ -34,7 +34,7 @@ const VOICE_OVER_ANNOUNCEMENT_DELAY = 1000;
|
|
|
34
34
|
|
|
35
35
|
const defaultRenderToggle = ( { onToggle, disabled, style, onLongPress } ) => (
|
|
36
36
|
<ToolbarButton
|
|
37
|
-
title={
|
|
37
|
+
title={ _x( 'Add block', 'Generic label for block inserter button' ) }
|
|
38
38
|
icon={
|
|
39
39
|
<Icon
|
|
40
40
|
icon={ plusCircleFilled }
|
|
@@ -63,7 +63,7 @@ function InserterTabs( {
|
|
|
63
63
|
}, [ tabIndex ] );
|
|
64
64
|
|
|
65
65
|
const { tabs, tabKeys } = useMemo( () => {
|
|
66
|
-
const filteredTabs = InserterTabs.
|
|
66
|
+
const filteredTabs = InserterTabs.getTabs().filter(
|
|
67
67
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
68
68
|
);
|
|
69
69
|
return {
|
|
@@ -114,8 +114,9 @@ function InserterTabs( {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
117
|
+
const tabs = InserterTabs.getTabs();
|
|
117
118
|
const segments = useMemo( () => {
|
|
118
|
-
const filteredTabs =
|
|
119
|
+
const filteredTabs = tabs.filter(
|
|
119
120
|
( { name } ) => showReusableBlocks || name !== 'reusable'
|
|
120
121
|
);
|
|
121
122
|
return filteredTabs.map( ( { title } ) => title );
|
|
@@ -123,7 +124,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
123
124
|
|
|
124
125
|
const segmentHandler = useCallback(
|
|
125
126
|
( selectedTab ) => {
|
|
126
|
-
const tabTitles =
|
|
127
|
+
const tabTitles = tabs.map( ( { title } ) => title );
|
|
127
128
|
onChangeTab( tabTitles.indexOf( selectedTab ) );
|
|
128
129
|
},
|
|
129
130
|
[ onChangeTab ]
|
|
@@ -139,7 +140,7 @@ function TabsControl( { onChangeTab, showReusableBlocks } ) {
|
|
|
139
140
|
|
|
140
141
|
InserterTabs.Control = TabsControl;
|
|
141
142
|
|
|
142
|
-
InserterTabs.
|
|
143
|
+
InserterTabs.getTabs = () => [
|
|
143
144
|
{ name: 'blocks', title: __( 'Blocks' ), component: BlockTypesTab },
|
|
144
145
|
{ name: 'reusable', title: __( 'Reusable' ), component: ReusableBlocksTab },
|
|
145
146
|
];
|
|
@@ -6,5 +6,7 @@ import { useContext } from '@wordpress/element';
|
|
|
6
6
|
|
|
7
7
|
export default function BlockSupportSlotContainer( { Slot, ...props } ) {
|
|
8
8
|
const toolsPanelContext = useContext( ToolsPanelContext );
|
|
9
|
-
return
|
|
9
|
+
return (
|
|
10
|
+
<Slot { ...props } fillProps={ toolsPanelContext } bubblesVirtually />
|
|
11
|
+
);
|
|
10
12
|
}
|
|
@@ -14,7 +14,7 @@ import warning from '@wordpress/warning';
|
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
16
|
import groups from './groups';
|
|
17
|
-
import
|
|
17
|
+
import useDisplayBlockControls from '../use-display-block-controls';
|
|
18
18
|
import { BlockSettingsButton } from '../block-settings';
|
|
19
19
|
|
|
20
20
|
export default function InspectorControlsFill( {
|
|
@@ -22,13 +22,14 @@ export default function InspectorControlsFill( {
|
|
|
22
22
|
__experimentalGroup: group = 'default',
|
|
23
23
|
...props
|
|
24
24
|
} ) {
|
|
25
|
-
const
|
|
25
|
+
const isDisplayed = useDisplayBlockControls();
|
|
26
|
+
|
|
26
27
|
const Fill = groups[ group ]?.Fill;
|
|
27
28
|
if ( ! Fill ) {
|
|
28
29
|
warning( `Unknown InspectorControl group "${ group }" provided.` );
|
|
29
30
|
return null;
|
|
30
31
|
}
|
|
31
|
-
if ( !
|
|
32
|
+
if ( ! isDisplayed ) {
|
|
32
33
|
return null;
|
|
33
34
|
}
|
|
34
35
|
|
|
@@ -5,6 +5,7 @@ import { createSlotFill } from '@wordpress/components';
|
|
|
5
5
|
|
|
6
6
|
const InspectorControlsDefault = createSlotFill( 'InspectorControls' );
|
|
7
7
|
const InspectorControlsAdvanced = createSlotFill( 'InspectorAdvancedControls' );
|
|
8
|
+
const InspectorControlsBorder = createSlotFill( 'InspectorControlsBorder' );
|
|
8
9
|
const InspectorControlsDimensions = createSlotFill(
|
|
9
10
|
'InspectorControlsDimensions'
|
|
10
11
|
);
|
|
@@ -15,6 +16,7 @@ const InspectorControlsTypography = createSlotFill(
|
|
|
15
16
|
const groups = {
|
|
16
17
|
default: InspectorControlsDefault,
|
|
17
18
|
advanced: InspectorControlsAdvanced,
|
|
19
|
+
border: InspectorControlsBorder,
|
|
18
20
|
dimensions: InspectorControlsDimensions,
|
|
19
21
|
typography: InspectorControlsTypography,
|
|
20
22
|
};
|
|
@@ -13,7 +13,6 @@ import groups from './groups';
|
|
|
13
13
|
|
|
14
14
|
export default function InspectorControlsSlot( {
|
|
15
15
|
__experimentalGroup: group = 'default',
|
|
16
|
-
bubblesVirtually = true,
|
|
17
16
|
label,
|
|
18
17
|
...props
|
|
19
18
|
} ) {
|
|
@@ -32,14 +31,10 @@ export default function InspectorControlsSlot( {
|
|
|
32
31
|
if ( label ) {
|
|
33
32
|
return (
|
|
34
33
|
<BlockSupportToolsPanel group={ group } label={ label }>
|
|
35
|
-
<BlockSupportSlotContainer
|
|
36
|
-
{ ...props }
|
|
37
|
-
bubblesVirtually={ bubblesVirtually }
|
|
38
|
-
Slot={ Slot }
|
|
39
|
-
/>
|
|
34
|
+
<BlockSupportSlotContainer { ...props } Slot={ Slot } />
|
|
40
35
|
</BlockSupportToolsPanel>
|
|
41
36
|
);
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
return <Slot { ...props } bubblesVirtually
|
|
39
|
+
return <Slot { ...props } bubblesVirtually />;
|
|
45
40
|
}
|
|
@@ -15,12 +15,12 @@ import useSetting from '../../components/use-setting';
|
|
|
15
15
|
/**
|
|
16
16
|
* Control for letter-spacing.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object}
|
|
19
|
-
* @param {string}
|
|
20
|
-
* @param {Function}
|
|
21
|
-
* @param {
|
|
18
|
+
* @param {Object} props Component props.
|
|
19
|
+
* @param {string} props.value Currently selected letter-spacing.
|
|
20
|
+
* @param {Function} props.onChange Handles change in letter-spacing selection.
|
|
21
|
+
* @param {string|number|undefined} props.__unstableInputWidth Input width to pass through to inner UnitControl. Should be a valid CSS value.
|
|
22
22
|
*
|
|
23
|
-
* @return {WPElement}
|
|
23
|
+
* @return {WPElement} Letter-spacing control.
|
|
24
24
|
*/
|
|
25
25
|
export default function LetterSpacingControl( {
|
|
26
26
|
value,
|
|
@@ -33,7 +33,7 @@ export default function LetterSpacingControl( {
|
|
|
33
33
|
} );
|
|
34
34
|
return (
|
|
35
35
|
<UnitControl
|
|
36
|
-
label={ __( 'Letter
|
|
36
|
+
label={ __( 'Letter spacing' ) }
|
|
37
37
|
value={ value }
|
|
38
38
|
__unstableInputWidth={ __unstableInputWidth }
|
|
39
39
|
units={ units }
|
|
@@ -1634,6 +1634,7 @@ describe( 'Selecting links', () => {
|
|
|
1634
1634
|
);
|
|
1635
1635
|
|
|
1636
1636
|
// We should have highlighted the first item using the keyboard
|
|
1637
|
+
// eslint-disable-next-line jest/no-conditional-expect
|
|
1637
1638
|
expect( selectedSearchResultElement ).toEqual(
|
|
1638
1639
|
secondSearchSuggestion
|
|
1639
1640
|
);
|
|
@@ -1648,6 +1649,7 @@ describe( 'Selecting links', () => {
|
|
|
1648
1649
|
);
|
|
1649
1650
|
|
|
1650
1651
|
// We should be back to highlighting the first search result again
|
|
1652
|
+
// eslint-disable-next-line jest/no-conditional-expect
|
|
1651
1653
|
expect( selectedSearchResultElement ).toEqual(
|
|
1652
1654
|
firstSearchSuggestion
|
|
1653
1655
|
);
|
|
@@ -19,6 +19,7 @@ import useBlockDisplayInformation from '../use-block-display-information';
|
|
|
19
19
|
import { getBlockPositionDescription } from './utils';
|
|
20
20
|
import BlockTitle from '../block-title';
|
|
21
21
|
import ListViewExpander from './expander';
|
|
22
|
+
import { SPACE, ENTER } from '@wordpress/keycodes';
|
|
22
23
|
|
|
23
24
|
function ListViewBlockSelectButton(
|
|
24
25
|
{
|
|
@@ -47,6 +48,22 @@ function ListViewBlockSelectButton(
|
|
|
47
48
|
level
|
|
48
49
|
);
|
|
49
50
|
|
|
51
|
+
// The `href` attribute triggers the browser's native HTML drag operations.
|
|
52
|
+
// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
|
|
53
|
+
// We need to clear any HTML drag data to prevent `pasteHandler` from firing
|
|
54
|
+
// inside the `useOnBlockDrop` hook.
|
|
55
|
+
const onDragStartHandler = ( event ) => {
|
|
56
|
+
event.dataTransfer.clearData();
|
|
57
|
+
onDragStart( event );
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
function onKeyDownHandler( event ) {
|
|
61
|
+
if ( event.keyCode === ENTER || event.keyCode === SPACE ) {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
onClick( event );
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
return (
|
|
51
68
|
<>
|
|
52
69
|
<Button
|
|
@@ -55,13 +72,15 @@ function ListViewBlockSelectButton(
|
|
|
55
72
|
className
|
|
56
73
|
) }
|
|
57
74
|
onClick={ onClick }
|
|
75
|
+
onKeyDown={ onKeyDownHandler }
|
|
58
76
|
aria-describedby={ descriptionId }
|
|
59
77
|
ref={ ref }
|
|
60
78
|
tabIndex={ tabIndex }
|
|
61
79
|
onFocus={ onFocus }
|
|
62
|
-
onDragStart={
|
|
80
|
+
onDragStart={ onDragStartHandler }
|
|
63
81
|
onDragEnd={ onDragEnd }
|
|
64
82
|
draggable={ draggable }
|
|
83
|
+
href={ `#block-${ clientId }` }
|
|
65
84
|
>
|
|
66
85
|
<ListViewExpander onClick={ onToggleExpanded } />
|
|
67
86
|
<BlockIcon icon={ blockInformation?.icon } showColors />
|
|
@@ -75,6 +75,7 @@ export function MediaPlaceholder( {
|
|
|
75
75
|
onDoubleClick,
|
|
76
76
|
onFilesPreUpload = noop,
|
|
77
77
|
onHTMLDrop = noop,
|
|
78
|
+
onClose = noop,
|
|
78
79
|
children,
|
|
79
80
|
mediaLibraryButton,
|
|
80
81
|
placeholder,
|
|
@@ -328,6 +329,7 @@ export function MediaPlaceholder( {
|
|
|
328
329
|
gallery={ multiple && onlyAllowsImages() }
|
|
329
330
|
multiple={ multiple }
|
|
330
331
|
onSelect={ onSelect }
|
|
332
|
+
onClose={ onClose }
|
|
331
333
|
allowedTypes={ allowedTypes }
|
|
332
334
|
value={
|
|
333
335
|
Array.isArray( value )
|
|
@@ -39,6 +39,7 @@ const MediaReplaceFlow = ( {
|
|
|
39
39
|
onSelect,
|
|
40
40
|
onSelectURL,
|
|
41
41
|
onFilesUpload = noop,
|
|
42
|
+
onCloseModal = noop,
|
|
42
43
|
name = __( 'Replace' ),
|
|
43
44
|
createNotice,
|
|
44
45
|
removeNotice,
|
|
@@ -136,6 +137,7 @@ const MediaReplaceFlow = ( {
|
|
|
136
137
|
value={ mediaId }
|
|
137
138
|
onSelect={ ( media ) => selectMedia( media ) }
|
|
138
139
|
allowedTypes={ allowedTypes }
|
|
140
|
+
onClose={ onCloseModal }
|
|
139
141
|
render={ ( { open } ) => (
|
|
140
142
|
<MenuItem icon={ mediaIcon } onClick={ open }>
|
|
141
143
|
{ __( 'Open Media Library' ) }
|
|
@@ -5,7 +5,9 @@ import { createBlobURL } from '@wordpress/blob';
|
|
|
5
5
|
|
|
6
6
|
export function filePasteHandler( files ) {
|
|
7
7
|
return files
|
|
8
|
-
.filter( ( { type } ) =>
|
|
8
|
+
.filter( ( { type } ) =>
|
|
9
|
+
/^image\/(?:jpe?g|png|gif|webp)$/.test( type )
|
|
10
|
+
)
|
|
9
11
|
.map( ( file ) => `<img src="${ createBlobURL( file ) }">` )
|
|
10
12
|
.join( '' );
|
|
11
13
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { insert } from '@wordpress/rich-text';
|
|
5
|
+
|
|
6
|
+
export function preventEventDiscovery( value ) {
|
|
7
|
+
const searchText = 'tales of gutenberg';
|
|
8
|
+
const addText =
|
|
9
|
+
' 🐡🐢🦀🐤🦋🐘🐧🐹🦁🦄🦍🐼🐿🎃🐴🐝🐆🦕🦔🌱🍇π🍌🐉💧🥨🌌🍂🍠🥦🥚🥝🎟🥥🥒🛵🥖🍒🍯🎾🎲🐺🐚🐮⌛️';
|
|
10
|
+
const { start, text } = value;
|
|
11
|
+
|
|
12
|
+
if ( start < searchText.length ) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const charactersBefore = text.slice( start - searchText.length, start );
|
|
17
|
+
|
|
18
|
+
if ( charactersBefore.toLowerCase() !== searchText ) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return insert( value, addText );
|
|
23
|
+
}
|
|
@@ -11,6 +11,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
import { store as blockEditorStore } from '../../store';
|
|
14
|
+
import { preventEventDiscovery } from './prevent-event-discovery';
|
|
14
15
|
|
|
15
16
|
export function useInputRules( props ) {
|
|
16
17
|
const {
|
|
@@ -85,7 +86,7 @@ export function useInputRules( props ) {
|
|
|
85
86
|
|
|
86
87
|
return accumlator;
|
|
87
88
|
},
|
|
88
|
-
value
|
|
89
|
+
preventEventDiscovery( value )
|
|
89
90
|
);
|
|
90
91
|
|
|
91
92
|
if ( transformed !== value ) {
|