@wordpress/block-editor 15.3.1-next.836ecdcae.0 → 15.3.1-next.a730c9c8c.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-card/index.js +4 -2
- package/build/components/block-card/index.js.map +1 -1
- package/build/components/block-inspector/edit-contents-button.js +54 -0
- package/build/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build/components/block-inspector/index.js +5 -1
- package/build/components/block-inspector/index.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 +13 -8
- 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-variation-transforms/index.js +10 -6
- package/build/components/block-variation-transforms/index.js.map +1 -1
- package/build/components/border-radius-control/utils.js.map +1 -1
- package/build/components/global-styles/border-panel.js +6 -6
- package/build/components/global-styles/border-panel.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/url-popover/image-url-input-ui.js +7 -2
- package/build/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build/store/private-selectors.js +9 -21
- package/build/store/private-selectors.js.map +1 -1
- package/build/store/reducer.js +114 -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/utils/block-bindings.js +1 -1
- package/build/utils/block-bindings.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-card/index.js +4 -2
- package/build-module/components/block-card/index.js.map +1 -1
- package/build-module/components/block-inspector/edit-contents-button.js +47 -0
- package/build-module/components/block-inspector/edit-contents-button.js.map +1 -0
- package/build-module/components/block-inspector/index.js +5 -1
- package/build-module/components/block-inspector/index.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 +13 -8
- 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-variation-transforms/index.js +10 -6
- package/build-module/components/block-variation-transforms/index.js.map +1 -1
- package/build-module/components/border-radius-control/utils.js.map +1 -1
- package/build-module/components/global-styles/border-panel.js +6 -6
- package/build-module/components/global-styles/border-panel.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/url-popover/image-url-input-ui.js +9 -4
- package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js +6 -1
- package/build-module/components/writing-flow/use-clipboard-handler.js.map +1 -1
- package/build-module/store/private-selectors.js +9 -21
- package/build-module/store/private-selectors.js.map +1 -1
- package/build-module/store/reducer.js +114 -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-module/utils/block-bindings.js +1 -1
- package/build-module/utils/block-bindings.js.map +1 -1
- package/build-style/style-rtl.css +9 -5
- package/build-style/style.css +9 -5
- package/package.json +34 -34
- package/src/autocompleters/block.js +6 -11
- package/src/components/block-card/index.js +11 -1
- package/src/components/block-inspector/edit-contents-button.js +46 -0
- package/src/components/block-inspector/index.js +6 -1
- package/src/components/block-inspector/style.scss +5 -0
- 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 +13 -4
- package/src/components/block-toolbar/index.js +11 -5
- package/src/components/block-toolbar/style.scss +3 -5
- package/src/components/block-tools/insertion-point.js +19 -1
- package/src/components/block-variation-transforms/index.js +39 -27
- package/src/components/border-radius-control/test/utils.js +71 -0
- package/src/components/border-radius-control/utils.js +1 -0
- package/src/components/global-styles/border-panel.js +7 -6
- 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/url-popover/image-url-input-ui.js +18 -2
- package/src/components/writing-flow/use-clipboard-handler.js +6 -0
- package/src/store/private-selectors.js +12 -24
- package/src/store/reducer.js +188 -0
- package/src/store/selectors.js +38 -59
- package/src/store/test/reducer.js +398 -0
- package/src/store/test/selectors.js +65 -192
- package/src/store/utils.js +21 -0
- package/src/utils/block-bindings.js +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,GAAG,IAAIC,OAAO,CAAC,CAAC;AACxC,MAAMC,eAAe,GAAG,IAAID,OAAO,CAAC,CAAC;AAErC,OAAO,SAASE,cAAcA,CAC7BC,WAAW,EACXC,mCAAmC,GAAG,EAAE,EACvC;EACD,OAAO;IACNC,IAAI,EAAE,cAAeF,WAAW,CAACG,EAAE,EAAG;IACtCA,EAAE,EAAEH,WAAW,CAACG,EAAE;IAClBC,IAAI,EAAEX,sBAAsB,CAACY,IAAI;IACjCC,KAAK,EAAEN,WAAW,CAACM,KAAK,EAAEC,GAAG;IAC7BC,UAAU,EAAER,WAAW,CAACS,mBAAmB,EAAEC,GAAG,CAAIC,KAAK,IAAM;MAC9D,MAAMC,QAAQ,GAAGX,mCAAmC,CAACY,IAAI,CACxD,CAAE;QAAEV;MAAG,CAAC,KAAMA,EAAE,KAAKQ,KACtB,CAAC;MACD,OAAOC,QAAQ,GAAGA,QAAQ,CAACE,IAAI,GAAGH,KAA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AACM,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,CAACrD,mCAAmC,EAClDoD,KAAK,CAACC,QAAQ,CAACE,4BAA4B,EAC3CH,KAAK,CAACC,QAAQ,CAAEjE,sBAAsB,CAAE,GAAI+D,MAAO,CAAC,EACpDC,KAAK,CAACI,aAAa,EACnBnE,MAAM,CAAE8D,MAAM,CAAE7D,UAAW,CAAE,CAAC,CAACmE,iBAAiB,CAAC,CAAC,CAClD;AACF,CAAC;AAED,OAAO,MAAMC,4BAA4B,GACtCP,MAAM,IAAM,CAAEC,KAAK,EAAEO,YAAY,KAAM;EACxC,OAAO,CACNP,KAAK,CAACQ,iBAAiB,CAAED,YAAY,CAAE,EACvCP,KAAK,CAACjC,MAAM,CAAC0C,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":[]}
|
|
@@ -13,7 +13,7 @@ const PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';
|
|
|
13
13
|
const BLOCK_BINDINGS_ALLOWED_BLOCKS = {
|
|
14
14
|
'core/paragraph': ['content'],
|
|
15
15
|
'core/heading': ['content'],
|
|
16
|
-
'core/image': ['id', 'url', 'title', 'alt'],
|
|
16
|
+
'core/image': ['id', 'url', 'title', 'alt', 'caption'],
|
|
17
17
|
'core/button': ['url', 'text', 'linkTarget', 'rel'],
|
|
18
18
|
'core/post-date': ['datetime']
|
|
19
19
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useDispatch","useRegistry","store","blockEditorStore","useBlockEditContext","DEFAULT_ATTRIBUTE","PATTERN_OVERRIDES_SOURCE","BLOCK_BINDINGS_ALLOWED_BLOCKS","isObjectEmpty","object","Object","keys","length","canBindBlock","blockName","canBindAttribute","attributeName","includes","getBindableAttributes","hasPatternOverridesDefaultBinding","bindings","source","replacePatternOverridesDefaultBinding","supportedAttributes","bindingsWithDefaults","bindingSource","useBlockBindingsUtils","clientId","contextClientId","blockClientId","updateBlockAttributes","getBlockAttributes","select","updateBlockBindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n\t'core/post-date': [ 'datetime' ],\n};\n\n/**\n * Checks if the given object is empty.\n *\n * @param {?Object} object The object to check.\n *\n * @return {boolean} Whether the object is empty.\n */\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Based on the given block name, checks if it is possible to bind the block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name, checks if it is possible to bind the block attribute.\n *\n * @param {string} blockName The name of the block.\n * @param {string} attributeName The name of attribute.\n *\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\n/**\n * Gets the bindable attributes for a given block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {string[]} The bindable attributes for the block.\n */\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,iBAAiB,GAAG,WAAW;AACrC,MAAMC,wBAAwB,GAAG,wBAAwB;AACzD,MAAMC,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,CAAE;EAC7C,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAE;EACrD,gBAAgB,EAAE,CAAE,UAAU;AAC/B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,SAAS,EAAG;EACzC,OAAOA,SAAS,IAAIP,6BAA6B;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,gBAAgBA,CAAED,SAAS,EAAEE,aAAa,EAAG;EAC5D,OACCH,YAAY,CAAEC,SAAU,CAAC,IACzBP,6BAA6B,CAAEO,SAAS,CAAE,CAACG,QAAQ,CAAED,aAAc,CAAC;AAEtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,qBAAqBA,CAAEJ,SAAS,EAAG;EAClD,OAAOP,6BAA6B,CAAEO,SAAS,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MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GACjDH,kBAAkB,CAAEF,aAAc,CAAC;IACpCC,qBAAqB,CAAED,aAAa,EAAE;MACrCK,QAAQ,EAAE1B,aAAa,CAAE0B,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAED,mBAAmB;IAAEU;EAAuB,CAAC;AACvD","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["useDispatch","useRegistry","store","blockEditorStore","useBlockEditContext","DEFAULT_ATTRIBUTE","PATTERN_OVERRIDES_SOURCE","BLOCK_BINDINGS_ALLOWED_BLOCKS","isObjectEmpty","object","Object","keys","length","canBindBlock","blockName","canBindAttribute","attributeName","includes","getBindableAttributes","hasPatternOverridesDefaultBinding","bindings","source","replacePatternOverridesDefaultBinding","supportedAttributes","bindingsWithDefaults","bindingSource","useBlockBindingsUtils","clientId","contextClientId","blockClientId","updateBlockAttributes","getBlockAttributes","select","updateBlockBindings","metadata","currentBindings","newBindings","entries","forEach","attribute","binding","newMetadata","undefined","removeAllBlockBindings"],"sources":["@wordpress/block-editor/src/utils/block-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useRegistry } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../store';\nimport { useBlockEditContext } from '../components/block-edit';\n\nconst DEFAULT_ATTRIBUTE = '__default';\nconst PATTERN_OVERRIDES_SOURCE = 'core/pattern-overrides';\nconst BLOCK_BINDINGS_ALLOWED_BLOCKS = {\n\t'core/paragraph': [ 'content' ],\n\t'core/heading': [ 'content' ],\n\t'core/image': [ 'id', 'url', 'title', 'alt', 'caption' ],\n\t'core/button': [ 'url', 'text', 'linkTarget', 'rel' ],\n\t'core/post-date': [ 'datetime' ],\n};\n\n/**\n * Checks if the given object is empty.\n *\n * @param {?Object} object The object to check.\n *\n * @return {boolean} Whether the object is empty.\n */\nfunction isObjectEmpty( object ) {\n\treturn ! object || Object.keys( object ).length === 0;\n}\n\n/**\n * Based on the given block name, checks if it is possible to bind the block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {boolean} Whether it is possible to bind the block to sources.\n */\nexport function canBindBlock( blockName ) {\n\treturn blockName in BLOCK_BINDINGS_ALLOWED_BLOCKS;\n}\n\n/**\n * Based on the given block name and attribute name, checks if it is possible to bind the block attribute.\n *\n * @param {string} blockName The name of the block.\n * @param {string} attributeName The name of attribute.\n *\n * @return {boolean} Whether it is possible to bind the block attribute.\n */\nexport function canBindAttribute( blockName, attributeName ) {\n\treturn (\n\t\tcanBindBlock( blockName ) &&\n\t\tBLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ].includes( attributeName )\n\t);\n}\n\n/**\n * Gets the bindable attributes for a given block.\n *\n * @param {string} blockName The name of the block.\n *\n * @return {string[]} The bindable attributes for the block.\n */\nexport function getBindableAttributes( blockName ) {\n\treturn BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n}\n\n/**\n * Checks if the block has the `__default` binding for pattern overrides.\n *\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {boolean} Whether the block has the `__default` binding for pattern overrides.\n */\nexport function hasPatternOverridesDefaultBinding( bindings ) {\n\treturn bindings?.[ DEFAULT_ATTRIBUTE ]?.source === PATTERN_OVERRIDES_SOURCE;\n}\n\n/**\n * Returns the bindings with the `__default` binding for pattern overrides\n * replaced with the full-set of supported attributes. e.g.:\n *\n * - bindings passed in: `{ __default: { source: 'core/pattern-overrides' } }`\n * - bindings returned: `{ content: { source: 'core/pattern-overrides' } }`\n *\n * @param {string} blockName The block name (e.g. 'core/paragraph').\n * @param {?Record<string, object>} bindings A block's bindings from the metadata attribute.\n *\n * @return {Object} The bindings with default replaced for pattern overrides.\n */\nexport function replacePatternOverridesDefaultBinding( blockName, bindings ) {\n\t// The `__default` binding currently only works for pattern overrides.\n\tif ( hasPatternOverridesDefaultBinding( bindings ) ) {\n\t\tconst supportedAttributes = BLOCK_BINDINGS_ALLOWED_BLOCKS[ blockName ];\n\t\tconst bindingsWithDefaults = {};\n\t\tfor ( const attributeName of supportedAttributes ) {\n\t\t\t// If the block has mixed binding sources, retain any non pattern override bindings.\n\t\t\tconst bindingSource = bindings[ attributeName ]\n\t\t\t\t? bindings[ attributeName ]\n\t\t\t\t: { source: PATTERN_OVERRIDES_SOURCE };\n\t\t\tbindingsWithDefaults[ attributeName ] = bindingSource;\n\t\t}\n\n\t\treturn bindingsWithDefaults;\n\t}\n\n\treturn bindings;\n}\n\n/**\n * Contains utils to update the block `bindings` metadata.\n *\n * @typedef {Object} WPBlockBindingsUtils\n *\n * @property {Function} updateBlockBindings Updates the value of the bindings connected to block attributes.\n * @property {Function} removeAllBlockBindings Removes the bindings property of the `metadata` attribute.\n */\n\n/**\n * Retrieves the existing utils needed to update the block `bindings` metadata.\n * They can be used to create, modify, or remove connections from the existing block attributes.\n *\n * It contains the following utils:\n * - `updateBlockBindings`: Updates the value of the bindings connected to block attributes. It can be used to remove a specific binding by setting the value to `undefined`.\n * - `removeAllBlockBindings`: Removes the bindings property of the `metadata` attribute.\n *\n * @since 6.7.0 Introduced in WordPress core.\n *\n * @param {?string} clientId Optional block client ID. If not set, it will use the current block client ID from the context.\n *\n * @return {?WPBlockBindingsUtils} Object containing the block bindings utils.\n *\n * @example\n * ```js\n * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n * const { updateBlockBindings, removeAllBlockBindings } = useBlockBindingsUtils();\n *\n * // Update url and alt attributes.\n * updateBlockBindings( {\n * url: {\n * source: 'core/post-meta',\n * args: {\n * key: 'url_custom_field',\n * },\n * },\n * alt: {\n * source: 'core/post-meta',\n * args: {\n * key: 'text_custom_field',\n * },\n * },\n * } );\n *\n * // Remove binding from url attribute.\n * updateBlockBindings( { url: undefined } );\n *\n * // Remove bindings from all attributes.\n * removeAllBlockBindings();\n * ```\n */\nexport function useBlockBindingsUtils( clientId ) {\n\tconst { clientId: contextClientId } = useBlockEditContext();\n\tconst blockClientId = clientId || contextClientId;\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { getBlockAttributes } = useRegistry().select( blockEditorStore );\n\n\t/**\n\t * Updates the value of the bindings connected to block attributes.\n\t * It removes the binding when the new value is `undefined`.\n\t *\n\t * @param {Object} bindings Bindings including the attributes to update and the new object.\n\t * @param {string} bindings.source The source name to connect to.\n\t * @param {Object} [bindings.args] Object containing the arguments needed by the source.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { updateBlockBindings } = useBlockBindingsUtils();\n\t * updateBlockBindings( {\n\t * url: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'url_custom_field',\n\t * },\n\t * \t },\n\t * alt: {\n\t * source: 'core/post-meta',\n\t * args: {\n\t * key: 'text_custom_field',\n\t * },\n\t * \t }\n\t * } );\n\t * ```\n\t */\n\tconst updateBlockBindings = ( bindings ) => {\n\t\tconst { metadata: { bindings: currentBindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tconst newBindings = { ...currentBindings };\n\n\t\tObject.entries( bindings ).forEach( ( [ attribute, binding ] ) => {\n\t\t\tif ( ! binding && newBindings[ attribute ] ) {\n\t\t\t\tdelete newBindings[ attribute ];\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tnewBindings[ attribute ] = binding;\n\t\t} );\n\n\t\tconst newMetadata = {\n\t\t\t...metadata,\n\t\t\tbindings: newBindings,\n\t\t};\n\n\t\tif ( isObjectEmpty( newMetadata.bindings ) ) {\n\t\t\tdelete newMetadata.bindings;\n\t\t}\n\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( newMetadata ) ? undefined : newMetadata,\n\t\t} );\n\t};\n\n\t/**\n\t * Removes the bindings property of the `metadata` attribute.\n\t *\n\t * @example\n\t * ```js\n\t * import { useBlockBindingsUtils } from '@wordpress/block-editor'\n\t *\n\t * const { removeAllBlockBindings } = useBlockBindingsUtils();\n\t * removeAllBlockBindings();\n\t * ```\n\t */\n\tconst removeAllBlockBindings = () => {\n\t\tconst { metadata: { bindings, ...metadata } = {} } =\n\t\t\tgetBlockAttributes( blockClientId );\n\t\tupdateBlockAttributes( blockClientId, {\n\t\t\tmetadata: isObjectEmpty( metadata ) ? undefined : metadata,\n\t\t} );\n\t};\n\n\treturn { updateBlockBindings, removeAllBlockBindings };\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,UAAU;AACpD,SAASC,mBAAmB,QAAQ,0BAA0B;AAE9D,MAAMC,iBAAiB,GAAG,WAAW;AACrC,MAAMC,wBAAwB,GAAG,wBAAwB;AACzD,MAAMC,6BAA6B,GAAG;EACrC,gBAAgB,EAAE,CAAE,SAAS,CAAE;EAC/B,cAAc,EAAE,CAAE,SAAS,CAAE;EAC7B,YAAY,EAAE,CAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,CAAE;EACxD,aAAa,EAAE,CAAE,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,KAAK,CAAE;EACrD,gBAAgB,EAAE,CAAE,UAAU;AAC/B,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,aAAaA,CAAEC,MAAM,EAAG;EAChC,OAAO,CAAEA,MAAM,IAAIC,MAAM,CAACC,IAAI,CAAEF,MAAO,CAAC,CAACG,MAAM,KAAK,CAAC;AACtD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,YAAYA,CAAEC,SAAS,EAAG;EACzC,OAAOA,SAAS,IAAIP,6BAA6B;AAClD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASQ,gBAAgBA,CAAED,SAAS,EAAEE,aAAa,EAAG;EAC5D,OACCH,YA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WAAY,CAAC,GAAGC,SAAS,GAAGD;IACtD,CAAE,CAAC;EACJ,CAAC;;EAED;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACC,MAAME,sBAAsB,GAAGA,CAAA,KAAM;IACpC,MAAM;MAAET,QAAQ,EAAE;QAAEd,QAAQ;QAAE,GAAGc;MAAS,CAAC,GAAG,CAAC;IAAE,CAAC,GACjDH,kBAAkB,CAAEF,aAAc,CAAC;IACpCC,qBAAqB,CAAED,aAAa,EAAE;MACrCK,QAAQ,EAAE1B,aAAa,CAAE0B,QAAS,CAAC,GAAGQ,SAAS,GAAGR;IACnD,CAAE,CAAC;EACJ,CAAC;EAED,OAAO;IAAED,mBAAmB;IAAEU;EAAuB,CAAC;AACvD","ignoreList":[]}
|
|
@@ -467,6 +467,11 @@ iframe[name=editor-canvas] {
|
|
|
467
467
|
border-top: 1px solid #ddd;
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
+
.block-editor-block-inspector-edit-contents-button {
|
|
471
|
+
margin-top: 8px;
|
|
472
|
+
justify-content: center;
|
|
473
|
+
}
|
|
474
|
+
|
|
470
475
|
/**
|
|
471
476
|
* Insertion Point.
|
|
472
477
|
*/
|
|
@@ -2434,7 +2439,6 @@ iframe[name=editor-canvas] {
|
|
|
2434
2439
|
}
|
|
2435
2440
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2436
2441
|
color: #757575;
|
|
2437
|
-
text-transform: capitalize;
|
|
2438
2442
|
white-space: nowrap;
|
|
2439
2443
|
}
|
|
2440
2444
|
.block-editor-link-control__search-item[aria-selected] {
|
|
@@ -3698,7 +3702,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3698
3702
|
.block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
|
|
3699
3703
|
color: var(--wp-block-synced-color);
|
|
3700
3704
|
}
|
|
3701
|
-
.block-editor-block-toolbar.is-synced .
|
|
3705
|
+
.block-editor-block-toolbar.is-synced .block-editor-block-switcher__no-switcher-icon[aria-disabled=true] .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher__no-switcher-icon[aria-disabled=true] .block-editor-block-icon {
|
|
3702
3706
|
color: var(--wp-block-synced-color);
|
|
3703
3707
|
}
|
|
3704
3708
|
.block-editor-block-toolbar > :last-child,
|
|
@@ -3807,13 +3811,13 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3807
3811
|
display: inline-flex;
|
|
3808
3812
|
}
|
|
3809
3813
|
|
|
3810
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon {
|
|
3814
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text)) {
|
|
3811
3815
|
width: auto;
|
|
3812
3816
|
}
|
|
3813
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon svg {
|
|
3817
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text)) svg {
|
|
3814
3818
|
display: none;
|
|
3815
3819
|
}
|
|
3816
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon::after {
|
|
3820
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text))::after {
|
|
3817
3821
|
content: attr(aria-label);
|
|
3818
3822
|
font-size: 12px;
|
|
3819
3823
|
}
|
package/build-style/style.css
CHANGED
|
@@ -467,6 +467,11 @@ iframe[name=editor-canvas] {
|
|
|
467
467
|
border-top: 1px solid #ddd;
|
|
468
468
|
}
|
|
469
469
|
|
|
470
|
+
.block-editor-block-inspector-edit-contents-button {
|
|
471
|
+
margin-top: 8px;
|
|
472
|
+
justify-content: center;
|
|
473
|
+
}
|
|
474
|
+
|
|
470
475
|
/**
|
|
471
476
|
* Insertion Point.
|
|
472
477
|
*/
|
|
@@ -2435,7 +2440,6 @@ iframe[name=editor-canvas] {
|
|
|
2435
2440
|
}
|
|
2436
2441
|
.block-editor-link-control__search-item .components-menu-item__shortcut {
|
|
2437
2442
|
color: #757575;
|
|
2438
|
-
text-transform: capitalize;
|
|
2439
2443
|
white-space: nowrap;
|
|
2440
2444
|
}
|
|
2441
2445
|
.block-editor-link-control__search-item[aria-selected] {
|
|
@@ -3700,7 +3704,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3700
3704
|
.block-editor-block-toolbar.is-synced .block-editor-block-switcher .components-button .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher .components-button .block-editor-block-icon {
|
|
3701
3705
|
color: var(--wp-block-synced-color);
|
|
3702
3706
|
}
|
|
3703
|
-
.block-editor-block-toolbar.is-synced .
|
|
3707
|
+
.block-editor-block-toolbar.is-synced .block-editor-block-switcher__no-switcher-icon[aria-disabled=true] .block-editor-block-icon, .block-editor-block-toolbar.is-connected .block-editor-block-switcher__no-switcher-icon[aria-disabled=true] .block-editor-block-icon {
|
|
3704
3708
|
color: var(--wp-block-synced-color);
|
|
3705
3709
|
}
|
|
3706
3710
|
.block-editor-block-toolbar > :last-child,
|
|
@@ -3809,13 +3813,13 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3809
3813
|
display: inline-flex;
|
|
3810
3814
|
}
|
|
3811
3815
|
|
|
3812
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon {
|
|
3816
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text)) {
|
|
3813
3817
|
width: auto;
|
|
3814
3818
|
}
|
|
3815
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon svg {
|
|
3819
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text)) svg {
|
|
3816
3820
|
display: none;
|
|
3817
3821
|
}
|
|
3818
|
-
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon::after {
|
|
3822
|
+
.show-icon-labels .block-editor-block-toolbar .components-button.has-icon:where(:not(.has-text))::after {
|
|
3819
3823
|
content: attr(aria-label);
|
|
3820
3824
|
font-size: 12px;
|
|
3821
3825
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.3.1-next.
|
|
3
|
+
"version": "15.3.1-next.a730c9c8c.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.1-next.
|
|
41
|
-
"@wordpress/api-fetch": "^7.30.1-next.
|
|
42
|
-
"@wordpress/blob": "^4.30.1-next.
|
|
43
|
-
"@wordpress/block-serialization-default-parser": "^5.30.1-next.
|
|
44
|
-
"@wordpress/blocks": "^15.3.1-next.
|
|
45
|
-
"@wordpress/commands": "^1.30.1-next.
|
|
46
|
-
"@wordpress/components": "^30.3.2-next.
|
|
47
|
-
"@wordpress/compose": "^7.30.1-next.
|
|
48
|
-
"@wordpress/data": "^10.30.1-next.
|
|
49
|
-
"@wordpress/date": "^5.30.1-next.
|
|
50
|
-
"@wordpress/deprecated": "^4.30.1-next.
|
|
51
|
-
"@wordpress/dom": "^4.30.1-next.
|
|
52
|
-
"@wordpress/element": "^6.30.1-next.
|
|
53
|
-
"@wordpress/escape-html": "^3.30.1-next.
|
|
54
|
-
"@wordpress/hooks": "^4.30.1-next.
|
|
55
|
-
"@wordpress/html-entities": "^4.30.1-next.
|
|
56
|
-
"@wordpress/i18n": "^6.3.1-next.
|
|
57
|
-
"@wordpress/icons": "^10.30.1-next.
|
|
58
|
-
"@wordpress/is-shallow-equal": "^5.30.1-next.
|
|
59
|
-
"@wordpress/keyboard-shortcuts": "^5.30.1-next.
|
|
60
|
-
"@wordpress/keycodes": "^4.30.1-next.
|
|
61
|
-
"@wordpress/notices": "^5.30.1-next.
|
|
62
|
-
"@wordpress/preferences": "^4.30.1-next.
|
|
63
|
-
"@wordpress/priority-queue": "^3.30.1-next.
|
|
64
|
-
"@wordpress/private-apis": "^1.30.1-next.
|
|
65
|
-
"@wordpress/rich-text": "^7.30.1-next.
|
|
66
|
-
"@wordpress/style-engine": "^2.30.1-next.
|
|
67
|
-
"@wordpress/token-list": "^3.30.1-next.
|
|
68
|
-
"@wordpress/upload-media": "^0.15.1-next.
|
|
69
|
-
"@wordpress/url": "^4.30.1-next.
|
|
70
|
-
"@wordpress/warning": "^3.30.1-next.
|
|
71
|
-
"@wordpress/wordcount": "^4.30.1-next.
|
|
40
|
+
"@wordpress/a11y": "^4.30.1-next.a730c9c8c.0",
|
|
41
|
+
"@wordpress/api-fetch": "^7.30.1-next.a730c9c8c.0",
|
|
42
|
+
"@wordpress/blob": "^4.30.1-next.a730c9c8c.0",
|
|
43
|
+
"@wordpress/block-serialization-default-parser": "^5.30.1-next.a730c9c8c.0",
|
|
44
|
+
"@wordpress/blocks": "^15.3.1-next.a730c9c8c.0",
|
|
45
|
+
"@wordpress/commands": "^1.30.1-next.a730c9c8c.0",
|
|
46
|
+
"@wordpress/components": "^30.3.2-next.a730c9c8c.0",
|
|
47
|
+
"@wordpress/compose": "^7.30.1-next.a730c9c8c.0",
|
|
48
|
+
"@wordpress/data": "^10.30.1-next.a730c9c8c.0",
|
|
49
|
+
"@wordpress/date": "^5.30.1-next.a730c9c8c.0",
|
|
50
|
+
"@wordpress/deprecated": "^4.30.1-next.a730c9c8c.0",
|
|
51
|
+
"@wordpress/dom": "^4.30.1-next.a730c9c8c.0",
|
|
52
|
+
"@wordpress/element": "^6.30.1-next.a730c9c8c.0",
|
|
53
|
+
"@wordpress/escape-html": "^3.30.1-next.a730c9c8c.0",
|
|
54
|
+
"@wordpress/hooks": "^4.30.1-next.a730c9c8c.0",
|
|
55
|
+
"@wordpress/html-entities": "^4.30.1-next.a730c9c8c.0",
|
|
56
|
+
"@wordpress/i18n": "^6.3.1-next.a730c9c8c.0",
|
|
57
|
+
"@wordpress/icons": "^10.30.1-next.a730c9c8c.0",
|
|
58
|
+
"@wordpress/is-shallow-equal": "^5.30.1-next.a730c9c8c.0",
|
|
59
|
+
"@wordpress/keyboard-shortcuts": "^5.30.1-next.a730c9c8c.0",
|
|
60
|
+
"@wordpress/keycodes": "^4.30.1-next.a730c9c8c.0",
|
|
61
|
+
"@wordpress/notices": "^5.30.1-next.a730c9c8c.0",
|
|
62
|
+
"@wordpress/preferences": "^4.30.1-next.a730c9c8c.0",
|
|
63
|
+
"@wordpress/priority-queue": "^3.30.1-next.a730c9c8c.0",
|
|
64
|
+
"@wordpress/private-apis": "^1.30.1-next.a730c9c8c.0",
|
|
65
|
+
"@wordpress/rich-text": "^7.30.1-next.a730c9c8c.0",
|
|
66
|
+
"@wordpress/style-engine": "^2.30.1-next.a730c9c8c.0",
|
|
67
|
+
"@wordpress/token-list": "^3.30.1-next.a730c9c8c.0",
|
|
68
|
+
"@wordpress/upload-media": "^0.15.1-next.a730c9c8c.0",
|
|
69
|
+
"@wordpress/url": "^4.30.1-next.a730c9c8c.0",
|
|
70
|
+
"@wordpress/warning": "^3.30.1-next.a730c9c8c.0",
|
|
71
|
+
"@wordpress/wordcount": "^4.30.1-next.a730c9c8c.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": "85a580bd2c55f811c8969b42dbb10209d19d514e"
|
|
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,
|
|
@@ -53,9 +53,18 @@ const { Badge } = unlock( componentsPrivateApis );
|
|
|
53
53
|
* @param {Object} [props.blockType] Deprecated: Object containing block type data.
|
|
54
54
|
* @param {string} [props.className] Additional classes to apply to the card.
|
|
55
55
|
* @param {string} [props.name] Custom block name to display before the title.
|
|
56
|
+
* @param {Element} [props.children] Children.
|
|
56
57
|
* @return {Element} Block card component.
|
|
57
58
|
*/
|
|
58
|
-
function BlockCard( {
|
|
59
|
+
function BlockCard( {
|
|
60
|
+
title,
|
|
61
|
+
icon,
|
|
62
|
+
description,
|
|
63
|
+
blockType,
|
|
64
|
+
className,
|
|
65
|
+
name,
|
|
66
|
+
children,
|
|
67
|
+
} ) {
|
|
59
68
|
if ( blockType ) {
|
|
60
69
|
deprecated( '`blockType` property in `BlockCard component`', {
|
|
61
70
|
since: '5.7',
|
|
@@ -109,6 +118,7 @@ function BlockCard( { title, icon, description, blockType, className, name } ) {
|
|
|
109
118
|
{ description }
|
|
110
119
|
</Text>
|
|
111
120
|
) }
|
|
121
|
+
{ children }
|
|
112
122
|
</VStack>
|
|
113
123
|
</div>
|
|
114
124
|
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Button } from '@wordpress/components';
|
|
5
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import { store as blockEditorStore } from '../../store';
|
|
12
|
+
|
|
13
|
+
export default function EditContentsButton( { clientId } ) {
|
|
14
|
+
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
15
|
+
const { attributes } = useSelect(
|
|
16
|
+
( select ) => {
|
|
17
|
+
return {
|
|
18
|
+
attributes:
|
|
19
|
+
select( blockEditorStore ).getBlockAttributes( clientId ),
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
[ clientId ]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
if ( ! attributes?.metadata?.patternName ) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Button
|
|
31
|
+
className="block-editor-block-inspector-edit-contents-button"
|
|
32
|
+
__next40pxDefaultSize
|
|
33
|
+
variant="secondary"
|
|
34
|
+
onClick={ () => {
|
|
35
|
+
const { patternName, ...metadataWithoutPatternName } =
|
|
36
|
+
attributes?.metadata ?? {};
|
|
37
|
+
updateBlockAttributes( clientId, {
|
|
38
|
+
...attributes,
|
|
39
|
+
metadata: metadataWithoutPatternName,
|
|
40
|
+
} );
|
|
41
|
+
} }
|
|
42
|
+
>
|
|
43
|
+
{ __( 'Edit contents' ) }
|
|
44
|
+
</Button>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -13,6 +13,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
13
13
|
/**
|
|
14
14
|
* Internal dependencies
|
|
15
15
|
*/
|
|
16
|
+
import EditContentsButton from './edit-contents-button';
|
|
16
17
|
import SkipToSelectedBlock from '../skip-to-selected-block';
|
|
17
18
|
import BlockCard from '../block-card';
|
|
18
19
|
import MultiSelectionInspector from '../multi-selection-inspector';
|
|
@@ -247,7 +248,11 @@ const BlockInspectorSingleBlock = ( {
|
|
|
247
248
|
<BlockCard
|
|
248
249
|
{ ...blockInformation }
|
|
249
250
|
className={ blockInformation.isSynced && 'is-synced' }
|
|
250
|
-
|
|
251
|
+
>
|
|
252
|
+
{ window?.__experimentalContentOnlyPatternInsertion && (
|
|
253
|
+
<EditContentsButton clientId={ clientId } />
|
|
254
|
+
) }
|
|
255
|
+
</BlockCard>
|
|
251
256
|
<BlockVariationTransforms blockClientId={ clientId } />
|
|
252
257
|
{ showTabs && (
|
|
253
258
|
<InspectorControlsTabs
|
|
@@ -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,
|
|
@@ -101,14 +102,16 @@ function BlockSwitcherDropdownMenuContents( {
|
|
|
101
102
|
selectForMultipleBlocks( transformedBlocks );
|
|
102
103
|
}
|
|
103
104
|
/**
|
|
104
|
-
* The `
|
|
105
|
+
* The `isSynced` check is a stopgap solution here.
|
|
105
106
|
* Ideally, the Transforms API should handle this
|
|
106
107
|
* by allowing to exclude blocks from wildcard transformations.
|
|
107
108
|
*/
|
|
108
109
|
const isSingleBlock = blocks.length === 1;
|
|
109
|
-
const
|
|
110
|
+
const isSynced =
|
|
111
|
+
isSingleBlock &&
|
|
112
|
+
( isTemplatePart( blocks[ 0 ] ) || isReusableBlock( blocks[ 0 ] ) );
|
|
110
113
|
const hasPossibleBlockTransformations =
|
|
111
|
-
!! possibleBlockTransformations
|
|
114
|
+
!! possibleBlockTransformations?.length && canRemove && ! isSynced;
|
|
112
115
|
const hasPossibleBlockVariationTransformations =
|
|
113
116
|
!! blockVariationTransformations?.length;
|
|
114
117
|
const hasPatternTransformation = !! patterns?.length && canRemove;
|
|
@@ -196,6 +199,7 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
196
199
|
isReusable,
|
|
197
200
|
isTemplate,
|
|
198
201
|
isDisabled,
|
|
202
|
+
isSection,
|
|
199
203
|
} = useSelect(
|
|
200
204
|
( select ) => {
|
|
201
205
|
const {
|
|
@@ -204,7 +208,8 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
204
208
|
getBlockAttributes,
|
|
205
209
|
canRemoveBlocks,
|
|
206
210
|
getBlockEditingMode,
|
|
207
|
-
|
|
211
|
+
isSectionBlock,
|
|
212
|
+
} = unlock( select( blockEditorStore ) );
|
|
208
213
|
const { getBlockStyles, getBlockType, getActiveBlockVariation } =
|
|
209
214
|
select( blocksStore );
|
|
210
215
|
const _blocks = getBlocksByClientId( clientIds );
|
|
@@ -250,6 +255,7 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
250
255
|
_isSingleBlockSelected && isTemplatePart( _blocks[ 0 ] ),
|
|
251
256
|
hasContentOnlyLocking: _hasTemplateLock,
|
|
252
257
|
isDisabled: editingMode !== 'default',
|
|
258
|
+
isSection: isSectionBlock( clientIds[ 0 ] ),
|
|
253
259
|
};
|
|
254
260
|
},
|
|
255
261
|
[ clientIds ]
|
|
@@ -278,7 +284,10 @@ export const BlockSwitcher = ( { clientIds } ) => {
|
|
|
278
284
|
? blockTitle
|
|
279
285
|
: undefined;
|
|
280
286
|
|
|
287
|
+
const hideTransformsForSections =
|
|
288
|
+
window?.__experimentalContentOnlyPatternInsertion && isSection;
|
|
281
289
|
const hideDropdown =
|
|
290
|
+
hideTransformsForSections ||
|
|
282
291
|
isDisabled ||
|
|
283
292
|
( ! hasBlockStyles && ! canRemove ) ||
|
|
284
293
|
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
|
};
|