@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/background-image-control/index.js +2 -2
- package/build/components/background-image-control/index.js.map +2 -2
- package/build/components/block-list/block.js +3 -3
- package/build/components/block-list/block.js.map +2 -2
- package/build/components/block-list/index.js +2 -2
- package/build/components/block-list/index.js.map +1 -1
- package/build/components/block-quick-navigation/index.js +0 -1
- package/build/components/block-quick-navigation/index.js.map +2 -2
- package/build/components/global-styles/border-panel.js +1 -2
- package/build/components/global-styles/border-panel.js.map +2 -2
- package/build/components/global-styles/color-panel.js +1 -2
- package/build/components/global-styles/color-panel.js.map +2 -2
- package/build/components/global-styles/dimensions-panel.js +2 -3
- package/build/components/global-styles/dimensions-panel.js.map +2 -2
- package/build/components/global-styles/filters-panel.js +1 -2
- package/build/components/global-styles/filters-panel.js.map +2 -2
- package/build/components/global-styles/get-block-css-selector.js +78 -0
- package/build/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build/components/global-styles/hooks.js +95 -23
- package/build/components/global-styles/hooks.js.map +2 -2
- package/build/components/global-styles/index.js +14 -0
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +19 -3
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/typography-utils.js +49 -2
- package/build/components/global-styles/typography-utils.js.map +2 -2
- package/build/components/global-styles/use-global-styles-output.js +998 -0
- package/build/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build/components/global-styles/utils.js +377 -0
- package/build/components/global-styles/utils.js.map +2 -2
- package/build/components/rich-text/index.js +8 -7
- package/build/components/rich-text/index.js.map +2 -2
- package/build/hooks/allowed-blocks.js +50 -1
- package/build/hooks/allowed-blocks.js.map +2 -2
- package/build/hooks/block-bindings.js +111 -170
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/block-style-variation.js +10 -6
- package/build/hooks/block-style-variation.js.map +2 -2
- package/build/hooks/custom-class-name.js +1 -1
- package/build/hooks/custom-class-name.js.map +1 -1
- package/build/hooks/duotone.js +3 -3
- package/build/hooks/duotone.js.map +2 -2
- package/build/hooks/fit-text.js +33 -20
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +6 -5
- package/build/hooks/font-size.js.map +2 -2
- package/build/hooks/metadata.js +48 -2
- package/build/hooks/metadata.js.map +2 -2
- package/build/hooks/typography.js +11 -4
- package/build/hooks/typography.js.map +3 -3
- package/build/hooks/use-typography-props.js +2 -2
- package/build/hooks/use-typography-props.js.map +2 -2
- package/build/store/private-selectors.js +3 -3
- package/build/store/private-selectors.js.map +2 -2
- package/build/store/selectors.js +38 -13
- package/build/store/selectors.js.map +2 -2
- package/build/store/utils.js +2 -1
- package/build/store/utils.js.map +2 -2
- package/build/utils/fit-text-utils.js +4 -4
- package/build/utils/fit-text-utils.js.map +2 -2
- package/build-module/components/background-image-control/index.js +1 -1
- package/build-module/components/background-image-control/index.js.map +2 -2
- package/build-module/components/block-list/block.js +3 -3
- package/build-module/components/block-list/block.js.map +2 -2
- package/build-module/components/block-list/index.js +2 -2
- package/build-module/components/block-list/index.js.map +1 -1
- package/build-module/components/block-quick-navigation/index.js +0 -1
- package/build-module/components/block-quick-navigation/index.js.map +2 -2
- package/build-module/components/global-styles/border-panel.js +1 -2
- package/build-module/components/global-styles/border-panel.js.map +2 -2
- package/build-module/components/global-styles/color-panel.js +1 -2
- package/build-module/components/global-styles/color-panel.js.map +2 -2
- package/build-module/components/global-styles/dimensions-panel.js +1 -2
- package/build-module/components/global-styles/dimensions-panel.js.map +2 -2
- package/build-module/components/global-styles/filters-panel.js +1 -2
- package/build-module/components/global-styles/filters-panel.js.map +2 -2
- package/build-module/components/global-styles/get-block-css-selector.js +54 -0
- package/build-module/components/global-styles/get-block-css-selector.js.map +7 -0
- package/build-module/components/global-styles/hooks.js +95 -27
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +14 -0
- package/build-module/components/global-styles/index.js.map +2 -2
- package/build-module/components/global-styles/typography-panel.js +19 -3
- package/build-module/components/global-styles/typography-panel.js.map +2 -2
- package/build-module/components/global-styles/typography-utils.js +49 -1
- package/build-module/components/global-styles/typography-utils.js.map +2 -2
- package/build-module/components/global-styles/use-global-styles-output.js +979 -0
- package/build-module/components/global-styles/use-global-styles-output.js.map +7 -0
- package/build-module/components/global-styles/utils.js +364 -0
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/rich-text/index.js +8 -7
- package/build-module/components/rich-text/index.js.map +2 -2
- package/build-module/hooks/allowed-blocks.js +49 -1
- package/build-module/hooks/allowed-blocks.js.map +2 -2
- package/build-module/hooks/block-bindings.js +112 -172
- package/build-module/hooks/block-bindings.js.map +2 -2
- package/build-module/hooks/block-style-variation.js +12 -4
- package/build-module/hooks/block-style-variation.js.map +2 -2
- package/build-module/hooks/custom-class-name.js +1 -1
- package/build-module/hooks/custom-class-name.js.map +1 -1
- package/build-module/hooks/duotone.js +3 -3
- package/build-module/hooks/duotone.js.map +2 -2
- package/build-module/hooks/fit-text.js +34 -21
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +5 -4
- package/build-module/hooks/font-size.js.map +2 -2
- package/build-module/hooks/metadata.js +46 -1
- package/build-module/hooks/metadata.js.map +2 -2
- package/build-module/hooks/typography.js +11 -4
- package/build-module/hooks/typography.js.map +3 -3
- package/build-module/hooks/use-typography-props.js +1 -1
- package/build-module/hooks/use-typography-props.js.map +2 -2
- package/build-module/store/private-selectors.js +2 -2
- package/build-module/store/private-selectors.js.map +2 -2
- package/build-module/store/selectors.js +39 -14
- package/build-module/store/selectors.js.map +2 -2
- package/build-module/store/utils.js +3 -2
- package/build-module/store/utils.js.map +2 -2
- package/build-module/utils/fit-text-utils.js +4 -4
- package/build-module/utils/fit-text-utils.js.map +2 -2
- package/build-style/style-rtl.css +6 -10
- package/build-style/style.css +6 -10
- package/package.json +35 -36
- package/src/components/background-image-control/index.js +1 -1
- package/src/components/block-card/style.scss +1 -1
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-navigation/style.scss +1 -1
- package/src/components/block-quick-navigation/index.js +0 -1
- package/src/components/block-switcher/style.scss +1 -1
- package/src/components/color-palette/test/__snapshots__/control.js.snap +1 -1
- package/src/components/global-styles/border-panel.js +1 -2
- package/src/components/global-styles/color-panel.js +1 -2
- package/src/components/global-styles/color-panel.native.js +1 -1
- package/src/components/global-styles/dimensions-panel.js +1 -2
- package/src/components/global-styles/filters-panel.js +1 -2
- package/src/components/global-styles/get-block-css-selector.js +114 -0
- package/src/components/global-styles/hooks.js +108 -29
- package/src/components/global-styles/index.js +8 -0
- package/src/components/global-styles/test/typography-utils.js +806 -0
- package/src/components/global-styles/test/use-global-styles-output.js +1131 -0
- package/src/components/global-styles/test/utils.js +442 -1
- package/src/components/global-styles/typography-panel.js +27 -3
- package/src/components/global-styles/typography-utils.js +133 -0
- package/src/components/global-styles/use-global-styles-output.js +1487 -0
- package/src/components/global-styles/utils.js +537 -0
- package/src/components/inserter/style.scss +2 -2
- package/src/components/multi-selection-inspector/style.scss +1 -1
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/allowed-blocks.js +89 -1
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/block-style-variation.js +12 -4
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/duotone.js +3 -3
- package/src/hooks/fit-text.js +39 -30
- package/src/hooks/font-size.js +8 -4
- package/src/hooks/metadata.js +89 -0
- package/src/hooks/test/allowed-blocks.js +278 -0
- package/src/hooks/test/metadata.js +316 -0
- package/src/hooks/typography.js +15 -4
- package/src/hooks/use-typography-props.js +1 -1
- package/src/store/private-selectors.js +2 -2
- package/src/store/selectors.js +59 -21
- package/src/store/test/selectors.js +1 -1
- package/src/store/utils.js +2 -1
- package/src/style.scss +0 -1
- package/src/utils/fit-text-utils.js +4 -16
- package/tsconfig.json +0 -1
- package/src/components/block-quick-navigation/style.scss +0 -5
|
@@ -3,7 +3,7 @@ import { parse as grammarParse } from "@wordpress/block-serialization-default-pa
|
|
|
3
3
|
import { selectBlockPatternsKey } from "./private-keys";
|
|
4
4
|
import { unlock } from "../lock-unlock";
|
|
5
5
|
import { STORE_NAME } from "./constants";
|
|
6
|
-
import { getSectionRootClientId } from "./private-selectors";
|
|
6
|
+
import { getSectionRootClientId, isSectionBlock } from "./private-selectors";
|
|
7
7
|
import { getBlockEditingMode } from "./selectors";
|
|
8
8
|
import { INSERTER_PATTERN_TYPES } from "../components/inserter/block-patterns-tab/utils";
|
|
9
9
|
const isFiltered = Symbol("isFiltered");
|
|
@@ -112,7 +112,8 @@ const getInsertBlockTypeDependants = () => (state, rootClientId) => {
|
|
|
112
112
|
state.settings.allowedBlockTypes,
|
|
113
113
|
state.settings.templateLock,
|
|
114
114
|
getBlockEditingMode(state, rootClientId),
|
|
115
|
-
getSectionRootClientId(state)
|
|
115
|
+
getSectionRootClientId(state),
|
|
116
|
+
isSectionBlock(state, rootClientId)
|
|
116
117
|
];
|
|
117
118
|
};
|
|
118
119
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/store/utils.js"],
|
|
4
|
-
"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 { getBlockEditingMode } from './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 = () => ( state, rootClientId ) => {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tgetBlockEditingMode( state, rootClientId ),\n\t\tgetSectionRootClientId( state ),\n\t];\n};\n"],
|
|
5
|
-
"mappings": "AAGA,SAAS,aAAa;AACtB,SAAS,SAAS,oBAAoB;AAKtC,SAAS,8BAA8B;AACvC,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAC3B,SAAS,
|
|
4
|
+
"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, isSectionBlock } from './private-selectors';\nimport { getBlockEditingMode } from './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 = () => ( state, rootClientId ) => {\n\treturn [\n\t\tstate.blockListSettings[ rootClientId ],\n\t\tstate.blocks.byClientId.get( rootClientId ),\n\t\tstate.settings.allowedBlockTypes,\n\t\tstate.settings.templateLock,\n\t\tgetBlockEditingMode( state, rootClientId ),\n\t\tgetSectionRootClientId( state ),\n\t\tisSectionBlock( state, rootClientId ),\n\t];\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
function generateCSSRule(elementSelector, fontSize) {
|
|
2
2
|
return `${elementSelector} { font-size: ${fontSize}px !important; }`;
|
|
3
3
|
}
|
|
4
|
-
function findOptimalFontSize(textElement, elementSelector, applyStylesFn
|
|
4
|
+
function findOptimalFontSize(textElement, elementSelector, applyStylesFn) {
|
|
5
5
|
const alreadyHasScrollableHeight = textElement.scrollHeight > textElement.clientHeight;
|
|
6
6
|
let minSize = 5;
|
|
7
|
+
let maxSize = 600;
|
|
7
8
|
let bestSize = minSize;
|
|
8
9
|
while (minSize <= maxSize) {
|
|
9
10
|
const midSize = Math.floor((minSize + maxSize) / 2);
|
|
@@ -19,7 +20,7 @@ function findOptimalFontSize(textElement, elementSelector, applyStylesFn, maxSiz
|
|
|
19
20
|
}
|
|
20
21
|
return bestSize;
|
|
21
22
|
}
|
|
22
|
-
function optimizeFitText(textElement, elementSelector, applyStylesFn
|
|
23
|
+
function optimizeFitText(textElement, elementSelector, applyStylesFn) {
|
|
23
24
|
if (!textElement) {
|
|
24
25
|
return;
|
|
25
26
|
}
|
|
@@ -27,8 +28,7 @@ function optimizeFitText(textElement, elementSelector, applyStylesFn, maxSize) {
|
|
|
27
28
|
const optimalSize = findOptimalFontSize(
|
|
28
29
|
textElement,
|
|
29
30
|
elementSelector,
|
|
30
|
-
applyStylesFn
|
|
31
|
-
maxSize
|
|
31
|
+
applyStylesFn
|
|
32
32
|
);
|
|
33
33
|
const cssRule = generateCSSRule(elementSelector, optimalSize);
|
|
34
34
|
applyStylesFn(cssRule);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/fit-text-utils.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\n/**\n * Generate CSS rule for single text element.\n *\n * @param {string} elementSelector CSS selector for the text element\n * @param {number} fontSize Font size in pixels\n * @return {string} CSS rule string\n */\nfunction generateCSSRule( elementSelector, fontSize ) {\n\treturn `${ elementSelector } { font-size: ${ fontSize }px !important; }`;\n}\n\n/**\n * Find optimal font size using simple binary search between 5-600px.\n *\n * @param {HTMLElement} textElement The text element\n * @param {string} elementSelector CSS selector for the text element\n * @param {Function} applyStylesFn Function to apply test styles\n * @
|
|
5
|
-
"mappings": "AAYA,SAAS,gBAAiB,iBAAiB,UAAW;AACrD,SAAO,GAAI,eAAgB,iBAAkB,QAAS;AACvD;
|
|
4
|
+
"sourcesContent": ["/**\n * Shared utility functions for fit text functionality.\n * Uses callback-based approach for maximum code reuse between editor and frontend.\n */\n\n/**\n * Generate CSS rule for single text element.\n *\n * @param {string} elementSelector CSS selector for the text element\n * @param {number} fontSize Font size in pixels\n * @return {string} CSS rule string\n */\nfunction generateCSSRule( elementSelector, fontSize ) {\n\treturn `${ elementSelector } { font-size: ${ fontSize }px !important; }`;\n}\n\n/**\n * Find optimal font size using simple binary search between 5-600px.\n *\n * @param {HTMLElement} textElement The text element\n * @param {string} elementSelector CSS selector for the text element\n * @param {Function} applyStylesFn Function to apply test styles\n * @return {number} Optimal font size\n */\nfunction findOptimalFontSize( textElement, elementSelector, applyStylesFn ) {\n\tconst alreadyHasScrollableHeight =\n\t\ttextElement.scrollHeight > textElement.clientHeight;\n\tlet minSize = 5;\n\tlet maxSize = 600;\n\tlet bestSize = minSize;\n\n\twhile ( minSize <= maxSize ) {\n\t\tconst midSize = Math.floor( ( minSize + maxSize ) / 2 );\n\t\tapplyStylesFn( generateCSSRule( elementSelector, midSize ) );\n\n\t\tconst fitsWidth = textElement.scrollWidth <= textElement.clientWidth;\n\t\tconst fitsHeight =\n\t\t\talreadyHasScrollableHeight ||\n\t\t\ttextElement.scrollHeight <= textElement.clientHeight;\n\n\t\tif ( fitsWidth && fitsHeight ) {\n\t\t\tbestSize = midSize;\n\t\t\tminSize = midSize + 1;\n\t\t} else {\n\t\t\tmaxSize = midSize - 1;\n\t\t}\n\t}\n\n\treturn bestSize;\n}\n\n/**\n * Complete fit text optimization for a single text element.\n * Handles the full flow using callbacks for style management.\n *\n * @param {HTMLElement} textElement The text element (paragraph, heading, etc.)\n * @param {string} elementSelector CSS selector for the text element\n * @param {Function} applyStylesFn Function to apply CSS styles (pass empty string to clear)\n */\nexport function optimizeFitText( textElement, elementSelector, applyStylesFn ) {\n\tif ( ! textElement ) {\n\t\treturn;\n\t}\n\n\tapplyStylesFn( '' );\n\n\tconst optimalSize = findOptimalFontSize(\n\t\ttextElement,\n\t\telementSelector,\n\t\tapplyStylesFn\n\t);\n\n\tconst cssRule = generateCSSRule( elementSelector, optimalSize );\n\tapplyStylesFn( cssRule );\n}\n"],
|
|
5
|
+
"mappings": "AAYA,SAAS,gBAAiB,iBAAiB,UAAW;AACrD,SAAO,GAAI,eAAgB,iBAAkB,QAAS;AACvD;AAUA,SAAS,oBAAqB,aAAa,iBAAiB,eAAgB;AAC3E,QAAM,6BACL,YAAY,eAAe,YAAY;AACxC,MAAI,UAAU;AACd,MAAI,UAAU;AACd,MAAI,WAAW;AAEf,SAAQ,WAAW,SAAU;AAC5B,UAAM,UAAU,KAAK,OAAS,UAAU,WAAY,CAAE;AACtD,kBAAe,gBAAiB,iBAAiB,OAAQ,CAAE;AAE3D,UAAM,YAAY,YAAY,eAAe,YAAY;AACzD,UAAM,aACL,8BACA,YAAY,gBAAgB,YAAY;AAEzC,QAAK,aAAa,YAAa;AAC9B,iBAAW;AACX,gBAAU,UAAU;AAAA,IACrB,OAAO;AACN,gBAAU,UAAU;AAAA,IACrB;AAAA,EACD;AAEA,SAAO;AACR;AAUO,SAAS,gBAAiB,aAAa,iBAAiB,eAAgB;AAC9E,MAAK,CAAE,aAAc;AACpB;AAAA,EACD;AAEA,gBAAe,EAAG;AAElB,QAAM,cAAc;AAAA,IACnB;AAAA,IACA;AAAA,IACA;AAAA,EACD;AAEA,QAAM,UAAU,gBAAiB,iBAAiB,WAAY;AAC9D,gBAAe,OAAQ;AACxB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -661,7 +661,7 @@ iframe[name=editor-canvas] {
|
|
|
661
661
|
}
|
|
662
662
|
|
|
663
663
|
.block-editor-block-card__title {
|
|
664
|
-
font-weight:
|
|
664
|
+
font-weight: 500;
|
|
665
665
|
display: flex;
|
|
666
666
|
align-items: center;
|
|
667
667
|
flex-wrap: wrap;
|
|
@@ -979,7 +979,7 @@ iframe[name=editor-canvas] {
|
|
|
979
979
|
color: #757575;
|
|
980
980
|
text-transform: uppercase;
|
|
981
981
|
font-size: 11px;
|
|
982
|
-
font-weight:
|
|
982
|
+
font-weight: 500;
|
|
983
983
|
}
|
|
984
984
|
|
|
985
985
|
.block-editor-block-patterns-list__list-item {
|
|
@@ -1132,10 +1132,6 @@ iframe[name=editor-canvas] {
|
|
|
1132
1132
|
z-index: 1;
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
-
.block-editor-block-quick-navigation__item {
|
|
1136
|
-
font-weight: 400;
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1135
|
.block-editor-block-rename-modal {
|
|
1140
1136
|
z-index: 1000001;
|
|
1141
1137
|
}
|
|
@@ -1271,7 +1267,7 @@ iframe[name=editor-canvas] {
|
|
|
1271
1267
|
color: #757575;
|
|
1272
1268
|
text-transform: uppercase;
|
|
1273
1269
|
font-size: 11px;
|
|
1274
|
-
font-weight:
|
|
1270
|
+
font-weight: 500;
|
|
1275
1271
|
}
|
|
1276
1272
|
|
|
1277
1273
|
.block-editor-block-contextual-toolbar .components-button.block-editor-block-switcher__no-switcher-icon {
|
|
@@ -3114,7 +3110,7 @@ iframe[name=editor-canvas] {
|
|
|
3114
3110
|
}
|
|
3115
3111
|
|
|
3116
3112
|
.block-editor-multi-selection-inspector__card-title {
|
|
3117
|
-
font-weight:
|
|
3113
|
+
font-weight: 500;
|
|
3118
3114
|
}
|
|
3119
3115
|
|
|
3120
3116
|
.block-editor-multi-selection-inspector__card .block-editor-block-icon {
|
|
@@ -3921,7 +3917,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3921
3917
|
color: #757575;
|
|
3922
3918
|
text-transform: uppercase;
|
|
3923
3919
|
font-size: 11px;
|
|
3924
|
-
font-weight:
|
|
3920
|
+
font-weight: 500;
|
|
3925
3921
|
}
|
|
3926
3922
|
|
|
3927
3923
|
.block-editor-inserter__panel-dropdown select.components-select-control__input.components-select-control__input.components-select-control__input {
|
|
@@ -4192,7 +4188,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
4192
4188
|
}
|
|
4193
4189
|
|
|
4194
4190
|
.components-heading.block-editor-inserter__patterns-category-panel-title {
|
|
4195
|
-
font-weight:
|
|
4191
|
+
font-weight: 500;
|
|
4196
4192
|
}
|
|
4197
4193
|
|
|
4198
4194
|
.block-editor-inserter__patterns-explore-button.components-button,
|
package/build-style/style.css
CHANGED
|
@@ -661,7 +661,7 @@ iframe[name=editor-canvas] {
|
|
|
661
661
|
}
|
|
662
662
|
|
|
663
663
|
.block-editor-block-card__title {
|
|
664
|
-
font-weight:
|
|
664
|
+
font-weight: 500;
|
|
665
665
|
display: flex;
|
|
666
666
|
align-items: center;
|
|
667
667
|
flex-wrap: wrap;
|
|
@@ -979,7 +979,7 @@ iframe[name=editor-canvas] {
|
|
|
979
979
|
color: #757575;
|
|
980
980
|
text-transform: uppercase;
|
|
981
981
|
font-size: 11px;
|
|
982
|
-
font-weight:
|
|
982
|
+
font-weight: 500;
|
|
983
983
|
}
|
|
984
984
|
|
|
985
985
|
.block-editor-block-patterns-list__list-item {
|
|
@@ -1132,10 +1132,6 @@ iframe[name=editor-canvas] {
|
|
|
1132
1132
|
z-index: 1;
|
|
1133
1133
|
}
|
|
1134
1134
|
|
|
1135
|
-
.block-editor-block-quick-navigation__item {
|
|
1136
|
-
font-weight: 400;
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
1135
|
.block-editor-block-rename-modal {
|
|
1140
1136
|
z-index: 1000001;
|
|
1141
1137
|
}
|
|
@@ -1271,7 +1267,7 @@ iframe[name=editor-canvas] {
|
|
|
1271
1267
|
color: #757575;
|
|
1272
1268
|
text-transform: uppercase;
|
|
1273
1269
|
font-size: 11px;
|
|
1274
|
-
font-weight:
|
|
1270
|
+
font-weight: 500;
|
|
1275
1271
|
}
|
|
1276
1272
|
|
|
1277
1273
|
.block-editor-block-contextual-toolbar .components-button.block-editor-block-switcher__no-switcher-icon {
|
|
@@ -3116,7 +3112,7 @@ iframe[name=editor-canvas] {
|
|
|
3116
3112
|
}
|
|
3117
3113
|
|
|
3118
3114
|
.block-editor-multi-selection-inspector__card-title {
|
|
3119
|
-
font-weight:
|
|
3115
|
+
font-weight: 500;
|
|
3120
3116
|
}
|
|
3121
3117
|
|
|
3122
3118
|
.block-editor-multi-selection-inspector__card .block-editor-block-icon {
|
|
@@ -3923,7 +3919,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
3923
3919
|
color: #757575;
|
|
3924
3920
|
text-transform: uppercase;
|
|
3925
3921
|
font-size: 11px;
|
|
3926
|
-
font-weight:
|
|
3922
|
+
font-weight: 500;
|
|
3927
3923
|
}
|
|
3928
3924
|
|
|
3929
3925
|
.block-editor-inserter__panel-dropdown select.components-select-control__input.components-select-control__input.components-select-control__input {
|
|
@@ -4194,7 +4190,7 @@ div.block-editor-bindings__panel button:hover .block-editor-bindings__item span
|
|
|
4194
4190
|
}
|
|
4195
4191
|
|
|
4196
4192
|
.components-heading.block-editor-inserter__patterns-category-panel-title {
|
|
4197
|
-
font-weight:
|
|
4193
|
+
font-weight: 500;
|
|
4198
4194
|
}
|
|
4199
4195
|
|
|
4200
4196
|
.block-editor-inserter__patterns-explore-button.components-button,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.6.
|
|
3
|
+
"version": "15.6.2",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -56,40 +56,39 @@
|
|
|
56
56
|
"@emotion/react": "^11.7.1",
|
|
57
57
|
"@emotion/styled": "^11.6.0",
|
|
58
58
|
"@react-spring/web": "^9.4.5",
|
|
59
|
-
"@wordpress/a11y": "^4.33.1
|
|
60
|
-
"@wordpress/api-fetch": "^7.33.1
|
|
61
|
-
"@wordpress/base-styles": "^6.
|
|
62
|
-
"@wordpress/blob": "^4.33.1
|
|
63
|
-
"@wordpress/block-serialization-default-parser": "^5.33.1
|
|
64
|
-
"@wordpress/blocks": "^15.6.1
|
|
65
|
-
"@wordpress/commands": "^1.33.1
|
|
66
|
-
"@wordpress/components": "^30.
|
|
67
|
-
"@wordpress/compose": "^7.33.1
|
|
68
|
-
"@wordpress/data": "^10.33.1
|
|
69
|
-
"@wordpress/date": "^5.33.1
|
|
70
|
-
"@wordpress/deprecated": "^4.33.1
|
|
71
|
-
"@wordpress/dom": "^4.33.1
|
|
72
|
-
"@wordpress/element": "^6.33.1
|
|
73
|
-
"@wordpress/escape-html": "^3.33.1
|
|
74
|
-
"@wordpress/
|
|
75
|
-
"@wordpress/
|
|
76
|
-
"@wordpress/
|
|
77
|
-
"@wordpress/
|
|
78
|
-
"@wordpress/
|
|
79
|
-
"@wordpress/
|
|
80
|
-
"@wordpress/
|
|
81
|
-
"@wordpress/
|
|
82
|
-
"@wordpress/
|
|
83
|
-
"@wordpress/
|
|
84
|
-
"@wordpress/
|
|
85
|
-
"@wordpress/
|
|
86
|
-
"@wordpress/
|
|
87
|
-
"@wordpress/
|
|
88
|
-
"@wordpress/
|
|
89
|
-
"@wordpress/
|
|
90
|
-
"@wordpress/
|
|
91
|
-
"@wordpress/
|
|
92
|
-
"@wordpress/wordcount": "^4.33.1-next.36001005c.0",
|
|
59
|
+
"@wordpress/a11y": "^4.33.1",
|
|
60
|
+
"@wordpress/api-fetch": "^7.33.1",
|
|
61
|
+
"@wordpress/base-styles": "^6.9.1",
|
|
62
|
+
"@wordpress/blob": "^4.33.1",
|
|
63
|
+
"@wordpress/block-serialization-default-parser": "^5.33.1",
|
|
64
|
+
"@wordpress/blocks": "^15.6.1",
|
|
65
|
+
"@wordpress/commands": "^1.33.1",
|
|
66
|
+
"@wordpress/components": "^30.6.1",
|
|
67
|
+
"@wordpress/compose": "^7.33.1",
|
|
68
|
+
"@wordpress/data": "^10.33.1",
|
|
69
|
+
"@wordpress/date": "^5.33.1",
|
|
70
|
+
"@wordpress/deprecated": "^4.33.1",
|
|
71
|
+
"@wordpress/dom": "^4.33.1",
|
|
72
|
+
"@wordpress/element": "^6.33.1",
|
|
73
|
+
"@wordpress/escape-html": "^3.33.1",
|
|
74
|
+
"@wordpress/hooks": "^4.33.1",
|
|
75
|
+
"@wordpress/html-entities": "^4.33.1",
|
|
76
|
+
"@wordpress/i18n": "^6.6.1",
|
|
77
|
+
"@wordpress/icons": "^11.0.1",
|
|
78
|
+
"@wordpress/is-shallow-equal": "^5.33.1",
|
|
79
|
+
"@wordpress/keyboard-shortcuts": "^5.33.1",
|
|
80
|
+
"@wordpress/keycodes": "^4.33.1",
|
|
81
|
+
"@wordpress/notices": "^5.33.1",
|
|
82
|
+
"@wordpress/preferences": "^4.33.1",
|
|
83
|
+
"@wordpress/priority-queue": "^3.33.1",
|
|
84
|
+
"@wordpress/private-apis": "^1.33.1",
|
|
85
|
+
"@wordpress/rich-text": "^7.33.1",
|
|
86
|
+
"@wordpress/style-engine": "^2.33.1",
|
|
87
|
+
"@wordpress/token-list": "^3.33.1",
|
|
88
|
+
"@wordpress/upload-media": "^0.18.1",
|
|
89
|
+
"@wordpress/url": "^4.33.1",
|
|
90
|
+
"@wordpress/warning": "^3.33.1",
|
|
91
|
+
"@wordpress/wordcount": "^4.33.1",
|
|
93
92
|
"change-case": "^4.1.2",
|
|
94
93
|
"clsx": "^2.1.1",
|
|
95
94
|
"colord": "^2.7.0",
|
|
@@ -112,5 +111,5 @@
|
|
|
112
111
|
"publishConfig": {
|
|
113
112
|
"access": "public"
|
|
114
113
|
},
|
|
115
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "45005cc254bab59182927e35a68cd22f6320634d"
|
|
116
115
|
}
|
|
@@ -33,11 +33,11 @@ import { useRef, useState, useEffect, useMemo } from '@wordpress/element';
|
|
|
33
33
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
34
34
|
import { focus } from '@wordpress/dom';
|
|
35
35
|
import { isBlobURL } from '@wordpress/blob';
|
|
36
|
-
import { getResolvedValue } from '@wordpress/global-styles-engine';
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
* Internal dependencies
|
|
40
39
|
*/
|
|
40
|
+
import { getResolvedValue } from '../global-styles/utils';
|
|
41
41
|
import { hasBackgroundImageValue } from '../global-styles/background-panel';
|
|
42
42
|
import { setImmutably } from '../../utils/object';
|
|
43
43
|
import MediaReplaceFlow from '../media-replace-flow';
|
|
@@ -633,6 +633,7 @@ function BlockListBlockProvider( props ) {
|
|
|
633
633
|
: undefined,
|
|
634
634
|
blockTitle: blockType?.title,
|
|
635
635
|
isBlockHidden: attributes?.metadata?.blockVisibility === false,
|
|
636
|
+
bindableAttributes,
|
|
636
637
|
};
|
|
637
638
|
|
|
638
639
|
// When in preview mode, we can avoid a lot of selection and
|
|
@@ -718,7 +719,6 @@ function BlockListBlockProvider( props ) {
|
|
|
718
719
|
? blocksWithSameName[ 0 ]
|
|
719
720
|
: false,
|
|
720
721
|
isBlockHidden: _isBlockHidden( clientId ),
|
|
721
|
-
bindableAttributes,
|
|
722
722
|
};
|
|
723
723
|
},
|
|
724
724
|
[ clientId, rootClientId ]
|
|
@@ -184,7 +184,7 @@ function Items( {
|
|
|
184
184
|
getTemplateLock,
|
|
185
185
|
getBlockEditingMode,
|
|
186
186
|
isSectionBlock,
|
|
187
|
-
|
|
187
|
+
isContainerInsertableToInContentOnlyMode,
|
|
188
188
|
getBlockName,
|
|
189
189
|
isZoomOut: _isZoomOut,
|
|
190
190
|
canInsertBlockType,
|
|
@@ -223,7 +223,7 @@ function Items( {
|
|
|
223
223
|
isZoomOut: _isZoomOut(),
|
|
224
224
|
shouldRenderAppender:
|
|
225
225
|
( ! isSectionBlock( rootClientId ) ||
|
|
226
|
-
|
|
226
|
+
isContainerInsertableToInContentOnlyMode(
|
|
227
227
|
getBlockName( selectedBlockClientId ),
|
|
228
228
|
rootClientId
|
|
229
229
|
) ) &&
|
|
@@ -11,14 +11,13 @@ import {
|
|
|
11
11
|
} from '@wordpress/components';
|
|
12
12
|
import { useCallback, useMemo } from '@wordpress/element';
|
|
13
13
|
import { __ } from '@wordpress/i18n';
|
|
14
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Internal dependencies
|
|
18
17
|
*/
|
|
19
18
|
import BorderRadiusControl from '../border-radius-control';
|
|
20
19
|
import { useColorsPerOrigin } from './hooks';
|
|
21
|
-
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
20
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
22
21
|
import { setImmutably } from '../../utils/object';
|
|
23
22
|
import { useBorderPanelLabel } from '../../hooks/border';
|
|
24
23
|
import { ShadowPopover, useShadowPresets } from './shadow-panel-components';
|
|
@@ -21,14 +21,13 @@ import {
|
|
|
21
21
|
} from '@wordpress/components';
|
|
22
22
|
import { useCallback, useRef } from '@wordpress/element';
|
|
23
23
|
import { __ } from '@wordpress/i18n';
|
|
24
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Internal dependencies
|
|
28
27
|
*/
|
|
29
28
|
import ColorGradientControl from '../colors-gradients/control';
|
|
30
29
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
31
|
-
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
30
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
32
31
|
import { setImmutably } from '../../utils/object';
|
|
33
32
|
import { unlock } from '../../lock-unlock';
|
|
34
33
|
import { reset as resetIcon } from '@wordpress/icons';
|
|
@@ -5,13 +5,13 @@ import { useSelect } from '@wordpress/data';
|
|
|
5
5
|
import { useEffect, useState, useMemo, useCallback } from '@wordpress/element';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Internal dependencies
|
|
12
11
|
*/
|
|
13
12
|
import PanelColorGradientSettings from '../colors-gradients/panel-color-gradient-settings';
|
|
14
13
|
import { useColorsPerOrigin, useGradientsPerOrigin } from './hooks';
|
|
14
|
+
import { getValueFromVariable } from './utils';
|
|
15
15
|
import { setImmutably } from '../../utils/object';
|
|
16
16
|
import ContrastChecker from '../contrast-checker';
|
|
17
17
|
import InspectorControls from '../inspector-controls';
|
|
@@ -17,12 +17,11 @@ import {
|
|
|
17
17
|
} from '@wordpress/components';
|
|
18
18
|
import { Icon, alignNone, stretchWide } from '@wordpress/icons';
|
|
19
19
|
import { useCallback, useState, Platform } from '@wordpress/element';
|
|
20
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Internal dependencies
|
|
24
23
|
*/
|
|
25
|
-
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
24
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
26
25
|
import SpacingSizesControl from '../spacing-sizes-control';
|
|
27
26
|
import HeightControl from '../height-control';
|
|
28
27
|
import ChildLayoutControl from '../child-layout-control';
|
|
@@ -24,12 +24,11 @@ import {
|
|
|
24
24
|
import { __, _x } from '@wordpress/i18n';
|
|
25
25
|
import { useCallback, useMemo, useRef } from '@wordpress/element';
|
|
26
26
|
import { reset as resetIcon } from '@wordpress/icons';
|
|
27
|
-
import { getValueFromVariable } from '@wordpress/global-styles-engine';
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* Internal dependencies
|
|
31
30
|
*/
|
|
32
|
-
import { useToolsPanelDropdownMenuProps } from './utils';
|
|
31
|
+
import { getValueFromVariable, useToolsPanelDropdownMenuProps } from './utils';
|
|
33
32
|
import { setImmutably } from '../../utils/object';
|
|
34
33
|
|
|
35
34
|
const EMPTY_ARRAY = [];
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { scopeSelector } from './utils';
|
|
5
|
+
import { getValueFromObjectPath } from '../../utils/object';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Determine the CSS selector for the block type and target provided, returning
|
|
9
|
+
* it if available.
|
|
10
|
+
*
|
|
11
|
+
* @param {import('@wordpress/blocks').Block} blockType The block's type.
|
|
12
|
+
* @param {string|string[]} target The desired selector's target e.g. `root`, delimited string, or array path.
|
|
13
|
+
* @param {Object} options Options object.
|
|
14
|
+
* @param {boolean} options.fallback Whether or not to fallback to broader selector.
|
|
15
|
+
*
|
|
16
|
+
* @return {?string} The CSS selector or `null` if no selector available.
|
|
17
|
+
*/
|
|
18
|
+
export function getBlockCSSSelector(
|
|
19
|
+
blockType,
|
|
20
|
+
target = 'root',
|
|
21
|
+
options = {}
|
|
22
|
+
) {
|
|
23
|
+
if ( ! target ) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const { fallback = false } = options;
|
|
28
|
+
const { name, selectors, supports } = blockType;
|
|
29
|
+
|
|
30
|
+
const hasSelectors = selectors && Object.keys( selectors ).length > 0;
|
|
31
|
+
const path = Array.isArray( target ) ? target.join( '.' ) : target;
|
|
32
|
+
|
|
33
|
+
// Root selector.
|
|
34
|
+
|
|
35
|
+
// Calculated before returning as it can be used as a fallback for feature
|
|
36
|
+
// selectors later on.
|
|
37
|
+
let rootSelector = null;
|
|
38
|
+
|
|
39
|
+
if ( hasSelectors && selectors.root ) {
|
|
40
|
+
// Use the selectors API if available.
|
|
41
|
+
rootSelector = selectors?.root;
|
|
42
|
+
} else if ( supports?.__experimentalSelector ) {
|
|
43
|
+
// Use the old experimental selector supports property if set.
|
|
44
|
+
rootSelector = supports.__experimentalSelector;
|
|
45
|
+
} else {
|
|
46
|
+
// If no root selector found, generate default block class selector.
|
|
47
|
+
rootSelector =
|
|
48
|
+
'.wp-block-' + name.replace( 'core/', '' ).replace( '/', '-' );
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Return selector if it's the root target we are looking for.
|
|
52
|
+
if ( path === 'root' ) {
|
|
53
|
+
return rootSelector;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// If target is not `root` or `duotone` we have a feature or subfeature
|
|
57
|
+
// as the target. If the target is a string convert to an array.
|
|
58
|
+
const pathArray = Array.isArray( target ) ? target : target.split( '.' );
|
|
59
|
+
|
|
60
|
+
// Feature selectors ( may fallback to root selector );
|
|
61
|
+
if ( pathArray.length === 1 ) {
|
|
62
|
+
const fallbackSelector = fallback ? rootSelector : null;
|
|
63
|
+
|
|
64
|
+
// Prefer the selectors API if available.
|
|
65
|
+
if ( hasSelectors ) {
|
|
66
|
+
// Get selector from either `feature.root` or shorthand path.
|
|
67
|
+
const featureSelector =
|
|
68
|
+
getValueFromObjectPath( selectors, `${ path }.root`, null ) ||
|
|
69
|
+
getValueFromObjectPath( selectors, path, null );
|
|
70
|
+
|
|
71
|
+
// Return feature selector if found or any available fallback.
|
|
72
|
+
return featureSelector || fallbackSelector;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// Try getting old experimental supports selector value.
|
|
76
|
+
const featureSelector = getValueFromObjectPath(
|
|
77
|
+
supports,
|
|
78
|
+
`${ path }.__experimentalSelector`,
|
|
79
|
+
null
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
// If nothing to work with, provide fallback selector if available.
|
|
83
|
+
if ( ! featureSelector ) {
|
|
84
|
+
return fallbackSelector;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Scope the feature selector by the block's root selector.
|
|
88
|
+
return scopeSelector( rootSelector, featureSelector );
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Subfeature selector.
|
|
92
|
+
// This may fallback either to parent feature or root selector.
|
|
93
|
+
let subfeatureSelector;
|
|
94
|
+
|
|
95
|
+
// Use selectors API if available.
|
|
96
|
+
if ( hasSelectors ) {
|
|
97
|
+
subfeatureSelector = getValueFromObjectPath( selectors, path, null );
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Only return if we have a subfeature selector.
|
|
101
|
+
if ( subfeatureSelector ) {
|
|
102
|
+
return subfeatureSelector;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// To this point we don't have a subfeature selector. If a fallback has been
|
|
106
|
+
// requested, remove subfeature from target path and return results of a
|
|
107
|
+
// call for the parent feature's selector.
|
|
108
|
+
if ( fallback ) {
|
|
109
|
+
return getBlockCSSSelector( blockType, pathArray[ 0 ], options );
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// We tried.
|
|
113
|
+
return null;
|
|
114
|
+
}
|