Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: block-editor.js
* getReportUrl: ( { sourceId } ) =>
[16000] Fix | Delete
* `https://wordpress.org/openverse/image/${ sourceId }/report/`,
[16001] Fix | Delete
* isExternalResource: true,
[16002] Fix | Delete
* } );
[16003] Fix | Delete
* ```
[16004] Fix | Delete
*
[16005] Fix | Delete
* @typedef {Object} InserterMediaCategory Interface for inserter media category.
[16006] Fix | Delete
* @property {string} name The name of the media category, that should be unique among all media categories.
[16007] Fix | Delete
* @property {Object} labels Labels for the media category.
[16008] Fix | Delete
* @property {string} labels.name General name of the media category. It's used in the inserter media items list.
[16009] Fix | Delete
* @property {string} [labels.search_items='Search'] Label for searching items. Default is ‘Search Posts’ / ‘Search Pages’.
[16010] Fix | Delete
* @property {('image'|'audio'|'video')} mediaType The media type of the media category.
[16011] Fix | Delete
* @property {(InserterMediaRequest) => Promise<InserterMediaItem[]>} fetch The function to fetch media items for the category.
[16012] Fix | Delete
* @property {(InserterMediaItem) => string} [getReportUrl] If the media category supports reporting media items, this function should return
[16013] Fix | Delete
* the report url for the media item. It accepts the `InserterMediaItem` as an argument.
[16014] Fix | Delete
* @property {boolean} [isExternalResource] If the media category is an external resource, this should be set to true.
[16015] Fix | Delete
* This is used to avoid making a request to the external resource when the user
[16016] Fix | Delete
*/
[16017] Fix | Delete
const registerInserterMediaCategory = category => ({
[16018] Fix | Delete
select,
[16019] Fix | Delete
dispatch
[16020] Fix | Delete
}) => {
[16021] Fix | Delete
if (!category || typeof category !== 'object') {
[16022] Fix | Delete
console.error('Category should be an `InserterMediaCategory` object.');
[16023] Fix | Delete
return;
[16024] Fix | Delete
}
[16025] Fix | Delete
if (!category.name) {
[16026] Fix | Delete
console.error('Category should have a `name` that should be unique among all media categories.');
[16027] Fix | Delete
return;
[16028] Fix | Delete
}
[16029] Fix | Delete
if (!category.labels?.name) {
[16030] Fix | Delete
console.error('Category should have a `labels.name`.');
[16031] Fix | Delete
return;
[16032] Fix | Delete
}
[16033] Fix | Delete
if (!['image', 'audio', 'video'].includes(category.mediaType)) {
[16034] Fix | Delete
console.error('Category should have `mediaType` property that is one of `image|audio|video`.');
[16035] Fix | Delete
return;
[16036] Fix | Delete
}
[16037] Fix | Delete
if (!category.fetch || typeof category.fetch !== 'function') {
[16038] Fix | Delete
console.error('Category should have a `fetch` function defined with the following signature `(InserterMediaRequest) => Promise<InserterMediaItem[]>`.');
[16039] Fix | Delete
return;
[16040] Fix | Delete
}
[16041] Fix | Delete
const registeredInserterMediaCategories = select.getRegisteredInserterMediaCategories();
[16042] Fix | Delete
if (registeredInserterMediaCategories.some(({
[16043] Fix | Delete
name
[16044] Fix | Delete
}) => name === category.name)) {
[16045] Fix | Delete
console.error(`A category is already registered with the same name: "${category.name}".`);
[16046] Fix | Delete
return;
[16047] Fix | Delete
}
[16048] Fix | Delete
if (registeredInserterMediaCategories.some(({
[16049] Fix | Delete
labels: {
[16050] Fix | Delete
name
[16051] Fix | Delete
} = {}
[16052] Fix | Delete
}) => name === category.labels?.name)) {
[16053] Fix | Delete
console.error(`A category is already registered with the same labels.name: "${category.labels.name}".`);
[16054] Fix | Delete
return;
[16055] Fix | Delete
}
[16056] Fix | Delete
// `inserterMediaCategories` is a private block editor setting, which means it cannot
[16057] Fix | Delete
// be updated through the public `updateSettings` action. We preserve this setting as
[16058] Fix | Delete
// private, so extenders can only add new inserter media categories and don't have any
[16059] Fix | Delete
// control over the core media categories.
[16060] Fix | Delete
dispatch({
[16061] Fix | Delete
type: 'REGISTER_INSERTER_MEDIA_CATEGORY',
[16062] Fix | Delete
category: {
[16063] Fix | Delete
...category,
[16064] Fix | Delete
isExternalResource: true
[16065] Fix | Delete
}
[16066] Fix | Delete
});
[16067] Fix | Delete
};
[16068] Fix | Delete
[16069] Fix | Delete
/**
[16070] Fix | Delete
* @typedef {import('../components/block-editing-mode').BlockEditingMode} BlockEditingMode
[16071] Fix | Delete
*/
[16072] Fix | Delete
[16073] Fix | Delete
/**
[16074] Fix | Delete
* Sets the block editing mode for a given block.
[16075] Fix | Delete
*
[16076] Fix | Delete
* @see useBlockEditingMode
[16077] Fix | Delete
*
[16078] Fix | Delete
* @param {string} clientId The block client ID, or `''` for the root container.
[16079] Fix | Delete
* @param {BlockEditingMode} mode The block editing mode. One of `'disabled'`,
[16080] Fix | Delete
* `'contentOnly'`, or `'default'`.
[16081] Fix | Delete
*
[16082] Fix | Delete
* @return {Object} Action object.
[16083] Fix | Delete
*/
[16084] Fix | Delete
function setBlockEditingMode(clientId = '', mode) {
[16085] Fix | Delete
return {
[16086] Fix | Delete
type: 'SET_BLOCK_EDITING_MODE',
[16087] Fix | Delete
clientId,
[16088] Fix | Delete
mode
[16089] Fix | Delete
};
[16090] Fix | Delete
}
[16091] Fix | Delete
[16092] Fix | Delete
/**
[16093] Fix | Delete
* Clears the block editing mode for a given block.
[16094] Fix | Delete
*
[16095] Fix | Delete
* @see useBlockEditingMode
[16096] Fix | Delete
*
[16097] Fix | Delete
* @param {string} clientId The block client ID, or `''` for the root container.
[16098] Fix | Delete
*
[16099] Fix | Delete
* @return {Object} Action object.
[16100] Fix | Delete
*/
[16101] Fix | Delete
function unsetBlockEditingMode(clientId = '') {
[16102] Fix | Delete
return {
[16103] Fix | Delete
type: 'UNSET_BLOCK_EDITING_MODE',
[16104] Fix | Delete
clientId
[16105] Fix | Delete
};
[16106] Fix | Delete
}
[16107] Fix | Delete
[16108] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/store/index.js
[16109] Fix | Delete
/**
[16110] Fix | Delete
* WordPress dependencies
[16111] Fix | Delete
*/
[16112] Fix | Delete
[16113] Fix | Delete
[16114] Fix | Delete
/**
[16115] Fix | Delete
* Internal dependencies
[16116] Fix | Delete
*/
[16117] Fix | Delete
[16118] Fix | Delete
[16119] Fix | Delete
[16120] Fix | Delete
[16121] Fix | Delete
[16122] Fix | Delete
[16123] Fix | Delete
[16124] Fix | Delete
[16125] Fix | Delete
/**
[16126] Fix | Delete
* Block editor data store configuration.
[16127] Fix | Delete
*
[16128] Fix | Delete
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
[16129] Fix | Delete
*/
[16130] Fix | Delete
const storeConfig = {
[16131] Fix | Delete
reducer: reducer,
[16132] Fix | Delete
selectors: selectors_namespaceObject,
[16133] Fix | Delete
actions: actions_namespaceObject
[16134] Fix | Delete
};
[16135] Fix | Delete
[16136] Fix | Delete
/**
[16137] Fix | Delete
* Store definition for the block editor namespace.
[16138] Fix | Delete
*
[16139] Fix | Delete
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
[16140] Fix | Delete
*/
[16141] Fix | Delete
const store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
[16142] Fix | Delete
...storeConfig,
[16143] Fix | Delete
persist: ['preferences']
[16144] Fix | Delete
});
[16145] Fix | Delete
[16146] Fix | Delete
// We will be able to use the `register` function once we switch
[16147] Fix | Delete
// the "preferences" persistence to use the new preferences package.
[16148] Fix | Delete
const registeredStore = (0,external_wp_data_namespaceObject.registerStore)(STORE_NAME, {
[16149] Fix | Delete
...storeConfig,
[16150] Fix | Delete
persist: ['preferences']
[16151] Fix | Delete
});
[16152] Fix | Delete
unlock(registeredStore).registerPrivateActions(private_actions_namespaceObject);
[16153] Fix | Delete
unlock(registeredStore).registerPrivateSelectors(private_selectors_namespaceObject);
[16154] Fix | Delete
[16155] Fix | Delete
// TODO: Remove once we switch to the `register` function (see above).
[16156] Fix | Delete
//
[16157] Fix | Delete
// Until then, private functions also need to be attached to the original
[16158] Fix | Delete
// `store` descriptor in order to avoid unit tests failing, which could happen
[16159] Fix | Delete
// when tests create new registries in which they register stores.
[16160] Fix | Delete
//
[16161] Fix | Delete
// @see https://github.com/WordPress/gutenberg/pull/51145#discussion_r1239999590
[16162] Fix | Delete
unlock(store).registerPrivateActions(private_actions_namespaceObject);
[16163] Fix | Delete
unlock(store).registerPrivateSelectors(private_selectors_namespaceObject);
[16164] Fix | Delete
[16165] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/use-settings/index.js
[16166] Fix | Delete
/**
[16167] Fix | Delete
* WordPress dependencies
[16168] Fix | Delete
*/
[16169] Fix | Delete
[16170] Fix | Delete
[16171] Fix | Delete
[16172] Fix | Delete
/**
[16173] Fix | Delete
* Internal dependencies
[16174] Fix | Delete
*/
[16175] Fix | Delete
[16176] Fix | Delete
[16177] Fix | Delete
[16178] Fix | Delete
[16179] Fix | Delete
/**
[16180] Fix | Delete
* Hook that retrieves the given settings for the block instance in use.
[16181] Fix | Delete
*
[16182] Fix | Delete
* It looks up the settings first in the block instance hierarchy.
[16183] Fix | Delete
* If none are found, it'll look them up in the block editor settings.
[16184] Fix | Delete
*
[16185] Fix | Delete
* @param {string[]} paths The paths to the settings.
[16186] Fix | Delete
* @return {any[]} Returns the values defined for the settings.
[16187] Fix | Delete
* @example
[16188] Fix | Delete
* ```js
[16189] Fix | Delete
* const [ fixed, sticky ] = useSettings( 'position.fixed', 'position.sticky' );
[16190] Fix | Delete
* ```
[16191] Fix | Delete
*/
[16192] Fix | Delete
function use_settings_useSettings(...paths) {
[16193] Fix | Delete
const {
[16194] Fix | Delete
clientId = null
[16195] Fix | Delete
} = useBlockEditContext();
[16196] Fix | Delete
return (0,external_wp_data_namespaceObject.useSelect)(select => unlock(select(store)).getBlockSettings(clientId, ...paths),
[16197] Fix | Delete
// eslint-disable-next-line react-hooks/exhaustive-deps
[16198] Fix | Delete
[clientId, ...paths]);
[16199] Fix | Delete
}
[16200] Fix | Delete
[16201] Fix | Delete
/**
[16202] Fix | Delete
* Hook that retrieves the given setting for the block instance in use.
[16203] Fix | Delete
*
[16204] Fix | Delete
* It looks up the setting first in the block instance hierarchy.
[16205] Fix | Delete
* If none is found, it'll look it up in the block editor settings.
[16206] Fix | Delete
*
[16207] Fix | Delete
* @param {string} path The path to the setting.
[16208] Fix | Delete
* @return {any} Returns the value defined for the setting.
[16209] Fix | Delete
* @deprecated 6.5.0 Use useSettings instead.
[16210] Fix | Delete
* @example
[16211] Fix | Delete
* ```js
[16212] Fix | Delete
* const isEnabled = useSetting( 'typography.dropCap' );
[16213] Fix | Delete
* ```
[16214] Fix | Delete
*/
[16215] Fix | Delete
function useSetting(path) {
[16216] Fix | Delete
external_wp_deprecated_default()('wp.blockEditor.useSetting', {
[16217] Fix | Delete
since: '6.5',
[16218] Fix | Delete
alternative: 'wp.blockEditor.useSettings',
[16219] Fix | Delete
note: 'The new useSettings function can retrieve multiple settings at once, with better performance.'
[16220] Fix | Delete
});
[16221] Fix | Delete
const [value] = use_settings_useSettings(path);
[16222] Fix | Delete
return value;
[16223] Fix | Delete
}
[16224] Fix | Delete
[16225] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/font-sizes/fluid-utils.js
[16226] Fix | Delete
/**
[16227] Fix | Delete
* The fluid utilities must match the backend equivalent.
[16228] Fix | Delete
* See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
[16229] Fix | Delete
* ---------------------------------------------------------------
[16230] Fix | Delete
*/
[16231] Fix | Delete
[16232] Fix | Delete
// Defaults.
[16233] Fix | Delete
const DEFAULT_MAXIMUM_VIEWPORT_WIDTH = '1600px';
[16234] Fix | Delete
const DEFAULT_MINIMUM_VIEWPORT_WIDTH = '320px';
[16235] Fix | Delete
const DEFAULT_SCALE_FACTOR = 1;
[16236] Fix | Delete
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
[16237] Fix | Delete
const DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
[16238] Fix | Delete
const DEFAULT_MINIMUM_FONT_SIZE_LIMIT = '14px';
[16239] Fix | Delete
[16240] Fix | Delete
/**
[16241] Fix | Delete
* Computes a fluid font-size value that uses clamp(). A minimum and maximum
[16242] Fix | Delete
* font size OR a single font size can be specified.
[16243] Fix | Delete
*
[16244] Fix | Delete
* If a single font size is specified, it is scaled up and down using a logarithmic scale.
[16245] Fix | Delete
*
[16246] Fix | Delete
* @example
[16247] Fix | Delete
* ```js
[16248] Fix | Delete
* // Calculate fluid font-size value from a minimum and maximum value.
[16249] Fix | Delete
* const fontSize = getComputedFluidTypographyValue( {
[16250] Fix | Delete
* minimumFontSize: '20px',
[16251] Fix | Delete
* maximumFontSize: '45px'
[16252] Fix | Delete
* } );
[16253] Fix | Delete
* // Calculate fluid font-size value from a single font size.
[16254] Fix | Delete
* const fontSize = getComputedFluidTypographyValue( {
[16255] Fix | Delete
* fontSize: '30px',
[16256] Fix | Delete
* } );
[16257] Fix | Delete
* ```
[16258] Fix | Delete
*
[16259] Fix | Delete
* @param {Object} args
[16260] Fix | Delete
* @param {?string} args.minimumViewportWidth Minimum viewport size from which type will have fluidity. Optional if fontSize is specified.
[16261] Fix | Delete
* @param {?string} args.maximumViewportWidth Maximum size up to which type will have fluidity. Optional if fontSize is specified.
[16262] Fix | Delete
* @param {string|number} [args.fontSize] Size to derive maximumFontSize and minimumFontSize from, if necessary. Optional if minimumFontSize and maximumFontSize are specified.
[16263] Fix | Delete
* @param {?string} args.maximumFontSize Maximum font size for any clamp() calculation. Optional.
[16264] Fix | Delete
* @param {?string} args.minimumFontSize Minimum font size for any clamp() calculation. Optional.
[16265] Fix | Delete
* @param {?number} args.scaleFactor A scale factor to determine how fast a font scales within boundaries. Optional.
[16266] Fix | Delete
* @param {?string} args.minimumFontSizeLimit The smallest a calculated font size may be. Optional.
[16267] Fix | Delete
*
[16268] Fix | Delete
* @return {string|null} A font-size value using clamp().
[16269] Fix | Delete
*/
[16270] Fix | Delete
function getComputedFluidTypographyValue({
[16271] Fix | Delete
minimumFontSize,
[16272] Fix | Delete
maximumFontSize,
[16273] Fix | Delete
fontSize,
[16274] Fix | Delete
minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
[16275] Fix | Delete
maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
[16276] Fix | Delete
scaleFactor = DEFAULT_SCALE_FACTOR,
[16277] Fix | Delete
minimumFontSizeLimit
[16278] Fix | Delete
}) {
[16279] Fix | Delete
// Validate incoming settings and set defaults.
[16280] Fix | Delete
minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT;
[16281] Fix | Delete
[16282] Fix | Delete
/*
[16283] Fix | Delete
* Calculates missing minimumFontSize and maximumFontSize from
[16284] Fix | Delete
* defaultFontSize if provided.
[16285] Fix | Delete
*/
[16286] Fix | Delete
if (fontSize) {
[16287] Fix | Delete
// Parses default font size.
[16288] Fix | Delete
const fontSizeParsed = getTypographyValueAndUnit(fontSize);
[16289] Fix | Delete
[16290] Fix | Delete
// Protect against invalid units.
[16291] Fix | Delete
if (!fontSizeParsed?.unit) {
[16292] Fix | Delete
return null;
[16293] Fix | Delete
}
[16294] Fix | Delete
[16295] Fix | Delete
// Parses the minimum font size limit, so we can perform checks using it.
[16296] Fix | Delete
const minimumFontSizeLimitParsed = getTypographyValueAndUnit(minimumFontSizeLimit, {
[16297] Fix | Delete
coerceTo: fontSizeParsed.unit
[16298] Fix | Delete
});
[16299] Fix | Delete
[16300] Fix | Delete
// Don't enforce minimum font size if a font size has explicitly set a min and max value.
[16301] Fix | Delete
if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) {
[16302] Fix | Delete
/*
[16303] Fix | Delete
* If a minimum size was not passed to this function
[16304] Fix | Delete
* and the user-defined font size is lower than $minimum_font_size_limit,
[16305] Fix | Delete
* do not calculate a fluid value.
[16306] Fix | Delete
*/
[16307] Fix | Delete
if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) {
[16308] Fix | Delete
return null;
[16309] Fix | Delete
}
[16310] Fix | Delete
}
[16311] Fix | Delete
[16312] Fix | Delete
// If no fluid max font size is available use the incoming value.
[16313] Fix | Delete
if (!maximumFontSize) {
[16314] Fix | Delete
maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
[16315] Fix | Delete
}
[16316] Fix | Delete
[16317] Fix | Delete
/*
[16318] Fix | Delete
* If no minimumFontSize is provided, create one using
[16319] Fix | Delete
* the given font size multiplied by the min font size scale factor.
[16320] Fix | Delete
*/
[16321] Fix | Delete
if (!minimumFontSize) {
[16322] Fix | Delete
const fontSizeValueInPx = fontSizeParsed.unit === 'px' ? fontSizeParsed.value : fontSizeParsed.value * 16;
[16323] Fix | Delete
[16324] Fix | Delete
/*
[16325] Fix | Delete
* The scale factor is a multiplier that affects how quickly the curve will move towards the minimum,
[16326] Fix | Delete
* that is, how quickly the size factor reaches 0 given increasing font size values.
[16327] Fix | Delete
* For a - b * log2(), lower values of b will make the curve move towards the minimum faster.
[16328] Fix | Delete
* The scale factor is constrained between min and max values.
[16329] Fix | Delete
*/
[16330] Fix | Delete
const minimumFontSizeFactor = Math.min(Math.max(1 - 0.075 * Math.log2(fontSizeValueInPx), DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN), DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX);
[16331] Fix | Delete
[16332] Fix | Delete
// Calculates the minimum font size.
[16333] Fix | Delete
const calculatedMinimumFontSize = roundToPrecision(fontSizeParsed.value * minimumFontSizeFactor, 3);
[16334] Fix | Delete
[16335] Fix | Delete
// Only use calculated min font size if it's > $minimum_font_size_limit value.
[16336] Fix | Delete
if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) {
[16337] Fix | Delete
minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
[16338] Fix | Delete
} else {
[16339] Fix | Delete
minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
[16340] Fix | Delete
}
[16341] Fix | Delete
}
[16342] Fix | Delete
}
[16343] Fix | Delete
[16344] Fix | Delete
// Grab the minimum font size and normalize it in order to use the value for calculations.
[16345] Fix | Delete
const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize);
[16346] Fix | Delete
[16347] Fix | Delete
// We get a 'preferred' unit to keep units consistent when calculating,
[16348] Fix | Delete
// otherwise the result will not be accurate.
[16349] Fix | Delete
const fontSizeUnit = minimumFontSizeParsed?.unit || 'rem';
[16350] Fix | Delete
[16351] Fix | Delete
// Grabs the maximum font size and normalize it in order to use the value for calculations.
[16352] Fix | Delete
const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
[16353] Fix | Delete
coerceTo: fontSizeUnit
[16354] Fix | Delete
});
[16355] Fix | Delete
[16356] Fix | Delete
// Checks for mandatory min and max sizes, and protects against unsupported units.
[16357] Fix | Delete
if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
[16358] Fix | Delete
return null;
[16359] Fix | Delete
}
[16360] Fix | Delete
[16361] Fix | Delete
// Uses rem for accessible fluid target font scaling.
[16362] Fix | Delete
const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
[16363] Fix | Delete
coerceTo: 'rem'
[16364] Fix | Delete
});
[16365] Fix | Delete
[16366] Fix | Delete
// Viewport widths defined for fluid typography. Normalize units
[16367] Fix | Delete
const maximumViewportWidthParsed = getTypographyValueAndUnit(maximumViewportWidth, {
[16368] Fix | Delete
coerceTo: fontSizeUnit
[16369] Fix | Delete
});
[16370] Fix | Delete
const minimumViewportWidthParsed = getTypographyValueAndUnit(minimumViewportWidth, {
[16371] Fix | Delete
coerceTo: fontSizeUnit
[16372] Fix | Delete
});
[16373] Fix | Delete
[16374] Fix | Delete
// Protect against unsupported units.
[16375] Fix | Delete
if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
[16376] Fix | Delete
return null;
[16377] Fix | Delete
}
[16378] Fix | Delete
[16379] Fix | Delete
// Calculates the linear factor denominator. If it's 0, we cannot calculate a fluid value.
[16380] Fix | Delete
const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
[16381] Fix | Delete
if (!linearDenominator) {
[16382] Fix | Delete
return null;
[16383] Fix | Delete
}
[16384] Fix | Delete
[16385] Fix | Delete
// Build CSS rule.
[16386] Fix | Delete
// Borrowed from https://websemantics.uk/tools/responsive-font-calculator/.
[16387] Fix | Delete
const minViewportWidthOffsetValue = roundToPrecision(minimumViewportWidthParsed.value / 100, 3);
[16388] Fix | Delete
const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
[16389] Fix | Delete
const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator);
[16390] Fix | Delete
const linearFactorScaled = roundToPrecision((linearFactor || 1) * scaleFactor, 3);
[16391] Fix | Delete
const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
[16392] Fix | Delete
return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
[16393] Fix | Delete
}
[16394] Fix | Delete
[16395] Fix | Delete
/**
[16396] Fix | Delete
* Internal method that checks a string for a unit and value and returns an array consisting of `'value'` and `'unit'`, e.g., [ '42', 'rem' ].
[16397] Fix | Delete
* A raw font size of `value + unit` is expected. If the value is an integer, it will convert to `value + 'px'`.
[16398] Fix | Delete
*
[16399] Fix | Delete
* @param {string|number} rawValue Raw size value from theme.json.
[16400] Fix | Delete
* @param {Object|undefined} options Calculation options.
[16401] Fix | Delete
*
[16402] Fix | Delete
* @return {{ unit: string, value: number }|null} An object consisting of `'value'` and `'unit'` properties.
[16403] Fix | Delete
*/
[16404] Fix | Delete
function getTypographyValueAndUnit(rawValue, options = {}) {
[16405] Fix | Delete
if (typeof rawValue !== 'string' && typeof rawValue !== 'number') {
[16406] Fix | Delete
return null;
[16407] Fix | Delete
}
[16408] Fix | Delete
[16409] Fix | Delete
// Converts numeric values to pixel values by default.
[16410] Fix | Delete
if (isFinite(rawValue)) {
[16411] Fix | Delete
rawValue = `${rawValue}px`;
[16412] Fix | Delete
}
[16413] Fix | Delete
const {
[16414] Fix | Delete
coerceTo,
[16415] Fix | Delete
rootSizeValue,
[16416] Fix | Delete
acceptableUnits
[16417] Fix | Delete
} = {
[16418] Fix | Delete
coerceTo: '',
[16419] Fix | Delete
// Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
[16420] Fix | Delete
rootSizeValue: 16,
[16421] Fix | Delete
acceptableUnits: ['rem', 'px', 'em'],
[16422] Fix | Delete
...options
[16423] Fix | Delete
};
[16424] Fix | Delete
const acceptableUnitsGroup = acceptableUnits?.join('|');
[16425] Fix | Delete
const regexUnits = new RegExp(`^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`);
[16426] Fix | Delete
const matches = rawValue.match(regexUnits);
[16427] Fix | Delete
[16428] Fix | Delete
// We need a number value and a unit.
[16429] Fix | Delete
if (!matches || matches.length < 3) {
[16430] Fix | Delete
return null;
[16431] Fix | Delete
}
[16432] Fix | Delete
let [, value, unit] = matches;
[16433] Fix | Delete
let returnValue = parseFloat(value);
[16434] Fix | Delete
if ('px' === coerceTo && ('em' === unit || 'rem' === unit)) {
[16435] Fix | Delete
returnValue = returnValue * rootSizeValue;
[16436] Fix | Delete
unit = coerceTo;
[16437] Fix | Delete
}
[16438] Fix | Delete
if ('px' === unit && ('em' === coerceTo || 'rem' === coerceTo)) {
[16439] Fix | Delete
returnValue = returnValue / rootSizeValue;
[16440] Fix | Delete
unit = coerceTo;
[16441] Fix | Delete
}
[16442] Fix | Delete
[16443] Fix | Delete
/*
[16444] Fix | Delete
* No calculation is required if swapping between em and rem yet,
[16445] Fix | Delete
* since we assume a root size value. Later we might like to differentiate between
[16446] Fix | Delete
* :root font size (rem) and parent element font size (em) relativity.
[16447] Fix | Delete
*/
[16448] Fix | Delete
if (('em' === coerceTo || 'rem' === coerceTo) && ('em' === unit || 'rem' === unit)) {
[16449] Fix | Delete
unit = coerceTo;
[16450] Fix | Delete
}
[16451] Fix | Delete
return {
[16452] Fix | Delete
value: roundToPrecision(returnValue, 3),
[16453] Fix | Delete
unit
[16454] Fix | Delete
};
[16455] Fix | Delete
}
[16456] Fix | Delete
[16457] Fix | Delete
/**
[16458] Fix | Delete
* Returns a value rounded to defined precision.
[16459] Fix | Delete
* Returns `undefined` if the value is not a valid finite number.
[16460] Fix | Delete
*
[16461] Fix | Delete
* @param {number} value Raw value.
[16462] Fix | Delete
* @param {number} digits The number of digits to appear after the decimal point
[16463] Fix | Delete
*
[16464] Fix | Delete
* @return {number|undefined} Value rounded to standard precision.
[16465] Fix | Delete
*/
[16466] Fix | Delete
function roundToPrecision(value, digits = 3) {
[16467] Fix | Delete
const base = Math.pow(10, digits);
[16468] Fix | Delete
return Number.isFinite(value) ? parseFloat(Math.round(value * base) / base) : undefined;
[16469] Fix | Delete
}
[16470] Fix | Delete
[16471] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/global-styles/typography-utils.js
[16472] Fix | Delete
/**
[16473] Fix | Delete
* The fluid utilities must match the backend equivalent.
[16474] Fix | Delete
* See: gutenberg_get_typography_font_size_value() in lib/block-supports/typography.php
[16475] Fix | Delete
* ---------------------------------------------------------------
[16476] Fix | Delete
*/
[16477] Fix | Delete
[16478] Fix | Delete
/**
[16479] Fix | Delete
* Internal dependencies
[16480] Fix | Delete
*/
[16481] Fix | Delete
[16482] Fix | Delete
[16483] Fix | Delete
/**
[16484] Fix | Delete
* @typedef {Object} FluidPreset
[16485] Fix | Delete
* @property {string|undefined} max A maximum font size value.
[16486] Fix | Delete
* @property {?string|undefined} min A minimum font size value.
[16487] Fix | Delete
*/
[16488] Fix | Delete
[16489] Fix | Delete
/**
[16490] Fix | Delete
* @typedef {Object} Preset
[16491] Fix | Delete
* @property {?string|?number} size A default font size.
[16492] Fix | Delete
* @property {string} name A font size name, displayed in the UI.
[16493] Fix | Delete
* @property {string} slug A font size slug
[16494] Fix | Delete
* @property {boolean|FluidPreset|undefined} fluid Specifies the minimum and maximum font size value of a fluid font size.
[16495] Fix | Delete
*/
[16496] Fix | Delete
[16497] Fix | Delete
/**
[16498] Fix | Delete
* @typedef {Object} TypographySettings
[16499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function