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
*
[23500] Fix | Delete
* @typedef {{[setting:string]:any}} WPLinkControlSettingsValue
[23501] Fix | Delete
*/
[23502] Fix | Delete
/* eslint-enable */
[23503] Fix | Delete
[23504] Fix | Delete
/**
[23505] Fix | Delete
* Custom settings values associated with a link.
[23506] Fix | Delete
*
[23507] Fix | Delete
* @typedef WPLinkControlSetting
[23508] Fix | Delete
*
[23509] Fix | Delete
* @property {string} id Identifier to use as property for setting value.
[23510] Fix | Delete
* @property {string} title Human-readable label to show in user interface.
[23511] Fix | Delete
*/
[23512] Fix | Delete
[23513] Fix | Delete
/**
[23514] Fix | Delete
* Properties associated with a link control value, composed as a union of the
[23515] Fix | Delete
* default properties and any custom settings values.
[23516] Fix | Delete
*
[23517] Fix | Delete
* @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue
[23518] Fix | Delete
*/
[23519] Fix | Delete
[23520] Fix | Delete
/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */
[23521] Fix | Delete
[23522] Fix | Delete
/**
[23523] Fix | Delete
* Properties associated with a search suggestion used within the LinkControl.
[23524] Fix | Delete
*
[23525] Fix | Delete
* @typedef WPLinkControlSuggestion
[23526] Fix | Delete
*
[23527] Fix | Delete
* @property {string} id Identifier to use to uniquely identify the suggestion.
[23528] Fix | Delete
* @property {string} type Identifies the type of the suggestion (eg: `post`,
[23529] Fix | Delete
* `page`, `url`...etc)
[23530] Fix | Delete
* @property {string} title Human-readable label to show in user interface.
[23531] Fix | Delete
* @property {string} url A URL for the suggestion.
[23532] Fix | Delete
*/
[23533] Fix | Delete
[23534] Fix | Delete
/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */
[23535] Fix | Delete
[23536] Fix | Delete
/**
[23537] Fix | Delete
* @typedef WPLinkControlProps
[23538] Fix | Delete
*
[23539] Fix | Delete
* @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to
[23540] Fix | Delete
* render a `ToggleControl` for that setting.
[23541] Fix | Delete
* @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the
[23542] Fix | Delete
* internal editing state of the component to respective
[23543] Fix | Delete
* show or not show the URL input field.
[23544] Fix | Delete
* @property {WPLinkControlValue=} value Current link value.
[23545] Fix | Delete
* @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if
[23546] Fix | Delete
* the user selects a new link or updates settings.
[23547] Fix | Delete
* @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.
[23548] Fix | Delete
* @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.
[23549] Fix | Delete
* @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.
[23550] Fix | Delete
* @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.
[23551] Fix | Delete
* @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.
[23552] Fix | Delete
* @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.
[23553] Fix | Delete
* @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.
[23554] Fix | Delete
* @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.
[23555] Fix | Delete
* @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.
[23556] Fix | Delete
*/
[23557] Fix | Delete
[23558] Fix | Delete
[23559] Fix | Delete
[23560] Fix | Delete
const link_control_noop = () => {};
[23561] Fix | Delete
const PREFERENCE_SCOPE = 'core/block-editor';
[23562] Fix | Delete
const PREFERENCE_KEY = 'linkControlSettingsDrawer';
[23563] Fix | Delete
[23564] Fix | Delete
/**
[23565] Fix | Delete
* Renders a link control. A link control is a controlled input which maintains
[23566] Fix | Delete
* a value associated with a link (HTML anchor element) and relevant settings
[23567] Fix | Delete
* for how that link is expected to behave.
[23568] Fix | Delete
*
[23569] Fix | Delete
* @param {WPLinkControlProps} props Component props.
[23570] Fix | Delete
*/
[23571] Fix | Delete
function LinkControl({
[23572] Fix | Delete
searchInputPlaceholder,
[23573] Fix | Delete
value,
[23574] Fix | Delete
settings = DEFAULT_LINK_SETTINGS,
[23575] Fix | Delete
onChange = link_control_noop,
[23576] Fix | Delete
onRemove,
[23577] Fix | Delete
onCancel,
[23578] Fix | Delete
noDirectEntry = false,
[23579] Fix | Delete
showSuggestions = true,
[23580] Fix | Delete
showInitialSuggestions,
[23581] Fix | Delete
forceIsEditingLink,
[23582] Fix | Delete
createSuggestion,
[23583] Fix | Delete
withCreateSuggestion,
[23584] Fix | Delete
inputValue: propInputValue = '',
[23585] Fix | Delete
suggestionsQuery = {},
[23586] Fix | Delete
noURLSuggestion = false,
[23587] Fix | Delete
createSuggestionButtonText,
[23588] Fix | Delete
hasRichPreviews = false,
[23589] Fix | Delete
hasTextControl = false,
[23590] Fix | Delete
renderControlBottom = null
[23591] Fix | Delete
}) {
[23592] Fix | Delete
if (withCreateSuggestion === undefined && createSuggestion) {
[23593] Fix | Delete
withCreateSuggestion = true;
[23594] Fix | Delete
}
[23595] Fix | Delete
const [settingsOpen, setSettingsOpen] = (0,external_wp_element_namespaceObject.useState)(false);
[23596] Fix | Delete
const {
[23597] Fix | Delete
advancedSettingsPreference
[23598] Fix | Delete
} = (0,external_wp_data_namespaceObject.useSelect)(select => {
[23599] Fix | Delete
var _prefsStore$get;
[23600] Fix | Delete
const prefsStore = select(external_wp_preferences_namespaceObject.store);
[23601] Fix | Delete
return {
[23602] Fix | Delete
advancedSettingsPreference: (_prefsStore$get = prefsStore.get(PREFERENCE_SCOPE, PREFERENCE_KEY)) !== null && _prefsStore$get !== void 0 ? _prefsStore$get : false
[23603] Fix | Delete
};
[23604] Fix | Delete
}, []);
[23605] Fix | Delete
const {
[23606] Fix | Delete
set: setPreference
[23607] Fix | Delete
} = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
[23608] Fix | Delete
[23609] Fix | Delete
/**
[23610] Fix | Delete
* Sets the open/closed state of the Advanced Settings Drawer,
[23611] Fix | Delete
* optionlly persisting the state to the user's preferences.
[23612] Fix | Delete
*
[23613] Fix | Delete
* Note that Block Editor components can be consumed by non-WordPress
[23614] Fix | Delete
* environments which may not have preferences setup.
[23615] Fix | Delete
* Therefore a local state is also used as a fallback.
[23616] Fix | Delete
*
[23617] Fix | Delete
* @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.
[23618] Fix | Delete
*/
[23619] Fix | Delete
const setSettingsOpenWithPreference = prefVal => {
[23620] Fix | Delete
if (setPreference) {
[23621] Fix | Delete
setPreference(PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal);
[23622] Fix | Delete
}
[23623] Fix | Delete
setSettingsOpen(prefVal);
[23624] Fix | Delete
};
[23625] Fix | Delete
[23626] Fix | Delete
// Block Editor components can be consumed by non-WordPress environments
[23627] Fix | Delete
// which may not have these preferences setup.
[23628] Fix | Delete
// Therefore a local state is used as a fallback.
[23629] Fix | Delete
const isSettingsOpen = advancedSettingsPreference || settingsOpen;
[23630] Fix | Delete
const isMounting = (0,external_wp_element_namespaceObject.useRef)(true);
[23631] Fix | Delete
const wrapperNode = (0,external_wp_element_namespaceObject.useRef)();
[23632] Fix | Delete
const textInputRef = (0,external_wp_element_namespaceObject.useRef)();
[23633] Fix | Delete
const isEndingEditWithFocus = (0,external_wp_element_namespaceObject.useRef)(false);
[23634] Fix | Delete
const settingsKeys = settings.map(({
[23635] Fix | Delete
id
[23636] Fix | Delete
}) => id);
[23637] Fix | Delete
const [internalControlValue, setInternalControlValue, setInternalURLInputValue, setInternalTextInputValue, createSetInternalSettingValueHandler] = useInternalValue(value);
[23638] Fix | Delete
const valueHasChanges = value && !(0,external_wp_isShallowEqual_namespaceObject.isShallowEqualObjects)(internalControlValue, value);
[23639] Fix | Delete
const [isEditingLink, setIsEditingLink] = (0,external_wp_element_namespaceObject.useState)(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
[23640] Fix | Delete
const {
[23641] Fix | Delete
createPage,
[23642] Fix | Delete
isCreatingPage,
[23643] Fix | Delete
errorMessage
[23644] Fix | Delete
} = useCreatePage(createSuggestion);
[23645] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[23646] Fix | Delete
if (forceIsEditingLink === undefined) {
[23647] Fix | Delete
return;
[23648] Fix | Delete
}
[23649] Fix | Delete
setIsEditingLink(forceIsEditingLink);
[23650] Fix | Delete
}, [forceIsEditingLink]);
[23651] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[23652] Fix | Delete
// We don't auto focus into the Link UI on mount
[23653] Fix | Delete
// because otherwise using the keyboard to select text
[23654] Fix | Delete
// *within* the link format is not possible.
[23655] Fix | Delete
if (isMounting.current) {
[23656] Fix | Delete
return;
[23657] Fix | Delete
}
[23658] Fix | Delete
[23659] Fix | Delete
// Scenario - when:
[23660] Fix | Delete
// - switching between editable and non editable LinkControl
[23661] Fix | Delete
// - clicking on a link
[23662] Fix | Delete
// ...then move focus to the *first* element to avoid focus loss
[23663] Fix | Delete
// and to ensure focus is *within* the Link UI.
[23664] Fix | Delete
const nextFocusTarget = external_wp_dom_namespaceObject.focus.focusable.find(wrapperNode.current)[0] || wrapperNode.current;
[23665] Fix | Delete
nextFocusTarget.focus();
[23666] Fix | Delete
isEndingEditWithFocus.current = false;
[23667] Fix | Delete
}, [isEditingLink, isCreatingPage]);
[23668] Fix | Delete
[23669] Fix | Delete
// The component mounting reference is maintained separately
[23670] Fix | Delete
// to correctly reset values in `StrictMode`.
[23671] Fix | Delete
(0,external_wp_element_namespaceObject.useEffect)(() => {
[23672] Fix | Delete
isMounting.current = false;
[23673] Fix | Delete
return () => {
[23674] Fix | Delete
isMounting.current = true;
[23675] Fix | Delete
};
[23676] Fix | Delete
}, []);
[23677] Fix | Delete
const hasLinkValue = value?.url?.trim()?.length > 0;
[23678] Fix | Delete
[23679] Fix | Delete
/**
[23680] Fix | Delete
* Cancels editing state and marks that focus may need to be restored after
[23681] Fix | Delete
* the next render, if focus was within the wrapper when editing finished.
[23682] Fix | Delete
*/
[23683] Fix | Delete
const stopEditing = () => {
[23684] Fix | Delete
isEndingEditWithFocus.current = !!wrapperNode.current?.contains(wrapperNode.current.ownerDocument.activeElement);
[23685] Fix | Delete
setIsEditingLink(false);
[23686] Fix | Delete
};
[23687] Fix | Delete
const handleSelectSuggestion = updatedValue => {
[23688] Fix | Delete
// Suggestions may contains "settings" values (e.g. `opensInNewTab`)
[23689] Fix | Delete
// which should not overide any existing settings values set by the
[23690] Fix | Delete
// user. This filters out any settings values from the suggestion.
[23691] Fix | Delete
const nonSettingsChanges = Object.keys(updatedValue).reduce((acc, key) => {
[23692] Fix | Delete
if (!settingsKeys.includes(key)) {
[23693] Fix | Delete
acc[key] = updatedValue[key];
[23694] Fix | Delete
}
[23695] Fix | Delete
return acc;
[23696] Fix | Delete
}, {});
[23697] Fix | Delete
onChange({
[23698] Fix | Delete
...internalControlValue,
[23699] Fix | Delete
...nonSettingsChanges,
[23700] Fix | Delete
// As title is not a setting, it must be manually applied
[23701] Fix | Delete
// in such a way as to preserve the users changes over
[23702] Fix | Delete
// any "title" value provided by the "suggestion".
[23703] Fix | Delete
title: internalControlValue?.title || updatedValue?.title
[23704] Fix | Delete
});
[23705] Fix | Delete
stopEditing();
[23706] Fix | Delete
};
[23707] Fix | Delete
const handleSubmit = () => {
[23708] Fix | Delete
if (valueHasChanges) {
[23709] Fix | Delete
// Submit the original value with new stored values applied
[23710] Fix | Delete
// on top. URL is a special case as it may also be a prop.
[23711] Fix | Delete
onChange({
[23712] Fix | Delete
...value,
[23713] Fix | Delete
...internalControlValue,
[23714] Fix | Delete
url: currentUrlInputValue
[23715] Fix | Delete
});
[23716] Fix | Delete
}
[23717] Fix | Delete
stopEditing();
[23718] Fix | Delete
};
[23719] Fix | Delete
const handleSubmitWithEnter = event => {
[23720] Fix | Delete
const {
[23721] Fix | Delete
keyCode
[23722] Fix | Delete
} = event;
[23723] Fix | Delete
if (keyCode === external_wp_keycodes_namespaceObject.ENTER && !currentInputIsEmpty // Disallow submitting empty values.
[23724] Fix | Delete
) {
[23725] Fix | Delete
event.preventDefault();
[23726] Fix | Delete
handleSubmit();
[23727] Fix | Delete
}
[23728] Fix | Delete
};
[23729] Fix | Delete
const resetInternalValues = () => {
[23730] Fix | Delete
setInternalControlValue(value);
[23731] Fix | Delete
};
[23732] Fix | Delete
const handleCancel = event => {
[23733] Fix | Delete
event.preventDefault();
[23734] Fix | Delete
event.stopPropagation();
[23735] Fix | Delete
[23736] Fix | Delete
// Ensure that any unsubmitted input changes are reset.
[23737] Fix | Delete
resetInternalValues();
[23738] Fix | Delete
if (hasLinkValue) {
[23739] Fix | Delete
// If there is a link then exist editing mode and show preview.
[23740] Fix | Delete
stopEditing();
[23741] Fix | Delete
} else {
[23742] Fix | Delete
// If there is no link value, then remove the link entirely.
[23743] Fix | Delete
onRemove?.();
[23744] Fix | Delete
}
[23745] Fix | Delete
onCancel?.();
[23746] Fix | Delete
};
[23747] Fix | Delete
const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
[23748] Fix | Delete
const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
[23749] Fix | Delete
const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
[23750] Fix | Delete
const showActions = isEditingLink && hasLinkValue;
[23751] Fix | Delete
[23752] Fix | Delete
// Only show text control once a URL value has been committed
[23753] Fix | Delete
// and it isn't just empty whitespace.
[23754] Fix | Delete
// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
[23755] Fix | Delete
const showTextControl = hasLinkValue && hasTextControl;
[23756] Fix | Delete
const isEditing = (isEditingLink || !value) && !isCreatingPage;
[23757] Fix | Delete
const isDisabled = !valueHasChanges || currentInputIsEmpty;
[23758] Fix | Delete
const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
[23759] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[23760] Fix | Delete
tabIndex: -1,
[23761] Fix | Delete
ref: wrapperNode,
[23762] Fix | Delete
className: "block-editor-link-control",
[23763] Fix | Delete
children: [isCreatingPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[23764] Fix | Delete
className: "block-editor-link-control__loading",
[23765] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), " ", (0,external_wp_i18n_namespaceObject.__)('Creating'), "\u2026"]
[23766] Fix | Delete
}), isEditing && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[23767] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
[23768] Fix | Delete
className: dist_clsx({
[23769] Fix | Delete
'block-editor-link-control__search-input-wrapper': true,
[23770] Fix | Delete
'has-text-control': showTextControl,
[23771] Fix | Delete
'has-actions': showActions
[23772] Fix | Delete
}),
[23773] Fix | Delete
children: [showTextControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
[23774] Fix | Delete
__nextHasNoMarginBottom: true,
[23775] Fix | Delete
ref: textInputRef,
[23776] Fix | Delete
className: "block-editor-link-control__field block-editor-link-control__text-content",
[23777] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Text'),
[23778] Fix | Delete
value: internalControlValue?.title,
[23779] Fix | Delete
onChange: setInternalTextInputValue,
[23780] Fix | Delete
onKeyDown: handleSubmitWithEnter,
[23781] Fix | Delete
size: "__unstable-large"
[23782] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(search_input, {
[23783] Fix | Delete
currentLink: value,
[23784] Fix | Delete
className: "block-editor-link-control__field block-editor-link-control__search-input",
[23785] Fix | Delete
placeholder: searchInputPlaceholder,
[23786] Fix | Delete
value: currentUrlInputValue,
[23787] Fix | Delete
withCreateSuggestion: withCreateSuggestion,
[23788] Fix | Delete
onCreateSuggestion: createPage,
[23789] Fix | Delete
onChange: setInternalURLInputValue,
[23790] Fix | Delete
onSelect: handleSelectSuggestion,
[23791] Fix | Delete
showInitialSuggestions: showInitialSuggestions,
[23792] Fix | Delete
allowDirectEntry: !noDirectEntry,
[23793] Fix | Delete
showSuggestions: showSuggestions,
[23794] Fix | Delete
suggestionsQuery: suggestionsQuery,
[23795] Fix | Delete
withURLSuggestion: !noURLSuggestion,
[23796] Fix | Delete
createSuggestionButtonText: createSuggestionButtonText,
[23797] Fix | Delete
hideLabelFromVision: !showTextControl
[23798] Fix | Delete
}), !showActions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
[23799] Fix | Delete
className: "block-editor-link-control__search-enter",
[23800] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[23801] Fix | Delete
onClick: isDisabled ? link_control_noop : handleSubmit,
[23802] Fix | Delete
label: (0,external_wp_i18n_namespaceObject.__)('Submit'),
[23803] Fix | Delete
icon: keyboard_return,
[23804] Fix | Delete
className: "block-editor-link-control__search-submit",
[23805] Fix | Delete
"aria-disabled": isDisabled
[23806] Fix | Delete
})
[23807] Fix | Delete
})]
[23808] Fix | Delete
}), errorMessage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
[23809] Fix | Delete
className: "block-editor-link-control__search-error",
[23810] Fix | Delete
status: "error",
[23811] Fix | Delete
isDismissible: false,
[23812] Fix | Delete
children: errorMessage
[23813] Fix | Delete
})]
[23814] Fix | Delete
}), value && !isEditingLink && !isCreatingPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LinkPreview, {
[23815] Fix | Delete
// force remount when URL changes to avoid race conditions for rich previews
[23816] Fix | Delete
value: value,
[23817] Fix | Delete
onEditClick: () => setIsEditingLink(true),
[23818] Fix | Delete
hasRichPreviews: hasRichPreviews,
[23819] Fix | Delete
hasUnlinkControl: shownUnlinkControl,
[23820] Fix | Delete
onRemove: () => {
[23821] Fix | Delete
onRemove();
[23822] Fix | Delete
setIsEditingLink(true);
[23823] Fix | Delete
}
[23824] Fix | Delete
}, value?.url), showSettings && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
[23825] Fix | Delete
className: "block-editor-link-control__tools",
[23826] Fix | Delete
children: !currentInputIsEmpty && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(settings_drawer, {
[23827] Fix | Delete
settingsOpen: isSettingsOpen,
[23828] Fix | Delete
setSettingsOpen: setSettingsOpenWithPreference,
[23829] Fix | Delete
children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(link_control_settings, {
[23830] Fix | Delete
value: internalControlValue,
[23831] Fix | Delete
settings: settings,
[23832] Fix | Delete
onChange: createSetInternalSettingValueHandler(settingsKeys)
[23833] Fix | Delete
})
[23834] Fix | Delete
})
[23835] Fix | Delete
}), showActions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
[23836] Fix | Delete
justify: "right",
[23837] Fix | Delete
className: "block-editor-link-control__search-actions",
[23838] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[23839] Fix | Delete
variant: "tertiary",
[23840] Fix | Delete
onClick: handleCancel,
[23841] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
[23842] Fix | Delete
}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
[23843] Fix | Delete
variant: "primary",
[23844] Fix | Delete
onClick: isDisabled ? link_control_noop : handleSubmit,
[23845] Fix | Delete
className: "block-editor-link-control__search-submit",
[23846] Fix | Delete
"aria-disabled": isDisabled,
[23847] Fix | Delete
children: (0,external_wp_i18n_namespaceObject.__)('Save')
[23848] Fix | Delete
})]
[23849] Fix | Delete
}), !isCreatingPage && renderControlBottom && renderControlBottom()]
[23850] Fix | Delete
});
[23851] Fix | Delete
}
[23852] Fix | Delete
LinkControl.ViewerFill = ViewerFill;
[23853] Fix | Delete
LinkControl.DEFAULT_LINK_SETTINGS = DEFAULT_LINK_SETTINGS;
[23854] Fix | Delete
/* harmony default export */ const link_control = (LinkControl);
[23855] Fix | Delete
[23856] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/block-editor/build-module/components/media-replace-flow/index.js
[23857] Fix | Delete
/**
[23858] Fix | Delete
* External dependencies
[23859] Fix | Delete
*/
[23860] Fix | Delete
[23861] Fix | Delete
[23862] Fix | Delete
/**
[23863] Fix | Delete
* WordPress dependencies
[23864] Fix | Delete
*/
[23865] Fix | Delete
[23866] Fix | Delete
[23867] Fix | Delete
[23868] Fix | Delete
[23869] Fix | Delete
[23870] Fix | Delete
[23871] Fix | Delete
[23872] Fix | Delete
[23873] Fix | Delete
[23874] Fix | Delete
[23875] Fix | Delete
[23876] Fix | Delete
/**
[23877] Fix | Delete
* Internal dependencies
[23878] Fix | Delete
*/
[23879] Fix | Delete
[23880] Fix | Delete
[23881] Fix | Delete
[23882] Fix | Delete
[23883] Fix | Delete
[23884] Fix | Delete
[23885] Fix | Delete
[23886] Fix | Delete
const media_replace_flow_noop = () => {};
[23887] Fix | Delete
let uniqueId = 0;
[23888] Fix | Delete
const MediaReplaceFlow = ({
[23889] Fix | Delete
mediaURL,
[23890] Fix | Delete
mediaId,
[23891] Fix | Delete
mediaIds,
[23892] Fix | Delete
allowedTypes,
[23893] Fix | Delete
accept,
[23894] Fix | Delete
onError,
[23895] Fix | Delete
onSelect,
[23896] Fix | Delete
onSelectURL,
[23897] Fix | Delete
onToggleFeaturedImage,
[23898] Fix | Delete
useFeaturedImage,
[23899] Fix | Delete
onFilesUpload = media_replace_flow_noop,
[23900] Fix | Delete
name = (0,external_wp_i18n_namespaceObject.__)('Replace'),
[23901] Fix | Delete
createNotice,
[23902] Fix | Delete
removeNotice,
[23903] Fix | Delete
children,
[23904] Fix | Delete
multiple = false,
[23905] Fix | Delete
addToGallery,
[23906] Fix | Delete
handleUpload = true,
[23907] Fix | Delete
popoverProps
[23908] Fix | Delete
}) => {
[23909] Fix | Delete
const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
[23910] Fix | Delete
return select(store).getSettings().mediaUpload;
[23911] Fix | Delete
}, []);
[23912] Fix | Delete
const canUpload = !!mediaUpload;
[23913] Fix | Delete
const editMediaButtonRef = (0,external_wp_element_namespaceObject.useRef)();
[23914] Fix | Delete
const errorNoticeID = `block-editor/media-replace-flow/error-notice/${++uniqueId}`;
[23915] Fix | Delete
const onUploadError = message => {
[23916] Fix | Delete
const safeMessage = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(message);
[23917] Fix | Delete
if (onError) {
[23918] Fix | Delete
onError(safeMessage);
[23919] Fix | Delete
return;
[23920] Fix | Delete
}
[23921] Fix | Delete
// We need to set a timeout for showing the notice
[23922] Fix | Delete
// so that VoiceOver and possibly other screen readers
[23923] Fix | Delete
// can announce the error afer the toolbar button
[23924] Fix | Delete
// regains focus once the upload dialog closes.
[23925] Fix | Delete
// Otherwise VO simply skips over the notice and announces
[23926] Fix | Delete
// the focused element and the open menu.
[23927] Fix | Delete
setTimeout(() => {
[23928] Fix | Delete
createNotice('error', safeMessage, {
[23929] Fix | Delete
speak: true,
[23930] Fix | Delete
id: errorNoticeID,
[23931] Fix | Delete
isDismissible: true
[23932] Fix | Delete
});
[23933] Fix | Delete
}, 1000);
[23934] Fix | Delete
};
[23935] Fix | Delete
const selectMedia = (media, closeMenu) => {
[23936] Fix | Delete
if (useFeaturedImage && onToggleFeaturedImage) {
[23937] Fix | Delete
onToggleFeaturedImage();
[23938] Fix | Delete
}
[23939] Fix | Delete
closeMenu();
[23940] Fix | Delete
// Calling `onSelect` after the state update since it might unmount the component.
[23941] Fix | Delete
onSelect(media);
[23942] Fix | Delete
(0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('The media file has been replaced'));
[23943] Fix | Delete
removeNotice(errorNoticeID);
[23944] Fix | Delete
};
[23945] Fix | Delete
const uploadFiles = (event, closeMenu) => {
[23946] Fix | Delete
const files = event.target.files;
[23947] Fix | Delete
if (!handleUpload) {
[23948] Fix | Delete
closeMenu();
[23949] Fix | Delete
return onSelect(files);
[23950] Fix | Delete
}
[23951] Fix | Delete
onFilesUpload(files);
[23952] Fix | Delete
mediaUpload({
[23953] Fix | Delete
allowedTypes,
[23954] Fix | Delete
filesList: files,
[23955] Fix | Delete
onFileChange: ([media]) => {
[23956] Fix | Delete
selectMedia(media, closeMenu);
[23957] Fix | Delete
},
[23958] Fix | Delete
onError: onUploadError
[23959] Fix | Delete
});
[23960] Fix | Delete
};
[23961] Fix | Delete
const openOnArrowDown = event => {
[23962] Fix | Delete
if (event.keyCode === external_wp_keycodes_namespaceObject.DOWN) {
[23963] Fix | Delete
event.preventDefault();
[23964] Fix | Delete
event.target.click();
[23965] Fix | Delete
}
[23966] Fix | Delete
};
[23967] Fix | Delete
const onlyAllowsImages = () => {
[23968] Fix | Delete
if (!allowedTypes || allowedTypes.length === 0) {
[23969] Fix | Delete
return false;
[23970] Fix | Delete
}
[23971] Fix | Delete
return allowedTypes.every(allowedType => allowedType === 'image' || allowedType.startsWith('image/'));
[23972] Fix | Delete
};
[23973] Fix | Delete
const gallery = multiple && onlyAllowsImages();
[23974] Fix | Delete
return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
[23975] Fix | Delete
popoverProps: popoverProps,
[23976] Fix | Delete
contentClassName: "block-editor-media-replace-flow__options",
[23977] Fix | Delete
renderToggle: ({
[23978] Fix | Delete
isOpen,
[23979] Fix | Delete
onToggle
[23980] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarButton, {
[23981] Fix | Delete
ref: editMediaButtonRef,
[23982] Fix | Delete
"aria-expanded": isOpen,
[23983] Fix | Delete
"aria-haspopup": "true",
[23984] Fix | Delete
onClick: onToggle,
[23985] Fix | Delete
onKeyDown: openOnArrowDown,
[23986] Fix | Delete
children: name
[23987] Fix | Delete
}),
[23988] Fix | Delete
renderContent: ({
[23989] Fix | Delete
onClose
[23990] Fix | Delete
}) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
[23991] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.NavigableMenu, {
[23992] Fix | Delete
className: "block-editor-media-replace-flow__media-upload-menu",
[23993] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(check, {
[23994] Fix | Delete
children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(media_upload, {
[23995] Fix | Delete
gallery: gallery,
[23996] Fix | Delete
addToGallery: addToGallery,
[23997] Fix | Delete
multiple: multiple,
[23998] Fix | Delete
value: multiple ? mediaIds : mediaId,
[23999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function