@wordpress/block-editor 15.6.1-next.36001005c.0 → 15.7.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/CHANGELOG.md +2 -0
- 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-toolbar/switch-section-style.js +2 -5
- package/build/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build/components/global-styles/hooks.js +0 -107
- package/build/components/global-styles/hooks.js.map +3 -3
- package/build/components/global-styles/index.js +0 -15
- package/build/components/global-styles/index.js.map +2 -2
- package/build/components/global-styles/typography-panel.js +18 -1
- package/build/components/global-styles/typography-panel.js.map +2 -2
- package/build/components/global-styles/utils.js +0 -19
- package/build/components/global-styles/utils.js.map +3 -3
- package/build/components/inserter/media-tab/media-tab.js +33 -1
- package/build/components/inserter/media-tab/media-tab.js.map +3 -3
- package/build/components/inserter/tips.js +0 -2
- package/build/components/inserter/tips.js.map +2 -2
- package/build/components/media-placeholder/index.js +31 -1
- package/build/components/media-placeholder/index.js.map +3 -3
- package/build/components/media-replace-flow/index.js +29 -1
- package/build/components/media-replace-flow/index.js.map +3 -3
- package/build/components/{global-styles/context.js → media-upload-modal/index.js} +8 -23
- package/build/components/media-upload-modal/index.js.map +7 -0
- 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 +3 -8
- package/build/hooks/allowed-blocks.js.map +3 -3
- package/build/hooks/block-bindings.js +111 -170
- package/build/hooks/block-bindings.js.map +2 -2
- package/build/hooks/block-style-variation.js +4 -13
- 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/fit-text.js +33 -20
- 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/private-apis.js +3 -1
- package/build/private-apis.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/block-toolbar/switch-section-style.js +2 -5
- package/build-module/components/block-toolbar/switch-section-style.js.map +2 -2
- package/build-module/components/global-styles/hooks.js +1 -99
- package/build-module/components/global-styles/hooks.js.map +2 -2
- package/build-module/components/global-styles/index.js +1 -15
- package/build-module/components/global-styles/index.js.map +2 -2
- 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/global-styles/utils.js +0 -8
- package/build-module/components/global-styles/utils.js.map +2 -2
- package/build-module/components/inserter/media-tab/media-tab.js +34 -2
- package/build-module/components/inserter/media-tab/media-tab.js.map +2 -2
- package/build-module/components/inserter/tips.js +0 -2
- package/build-module/components/inserter/tips.js.map +2 -2
- package/build-module/components/media-placeholder/index.js +31 -1
- package/build-module/components/media-placeholder/index.js.map +2 -2
- package/build-module/components/media-replace-flow/index.js +29 -1
- package/build-module/components/media-replace-flow/index.js.map +2 -2
- package/build-module/components/media-upload-modal/index.js +7 -0
- package/build-module/components/media-upload-modal/index.js.map +7 -0
- 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 +3 -8
- 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 +5 -14
- 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/fit-text.js +34 -21
- 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/private-apis.js +3 -1
- package/build-module/private-apis.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/package.json +36 -36
- package/src/components/block-list/block.js +1 -1
- package/src/components/block-list/index.js +2 -2
- package/src/components/block-toolbar/switch-section-style.js +2 -5
- package/src/components/global-styles/hooks.js +1 -121
- package/src/components/global-styles/index.js +1 -9
- package/src/components/global-styles/typography-panel.js +26 -1
- package/src/components/global-styles/utils.js +0 -31
- package/src/components/inserter/media-tab/media-tab.js +44 -2
- package/src/components/inserter/tips.js +0 -2
- package/src/components/media-placeholder/index.js +41 -1
- package/src/components/media-replace-flow/index.js +39 -1
- package/src/components/media-upload-modal/index.js +18 -0
- package/src/components/rich-text/index.js +8 -14
- package/src/hooks/allowed-blocks.js +3 -11
- package/src/hooks/block-bindings.js +79 -153
- package/src/hooks/block-style-variation.js +5 -17
- package/src/hooks/custom-class-name.js +1 -1
- package/src/hooks/fit-text.js +39 -30
- 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/private-apis.js +2 -0
- 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
- package/tsconfig.json +1 -0
- package/build/components/global-styles/context.js.map +0 -7
- package/build/components/global-styles/get-global-styles-changes.js +0 -216
- package/build/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/build-module/components/global-styles/context.js +0 -17
- package/build-module/components/global-styles/context.js.map +0 -7
- package/build-module/components/global-styles/get-global-styles-changes.js +0 -182
- package/build-module/components/global-styles/get-global-styles-changes.js.map +0 -7
- package/src/components/global-styles/README.md +0 -190
- package/src/components/global-styles/context.js +0 -16
- package/src/components/global-styles/get-global-styles-changes.js +0 -252
- package/src/components/global-styles/test/get-global-styles-changes.js +0 -290
- package/src/components/global-styles/test/utils.js +0 -58
|
@@ -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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-editor",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.7.0",
|
|
4
4
|
"description": "Generic block editor.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -56,40 +56,40 @@
|
|
|
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.
|
|
60
|
-
"@wordpress/api-fetch": "^7.
|
|
61
|
-
"@wordpress/base-styles": "^6.10.
|
|
62
|
-
"@wordpress/blob": "^4.
|
|
63
|
-
"@wordpress/block-serialization-default-parser": "^5.
|
|
64
|
-
"@wordpress/blocks": "^15.
|
|
65
|
-
"@wordpress/commands": "^1.
|
|
66
|
-
"@wordpress/components": "^30.7.
|
|
67
|
-
"@wordpress/compose": "^7.
|
|
68
|
-
"@wordpress/data": "^10.
|
|
69
|
-
"@wordpress/date": "^5.
|
|
70
|
-
"@wordpress/deprecated": "^4.
|
|
71
|
-
"@wordpress/dom": "^4.
|
|
72
|
-
"@wordpress/element": "^6.
|
|
73
|
-
"@wordpress/escape-html": "^3.
|
|
74
|
-
"@wordpress/global-styles-engine": "^1.
|
|
75
|
-
"@wordpress/hooks": "^4.
|
|
76
|
-
"@wordpress/html-entities": "^4.
|
|
77
|
-
"@wordpress/i18n": "^6.
|
|
78
|
-
"@wordpress/icons": "^11.
|
|
79
|
-
"@wordpress/is-shallow-equal": "^5.
|
|
80
|
-
"@wordpress/keyboard-shortcuts": "^5.
|
|
81
|
-
"@wordpress/keycodes": "^4.
|
|
82
|
-
"@wordpress/notices": "^5.
|
|
83
|
-
"@wordpress/preferences": "^4.
|
|
84
|
-
"@wordpress/priority-queue": "^3.
|
|
85
|
-
"@wordpress/private-apis": "^1.
|
|
86
|
-
"@wordpress/rich-text": "^7.
|
|
87
|
-
"@wordpress/style-engine": "^2.
|
|
88
|
-
"@wordpress/token-list": "^3.
|
|
89
|
-
"@wordpress/upload-media": "^0.
|
|
90
|
-
"@wordpress/url": "^4.
|
|
91
|
-
"@wordpress/warning": "^3.
|
|
92
|
-
"@wordpress/wordcount": "^4.
|
|
59
|
+
"@wordpress/a11y": "^4.34.0",
|
|
60
|
+
"@wordpress/api-fetch": "^7.34.0",
|
|
61
|
+
"@wordpress/base-styles": "^6.10.0",
|
|
62
|
+
"@wordpress/blob": "^4.34.0",
|
|
63
|
+
"@wordpress/block-serialization-default-parser": "^5.34.0",
|
|
64
|
+
"@wordpress/blocks": "^15.7.0",
|
|
65
|
+
"@wordpress/commands": "^1.34.0",
|
|
66
|
+
"@wordpress/components": "^30.7.0",
|
|
67
|
+
"@wordpress/compose": "^7.34.0",
|
|
68
|
+
"@wordpress/data": "^10.34.0",
|
|
69
|
+
"@wordpress/date": "^5.34.0",
|
|
70
|
+
"@wordpress/deprecated": "^4.34.0",
|
|
71
|
+
"@wordpress/dom": "^4.34.0",
|
|
72
|
+
"@wordpress/element": "^6.34.0",
|
|
73
|
+
"@wordpress/escape-html": "^3.34.0",
|
|
74
|
+
"@wordpress/global-styles-engine": "^1.1.0",
|
|
75
|
+
"@wordpress/hooks": "^4.34.0",
|
|
76
|
+
"@wordpress/html-entities": "^4.34.0",
|
|
77
|
+
"@wordpress/i18n": "^6.7.0",
|
|
78
|
+
"@wordpress/icons": "^11.1.0",
|
|
79
|
+
"@wordpress/is-shallow-equal": "^5.34.0",
|
|
80
|
+
"@wordpress/keyboard-shortcuts": "^5.34.0",
|
|
81
|
+
"@wordpress/keycodes": "^4.34.0",
|
|
82
|
+
"@wordpress/notices": "^5.34.0",
|
|
83
|
+
"@wordpress/preferences": "^4.34.0",
|
|
84
|
+
"@wordpress/priority-queue": "^3.34.0",
|
|
85
|
+
"@wordpress/private-apis": "^1.34.0",
|
|
86
|
+
"@wordpress/rich-text": "^7.34.0",
|
|
87
|
+
"@wordpress/style-engine": "^2.34.0",
|
|
88
|
+
"@wordpress/token-list": "^3.34.0",
|
|
89
|
+
"@wordpress/upload-media": "^0.19.0",
|
|
90
|
+
"@wordpress/url": "^4.34.0",
|
|
91
|
+
"@wordpress/warning": "^3.34.0",
|
|
92
|
+
"@wordpress/wordcount": "^4.34.0",
|
|
93
93
|
"change-case": "^4.1.2",
|
|
94
94
|
"clsx": "^2.1.1",
|
|
95
95
|
"colord": "^2.7.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"publishConfig": {
|
|
113
113
|
"access": "public"
|
|
114
114
|
},
|
|
115
|
-
"gitHead": "
|
|
115
|
+
"gitHead": "ceebff807958d2e8fc755b5a20473939c78b4d1d"
|
|
116
116
|
}
|
|
@@ -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
|
) ) &&
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import { useContext } from '@wordpress/element';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Internal dependencies
|
|
@@ -18,7 +17,6 @@ import { useContext } from '@wordpress/element';
|
|
|
18
17
|
import useStylesForBlocks from '../block-styles/use-styles-for-block';
|
|
19
18
|
import { replaceActiveStyle } from '../block-styles/utils';
|
|
20
19
|
import { store as blockEditorStore } from '../../store';
|
|
21
|
-
import { GlobalStylesContext } from '../global-styles';
|
|
22
20
|
import { globalStylesDataKey } from '../../store/private-keys';
|
|
23
21
|
import { getVariationStylesWithRefValues } from '../../hooks/block-style-variation';
|
|
24
22
|
|
|
@@ -47,7 +45,6 @@ function SwitchSectionStyle( { clientId } ) {
|
|
|
47
45
|
const { updateBlockAttributes } = useDispatch( blockEditorStore );
|
|
48
46
|
|
|
49
47
|
// Get global styles data
|
|
50
|
-
const { merged: mergedConfig } = useContext( GlobalStylesContext );
|
|
51
48
|
const { globalSettings, globalStyles, blockName } = useSelect(
|
|
52
49
|
( select ) => {
|
|
53
50
|
const settings = select( blockEditorStore ).getSettings();
|
|
@@ -64,8 +61,8 @@ function SwitchSectionStyle( { clientId } ) {
|
|
|
64
61
|
const activeStyleBackground = activeStyle?.name
|
|
65
62
|
? getVariationStylesWithRefValues(
|
|
66
63
|
{
|
|
67
|
-
settings:
|
|
68
|
-
styles:
|
|
64
|
+
settings: globalSettings,
|
|
65
|
+
styles: globalStyles,
|
|
69
66
|
},
|
|
70
67
|
blockName,
|
|
71
68
|
activeStyle.name
|
|
@@ -1,136 +1,16 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
|
-
import {
|
|
4
|
+
import { useMemo } from '@wordpress/element';
|
|
10
5
|
import { useSelect } from '@wordpress/data';
|
|
11
6
|
import { store as blocksStore } from '@wordpress/blocks';
|
|
12
7
|
import { _x } from '@wordpress/i18n';
|
|
13
|
-
import {
|
|
14
|
-
getSetting,
|
|
15
|
-
getStyle,
|
|
16
|
-
getPresetVariableFromValue,
|
|
17
|
-
} from '@wordpress/global-styles-engine';
|
|
18
8
|
|
|
19
9
|
/**
|
|
20
10
|
* Internal dependencies
|
|
21
11
|
*/
|
|
22
|
-
import { setImmutably } from '../../utils/object';
|
|
23
|
-
import { GlobalStylesContext } from './context';
|
|
24
12
|
import { unlock } from '../../lock-unlock';
|
|
25
13
|
|
|
26
|
-
const EMPTY_CONFIG = { settings: {}, styles: {} };
|
|
27
|
-
|
|
28
|
-
export const useGlobalStylesReset = () => {
|
|
29
|
-
const { user, setUserConfig } = useContext( GlobalStylesContext );
|
|
30
|
-
const config = {
|
|
31
|
-
settings: user.settings,
|
|
32
|
-
styles: user.styles,
|
|
33
|
-
};
|
|
34
|
-
const canReset = !! config && ! fastDeepEqual( config, EMPTY_CONFIG );
|
|
35
|
-
return [
|
|
36
|
-
canReset,
|
|
37
|
-
useCallback( () => setUserConfig( EMPTY_CONFIG ), [ setUserConfig ] ),
|
|
38
|
-
];
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export function useGlobalSetting( propertyPath, blockName, source = 'all' ) {
|
|
42
|
-
const { setUserConfig, ...configs } = useContext( GlobalStylesContext );
|
|
43
|
-
const appendedBlockPath = blockName ? '.blocks.' + blockName : '';
|
|
44
|
-
const appendedPropertyPath = propertyPath ? '.' + propertyPath : '';
|
|
45
|
-
const contextualPath = `settings${ appendedBlockPath }${ appendedPropertyPath }`;
|
|
46
|
-
const sourceKey = source === 'all' ? 'merged' : source;
|
|
47
|
-
|
|
48
|
-
const settingValue = useMemo( () => {
|
|
49
|
-
const configToUse = configs[ sourceKey ];
|
|
50
|
-
if ( ! configToUse ) {
|
|
51
|
-
throw 'Unsupported source';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Use engine's getSetting instead of duplicating logic
|
|
55
|
-
return getSetting( configToUse, propertyPath, blockName );
|
|
56
|
-
}, [ configs, sourceKey, propertyPath, blockName ] );
|
|
57
|
-
|
|
58
|
-
const setSetting = ( newValue ) => {
|
|
59
|
-
setUserConfig( ( currentConfig ) =>
|
|
60
|
-
setImmutably( currentConfig, contextualPath.split( '.' ), newValue )
|
|
61
|
-
);
|
|
62
|
-
};
|
|
63
|
-
return [ settingValue, setSetting ];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function useGlobalStyle(
|
|
67
|
-
path,
|
|
68
|
-
blockName,
|
|
69
|
-
source = 'all',
|
|
70
|
-
{ shouldDecodeEncode = true } = {}
|
|
71
|
-
) {
|
|
72
|
-
const {
|
|
73
|
-
merged: mergedConfig,
|
|
74
|
-
base: baseConfig,
|
|
75
|
-
user: userConfig,
|
|
76
|
-
setUserConfig,
|
|
77
|
-
} = useContext( GlobalStylesContext );
|
|
78
|
-
const appendedPath = path ? '.' + path : '';
|
|
79
|
-
const finalPath = ! blockName
|
|
80
|
-
? `styles${ appendedPath }`
|
|
81
|
-
: `styles.blocks.${ blockName }${ appendedPath }`;
|
|
82
|
-
|
|
83
|
-
const setStyle = ( newValue ) => {
|
|
84
|
-
setUserConfig( ( currentConfig ) =>
|
|
85
|
-
setImmutably(
|
|
86
|
-
currentConfig,
|
|
87
|
-
finalPath.split( '.' ),
|
|
88
|
-
shouldDecodeEncode
|
|
89
|
-
? getPresetVariableFromValue(
|
|
90
|
-
mergedConfig.settings,
|
|
91
|
-
blockName,
|
|
92
|
-
path,
|
|
93
|
-
newValue
|
|
94
|
-
)
|
|
95
|
-
: newValue
|
|
96
|
-
)
|
|
97
|
-
);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
let result;
|
|
101
|
-
// Use engine's getStyle instead of duplicating logic
|
|
102
|
-
switch ( source ) {
|
|
103
|
-
case 'all':
|
|
104
|
-
result = getStyle(
|
|
105
|
-
mergedConfig,
|
|
106
|
-
path,
|
|
107
|
-
blockName,
|
|
108
|
-
shouldDecodeEncode
|
|
109
|
-
);
|
|
110
|
-
break;
|
|
111
|
-
case 'user':
|
|
112
|
-
result = getStyle(
|
|
113
|
-
userConfig,
|
|
114
|
-
path,
|
|
115
|
-
blockName,
|
|
116
|
-
shouldDecodeEncode
|
|
117
|
-
);
|
|
118
|
-
break;
|
|
119
|
-
case 'base':
|
|
120
|
-
result = getStyle(
|
|
121
|
-
baseConfig,
|
|
122
|
-
path,
|
|
123
|
-
blockName,
|
|
124
|
-
shouldDecodeEncode
|
|
125
|
-
);
|
|
126
|
-
break;
|
|
127
|
-
default:
|
|
128
|
-
throw 'Unsupported source';
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return [ result, setStyle ];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
14
|
/**
|
|
135
15
|
* React hook that overrides a global settings object with block and element specific settings.
|
|
136
16
|
*
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
useGlobalStylesReset,
|
|
3
|
-
useGlobalSetting,
|
|
4
|
-
useGlobalStyle,
|
|
5
|
-
useSettingsForBlockElement,
|
|
6
|
-
} from './hooks';
|
|
7
|
-
export { GlobalStylesContext } from './context';
|
|
1
|
+
export { useSettingsForBlockElement } from './hooks';
|
|
8
2
|
export {
|
|
9
3
|
default as TypographyPanel,
|
|
10
4
|
useHasTypographyPanel,
|
|
@@ -29,5 +23,3 @@ export {
|
|
|
29
23
|
default as BackgroundPanel,
|
|
30
24
|
useHasBackgroundPanel,
|
|
31
25
|
} from './background-panel';
|
|
32
|
-
export { areGlobalStyleConfigsEqual } from './utils';
|
|
33
|
-
export { default as getGlobalStylesChanges } from './get-global-styles-changes';
|
|
@@ -213,6 +213,30 @@ export default function TypographyPanel( {
|
|
|
213
213
|
const mergedFontSizes = getMergedFontSizes( settings );
|
|
214
214
|
|
|
215
215
|
const fontSize = decodeValue( inheritedValue?.typography?.fontSize );
|
|
216
|
+
|
|
217
|
+
// Extract the slug from the CSS custom property if it exists
|
|
218
|
+
const currentFontSizeSlug = ( () => {
|
|
219
|
+
const rawValue = inheritedValue?.typography?.fontSize;
|
|
220
|
+
if ( ! rawValue || typeof rawValue !== 'string' ) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Block supports use `var:preset` format.
|
|
225
|
+
if ( rawValue.startsWith( 'var:preset|font-size|' ) ) {
|
|
226
|
+
return rawValue.replace( 'var:preset|font-size|', '' );
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// Global styles data uses `var(--wp--preset)` format.
|
|
230
|
+
const cssVarMatch = rawValue.match(
|
|
231
|
+
/^var\(--wp--preset--font-size--([^)]+)\)$/
|
|
232
|
+
);
|
|
233
|
+
if ( cssVarMatch ) {
|
|
234
|
+
return cssVarMatch[ 1 ];
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return undefined;
|
|
238
|
+
} )();
|
|
239
|
+
|
|
216
240
|
const setFontSize = ( newValue, metadata ) => {
|
|
217
241
|
const actualValue = !! metadata?.slug
|
|
218
242
|
? `var:preset|font-size|${ metadata?.slug }`
|
|
@@ -433,7 +457,8 @@ export default function TypographyPanel( {
|
|
|
433
457
|
panelId={ panelId }
|
|
434
458
|
>
|
|
435
459
|
<FontSizePicker
|
|
436
|
-
value={ fontSize }
|
|
460
|
+
value={ currentFontSizeSlug || fontSize }
|
|
461
|
+
valueMode={ currentFontSizeSlug ? 'slug' : 'literal' }
|
|
437
462
|
onChange={ setFontSize }
|
|
438
463
|
fontSizes={ mergedFontSizes }
|
|
439
464
|
disableCustomFontSizes={ disableCustomFontSizes }
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import fastDeepEqual from 'fast-deep-equal/es6';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
@@ -55,29 +50,3 @@ export function scopeSelector( scope, selector ) {
|
|
|
55
50
|
|
|
56
51
|
return selectorsScoped.join( ', ' );
|
|
57
52
|
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Compares global style variations according to their styles and settings properties.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```js
|
|
64
|
-
* const globalStyles = { styles: { typography: { fontSize: '10px' } }, settings: {} };
|
|
65
|
-
* const variation = { styles: { typography: { fontSize: '10000px' } }, settings: {} };
|
|
66
|
-
* const isEqual = areGlobalStyleConfigsEqual( globalStyles, variation );
|
|
67
|
-
* // false
|
|
68
|
-
* ```
|
|
69
|
-
*
|
|
70
|
-
* @param {Object} original A global styles object.
|
|
71
|
-
* @param {Object} variation A global styles object.
|
|
72
|
-
*
|
|
73
|
-
* @return {boolean} Whether `original` and `variation` match.
|
|
74
|
-
*/
|
|
75
|
-
export function areGlobalStyleConfigsEqual( original, variation ) {
|
|
76
|
-
if ( typeof original !== 'object' || typeof variation !== 'object' ) {
|
|
77
|
-
return original === variation;
|
|
78
|
-
}
|
|
79
|
-
return (
|
|
80
|
-
fastDeepEqual( original?.styles, variation?.styles ) &&
|
|
81
|
-
fastDeepEqual( original?.settings, variation?.settings )
|
|
82
|
-
);
|
|
83
|
-
}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { useViewportMatch } from '@wordpress/compose';
|
|
6
6
|
import { Button } from '@wordpress/components';
|
|
7
|
-
import { useCallback, useMemo } from '@wordpress/element';
|
|
7
|
+
import { useCallback, useMemo, useState } from '@wordpress/element';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -12,14 +13,55 @@ import { useCallback, useMemo } from '@wordpress/element';
|
|
|
12
13
|
import { MediaCategoryPanel } from './media-panel';
|
|
13
14
|
import MediaUploadCheck from '../../media-upload/check';
|
|
14
15
|
import MediaUpload from '../../media-upload';
|
|
16
|
+
import MediaUploadModal from '../../media-upload-modal';
|
|
15
17
|
import { useMediaCategories } from './hooks';
|
|
16
18
|
import { getBlockAndPreviewFromMedia } from './utils';
|
|
17
19
|
import MobileTabNavigation from '../mobile-tab-navigation';
|
|
18
20
|
import CategoryTabs from '../category-tabs';
|
|
19
21
|
import InserterNoResults from '../no-results';
|
|
22
|
+
import { store as blockEditorStore } from '../../../store';
|
|
20
23
|
|
|
21
24
|
const ALLOWED_MEDIA_TYPES = [ 'image', 'video', 'audio' ];
|
|
22
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Conditional Media component that uses MediaUploadModal when experiment is enabled,
|
|
28
|
+
* otherwise falls back to MediaUpload.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} root0 Component props.
|
|
31
|
+
* @param {Function} root0.render Render prop function that receives { open } object.
|
|
32
|
+
* @return {JSX.Element} The component.
|
|
33
|
+
*/
|
|
34
|
+
function ConditionalMediaUpload( { render, ...props } ) {
|
|
35
|
+
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
36
|
+
const mediaUpload = useSelect( ( select ) => {
|
|
37
|
+
const { getSettings } = select( blockEditorStore );
|
|
38
|
+
return getSettings().mediaUpload;
|
|
39
|
+
}, [] );
|
|
40
|
+
|
|
41
|
+
if ( window.__experimentalDataViewsMediaModal ) {
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
{ render && render( { open: () => setIsModalOpen( true ) } ) }
|
|
45
|
+
<MediaUploadModal
|
|
46
|
+
{ ...props }
|
|
47
|
+
isOpen={ isModalOpen }
|
|
48
|
+
onClose={ () => {
|
|
49
|
+
setIsModalOpen( false );
|
|
50
|
+
props.onClose?.();
|
|
51
|
+
} }
|
|
52
|
+
onSelect={ ( media ) => {
|
|
53
|
+
setIsModalOpen( false );
|
|
54
|
+
props.onSelect?.( media );
|
|
55
|
+
} }
|
|
56
|
+
onUpload={ mediaUpload }
|
|
57
|
+
/>
|
|
58
|
+
</>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return <MediaUpload { ...props } render={ render } />;
|
|
63
|
+
}
|
|
64
|
+
|
|
23
65
|
function MediaTab( {
|
|
24
66
|
rootClientId,
|
|
25
67
|
selectedCategory,
|
|
@@ -65,7 +107,7 @@ function MediaTab( {
|
|
|
65
107
|
{ children }
|
|
66
108
|
</CategoryTabs>
|
|
67
109
|
<MediaUploadCheck>
|
|
68
|
-
<
|
|
110
|
+
<ConditionalMediaUpload
|
|
69
111
|
multiple={ false }
|
|
70
112
|
onSelect={ onSelectMedia }
|
|
71
113
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
@@ -25,6 +25,7 @@ import deprecated from '@wordpress/deprecated';
|
|
|
25
25
|
* Internal dependencies
|
|
26
26
|
*/
|
|
27
27
|
import MediaUpload from '../media-upload';
|
|
28
|
+
import MediaUploadModal from '../media-upload-modal';
|
|
28
29
|
import MediaUploadCheck from '../media-upload/check';
|
|
29
30
|
import URLPopover from '../url-popover';
|
|
30
31
|
import { store as blockEditorStore } from '../../store';
|
|
@@ -32,6 +33,45 @@ import { parseDropEvent } from '../use-on-block-drop';
|
|
|
32
33
|
|
|
33
34
|
const noop = () => {};
|
|
34
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Conditional Media component that uses MediaUploadModal when experiment is enabled,
|
|
38
|
+
* otherwise falls back to MediaUpload.
|
|
39
|
+
*
|
|
40
|
+
* @param {Object} root0 Component props.
|
|
41
|
+
* @param {Function} root0.render Render prop function that receives { open } object.
|
|
42
|
+
* @return {JSX.Element} The component.
|
|
43
|
+
*/
|
|
44
|
+
function ConditionalMediaUpload( { render, ...props } ) {
|
|
45
|
+
const [ isModalOpen, setIsModalOpen ] = useState( false );
|
|
46
|
+
const mediaUpload = useSelect( ( select ) => {
|
|
47
|
+
const { getSettings } = select( blockEditorStore );
|
|
48
|
+
return getSettings().mediaUpload;
|
|
49
|
+
}, [] );
|
|
50
|
+
|
|
51
|
+
if ( window.__experimentalDataViewsMediaModal ) {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
{ render && render( { open: () => setIsModalOpen( true ) } ) }
|
|
55
|
+
<MediaUploadModal
|
|
56
|
+
{ ...props }
|
|
57
|
+
isOpen={ isModalOpen }
|
|
58
|
+
onClose={ () => {
|
|
59
|
+
setIsModalOpen( false );
|
|
60
|
+
props.onClose?.();
|
|
61
|
+
} }
|
|
62
|
+
onSelect={ ( media ) => {
|
|
63
|
+
setIsModalOpen( false );
|
|
64
|
+
props.onSelect?.( media );
|
|
65
|
+
} }
|
|
66
|
+
onUpload={ mediaUpload }
|
|
67
|
+
/>
|
|
68
|
+
</>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return <MediaUpload { ...props } render={ render } />;
|
|
73
|
+
}
|
|
74
|
+
|
|
35
75
|
const InsertFromURLPopover = ( {
|
|
36
76
|
src,
|
|
37
77
|
onChange,
|
|
@@ -448,7 +488,7 @@ export function MediaPlaceholder( {
|
|
|
448
488
|
};
|
|
449
489
|
const libraryButton = mediaLibraryButton ?? defaultButton;
|
|
450
490
|
const uploadMediaLibraryButton = (
|
|
451
|
-
<
|
|
491
|
+
<ConditionalMediaUpload
|
|
452
492
|
addToGallery={ addToGallery }
|
|
453
493
|
gallery={ multiple && onlyAllowsImages() }
|
|
454
494
|
multiple={ multiple }
|