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: editor.js
const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
[9000] Fix | Delete
let entityLabel = entityConfig.label;
[9001] Fix | Delete
if (firstRecord?.name === 'wp_template_part') {
[9002] Fix | Delete
entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
[9003] Fix | Delete
}
[9004] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
[9005] Fix | Delete
title: entityLabel,
[9006] Fix | Delete
initialOpen: true,
[9007] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
[9008] Fix | Delete
record: firstRecord,
[9009] Fix | Delete
count: count
[9010] Fix | Delete
}), list.map(record => {
[9011] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
[9012] Fix | Delete
record: record,
[9013] Fix | Delete
checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
[9014] Fix | Delete
onChange: value => setUnselectedEntities(record, value)
[9015] Fix | Delete
}, record.key || record.property);
[9016] Fix | Delete
}), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
[9017] Fix | Delete
record: firstRecord
[9018] Fix | Delete
})]
[9019] Fix | Delete
});
[9020] Fix | Delete
}
[9021] Fix | Delete
[9022] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
[9023] Fix | Delete
/**
[9024] Fix | Delete
* WordPress dependencies
[9025] Fix | Delete
*/
[9026] Fix | Delete
[9027] Fix | Delete
[9028] Fix | Delete
[9029] Fix | Delete
const useIsDirty = () => {
[9030] Fix | Delete
const {
[9031] Fix | Delete
editedEntities,
[9032] Fix | Delete
siteEdits,
[9033] Fix | Delete
siteEntityConfig
[9034] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[9035] Fix | Delete
const {
[9036] Fix | Delete
__experimentalGetDirtyEntityRecords,
[9037] Fix | Delete
getEntityRecordEdits,
[9038] Fix | Delete
getEntityConfig
[9039] Fix | Delete
} = select(external_wp_coreData_namespaceObject.store);
[9040] Fix | Delete
return {
[9041] Fix | Delete
editedEntities: __experimentalGetDirtyEntityRecords(),
[9042] Fix | Delete
siteEdits: getEntityRecordEdits('root', 'site'),
[9043] Fix | Delete
siteEntityConfig: getEntityConfig('root', 'site')
[9044] Fix | Delete
};
[9045] Fix | Delete
}, []);
[9046] Fix | Delete
const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
[9047] Fix | Delete
var _siteEntityConfig$met;
[9048] Fix | Delete
// Remove site object and decouple into its edited pieces.
[9049] Fix | Delete
const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
[9050] Fix | Delete
const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
[9051] Fix | Delete
const editedSiteEntities = [];
[9052] Fix | Delete
for (const property in siteEdits) {
[9053] Fix | Delete
editedSiteEntities.push({
[9054] Fix | Delete
kind: 'root',
[9055] Fix | Delete
name: 'site',
[9056] Fix | Delete
title: siteEntityLabels[property] || property,
[9057] Fix | Delete
property
[9058] Fix | Delete
});
[9059] Fix | Delete
}
[9060] Fix | Delete
return [...editedEntitiesWithoutSite, ...editedSiteEntities];
[9061] Fix | Delete
}, [editedEntities, siteEdits, siteEntityConfig]);
[9062] Fix | Delete
[9063] Fix | Delete
// Unchecked entities to be ignored by save function.
[9064] Fix | Delete
const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
[9065] Fix | Delete
const setUnselectedEntities = ({
[9066] Fix | Delete
kind,
[9067] Fix | Delete
name,
[9068] Fix | Delete
key,
[9069] Fix | Delete
property
[9070] Fix | Delete
}, checked) => {
[9071] Fix | Delete
if (checked) {
[9072] Fix | Delete
_setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
[9073] Fix | Delete
} else {
[9074] Fix | Delete
_setUnselectedEntities([...unselectedEntities, {
[9075] Fix | Delete
kind,
[9076] Fix | Delete
name,
[9077] Fix | Delete
key,
[9078] Fix | Delete
property
[9079] Fix | Delete
}]);
[9080] Fix | Delete
}
[9081] Fix | Delete
};
[9082] Fix | Delete
const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
[9083] Fix | Delete
return {
[9084] Fix | Delete
dirtyEntityRecords,
[9085] Fix | Delete
isDirty,
[9086] Fix | Delete
setUnselectedEntities,
[9087] Fix | Delete
unselectedEntities
[9088] Fix | Delete
};
[9089] Fix | Delete
};
[9090] Fix | Delete
[9091] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/entities-saved-states/index.js
[9092] Fix | Delete
/**
[9093] Fix | Delete
* WordPress dependencies
[9094] Fix | Delete
*/
[9095] Fix | Delete
[9096] Fix | Delete
[9097] Fix | Delete
[9098] Fix | Delete
[9099] Fix | Delete
[9100] Fix | Delete
[9101] Fix | Delete
/**
[9102] Fix | Delete
* Internal dependencies
[9103] Fix | Delete
*/
[9104] Fix | Delete
[9105] Fix | Delete
[9106] Fix | Delete
[9107] Fix | Delete
[9108] Fix | Delete
[9109] Fix | Delete
[9110] Fix | Delete
function identity(values) {
[9111] Fix | Delete
return values;
[9112] Fix | Delete
}
[9113] Fix | Delete
function EntitiesSavedStates({
[9114] Fix | Delete
close,
[9115] Fix | Delete
renderDialog = undefined
[9116] Fix | Delete
}) {
[9117] Fix | Delete
const isDirtyProps = useIsDirty();
[9118] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
[9119] Fix | Delete
close: close,
[9120] Fix | Delete
renderDialog: renderDialog,
[9121] Fix | Delete
...isDirtyProps
[9122] Fix | Delete
});
[9123] Fix | Delete
}
[9124] Fix | Delete
function EntitiesSavedStatesExtensible({
[9125] Fix | Delete
additionalPrompt = undefined,
[9126] Fix | Delete
close,
[9127] Fix | Delete
onSave = identity,
[9128] Fix | Delete
saveEnabled: saveEnabledProp = undefined,
[9129] Fix | Delete
saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
[9130] Fix | Delete
renderDialog = undefined,
[9131] Fix | Delete
dirtyEntityRecords,
[9132] Fix | Delete
isDirty,
[9133] Fix | Delete
setUnselectedEntities,
[9134] Fix | Delete
unselectedEntities
[9135] Fix | Delete
}) {
[9136] Fix | Delete
const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
[9137] Fix | Delete
const {
[9138] Fix | Delete
saveDirtyEntities
[9139] Fix | Delete
} = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
[9140] Fix | Delete
// To group entities by type.
[9141] Fix | Delete
const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
[9142] Fix | Delete
const {
[9143] Fix | Delete
name
[9144] Fix | Delete
} = record;
[9145] Fix | Delete
if (!acc[name]) {
[9146] Fix | Delete
acc[name] = [];
[9147] Fix | Delete
}
[9148] Fix | Delete
acc[name].push(record);
[9149] Fix | Delete
return acc;
[9150] Fix | Delete
}, {});
[9151] Fix | Delete
[9152] Fix | Delete
// Sort entity groups.
[9153] Fix | Delete
const {
[9154] Fix | Delete
site: siteSavables,
[9155] Fix | Delete
wp_template: templateSavables,
[9156] Fix | Delete
wp_template_part: templatePartSavables,
[9157] Fix | Delete
...contentSavables
[9158] Fix | Delete
} = partitionedSavables;
[9159] Fix | Delete
const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
[9160] Fix | Delete
const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
[9161] Fix | Delete
// Explicitly define this with no argument passed. Using `close` on
[9162] Fix | Delete
// its own will use the event object in place of the expected saved entities.
[9163] Fix | Delete
const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
[9164] Fix | Delete
const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
[9165] Fix | Delete
onClose: () => dismissPanel()
[9166] Fix | Delete
});
[9167] Fix | Delete
const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
[9168] Fix | Delete
const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
[9169] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[9170] Fix | Delete
ref: saveDialogRef,
[9171] Fix | Delete
...saveDialogProps,
[9172] Fix | Delete
className: "entities-saved-states__panel",
[9173] Fix | Delete
role: renderDialog ? 'dialog' : undefined,
[9174] Fix | Delete
"aria-labelledby": renderDialog ? dialogLabel : undefined,
[9175] Fix | Delete
"aria-describedby": renderDialog ? dialogDescription : undefined,
[9176] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
[9177] Fix | Delete
className: "entities-saved-states__panel-header",
[9178] Fix | Delete
gap: 2,
[9179] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
[9180] Fix | Delete
isBlock: true,
[9181] Fix | Delete
as: external_wp_components_namespaceObject.Button,
[9182] Fix | Delete
ref: saveButtonRef,
[9183] Fix | Delete
variant: "primary",
[9184] Fix | Delete
disabled: !saveEnabled,
[9185] Fix | Delete
__experimentalIsFocusable: true,
[9186] Fix | Delete
onClick: () => saveDirtyEntities({
[9187] Fix | Delete
onSave,
[9188] Fix | Delete
dirtyEntityRecords,
[9189] Fix | Delete
entitiesToSkip: unselectedEntities,
[9190] Fix | Delete
close
[9191] Fix | Delete
}),
[9192] Fix | Delete
className: "editor-entities-saved-states__save-button",
[9193] Fix | Delete
children: saveLabel
[9194] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
[9195] Fix | Delete
isBlock: true,
[9196] Fix | Delete
as: external_wp_components_namespaceObject.Button,
[9197] Fix | Delete
variant: "secondary",
[9198] Fix | Delete
onClick: dismissPanel,
[9199] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
[9200] Fix | Delete
})]
[9201] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[9202] Fix | Delete
className: "entities-saved-states__text-prompt",
[9203] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[9204] Fix | Delete
className: "entities-saved-states__text-prompt--header-wrapper",
[9205] Fix | Delete
id: renderDialog ? dialogLabel : undefined,
[9206] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
[9207] Fix | Delete
className: "entities-saved-states__text-prompt--header",
[9208] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
[9209] Fix | Delete
}), additionalPrompt]
[9210] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
[9211] Fix | Delete
id: renderDialog ? dialogDescription : undefined,
[9212] Fix | Delete
children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of site changes waiting to be saved. */
[9213] Fix | Delete
(0,external_wp_i18n_namespaceObject._n)('There is <strong>%d site change</strong> waiting to be saved.', 'There are <strong>%d site changes</strong> waiting to be saved.', sortedPartitionedSavables.length), sortedPartitionedSavables.length), {
[9214] Fix | Delete
strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
[9215] Fix | Delete
}) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.')
[9216] Fix | Delete
})]
[9217] Fix | Delete
}), sortedPartitionedSavables.map(list => {
[9218] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
[9219] Fix | Delete
list: list,
[9220] Fix | Delete
unselectedEntities: unselectedEntities,
[9221] Fix | Delete
setUnselectedEntities: setUnselectedEntities
[9222] Fix | Delete
}, list[0].name);
[9223] Fix | Delete
})]
[9224] Fix | Delete
});
[9225] Fix | Delete
}
[9226] Fix | Delete
[9227] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js
[9228] Fix | Delete
/**
[9229] Fix | Delete
* WordPress dependencies
[9230] Fix | Delete
*/
[9231] Fix | Delete
[9232] Fix | Delete
[9233] Fix | Delete
[9234] Fix | Delete
[9235] Fix | Delete
[9236] Fix | Delete
[9237] Fix | Delete
[9238] Fix | Delete
[9239] Fix | Delete
/**
[9240] Fix | Delete
* Internal dependencies
[9241] Fix | Delete
*/
[9242] Fix | Delete
[9243] Fix | Delete
[9244] Fix | Delete
function getContent() {
[9245] Fix | Delete
try {
[9246] Fix | Delete
// While `select` in a component is generally discouraged, it is
[9247] Fix | Delete
// used here because it (a) reduces the chance of data loss in the
[9248] Fix | Delete
// case of additional errors by performing a direct retrieval and
[9249] Fix | Delete
// (b) avoids the performance cost associated with unnecessary
[9250] Fix | Delete
// content serialization throughout the lifetime of a non-erroring
[9251] Fix | Delete
// application.
[9252] Fix | Delete
return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
[9253] Fix | Delete
} catch (error) {}
[9254] Fix | Delete
}
[9255] Fix | Delete
function CopyButton({
[9256] Fix | Delete
text,
[9257] Fix | Delete
children
[9258] Fix | Delete
}) {
[9259] Fix | Delete
const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
[9260] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[9261] Fix | Delete
variant: "secondary",
[9262] Fix | Delete
ref: ref,
[9263] Fix | Delete
children: children
[9264] Fix | Delete
});
[9265] Fix | Delete
}
[9266] Fix | Delete
class ErrorBoundary extends external_wp_element_namespaceObject.Component {
[9267] Fix | Delete
constructor() {
[9268] Fix | Delete
super(...arguments);
[9269] Fix | Delete
this.state = {
[9270] Fix | Delete
error: null
[9271] Fix | Delete
};
[9272] Fix | Delete
}
[9273] Fix | Delete
componentDidCatch(error) {
[9274] Fix | Delete
(0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
[9275] Fix | Delete
}
[9276] Fix | Delete
static getDerivedStateFromError(error) {
[9277] Fix | Delete
return {
[9278] Fix | Delete
error
[9279] Fix | Delete
};
[9280] Fix | Delete
}
[9281] Fix | Delete
render() {
[9282] Fix | Delete
const {
[9283] Fix | Delete
error
[9284] Fix | Delete
} = this.state;
[9285] Fix | Delete
if (!error) {
[9286] Fix | Delete
return this.props.children;
[9287] Fix | Delete
}
[9288] Fix | Delete
const actions = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
[9289] Fix | Delete
text: getContent,
[9290] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')
[9291] Fix | Delete
}, "copy-post"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
[9292] Fix | Delete
text: error.stack,
[9293] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Copy Error')
[9294] Fix | Delete
}, "copy-error")];
[9295] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, {
[9296] Fix | Delete
className: "editor-error-boundary",
[9297] Fix | Delete
actions: actions,
[9298] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
[9299] Fix | Delete
});
[9300] Fix | Delete
}
[9301] Fix | Delete
}
[9302] Fix | Delete
[9303] Fix | Delete
/**
[9304] Fix | Delete
* ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
[9305] Fix | Delete
*
[9306] Fix | Delete
* It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
[9307] Fix | Delete
*
[9308] Fix | Delete
* getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
[9309] Fix | Delete
*
[9310] Fix | Delete
* @class ErrorBoundary
[9311] Fix | Delete
* @augments Component
[9312] Fix | Delete
*/
[9313] Fix | Delete
/* harmony default export */ const error_boundary = (ErrorBoundary);
[9314] Fix | Delete
[9315] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/local-autosave-monitor/index.js
[9316] Fix | Delete
/**
[9317] Fix | Delete
* WordPress dependencies
[9318] Fix | Delete
*/
[9319] Fix | Delete
[9320] Fix | Delete
[9321] Fix | Delete
[9322] Fix | Delete
[9323] Fix | Delete
[9324] Fix | Delete
[9325] Fix | Delete
[9326] Fix | Delete
/**
[9327] Fix | Delete
* Internal dependencies
[9328] Fix | Delete
*/
[9329] Fix | Delete
[9330] Fix | Delete
[9331] Fix | Delete
[9332] Fix | Delete
[9333] Fix | Delete
const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
[9334] Fix | Delete
let hasStorageSupport;
[9335] Fix | Delete
[9336] Fix | Delete
/**
[9337] Fix | Delete
* Function which returns true if the current environment supports browser
[9338] Fix | Delete
* sessionStorage, or false otherwise. The result of this function is cached and
[9339] Fix | Delete
* reused in subsequent invocations.
[9340] Fix | Delete
*/
[9341] Fix | Delete
const hasSessionStorageSupport = () => {
[9342] Fix | Delete
if (hasStorageSupport !== undefined) {
[9343] Fix | Delete
return hasStorageSupport;
[9344] Fix | Delete
}
[9345] Fix | Delete
try {
[9346] Fix | Delete
// Private Browsing in Safari 10 and earlier will throw an error when
[9347] Fix | Delete
// attempting to set into sessionStorage. The test here is intentional in
[9348] Fix | Delete
// causing a thrown error as condition bailing from local autosave.
[9349] Fix | Delete
window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
[9350] Fix | Delete
window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
[9351] Fix | Delete
hasStorageSupport = true;
[9352] Fix | Delete
} catch {
[9353] Fix | Delete
hasStorageSupport = false;
[9354] Fix | Delete
}
[9355] Fix | Delete
return hasStorageSupport;
[9356] Fix | Delete
};
[9357] Fix | Delete
[9358] Fix | Delete
/**
[9359] Fix | Delete
* Custom hook which manages the creation of a notice prompting the user to
[9360] Fix | Delete
* restore a local autosave, if one exists.
[9361] Fix | Delete
*/
[9362] Fix | Delete
function useAutosaveNotice() {
[9363] Fix | Delete
const {
[9364] Fix | Delete
postId,
[9365] Fix | Delete
isEditedPostNew,
[9366] Fix | Delete
hasRemoteAutosave
[9367] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => ({
[9368] Fix | Delete
postId: select(store_store).getCurrentPostId(),
[9369] Fix | Delete
isEditedPostNew: select(store_store).isEditedPostNew(),
[9370] Fix | Delete
hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
[9371] Fix | Delete
}), []);
[9372] Fix | Delete
const {
[9373] Fix | Delete
getEditedPostAttribute
[9374] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(store_store);
[9375] Fix | Delete
const {
[9376] Fix | Delete
createWarningNotice,
[9377] Fix | Delete
removeNotice
[9378] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
[9379] Fix | Delete
const {
[9380] Fix | Delete
editPost,
[9381] Fix | Delete
resetEditorBlocks
[9382] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
[9383] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[9384] Fix | Delete
let localAutosave = localAutosaveGet(postId, isEditedPostNew);
[9385] Fix | Delete
if (!localAutosave) {
[9386] Fix | Delete
return;
[9387] Fix | Delete
}
[9388] Fix | Delete
try {
[9389] Fix | Delete
localAutosave = JSON.parse(localAutosave);
[9390] Fix | Delete
} catch {
[9391] Fix | Delete
// Not usable if it can't be parsed.
[9392] Fix | Delete
return;
[9393] Fix | Delete
}
[9394] Fix | Delete
const {
[9395] Fix | Delete
post_title: title,
[9396] Fix | Delete
content,
[9397] Fix | Delete
excerpt
[9398] Fix | Delete
} = localAutosave;
[9399] Fix | Delete
const edits = {
[9400] Fix | Delete
title,
[9401] Fix | Delete
content,
[9402] Fix | Delete
excerpt
[9403] Fix | Delete
};
[9404] Fix | Delete
{
[9405] Fix | Delete
// Only display a notice if there is a difference between what has been
[9406] Fix | Delete
// saved and that which is stored in sessionStorage.
[9407] Fix | Delete
const hasDifference = Object.keys(edits).some(key => {
[9408] Fix | Delete
return edits[key] !== getEditedPostAttribute(key);
[9409] Fix | Delete
});
[9410] Fix | Delete
if (!hasDifference) {
[9411] Fix | Delete
// If there is no difference, it can be safely ejected from storage.
[9412] Fix | Delete
localAutosaveClear(postId, isEditedPostNew);
[9413] Fix | Delete
return;
[9414] Fix | Delete
}
[9415] Fix | Delete
}
[9416] Fix | Delete
if (hasRemoteAutosave) {
[9417] Fix | Delete
return;
[9418] Fix | Delete
}
[9419] Fix | Delete
const id = 'wpEditorAutosaveRestore';
[9420] Fix | Delete
createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
[9421] Fix | Delete
id,
[9422] Fix | Delete
actions: [{
[9423] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
[9424] Fix | Delete
onClick() {
[9425] Fix | Delete
const {
[9426] Fix | Delete
content: editsContent,
[9427] Fix | Delete
...editsWithoutContent
[9428] Fix | Delete
} = edits;
[9429] Fix | Delete
editPost(editsWithoutContent);
[9430] Fix | Delete
resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
[9431] Fix | Delete
removeNotice(id);
[9432] Fix | Delete
}
[9433] Fix | Delete
}]
[9434] Fix | Delete
});
[9435] Fix | Delete
}, [isEditedPostNew, postId]);
[9436] Fix | Delete
}
[9437] Fix | Delete
[9438] Fix | Delete
/**
[9439] Fix | Delete
* Custom hook which ejects a local autosave after a successful save occurs.
[9440] Fix | Delete
*/
[9441] Fix | Delete
function useAutosavePurge() {
[9442] Fix | Delete
const {
[9443] Fix | Delete
postId,
[9444] Fix | Delete
isEditedPostNew,
[9445] Fix | Delete
isDirty,
[9446] Fix | Delete
isAutosaving,
[9447] Fix | Delete
didError
[9448] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => ({
[9449] Fix | Delete
postId: select(store_store).getCurrentPostId(),
[9450] Fix | Delete
isEditedPostNew: select(store_store).isEditedPostNew(),
[9451] Fix | Delete
isDirty: select(store_store).isEditedPostDirty(),
[9452] Fix | Delete
isAutosaving: select(store_store).isAutosavingPost(),
[9453] Fix | Delete
didError: select(store_store).didPostSaveRequestFail()
[9454] Fix | Delete
}), []);
[9455] Fix | Delete
const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
[9456] Fix | Delete
const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
[9457] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[9458] Fix | Delete
if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
[9459] Fix | Delete
localAutosaveClear(postId, isEditedPostNew);
[9460] Fix | Delete
}
[9461] Fix | Delete
lastIsDirty.current = isDirty;
[9462] Fix | Delete
lastIsAutosaving.current = isAutosaving;
[9463] Fix | Delete
}, [isDirty, isAutosaving, didError]);
[9464] Fix | Delete
[9465] Fix | Delete
// Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
[9466] Fix | Delete
const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
[9467] Fix | Delete
const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
[9468] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[9469] Fix | Delete
if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
[9470] Fix | Delete
localAutosaveClear(postId, true);
[9471] Fix | Delete
}
[9472] Fix | Delete
}, [isEditedPostNew, postId]);
[9473] Fix | Delete
}
[9474] Fix | Delete
function LocalAutosaveMonitor() {
[9475] Fix | Delete
const {
[9476] Fix | Delete
autosave
[9477] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
[9478] Fix | Delete
const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
[9479] Fix | Delete
requestIdleCallback(() => autosave({
[9480] Fix | Delete
local: true
[9481] Fix | Delete
}));
[9482] Fix | Delete
}, []);
[9483] Fix | Delete
useAutosaveNotice();
[9484] Fix | Delete
useAutosavePurge();
[9485] Fix | Delete
const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
[9486] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
[9487] Fix | Delete
interval: localAutosaveInterval,
[9488] Fix | Delete
autosave: deferredAutosave
[9489] Fix | Delete
});
[9490] Fix | Delete
}
[9491] Fix | Delete
[9492] Fix | Delete
/**
[9493] Fix | Delete
* Monitors local autosaves of a post in the editor.
[9494] Fix | Delete
* It uses several hooks and functions to manage autosave behavior:
[9495] Fix | Delete
* - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
[9496] Fix | Delete
* - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
[9497] Fix | Delete
* - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
[9498] Fix | Delete
* - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
[9499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function