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
const {
[43000] Fix | Delete
__unstableIsFullySelected,
[43001] Fix | Delete
getSelectedBlockClientIds,
[43002] Fix | Delete
getSelectedBlockClientId,
[43003] Fix | Delete
__unstableIsSelectionMergeable,
[43004] Fix | Delete
hasMultiSelection,
[43005] Fix | Delete
getBlockName,
[43006] Fix | Delete
canInsertBlockType,
[43007] Fix | Delete
getBlockRootClientId,
[43008] Fix | Delete
getSelectionStart,
[43009] Fix | Delete
getSelectionEnd,
[43010] Fix | Delete
getBlockAttributes
[43011] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[43012] Fix | Delete
const {
[43013] Fix | Delete
replaceBlocks,
[43014] Fix | Delete
__unstableSplitSelection,
[43015] Fix | Delete
removeBlocks,
[43016] Fix | Delete
__unstableDeleteSelection,
[43017] Fix | Delete
__unstableExpandSelection,
[43018] Fix | Delete
__unstableMarkAutomaticChange
[43019] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
[43020] Fix | Delete
return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
[43021] Fix | Delete
function onBeforeInput(event) {
[43022] Fix | Delete
// If writing flow is editable, NEVER allow the browser to alter the
[43023] Fix | Delete
// DOM. This will cause React errors (and the DOM should only be
[43024] Fix | Delete
// altered in a controlled fashion).
[43025] Fix | Delete
if (node.contentEditable === 'true') {
[43026] Fix | Delete
event.preventDefault();
[43027] Fix | Delete
}
[43028] Fix | Delete
}
[43029] Fix | Delete
function onKeyDown(event) {
[43030] Fix | Delete
if (event.defaultPrevented) {
[43031] Fix | Delete
return;
[43032] Fix | Delete
}
[43033] Fix | Delete
if (!hasMultiSelection()) {
[43034] Fix | Delete
if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
[43035] Fix | Delete
if (event.shiftKey || __unstableIsFullySelected()) {
[43036] Fix | Delete
return;
[43037] Fix | Delete
}
[43038] Fix | Delete
const clientId = getSelectedBlockClientId();
[43039] Fix | Delete
const blockName = getBlockName(clientId);
[43040] Fix | Delete
const selectionStart = getSelectionStart();
[43041] Fix | Delete
const selectionEnd = getSelectionEnd();
[43042] Fix | Delete
if (selectionStart.attributeKey === selectionEnd.attributeKey) {
[43043] Fix | Delete
const selectedAttributeValue = getBlockAttributes(clientId)[selectionStart.attributeKey];
[43044] Fix | Delete
const transforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from').filter(({
[43045] Fix | Delete
type
[43046] Fix | Delete
}) => type === 'enter');
[43047] Fix | Delete
const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(transforms, item => {
[43048] Fix | Delete
return item.regExp.test(selectedAttributeValue);
[43049] Fix | Delete
});
[43050] Fix | Delete
if (transformation) {
[43051] Fix | Delete
replaceBlocks(clientId, transformation.transform({
[43052] Fix | Delete
content: selectedAttributeValue
[43053] Fix | Delete
}));
[43054] Fix | Delete
__unstableMarkAutomaticChange();
[43055] Fix | Delete
return;
[43056] Fix | Delete
}
[43057] Fix | Delete
}
[43058] Fix | Delete
if (!(0,external_wp_blocks_namespaceObject.hasBlockSupport)(blockName, 'splitting', false) && !event.__deprecatedOnSplit) {
[43059] Fix | Delete
return;
[43060] Fix | Delete
}
[43061] Fix | Delete
[43062] Fix | Delete
// Ensure template is not locked.
[43063] Fix | Delete
if (canInsertBlockType(blockName, getBlockRootClientId(clientId))) {
[43064] Fix | Delete
__unstableSplitSelection();
[43065] Fix | Delete
event.preventDefault();
[43066] Fix | Delete
}
[43067] Fix | Delete
}
[43068] Fix | Delete
return;
[43069] Fix | Delete
}
[43070] Fix | Delete
if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
[43071] Fix | Delete
node.contentEditable = false;
[43072] Fix | Delete
event.preventDefault();
[43073] Fix | Delete
if (__unstableIsFullySelected()) {
[43074] Fix | Delete
replaceBlocks(getSelectedBlockClientIds(), (0,external_wp_blocks_namespaceObject.createBlock)((0,external_wp_blocks_namespaceObject.getDefaultBlockName)()));
[43075] Fix | Delete
} else {
[43076] Fix | Delete
__unstableSplitSelection();
[43077] Fix | Delete
}
[43078] Fix | Delete
} else if (event.keyCode === external_wp_keycodes_namespaceObject.BACKSPACE || event.keyCode === external_wp_keycodes_namespaceObject.DELETE) {
[43079] Fix | Delete
node.contentEditable = false;
[43080] Fix | Delete
event.preventDefault();
[43081] Fix | Delete
if (__unstableIsFullySelected()) {
[43082] Fix | Delete
removeBlocks(getSelectedBlockClientIds());
[43083] Fix | Delete
} else if (__unstableIsSelectionMergeable()) {
[43084] Fix | Delete
__unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
[43085] Fix | Delete
} else {
[43086] Fix | Delete
__unstableExpandSelection();
[43087] Fix | Delete
}
[43088] Fix | Delete
} else if (
[43089] Fix | Delete
// If key.length is longer than 1, it's a control key that doesn't
[43090] Fix | Delete
// input anything.
[43091] Fix | Delete
event.key.length === 1 && !(event.metaKey || event.ctrlKey)) {
[43092] Fix | Delete
node.contentEditable = false;
[43093] Fix | Delete
if (__unstableIsSelectionMergeable()) {
[43094] Fix | Delete
__unstableDeleteSelection(event.keyCode === external_wp_keycodes_namespaceObject.DELETE);
[43095] Fix | Delete
} else {
[43096] Fix | Delete
event.preventDefault();
[43097] Fix | Delete
// Safari does not stop default behaviour with either
[43098] Fix | Delete
// event.preventDefault() or node.contentEditable = false, so
[43099] Fix | Delete
// remove the selection to stop browser manipulation.
[43100] Fix | Delete
node.ownerDocument.defaultView.getSelection().removeAllRanges();
[43101] Fix | Delete
}
[43102] Fix | Delete
}
[43103] Fix | Delete
}
[43104] Fix | Delete
function onCompositionStart(event) {
[43105] Fix | Delete
if (!hasMultiSelection()) {
[43106] Fix | Delete
return;
[43107] Fix | Delete
}
[43108] Fix | Delete
node.contentEditable = false;
[43109] Fix | Delete
if (__unstableIsSelectionMergeable()) {
[43110] Fix | Delete
__unstableDeleteSelection();
[43111] Fix | Delete
} else {
[43112] Fix | Delete
event.preventDefault();
[43113] Fix | Delete
// Safari does not stop default behaviour with either
[43114] Fix | Delete
// event.preventDefault() or node.contentEditable = false, so
[43115] Fix | Delete
// remove the selection to stop browser manipulation.
[43116] Fix | Delete
node.ownerDocument.defaultView.getSelection().removeAllRanges();
[43117] Fix | Delete
}
[43118] Fix | Delete
}
[43119] Fix | Delete
node.addEventListener('beforeinput', onBeforeInput);
[43120] Fix | Delete
node.addEventListener('keydown', onKeyDown);
[43121] Fix | Delete
node.addEventListener('compositionstart', onCompositionStart);
[43122] Fix | Delete
return () => {
[43123] Fix | Delete
node.removeEventListener('beforeinput', onBeforeInput);
[43124] Fix | Delete
node.removeEventListener('keydown', onKeyDown);
[43125] Fix | Delete
node.removeEventListener('compositionstart', onCompositionStart);
[43126] Fix | Delete
};
[43127] Fix | Delete
}, []);
[43128] Fix | Delete
}
[43129] Fix | Delete
[43130] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/use-notify-copy.js
[43131] Fix | Delete
/**
[43132] Fix | Delete
* WordPress dependencies
[43133] Fix | Delete
*/
[43134] Fix | Delete
[43135] Fix | Delete
[43136] Fix | Delete
[43137] Fix | Delete
[43138] Fix | Delete
[43139] Fix | Delete
[43140] Fix | Delete
/**
[43141] Fix | Delete
* Internal dependencies
[43142] Fix | Delete
*/
[43143] Fix | Delete
[43144] Fix | Delete
function useNotifyCopy() {
[43145] Fix | Delete
const {
[43146] Fix | Delete
getBlockName
[43147] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[43148] Fix | Delete
const {
[43149] Fix | Delete
getBlockType
[43150] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
[43151] Fix | Delete
const {
[43152] Fix | Delete
createSuccessNotice
[43153] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[43154] Fix | Delete
return (0,external_wp_element_namespaceObject.useCallback)((eventType, selectedBlockClientIds) => {
[43155] Fix | Delete
let notice = '';
[43156] Fix | Delete
if (selectedBlockClientIds.length === 1) {
[43157] Fix | Delete
const clientId = selectedBlockClientIds[0];
[43158] Fix | Delete
const title = getBlockType(getBlockName(clientId))?.title;
[43159] Fix | Delete
notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)(
[43160] Fix | Delete
// Translators: Name of the block being copied, e.g. "Paragraph".
[43161] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('Copied "%s" to clipboard.'), title) : (0,external_wp_i18n_namespaceObject.sprintf)(
[43162] Fix | Delete
// Translators: Name of the block being cut, e.g. "Paragraph".
[43163] Fix | Delete
(0,external_wp_i18n_namespaceObject.__)('Moved "%s" to clipboard.'), title);
[43164] Fix | Delete
} else {
[43165] Fix | Delete
notice = eventType === 'copy' ? (0,external_wp_i18n_namespaceObject.sprintf)(
[43166] Fix | Delete
// Translators: %d: Number of blocks being copied.
[43167] Fix | Delete
(0,external_wp_i18n_namespaceObject._n)('Copied %d block to clipboard.', 'Copied %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
[43168] Fix | Delete
// Translators: %d: Number of blocks being cut.
[43169] Fix | Delete
(0,external_wp_i18n_namespaceObject._n)('Moved %d block to clipboard.', 'Moved %d blocks to clipboard.', selectedBlockClientIds.length), selectedBlockClientIds.length);
[43170] Fix | Delete
}
[43171] Fix | Delete
createSuccessNotice(notice, {
[43172] Fix | Delete
type: 'snackbar'
[43173] Fix | Delete
});
[43174] Fix | Delete
}, []);
[43175] Fix | Delete
}
[43176] Fix | Delete
[43177] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/utils/pasting.js
[43178] Fix | Delete
/**
[43179] Fix | Delete
* WordPress dependencies
[43180] Fix | Delete
*/
[43181] Fix | Delete
[43182] Fix | Delete
[43183] Fix | Delete
/**
[43184] Fix | Delete
* Normalizes a given string of HTML to remove the Windows-specific "Fragment"
[43185] Fix | Delete
* comments and any preceding and trailing content.
[43186] Fix | Delete
*
[43187] Fix | Delete
* @param {string} html the html to be normalized
[43188] Fix | Delete
* @return {string} the normalized html
[43189] Fix | Delete
*/
[43190] Fix | Delete
function removeWindowsFragments(html) {
[43191] Fix | Delete
const startStr = '<!--StartFragment-->';
[43192] Fix | Delete
const startIdx = html.indexOf(startStr);
[43193] Fix | Delete
if (startIdx > -1) {
[43194] Fix | Delete
html = html.substring(startIdx + startStr.length);
[43195] Fix | Delete
} else {
[43196] Fix | Delete
// No point looking for EndFragment
[43197] Fix | Delete
return html;
[43198] Fix | Delete
}
[43199] Fix | Delete
const endStr = '<!--EndFragment-->';
[43200] Fix | Delete
const endIdx = html.indexOf(endStr);
[43201] Fix | Delete
if (endIdx > -1) {
[43202] Fix | Delete
html = html.substring(0, endIdx);
[43203] Fix | Delete
}
[43204] Fix | Delete
return html;
[43205] Fix | Delete
}
[43206] Fix | Delete
[43207] Fix | Delete
/**
[43208] Fix | Delete
* Removes the charset meta tag inserted by Chromium.
[43209] Fix | Delete
* See:
[43210] Fix | Delete
* - https://github.com/WordPress/gutenberg/issues/33585
[43211] Fix | Delete
* - https://bugs.chromium.org/p/chromium/issues/detail?id=1264616#c4
[43212] Fix | Delete
*
[43213] Fix | Delete
* @param {string} html the html to be stripped of the meta tag.
[43214] Fix | Delete
* @return {string} the cleaned html
[43215] Fix | Delete
*/
[43216] Fix | Delete
function removeCharsetMetaTag(html) {
[43217] Fix | Delete
const metaTag = `<meta charset='utf-8'>`;
[43218] Fix | Delete
if (html.startsWith(metaTag)) {
[43219] Fix | Delete
return html.slice(metaTag.length);
[43220] Fix | Delete
}
[43221] Fix | Delete
return html;
[43222] Fix | Delete
}
[43223] Fix | Delete
function getPasteEventData({
[43224] Fix | Delete
clipboardData
[43225] Fix | Delete
}) {
[43226] Fix | Delete
let plainText = '';
[43227] Fix | Delete
let html = '';
[43228] Fix | Delete
[43229] Fix | Delete
// IE11 only supports `Text` as an argument for `getData` and will
[43230] Fix | Delete
// otherwise throw an invalid argument error, so we try the standard
[43231] Fix | Delete
// arguments first, then fallback to `Text` if they fail.
[43232] Fix | Delete
try {
[43233] Fix | Delete
plainText = clipboardData.getData('text/plain');
[43234] Fix | Delete
html = clipboardData.getData('text/html');
[43235] Fix | Delete
} catch (error1) {
[43236] Fix | Delete
try {
[43237] Fix | Delete
html = clipboardData.getData('Text');
[43238] Fix | Delete
} catch (error2) {
[43239] Fix | Delete
// Some browsers like UC Browser paste plain text by default and
[43240] Fix | Delete
// don't support clipboardData at all, so allow default
[43241] Fix | Delete
// behaviour.
[43242] Fix | Delete
return;
[43243] Fix | Delete
}
[43244] Fix | Delete
}
[43245] Fix | Delete
[43246] Fix | Delete
// Remove Windows-specific metadata appended within copied HTML text.
[43247] Fix | Delete
html = removeWindowsFragments(html);
[43248] Fix | Delete
[43249] Fix | Delete
// Strip meta tag.
[43250] Fix | Delete
html = removeCharsetMetaTag(html);
[43251] Fix | Delete
const files = (0,external_wp_dom_namespaceObject.getFilesFromDataTransfer)(clipboardData);
[43252] Fix | Delete
if (files.length && !shouldDismissPastedFiles(files, html)) {
[43253] Fix | Delete
return {
[43254] Fix | Delete
files
[43255] Fix | Delete
};
[43256] Fix | Delete
}
[43257] Fix | Delete
return {
[43258] Fix | Delete
html,
[43259] Fix | Delete
plainText,
[43260] Fix | Delete
files: []
[43261] Fix | Delete
};
[43262] Fix | Delete
}
[43263] Fix | Delete
[43264] Fix | Delete
/**
[43265] Fix | Delete
* Given a collection of DataTransfer files and HTML and plain text strings,
[43266] Fix | Delete
* determine whether the files are to be dismissed in favor of the HTML.
[43267] Fix | Delete
*
[43268] Fix | Delete
* Certain office-type programs, like Microsoft Word or Apple Numbers,
[43269] Fix | Delete
* will, upon copy, generate a screenshot of the content being copied and
[43270] Fix | Delete
* attach it to the clipboard alongside the actual rich text that the user
[43271] Fix | Delete
* sought to copy. In those cases, we should let Gutenberg handle the rich text
[43272] Fix | Delete
* content and not the screenshot, since this allows Gutenberg to insert
[43273] Fix | Delete
* meaningful blocks, like paragraphs, lists or even tables.
[43274] Fix | Delete
*
[43275] Fix | Delete
* @param {File[]} files File objects obtained from a paste event
[43276] Fix | Delete
* @param {string} html HTML content obtained from a paste event
[43277] Fix | Delete
* @return {boolean} True if the files should be dismissed
[43278] Fix | Delete
*/
[43279] Fix | Delete
function shouldDismissPastedFiles(files, html /*, plainText */) {
[43280] Fix | Delete
// The question is only relevant when there is actual HTML content and when
[43281] Fix | Delete
// there is exactly one image file.
[43282] Fix | Delete
if (html && files?.length === 1 && files[0].type.indexOf('image/') === 0) {
[43283] Fix | Delete
// A single <img> tag found in the HTML source suggests that the
[43284] Fix | Delete
// content being pasted revolves around an image. Sometimes there are
[43285] Fix | Delete
// other elements found, like <figure>, but we assume that the user's
[43286] Fix | Delete
// intention is to paste the actual image file.
[43287] Fix | Delete
const IMAGE_TAG = /<\s*img\b/gi;
[43288] Fix | Delete
if (html.match(IMAGE_TAG)?.length !== 1) {
[43289] Fix | Delete
return true;
[43290] Fix | Delete
}
[43291] Fix | Delete
[43292] Fix | Delete
// Even when there is exactly one <img> tag in the HTML payload, we
[43293] Fix | Delete
// choose to weed out local images, i.e. those whose source starts with
[43294] Fix | Delete
// "file://". These payloads occur in specific configurations, such as
[43295] Fix | Delete
// when copying an entire document from Microsoft Word, that contains
[43296] Fix | Delete
// text and exactly one image, and pasting that content using Google
[43297] Fix | Delete
// Chrome.
[43298] Fix | Delete
const IMG_WITH_LOCAL_SRC = /<\s*img\b[^>]*\bsrc="file:\/\//i;
[43299] Fix | Delete
if (html.match(IMG_WITH_LOCAL_SRC)) {
[43300] Fix | Delete
return true;
[43301] Fix | Delete
}
[43302] Fix | Delete
}
[43303] Fix | Delete
return false;
[43304] Fix | Delete
}
[43305] Fix | Delete
[43306] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/utils.js
[43307] Fix | Delete
/**
[43308] Fix | Delete
* WordPress dependencies
[43309] Fix | Delete
*/
[43310] Fix | Delete
[43311] Fix | Delete
[43312] Fix | Delete
[43313] Fix | Delete
/**
[43314] Fix | Delete
* Internal dependencies
[43315] Fix | Delete
*/
[43316] Fix | Delete
[43317] Fix | Delete
[43318] Fix | Delete
const requiresWrapperOnCopy = Symbol('requiresWrapperOnCopy');
[43319] Fix | Delete
[43320] Fix | Delete
/**
[43321] Fix | Delete
* Sets the clipboard data for the provided blocks, with both HTML and plain
[43322] Fix | Delete
* text representations.
[43323] Fix | Delete
*
[43324] Fix | Delete
* @param {ClipboardEvent} event Clipboard event.
[43325] Fix | Delete
* @param {WPBlock[]} blocks Blocks to set as clipboard data.
[43326] Fix | Delete
* @param {Object} registry The registry to select from.
[43327] Fix | Delete
*/
[43328] Fix | Delete
function setClipboardBlocks(event, blocks, registry) {
[43329] Fix | Delete
let _blocks = blocks;
[43330] Fix | Delete
const [firstBlock] = blocks;
[43331] Fix | Delete
if (firstBlock) {
[43332] Fix | Delete
const firstBlockType = registry.select(external_wp_blocks_namespaceObject.store).getBlockType(firstBlock.name);
[43333] Fix | Delete
if (firstBlockType[requiresWrapperOnCopy]) {
[43334] Fix | Delete
const {
[43335] Fix | Delete
getBlockRootClientId,
[43336] Fix | Delete
getBlockName,
[43337] Fix | Delete
getBlockAttributes
[43338] Fix | Delete
} = registry.select(store);
[43339] Fix | Delete
const wrapperBlockClientId = getBlockRootClientId(firstBlock.clientId);
[43340] Fix | Delete
const wrapperBlockName = getBlockName(wrapperBlockClientId);
[43341] Fix | Delete
if (wrapperBlockName) {
[43342] Fix | Delete
_blocks = (0,external_wp_blocks_namespaceObject.createBlock)(wrapperBlockName, getBlockAttributes(wrapperBlockClientId), _blocks);
[43343] Fix | Delete
}
[43344] Fix | Delete
}
[43345] Fix | Delete
}
[43346] Fix | Delete
const serialized = (0,external_wp_blocks_namespaceObject.serialize)(_blocks);
[43347] Fix | Delete
event.clipboardData.setData('text/plain', toPlainText(serialized));
[43348] Fix | Delete
event.clipboardData.setData('text/html', serialized);
[43349] Fix | Delete
}
[43350] Fix | Delete
[43351] Fix | Delete
/**
[43352] Fix | Delete
* Returns the blocks to be pasted from the clipboard event.
[43353] Fix | Delete
*
[43354] Fix | Delete
* @param {ClipboardEvent} event The clipboard event.
[43355] Fix | Delete
* @param {boolean} canUserUseUnfilteredHTML Whether the user can or can't post unfiltered HTML.
[43356] Fix | Delete
* @return {Array|string} A list of blocks or a string, depending on `handlerMode`.
[43357] Fix | Delete
*/
[43358] Fix | Delete
function getPasteBlocks(event, canUserUseUnfilteredHTML) {
[43359] Fix | Delete
const {
[43360] Fix | Delete
plainText,
[43361] Fix | Delete
html,
[43362] Fix | Delete
files
[43363] Fix | Delete
} = getPasteEventData(event);
[43364] Fix | Delete
let blocks = [];
[43365] Fix | Delete
if (files.length) {
[43366] Fix | Delete
const fromTransforms = (0,external_wp_blocks_namespaceObject.getBlockTransforms)('from');
[43367] Fix | Delete
blocks = files.reduce((accumulator, file) => {
[43368] Fix | Delete
const transformation = (0,external_wp_blocks_namespaceObject.findTransform)(fromTransforms, transform => transform.type === 'files' && transform.isMatch([file]));
[43369] Fix | Delete
if (transformation) {
[43370] Fix | Delete
accumulator.push(transformation.transform([file]));
[43371] Fix | Delete
}
[43372] Fix | Delete
return accumulator;
[43373] Fix | Delete
}, []).flat();
[43374] Fix | Delete
} else {
[43375] Fix | Delete
blocks = (0,external_wp_blocks_namespaceObject.pasteHandler)({
[43376] Fix | Delete
HTML: html,
[43377] Fix | Delete
plainText,
[43378] Fix | Delete
mode: 'BLOCKS',
[43379] Fix | Delete
canUserUseUnfilteredHTML
[43380] Fix | Delete
});
[43381] Fix | Delete
}
[43382] Fix | Delete
return blocks;
[43383] Fix | Delete
}
[43384] Fix | Delete
[43385] Fix | Delete
/**
[43386] Fix | Delete
* Given a string of HTML representing serialized blocks, returns the plain
[43387] Fix | Delete
* text extracted after stripping the HTML of any tags and fixing line breaks.
[43388] Fix | Delete
*
[43389] Fix | Delete
* @param {string} html Serialized blocks.
[43390] Fix | Delete
* @return {string} The plain-text content with any html removed.
[43391] Fix | Delete
*/
[43392] Fix | Delete
function toPlainText(html) {
[43393] Fix | Delete
// Manually handle BR tags as line breaks prior to `stripHTML` call
[43394] Fix | Delete
html = html.replace(/<br>/g, '\n');
[43395] Fix | Delete
const plainText = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(html).trim();
[43396] Fix | Delete
[43397] Fix | Delete
// Merge any consecutive line breaks
[43398] Fix | Delete
return plainText.replace(/\n\n+/g, '\n\n');
[43399] Fix | Delete
}
[43400] Fix | Delete
[43401] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/writing-flow/use-clipboard-handler.js
[43402] Fix | Delete
/**
[43403] Fix | Delete
* WordPress dependencies
[43404] Fix | Delete
*/
[43405] Fix | Delete
[43406] Fix | Delete
[43407] Fix | Delete
[43408] Fix | Delete
[43409] Fix | Delete
[43410] Fix | Delete
/**
[43411] Fix | Delete
* Internal dependencies
[43412] Fix | Delete
*/
[43413] Fix | Delete
[43414] Fix | Delete
[43415] Fix | Delete
[43416] Fix | Delete
[43417] Fix | Delete
function useClipboardHandler() {
[43418] Fix | Delete
const registry = (0,external_wp_data_namespaceObject.useRegistry)();
[43419] Fix | Delete
const {
[43420] Fix | Delete
getBlocksByClientId,
[43421] Fix | Delete
getSelectedBlockClientIds,
[43422] Fix | Delete
hasMultiSelection,
[43423] Fix | Delete
getSettings,
[43424] Fix | Delete
getBlockName,
[43425] Fix | Delete
__unstableIsFullySelected,
[43426] Fix | Delete
__unstableIsSelectionCollapsed,
[43427] Fix | Delete
__unstableIsSelectionMergeable,
[43428] Fix | Delete
__unstableGetSelectedBlocksWithPartialSelection,
[43429] Fix | Delete
canInsertBlockType,
[43430] Fix | Delete
getBlockRootClientId
[43431] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store);
[43432] Fix | Delete
const {
[43433] Fix | Delete
flashBlock,
[43434] Fix | Delete
removeBlocks,
[43435] Fix | Delete
replaceBlocks,
[43436] Fix | Delete
__unstableDeleteSelection,
[43437] Fix | Delete
__unstableExpandSelection,
[43438] Fix | Delete
__unstableSplitSelection
[43439] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(store);
[43440] Fix | Delete
const notifyCopy = useNotifyCopy();
[43441] Fix | Delete
return (0,external_wp_compose_namespaceObject.useRefEffect)(node => {
[43442] Fix | Delete
function handler(event) {
[43443] Fix | Delete
if (event.defaultPrevented) {
[43444] Fix | Delete
// This was likely already handled in rich-text/use-paste-handler.js.
[43445] Fix | Delete
return;
[43446] Fix | Delete
}
[43447] Fix | Delete
const selectedBlockClientIds = getSelectedBlockClientIds();
[43448] Fix | Delete
if (selectedBlockClientIds.length === 0) {
[43449] Fix | Delete
return;
[43450] Fix | Delete
}
[43451] Fix | Delete
[43452] Fix | Delete
// Let native copy/paste behaviour take over in input fields.
[43453] Fix | Delete
// But always handle multiple selected blocks.
[43454] Fix | Delete
if (!hasMultiSelection()) {
[43455] Fix | Delete
const {
[43456] Fix | Delete
target
[43457] Fix | Delete
} = event;
[43458] Fix | Delete
const {
[43459] Fix | Delete
ownerDocument
[43460] Fix | Delete
} = target;
[43461] Fix | Delete
// If copying, only consider actual text selection as selection.
[43462] Fix | Delete
// Otherwise, any focus on an input field is considered.
[43463] Fix | Delete
const hasSelection = event.type === 'copy' || event.type === 'cut' ? (0,external_wp_dom_namespaceObject.documentHasUncollapsedSelection)(ownerDocument) : (0,external_wp_dom_namespaceObject.documentHasSelection)(ownerDocument) && !ownerDocument.activeElement.isContentEditable;
[43464] Fix | Delete
[43465] Fix | Delete
// Let native copy behaviour take over in input fields.
[43466] Fix | Delete
if (hasSelection) {
[43467] Fix | Delete
return;
[43468] Fix | Delete
}
[43469] Fix | Delete
}
[43470] Fix | Delete
const {
[43471] Fix | Delete
activeElement
[43472] Fix | Delete
} = event.target.ownerDocument;
[43473] Fix | Delete
if (!node.contains(activeElement)) {
[43474] Fix | Delete
return;
[43475] Fix | Delete
}
[43476] Fix | Delete
const isSelectionMergeable = __unstableIsSelectionMergeable();
[43477] Fix | Delete
const shouldHandleWholeBlocks = __unstableIsSelectionCollapsed() || __unstableIsFullySelected();
[43478] Fix | Delete
const expandSelectionIsNeeded = !shouldHandleWholeBlocks && !isSelectionMergeable;
[43479] Fix | Delete
if (event.type === 'copy' || event.type === 'cut') {
[43480] Fix | Delete
event.preventDefault();
[43481] Fix | Delete
if (selectedBlockClientIds.length === 1) {
[43482] Fix | Delete
flashBlock(selectedBlockClientIds[0]);
[43483] Fix | Delete
}
[43484] Fix | Delete
// If we have a partial selection that is not mergeable, just
[43485] Fix | Delete
// expand the selection to the whole blocks.
[43486] Fix | Delete
if (expandSelectionIsNeeded) {
[43487] Fix | Delete
__unstableExpandSelection();
[43488] Fix | Delete
} else {
[43489] Fix | Delete
notifyCopy(event.type, selectedBlockClientIds);
[43490] Fix | Delete
let blocks;
[43491] Fix | Delete
// Check if we have partial selection.
[43492] Fix | Delete
if (shouldHandleWholeBlocks) {
[43493] Fix | Delete
blocks = getBlocksByClientId(selectedBlockClientIds);
[43494] Fix | Delete
} else {
[43495] Fix | Delete
const [head, tail] = __unstableGetSelectedBlocksWithPartialSelection();
[43496] Fix | Delete
const inBetweenBlocks = getBlocksByClientId(selectedBlockClientIds.slice(1, selectedBlockClientIds.length - 1));
[43497] Fix | Delete
blocks = [head, ...inBetweenBlocks, tail];
[43498] Fix | Delete
}
[43499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function