@wordpress/block-editor 12.19.2 → 12.19.3
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/build/components/block-tools/insertion-point.js +4 -1
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/global-styles/advanced-panel.js +5 -10
- package/build/components/global-styles/advanced-panel.js.map +1 -1
- package/build/components/global-styles/shadow-panel-components.js +3 -3
- package/build/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build/components/inserter/media-tab/media-preview.js +1 -1
- package/build/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build/components/rich-text/index.js +7 -3
- package/build/components/rich-text/index.js.map +1 -1
- package/build/components/rich-text/use-paste-handler.js +25 -26
- package/build/components/rich-text/use-paste-handler.js.map +1 -1
- package/build/hooks/background.js +4 -2
- package/build/hooks/background.js.map +1 -1
- package/build/private-apis.js +3 -1
- package/build/private-apis.js.map +1 -1
- package/build/store/index.js +0 -2
- package/build/store/index.js.map +1 -1
- package/build/store/private-keys.js +8 -0
- package/build/store/private-keys.js.map +1 -0
- package/build/store/private-selectors.js +6 -9
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +1 -9
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +7 -12
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +7 -2
- package/build/store/utils.js.map +1 -1
- package/build-module/components/block-tools/insertion-point.js +4 -1
- package/build-module/components/block-tools/insertion-point.js.map +1 -1
- package/build-module/components/global-styles/advanced-panel.js +6 -11
- package/build-module/components/global-styles/advanced-panel.js.map +1 -1
- package/build-module/components/global-styles/shadow-panel-components.js +3 -3
- package/build-module/components/global-styles/shadow-panel-components.js.map +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js +1 -1
- package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
- package/build-module/components/rich-text/index.js +7 -3
- package/build-module/components/rich-text/index.js.map +1 -1
- package/build-module/components/rich-text/use-paste-handler.js +25 -26
- package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
- package/build-module/hooks/background.js +4 -2
- package/build-module/hooks/background.js.map +1 -1
- package/build-module/private-apis.js +3 -1
- package/build-module/private-apis.js.map +1 -1
- package/build-module/store/index.js +0 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/private-keys.js +2 -0
- package/build-module/store/private-keys.js.map +1 -0
- package/build-module/store/private-selectors.js +5 -6
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +1 -9
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +8 -13
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +6 -2
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -10
- package/build-style/style.css +0 -10
- package/package.json +3 -3
- package/src/components/block-tools/insertion-point.js +6 -1
- package/src/components/global-styles/advanced-panel.js +6 -12
- package/src/components/global-styles/shadow-panel-components.js +3 -3
- package/src/components/global-styles/style.scss +0 -10
- package/src/components/inserter/media-tab/media-preview.js +6 -1
- package/src/components/rich-text/index.js +12 -5
- package/src/components/rich-text/use-paste-handler.js +26 -25
- package/src/hooks/background.js +5 -2
- package/src/private-apis.js +2 -0
- package/src/store/index.js +0 -2
- package/src/store/private-keys.js +1 -0
- package/src/store/private-selectors.js +4 -7
- package/src/store/reducer.js +0 -10
- package/src/store/selectors.js +7 -15
- package/src/store/utils.js +7 -2
- package/build/store/resolvers.js +0 -27
- package/build/store/resolvers.js.map +0 -1
- package/build-module/store/resolvers.js +0 -20
- package/build-module/store/resolvers.js.map +0 -1
- package/src/store/resolvers.js +0 -17
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
1
5
|
export const checkAllowList = (list, item, defaultResult = null) => {
|
|
2
6
|
if (typeof list === 'boolean') {
|
|
3
7
|
return list;
|
|
@@ -30,7 +34,7 @@ export const checkAllowListRecursive = (blocks, allowedBlockTypes) => {
|
|
|
30
34
|
}
|
|
31
35
|
return true;
|
|
32
36
|
};
|
|
33
|
-
export const getAllPatternsDependants = state => {
|
|
34
|
-
return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings
|
|
37
|
+
export const getAllPatternsDependants = select => state => {
|
|
38
|
+
return [state.settings.__experimentalBlockPatterns, state.settings.__experimentalUserPatternCategories, state.settings.__experimentalReusableBlocks, state.settings[selectBlockPatternsKey]?.(select), state.blockPatterns];
|
|
35
39
|
};
|
|
36
40
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","
|
|
1
|
+
{"version":3,"names":["selectBlockPatternsKey","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","blocks","allowedBlockTypes","blocksQueue","length","block","shift","isAllowed","name","blockName","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalUserPatternCategories","__experimentalReusableBlocks","blockPatterns"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\n\nexport const checkAllowList = ( list, item, defaultResult = null ) => {\n\tif ( typeof list === 'boolean' ) {\n\t\treturn list;\n\t}\n\tif ( Array.isArray( list ) ) {\n\t\t// TODO: when there is a canonical way to detect that we are editing a post\n\t\t// the following check should be changed to something like:\n\t\t// if ( list.includes( 'core/post-content' ) && getEditorMode() === 'post-content' && item === null )\n\t\tif ( list.includes( 'core/post-content' ) && item === null ) {\n\t\t\treturn true;\n\t\t}\n\t\treturn list.includes( item );\n\t}\n\treturn defaultResult;\n};\n\nexport const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {\n\tif ( typeof allowedBlockTypes === 'boolean' ) {\n\t\treturn allowedBlockTypes;\n\t}\n\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\n\t\tconst isAllowed = checkAllowList(\n\t\t\tallowedBlockTypes,\n\t\t\tblock.name || block.blockName,\n\t\t\ttrue\n\t\t);\n\t\tif ( ! isAllowed ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\n\treturn true;\n};\n\nexport const getAllPatternsDependants = ( select ) => ( state ) => {\n\treturn [\n\t\tstate.settings.__experimentalBlockPatterns,\n\t\tstate.settings.__experimentalUserPatternCategories,\n\t\tstate.settings.__experimentalReusableBlocks,\n\t\tstate.settings[ selectBlockPatternsKey ]?.( select ),\n\t\tstate.blockPatterns,\n\t];\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,gBAAgB;AAEvD,OAAO,MAAMC,cAAc,GAAGA,CAAEC,IAAI,EAAEC,IAAI,EAAEC,aAAa,GAAG,IAAI,KAAM;EACrE,IAAK,OAAOF,IAAI,KAAK,SAAS,EAAG;IAChC,OAAOA,IAAI;EACZ;EACA,IAAKG,KAAK,CAACC,OAAO,CAAEJ,IAAK,CAAC,EAAG;IAC5B;IACA;IACA;IACA,IAAKA,IAAI,CAACK,QAAQ,CAAE,mBAAoB,CAAC,IAAIJ,IAAI,KAAK,IAAI,EAAG;MAC5D,OAAO,IAAI;IACZ;IACA,OAAOD,IAAI,CAACK,QAAQ,CAAEJ,IAAK,CAAC;EAC7B;EACA,OAAOC,aAAa;AACrB,CAAC;AAED,OAAO,MAAMI,uBAAuB,GAAGA,CAAEC,MAAM,EAAEC,iBAAiB,KAAM;EACvE,IAAK,OAAOA,iBAAiB,KAAK,SAAS,EAAG;IAC7C,OAAOA,iBAAiB;EACzB;EAEA,MAAMC,WAAW,GAAG,CAAE,GAAGF,MAAM,CAAE;EACjC,OAAQE,WAAW,CAACC,MAAM,GAAG,CAAC,EAAG;IAChC,MAAMC,KAAK,GAAGF,WAAW,CAACG,KAAK,CAAC,CAAC;IAEjC,MAAMC,SAAS,GAAGd,cAAc,CAC/BS,iBAAiB,EACjBG,KAAK,CAACG,IAAI,IAAIH,KAAK,CAACI,SAAS,EAC7B,IACD,CAAC;IACD,IAAK,CAAEF,SAAS,EAAG;MAClB,OAAO,KAAK;IACb;IAEAF,KAAK,CAACK,WAAW,EAAEC,OAAO,CAAIC,UAAU,IAAM;MAC7CT,WAAW,CAACU,IAAI,CAAED,UAAW,CAAC;IAC/B,CAAE,CAAC;EACJ;EAEA,OAAO,IAAI;AACZ,CAAC;AAED,OAAO,MAAME,wBAAwB,GAAKC,MAAM,IAAQC,KAAK,IAAM;EAClE,OAAO,CACNA,KAAK,CAACC,QAAQ,CAACC,2BAA2B,EAC1CF,KAAK,CAACC,QAAQ,CAACE,mCAAmC,EAClDH,KAAK,CAACC,QAAQ,CAACG,4BAA4B,EAC3CJ,KAAK,CAACC,QAAQ,CAAEzB,sBAAsB,CAAE,GAAIuB,MAAO,CAAC,EACpDC,KAAK,CAACK,aAAa,CACnB;AACF,CAAC"}
|
|
@@ -1587,16 +1587,6 @@ iframe[name=editor-canvas].has-editor-padding {
|
|
|
1587
1587
|
direction: ltr;
|
|
1588
1588
|
}
|
|
1589
1589
|
|
|
1590
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
1591
|
-
position: absolute;
|
|
1592
|
-
bottom: 16px;
|
|
1593
|
-
left: 24px;
|
|
1594
|
-
}
|
|
1595
|
-
|
|
1596
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
1597
|
-
fill: #cc1818;
|
|
1598
|
-
}
|
|
1599
|
-
|
|
1600
1590
|
.block-editor-height-control {
|
|
1601
1591
|
border: 0;
|
|
1602
1592
|
margin: 0;
|
package/build-style/style.css
CHANGED
|
@@ -1588,16 +1588,6 @@ iframe[name=editor-canvas].has-editor-padding {
|
|
|
1588
1588
|
direction: ltr;
|
|
1589
1589
|
}
|
|
1590
1590
|
|
|
1591
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
1592
|
-
position: absolute;
|
|
1593
|
-
bottom: 16px;
|
|
1594
|
-
right: 24px;
|
|
1595
|
-
}
|
|
1596
|
-
|
|
1597
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
1598
|
-
fill: #cc1818;
|
|
1599
|
-
}
|
|
1600
|
-
|
|
1601
1591
|
.block-editor-height-control {
|
|
1602
1592
|
border: 0;
|
|
1603
1593
|
margin: 0;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "12.19.
|
|
3
|
+
"version": "12.19.3",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"@wordpress/a11y": "^3.51.1",
|
|
39
39
|
"@wordpress/api-fetch": "^6.48.1",
|
|
40
40
|
"@wordpress/blob": "^3.51.1",
|
|
41
|
-
"@wordpress/blocks": "^12.28.
|
|
41
|
+
"@wordpress/blocks": "^12.28.3",
|
|
42
42
|
"@wordpress/commands": "^0.22.2",
|
|
43
43
|
"@wordpress/components": "^26.0.2",
|
|
44
44
|
"@wordpress/compose": "^6.28.1",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "b12d75c5c5256fda2a0509bb432e20ddd3354d5e"
|
|
91
91
|
}
|
|
@@ -81,11 +81,16 @@ function InbetweenInsertionPointPopover( {
|
|
|
81
81
|
isInserterShown: insertionPoint?.__unstableWithInserter,
|
|
82
82
|
};
|
|
83
83
|
}, [] );
|
|
84
|
+
const { getBlockEditingMode } = useSelect( blockEditorStore );
|
|
84
85
|
|
|
85
86
|
const disableMotion = useReducedMotion();
|
|
86
87
|
|
|
87
88
|
function onClick( event ) {
|
|
88
|
-
if (
|
|
89
|
+
if (
|
|
90
|
+
event.target === ref.current &&
|
|
91
|
+
nextClientId &&
|
|
92
|
+
getBlockEditingMode( nextClientId ) !== 'disabled'
|
|
93
|
+
) {
|
|
89
94
|
selectBlock( nextClientId, -1 );
|
|
90
95
|
}
|
|
91
96
|
}
|
|
@@ -3,12 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import {
|
|
5
5
|
TextareaControl,
|
|
6
|
-
|
|
6
|
+
Notice,
|
|
7
7
|
__experimentalVStack as VStack,
|
|
8
8
|
} from '@wordpress/components';
|
|
9
9
|
import { useState } from '@wordpress/element';
|
|
10
10
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
import { Icon, info } from '@wordpress/icons';
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Internal dependencies
|
|
@@ -58,6 +57,11 @@ export default function AdvancedPanel( {
|
|
|
58
57
|
|
|
59
58
|
return (
|
|
60
59
|
<VStack spacing={ 3 }>
|
|
60
|
+
{ cssError && (
|
|
61
|
+
<Notice status="error" onRemove={ () => setCSSError( null ) }>
|
|
62
|
+
{ cssError }
|
|
63
|
+
</Notice>
|
|
64
|
+
) }
|
|
61
65
|
<TextareaControl
|
|
62
66
|
label={ __( 'Additional CSS' ) }
|
|
63
67
|
__nextHasNoMarginBottom
|
|
@@ -67,16 +71,6 @@ export default function AdvancedPanel( {
|
|
|
67
71
|
className="block-editor-global-styles-advanced-panel__custom-css-input"
|
|
68
72
|
spellCheck={ false }
|
|
69
73
|
/>
|
|
70
|
-
{ cssError && (
|
|
71
|
-
<Tooltip text={ cssError }>
|
|
72
|
-
<div className="block-editor-global-styles-advanced-panel__custom-css-validation-wrapper">
|
|
73
|
-
<Icon
|
|
74
|
-
icon={ info }
|
|
75
|
-
className="block-editor-global-styles-advanced-panel__custom-css-validation-icon"
|
|
76
|
-
/>
|
|
77
|
-
</div>
|
|
78
|
-
</Tooltip>
|
|
79
|
-
) }
|
|
80
74
|
</VStack>
|
|
81
75
|
);
|
|
82
76
|
}
|
|
@@ -19,13 +19,13 @@ import { shadow as shadowIcon, Icon, check } from '@wordpress/icons';
|
|
|
19
19
|
import classNames from 'classnames';
|
|
20
20
|
|
|
21
21
|
export function ShadowPopoverContainer( { shadow, onShadowChange, settings } ) {
|
|
22
|
-
const defaultShadows = settings?.shadow?.presets?.default;
|
|
23
|
-
const themeShadows = settings?.shadow?.presets?.theme;
|
|
22
|
+
const defaultShadows = settings?.shadow?.presets?.default || [];
|
|
23
|
+
const themeShadows = settings?.shadow?.presets?.theme || [];
|
|
24
24
|
const defaultPresetsEnabled = settings?.shadow?.defaultPresets;
|
|
25
25
|
|
|
26
26
|
const shadows = [
|
|
27
27
|
...( defaultPresetsEnabled ? defaultShadows : [] ),
|
|
28
|
-
...
|
|
28
|
+
...themeShadows,
|
|
29
29
|
];
|
|
30
30
|
|
|
31
31
|
return (
|
|
@@ -47,13 +47,3 @@
|
|
|
47
47
|
/*rtl:ignore*/
|
|
48
48
|
direction: ltr;
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-wrapper {
|
|
52
|
-
position: absolute;
|
|
53
|
-
bottom: $grid-unit-20;
|
|
54
|
-
right: $grid-unit * 3;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.block-editor-global-styles-advanced-panel__custom-css-validation-icon {
|
|
58
|
-
fill: $alert-red;
|
|
59
|
-
}
|
|
@@ -195,7 +195,12 @@ export function MediaPreview( { media, onClick, category } ) {
|
|
|
195
195
|
createSuccessNotice,
|
|
196
196
|
]
|
|
197
197
|
);
|
|
198
|
-
|
|
198
|
+
|
|
199
|
+
const title =
|
|
200
|
+
typeof media.title === 'string'
|
|
201
|
+
? media.title
|
|
202
|
+
: media.title?.rendered || __( 'no title' );
|
|
203
|
+
|
|
199
204
|
let truncatedTitle;
|
|
200
205
|
if ( title.length > MAXIMUM_TITLE_LENGTH ) {
|
|
201
206
|
const omission = '...';
|
|
@@ -156,12 +156,19 @@ export function RichTextWrapper(
|
|
|
156
156
|
for ( const [ attribute, args ] of Object.entries(
|
|
157
157
|
blockBindings
|
|
158
158
|
) ) {
|
|
159
|
-
// If any of the attributes with source "rich-text" is part of the bindings,
|
|
160
|
-
// has a source with `lockAttributesEditing`, disable it.
|
|
161
159
|
if (
|
|
162
|
-
blockTypeAttributes?.[ attribute ]?.source
|
|
163
|
-
|
|
164
|
-
|
|
160
|
+
blockTypeAttributes?.[ attribute ]?.source !== 'rich-text'
|
|
161
|
+
) {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// If the source is not defined, or if its value of `lockAttributesEditing` is `true`, disable it.
|
|
166
|
+
const blockBindingsSource = getBlockBindingsSource(
|
|
167
|
+
args.source
|
|
168
|
+
);
|
|
169
|
+
if (
|
|
170
|
+
! blockBindingsSource ||
|
|
171
|
+
blockBindingsSource.lockAttributesEditing
|
|
165
172
|
) {
|
|
166
173
|
shouldDisableEditing = true;
|
|
167
174
|
break;
|
|
@@ -58,13 +58,35 @@ export function usePasteHandler( props ) {
|
|
|
58
58
|
const isInternal =
|
|
59
59
|
event.clipboardData.getData( 'rich-text' ) === 'true';
|
|
60
60
|
|
|
61
|
+
function pasteInline( content ) {
|
|
62
|
+
const transformed = formatTypes.reduce(
|
|
63
|
+
( accumulator, { __unstablePasteRule } ) => {
|
|
64
|
+
// Only allow one transform.
|
|
65
|
+
if ( __unstablePasteRule && accumulator === value ) {
|
|
66
|
+
accumulator = __unstablePasteRule( value, {
|
|
67
|
+
html,
|
|
68
|
+
plainText,
|
|
69
|
+
} );
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return accumulator;
|
|
73
|
+
},
|
|
74
|
+
value
|
|
75
|
+
);
|
|
76
|
+
if ( transformed !== value ) {
|
|
77
|
+
onChange( transformed );
|
|
78
|
+
} else {
|
|
79
|
+
const valueToInsert = create( { html: content } );
|
|
80
|
+
addActiveFormats( valueToInsert, value.activeFormats );
|
|
81
|
+
onChange( insert( value, valueToInsert ) );
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
61
85
|
// If the data comes from a rich text instance, we can directly use it
|
|
62
86
|
// without filtering the data. The filters are only meant for externally
|
|
63
87
|
// pasted content and remove inline styles.
|
|
64
88
|
if ( isInternal ) {
|
|
65
|
-
|
|
66
|
-
addActiveFormats( pastedValue, value.activeFormats );
|
|
67
|
-
onChange( insert( value, pastedValue ) );
|
|
89
|
+
pasteInline( html );
|
|
68
90
|
return;
|
|
69
91
|
}
|
|
70
92
|
|
|
@@ -135,28 +157,7 @@ export function usePasteHandler( props ) {
|
|
|
135
157
|
} );
|
|
136
158
|
|
|
137
159
|
if ( typeof content === 'string' ) {
|
|
138
|
-
|
|
139
|
-
( accumlator, { __unstablePasteRule } ) => {
|
|
140
|
-
// Only allow one transform.
|
|
141
|
-
if ( __unstablePasteRule && accumlator === value ) {
|
|
142
|
-
accumlator = __unstablePasteRule( value, {
|
|
143
|
-
html,
|
|
144
|
-
plainText,
|
|
145
|
-
} );
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
return accumlator;
|
|
149
|
-
},
|
|
150
|
-
value
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
if ( transformed !== value ) {
|
|
154
|
-
onChange( transformed );
|
|
155
|
-
} else {
|
|
156
|
-
const valueToInsert = create( { html: content } );
|
|
157
|
-
addActiveFormats( valueToInsert, value.activeFormats );
|
|
158
|
-
onChange( insert( value, valueToInsert ) );
|
|
159
|
-
}
|
|
160
|
+
pasteInline( content );
|
|
160
161
|
} else if ( content.length > 0 ) {
|
|
161
162
|
if ( onReplace && isEmpty( value ) ) {
|
|
162
163
|
onReplace( content, content.length - 1, -1 );
|
package/src/hooks/background.js
CHANGED
|
@@ -374,11 +374,14 @@ function backgroundSizeHelpText( value ) {
|
|
|
374
374
|
}
|
|
375
375
|
|
|
376
376
|
export const coordsToBackgroundPosition = ( value ) => {
|
|
377
|
-
if ( ! value || isNaN( value.x )
|
|
377
|
+
if ( ! value || ( isNaN( value.x ) && isNaN( value.y ) ) ) {
|
|
378
378
|
return undefined;
|
|
379
379
|
}
|
|
380
380
|
|
|
381
|
-
|
|
381
|
+
const x = isNaN( value.x ) ? 0.5 : value.x;
|
|
382
|
+
const y = isNaN( value.y ) ? 0.5 : value.y;
|
|
383
|
+
|
|
384
|
+
return `${ x * 100 }% ${ y * 100 }%`;
|
|
382
385
|
};
|
|
383
386
|
|
|
384
387
|
export const backgroundPositionToCoords = ( value ) => {
|
package/src/private-apis.js
CHANGED
|
@@ -26,6 +26,7 @@ import { usesContextKey } from './components/rich-text/format-edit';
|
|
|
26
26
|
import { ExperimentalBlockCanvas } from './components/block-canvas';
|
|
27
27
|
import { getDuotoneFilter } from './components/duotone/utils';
|
|
28
28
|
import { useFlashEditableBlocks } from './components/use-flash-editable-blocks';
|
|
29
|
+
import { selectBlockPatternsKey } from './store/private-keys';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Private @wordpress/block-editor APIs.
|
|
@@ -56,4 +57,5 @@ lock( privateApis, {
|
|
|
56
57
|
useReusableBlocksRenameHint,
|
|
57
58
|
usesContextKey,
|
|
58
59
|
useFlashEditableBlocks,
|
|
60
|
+
selectBlockPatternsKey,
|
|
59
61
|
} );
|
package/src/store/index.js
CHANGED
|
@@ -10,7 +10,6 @@ import reducer from './reducer';
|
|
|
10
10
|
import * as selectors from './selectors';
|
|
11
11
|
import * as privateActions from './private-actions';
|
|
12
12
|
import * as privateSelectors from './private-selectors';
|
|
13
|
-
import * as resolvers from './resolvers';
|
|
14
13
|
import * as actions from './actions';
|
|
15
14
|
import { STORE_NAME } from './constants';
|
|
16
15
|
import { unlock } from '../lock-unlock';
|
|
@@ -23,7 +22,6 @@ import { unlock } from '../lock-unlock';
|
|
|
23
22
|
export const storeConfig = {
|
|
24
23
|
reducer,
|
|
25
24
|
selectors,
|
|
26
|
-
resolvers,
|
|
27
25
|
actions,
|
|
28
26
|
};
|
|
29
27
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const selectBlockPatternsKey = Symbol( 'selectBlockPatternsKey' );
|
|
@@ -22,6 +22,7 @@ import { checkAllowListRecursive, getAllPatternsDependants } from './utils';
|
|
|
22
22
|
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
23
23
|
import { STORE_NAME } from './constants';
|
|
24
24
|
import { unlock } from '../lock-unlock';
|
|
25
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
25
26
|
|
|
26
27
|
export { getBlockSettings } from './get-block-settings';
|
|
27
28
|
|
|
@@ -250,10 +251,6 @@ export const getInserterMediaCategories = createSelector(
|
|
|
250
251
|
]
|
|
251
252
|
);
|
|
252
253
|
|
|
253
|
-
export function getFetchedPatterns( state ) {
|
|
254
|
-
return state.blockPatterns;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
254
|
/**
|
|
258
255
|
* Returns whether there is at least one allowed pattern for inner blocks children.
|
|
259
256
|
* This is useful for deferring the parsing of all patterns until needed.
|
|
@@ -285,7 +282,7 @@ export const hasAllowedPatterns = createRegistrySelector( ( select ) =>
|
|
|
285
282
|
} );
|
|
286
283
|
},
|
|
287
284
|
( state, rootClientId ) => [
|
|
288
|
-
getAllPatternsDependants( state ),
|
|
285
|
+
getAllPatternsDependants( select )( state ),
|
|
289
286
|
state.settings.allowedBlockTypes,
|
|
290
287
|
state.settings.templateLock,
|
|
291
288
|
state.blockListSettings[ rootClientId ],
|
|
@@ -325,12 +322,12 @@ export const getAllPatterns = createRegistrySelector( ( select ) =>
|
|
|
325
322
|
return [
|
|
326
323
|
...userPatterns,
|
|
327
324
|
...__experimentalBlockPatterns,
|
|
328
|
-
...
|
|
325
|
+
...( state.settings[ selectBlockPatternsKey ]?.( select ) ?? [] ),
|
|
329
326
|
].filter(
|
|
330
327
|
( x, index, arr ) =>
|
|
331
328
|
index === arr.findIndex( ( y ) => x.name === y.name )
|
|
332
329
|
);
|
|
333
|
-
}, getAllPatternsDependants )
|
|
330
|
+
}, getAllPatternsDependants( select ) )
|
|
334
331
|
);
|
|
335
332
|
|
|
336
333
|
/**
|
package/src/store/reducer.js
CHANGED
|
@@ -2064,15 +2064,6 @@ function blockBindingsSources( state = {}, action ) {
|
|
|
2064
2064
|
return state;
|
|
2065
2065
|
}
|
|
2066
2066
|
|
|
2067
|
-
function blockPatterns( state = [], action ) {
|
|
2068
|
-
switch ( action.type ) {
|
|
2069
|
-
case 'RECEIVE_BLOCK_PATTERNS':
|
|
2070
|
-
return action.patterns;
|
|
2071
|
-
}
|
|
2072
|
-
|
|
2073
|
-
return state;
|
|
2074
|
-
}
|
|
2075
|
-
|
|
2076
2067
|
const combinedReducers = combineReducers( {
|
|
2077
2068
|
blocks,
|
|
2078
2069
|
isDragging,
|
|
@@ -2105,7 +2096,6 @@ const combinedReducers = combineReducers( {
|
|
|
2105
2096
|
openedBlockSettingsMenu,
|
|
2106
2097
|
registeredInserterMediaCategories,
|
|
2107
2098
|
blockBindingsSources,
|
|
2108
|
-
blockPatterns,
|
|
2109
2099
|
} );
|
|
2110
2100
|
|
|
2111
2101
|
function withAutomaticChangeReset( reducer ) {
|
package/src/store/selectors.js
CHANGED
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
getBlockType,
|
|
11
11
|
getBlockTypes,
|
|
12
12
|
getBlockVariations,
|
|
13
|
-
getHookedBlocks,
|
|
14
13
|
hasBlockSupport,
|
|
15
14
|
getPossibleBlockTransformations,
|
|
16
15
|
parse,
|
|
@@ -1937,16 +1936,9 @@ const buildBlockTypeItem =
|
|
|
1937
1936
|
blockType.name,
|
|
1938
1937
|
'inserter'
|
|
1939
1938
|
);
|
|
1940
|
-
|
|
1941
|
-
const ignoredHookedBlocks = [
|
|
1942
|
-
...new Set( Object.values( getHookedBlocks( id ) ).flat() ),
|
|
1943
|
-
];
|
|
1944
|
-
|
|
1945
1939
|
return {
|
|
1946
1940
|
...blockItemBase,
|
|
1947
|
-
initialAttributes:
|
|
1948
|
-
? { metadata: { ignoredHookedBlocks } }
|
|
1949
|
-
: {},
|
|
1941
|
+
initialAttributes: {},
|
|
1950
1942
|
description: blockType.description,
|
|
1951
1943
|
category: blockType.category,
|
|
1952
1944
|
keywords: blockType.keywords,
|
|
@@ -2307,12 +2299,12 @@ export const __experimentalGetParsedPattern = createRegistrySelector(
|
|
|
2307
2299
|
__unstableSkipMigrationLogs: true,
|
|
2308
2300
|
} ),
|
|
2309
2301
|
};
|
|
2310
|
-
}, getAllPatternsDependants )
|
|
2302
|
+
}, getAllPatternsDependants( select ) )
|
|
2311
2303
|
);
|
|
2312
2304
|
|
|
2313
|
-
const getAllowedPatternsDependants = ( state, rootClientId ) => {
|
|
2305
|
+
const getAllowedPatternsDependants = ( select ) => ( state, rootClientId ) => {
|
|
2314
2306
|
return [
|
|
2315
|
-
...getAllPatternsDependants( state ),
|
|
2307
|
+
...getAllPatternsDependants( select )( state ),
|
|
2316
2308
|
state.settings.allowedBlockTypes,
|
|
2317
2309
|
state.settings.templateLock,
|
|
2318
2310
|
state.blockListSettings[ rootClientId ],
|
|
@@ -2353,7 +2345,7 @@ export const __experimentalGetAllowedPatterns = createRegistrySelector(
|
|
|
2353
2345
|
);
|
|
2354
2346
|
|
|
2355
2347
|
return patternsAllowed;
|
|
2356
|
-
}, getAllowedPatternsDependants );
|
|
2348
|
+
}, getAllowedPatternsDependants( select ) );
|
|
2357
2349
|
}
|
|
2358
2350
|
);
|
|
2359
2351
|
|
|
@@ -2392,7 +2384,7 @@ export const getPatternsByBlockTypes = createRegistrySelector( ( select ) =>
|
|
|
2392
2384
|
return filteredPatterns;
|
|
2393
2385
|
},
|
|
2394
2386
|
( state, blockNames, rootClientId ) =>
|
|
2395
|
-
getAllowedPatternsDependants( state, rootClientId )
|
|
2387
|
+
getAllowedPatternsDependants( select )( state, rootClientId )
|
|
2396
2388
|
)
|
|
2397
2389
|
);
|
|
2398
2390
|
|
|
@@ -2466,7 +2458,7 @@ export const __experimentalGetPatternTransformItems = createRegistrySelector(
|
|
|
2466
2458
|
);
|
|
2467
2459
|
},
|
|
2468
2460
|
( state, blocks, rootClientId ) =>
|
|
2469
|
-
getAllowedPatternsDependants( state, rootClientId )
|
|
2461
|
+
getAllowedPatternsDependants( select )( state, rootClientId )
|
|
2470
2462
|
)
|
|
2471
2463
|
);
|
|
2472
2464
|
|
package/src/store/utils.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { selectBlockPatternsKey } from './private-keys';
|
|
5
|
+
|
|
1
6
|
export const checkAllowList = ( list, item, defaultResult = null ) => {
|
|
2
7
|
if ( typeof list === 'boolean' ) {
|
|
3
8
|
return list;
|
|
@@ -40,12 +45,12 @@ export const checkAllowListRecursive = ( blocks, allowedBlockTypes ) => {
|
|
|
40
45
|
return true;
|
|
41
46
|
};
|
|
42
47
|
|
|
43
|
-
export const getAllPatternsDependants = ( state ) => {
|
|
48
|
+
export const getAllPatternsDependants = ( select ) => ( state ) => {
|
|
44
49
|
return [
|
|
45
50
|
state.settings.__experimentalBlockPatterns,
|
|
46
51
|
state.settings.__experimentalUserPatternCategories,
|
|
47
52
|
state.settings.__experimentalReusableBlocks,
|
|
48
|
-
state.settings
|
|
53
|
+
state.settings[ selectBlockPatternsKey ]?.( select ),
|
|
49
54
|
state.blockPatterns,
|
|
50
55
|
];
|
|
51
56
|
};
|
package/build/store/resolvers.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getFetchedPatterns = void 0;
|
|
7
|
-
const getFetchedPatterns = () => async ({
|
|
8
|
-
dispatch,
|
|
9
|
-
select
|
|
10
|
-
}) => {
|
|
11
|
-
const {
|
|
12
|
-
__experimentalFetchBlockPatterns
|
|
13
|
-
} = select.getSettings();
|
|
14
|
-
if (!__experimentalFetchBlockPatterns) {
|
|
15
|
-
return [];
|
|
16
|
-
}
|
|
17
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
18
|
-
dispatch({
|
|
19
|
-
type: 'RECEIVE_BLOCK_PATTERNS',
|
|
20
|
-
patterns
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
exports.getFetchedPatterns = getFetchedPatterns;
|
|
24
|
-
getFetchedPatterns.shouldInvalidate = action => {
|
|
25
|
-
return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","exports","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":";;;;;;AAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAACE,OAAA,CAAAP,kBAAA,GAAAA,kBAAA;AAEHA,kBAAkB,CAACQ,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACH,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEG,MAAM,CAACC,QAAQ,CAACP,gCAAgC;AAErD,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const getFetchedPatterns = () => async ({
|
|
2
|
-
dispatch,
|
|
3
|
-
select
|
|
4
|
-
}) => {
|
|
5
|
-
const {
|
|
6
|
-
__experimentalFetchBlockPatterns
|
|
7
|
-
} = select.getSettings();
|
|
8
|
-
if (!__experimentalFetchBlockPatterns) {
|
|
9
|
-
return [];
|
|
10
|
-
}
|
|
11
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
12
|
-
dispatch({
|
|
13
|
-
type: 'RECEIVE_BLOCK_PATTERNS',
|
|
14
|
-
patterns
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
getFetchedPatterns.shouldInvalidate = action => {
|
|
18
|
-
return action.type === 'UPDATE_SETTINGS' && !!action.settings.__experimentalFetchBlockPatterns;
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=resolvers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["getFetchedPatterns","dispatch","select","__experimentalFetchBlockPatterns","getSettings","patterns","type","shouldInvalidate","action","settings"],"sources":["@wordpress/block-editor/src/store/resolvers.js"],"sourcesContent":["export const getFetchedPatterns =\n\t() =>\n\tasync ( { dispatch, select } ) => {\n\t\tconst { __experimentalFetchBlockPatterns } = select.getSettings();\n\t\tif ( ! __experimentalFetchBlockPatterns ) {\n\t\t\treturn [];\n\t\t}\n\t\tconst patterns = await __experimentalFetchBlockPatterns();\n\t\tdispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );\n\t};\n\ngetFetchedPatterns.shouldInvalidate = ( action ) => {\n\treturn (\n\t\taction.type === 'UPDATE_SETTINGS' &&\n\t\t!! action.settings.__experimentalFetchBlockPatterns\n\t);\n};\n"],"mappings":"AAAA,OAAO,MAAMA,kBAAkB,GAC9BA,CAAA,KACA,OAAQ;EAAEC,QAAQ;EAAEC;AAAO,CAAC,KAAM;EACjC,MAAM;IAAEC;EAAiC,CAAC,GAAGD,MAAM,CAACE,WAAW,CAAC,CAAC;EACjE,IAAK,CAAED,gCAAgC,EAAG;IACzC,OAAO,EAAE;EACV;EACA,MAAME,QAAQ,GAAG,MAAMF,gCAAgC,CAAC,CAAC;EACzDF,QAAQ,CAAE;IAAEK,IAAI,EAAE,wBAAwB;IAAED;EAAS,CAAE,CAAC;AACzD,CAAC;AAEFL,kBAAkB,CAACO,gBAAgB,GAAKC,MAAM,IAAM;EACnD,OACCA,MAAM,CAACF,IAAI,KAAK,iBAAiB,IACjC,CAAC,CAAEE,MAAM,CAACC,QAAQ,CAACN,gCAAgC;AAErD,CAAC"}
|
package/src/store/resolvers.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export const getFetchedPatterns =
|
|
2
|
-
() =>
|
|
3
|
-
async ( { dispatch, select } ) => {
|
|
4
|
-
const { __experimentalFetchBlockPatterns } = select.getSettings();
|
|
5
|
-
if ( ! __experimentalFetchBlockPatterns ) {
|
|
6
|
-
return [];
|
|
7
|
-
}
|
|
8
|
-
const patterns = await __experimentalFetchBlockPatterns();
|
|
9
|
-
dispatch( { type: 'RECEIVE_BLOCK_PATTERNS', patterns } );
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
getFetchedPatterns.shouldInvalidate = ( action ) => {
|
|
13
|
-
return (
|
|
14
|
-
action.type === 'UPDATE_SETTINGS' &&
|
|
15
|
-
!! action.settings.__experimentalFetchBlockPatterns
|
|
16
|
-
);
|
|
17
|
-
};
|