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
blockType,
[67000] Fix | Delete
topLevelLockedBlock
[67001] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[67002] Fix | Delete
const {
[67003] Fix | Delete
getSelectedBlockClientId,
[67004] Fix | Delete
getSelectedBlockCount,
[67005] Fix | Delete
getBlockName,
[67006] Fix | Delete
getContentLockingParent,
[67007] Fix | Delete
getTemplateLock
[67008] Fix | Delete
} = unlock(select(store));
[67009] Fix | Delete
const _selectedBlockClientId = getSelectedBlockClientId();
[67010] Fix | Delete
const _selectedBlockName = _selectedBlockClientId && getBlockName(_selectedBlockClientId);
[67011] Fix | Delete
const _blockType = _selectedBlockName && (0,external_wp_blocks_namespaceObject.getBlockType)(_selectedBlockName);
[67012] Fix | Delete
return {
[67013] Fix | Delete
count: getSelectedBlockCount(),
[67014] Fix | Delete
selectedBlockClientId: _selectedBlockClientId,
[67015] Fix | Delete
selectedBlockName: _selectedBlockName,
[67016] Fix | Delete
blockType: _blockType,
[67017] Fix | Delete
topLevelLockedBlock: getContentLockingParent(_selectedBlockClientId) || (getTemplateLock(_selectedBlockClientId) === 'contentOnly' || _selectedBlockName === 'core/block' ? _selectedBlockClientId : undefined)
[67018] Fix | Delete
};
[67019] Fix | Delete
}, []);
[67020] Fix | Delete
const availableTabs = useInspectorControlsTabs(blockType?.name);
[67021] Fix | Delete
const showTabs = availableTabs?.length > 1;
[67022] Fix | Delete
[67023] Fix | Delete
// The block inspector animation settings will be completely
[67024] Fix | Delete
// removed in the future to create an API which allows the block
[67025] Fix | Delete
// inspector to transition between what it
[67026] Fix | Delete
// displays based on the relationship between the selected block
[67027] Fix | Delete
// and its parent, and only enable it if the parent is controlling
[67028] Fix | Delete
// its children blocks.
[67029] Fix | Delete
const blockInspectorAnimationSettings = useBlockInspectorAnimationSettings(blockType);
[67030] Fix | Delete
const borderPanelLabel = useBorderPanelLabel({
[67031] Fix | Delete
blockName: selectedBlockName
[67032] Fix | Delete
});
[67033] Fix | Delete
if (count > 1) {
[67034] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[67035] Fix | Delete
className: "block-editor-block-inspector",
[67036] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(multi_selection_inspector, {}), showTabs ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InspectorControlsTabs, {
[67037] Fix | Delete
tabs: availableTabs
[67038] Fix | Delete
}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[67039] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67040] Fix | Delete
group: "color",
[67041] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Color'),
[67042] Fix | Delete
className: "color-block-support-panel__inner-wrapper"
[67043] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67044] Fix | Delete
group: "typography",
[67045] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Typography')
[67046] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67047] Fix | Delete
group: "dimensions",
[67048] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
[67049] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67050] Fix | Delete
group: "border",
[67051] Fix | Delete
label: borderPanelLabel
[67052] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67053] Fix | Delete
group: "styles"
[67054] Fix | Delete
})]
[67055] Fix | Delete
})]
[67056] Fix | Delete
});
[67057] Fix | Delete
}
[67058] Fix | Delete
const isSelectedBlockUnregistered = selectedBlockName === (0,external_wp_blocks_namespaceObject.getUnregisteredTypeHandlerName)();
[67059] Fix | Delete
[67060] Fix | Delete
/*
[67061] Fix | Delete
* If the selected block is of an unregistered type, avoid showing it as an actual selection
[67062] Fix | Delete
* because we want the user to focus on the unregistered block warning, not block settings.
[67063] Fix | Delete
*/
[67064] Fix | Delete
if (!blockType || !selectedBlockClientId || isSelectedBlockUnregistered) {
[67065] Fix | Delete
if (showNoBlockSelectedMessage) {
[67066] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
[67067] Fix | Delete
className: "block-editor-block-inspector__no-blocks",
[67068] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('No block selected.')
[67069] Fix | Delete
});
[67070] Fix | Delete
}
[67071] Fix | Delete
return null;
[67072] Fix | Delete
}
[67073] Fix | Delete
if (topLevelLockedBlock) {
[67074] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockInspectorLockedBlocks, {
[67075] Fix | Delete
topLevelLockedBlock: topLevelLockedBlock
[67076] Fix | Delete
});
[67077] Fix | Delete
}
[67078] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockInspectorSingleBlockWrapper, {
[67079] Fix | Delete
animate: blockInspectorAnimationSettings,
[67080] Fix | Delete
wrapper: children => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AnimatedContainer, {
[67081] Fix | Delete
blockInspectorAnimationSettings: blockInspectorAnimationSettings,
[67082] Fix | Delete
selectedBlockClientId: selectedBlockClientId,
[67083] Fix | Delete
children: children
[67084] Fix | Delete
}),
[67085] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockInspectorSingleBlock, {
[67086] Fix | Delete
clientId: selectedBlockClientId,
[67087] Fix | Delete
blockName: blockType.name
[67088] Fix | Delete
})
[67089] Fix | Delete
});
[67090] Fix | Delete
};
[67091] Fix | Delete
const BlockInspectorSingleBlockWrapper = ({
[67092] Fix | Delete
animate,
[67093] Fix | Delete
wrapper,
[67094] Fix | Delete
children
[67095] Fix | Delete
}) => {
[67096] Fix | Delete
return animate ? wrapper(children) : children;
[67097] Fix | Delete
};
[67098] Fix | Delete
const AnimatedContainer = ({
[67099] Fix | Delete
blockInspectorAnimationSettings,
[67100] Fix | Delete
selectedBlockClientId,
[67101] Fix | Delete
children
[67102] Fix | Delete
}) => {
[67103] Fix | Delete
const animationOrigin = blockInspectorAnimationSettings && blockInspectorAnimationSettings.enterDirection === 'leftToRight' ? -50 : 50;
[67104] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
[67105] Fix | Delete
animate: {
[67106] Fix | Delete
x: 0,
[67107] Fix | Delete
opacity: 1,
[67108] Fix | Delete
transition: {
[67109] Fix | Delete
ease: 'easeInOut',
[67110] Fix | Delete
duration: 0.14
[67111] Fix | Delete
}
[67112] Fix | Delete
},
[67113] Fix | Delete
initial: {
[67114] Fix | Delete
x: animationOrigin,
[67115] Fix | Delete
opacity: 0
[67116] Fix | Delete
},
[67117] Fix | Delete
children: children
[67118] Fix | Delete
}, selectedBlockClientId);
[67119] Fix | Delete
};
[67120] Fix | Delete
const BlockInspectorSingleBlock = ({
[67121] Fix | Delete
clientId,
[67122] Fix | Delete
blockName
[67123] Fix | Delete
}) => {
[67124] Fix | Delete
const availableTabs = useInspectorControlsTabs(blockName);
[67125] Fix | Delete
const showTabs = availableTabs?.length > 1;
[67126] Fix | Delete
const hasBlockStyles = (0,external_wp_data_namespaceObject.useSelect)(select => {
[67127] Fix | Delete
const {
[67128] Fix | Delete
getBlockStyles
[67129] Fix | Delete
} = select(external_wp_blocks_namespaceObject.store);
[67130] Fix | Delete
const blockStyles = getBlockStyles(blockName);
[67131] Fix | Delete
return blockStyles && blockStyles.length > 0;
[67132] Fix | Delete
}, [blockName]);
[67133] Fix | Delete
const blockInformation = useBlockDisplayInformation(clientId);
[67134] Fix | Delete
const borderPanelLabel = useBorderPanelLabel({
[67135] Fix | Delete
blockName
[67136] Fix | Delete
});
[67137] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[67138] Fix | Delete
className: "block-editor-block-inspector",
[67139] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_card, {
[67140] Fix | Delete
...blockInformation,
[67141] Fix | Delete
className: blockInformation.isSynced && 'is-synced'
[67142] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_variation_transforms, {
[67143] Fix | Delete
blockClientId: clientId
[67144] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_info_slot_fill.Slot, {}), showTabs && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InspectorControlsTabs, {
[67145] Fix | Delete
hasBlockStyles: hasBlockStyles,
[67146] Fix | Delete
clientId: clientId,
[67147] Fix | Delete
blockName: blockName,
[67148] Fix | Delete
tabs: availableTabs
[67149] Fix | Delete
}), !showTabs && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[67150] Fix | Delete
children: [hasBlockStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
[67151] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
[67152] Fix | Delete
title: (0,external_wp_i18n_namespaceObject.__)('Styles'),
[67153] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_styles, {
[67154] Fix | Delete
clientId: clientId
[67155] Fix | Delete
})
[67156] Fix | Delete
})
[67157] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67158] Fix | Delete
group: "list"
[67159] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67160] Fix | Delete
group: "color",
[67161] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Color'),
[67162] Fix | Delete
className: "color-block-support-panel__inner-wrapper"
[67163] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67164] Fix | Delete
group: "typography",
[67165] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Typography')
[67166] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67167] Fix | Delete
group: "dimensions",
[67168] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Dimensions')
[67169] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67170] Fix | Delete
group: "border",
[67171] Fix | Delete
label: borderPanelLabel
[67172] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67173] Fix | Delete
group: "styles"
[67174] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(inspector_controls.Slot, {
[67175] Fix | Delete
group: "background",
[67176] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Background image')
[67177] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(position_controls_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
[67178] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(advanced_controls_panel, {})
[67179] Fix | Delete
})]
[67180] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SkipToSelectedBlock, {}, "back")]
[67181] Fix | Delete
});
[67182] Fix | Delete
};
[67183] Fix | Delete
[67184] Fix | Delete
/**
[67185] Fix | Delete
* @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/block-inspector/README.md
[67186] Fix | Delete
*/
[67187] Fix | Delete
/* harmony default export */ const block_inspector = (BlockInspector);
[67188] Fix | Delete
[67189] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/copy-handler/index.js
[67190] Fix | Delete
/**
[67191] Fix | Delete
* WordPress dependencies
[67192] Fix | Delete
*/
[67193] Fix | Delete
[67194] Fix | Delete
[67195] Fix | Delete
/**
[67196] Fix | Delete
* Internal dependencies
[67197] Fix | Delete
*/
[67198] Fix | Delete
[67199] Fix | Delete
[67200] Fix | Delete
/**
[67201] Fix | Delete
* @deprecated
[67202] Fix | Delete
*/
[67203] Fix | Delete
[67204] Fix | Delete
const __unstableUseClipboardHandler = () => {
[67205] Fix | Delete
external_wp_deprecated_default()('__unstableUseClipboardHandler', {
[67206] Fix | Delete
alternative: 'BlockCanvas or WritingFlow',
[67207] Fix | Delete
since: '6.4',
[67208] Fix | Delete
version: '6.7'
[67209] Fix | Delete
});
[67210] Fix | Delete
return useClipboardHandler();
[67211] Fix | Delete
};
[67212] Fix | Delete
[67213] Fix | Delete
/**
[67214] Fix | Delete
* @deprecated
[67215] Fix | Delete
* @param {Object} props
[67216] Fix | Delete
*/
[67217] Fix | Delete
function CopyHandler(props) {
[67218] Fix | Delete
external_wp_deprecated_default()('CopyHandler', {
[67219] Fix | Delete
alternative: 'BlockCanvas or WritingFlow',
[67220] Fix | Delete
since: '6.4',
[67221] Fix | Delete
version: '6.7'
[67222] Fix | Delete
});
[67223] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
[67224] Fix | Delete
...props,
[67225] Fix | Delete
ref: useClipboardHandler()
[67226] Fix | Delete
});
[67227] Fix | Delete
}
[67228] Fix | Delete
[67229] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/inserter/library.js
[67230] Fix | Delete
/**
[67231] Fix | Delete
* WordPress dependencies
[67232] Fix | Delete
*/
[67233] Fix | Delete
[67234] Fix | Delete
[67235] Fix | Delete
[67236] Fix | Delete
/**
[67237] Fix | Delete
* Internal dependencies
[67238] Fix | Delete
*/
[67239] Fix | Delete
[67240] Fix | Delete
[67241] Fix | Delete
[67242] Fix | Delete
const library_noop = () => {};
[67243] Fix | Delete
function InserterLibrary({
[67244] Fix | Delete
rootClientId,
[67245] Fix | Delete
clientId,
[67246] Fix | Delete
isAppender,
[67247] Fix | Delete
showInserterHelpPanel,
[67248] Fix | Delete
showMostUsedBlocks = false,
[67249] Fix | Delete
__experimentalInsertionIndex,
[67250] Fix | Delete
__experimentalInitialTab,
[67251] Fix | Delete
__experimentalInitialCategory,
[67252] Fix | Delete
__experimentalFilterValue,
[67253] Fix | Delete
onPatternCategorySelection,
[67254] Fix | Delete
onSelect = library_noop,
[67255] Fix | Delete
shouldFocusBlock = false,
[67256] Fix | Delete
onClose
[67257] Fix | Delete
}, ref) {
[67258] Fix | Delete
const {
[67259] Fix | Delete
destinationRootClientId
[67260] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[67261] Fix | Delete
const {
[67262] Fix | Delete
getBlockRootClientId
[67263] Fix | Delete
} = select(store);
[67264] Fix | Delete
const _rootClientId = rootClientId || getBlockRootClientId(clientId) || undefined;
[67265] Fix | Delete
return {
[67266] Fix | Delete
destinationRootClientId: _rootClientId
[67267] Fix | Delete
};
[67268] Fix | Delete
}, [clientId, rootClientId]);
[67269] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterMenu, {
[67270] Fix | Delete
onSelect: onSelect,
[67271] Fix | Delete
rootClientId: destinationRootClientId,
[67272] Fix | Delete
clientId: clientId,
[67273] Fix | Delete
isAppender: isAppender,
[67274] Fix | Delete
showInserterHelpPanel: showInserterHelpPanel,
[67275] Fix | Delete
showMostUsedBlocks: showMostUsedBlocks,
[67276] Fix | Delete
__experimentalInsertionIndex: __experimentalInsertionIndex,
[67277] Fix | Delete
__experimentalFilterValue: __experimentalFilterValue,
[67278] Fix | Delete
onPatternCategorySelection: onPatternCategorySelection,
[67279] Fix | Delete
__experimentalInitialTab: __experimentalInitialTab,
[67280] Fix | Delete
__experimentalInitialCategory: __experimentalInitialCategory,
[67281] Fix | Delete
shouldFocusBlock: shouldFocusBlock,
[67282] Fix | Delete
ref: ref,
[67283] Fix | Delete
onClose: onClose
[67284] Fix | Delete
});
[67285] Fix | Delete
}
[67286] Fix | Delete
const PrivateInserterLibrary = (0,external_wp_element_namespaceObject.forwardRef)(InserterLibrary);
[67287] Fix | Delete
function PublicInserterLibrary(props, ref) {
[67288] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
[67289] Fix | Delete
...props,
[67290] Fix | Delete
onPatternCategorySelection: undefined,
[67291] Fix | Delete
ref: ref
[67292] Fix | Delete
});
[67293] Fix | Delete
}
[67294] Fix | Delete
/* harmony default export */ const library = ((0,external_wp_element_namespaceObject.forwardRef)(PublicInserterLibrary));
[67295] Fix | Delete
[67296] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/selection-scroll-into-view/index.js
[67297] Fix | Delete
/**
[67298] Fix | Delete
* WordPress dependencies
[67299] Fix | Delete
*/
[67300] Fix | Delete
[67301] Fix | Delete
[67302] Fix | Delete
/**
[67303] Fix | Delete
* Scrolls the multi block selection end into view if not in view already. This
[67304] Fix | Delete
* is important to do after selection by keyboard.
[67305] Fix | Delete
*
[67306] Fix | Delete
* @deprecated
[67307] Fix | Delete
*/
[67308] Fix | Delete
function MultiSelectScrollIntoView() {
[67309] Fix | Delete
external_wp_deprecated_default()('wp.blockEditor.MultiSelectScrollIntoView', {
[67310] Fix | Delete
hint: 'This behaviour is now built-in.',
[67311] Fix | Delete
since: '5.8'
[67312] Fix | Delete
});
[67313] Fix | Delete
return null;
[67314] Fix | Delete
}
[67315] Fix | Delete
[67316] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/typewriter/index.js
[67317] Fix | Delete
/**
[67318] Fix | Delete
* WordPress dependencies
[67319] Fix | Delete
*/
[67320] Fix | Delete
[67321] Fix | Delete
[67322] Fix | Delete
[67323] Fix | Delete
[67324] Fix | Delete
[67325] Fix | Delete
/**
[67326] Fix | Delete
* Internal dependencies
[67327] Fix | Delete
*/
[67328] Fix | Delete
[67329] Fix | Delete
[67330] Fix | Delete
const isIE = window.navigator.userAgent.indexOf('Trident') !== -1;
[67331] Fix | Delete
const arrowKeyCodes = new Set([external_wp_keycodes_namespaceObject.UP, external_wp_keycodes_namespaceObject.DOWN, external_wp_keycodes_namespaceObject.LEFT, external_wp_keycodes_namespaceObject.RIGHT]);
[67332] Fix | Delete
const initialTriggerPercentage = 0.75;
[67333] Fix | Delete
function useTypewriter() {
[67334] Fix | Delete
const hasSelectedBlock = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).hasSelectedBlock(), []);
[67335] Fix | Delete
return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
[67336] Fix | Delete
if (!hasSelectedBlock) {
[67337] Fix | Delete
return;
[67338] Fix | Delete
}
[67339] Fix | Delete
const {
[67340] Fix | Delete
ownerDocument
[67341] Fix | Delete
} = node;
[67342] Fix | Delete
const {
[67343] Fix | Delete
defaultView
[67344] Fix | Delete
} = ownerDocument;
[67345] Fix | Delete
let scrollResizeRafId;
[67346] Fix | Delete
let onKeyDownRafId;
[67347] Fix | Delete
let caretRect;
[67348] Fix | Delete
function onScrollResize() {
[67349] Fix | Delete
if (scrollResizeRafId) {
[67350] Fix | Delete
return;
[67351] Fix | Delete
}
[67352] Fix | Delete
scrollResizeRafId = defaultView.requestAnimationFrame(() => {
[67353] Fix | Delete
computeCaretRectangle();
[67354] Fix | Delete
scrollResizeRafId = null;
[67355] Fix | Delete
});
[67356] Fix | Delete
}
[67357] Fix | Delete
function onKeyDown(event) {
[67358] Fix | Delete
// Ensure the any remaining request is cancelled.
[67359] Fix | Delete
if (onKeyDownRafId) {
[67360] Fix | Delete
defaultView.cancelAnimationFrame(onKeyDownRafId);
[67361] Fix | Delete
}
[67362] Fix | Delete
[67363] Fix | Delete
// Use an animation frame for a smooth result.
[67364] Fix | Delete
onKeyDownRafId = defaultView.requestAnimationFrame(() => {
[67365] Fix | Delete
maintainCaretPosition(event);
[67366] Fix | Delete
onKeyDownRafId = null;
[67367] Fix | Delete
});
[67368] Fix | Delete
}
[67369] Fix | Delete
[67370] Fix | Delete
/**
[67371] Fix | Delete
* Maintains the scroll position after a selection change caused by a
[67372] Fix | Delete
* keyboard event.
[67373] Fix | Delete
*
[67374] Fix | Delete
* @param {KeyboardEvent} event Keyboard event.
[67375] Fix | Delete
*/
[67376] Fix | Delete
function maintainCaretPosition({
[67377] Fix | Delete
keyCode
[67378] Fix | Delete
}) {
[67379] Fix | Delete
if (!isSelectionEligibleForScroll()) {
[67380] Fix | Delete
return;
[67381] Fix | Delete
}
[67382] Fix | Delete
const currentCaretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
[67383] Fix | Delete
if (!currentCaretRect) {
[67384] Fix | Delete
return;
[67385] Fix | Delete
}
[67386] Fix | Delete
[67387] Fix | Delete
// If for some reason there is no position set to be scrolled to, let
[67388] Fix | Delete
// this be the position to be scrolled to in the future.
[67389] Fix | Delete
if (!caretRect) {
[67390] Fix | Delete
caretRect = currentCaretRect;
[67391] Fix | Delete
return;
[67392] Fix | Delete
}
[67393] Fix | Delete
[67394] Fix | Delete
// Even though enabling the typewriter effect for arrow keys results in
[67395] Fix | Delete
// a pleasant experience, it may not be the case for everyone, so, for
[67396] Fix | Delete
// now, let's disable it.
[67397] Fix | Delete
if (arrowKeyCodes.has(keyCode)) {
[67398] Fix | Delete
// Reset the caret position to maintain.
[67399] Fix | Delete
caretRect = currentCaretRect;
[67400] Fix | Delete
return;
[67401] Fix | Delete
}
[67402] Fix | Delete
const diff = currentCaretRect.top - caretRect.top;
[67403] Fix | Delete
if (diff === 0) {
[67404] Fix | Delete
return;
[67405] Fix | Delete
}
[67406] Fix | Delete
const scrollContainer = (0,external_wp_dom_namespaceObject.getScrollContainer)(node);
[67407] Fix | Delete
[67408] Fix | Delete
// The page must be scrollable.
[67409] Fix | Delete
if (!scrollContainer) {
[67410] Fix | Delete
return;
[67411] Fix | Delete
}
[67412] Fix | Delete
const windowScroll = scrollContainer === ownerDocument.body || scrollContainer === ownerDocument.documentElement;
[67413] Fix | Delete
const scrollY = windowScroll ? defaultView.scrollY : scrollContainer.scrollTop;
[67414] Fix | Delete
const scrollContainerY = windowScroll ? 0 : scrollContainer.getBoundingClientRect().top;
[67415] Fix | Delete
const relativeScrollPosition = windowScroll ? caretRect.top / defaultView.innerHeight : (caretRect.top - scrollContainerY) / (defaultView.innerHeight - scrollContainerY);
[67416] Fix | Delete
[67417] Fix | Delete
// If the scroll position is at the start, the active editable element
[67418] Fix | Delete
// is the last one, and the caret is positioned within the initial
[67419] Fix | Delete
// trigger percentage of the page, do not scroll the page.
[67420] Fix | Delete
// The typewriter effect should not kick in until an empty page has been
[67421] Fix | Delete
// filled with the initial trigger percentage or the user scrolls
[67422] Fix | Delete
// intentionally down.
[67423] Fix | Delete
if (scrollY === 0 && relativeScrollPosition < initialTriggerPercentage && isLastEditableNode()) {
[67424] Fix | Delete
// Reset the caret position to maintain.
[67425] Fix | Delete
caretRect = currentCaretRect;
[67426] Fix | Delete
return;
[67427] Fix | Delete
}
[67428] Fix | Delete
const scrollContainerHeight = windowScroll ? defaultView.innerHeight : scrollContainer.clientHeight;
[67429] Fix | Delete
[67430] Fix | Delete
// Abort if the target scroll position would scroll the caret out of
[67431] Fix | Delete
// view.
[67432] Fix | Delete
if (
[67433] Fix | Delete
// The caret is under the lower fold.
[67434] Fix | Delete
caretRect.top + caretRect.height > scrollContainerY + scrollContainerHeight ||
[67435] Fix | Delete
// The caret is above the upper fold.
[67436] Fix | Delete
caretRect.top < scrollContainerY) {
[67437] Fix | Delete
// Reset the caret position to maintain.
[67438] Fix | Delete
caretRect = currentCaretRect;
[67439] Fix | Delete
return;
[67440] Fix | Delete
}
[67441] Fix | Delete
if (windowScroll) {
[67442] Fix | Delete
defaultView.scrollBy(0, diff);
[67443] Fix | Delete
} else {
[67444] Fix | Delete
scrollContainer.scrollTop += diff;
[67445] Fix | Delete
}
[67446] Fix | Delete
}
[67447] Fix | Delete
[67448] Fix | Delete
/**
[67449] Fix | Delete
* Adds a `selectionchange` listener to reset the scroll position to be
[67450] Fix | Delete
* maintained.
[67451] Fix | Delete
*/
[67452] Fix | Delete
function addSelectionChangeListener() {
[67453] Fix | Delete
ownerDocument.addEventListener('selectionchange', computeCaretRectOnSelectionChange);
[67454] Fix | Delete
}
[67455] Fix | Delete
[67456] Fix | Delete
/**
[67457] Fix | Delete
* Resets the scroll position to be maintained during a `selectionchange`
[67458] Fix | Delete
* event. Also removes the listener, so it acts as a one-time listener.
[67459] Fix | Delete
*/
[67460] Fix | Delete
function computeCaretRectOnSelectionChange() {
[67461] Fix | Delete
ownerDocument.removeEventListener('selectionchange', computeCaretRectOnSelectionChange);
[67462] Fix | Delete
computeCaretRectangle();
[67463] Fix | Delete
}
[67464] Fix | Delete
[67465] Fix | Delete
/**
[67466] Fix | Delete
* Resets the scroll position to be maintained.
[67467] Fix | Delete
*/
[67468] Fix | Delete
function computeCaretRectangle() {
[67469] Fix | Delete
if (isSelectionEligibleForScroll()) {
[67470] Fix | Delete
caretRect = (0,external_wp_dom_namespaceObject.computeCaretRect)(defaultView);
[67471] Fix | Delete
}
[67472] Fix | Delete
}
[67473] Fix | Delete
[67474] Fix | Delete
/**
[67475] Fix | Delete
* Checks if the current situation is elegible for scroll:
[67476] Fix | Delete
* - There should be one and only one block selected.
[67477] Fix | Delete
* - The component must contain the selection.
[67478] Fix | Delete
* - The active element must be contenteditable.
[67479] Fix | Delete
*/
[67480] Fix | Delete
function isSelectionEligibleForScroll() {
[67481] Fix | Delete
return node.contains(ownerDocument.activeElement) && ownerDocument.activeElement.isContentEditable;
[67482] Fix | Delete
}
[67483] Fix | Delete
function isLastEditableNode() {
[67484] Fix | Delete
const editableNodes = node.querySelectorAll('[contenteditable="true"]');
[67485] Fix | Delete
const lastEditableNode = editableNodes[editableNodes.length - 1];
[67486] Fix | Delete
return lastEditableNode === ownerDocument.activeElement;
[67487] Fix | Delete
}
[67488] Fix | Delete
[67489] Fix | Delete
// When the user scrolls or resizes, the scroll position should be
[67490] Fix | Delete
// reset.
[67491] Fix | Delete
defaultView.addEventListener('scroll', onScrollResize, true);
[67492] Fix | Delete
defaultView.addEventListener('resize', onScrollResize, true);
[67493] Fix | Delete
node.addEventListener('keydown', onKeyDown);
[67494] Fix | Delete
node.addEventListener('keyup', maintainCaretPosition);
[67495] Fix | Delete
node.addEventListener('mousedown', addSelectionChangeListener);
[67496] Fix | Delete
node.addEventListener('touchstart', addSelectionChangeListener);
[67497] Fix | Delete
return () => {
[67498] Fix | Delete
defaultView.removeEventListener('scroll', onScrollResize, true);
[67499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function