@wordpress/block-editor 15.6.0 → 15.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/components/block-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/global-styles/typography-panel.js +18 -1
- package/build/components/global-styles/typography-panel.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/block-bindings.js +111 -170
- package/build/hooks/block-bindings.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/fit-text.js +31 -18
- package/build/hooks/fit-text.js.map +2 -2
- package/build/hooks/font-size.js +4 -3
- 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/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/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/global-styles/typography-panel.js +18 -1
- package/build-module/components/global-styles/typography-panel.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/block-bindings.js +112 -172
- package/build-module/hooks/block-bindings.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/fit-text.js +32 -19
- package/build-module/hooks/fit-text.js.map +2 -2
- package/build-module/hooks/font-size.js +4 -3
- 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/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/package.json +35 -35
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/global-styles/typography-panel.js +26 -1
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/fit-text.js +37 -28
- package/src/hooks/font-size.js +7 -3
- package/src/hooks/metadata.js +89 -0
- package/src/hooks/test/metadata.js +316 -0
- package/src/hooks/typography.js +15 -4
- 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/utils/fit-text-utils.js +4 -16
|
@@ -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": "AAGA,SAAS,aAAa;AACtB,SAAS,SAAS,oBAAoB;AAKtC,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OAAQ,UAAW,CAAE,EAAE,kBAAkB;AAAA,EAClD;AACD;AAEO,MAAM,+BAA+B,MAAM,CAAE,OAAO,iBAAkB;AAC5E,SAAO;AAAA,IACN,MAAM,kBAAmB,YAAa;AAAA,IACtC,MAAM,OAAO,WAAW,IAAK,YAAa;AAAA,IAC1C,MAAM,SAAS;AAAA,IACf,MAAM,SAAS;AAAA,IACf,oBAAqB,OAAO,YAAa;AAAA,IACzC,uBAAwB,KAAM;AAAA,IAC9B,eAAgB,OAAO,YAAa;AAAA,EACrC;AACD;",
|
|
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.6.
|
|
3
|
+
"version": "15.6.1",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -56,39 +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.
|
|
60
|
-
"@wordpress/api-fetch": "^7.33.
|
|
61
|
-
"@wordpress/base-styles": "^6.9.
|
|
62
|
-
"@wordpress/blob": "^4.33.
|
|
63
|
-
"@wordpress/block-serialization-default-parser": "^5.33.
|
|
64
|
-
"@wordpress/blocks": "^15.6.
|
|
65
|
-
"@wordpress/commands": "^1.33.
|
|
66
|
-
"@wordpress/components": "^30.6.
|
|
67
|
-
"@wordpress/compose": "^7.33.
|
|
68
|
-
"@wordpress/data": "^10.33.
|
|
69
|
-
"@wordpress/date": "^5.33.
|
|
70
|
-
"@wordpress/deprecated": "^4.33.
|
|
71
|
-
"@wordpress/dom": "^4.33.
|
|
72
|
-
"@wordpress/element": "^6.33.
|
|
73
|
-
"@wordpress/escape-html": "^3.33.
|
|
74
|
-
"@wordpress/hooks": "^4.33.
|
|
75
|
-
"@wordpress/html-entities": "^4.33.
|
|
76
|
-
"@wordpress/i18n": "^6.6.
|
|
77
|
-
"@wordpress/icons": "^11.0.
|
|
78
|
-
"@wordpress/is-shallow-equal": "^5.33.
|
|
79
|
-
"@wordpress/keyboard-shortcuts": "^5.33.
|
|
80
|
-
"@wordpress/keycodes": "^4.33.
|
|
81
|
-
"@wordpress/notices": "^5.33.
|
|
82
|
-
"@wordpress/preferences": "^4.33.
|
|
83
|
-
"@wordpress/priority-queue": "^3.33.
|
|
84
|
-
"@wordpress/private-apis": "^1.33.
|
|
85
|
-
"@wordpress/rich-text": "^7.33.
|
|
86
|
-
"@wordpress/style-engine": "^2.33.
|
|
87
|
-
"@wordpress/token-list": "^3.33.
|
|
88
|
-
"@wordpress/upload-media": "^0.18.
|
|
89
|
-
"@wordpress/url": "^4.33.
|
|
90
|
-
"@wordpress/warning": "^3.33.
|
|
91
|
-
"@wordpress/wordcount": "^4.33.
|
|
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",
|
|
92
92
|
"change-case": "^4.1.2",
|
|
93
93
|
"clsx": "^2.1.1",
|
|
94
94
|
"colord": "^2.7.0",
|
|
@@ -111,5 +111,5 @@
|
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
},
|
|
114
|
-
"gitHead": "
|
|
114
|
+
"gitHead": "5f84bafdec1bed05247c1080c12f6a237951b862"
|
|
115
115
|
}
|
|
@@ -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
|
) ) &&
|
|
@@ -212,6 +212,30 @@ export default function TypographyPanel( {
|
|
|
212
212
|
const mergedFontSizes = getMergedFontSizes( settings );
|
|
213
213
|
|
|
214
214
|
const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
|
|
215
|
+
|
|
216
|
+
// Extract the slug from the CSS custom property if it exists
|
|
217
|
+
const currentFontSizeSlug = ( () => {
|
|
218
|
+
const rawValue = inheritedValue?.typography?.fontSize;
|
|
219
|
+
if ( ! rawValue || typeof rawValue !== 'string' ) {
|
|
220
|
+
return undefined;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Block supports use `var:preset` format.
|
|
224
|
+
if ( rawValue.startsWith( 'var:preset|font-size|' ) ) {
|
|
225
|
+
return rawValue.replace( 'var:preset|font-size|', '' );
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// Global styles data uses `var(--wp--preset)` format.
|
|
229
|
+
const cssVarMatch = rawValue.match(
|
|
230
|
+
/^var\(--wp--preset--font-size--([^)]+)\)$/
|
|
231
|
+
);
|
|
232
|
+
if ( cssVarMatch ) {
|
|
233
|
+
return cssVarMatch[ 1 ];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return undefined;
|
|
237
|
+
} )();
|
|
238
|
+
|
|
215
239
|
const setFontSize = ( newValue, metadata ) => {
|
|
216
240
|
const actualValue = !! metadata?.slug
|
|
217
241
|
? `var:preset|font-size|${ metadata?.slug }`
|
|
@@ -432,7 +456,8 @@ export default function TypographyPanel( {
|
|
|
432
456
|
panelId={ panelId }
|
|
433
457
|
>
|
|
434
458
|
<FontSizePicker
|
|
435
|
-
value={ fontSize }
|
|
459
|
+
value={ currentFontSizeSlug || fontSize }
|
|
460
|
+
valueMode={ currentFontSizeSlug ? 'slug' : 'literal' }
|
|
436
461
|
onChange={ setFontSize }
|
|
437
462
|
fontSizes={ mergedFontSizes }
|
|
438
463
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
@@ -41,6 +41,7 @@ import { getAllowedFormats } from './utils';
|
|
|
41
41
|
import { Content, valueToHTMLString } from './content';
|
|
42
42
|
import { withDeprecations } from './with-deprecations';
|
|
43
43
|
import BlockContext from '../block-context';
|
|
44
|
+
import { PrivateBlockContext } from '../block-list/private-block-context';
|
|
44
45
|
|
|
45
46
|
export const keyboardShortcutContext = createContext();
|
|
46
47
|
keyboardShortcutContext.displayName = 'keyboardShortcutContext';
|
|
@@ -124,9 +125,10 @@ export function RichTextWrapper(
|
|
|
124
125
|
const instanceId = useInstanceId( RichTextWrapper );
|
|
125
126
|
const anchorRef = useRef();
|
|
126
127
|
const context = useBlockEditContext();
|
|
127
|
-
const { clientId, isSelected: isBlockSelected
|
|
128
|
+
const { clientId, isSelected: isBlockSelected } = context;
|
|
128
129
|
const blockBindings = context[ blockBindingsKey ];
|
|
129
130
|
const blockContext = useContext( BlockContext );
|
|
131
|
+
const { bindableAttributes } = useContext( PrivateBlockContext );
|
|
130
132
|
const registry = useRegistry();
|
|
131
133
|
const selector = ( select ) => {
|
|
132
134
|
// Avoid subscribing to the block editor store if the block is not
|
|
@@ -171,15 +173,7 @@ export function RichTextWrapper(
|
|
|
171
173
|
|
|
172
174
|
const { disableBoundBlock, bindingsPlaceholder, bindingsLabel } = useSelect(
|
|
173
175
|
( select ) => {
|
|
174
|
-
|
|
175
|
-
select( blockEditorStore ).getSettings();
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
! blockBindings?.[ identifier ] ||
|
|
179
|
-
! (
|
|
180
|
-
blockName in __experimentalBlockBindingsSupportedAttributes
|
|
181
|
-
)
|
|
182
|
-
) {
|
|
176
|
+
if ( ! blockBindings?.[ identifier ] || ! bindableAttributes ) {
|
|
183
177
|
return {};
|
|
184
178
|
}
|
|
185
179
|
|
|
@@ -214,12 +208,12 @@ export function RichTextWrapper(
|
|
|
214
208
|
const { getBlockAttributes } = select( blockEditorStore );
|
|
215
209
|
const blockAttributes = getBlockAttributes( clientId );
|
|
216
210
|
let clientSideFieldLabel = null;
|
|
217
|
-
if ( blockBindingsSource?.
|
|
218
|
-
const
|
|
211
|
+
if ( blockBindingsSource?.getFieldsList ) {
|
|
212
|
+
const fieldsItems = blockBindingsSource.getFieldsList( {
|
|
219
213
|
select,
|
|
220
214
|
context: blockBindingsContext,
|
|
221
215
|
} );
|
|
222
|
-
clientSideFieldLabel =
|
|
216
|
+
clientSideFieldLabel = fieldsItems?.find( ( item ) =>
|
|
223
217
|
fastDeepEqual( item.args, relatedBinding?.args )
|
|
224
218
|
)?.label;
|
|
225
219
|
}
|
|
@@ -252,7 +246,7 @@ export function RichTextWrapper(
|
|
|
252
246
|
[
|
|
253
247
|
blockBindings,
|
|
254
248
|
identifier,
|
|
255
|
-
|
|
249
|
+
bindableAttributes,
|
|
256
250
|
adjustedValue,
|
|
257
251
|
clientId,
|
|
258
252
|
blockContext,
|