@wordpress/block-editor 12.3.12 → 12.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/build/components/block-controls/use-has-block-controls.js +52 -0
  2. package/build/components/block-controls/use-has-block-controls.js.map +1 -0
  3. package/build/components/block-tools/block-contextual-toolbar.js +50 -5
  4. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  5. package/build/components/copy-handler/index.js +2 -0
  6. package/build/components/copy-handler/index.js.map +1 -1
  7. package/build/components/global-styles/typography-utils.js +3 -2
  8. package/build/components/global-styles/typography-utils.js.map +1 -1
  9. package/build/components/link-control/index.js +47 -6
  10. package/build/components/link-control/index.js.map +1 -1
  11. package/build/components/rich-text/index.js +8 -1
  12. package/build/components/rich-text/index.js.map +1 -1
  13. package/build/components/rich-text/use-format-types.js +3 -2
  14. package/build/components/rich-text/use-format-types.js.map +1 -1
  15. package/build-module/components/block-controls/use-has-block-controls.js +38 -0
  16. package/build-module/components/block-controls/use-has-block-controls.js.map +1 -0
  17. package/build-module/components/block-tools/block-contextual-toolbar.js +49 -5
  18. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  19. package/build-module/components/copy-handler/index.js +2 -0
  20. package/build-module/components/copy-handler/index.js.map +1 -1
  21. package/build-module/components/global-styles/typography-utils.js +4 -3
  22. package/build-module/components/global-styles/typography-utils.js.map +1 -1
  23. package/build-module/components/link-control/index.js +45 -6
  24. package/build-module/components/link-control/index.js.map +1 -1
  25. package/build-module/components/rich-text/index.js +8 -1
  26. package/build-module/components/rich-text/index.js.map +1 -1
  27. package/build-module/components/rich-text/use-format-types.js +3 -2
  28. package/build-module/components/rich-text/use-format-types.js.map +1 -1
  29. package/build-style/content-rtl.css +5 -7
  30. package/build-style/content.css +5 -7
  31. package/build-style/style-rtl.css +28 -6
  32. package/build-style/style.css +28 -6
  33. package/package.json +5 -5
  34. package/src/components/block-controls/use-has-block-controls.js +35 -0
  35. package/src/components/block-list/content.scss +2 -3
  36. package/src/components/block-toolbar/style.scss +10 -0
  37. package/src/components/block-tools/block-contextual-toolbar.js +86 -7
  38. package/src/components/block-tools/style.scss +34 -10
  39. package/src/components/copy-handler/index.js +1 -0
  40. package/src/components/global-styles/test/typography-utils.js +10 -0
  41. package/src/components/global-styles/typography-utils.js +11 -3
  42. package/src/components/link-control/README.md +12 -3
  43. package/src/components/link-control/index.js +43 -6
  44. package/src/components/link-control/test/index.js +2 -1
  45. package/src/components/rich-text/index.js +7 -0
  46. package/src/components/rich-text/use-format-types.js +3 -3
@@ -14,6 +14,8 @@ import { useRef, useState, useEffect } from '@wordpress/element';
14
14
  import { focus } from '@wordpress/dom';
15
15
  import { ENTER } from '@wordpress/keycodes';
16
16
  import { isShallowEqualObjects } from '@wordpress/is-shallow-equal';
17
+ import { useSelect, useDispatch } from '@wordpress/data';
18
+ import { store as preferencesStore } from '@wordpress/preferences';
17
19
  /**
18
20
  * Internal dependencies
19
21
  */
@@ -103,6 +105,9 @@ import { DEFAULT_LINK_SETTINGS } from './constants';
103
105
  */
104
106
 
105
107
  const noop = () => {};
108
+
109
+ const PREFERENCE_SCOPE = 'core/block-editor';
110
+ const PREFERENCE_KEY = 'linkControlSettingsDrawer';
106
111
  /**
107
112
  * Renders a link control. A link control is a controlled input which maintains
108
113
  * a value associated with a link (HTML anchor element) and relevant settings
@@ -111,7 +116,6 @@ const noop = () => {};
111
116
  * @param {WPLinkControlProps} props Component props.
112
117
  */
113
118
 
114
-
115
119
  function LinkControl({
116
120
  searchInputPlaceholder,
117
121
  value,
@@ -137,6 +141,43 @@ function LinkControl({
137
141
  withCreateSuggestion = true;
138
142
  }
139
143
 
144
+ const [settingsOpen, setSettingsOpen] = useState(false);
145
+ const {
146
+ advancedSettingsPreference
147
+ } = useSelect(select => {
148
+ var _prefsStore$get;
149
+
150
+ const prefsStore = select(preferencesStore);
151
+ return {
152
+ advancedSettingsPreference: (_prefsStore$get = prefsStore.get(PREFERENCE_SCOPE, PREFERENCE_KEY)) !== null && _prefsStore$get !== void 0 ? _prefsStore$get : false
153
+ };
154
+ }, []);
155
+ const {
156
+ set: setPreference
157
+ } = useDispatch(preferencesStore);
158
+ /**
159
+ * Sets the open/closed state of the Advanced Settings Drawer,
160
+ * optionlly persisting the state to the user's preferences.
161
+ *
162
+ * Note that Block Editor components can be consumed by non-WordPress
163
+ * environments which may not have preferences setup.
164
+ * Therefore a local state is also used as a fallback.
165
+ *
166
+ * @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.
167
+ */
168
+
169
+ const setSettingsOpenWithPreference = prefVal => {
170
+ if (setPreference) {
171
+ setPreference(PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal);
172
+ }
173
+
174
+ setSettingsOpen(prefVal);
175
+ }; // Block Editor components can be consumed by non-WordPress environments
176
+ // which may not have these preferences setup.
177
+ // Therefore a local state is used as a fallback.
178
+
179
+
180
+ const isSettingsOpen = advancedSettingsPreference || settingsOpen;
140
181
  const isMounting = useRef(true);
141
182
  const wrapperNode = useRef();
142
183
  const textInputRef = useRef();
@@ -144,7 +185,6 @@ function LinkControl({
144
185
  const settingsKeys = settings.map(({
145
186
  id
146
187
  }) => id);
147
- const [settingsOpen, setSettingsOpen] = useState(false);
148
188
  const [internalControlValue, setInternalControlValue, setInternalURLInputValue, setInternalTextInputValue, createSetInternalSettingValueHandler] = useInternalValue(value);
149
189
  const valueHasChanges = value && !isShallowEqualObjects(internalControlValue, value);
150
190
  const [isEditingLink, setIsEditingLink] = useState(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
@@ -186,7 +226,6 @@ function LinkControl({
186
226
 
187
227
  const stopEditing = () => {
188
228
  isEndingEditWithFocus.current = !!wrapperNode.current?.contains(wrapperNode.current.ownerDocument.activeElement);
189
- setSettingsOpen(false);
190
229
  setIsEditingLink(false);
191
230
  };
192
231
 
@@ -260,7 +299,6 @@ function LinkControl({
260
299
  const currentUrlInputValue = propInputValue || internalControlValue?.url || '';
261
300
  const currentInputIsEmpty = !currentUrlInputValue?.trim()?.length;
262
301
  const shownUnlinkControl = onRemove && value && !isEditingLink && !isCreatingPage;
263
- const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
264
302
  const showActions = isEditingLink && hasLinkValue; // Only show text control once a URL value has been committed
265
303
  // and it isn't just empty whitespace.
266
304
  // See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.
@@ -268,6 +306,7 @@ function LinkControl({
268
306
  const showTextControl = hasLinkValue && hasTextControl;
269
307
  const isEditing = (isEditingLink || !value) && !isCreatingPage;
270
308
  const isDisabled = !valueHasChanges || currentInputIsEmpty;
309
+ const showSettings = !!settings?.length && isEditingLink && hasLinkValue;
271
310
  return createElement("div", {
272
311
  tabIndex: -1,
273
312
  ref: wrapperNode,
@@ -319,8 +358,8 @@ function LinkControl({
319
358
  }), showSettings && createElement("div", {
320
359
  className: "block-editor-link-control__tools"
321
360
  }, !currentInputIsEmpty && createElement(LinkControlSettingsDrawer, {
322
- settingsOpen: settingsOpen,
323
- setSettingsOpen: setSettingsOpen
361
+ settingsOpen: isSettingsOpen,
362
+ setSettingsOpen: setSettingsOpenWithPreference
324
363
  }, createElement(LinkSettings, {
325
364
  value: internalControlValue,
326
365
  settings: settings,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","settingsOpen","setSettingsOpen","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showSettings","showActions","showTextControl","isEditing","isDisabled"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AAC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G,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetSettingsOpen( false );\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ settingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpen }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["classnames","Button","Spinner","Notice","TextControl","__","useRef","useState","useEffect","focus","ENTER","isShallowEqualObjects","useSelect","useDispatch","store","preferencesStore","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","LinkSettings","useCreatePage","useInternalValue","ViewerFill","DEFAULT_LINK_SETTINGS","noop","PREFERENCE_SCOPE","PREFERENCE_KEY","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","onCancel","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","settingsOpen","setSettingsOpen","advancedSettingsPreference","select","prefsStore","get","set","setPreference","setSettingsOpenWithPreference","prefVal","isSettingsOpen","isMounting","wrapperNode","textInputRef","isEndingEditWithFocus","settingsKeys","map","id","internalControlValue","setInternalControlValue","setInternalURLInputValue","setInternalTextInputValue","createSetInternalSettingValueHandler","valueHasChanges","isEditingLink","setIsEditingLink","url","createPage","isCreatingPage","errorMessage","current","nextFocusTarget","focusable","find","hasLinkValue","trim","length","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","nonSettingsChanges","Object","keys","reduce","acc","key","includes","title","handleSubmit","currentUrlInputValue","handleSubmitWithEnter","event","keyCode","currentInputIsEmpty","preventDefault","resetInternalValues","handleCancel","stopPropagation","shownUnlinkControl","showActions","showTextControl","isEditing","isDisabled","showSettings"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,qBAAT,QAAsC,6BAAtC;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,YAAP,MAAyB,YAAzB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,OAAOC,gBAAP,MAA6B,sBAA7B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AACA;AACA;AACA;AACA;AACA;;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,MAAMC,IAAI,GAAG,MAAM,CAAE,CAArB;;AAEA,MAAMC,gBAAgB,GAAG,mBAAzB;AACA,MAAMC,cAAc,GAAG,2BAAvB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Z;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,OAAO,EAAGG,UAAU,GAAG1F,IAAH,GAAU4E,YAF/B;AAGC,IAAA,SAAS,EAAC,0CAHX;AAIC,qBAAgBc;AAJjB,KAMG7G,EAAE,CAAE,MAAF,CANL,CADD,EASC,cAAC,MAAD;AAAQ,IAAA,OAAO,EAAC,UAAhB;AAA2B,IAAA,OAAO,EAAGuG;AAArC,KACGvG,EAAE,CAAE,QAAF,CADL,CATD,CA9FF,EA6GG0C,mBAAmB,IAAIA,mBAAmB,EA7G7C,CADD;AAiHA;;AAEDpB,WAAW,CAACL,UAAZ,GAAyBA,UAAzB;AAEA,eAAeK,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\nimport { isShallowEqualObjects } from '@wordpress/is-shallow-equal';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport LinkSettings from './settings';\nimport useCreatePage from './use-create-page';\nimport useInternalValue from './use-internal-value';\nimport { ViewerFill } from './viewer-slot';\nimport { DEFAULT_LINK_SETTINGS } from './constants';\n\n/**\n * Default properties associated with a link control value.\n *\n * @typedef WPLinkControlDefaultValue\n *\n * @property {string} url Link URL.\n * @property {string=} title Link title.\n * @property {boolean=} opensInNewTab Whether link should open in a new browser\n * tab. This value is only assigned if not\n * providing a custom `settings` prop.\n */\n\n/* eslint-disable jsdoc/valid-types */\n/**\n * Custom settings values associated with a link.\n *\n * @typedef {{[setting:string]:any}} WPLinkControlSettingsValue\n */\n/* eslint-enable */\n\n/**\n * Custom settings values associated with a link.\n *\n * @typedef WPLinkControlSetting\n *\n * @property {string} id Identifier to use as property for setting value.\n * @property {string} title Human-readable label to show in user interface.\n */\n\n/**\n * Properties associated with a link control value, composed as a union of the\n * default properties and any custom settings values.\n *\n * @typedef {WPLinkControlDefaultValue&WPLinkControlSettingsValue} WPLinkControlValue\n */\n\n/** @typedef {(nextValue:WPLinkControlValue)=>void} WPLinkControlOnChangeProp */\n\n/**\n * Properties associated with a search suggestion used within the LinkControl.\n *\n * @typedef WPLinkControlSuggestion\n *\n * @property {string} id Identifier to use to uniquely identify the suggestion.\n * @property {string} type Identifies the type of the suggestion (eg: `post`,\n * `page`, `url`...etc)\n * @property {string} title Human-readable label to show in user interface.\n * @property {string} url A URL for the suggestion.\n */\n\n/** @typedef {(title:string)=>WPLinkControlSuggestion} WPLinkControlCreateSuggestionProp */\n\n/**\n * @typedef WPLinkControlProps\n *\n * @property {(WPLinkControlSetting[])=} settings An array of settings objects. Each object will used to\n * render a `ToggleControl` for that setting.\n * @property {boolean=} forceIsEditingLink If passed as either `true` or `false`, controls the\n * internal editing state of the component to respective\n * show or not show the URL input field.\n * @property {WPLinkControlValue=} value Current link value.\n * @property {WPLinkControlOnChangeProp=} onChange Value change handler, called with the updated value if\n * the user selects a new link or updates settings.\n * @property {boolean=} noDirectEntry Whether to allow turning a URL-like search query directly into a link.\n * @property {boolean=} showSuggestions Whether to present suggestions when typing the URL.\n * @property {boolean=} showInitialSuggestions Whether to present initial suggestions immediately.\n * @property {boolean=} withCreateSuggestion Whether to allow creation of link value from suggestion.\n * @property {Object=} suggestionsQuery Query parameters to pass along to wp.blockEditor.__experimentalFetchLinkSuggestions.\n * @property {boolean=} noURLSuggestion Whether to add a fallback suggestion which treats the search query as a URL.\n * @property {boolean=} hasTextControl Whether to add a text field to the UI to update the value.title.\n * @property {string|Function|undefined} createSuggestionButtonText The text to use in the button that calls createSuggestion.\n * @property {Function} renderControlBottom Optional controls to be rendered at the bottom of the component.\n */\n\nconst noop = () => {};\n\nconst PREFERENCE_SCOPE = 'core/block-editor';\nconst PREFERENCE_KEY = 'linkControlSettingsDrawer';\n\n/**\n * Renders a link control. A link control is a controlled input which maintains\n * a value associated with a link (HTML anchor element) and relevant settings\n * for how that link is expected to behave.\n *\n * @param {WPLinkControlProps} props Component props.\n */\nfunction LinkControl( {\n\tsearchInputPlaceholder,\n\tvalue,\n\tsettings = DEFAULT_LINK_SETTINGS,\n\tonChange = noop,\n\tonRemove,\n\tonCancel,\n\tnoDirectEntry = false,\n\tshowSuggestions = true,\n\tshowInitialSuggestions,\n\tforceIsEditingLink,\n\tcreateSuggestion,\n\twithCreateSuggestion,\n\tinputValue: propInputValue = '',\n\tsuggestionsQuery = {},\n\tnoURLSuggestion = false,\n\tcreateSuggestionButtonText,\n\thasRichPreviews = false,\n\thasTextControl = false,\n\trenderControlBottom = null,\n} ) {\n\tif ( withCreateSuggestion === undefined && createSuggestion ) {\n\t\twithCreateSuggestion = true;\n\t}\n\n\tconst [ settingsOpen, setSettingsOpen ] = useState( false );\n\n\tconst { advancedSettingsPreference } = useSelect( ( select ) => {\n\t\tconst prefsStore = select( preferencesStore );\n\n\t\treturn {\n\t\t\tadvancedSettingsPreference:\n\t\t\t\tprefsStore.get( PREFERENCE_SCOPE, PREFERENCE_KEY ) ?? false,\n\t\t};\n\t}, [] );\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\n\t/**\n\t * Sets the open/closed state of the Advanced Settings Drawer,\n\t * optionlly persisting the state to the user's preferences.\n\t *\n\t * Note that Block Editor components can be consumed by non-WordPress\n\t * environments which may not have preferences setup.\n\t * Therefore a local state is also used as a fallback.\n\t *\n\t * @param {boolean} prefVal the open/closed state of the Advanced Settings Drawer.\n\t */\n\tconst setSettingsOpenWithPreference = ( prefVal ) => {\n\t\tif ( setPreference ) {\n\t\t\tsetPreference( PREFERENCE_SCOPE, PREFERENCE_KEY, prefVal );\n\t\t}\n\t\tsetSettingsOpen( prefVal );\n\t};\n\n\t// Block Editor components can be consumed by non-WordPress environments\n\t// which may not have these preferences setup.\n\t// Therefore a local state is used as a fallback.\n\tconst isSettingsOpen = advancedSettingsPreference || settingsOpen;\n\n\tconst isMounting = useRef( true );\n\tconst wrapperNode = useRef();\n\tconst textInputRef = useRef();\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst settingsKeys = settings.map( ( { id } ) => id );\n\n\tconst [\n\t\tinternalControlValue,\n\t\tsetInternalControlValue,\n\t\tsetInternalURLInputValue,\n\t\tsetInternalTextInputValue,\n\t\tcreateSetInternalSettingValueHandler,\n\t] = useInternalValue( value );\n\n\tconst valueHasChanges =\n\t\tvalue && ! isShallowEqualObjects( internalControlValue, value );\n\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\n\tconst { createPage, isCreatingPage, errorMessage } =\n\t\tuseCreatePage( createSuggestion );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tforceIsEditingLink !== undefined &&\n\t\t\tforceIsEditingLink !== isEditingLink\n\t\t) {\n\t\t\tsetIsEditingLink( forceIsEditingLink );\n\t\t}\n\t\t// Todo: bug if the missing dep is introduced. Will need a fix.\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t}, [ forceIsEditingLink ] );\n\n\tuseEffect( () => {\n\t\t// We don't auto focus into the Link UI on mount\n\t\t// because otherwise using the keyboard to select text\n\t\t// *within* the link format is not possible.\n\t\tif ( isMounting.current ) {\n\t\t\tisMounting.current = false;\n\t\t\treturn;\n\t\t}\n\n\t\t// Scenario - when:\n\t\t// - switching between editable and non editable LinkControl\n\t\t// - clicking on a link\n\t\t// ...then move focus to the *first* element to avoid focus loss\n\t\t// and to ensure focus is *within* the Link UI.\n\t\tconst nextFocusTarget =\n\t\t\tfocus.focusable.find( wrapperNode.current )[ 0 ] ||\n\t\t\twrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tconst hasLinkValue = value?.url?.trim()?.length > 0;\n\n\t/**\n\t * Cancels editing state and marks that focus may need to be restored after\n\t * the next render, if focus was within the wrapper when editing finished.\n\t */\n\tconst stopEditing = () => {\n\t\tisEndingEditWithFocus.current = !! wrapperNode.current?.contains(\n\t\t\twrapperNode.current.ownerDocument.activeElement\n\t\t);\n\n\t\tsetIsEditingLink( false );\n\t};\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\t// Suggestions may contains \"settings\" values (e.g. `opensInNewTab`)\n\t\t// which should not overide any existing settings values set by the\n\t\t// user. This filters out any settings values from the suggestion.\n\t\tconst nonSettingsChanges = Object.keys( updatedValue ).reduce(\n\t\t\t( acc, key ) => {\n\t\t\t\tif ( ! settingsKeys.includes( key ) ) {\n\t\t\t\t\tacc[ key ] = updatedValue[ key ];\n\t\t\t\t}\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\tonChange( {\n\t\t\t...internalControlValue,\n\t\t\t...nonSettingsChanges,\n\t\t\t// As title is not a setting, it must be manually applied\n\t\t\t// in such a way as to preserve the users changes over\n\t\t\t// any \"title\" value provided by the \"suggestion\".\n\t\t\ttitle: internalControlValue?.title || updatedValue?.title,\n\t\t} );\n\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif ( valueHasChanges ) {\n\t\t\t// Submit the original value with new stored values applied\n\t\t\t// on top. URL is a special case as it may also be a prop.\n\t\t\tonChange( {\n\t\t\t\t...value,\n\t\t\t\t...internalControlValue,\n\t\t\t\turl: currentUrlInputValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\n\n\t\tif (\n\t\t\tkeyCode === ENTER &&\n\t\t\t! currentInputIsEmpty // Disallow submitting empty values.\n\t\t) {\n\t\t\tevent.preventDefault();\n\t\t\thandleSubmit();\n\t\t}\n\t};\n\n\tconst resetInternalValues = () => {\n\t\tsetInternalControlValue( value );\n\t};\n\n\tconst handleCancel = ( event ) => {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\n\t\t// Ensure that any unsubmitted input changes are reset.\n\t\tresetInternalValues();\n\n\t\tif ( hasLinkValue ) {\n\t\t\t// If there is a link then exist editing mode and show preview.\n\t\t\tstopEditing();\n\t\t} else {\n\t\t\t// If there is no link value, then remove the link entirely.\n\t\t\tonRemove?.();\n\t\t}\n\n\t\tonCancel?.();\n\t};\n\n\tconst currentUrlInputValue =\n\t\tpropInputValue || internalControlValue?.url || '';\n\n\tconst currentInputIsEmpty = ! currentUrlInputValue?.trim()?.length;\n\n\tconst shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showActions = isEditingLink && hasLinkValue;\n\n\t// Only show text control once a URL value has been committed\n\t// and it isn't just empty whitespace.\n\t// See https://github.com/WordPress/gutenberg/pull/33849/#issuecomment-932194927.\n\tconst showTextControl = hasLinkValue && hasTextControl;\n\n\tconst isEditing = ( isEditingLink || ! value ) && ! isCreatingPage;\n\tconst isDisabled = ! valueHasChanges || currentInputIsEmpty;\n\tconst showSettings = !! settings?.length && isEditingLink && hasLinkValue;\n\n\treturn (\n\t\t<div\n\t\t\ttabIndex={ -1 }\n\t\t\tref={ wrapperNode }\n\t\t\tclassName=\"block-editor-link-control\"\n\t\t>\n\t\t\t{ isCreatingPage && (\n\t\t\t\t<div className=\"block-editor-link-control__loading\">\n\t\t\t\t\t<Spinner /> { __( 'Creating' ) }…\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ isEditing && (\n\t\t\t\t<>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName={ classnames( {\n\t\t\t\t\t\t\t'block-editor-link-control__search-input-wrapper': true,\n\t\t\t\t\t\t\t'has-text-control': showTextControl,\n\t\t\t\t\t\t} ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ showTextControl && (\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\t\tref={ textInputRef }\n\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__text-content\"\n\t\t\t\t\t\t\t\tlabel={ __( 'Text' ) }\n\t\t\t\t\t\t\t\tvalue={ internalControlValue?.title }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextInputValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t\tsize=\"__unstable-large\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<LinkControlSearchInput\n\t\t\t\t\t\t\tcurrentLink={ value }\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__field block-editor-link-control__search-input\"\n\t\t\t\t\t\t\tplaceholder={ searchInputPlaceholder }\n\t\t\t\t\t\t\tvalue={ currentUrlInputValue }\n\t\t\t\t\t\t\twithCreateSuggestion={ withCreateSuggestion }\n\t\t\t\t\t\t\tonCreateSuggestion={ createPage }\n\t\t\t\t\t\t\tonChange={ setInternalURLInputValue }\n\t\t\t\t\t\t\tonSelect={ handleSelectSuggestion }\n\t\t\t\t\t\t\tshowInitialSuggestions={ showInitialSuggestions }\n\t\t\t\t\t\t\tallowDirectEntry={ ! noDirectEntry }\n\t\t\t\t\t\t\tshowSuggestions={ showSuggestions }\n\t\t\t\t\t\t\tsuggestionsQuery={ suggestionsQuery }\n\t\t\t\t\t\t\twithURLSuggestion={ ! noURLSuggestion }\n\t\t\t\t\t\t\tcreateSuggestionButtonText={\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\thideLabelFromVision={ ! showTextControl }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t\t{ errorMessage && (\n\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-error\"\n\t\t\t\t\t\t\tstatus=\"error\"\n\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ errorMessage }\n\t\t\t\t\t\t</Notice>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ value && ! isEditingLink && ! isCreatingPage && (\n\t\t\t\t<LinkPreview\n\t\t\t\t\tkey={ value?.url } // force remount when URL changes to avoid race conditions for rich previews\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonEditClick={ () => setIsEditingLink( true ) }\n\t\t\t\t\thasRichPreviews={ hasRichPreviews }\n\t\t\t\t\thasUnlinkControl={ shownUnlinkControl }\n\t\t\t\t\tonRemove={ onRemove }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ showSettings && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t{ ! currentInputIsEmpty && (\n\t\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\t\tsettingsOpen={ isSettingsOpen }\n\t\t\t\t\t\t\tsetSettingsOpen={ setSettingsOpenWithPreference }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkSettings\n\t\t\t\t\t\t\t\tvalue={ internalControlValue }\n\t\t\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\t\t\tonChange={ createSetInternalSettingValueHandler(\n\t\t\t\t\t\t\t\t\tsettingsKeys\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</LinkControlSettingsDrawer>\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ showActions && (\n\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ isDisabled ? noop : handleSubmit }\n\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\taria-disabled={ isDisabled }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t\t<Button variant=\"tertiary\" onClick={ handleCancel }>\n\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -362,7 +362,14 @@ function RichTextWrapper({
362
362
  }), anchorRef]),
363
363
  contentEditable: true,
364
364
  suppressContentEditableWarning: true,
365
- className: classnames('block-editor-rich-text__editable', props.className, 'rich-text')
365
+ className: classnames('block-editor-rich-text__editable', props.className, 'rich-text') // Setting tabIndex to 0 is unnecessary, the element is already
366
+ // focusable because it's contentEditable. This also fixes a
367
+ // Safari bug where it's not possible to Shift+Click multi
368
+ // select blocks when Shift Clicking into an element with
369
+ // tabIndex because Safari will focus the element. However,
370
+ // Safari will correctly ignore nested contentEditable elements.
371
+ ,
372
+ tabIndex: props.tabIndex === 0 ? null : props.tabIndex
366
373
  }));
367
374
  }
368
375
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["classnames","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","children","childrenSource","useInstanceId","useMergeRefs","__unstableUseRichText","useRichText","__unstableCreateElement","removeFormat","deprecated","Popover","useBlockEditorAutocompleteProps","useBlockEditContext","FormatToolbarContainer","store","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useBeforeInputRules","useInputRules","useDelete","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useInsertReplacementText","useFirefoxCompat","FormatEdit","getMultilineTag","getAllowedFormats","Content","keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","since","version","alternative","link","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","selectionStart","selectionEnd","undefined","attributeKey","offset","getBlockRootClientId","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","getValue","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","className","ForwardedRichTextContainer","isEmpty","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,UAHD,EAICC,aAJD,QAKO,oBALP;AAMA,SAASC,WAAT,EAAsBC,SAA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KADU;AAEVe,MAAAA,OAFU;AAGVD,MAAAA;AAHU,KAAF,CAlCU,EAuCnBhD,QAAQ,CAAE;AACTgH,MAAAA,uBADS;AAET9E,MAAAA,KAFS;AAGTU,MAAAA,SAHS;AAITM,MAAAA,OAJS;AAKTI,MAAAA,aALS;AAMT6B,MAAAA,YANS;AAOT/C,MAAAA,QAPS;AAQT0B,MAAAA,iBARS;AASTV,MAAAA;AATS,KAAF,CAvCW,EAkDnB9C,gBAAgB,CAAE;AAAE4B,MAAAA,KAAF;AAASE,MAAAA;AAAT,KAAF,CAlDG,EAmDnBkC,SAnDmB,CAAF,CAPnB;AA4DC,IAAA,eAAe,EAAG,IA5DnB;AA6DC,IAAA,8BAA8B,EAAG,IA7DlC;AA8DC,IAAA,SAAS,EAAGlG,UAAU,CACrB,kCADqB,EAErB0C,KAAK,CAACiI,SAFe,EAGrB,WAHqB;AA9DvB,IA1BD,CADD;AAiGA;;AAED,MAAMC,0BAA0B,GAAGzK,UAAU,CAAEyD,eAAF,CAA7C;AAEAgH,0BAA0B,CAACtI,OAA3B,GAAqCA,OAArC;;AACAsI,0BAA0B,CAACC,OAA3B,GAAuC/G,KAAF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACoD,MAAN,KAAiB,CAAnC;AACA,CAFD;AAIA;AACA;AACA;;;AACA,eAAe0D,0BAAf;AACA,SAASE,gBAAT,QAAiC,YAAjC;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\nimport { Content } from './content';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tif ( multiline ) {\n\t\tdeprecated( 'wp.blockEditor.RichText multiline prop', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'nested blocks (InnerBlocks)',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat( { value, onChange } ),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/index.js"],"names":["classnames","useRef","useCallback","forwardRef","createContext","useDispatch","useSelect","children","childrenSource","useInstanceId","useMergeRefs","__unstableUseRichText","useRichText","__unstableCreateElement","removeFormat","deprecated","Popover","useBlockEditorAutocompleteProps","useBlockEditContext","FormatToolbarContainer","store","blockEditorStore","useUndoAutomaticChange","useMarkPersistent","usePasteHandler","useBeforeInputRules","useInputRules","useDelete","useEnter","useFormatTypes","useRemoveBrowserShortcuts","useShortcuts","useInputEvents","useInsertReplacementText","useFirefoxCompat","FormatEdit","getMultilineTag","getAllowedFormats","Content","keyboardShortcutContext","inputEventContext","removeNativeProps","props","__unstableMobileNoFocusOnMount","deleteEnter","placeholderTextColor","textAlign","selectionColor","tagsToEliminate","disableEditingMenu","fontSize","fontFamily","fontWeight","fontStyle","minWidth","maxWidth","setRef","disableSuggestions","disableAutocorrection","restProps","RichTextWrapper","tagName","value","originalValue","onChange","originalOnChange","isSelected","originalIsSelected","multiline","inlineToolbar","wrapperClassName","autocompleters","onReplace","placeholder","allowedFormats","withoutInteractiveFormatting","onRemove","onMerge","onSplit","__unstableOnSplitAtEnd","onSplitAtEnd","__unstableOnSplitMiddle","onSplitMiddle","identifier","preserveWhiteSpace","__unstablePastePlainText","pastePlainText","__unstableEmbedURLOnPaste","__unstableDisableFormats","disableFormats","disableLineBreaks","__unstableAllowPrefixTransformations","forwardedRef","since","version","alternative","link","instanceId","anchorRef","clientId","selector","select","getSelectionStart","getSelectionEnd","selectionStart","selectionEnd","undefined","attributeKey","offset","getBlockRootClientId","selectionChange","multilineTag","adjustedAllowedFormats","hasFormats","length","adjustedValue","adjustedOnChange","Array","isArray","toHTML","newValue","fromDOM","document","childNodes","onSelectionChange","start","end","selection","unset","formatTypes","prepareHandlers","valueHandlers","changeHandlers","dependencies","addEditorOnlyFormats","reduce","accumulator","fn","text","formats","removeEditorOnlyFormats","forEach","formatType","__experimentalCreatePrepareEditableTree","name","addInvisibleFormats","getValue","ref","richTextRef","html","__unstableFormats","__unstableText","Object","values","changeHandler","__unstableIsSelected","__unstableMultilineTag","__unstableDependencies","__unstableAfterParse","__unstableBeforeSerialize","__unstableAddInvisibleFormats","autocompleteProps","completers","record","keyboardShortcuts","Set","inputEvents","onFocus","current","focus","TagName","className","tabIndex","ForwardedRichTextContainer","isEmpty","RichTextShortcut","RichTextToolbarButton","__unstableRichTextInputEvent"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,MADD,EAECC,WAFD,EAGCC,UAHD,EAICC,aAJD,QAKO,oBALP;AAMA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,QAAQ,IAAIC,cAArB,QAA2C,mBAA3C;AACA,SAASC,aAAT,EAAwBC,YAAxB,QAA4C,oBAA5C;AACA,SACCC,qBAAqB,IAAIC,WAD1B,EAECC,uBAFD,EAGCC,YAHD,QAIO,sBAJP;AAKA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,OAAT,QAAwB,uBAAxB;AAEA;AACA;AACA;;AACA,SAASC,+BAAT,QAAgD,iBAAhD;AACA,SAASC,mBAAT,QAAoC,eAApC;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,sBAAT,QAAuC,6BAAvC;AACA,SAASC,iBAAT,QAAkC,uBAAlC;AACA,SAASC,eAAT,QAAgC,qBAAhC;AACA,SAASC,mBAAT,QAAoC,0BAApC;AACA,SAASC,aAAT,QAA8B,mBAA9B;AACA,SAASC,SAAT,QAA0B,cAA1B;AACA,SAASC,QAAT,QAAyB,aAAzB;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,yBAAT,QAA0C,gCAA1C;AACA,SAASC,YAAT,QAA6B,iBAA7B;AACA,SAASC,cAAT,QAA+B,oBAA/B;AACA,SAASC,wBAAT,QAAyC,+BAAzC;AACA,SAASC,gBAAT,QAAiC,sBAAjC;AACA,OAAOC,UAAP,MAA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AF,IAAa;AACjD,SAAO,CAAEA,KAAF,IAAWA,KAAK,CAACoD,MAAN,KAAiB,CAAnC;AACA,CAFD;AAIA;AACA;AACA;;;AACA,eAAe2D,0BAAf;AACA,SAASE,gBAAT,QAAiC,YAAjC;AACA,SAASC,qBAAT,QAAsC,kBAAtC;AACA,SAASC,4BAAT,QAA6C,eAA7C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseRef,\n\tuseCallback,\n\tforwardRef,\n\tcreateContext,\n} from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { children as childrenSource } from '@wordpress/blocks';\nimport { useInstanceId, useMergeRefs } from '@wordpress/compose';\nimport {\n\t__unstableUseRichText as useRichText,\n\t__unstableCreateElement,\n\tremoveFormat,\n} from '@wordpress/rich-text';\nimport deprecated from '@wordpress/deprecated';\nimport { Popover } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { useBlockEditorAutocompleteProps } from '../autocomplete';\nimport { useBlockEditContext } from '../block-edit';\nimport FormatToolbarContainer from './format-toolbar-container';\nimport { store as blockEditorStore } from '../../store';\nimport { useUndoAutomaticChange } from './use-undo-automatic-change';\nimport { useMarkPersistent } from './use-mark-persistent';\nimport { usePasteHandler } from './use-paste-handler';\nimport { useBeforeInputRules } from './use-before-input-rules';\nimport { useInputRules } from './use-input-rules';\nimport { useDelete } from './use-delete';\nimport { useEnter } from './use-enter';\nimport { useFormatTypes } from './use-format-types';\nimport { useRemoveBrowserShortcuts } from './use-remove-browser-shortcuts';\nimport { useShortcuts } from './use-shortcuts';\nimport { useInputEvents } from './use-input-events';\nimport { useInsertReplacementText } from './use-insert-replacement-text';\nimport { useFirefoxCompat } from './use-firefox-compat';\nimport FormatEdit from './format-edit';\nimport { getMultilineTag, getAllowedFormats } from './utils';\nimport { Content } from './content';\n\nexport const keyboardShortcutContext = createContext();\nexport const inputEventContext = createContext();\n\n/**\n * Removes props used for the native version of RichText so that they are not\n * passed to the DOM element and log warnings.\n *\n * @param {Object} props Props to filter.\n *\n * @return {Object} Filtered props.\n */\nfunction removeNativeProps( props ) {\n\tconst {\n\t\t__unstableMobileNoFocusOnMount,\n\t\tdeleteEnter,\n\t\tplaceholderTextColor,\n\t\ttextAlign,\n\t\tselectionColor,\n\t\ttagsToEliminate,\n\t\tdisableEditingMenu,\n\t\tfontSize,\n\t\tfontFamily,\n\t\tfontWeight,\n\t\tfontStyle,\n\t\tminWidth,\n\t\tmaxWidth,\n\t\tsetRef,\n\t\tdisableSuggestions,\n\t\tdisableAutocorrection,\n\t\t...restProps\n\t} = props;\n\treturn restProps;\n}\n\nfunction RichTextWrapper(\n\t{\n\t\tchildren,\n\t\ttagName = 'div',\n\t\tvalue: originalValue = '',\n\t\tonChange: originalOnChange,\n\t\tisSelected: originalIsSelected,\n\t\tmultiline,\n\t\tinlineToolbar,\n\t\twrapperClassName,\n\t\tautocompleters,\n\t\tonReplace,\n\t\tplaceholder,\n\t\tallowedFormats,\n\t\twithoutInteractiveFormatting,\n\t\tonRemove,\n\t\tonMerge,\n\t\tonSplit,\n\t\t__unstableOnSplitAtEnd: onSplitAtEnd,\n\t\t__unstableOnSplitMiddle: onSplitMiddle,\n\t\tidentifier,\n\t\tpreserveWhiteSpace,\n\t\t__unstablePastePlainText: pastePlainText,\n\t\t__unstableEmbedURLOnPaste,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tdisableLineBreaks,\n\t\t__unstableAllowPrefixTransformations,\n\t\t...props\n\t},\n\tforwardedRef\n) {\n\tif ( multiline ) {\n\t\tdeprecated( 'wp.blockEditor.RichText multiline prop', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'nested blocks (InnerBlocks)',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/nested-blocks-inner-blocks/',\n\t\t} );\n\t}\n\n\tconst instanceId = useInstanceId( RichTextWrapper );\n\n\tidentifier = identifier || instanceId;\n\tprops = removeNativeProps( props );\n\n\tconst anchorRef = useRef();\n\tconst { clientId } = useBlockEditContext();\n\tconst selector = ( select ) => {\n\t\tconst { getSelectionStart, getSelectionEnd } =\n\t\t\tselect( blockEditorStore );\n\t\tconst selectionStart = getSelectionStart();\n\t\tconst selectionEnd = getSelectionEnd();\n\n\t\tlet isSelected;\n\n\t\tif ( originalIsSelected === undefined ) {\n\t\t\tisSelected =\n\t\t\t\tselectionStart.clientId === clientId &&\n\t\t\t\tselectionEnd.clientId === clientId &&\n\t\t\t\tselectionStart.attributeKey === identifier;\n\t\t} else if ( originalIsSelected ) {\n\t\t\tisSelected = selectionStart.clientId === clientId;\n\t\t}\n\n\t\treturn {\n\t\t\tselectionStart: isSelected ? selectionStart.offset : undefined,\n\t\t\tselectionEnd: isSelected ? selectionEnd.offset : undefined,\n\t\t\tisSelected,\n\t\t};\n\t};\n\t// This selector must run on every render so the right selection state is\n\t// retreived from the store on merge.\n\t// To do: fix this somehow.\n\tconst { selectionStart, selectionEnd, isSelected } = useSelect( selector );\n\tconst { getSelectionStart, getSelectionEnd, getBlockRootClientId } =\n\t\tuseSelect( blockEditorStore );\n\tconst { selectionChange } = useDispatch( blockEditorStore );\n\tconst multilineTag = getMultilineTag( multiline );\n\tconst adjustedAllowedFormats = getAllowedFormats( {\n\t\tallowedFormats,\n\t\tdisableFormats,\n\t} );\n\tconst hasFormats =\n\t\t! adjustedAllowedFormats || adjustedAllowedFormats.length > 0;\n\tlet adjustedValue = originalValue;\n\tlet adjustedOnChange = originalOnChange;\n\n\t// Handle deprecated format.\n\tif ( Array.isArray( originalValue ) ) {\n\t\tdeprecated( 'wp.blockEditor.RichText value prop as children type', {\n\t\t\tsince: '6.1',\n\t\t\tversion: '6.3',\n\t\t\talternative: 'value prop as string',\n\t\t\tlink: 'https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/introducing-attributes-and-editable-fields/',\n\t\t} );\n\n\t\tadjustedValue = childrenSource.toHTML( originalValue );\n\t\tadjustedOnChange = ( newValue ) =>\n\t\t\toriginalOnChange(\n\t\t\t\tchildrenSource.fromDOM(\n\t\t\t\t\t__unstableCreateElement( document, newValue ).childNodes\n\t\t\t\t)\n\t\t\t);\n\t}\n\n\tconst onSelectionChange = useCallback(\n\t\t( start, end ) => {\n\t\t\tconst selection = {};\n\t\t\tconst unset = start === undefined && end === undefined;\n\n\t\t\tif ( typeof start === 'number' || unset ) {\n\t\t\t\t// If we are only setting the start (or the end below), which\n\t\t\t\t// means a partial selection, and we're not updating a selection\n\t\t\t\t// with the same client ID, abort. This means the selected block\n\t\t\t\t// is a parent block.\n\t\t\t\tif (\n\t\t\t\t\tend === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionEnd().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.start = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: start,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tif ( typeof end === 'number' || unset ) {\n\t\t\t\tif (\n\t\t\t\t\tstart === undefined &&\n\t\t\t\t\tgetBlockRootClientId( clientId ) !==\n\t\t\t\t\t\tgetBlockRootClientId( getSelectionStart().clientId )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselection.end = {\n\t\t\t\t\tclientId,\n\t\t\t\t\tattributeKey: identifier,\n\t\t\t\t\toffset: end,\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tselectionChange( selection );\n\t\t},\n\t\t[ clientId, identifier ]\n\t);\n\n\tconst {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t} = useFormatTypes( {\n\t\tclientId,\n\t\tidentifier,\n\t\twithoutInteractiveFormatting,\n\t\tallowedFormats: adjustedAllowedFormats,\n\t} );\n\n\tfunction addEditorOnlyFormats( value ) {\n\t\treturn valueHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tfunction removeEditorOnlyFormats( value ) {\n\t\tformatTypes.forEach( ( formatType ) => {\n\t\t\t// Remove formats created by prepareEditableTree, because they are editor only.\n\t\t\tif ( formatType.__experimentalCreatePrepareEditableTree ) {\n\t\t\t\tvalue = removeFormat(\n\t\t\t\t\tvalue,\n\t\t\t\t\tformatType.name,\n\t\t\t\t\t0,\n\t\t\t\t\tvalue.text.length\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn value.formats;\n\t}\n\n\tfunction addInvisibleFormats( value ) {\n\t\treturn prepareHandlers.reduce(\n\t\t\t( accumulator, fn ) => fn( accumulator, value.text ),\n\t\t\tvalue.formats\n\t\t);\n\t}\n\n\tconst {\n\t\tvalue,\n\t\tgetValue,\n\t\tonChange,\n\t\tref: richTextRef,\n\t} = useRichText( {\n\t\tvalue: adjustedValue,\n\t\tonChange( html, { __unstableFormats, __unstableText } ) {\n\t\t\tadjustedOnChange( html );\n\t\t\tObject.values( changeHandlers ).forEach( ( changeHandler ) => {\n\t\t\t\tchangeHandler( __unstableFormats, __unstableText );\n\t\t\t} );\n\t\t},\n\t\tselectionStart,\n\t\tselectionEnd,\n\t\tonSelectionChange,\n\t\tplaceholder,\n\t\t__unstableIsSelected: isSelected,\n\t\t__unstableMultilineTag: multilineTag,\n\t\t__unstableDisableFormats: disableFormats,\n\t\tpreserveWhiteSpace,\n\t\t__unstableDependencies: [ ...dependencies, tagName ],\n\t\t__unstableAfterParse: addEditorOnlyFormats,\n\t\t__unstableBeforeSerialize: removeEditorOnlyFormats,\n\t\t__unstableAddInvisibleFormats: addInvisibleFormats,\n\t} );\n\tconst autocompleteProps = useBlockEditorAutocompleteProps( {\n\t\tonReplace,\n\t\tcompleters: autocompleters,\n\t\trecord: value,\n\t\tonChange,\n\t} );\n\n\tuseMarkPersistent( { html: adjustedValue, value } );\n\n\tconst keyboardShortcuts = useRef( new Set() );\n\tconst inputEvents = useRef( new Set() );\n\n\tfunction onFocus() {\n\t\tanchorRef.current?.focus();\n\t}\n\n\tconst TagName = tagName;\n\treturn (\n\t\t<>\n\t\t\t{ isSelected && (\n\t\t\t\t<keyboardShortcutContext.Provider value={ keyboardShortcuts }>\n\t\t\t\t\t<inputEventContext.Provider value={ inputEvents }>\n\t\t\t\t\t\t<Popover.__unstableSlotNameProvider value=\"__unstable-block-tools-after\">\n\t\t\t\t\t\t\t{ children &&\n\t\t\t\t\t\t\t\tchildren( { value, onChange, onFocus } ) }\n\n\t\t\t\t\t\t\t<FormatEdit\n\t\t\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\tformatTypes={ formatTypes }\n\t\t\t\t\t\t\t\tforwardedRef={ anchorRef }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover.__unstableSlotNameProvider>\n\t\t\t\t\t</inputEventContext.Provider>\n\t\t\t\t</keyboardShortcutContext.Provider>\n\t\t\t) }\n\t\t\t{ isSelected && hasFormats && (\n\t\t\t\t<FormatToolbarContainer\n\t\t\t\t\tinline={ inlineToolbar }\n\t\t\t\t\teditableContentElement={ anchorRef.current }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<TagName\n\t\t\t\t// Overridable props.\n\t\t\t\trole=\"textbox\"\n\t\t\t\taria-multiline={ ! disableLineBreaks }\n\t\t\t\taria-label={ placeholder }\n\t\t\t\t{ ...props }\n\t\t\t\t{ ...autocompleteProps }\n\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\tforwardedRef,\n\t\t\t\t\tautocompleteProps.ref,\n\t\t\t\t\tprops.ref,\n\t\t\t\t\trichTextRef,\n\t\t\t\t\tuseBeforeInputRules( { value, onChange } ),\n\t\t\t\t\tuseInputRules( {\n\t\t\t\t\t\tgetValue,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\t__unstableAllowPrefixTransformations,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tselectionChange,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseInsertReplacementText(),\n\t\t\t\t\tuseRemoveBrowserShortcuts(),\n\t\t\t\t\tuseShortcuts( keyboardShortcuts ),\n\t\t\t\t\tuseInputEvents( inputEvents ),\n\t\t\t\t\tuseUndoAutomaticChange(),\n\t\t\t\t\tusePasteHandler( {\n\t\t\t\t\t\tisSelected,\n\t\t\t\t\t\tdisableFormats,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tformatTypes,\n\t\t\t\t\t\ttagName,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\t__unstableEmbedURLOnPaste,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tpreserveWhiteSpace,\n\t\t\t\t\t\tpastePlainText,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseDelete( {\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonMerge,\n\t\t\t\t\t\tonRemove,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseEnter( {\n\t\t\t\t\t\tremoveEditorOnlyFormats,\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t\tonReplace,\n\t\t\t\t\t\tonSplit,\n\t\t\t\t\t\tonSplitMiddle,\n\t\t\t\t\t\tmultilineTag,\n\t\t\t\t\t\tonChange,\n\t\t\t\t\t\tdisableLineBreaks,\n\t\t\t\t\t\tonSplitAtEnd,\n\t\t\t\t\t} ),\n\t\t\t\t\tuseFirefoxCompat( { value, onChange } ),\n\t\t\t\t\tanchorRef,\n\t\t\t\t] ) }\n\t\t\t\tcontentEditable={ true }\n\t\t\t\tsuppressContentEditableWarning={ true }\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-rich-text__editable',\n\t\t\t\t\tprops.className,\n\t\t\t\t\t'rich-text'\n\t\t\t\t) }\n\t\t\t\t// Setting tabIndex to 0 is unnecessary, the element is already\n\t\t\t\t// focusable because it's contentEditable. This also fixes a\n\t\t\t\t// Safari bug where it's not possible to Shift+Click multi\n\t\t\t\t// select blocks when Shift Clicking into an element with\n\t\t\t\t// tabIndex because Safari will focus the element. However,\n\t\t\t\t// Safari will correctly ignore nested contentEditable elements.\n\t\t\t\ttabIndex={ props.tabIndex === 0 ? null : props.tabIndex }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nconst ForwardedRichTextContainer = forwardRef( RichTextWrapper );\n\nForwardedRichTextContainer.Content = Content;\nForwardedRichTextContainer.isEmpty = ( value ) => {\n\treturn ! value || value.length === 0;\n};\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/rich-text/README.md\n */\nexport default ForwardedRichTextContainer;\nexport { RichTextShortcut } from './shortcut';\nexport { RichTextToolbarButton } from './toolbar-button';\nexport { __unstableRichTextInputEvent } from './input-event';\n"]}
@@ -53,19 +53,20 @@ export function useFormatTypes({
53
53
  const formatTypes = useMemo(() => {
54
54
  return allFormatTypes.filter(({
55
55
  name,
56
+ interactive,
56
57
  tagName
57
58
  }) => {
58
59
  if (allowedFormats && !allowedFormats.includes(name)) {
59
60
  return false;
60
61
  }
61
62
 
62
- if (withoutInteractiveFormatting && interactiveContentTags.has(tagName)) {
63
+ if (withoutInteractiveFormatting && (interactive || interactiveContentTags.has(tagName))) {
63
64
  return false;
64
65
  }
65
66
 
66
67
  return true;
67
68
  });
68
- }, [allFormatTypes, allowedFormats, interactiveContentTags]);
69
+ }, [allFormatTypes, allowedFormats, withoutInteractiveFormatting]);
69
70
  const keyedSelected = useSelect(select => formatTypes.reduce((accumulator, type) => {
70
71
  if (!type.__experimentalGetPropsForEditableTreePreparation) {
71
72
  return accumulator;
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;;AAEA,SAASC,mBAAT,CAA8BC,MAA9B,EAAuC;AACtC,SAAOA,MAAM,CAAEF,aAAF,CAAN,CAAwBG,cAAxB,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAJ,CAAS,CACvC,GADuC,EAEvC,OAFuC,EAGvC,QAHuC,EAIvC,SAJuC,EAKvC,OALuC,EAMvC,QANuC,EAOvC,OAPuC,EAQvC,OARuC,EASvC,QATuC,EAUvC,UAVuC,EAWvC,OAXuC,CAAT,CAA/B;;AAcA,SAASC,gBAAT,CAA2BC,QAA3B,EAAqCC,MAArC,EAA8C;AAC7C,MAAK,OAAOD,QAAP,KAAoB,QAAzB,EAAoC,OAAO;AAAE,KAAEC,MAAF,GAAYD;AAAd,GAAP;AACpC,SAAOE,MAAM,CAACC,WAAP,CACND,MAAM,CAACE,OAAP,CAAgBJ,QAAhB,EAA2BK,GAA3B,CAAgC,CAAE,CAAEC,GAAF,EA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EAAsD;AACrDP,QAAAA,aAAa,CAACG,IAAd,CAAoBG,OAApB;AACA,OAFD,MAEO;AACNP,QAAAA,eAAe,CAACI,IAAhB,CAAsBG,OAAtB;AACA;AACD;;AAED,QAAKZ,IAAI,CAACa,yCAAV,EAAsD;AACrD,UAAIC,WAAW,GAAG,EAAlB;;AAEA,UAAKd,IAAI,CAACe,kDAAV,EAA+D;AAC9DD,QAAAA,WAAW,GACVd,IAAI,CAACe,kDAAL,CACCX,QADD,EAEC;AACCF,UAAAA,kBAAkB,EAAEZ,UADrB;AAECa,UAAAA,aAAa,EAAEd;AAFhB,SAFD,CADD;AAQA;;AAED,YAAMjB,QAAQ,GAAGQ,qBAAqB,CAAEmB,aAAF,EAAiBC,IAAI,CAACL,IAAtB,CAAtC;AACAY,MAAAA,cAAc,CAACE,IAAf,CACCT,IAAI,CAACa,yCAAL,CACC,EACC,IAAK,OAAOzC,QAAP,KAAoB,QAApB,GAA+BA,QAA/B,GAA0C,EAA/C,CADD;AAEC,WAAG0C;AAFJ,OADD,EAKC;AACCZ,QAAAA,kBAAkB,EAAEZ,UADrB;AAECa,QAAAA,aAAa,EAAEd;AAFhB,OALD,CADD;AAYA;AACD,GA7CD;AA+CA,SAAO;AACNK,IAAAA,WADM;AAENW,IAAAA,eAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,cAJM;AAKNC,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) return { [ prefix ]: selected };\n\treturn Object.fromEntries(\n\t\tObject.entries( selected ).map( ( [ key, value ] ) => [\n\t\t\t`${ prefix }.${ key }`,\n\t\t\tvalue,\n\t\t] )\n\t);\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) return selected[ prefix ];\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\tinteractiveContentTags.has( tagName )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, interactiveContentTags ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/rich-text/use-format-types.js"],"names":["useMemo","useSelect","useDispatch","store","richTextStore","formatTypesSelector","select","getFormatTypes","interactiveContentTags","Set","prefixSelectKeys","selected","prefix","Object","fromEntries","entries","map","key","value","getPrefixedSelectKeys","keys","filter","startsWith","reduce","accumulator","slice","length","useFormatTypes","clientId","identifier","withoutInteractiveFormatting","allowedFormats","allFormatTypes","formatTypes","name","interactive","tagName","includes","has","keyedSelected","type","__experimentalGetPropsForEditableTreePreparation","richTextIdentifier","blockClientId","dispatch","prepareHandlers","valueHandlers","changeHandlers","dependencies","push","forEach","__experimentalCreatePrepareEditableTree","handler","__experimentalCreateOnChangeEditableValue","dispatchers","__experimentalGetPropsForEditableTreeChangeHandler"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,oBAAxB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;;AAEA,SAASC,mBAAT,CAA8BC,MAA9B,EAAuC;AACtC,SAAOA,MAAM,CAAEF,aAAF,CAAN,CAAwBG,cAAxB,EAAP;AACA;AAED;AACA;AACA;AACA;AACA;;;AACA,MAAMC,sBAAsB,GAAG,IAAIC,GAAJ,CAAS,CACvC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AAA,WADM;AAENY,IAAAA,eAFM;AAGNC,IAAAA,aAHM;AAINC,IAAAA,cAJM;AAKNC,IAAAA;AALM,GAAP;AAOA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useMemo } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as richTextStore } from '@wordpress/rich-text';\n\nfunction formatTypesSelector( select ) {\n\treturn select( richTextStore ).getFormatTypes();\n}\n\n/**\n * Set of all interactive content tags.\n *\n * @see https://html.spec.whatwg.org/multipage/dom.html#interactive-content\n */\nconst interactiveContentTags = new Set( [\n\t'a',\n\t'audio',\n\t'button',\n\t'details',\n\t'embed',\n\t'iframe',\n\t'input',\n\t'label',\n\t'select',\n\t'textarea',\n\t'video',\n] );\n\nfunction prefixSelectKeys( selected, prefix ) {\n\tif ( typeof selected !== 'object' ) return { [ prefix ]: selected };\n\treturn Object.fromEntries(\n\t\tObject.entries( selected ).map( ( [ key, value ] ) => [\n\t\t\t`${ prefix }.${ key }`,\n\t\t\tvalue,\n\t\t] )\n\t);\n}\n\nfunction getPrefixedSelectKeys( selected, prefix ) {\n\tif ( selected[ prefix ] ) return selected[ prefix ];\n\treturn Object.keys( selected )\n\t\t.filter( ( key ) => key.startsWith( prefix + '.' ) )\n\t\t.reduce( ( accumulator, key ) => {\n\t\t\taccumulator[ key.slice( prefix.length + 1 ) ] = selected[ key ];\n\t\t\treturn accumulator;\n\t\t}, {} );\n}\n\n/**\n * This hook provides RichText with the `formatTypes` and its derived props from\n * experimental format type settings.\n *\n * @param {Object} $0 Options\n * @param {string} $0.clientId Block client ID.\n * @param {string} $0.identifier Block attribute.\n * @param {boolean} $0.withoutInteractiveFormatting Whether to clean the interactive formattings or not.\n * @param {Array} $0.allowedFormats Allowed formats\n */\nexport function useFormatTypes( {\n\tclientId,\n\tidentifier,\n\twithoutInteractiveFormatting,\n\tallowedFormats,\n} ) {\n\tconst allFormatTypes = useSelect( formatTypesSelector, [] );\n\tconst formatTypes = useMemo( () => {\n\t\treturn allFormatTypes.filter( ( { name, interactive, tagName } ) => {\n\t\t\tif ( allowedFormats && ! allowedFormats.includes( name ) ) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\twithoutInteractiveFormatting &&\n\t\t\t\t( interactive || interactiveContentTags.has( tagName ) )\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\treturn true;\n\t\t} );\n\t}, [ allFormatTypes, allowedFormats, withoutInteractiveFormatting ] );\n\tconst keyedSelected = useSelect(\n\t\t( select ) =>\n\t\t\tformatTypes.reduce( ( accumulator, type ) => {\n\t\t\t\tif ( ! type.__experimentalGetPropsForEditableTreePreparation ) {\n\t\t\t\t\treturn accumulator;\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t...accumulator,\n\t\t\t\t\t...prefixSelectKeys(\n\t\t\t\t\t\ttype.__experimentalGetPropsForEditableTreePreparation(\n\t\t\t\t\t\t\tselect,\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t),\n\t\t\t\t\t\ttype.name\n\t\t\t\t\t),\n\t\t\t\t};\n\t\t\t}, {} ),\n\t\t[ formatTypes, clientId, identifier ]\n\t);\n\tconst dispatch = useDispatch();\n\tconst prepareHandlers = [];\n\tconst valueHandlers = [];\n\tconst changeHandlers = [];\n\tconst dependencies = [];\n\n\tfor ( const key in keyedSelected ) {\n\t\tdependencies.push( keyedSelected[ key ] );\n\t}\n\n\tformatTypes.forEach( ( type ) => {\n\t\tif ( type.__experimentalCreatePrepareEditableTree ) {\n\t\t\tconst handler = type.__experimentalCreatePrepareEditableTree(\n\t\t\t\tgetPrefixedSelectKeys( keyedSelected, type.name ),\n\t\t\t\t{\n\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\t\tvalueHandlers.push( handler );\n\t\t\t} else {\n\t\t\t\tprepareHandlers.push( handler );\n\t\t\t}\n\t\t}\n\n\t\tif ( type.__experimentalCreateOnChangeEditableValue ) {\n\t\t\tlet dispatchers = {};\n\n\t\t\tif ( type.__experimentalGetPropsForEditableTreeChangeHandler ) {\n\t\t\t\tdispatchers =\n\t\t\t\t\ttype.__experimentalGetPropsForEditableTreeChangeHandler(\n\t\t\t\t\t\tdispatch,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst selected = getPrefixedSelectKeys( keyedSelected, type.name );\n\t\t\tchangeHandlers.push(\n\t\t\t\ttype.__experimentalCreateOnChangeEditableValue(\n\t\t\t\t\t{\n\t\t\t\t\t\t...( typeof selected === 'object' ? selected : {} ),\n\t\t\t\t\t\t...dispatchers,\n\t\t\t\t\t},\n\t\t\t\t\t{\n\t\t\t\t\t\trichTextIdentifier: identifier,\n\t\t\t\t\t\tblockClientId: clientId,\n\t\t\t\t\t}\n\t\t\t\t)\n\t\t\t);\n\t\t}\n\t} );\n\n\treturn {\n\t\tformatTypes,\n\t\tprepareHandlers,\n\t\tvalueHandlers,\n\t\tchangeHandlers,\n\t\tdependencies,\n\t};\n}\n"]}
@@ -181,12 +181,12 @@
181
181
  box-shadow: none;
182
182
  }
183
183
  .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
184
- .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected, .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected,
184
+ .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
185
185
  .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
186
186
  outline: none;
187
187
  }
188
188
  .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
189
- .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after, .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected::after,
189
+ .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
190
190
  .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
191
191
  content: "";
192
192
  position: absolute;
@@ -201,14 +201,10 @@
201
201
  outline: 2px solid transparent;
202
202
  }
203
203
  .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
204
- .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after, .is-dark-theme .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected::after,
204
+ .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
205
205
  .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
206
206
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
207
207
  }
208
- .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
209
- box-shadow: none;
210
- outline: none;
211
- }
212
208
  .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
213
209
  content: "";
214
210
  position: absolute;
@@ -220,6 +216,8 @@
220
216
  top: -14px;
221
217
  border-radius: 2px;
222
218
  border-top: 4px solid #ccc;
219
+ bottom: auto;
220
+ box-shadow: none;
223
221
  }
224
222
  .block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
225
223
  border-color: var(--wp-admin-theme-color);
@@ -181,12 +181,12 @@
181
181
  box-shadow: none;
182
182
  }
183
183
  .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted,
184
- .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected, .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected,
184
+ .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected,
185
185
  .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus {
186
186
  outline: none;
187
187
  }
188
188
  .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
189
- .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after, .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected::after,
189
+ .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
190
190
  .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
191
191
  content: "";
192
192
  position: absolute;
@@ -201,14 +201,10 @@
201
201
  outline: 2px solid transparent;
202
202
  }
203
203
  .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted::after,
204
- .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after, .is-dark-theme .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.has-child-selected::after,
204
+ .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block.is-highlighted ~ .is-multi-selected::after, .is-dark-theme .block-editor-block-list__layout.is-navigate-mode .block-editor-block-list__block.is-selected::after,
205
205
  .is-dark-theme .block-editor-block-list__layout .block-editor-block-list__block:not([contenteditable]):focus::after {
206
206
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) #fff;
207
207
  }
208
- .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected {
209
- box-shadow: none;
210
- outline: none;
211
- }
212
208
  .block-editor-block-list__layout .is-block-moving-mode.block-editor-block-list__block.is-selected::after {
213
209
  content: "";
214
210
  position: absolute;
@@ -220,6 +216,8 @@
220
216
  top: -14px;
221
217
  border-radius: 2px;
222
218
  border-top: 4px solid #ccc;
219
+ bottom: auto;
220
+ box-shadow: none;
223
221
  }
224
222
  .block-editor-block-list__layout .is-block-moving-mode.can-insert-moving-block.block-editor-block-list__block.is-selected::after {
225
223
  border-color: var(--wp-admin-theme-color);