@wordpress/block-editor 15.3.0 → 15.3.1-next.6f42e1382.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/build/autocompleters/block.js +2 -4
- package/build/autocompleters/block.js.map +1 -1
- package/build/components/block-list/index.js +3 -1
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-popover/use-popover-scroll.js +11 -2
- package/build/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build/components/block-switcher/index.js +10 -5
- package/build/components/block-switcher/index.js.map +1 -1
- package/build/components/block-toolbar/index.js +5 -2
- package/build/components/block-toolbar/index.js.map +1 -1
- package/build/components/block-tools/insertion-point.js +10 -0
- package/build/components/block-tools/insertion-point.js.map +1 -1
- package/build/components/block-tools/use-show-block-tools.js +1 -1
- package/build/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build/components/block-variation-transforms/index.js +9 -5
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build/components/inserter/index.js +1 -3
- package/build/components/inserter/index.js.map +1 -1
- package/build/components/link-control/search-item.js +30 -12
- package/build/components/link-control/search-item.js.map +1 -1
- package/build/components/list-view/appender.js +13 -3
- package/build/components/list-view/appender.js.map +1 -1
- package/build/store/private-selectors.js +7 -20
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +60 -0
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +16 -30
- package/build/store/selectors.js.map +1 -1
- package/build/store/utils.js +18 -0
- package/build/store/utils.js.map +1 -1
- package/build-module/autocompleters/block.js +3 -5
- package/build-module/autocompleters/block.js.map +1 -1
- package/build-module/components/block-list/index.js +3 -1
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-popover/use-popover-scroll.js +11 -2
- package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
- package/build-module/components/block-switcher/index.js +10 -5
- package/build-module/components/block-switcher/index.js.map +1 -1
- package/build-module/components/block-toolbar/index.js +5 -2
- package/build-module/components/block-toolbar/index.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/block-tools/use-show-block-tools.js +1 -1
- package/build-module/components/block-tools/use-show-block-tools.js.map +1 -1
- package/build-module/components/block-variation-transforms/index.js +9 -5
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js +1 -1
- package/build-module/components/inserter/hooks/use-insertion-point.js.map +1 -1
- package/build-module/components/inserter/index.js +1 -3
- package/build-module/components/inserter/index.js.map +1 -1
- package/build-module/components/link-control/search-item.js +30 -12
- package/build-module/components/link-control/search-item.js.map +1 -1
- package/build-module/components/list-view/appender.js +13 -3
- package/build-module/components/list-view/appender.js.map +1 -1
- package/build-module/store/private-selectors.js +7 -20
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +60 -0
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js +16 -30
- package/build-module/store/selectors.js.map +1 -1
- package/build-module/store/utils.js +17 -0
- package/build-module/store/utils.js.map +1 -1
- package/build-style/style-rtl.css +0 -1
- package/build-style/style.css +0 -1
- package/package.json +34 -34
- package/src/autocompleters/block.js +6 -11
- package/src/components/block-list/index.js +7 -1
- package/src/components/block-popover/use-popover-scroll.js +10 -2
- package/src/components/block-switcher/index.js +8 -1
- package/src/components/block-toolbar/index.js +11 -5
- package/src/components/block-tools/insertion-point.js +19 -1
- package/src/components/block-tools/use-show-block-tools.js +1 -1
- package/src/components/block-variation-transforms/index.js +38 -27
- package/src/components/inserter/hooks/use-insertion-point.js +1 -1
- package/src/components/inserter/index.js +1 -3
- package/src/components/link-control/search-item.js +31 -12
- package/src/components/link-control/style.scss +0 -1
- package/src/components/link-control/test/index.js +14 -2
- package/src/components/list-view/appender.js +13 -6
- package/src/store/private-selectors.js +10 -23
- package/src/store/reducer.js +105 -0
- package/src/store/selectors.js +38 -59
- package/src/store/test/reducer.js +107 -0
- package/src/store/test/selectors.js +65 -192
- package/src/store/utils.js +21 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -11,9 +11,26 @@ import { selectBlockPatternsKey } from './private-keys';
|
|
|
11
11
|
import { unlock } from '../lock-unlock';
|
|
12
12
|
import { STORE_NAME } from './constants';
|
|
13
13
|
import { getSectionRootClientId } from './private-selectors';
|
|
14
|
+
import { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';
|
|
14
15
|
export const isFiltered = Symbol('isFiltered');
|
|
15
16
|
const parsedPatternCache = new WeakMap();
|
|
16
17
|
const grammarMapCache = new WeakMap();
|
|
18
|
+
export function mapUserPattern(userPattern, __experimentalUserPatternCategories = []) {
|
|
19
|
+
return {
|
|
20
|
+
name: `core/block/${userPattern.id}`,
|
|
21
|
+
id: userPattern.id,
|
|
22
|
+
type: INSERTER_PATTERN_TYPES.user,
|
|
23
|
+
title: userPattern.title?.raw,
|
|
24
|
+
categories: userPattern.wp_pattern_category?.map(catId => {
|
|
25
|
+
const category = __experimentalUserPatternCategories.find(({
|
|
26
|
+
id
|
|
27
|
+
}) => id === catId);
|
|
28
|
+
return category ? category.slug : catId;
|
|
29
|
+
}),
|
|
30
|
+
content: userPattern.content?.raw,
|
|
31
|
+
syncStatus: userPattern.wp_pattern_sync_status
|
|
32
|
+
};
|
|
33
|
+
}
|
|
17
34
|
function parsePattern(pattern) {
|
|
18
35
|
const blocks = parse(pattern.content, {
|
|
19
36
|
__unstableSkipMigrationLogs: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["parse","grammarParse","selectBlockPatternsKey","unlock","STORE_NAME","getSectionRootClientId","isFiltered","Symbol","parsedPatternCache","WeakMap","grammarMapCache","
|
|
1
|
+
{"version":3,"names":["parse","grammarParse","selectBlockPatternsKey","unlock","STORE_NAME","getSectionRootClientId","INSERTER_PATTERN_TYPES","isFiltered","Symbol","parsedPatternCache","WeakMap","grammarMapCache","mapUserPattern","userPattern","__experimentalUserPatternCategories","name","id","type","user","title","raw","categories","wp_pattern_category","map","catId","category","find","slug","content","syncStatus","wp_pattern_sync_status","parsePattern","pattern","blocks","__unstableSkipMigrationLogs","length","attributes","metadata","patternName","getParsedPattern","parsedPattern","get","set","getGrammar","grammarMap","filter","block","blockName","checkAllowList","list","item","defaultResult","Array","isArray","includes","checkAllowListRecursive","allowedBlockTypes","blocksQueue","shift","isAllowed","innerBlocks","forEach","innerBlock","push","getAllPatternsDependants","select","state","settings","__experimentalBlockPatterns","__experimentalReusableBlocks","blockPatterns","getReusableBlocks","getInsertBlockTypeDependants","rootClientId","blockListSettings","byClientId","templateLock","blockEditingModes","__unstableGetEditorMode"],"sources":["@wordpress/block-editor/src/store/utils.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { parse } from '@wordpress/blocks';\nimport { parse as grammarParse } from '@wordpress/block-serialization-default-parser';\n\n/**\n * Internal dependencies\n */\nimport { selectBlockPatternsKey } from './private-keys';\nimport { unlock } from '../lock-unlock';\nimport { STORE_NAME } from './constants';\nimport { getSectionRootClientId } from './private-selectors';\nimport { INSERTER_PATTERN_TYPES } from '../components/inserter/block-patterns-tab/utils';\n\nexport const isFiltered = Symbol( 'isFiltered' );\nconst parsedPatternCache = new WeakMap();\nconst grammarMapCache = new WeakMap();\n\nexport function mapUserPattern(\n\tuserPattern,\n\t__experimentalUserPatternCategories = []\n) {\n\treturn {\n\t\tname: `core/block/${ userPattern.id }`,\n\t\tid: userPattern.id,\n\t\ttype: INSERTER_PATTERN_TYPES.user,\n\t\ttitle: userPattern.title?.raw,\n\t\tcategories: userPattern.wp_pattern_category?.map( ( catId ) => {\n\t\t\tconst category = __experimentalUserPatternCategories.find(\n\t\t\t\t( { id } ) => id === catId\n\t\t\t);\n\t\t\treturn category ? category.slug : catId;\n\t\t} ),\n\t\tcontent: userPattern.content?.raw,\n\t\tsyncStatus: userPattern.wp_pattern_sync_status,\n\t};\n}\n\nfunction parsePattern( pattern ) {\n\tconst blocks = parse( pattern.content, {\n\t\t__unstableSkipMigrationLogs: true,\n\t} );\n\tif ( blocks.length === 1 ) {\n\t\tblocks[ 0 ].attributes = {\n\t\t\t...blocks[ 0 ].attributes,\n\t\t\tmetadata: {\n\t\t\t\t...( blocks[ 0 ].attributes.metadata || {} ),\n\t\t\t\tcategories: pattern.categories,\n\t\t\t\tpatternName: pattern.name,\n\t\t\t\tname: blocks[ 0 ].attributes.metadata?.name || pattern.title,\n\t\t\t},\n\t\t};\n\t}\n\treturn {\n\t\t...pattern,\n\t\tblocks,\n\t};\n}\n\nexport function getParsedPattern( pattern ) {\n\tlet parsedPattern = parsedPatternCache.get( pattern );\n\tif ( ! parsedPattern ) {\n\t\tparsedPattern = parsePattern( pattern );\n\t\tparsedPatternCache.set( pattern, parsedPattern );\n\t}\n\treturn parsedPattern;\n}\n\nexport function getGrammar( pattern ) {\n\tlet grammarMap = grammarMapCache.get( pattern );\n\tif ( ! grammarMap ) {\n\t\tgrammarMap = grammarParse( pattern.content );\n\t\t// Block names are null only at the top level for whitespace.\n\t\tgrammarMap = grammarMap.filter( ( block ) => block.blockName !== null );\n\t\tgrammarMapCache.set( pattern, grammarMap );\n\t}\n\treturn grammarMap;\n}\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\tunlock( select( STORE_NAME ) ).getReusableBlocks(),\n\t];\n};\n\nexport const getInsertBlockTypeDependants =\n\t( select ) => ( state, rootClientId ) => {\n\t\treturn [\n\t\t\tstate.blockListSettings[ rootClientId ],\n\t\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\t\tstate.settings.allowedBlockTypes,\n\t\t\tstate.settings.templateLock,\n\t\t\tstate.blockEditingModes,\n\t\t\tselect( STORE_NAME ).__unstableGetEditorMode( state ),\n\t\t\tgetSectionRootClientId( state ),\n\t\t];\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,QAAQ,mBAAmB;AACzC,SAASA,KAAK,IAAIC,YAAY,QAAQ,+CAA+C;;AAErF;AACA;AACA;AACA,SAASC,sBAAsB,QAAQ,gBAAgB;AACvD,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,sBAAsB,QAAQ,qBAAqB;AAC5D,SAASC,sBAAsB,QAAQ,iDAAiD;AAExF,OAAO,MAAMC,UAAU,GAAGC,MAAM,CAAE,YAAa,CAAC;AAChD,MAAMC,kBAAkB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0C,UAAU,CAAClC,GAAG,CAAEgC,YAAa,CAAC,EAC3CP,KAAK,CAACC,QAAQ,CAACX,iBAAiB,EAChCU,KAAK,CAACC,QAAQ,CAACS,YAAY,EAC3BV,KAAK,CAACW,iBAAiB,EACvBZ,MAAM,CAAE7D,UAAW,CAAC,CAAC0E,uBAAuB,CAAEZ,KAAM,CAAC,EACrD7D,sBAAsB,CAAE6D,KAAM,CAAC,CAC/B;AACF,CAAC","ignoreList":[]}
|
|
@@ -2434,7 +2434,6 @@ iframe[name=editor-canvas] {
|
|
|
2434
2434
|
}
|
|
2435
2435
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2436
2436
|
color: #757575;
|
|
2437
|
-
text-transform: capitalize;
|
|
2438
2437
|
white-space: nowrap;
|
|
2439
2438
|
}
|
|
2440
2439
|
.block-editor-link-control__search-item[aria-selected] {
|
package/build-style/style.css
CHANGED
|
@@ -2435,7 +2435,6 @@ iframe[name=editor-canvas] {
|
|
|
2435
2435
|
}
|
|
2436
2436
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2437
2437
|
color: #757575;
|
|
2438
|
-
text-transform: capitalize;
|
|
2439
2438
|
white-space: nowrap;
|
|
2440
2439
|
}
|
|
2441
2440
|
.block-editor-link-control__search-item[aria-selected] {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.3.0",
|
|
3
|
+
"version": "15.3.1-next.6f42e1382.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -37,38 +37,38 @@
|
|
|
37
37
|
"@emotion/react": "^11.7.1",
|
|
38
38
|
"@emotion/styled": "^11.6.0",
|
|
39
39
|
"@react-spring/web": "^9.4.5",
|
|
40
|
-
"@wordpress/a11y": "^4.30.0",
|
|
41
|
-
"@wordpress/api-fetch": "^7.30.0",
|
|
42
|
-
"@wordpress/blob": "^4.30.0",
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.30.0",
|
|
44
|
-
"@wordpress/blocks": "^15.3.0",
|
|
45
|
-
"@wordpress/commands": "^1.30.0",
|
|
46
|
-
"@wordpress/components": "^30.3.0",
|
|
47
|
-
"@wordpress/compose": "^7.30.0",
|
|
48
|
-
"@wordpress/data": "^10.30.0",
|
|
49
|
-
"@wordpress/date": "^5.30.0",
|
|
50
|
-
"@wordpress/deprecated": "^4.30.0",
|
|
51
|
-
"@wordpress/dom": "^4.30.0",
|
|
52
|
-
"@wordpress/element": "^6.30.0",
|
|
53
|
-
"@wordpress/escape-html": "^3.30.0",
|
|
54
|
-
"@wordpress/hooks": "^4.30.0",
|
|
55
|
-
"@wordpress/html-entities": "^4.30.0",
|
|
56
|
-
"@wordpress/i18n": "^6.3.0",
|
|
57
|
-
"@wordpress/icons": "^10.30.0",
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.30.0",
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.30.0",
|
|
60
|
-
"@wordpress/keycodes": "^4.30.0",
|
|
61
|
-
"@wordpress/notices": "^5.30.0",
|
|
62
|
-
"@wordpress/preferences": "^4.30.0",
|
|
63
|
-
"@wordpress/priority-queue": "^3.30.0",
|
|
64
|
-
"@wordpress/private-apis": "^1.30.0",
|
|
65
|
-
"@wordpress/rich-text": "^7.30.0",
|
|
66
|
-
"@wordpress/style-engine": "^2.30.0",
|
|
67
|
-
"@wordpress/token-list": "^3.30.0",
|
|
68
|
-
"@wordpress/upload-media": "^0.15.0",
|
|
69
|
-
"@wordpress/url": "^4.30.0",
|
|
70
|
-
"@wordpress/warning": "^3.30.0",
|
|
71
|
-
"@wordpress/wordcount": "^4.30.0",
|
|
40
|
+
"@wordpress/a11y": "^4.30.1-next.6f42e1382.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.30.1-next.6f42e1382.0",
|
|
42
|
+
"@wordpress/blob": "^4.30.1-next.6f42e1382.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.30.1-next.6f42e1382.0",
|
|
44
|
+
"@wordpress/blocks": "^15.3.1-next.6f42e1382.0",
|
|
45
|
+
"@wordpress/commands": "^1.30.1-next.6f42e1382.0",
|
|
46
|
+
"@wordpress/components": "^30.3.2-next.6f42e1382.0",
|
|
47
|
+
"@wordpress/compose": "^7.30.1-next.6f42e1382.0",
|
|
48
|
+
"@wordpress/data": "^10.30.1-next.6f42e1382.0",
|
|
49
|
+
"@wordpress/date": "^5.30.1-next.6f42e1382.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.30.1-next.6f42e1382.0",
|
|
51
|
+
"@wordpress/dom": "^4.30.1-next.6f42e1382.0",
|
|
52
|
+
"@wordpress/element": "^6.30.1-next.6f42e1382.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.30.1-next.6f42e1382.0",
|
|
54
|
+
"@wordpress/hooks": "^4.30.1-next.6f42e1382.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.30.1-next.6f42e1382.0",
|
|
56
|
+
"@wordpress/i18n": "^6.3.1-next.6f42e1382.0",
|
|
57
|
+
"@wordpress/icons": "^10.30.1-next.6f42e1382.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.30.1-next.6f42e1382.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.30.1-next.6f42e1382.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.30.1-next.6f42e1382.0",
|
|
61
|
+
"@wordpress/notices": "^5.30.1-next.6f42e1382.0",
|
|
62
|
+
"@wordpress/preferences": "^4.30.1-next.6f42e1382.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.30.1-next.6f42e1382.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.30.1-next.6f42e1382.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.30.1-next.6f42e1382.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.30.1-next.6f42e1382.0",
|
|
67
|
+
"@wordpress/token-list": "^3.30.1-next.6f42e1382.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.15.1-next.6f42e1382.0",
|
|
69
|
+
"@wordpress/url": "^4.30.1-next.6f42e1382.0",
|
|
70
|
+
"@wordpress/warning": "^3.30.1-next.6f42e1382.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.30.1-next.6f42e1382.0",
|
|
72
72
|
"change-case": "^4.1.2",
|
|
73
73
|
"clsx": "^2.1.1",
|
|
74
74
|
"colord": "^2.7.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "8806899f598577a3c90a55d9aa79fbc372fe1e75"
|
|
95
95
|
}
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useSelect } from '@wordpress/data';
|
|
5
5
|
import {
|
|
6
|
+
cloneBlock,
|
|
6
7
|
createBlock,
|
|
7
8
|
createBlocksFromInnerBlocksTemplate,
|
|
8
|
-
parse,
|
|
9
9
|
store as blocksStore,
|
|
10
10
|
} from '@wordpress/blocks';
|
|
11
11
|
import { useMemo } from '@wordpress/element';
|
|
@@ -125,21 +125,16 @@ function createBlockCompleter() {
|
|
|
125
125
|
return ! ( /\S/.test( before ) || /\S/.test( after ) );
|
|
126
126
|
},
|
|
127
127
|
getOptionCompletion( inserterItem ) {
|
|
128
|
-
const {
|
|
129
|
-
|
|
130
|
-
initialAttributes,
|
|
131
|
-
innerBlocks,
|
|
132
|
-
syncStatus,
|
|
133
|
-
content,
|
|
134
|
-
} = inserterItem;
|
|
128
|
+
const { name, initialAttributes, innerBlocks, syncStatus, blocks } =
|
|
129
|
+
inserterItem;
|
|
135
130
|
|
|
136
131
|
return {
|
|
137
132
|
action: 'replace',
|
|
138
133
|
value:
|
|
139
134
|
syncStatus === 'unsynced'
|
|
140
|
-
?
|
|
141
|
-
|
|
142
|
-
|
|
135
|
+
? ( blocks ?? [] ).map( ( block ) =>
|
|
136
|
+
cloneBlock( block )
|
|
137
|
+
)
|
|
143
138
|
: createBlock(
|
|
144
139
|
name,
|
|
145
140
|
initialAttributes,
|
|
@@ -179,6 +179,8 @@ function Items( {
|
|
|
179
179
|
getTemplateLock,
|
|
180
180
|
getBlockEditingMode,
|
|
181
181
|
isSectionBlock,
|
|
182
|
+
isContainerInsertableToInWriteMode,
|
|
183
|
+
getBlockName,
|
|
182
184
|
isZoomOut: _isZoomOut,
|
|
183
185
|
canInsertBlockType,
|
|
184
186
|
} = unlock( select( blockEditorStore ) );
|
|
@@ -215,7 +217,11 @@ function Items( {
|
|
|
215
217
|
visibleBlocks: __unstableGetVisibleBlocks(),
|
|
216
218
|
isZoomOut: _isZoomOut(),
|
|
217
219
|
shouldRenderAppender:
|
|
218
|
-
! isSectionBlock( rootClientId )
|
|
220
|
+
( ! isSectionBlock( rootClientId ) ||
|
|
221
|
+
isContainerInsertableToInWriteMode(
|
|
222
|
+
getBlockName( selectedBlockClientId ),
|
|
223
|
+
rootClientId
|
|
224
|
+
) ) &&
|
|
219
225
|
getBlockEditingMode( rootClientId ) !== 'disabled' &&
|
|
220
226
|
! getTemplateLock( rootClientId ) &&
|
|
221
227
|
hasAppender &&
|
|
@@ -17,14 +17,22 @@ function usePopoverScroll( contentRef ) {
|
|
|
17
17
|
const effect = useRefEffect(
|
|
18
18
|
( node ) => {
|
|
19
19
|
function onWheel( event ) {
|
|
20
|
-
const { deltaX, deltaY } = event;
|
|
20
|
+
const { deltaX, deltaY, target } = event;
|
|
21
21
|
const contentEl = contentRef.current;
|
|
22
22
|
let scrollContainer = scrollContainerCache.get( contentEl );
|
|
23
23
|
if ( ! scrollContainer ) {
|
|
24
24
|
scrollContainer = getScrollContainer( contentEl );
|
|
25
25
|
scrollContainerCache.set( contentEl, scrollContainer );
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
// Finds a scrollable ancestor of the event’s target. It's not cached because the
|
|
28
|
+
// it may not remain scrollable due to popover position changes. The cache is also
|
|
29
|
+
// less likely to be utilized because the target may be different every event.
|
|
30
|
+
const eventScrollContainer = getScrollContainer( target );
|
|
31
|
+
// Scrolls “through” the popover only if another contained scrollable area isn’t
|
|
32
|
+
// in front of it. This is to avoid scrolling both containers simultaneously.
|
|
33
|
+
if ( ! node.contains( eventScrollContainer ) ) {
|
|
34
|
+
scrollContainer.scrollBy( deltaX, deltaY );
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
37
|
// Tell the browser that we do not call event.preventDefault
|
|
30
38
|
// See https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#improving_scrolling_performance_with_passive_listeners
|
|
@@ -30,6 +30,7 @@ import { useBlockVariationTransforms } from './block-variation-transformations';
|
|
|
30
30
|
import BlockStylesMenu from './block-styles-menu';
|
|
31
31
|
import PatternTransformationsMenu from './pattern-transformations-menu';
|
|
32
32
|
import useBlockDisplayTitle from '../block-title/use-block-display-title';
|
|
33
|
+
import { unlock } from '../../lock-unlock';
|
|
33
34
|
|
|
34
35
|
function BlockSwitcherDropdownMenuContents( {
|
|
35
36
|
onClose,
|
|
@@ -196,6 +197,7 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
196
197
|
isReusable,
|
|
197
198
|
isTemplate,
|
|
198
199
|
isDisabled,
|
|
200
|
+
isSection,
|
|
199
201
|
} = useSelect(
|
|
200
202
|
( select ) => {
|
|
201
203
|
const {
|
|
@@ -204,7 +206,8 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
204
206
|
getBlockAttributes,
|
|
205
207
|
canRemoveBlocks,
|
|
206
208
|
getBlockEditingMode,
|
|
207
|
-
|
|
209
|
+
isSectionBlock,
|
|
210
|
+
} = unlock( select( blockEditorStore ) );
|
|
208
211
|
const { getBlockStyles, getBlockType, getActiveBlockVariation } =
|
|
209
212
|
select( blocksStore );
|
|
210
213
|
const _blocks = getBlocksByClientId( clientIds );
|
|
@@ -250,6 +253,7 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
250
253
|
_isSingleBlockSelected && isTemplatePart( _blocks[ 0 ] ),
|
|
251
254
|
hasContentOnlyLocking: _hasTemplateLock,
|
|
252
255
|
isDisabled: editingMode !== 'default',
|
|
256
|
+
isSection: isSectionBlock( clientIds[ 0 ] ),
|
|
253
257
|
};
|
|
254
258
|
},
|
|
255
259
|
[ clientIds ]
|
|
@@ -278,7 +282,10 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
278
282
|
? blockTitle
|
|
279
283
|
: undefined;
|
|
280
284
|
|
|
285
|
+
const hideTransformsForSections =
|
|
286
|
+
window?.__experimentalContentOnlyPatternInsertion && isSection;
|
|
281
287
|
const hideDropdown =
|
|
288
|
+
hideTransformsForSections ||
|
|
282
289
|
isDisabled ||
|
|
283
290
|
( ! hasBlockStyles && ! canRemove ) ||
|
|
284
291
|
hasContentOnlyLocking;
|
|
@@ -128,6 +128,16 @@ export function PrivateBlockToolbar( {
|
|
|
128
128
|
|
|
129
129
|
const _isZoomOut = isZoomOut();
|
|
130
130
|
|
|
131
|
+
// The switch style button appears more prominently with the
|
|
132
|
+
// content only pattern experiment.
|
|
133
|
+
const _showSwitchSectionStyleButton =
|
|
134
|
+
window?.__experimentalContentOnlyPatternInsertion
|
|
135
|
+
? _isZoomOut || isSectionBlock( selectedBlockClientId )
|
|
136
|
+
: _isZoomOut ||
|
|
137
|
+
( isNavigationModeEnabled &&
|
|
138
|
+
editingMode === 'contentOnly' &&
|
|
139
|
+
isSectionBlock( selectedBlockClientId ) );
|
|
140
|
+
|
|
131
141
|
return {
|
|
132
142
|
blockClientId: selectedBlockClientId,
|
|
133
143
|
blockClientIds: selectedBlockClientIds,
|
|
@@ -153,11 +163,7 @@ export function PrivateBlockToolbar( {
|
|
|
153
163
|
showSlots: ! _isZoomOut,
|
|
154
164
|
showGroupButtons: ! _isZoomOut,
|
|
155
165
|
showLockButtons: ! _isZoomOut,
|
|
156
|
-
showSwitchSectionStyleButton:
|
|
157
|
-
_isZoomOut ||
|
|
158
|
-
( isNavigationModeEnabled &&
|
|
159
|
-
editingMode === 'contentOnly' &&
|
|
160
|
-
isSectionBlock( selectedBlockClientId ) ), // Zoom out or Write Mode Section Blocks
|
|
166
|
+
showSwitchSectionStyleButton: _showSwitchSectionStyleButton,
|
|
161
167
|
hasFixedToolbar: getSettings().hasFixedToolbar,
|
|
162
168
|
isNavigationMode: isNavigationModeEnabled,
|
|
163
169
|
};
|
|
@@ -7,7 +7,12 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
useRef,
|
|
12
|
+
createContext,
|
|
13
|
+
useContext,
|
|
14
|
+
useCallback,
|
|
15
|
+
} from '@wordpress/element';
|
|
11
16
|
import { __unstableMotion as motion } from '@wordpress/components';
|
|
12
17
|
import { useReducedMotion } from '@wordpress/compose';
|
|
13
18
|
|
|
@@ -113,6 +118,18 @@ function InbetweenInsertionPointPopover( {
|
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
120
|
|
|
121
|
+
// Reset the insertion point reference when the Inserter unmounts,
|
|
122
|
+
// avoids stale references when `onSelectOrClose` is not called.
|
|
123
|
+
// See: https://github.com/WordPress/gutenberg/issues/65598#issuecomment-3249229264.
|
|
124
|
+
const maybeResetOpenRef = useCallback(
|
|
125
|
+
( node ) => {
|
|
126
|
+
if ( ! node && openRef.current ) {
|
|
127
|
+
openRef.current = false;
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
[ openRef ]
|
|
131
|
+
);
|
|
132
|
+
|
|
116
133
|
const lineVariants = {
|
|
117
134
|
// Initial position starts from the center and invisible.
|
|
118
135
|
start: {
|
|
@@ -203,6 +220,7 @@ function InbetweenInsertionPointPopover( {
|
|
|
203
220
|
) }
|
|
204
221
|
>
|
|
205
222
|
<Inserter
|
|
223
|
+
ref={ maybeResetOpenRef }
|
|
206
224
|
position="bottom center"
|
|
207
225
|
clientId={ nextClientId }
|
|
208
226
|
rootClientId={ rootClientId }
|
|
@@ -36,7 +36,7 @@ export function useShowBlockTools() {
|
|
|
36
36
|
const hasSelectedBlock = !! clientId && !! block;
|
|
37
37
|
const isEmptyDefaultBlock =
|
|
38
38
|
hasSelectedBlock &&
|
|
39
|
-
isUnmodifiedDefaultBlock( block ) &&
|
|
39
|
+
isUnmodifiedDefaultBlock( block, 'content' ) &&
|
|
40
40
|
getBlockMode( clientId ) !== 'html';
|
|
41
41
|
const _showEmptyBlockSideInserter =
|
|
42
42
|
clientId &&
|
|
@@ -139,32 +139,40 @@ function VariationsToggleGroupControl( {
|
|
|
139
139
|
|
|
140
140
|
function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
141
141
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
142
|
-
const { activeBlockVariation, variations, isContentOnly } =
|
|
143
|
-
(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
142
|
+
const { activeBlockVariation, variations, isContentOnly, isSection } =
|
|
143
|
+
useSelect(
|
|
144
|
+
( select ) => {
|
|
145
|
+
const { getActiveBlockVariation, getBlockVariations } =
|
|
146
|
+
select( blocksStore );
|
|
147
|
+
|
|
148
|
+
const {
|
|
149
|
+
getBlockName,
|
|
150
|
+
getBlockAttributes,
|
|
151
|
+
getBlockEditingMode,
|
|
152
|
+
isSectionBlock,
|
|
153
|
+
} = unlock( select( blockEditorStore ) );
|
|
154
|
+
|
|
155
|
+
const name = blockClientId && getBlockName( blockClientId );
|
|
156
|
+
|
|
157
|
+
const { hasContentRoleAttribute } = unlock(
|
|
158
|
+
select( blocksStore )
|
|
159
|
+
);
|
|
160
|
+
const isContentBlock = hasContentRoleAttribute( name );
|
|
161
|
+
|
|
162
|
+
return {
|
|
163
|
+
activeBlockVariation: getActiveBlockVariation(
|
|
164
|
+
name,
|
|
165
|
+
getBlockAttributes( blockClientId )
|
|
166
|
+
),
|
|
167
|
+
variations: name && getBlockVariations( name, 'transform' ),
|
|
168
|
+
isContentOnly:
|
|
169
|
+
getBlockEditingMode( blockClientId ) ===
|
|
170
|
+
'contentOnly' && ! isContentBlock,
|
|
171
|
+
isSection: isSectionBlock( blockClientId ),
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
[ blockClientId ]
|
|
175
|
+
);
|
|
168
176
|
|
|
169
177
|
const selectedValue = activeBlockVariation?.name;
|
|
170
178
|
|
|
@@ -189,7 +197,10 @@ function __experimentalBlockVariationTransforms( { blockClientId } ) {
|
|
|
189
197
|
} );
|
|
190
198
|
};
|
|
191
199
|
|
|
192
|
-
|
|
200
|
+
const hideVariationsForSections =
|
|
201
|
+
window?.__experimentalContentOnlyPatternInsertion && isSection;
|
|
202
|
+
|
|
203
|
+
if ( ! variations?.length || isContentOnly || hideVariationsForSections ) {
|
|
193
204
|
return null;
|
|
194
205
|
}
|
|
195
206
|
|
|
@@ -19,12 +19,27 @@ import { safeDecodeURI, filterURLForDisplay, getPath } from '@wordpress/url';
|
|
|
19
19
|
import { pipe } from '@wordpress/compose';
|
|
20
20
|
import deprecated from '@wordpress/deprecated';
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
post:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
const TYPES = {
|
|
23
|
+
post: {
|
|
24
|
+
icon: postList,
|
|
25
|
+
label: __( 'Post' ),
|
|
26
|
+
},
|
|
27
|
+
page: {
|
|
28
|
+
icon: page,
|
|
29
|
+
label: __( 'Page' ),
|
|
30
|
+
},
|
|
31
|
+
post_tag: {
|
|
32
|
+
icon: tag,
|
|
33
|
+
label: __( 'Tag' ),
|
|
34
|
+
},
|
|
35
|
+
category: {
|
|
36
|
+
icon: category,
|
|
37
|
+
label: __( 'Category' ),
|
|
38
|
+
},
|
|
39
|
+
attachment: {
|
|
40
|
+
icon: file,
|
|
41
|
+
label: __( 'Attachment' ),
|
|
42
|
+
},
|
|
28
43
|
};
|
|
29
44
|
|
|
30
45
|
function SearchItemIcon( { isURL, suggestion } ) {
|
|
@@ -32,8 +47,8 @@ function SearchItemIcon( { isURL, suggestion } ) {
|
|
|
32
47
|
|
|
33
48
|
if ( isURL ) {
|
|
34
49
|
icon = globe;
|
|
35
|
-
} else if ( suggestion.type in
|
|
36
|
-
icon =
|
|
50
|
+
} else if ( suggestion.type in TYPES ) {
|
|
51
|
+
icon = TYPES[ suggestion.type ].icon;
|
|
37
52
|
if ( suggestion.type === 'page' ) {
|
|
38
53
|
if ( suggestion.isFrontPage ) {
|
|
39
54
|
icon = home;
|
|
@@ -149,15 +164,19 @@ export const LinkControlSearchItem = ( {
|
|
|
149
164
|
|
|
150
165
|
function getVisualTypeName( suggestion ) {
|
|
151
166
|
if ( suggestion.isFrontPage ) {
|
|
152
|
-
return '
|
|
167
|
+
return __( 'Front page' );
|
|
153
168
|
}
|
|
154
169
|
|
|
155
170
|
if ( suggestion.isBlogHome ) {
|
|
156
|
-
return '
|
|
171
|
+
return __( 'Blog home' );
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Provide translated labels for built-in post types. Ideally, the API would return the localised CPT or taxonomy label.
|
|
175
|
+
if ( suggestion.type in TYPES ) {
|
|
176
|
+
return TYPES[ suggestion.type ].label;
|
|
157
177
|
}
|
|
158
178
|
|
|
159
|
-
|
|
160
|
-
return suggestion.type === 'post_tag' ? 'tag' : suggestion.type;
|
|
179
|
+
return suggestion.type;
|
|
161
180
|
}
|
|
162
181
|
|
|
163
182
|
export default LinkControlSearchItem;
|
|
@@ -28,6 +28,18 @@ import {
|
|
|
28
28
|
|
|
29
29
|
const mockFetchSearchSuggestions = jest.fn();
|
|
30
30
|
|
|
31
|
+
function getExpectedVisualTypeName( type ) {
|
|
32
|
+
const builtInLabels = {
|
|
33
|
+
post: 'Post',
|
|
34
|
+
page: 'Page',
|
|
35
|
+
post_tag: 'Tag',
|
|
36
|
+
category: 'Category',
|
|
37
|
+
attachment: 'Attachment',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return builtInLabels[ type ] || type;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
/**
|
|
32
44
|
* The call to the real method `fetchRichUrlData` is wrapped in a promise in order to make it cancellable.
|
|
33
45
|
* Therefore if we pass any value as the mock of `fetchRichUrlData` then ALL of the tests will require
|
|
@@ -510,7 +522,7 @@ describe( 'Searching for a link', () => {
|
|
|
510
522
|
firstSuggestion.title
|
|
511
523
|
);
|
|
512
524
|
expect( searchResultElements[ 0 ] ).toHaveTextContent(
|
|
513
|
-
firstSuggestion.type
|
|
525
|
+
getExpectedVisualTypeName( firstSuggestion.type )
|
|
514
526
|
);
|
|
515
527
|
|
|
516
528
|
// The fallback URL suggestion should not be shown when input is not URL-like.
|
|
@@ -2078,7 +2090,7 @@ describe( 'Post types', () => {
|
|
|
2078
2090
|
|
|
2079
2091
|
searchResultElements.forEach( ( resultItem, index ) => {
|
|
2080
2092
|
expect( resultItem ).toHaveTextContent(
|
|
2081
|
-
fauxEntitySuggestions[ index ].type
|
|
2093
|
+
getExpectedVisualTypeName( fauxEntitySuggestions[ index ].type )
|
|
2082
2094
|
);
|
|
2083
2095
|
} );
|
|
2084
2096
|
} );
|
|
@@ -22,13 +22,20 @@ export const Appender = forwardRef(
|
|
|
22
22
|
const { insertedBlock, setInsertedBlock } = useListViewContext();
|
|
23
23
|
|
|
24
24
|
const instanceId = useInstanceId( Appender );
|
|
25
|
-
const hideInserter = useSelect(
|
|
25
|
+
const { directInsert, hideInserter } = useSelect(
|
|
26
26
|
( select ) => {
|
|
27
|
-
const { getTemplateLock, isZoomOut } =
|
|
28
|
-
select( blockEditorStore )
|
|
29
|
-
);
|
|
27
|
+
const { getBlockListSettings, getTemplateLock, isZoomOut } =
|
|
28
|
+
unlock( select( blockEditorStore ) );
|
|
30
29
|
|
|
31
|
-
|
|
30
|
+
const settings = getBlockListSettings( clientId );
|
|
31
|
+
const directInsertValue = settings?.directInsert || false;
|
|
32
|
+
const hideInserterValue =
|
|
33
|
+
!! getTemplateLock( clientId ) || isZoomOut();
|
|
34
|
+
|
|
35
|
+
return {
|
|
36
|
+
directInsert: directInsertValue,
|
|
37
|
+
hideInserter: hideInserterValue,
|
|
38
|
+
};
|
|
32
39
|
},
|
|
33
40
|
[ clientId ]
|
|
34
41
|
);
|
|
@@ -79,7 +86,7 @@ export const Appender = forwardRef(
|
|
|
79
86
|
position="bottom right"
|
|
80
87
|
isAppender
|
|
81
88
|
selectBlockOnInsert={ false }
|
|
82
|
-
shouldDirectInsert={
|
|
89
|
+
shouldDirectInsert={ directInsert }
|
|
83
90
|
__experimentalIsQuick
|
|
84
91
|
{ ...props }
|
|
85
92
|
toggleProps={ { 'aria-describedby': descriptionId } }
|