@wordpress/block-editor 8.5.0 → 8.5.3

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 (123) hide show
  1. package/build/components/block-alignment-control/ui.js +1 -1
  2. package/build/components/block-alignment-control/ui.js.map +1 -1
  3. package/build/components/block-content-overlay/index.js +13 -4
  4. package/build/components/block-content-overlay/index.js.map +1 -1
  5. package/build/components/block-lock/index.js +8 -0
  6. package/build/components/block-lock/index.js.map +1 -1
  7. package/build/components/block-lock/menu-item.js +5 -20
  8. package/build/components/block-lock/menu-item.js.map +1 -1
  9. package/build/components/block-lock/modal.js +33 -12
  10. package/build/components/block-lock/modal.js.map +1 -1
  11. package/build/components/block-lock/toolbar.js +7 -20
  12. package/build/components/block-lock/toolbar.js.map +1 -1
  13. package/build/components/block-lock/use-block-lock.js +50 -0
  14. package/build/components/block-lock/use-block-lock.js.map +1 -0
  15. package/build/components/block-pattern-setup/index.js +37 -22
  16. package/build/components/block-pattern-setup/index.js.map +1 -1
  17. package/build/components/block-pattern-setup/setup-toolbar.js +1 -1
  18. package/build/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  19. package/build/components/block-preview/auto.js +6 -3
  20. package/build/components/block-preview/auto.js.map +1 -1
  21. package/build/components/block-preview/index.js +4 -2
  22. package/build/components/block-preview/index.js.map +1 -1
  23. package/build/components/block-switcher/index.js +7 -2
  24. package/build/components/block-switcher/index.js.map +1 -1
  25. package/build/components/copy-handler/index.js +44 -9
  26. package/build/components/copy-handler/index.js.map +1 -1
  27. package/build/components/link-control/index.js +6 -7
  28. package/build/components/link-control/index.js.map +1 -1
  29. package/build/components/list-view/block-select-button.js +4 -10
  30. package/build/components/list-view/block-select-button.js.map +1 -1
  31. package/build/components/list-view/block.js +13 -2
  32. package/build/components/list-view/block.js.map +1 -1
  33. package/build/components/writing-flow/use-selection-observer.js +7 -1
  34. package/build/components/writing-flow/use-selection-observer.js.map +1 -1
  35. package/build/hooks/duotone.js +66 -16
  36. package/build/hooks/duotone.js.map +1 -1
  37. package/build/hooks/index.js +7 -1
  38. package/build/hooks/index.js.map +1 -1
  39. package/build/index.js +7 -0
  40. package/build/index.js.map +1 -1
  41. package/build/store/actions.js +22 -29
  42. package/build/store/actions.js.map +1 -1
  43. package/build/store/selectors.js +122 -3
  44. package/build/store/selectors.js.map +1 -1
  45. package/build/store/utils.js +27 -0
  46. package/build/store/utils.js.map +1 -0
  47. package/build-module/components/block-alignment-control/ui.js +2 -2
  48. package/build-module/components/block-alignment-control/ui.js.map +1 -1
  49. package/build-module/components/block-content-overlay/index.js +13 -4
  50. package/build-module/components/block-content-overlay/index.js.map +1 -1
  51. package/build-module/components/block-lock/index.js +1 -0
  52. package/build-module/components/block-lock/index.js.map +1 -1
  53. package/build-module/components/block-lock/menu-item.js +4 -18
  54. package/build-module/components/block-lock/menu-item.js.map +1 -1
  55. package/build-module/components/block-lock/modal.js +31 -12
  56. package/build-module/components/block-lock/modal.js.map +1 -1
  57. package/build-module/components/block-lock/toolbar.js +6 -18
  58. package/build-module/components/block-lock/toolbar.js.map +1 -1
  59. package/build-module/components/block-lock/use-block-lock.js +41 -0
  60. package/build-module/components/block-lock/use-block-lock.js.map +1 -0
  61. package/build-module/components/block-pattern-setup/index.js +39 -24
  62. package/build-module/components/block-pattern-setup/index.js.map +1 -1
  63. package/build-module/components/block-pattern-setup/setup-toolbar.js +1 -1
  64. package/build-module/components/block-pattern-setup/setup-toolbar.js.map +1 -1
  65. package/build-module/components/block-preview/auto.js +6 -3
  66. package/build-module/components/block-preview/auto.js.map +1 -1
  67. package/build-module/components/block-preview/index.js +4 -2
  68. package/build-module/components/block-preview/index.js.map +1 -1
  69. package/build-module/components/block-switcher/index.js +7 -2
  70. package/build-module/components/block-switcher/index.js.map +1 -1
  71. package/build-module/components/copy-handler/index.js +44 -9
  72. package/build-module/components/copy-handler/index.js.map +1 -1
  73. package/build-module/components/link-control/index.js +6 -7
  74. package/build-module/components/link-control/index.js.map +1 -1
  75. package/build-module/components/list-view/block-select-button.js +4 -9
  76. package/build-module/components/list-view/block-select-button.js.map +1 -1
  77. package/build-module/components/list-view/block.js +13 -2
  78. package/build-module/components/list-view/block.js.map +1 -1
  79. package/build-module/components/writing-flow/use-selection-observer.js +7 -1
  80. package/build-module/components/writing-flow/use-selection-observer.js.map +1 -1
  81. package/build-module/hooks/duotone.js +63 -16
  82. package/build-module/hooks/duotone.js.map +1 -1
  83. package/build-module/hooks/index.js +1 -0
  84. package/build-module/hooks/index.js.map +1 -1
  85. package/build-module/index.js +1 -1
  86. package/build-module/index.js.map +1 -1
  87. package/build-module/store/actions.js +5 -14
  88. package/build-module/store/actions.js.map +1 -1
  89. package/build-module/store/selectors.js +112 -2
  90. package/build-module/store/selectors.js.map +1 -1
  91. package/build-module/store/utils.js +20 -0
  92. package/build-module/store/utils.js.map +1 -0
  93. package/build-style/style-rtl.css +35 -28
  94. package/build-style/style.css +35 -28
  95. package/package.json +28 -28
  96. package/src/components/block-alignment-control/ui.js +2 -2
  97. package/src/components/block-content-overlay/index.js +19 -2
  98. package/src/components/block-content-overlay/style.scss +0 -1
  99. package/src/components/block-lock/index.js +1 -0
  100. package/src/components/block-lock/menu-item.js +3 -23
  101. package/src/components/block-lock/modal.js +37 -13
  102. package/src/components/block-lock/style.scss +1 -2
  103. package/src/components/block-lock/toolbar.js +4 -21
  104. package/src/components/block-lock/use-block-lock.js +45 -0
  105. package/src/components/block-pattern-setup/index.js +84 -59
  106. package/src/components/block-pattern-setup/setup-toolbar.js +3 -1
  107. package/src/components/block-pattern-setup/style.scss +32 -26
  108. package/src/components/block-preview/auto.js +10 -1
  109. package/src/components/block-preview/index.js +2 -0
  110. package/src/components/block-switcher/index.js +13 -1
  111. package/src/components/block-switcher/style.scss +7 -3
  112. package/src/components/block-switcher/test/__snapshots__/index.js.snap +15 -13
  113. package/src/components/copy-handler/index.js +52 -10
  114. package/src/components/link-control/index.js +5 -5
  115. package/src/components/list-view/block-select-button.js +2 -10
  116. package/src/components/list-view/block.js +16 -7
  117. package/src/components/writing-flow/use-selection-observer.js +7 -0
  118. package/src/hooks/duotone.js +98 -62
  119. package/src/hooks/index.js +1 -0
  120. package/src/index.js +1 -0
  121. package/src/store/actions.js +5 -13
  122. package/src/store/selectors.js +148 -2
  123. package/src/store/utils.js +19 -0
@@ -145,6 +145,11 @@ function LinkControl(_ref) {
145
145
  const [isEditingLink, setIsEditingLink] = useState(forceIsEditingLink !== undefined ? forceIsEditingLink : !value || !value.url);
146
146
  const isEndingEditWithFocus = useRef(false);
147
147
  const currentInputIsEmpty = !(currentInputValue !== null && currentInputValue !== void 0 && (_currentInputValue$tr = currentInputValue.trim()) !== null && _currentInputValue$tr !== void 0 && _currentInputValue$tr.length);
148
+ const {
149
+ createPage,
150
+ isCreatingPage,
151
+ errorMessage
152
+ } = useCreatePage(createSuggestion);
148
153
  useEffect(() => {
149
154
  if (forceIsEditingLink !== undefined && forceIsEditingLink !== isEditingLink) {
150
155
  setIsEditingLink(forceIsEditingLink);
@@ -173,7 +178,7 @@ function LinkControl(_ref) {
173
178
  const nextFocusTarget = focus.focusable.find(wrapperNode.current)[whichFocusTargetIndex] || wrapperNode.current;
174
179
  nextFocusTarget.focus();
175
180
  isEndingEditWithFocus.current = false;
176
- }, [isEditingLink]);
181
+ }, [isEditingLink, isCreatingPage]);
177
182
  useEffect(() => {
178
183
  /**
179
184
  * If the value's `text` property changes then sync this
@@ -204,12 +209,6 @@ function LinkControl(_ref) {
204
209
  setIsEditingLink(false);
205
210
  }
206
211
 
207
- const {
208
- createPage,
209
- isCreatingPage,
210
- errorMessage
211
- } = useCreatePage(createSuggestion);
212
-
213
212
  const handleSelectSuggestion = updatedValue => {
214
213
  onChange({ ...updatedValue,
215
214
  title: internalTextValue || (updatedValue === null || updatedValue === void 0 ? void 0 : updatedValue.title)
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/index.js"],"names":["noop","classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","createPage","isCreatingPage","errorMessage","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;AACA,SAASC,UAAT,QAA2B,eAA3B;AACA,SAASC,qBAAT,QAAsC,aAAtC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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X;AAEC,IAAA,MAAM,EAAC,OAFR;AAGC,IAAA,aAAa,EAAG;AAHjB,KAKGA,YALH,CAjDF,CAZF,EAwEG9C,KAAK,IAAI,CAAE6B,aAAX,IAA4B,CAAEgB,cAA9B,IACD,cAAC,WAAD;AACC,IAAA,GAAG,EAAG7C,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEwB,GADd,CACoB;AADpB;AAEC,IAAA,KAAK,EAAGxB,KAFT;AAGC,IAAA,WAAW,EAAG,MAAM8B,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGf,eAJnB;AAKC,IAAA,gBAAgB,EAAGuC,kBALpB;AAMC,IAAA,QAAQ,EAAGnD;AANZ,IAzEF,EAmFGoD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACF,UAAZ,GAAyBA,UAAzB;AAEA,eAAeE,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\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 {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\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\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\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\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}, [ 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\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\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 )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\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\tfunction 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 { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\n\t);\n\n\tconst handleSelectSuggestion = ( updatedValue ) => {\n\t\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\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 shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\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 = value?.url?.trim()?.length > 0 && hasTextControl;\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{ ( isEditingLink || ! value ) && ! isCreatingPage && (\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\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={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\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={ currentInputValue }\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={ setInternalInputValue }\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\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\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{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\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":["noop","classnames","Button","Spinner","Notice","TextControl","keyboardReturn","__","useRef","useState","useEffect","focus","ENTER","LinkControlSettingsDrawer","LinkControlSearchInput","LinkPreview","useCreatePage","ViewerFill","DEFAULT_LINK_SETTINGS","LinkControl","searchInputPlaceholder","value","settings","onChange","onRemove","noDirectEntry","showSuggestions","showInitialSuggestions","forceIsEditingLink","createSuggestion","withCreateSuggestion","inputValue","propInputValue","suggestionsQuery","noURLSuggestion","createSuggestionButtonText","hasRichPreviews","hasTextControl","renderControlBottom","undefined","isMounting","wrapperNode","textInputRef","internalInputValue","setInternalInputValue","url","internalTextValue","setInternalTextValue","title","currentInputValue","isEditingLink","setIsEditingLink","isEndingEditWithFocus","currentInputIsEmpty","trim","length","createPage","isCreatingPage","errorMessage","current","whichFocusTargetIndex","nextFocusTarget","focusable","find","stopEditing","contains","ownerDocument","activeElement","handleSelectSuggestion","updatedValue","handleSubmit","handleSubmitWithEnter","event","keyCode","preventDefault","shownUnlinkControl","showSettingsDrawer","showTextControl"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,QAArB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,EAAiBC,OAAjB,EAA0BC,MAA1B,EAAkCC,WAAlC,QAAqD,uBAArD;AACA,SAASC,cAAT,QAA+B,kBAA/B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,EAAiBC,QAAjB,EAA2BC,SAA3B,QAA4C,oBAA5C;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,KAAT,QAAsB,qBAAtB;AAEA;AACA;AACA;;AACA,OAAOC,yBAAP,MAAsC,mBAAtC;AACA,OAAOC,sBAAP,MAAmC,gBAAnC;AACA,OAAOC,WAAP,MAAwB,gBAAxB;AACA,OAAOC,aAAP,MAA0B,mBAA1B;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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F,CAZF,EAwEGrC,KAAK,IAAI,CAAE6B,aAAX,IAA4B,CAAEO,cAA9B,IACD,cAAC,WAAD;AACC,IAAA,GAAG,EAAGpC,KAAH,aAAGA,KAAH,uBAAGA,KAAK,CAAEwB,GADd,CACoB;AADpB;AAEC,IAAA,KAAK,EAAGxB,KAFT;AAGC,IAAA,WAAW,EAAG,MAAM8B,gBAAgB,CAAE,IAAF,CAHrC;AAIC,IAAA,eAAe,EAAGf,eAJnB;AAKC,IAAA,gBAAgB,EAAGuC,kBALpB;AAMC,IAAA,QAAQ,EAAGnD;AANZ,IAzEF,EAmFGoD,kBAAkB,IACnB;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,cAAC,yBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,CApFF,EA4FGe,mBAAmB,IAAIA,mBAAmB,EA5F7C,CADD;AAgGA;;AAEDnB,WAAW,CAACF,UAAZ,GAAyBA,UAAzB;AAEA,eAAeE,WAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { noop } from 'lodash';\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button, Spinner, Notice, TextControl } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\nimport { __ } from '@wordpress/i18n';\nimport { useRef, useState, useEffect } from '@wordpress/element';\nimport { focus } from '@wordpress/dom';\nimport { ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSettingsDrawer from './settings-drawer';\nimport LinkControlSearchInput from './search-input';\nimport LinkPreview from './link-preview';\nimport useCreatePage from './use-create-page';\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 {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\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\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\n\tconst [ internalInputValue, setInternalInputValue ] = useState(\n\t\tvalue?.url || ''\n\t);\n\tconst [ internalTextValue, setInternalTextValue ] = useState(\n\t\tvalue?.title || ''\n\t);\n\tconst currentInputValue = propInputValue || internalInputValue;\n\tconst [ isEditingLink, setIsEditingLink ] = useState(\n\t\tforceIsEditingLink !== undefined\n\t\t\t? forceIsEditingLink\n\t\t\t: ! value || ! value.url\n\t);\n\tconst isEndingEditWithFocus = useRef( false );\n\n\tconst currentInputIsEmpty = ! currentInputValue?.trim()?.length;\n\n\tconst { createPage, isCreatingPage, errorMessage } = useCreatePage(\n\t\tcreateSuggestion\n\t);\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}, [ 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\t\t// Unless we are mounting, we always want to focus either:\n\t\t// - the URL input\n\t\t// - the first focusable element in the Link UI.\n\t\t// But in editing mode if there is a text input present then\n\t\t// the URL input is at index 1. If not then it is at index 0.\n\t\tconst whichFocusTargetIndex = textInputRef?.current ? 1 : 0;\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 )[\n\t\t\t\twhichFocusTargetIndex\n\t\t\t] || wrapperNode.current;\n\n\t\tnextFocusTarget.focus();\n\n\t\tisEndingEditWithFocus.current = false;\n\t}, [ isEditingLink, isCreatingPage ] );\n\n\tuseEffect( () => {\n\t\t/**\n\t\t * If the value's `text` property changes then sync this\n\t\t * back up with state.\n\t\t */\n\t\tif ( value?.title && value.title !== internalTextValue ) {\n\t\t\tsetInternalTextValue( value.title );\n\t\t}\n\n\t\t/**\n\t\t * Update the state value internalInputValue if the url value changes\n\t\t * for example when clicking on another anchor\n\t\t */\n\t\tif ( value?.url ) {\n\t\t\tsetInternalInputValue( value.url );\n\t\t}\n\t}, [ value ] );\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\tfunction 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\tonChange( {\n\t\t\t...updatedValue,\n\t\t\ttitle: internalTextValue || updatedValue?.title,\n\t\t} );\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmit = () => {\n\t\tif (\n\t\t\tcurrentInputValue !== value?.url ||\n\t\t\tinternalTextValue !== value?.title\n\t\t) {\n\t\t\tonChange( {\n\t\t\t\turl: currentInputValue,\n\t\t\t\ttitle: internalTextValue,\n\t\t\t} );\n\t\t}\n\t\tstopEditing();\n\t};\n\n\tconst handleSubmitWithEnter = ( event ) => {\n\t\tconst { keyCode } = event;\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 shownUnlinkControl =\n\t\tonRemove && value && ! isEditingLink && ! isCreatingPage;\n\n\tconst showSettingsDrawer = !! settings?.length;\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 = value?.url?.trim()?.length > 0 && hasTextControl;\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{ ( isEditingLink || ! value ) && ! isCreatingPage && (\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\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={ internalTextValue }\n\t\t\t\t\t\t\t\tonChange={ setInternalTextValue }\n\t\t\t\t\t\t\t\tonKeyDown={ handleSubmitWithEnter }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) }\n\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={ currentInputValue }\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={ setInternalInputValue }\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\tuseLabel={ showTextControl }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<div className=\"block-editor-link-control__search-actions\">\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ handleSubmit }\n\t\t\t\t\t\t\t\t\tlabel={ __( 'Submit' ) }\n\t\t\t\t\t\t\t\t\ticon={ keyboardReturn }\n\t\t\t\t\t\t\t\t\tclassName=\"block-editor-link-control__search-submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ currentInputIsEmpty } // Disallow submitting empty values.\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</LinkControlSearchInput>\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{ showSettingsDrawer && (\n\t\t\t\t<div className=\"block-editor-link-control__tools\">\n\t\t\t\t\t<LinkControlSettingsDrawer\n\t\t\t\t\t\tvalue={ value }\n\t\t\t\t\t\tsettings={ settings }\n\t\t\t\t\t\tonChange={ onChange }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ renderControlBottom && renderControlBottom() }\n\t\t</div>\n\t);\n}\n\nLinkControl.ViewerFill = ViewerFill;\n\nexport default LinkControl;\n"]}
@@ -10,7 +10,6 @@ import classnames from 'classnames';
10
10
 
11
11
  import { Button } from '@wordpress/components';
12
12
  import { forwardRef } from '@wordpress/element';
13
- import { useSelect } from '@wordpress/data';
14
13
  import { Icon, lock } from '@wordpress/icons';
15
14
  import { SPACE, ENTER } from '@wordpress/keycodes';
16
15
  /**
@@ -21,7 +20,7 @@ import BlockIcon from '../block-icon';
21
20
  import useBlockDisplayInformation from '../use-block-display-information';
22
21
  import BlockTitle from '../block-title';
23
22
  import ListViewExpander from './expander';
24
- import { store as blockEditorStore } from '../../store';
23
+ import { useBlockLock } from '../block-lock';
25
24
 
26
25
  function ListViewBlockSelectButton(_ref, ref) {
27
26
  let {
@@ -38,13 +37,9 @@ function ListViewBlockSelectButton(_ref, ref) {
38
37
  draggable
39
38
  } = _ref;
40
39
  const blockInformation = useBlockDisplayInformation(clientId);
41
- const isLocked = useSelect(select => {
42
- const {
43
- canMoveBlock,
44
- canRemoveBlock
45
- } = select(blockEditorStore);
46
- return !canMoveBlock(clientId) || !canRemoveBlock(clientId);
47
- }, [clientId]); // The `href` attribute triggers the browser's native HTML drag operations.
40
+ const {
41
+ isLocked
42
+ } = useBlockLock(clientId); // The `href` attribute triggers the browser's native HTML drag operations.
48
43
  // When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.
49
44
  // We need to clear any HTML drag data to prevent `pasteHandler` from firing
50
45
  // inside the `useOnBlockDrop` hook.
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","forwardRef","useSelect","Icon","lock","SPACE","ENTER","BlockIcon","useBlockDisplayInformation","BlockTitle","ListViewExpander","store","blockEditorStore","ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","isLocked","select","canMoveBlock","canRemoveBlock","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AACA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,qBAA7B;AAEA;AACA;AACA;;AACA,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rB,4CADqB,EAErBgB,SAFqB,CADvB;AAKC,IAAA,OAAO,EAAGG,OALX;AAMC,IAAA,SAAS,EAAGgB,gBANb;AAOC,IAAA,GAAG,EAAGpB,GAPP;AAQC,IAAA,QAAQ,EAAGM,QARZ;AASC,IAAA,OAAO,EAAGC,OATX;AAUC,IAAA,WAAW,EAAGS,kBAVf;AAWC,IAAA,SAAS,EAAGP,SAXb;AAYC,IAAA,SAAS,EAAGC,SAZb;AAaC,IAAA,IAAI,EAAI,UAAUP,QAAU,EAb7B;AAcC,mBAAc;AAdf,KAgBC,cAAC,gBAAD;AAAkB,IAAA,OAAO,EAAGE;AAA5B,IAhBD,EAiBC,cAAC,SAAD;AAAW,IAAA,IAAI,EAAGM,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEW,IAApC;AAA2C,IAAA,UAAU;AAArD,IAjBD,EAkBC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,UAAD;AAAY,IAAA,QAAQ,EAAGnB,QAAvB;AAAkC,IAAA,aAAa,EAAG;AAAlD,IADD,CAlBD,EAqBG,CAAAQ,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAEY,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGZ,gBAAgB,CAACY,MADpB,CAtBF,EA0BGX,QAAQ,IACT;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGtB;AAAb,IADD,CA3BF,CADD,CADD;AAoCA;;AAED,eAAeH,UAAU,CAAEY,yBAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { Icon, lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\nimport { store as blockEditorStore } from '../../store';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst isLocked = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canMoveBlock, canRemoveBlock } = select( blockEditorStore );\n\n\t\t\treturn ! canMoveBlock( clientId ) || ! canRemoveBlock( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-hidden={ true }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isLocked && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block-select-button.js"],"names":["classnames","Button","forwardRef","Icon","lock","SPACE","ENTER","BlockIcon","useBlockDisplayInformation","BlockTitle","ListViewExpander","useBlockLock","ListViewBlockSelectButton","ref","className","block","clientId","onClick","onToggleExpanded","tabIndex","onFocus","onDragStart","onDragEnd","draggable","blockInformation","isLocked","onDragStartHandler","event","dataTransfer","clearData","onKeyDownHandler","keyCode","icon","anchor"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,UAAT,QAA2B,oBAA3B;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AACA,SAASC,KAAT,EAAgBC,KAAhB,QAA6B,qBAA7B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,eAAtB;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,OAAOC,UAAP,MAAuB,gBAAvB;AACA,OAAOC,gBAAP,MAA6B,YAA7B;AACA,SAASC,YAAT,QAA6B,eAA7B;;AAEA,SAASC,yBAAT,OAYCC,GAZD,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SAAD;AAAW,IAAA,IAAI,EAAGM,gBAAH,aAAGA,gBAAH,uBAAGA,gBAAgB,CAAEQ,IAApC;AAA2C,IAAA,UAAU;AAArD,IAjBD,EAkBC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,UAAD;AAAY,IAAA,QAAQ,EAAGhB,QAAvB;AAAkC,IAAA,aAAa,EAAG;AAAlD,IADD,CAlBD,EAqBG,CAAAQ,gBAAgB,SAAhB,IAAAA,gBAAgB,WAAhB,YAAAA,gBAAgB,CAAES,MAAlB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGT,gBAAgB,CAACS,MADpB,CAtBF,EA0BGR,QAAQ,IACT;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,IAAD;AAAM,IAAA,IAAI,EAAGrB;AAAb,IADD,CA3BF,CADD,CADD;AAoCA;;AAED,eAAeF,UAAU,CAAEU,yBAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { forwardRef } from '@wordpress/element';\nimport { Icon, lock } from '@wordpress/icons';\nimport { SPACE, ENTER } from '@wordpress/keycodes';\n\n/**\n * Internal dependencies\n */\nimport BlockIcon from '../block-icon';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport BlockTitle from '../block-title';\nimport ListViewExpander from './expander';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlockSelectButton(\n\t{\n\t\tclassName,\n\t\tblock: { clientId },\n\t\tonClick,\n\t\tonToggleExpanded,\n\t\ttabIndex,\n\t\tonFocus,\n\t\tonDragStart,\n\t\tonDragEnd,\n\t\tdraggable,\n\t},\n\tref\n) {\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst { isLocked } = useBlockLock( clientId );\n\n\t// The `href` attribute triggers the browser's native HTML drag operations.\n\t// When the link is dragged, the element's outerHTML is set in DataTransfer object as text/html.\n\t// We need to clear any HTML drag data to prevent `pasteHandler` from firing\n\t// inside the `useOnBlockDrop` hook.\n\tconst onDragStartHandler = ( event ) => {\n\t\tevent.dataTransfer.clearData();\n\t\tonDragStart?.( event );\n\t};\n\n\tfunction onKeyDownHandler( event ) {\n\t\tif ( event.keyCode === ENTER || event.keyCode === SPACE ) {\n\t\t\tonClick( event );\n\t\t}\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-list-view-block-select-button',\n\t\t\t\t\tclassName\n\t\t\t\t) }\n\t\t\t\tonClick={ onClick }\n\t\t\t\tonKeyDown={ onKeyDownHandler }\n\t\t\t\tref={ ref }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\tonFocus={ onFocus }\n\t\t\t\tonDragStart={ onDragStartHandler }\n\t\t\t\tonDragEnd={ onDragEnd }\n\t\t\t\tdraggable={ draggable }\n\t\t\t\thref={ `#block-${ clientId }` }\n\t\t\t\taria-hidden={ true }\n\t\t\t>\n\t\t\t\t<ListViewExpander onClick={ onToggleExpanded } />\n\t\t\t\t<BlockIcon icon={ blockInformation?.icon } showColors />\n\t\t\t\t<span className=\"block-editor-list-view-block-select-button__title\">\n\t\t\t\t\t<BlockTitle clientId={ clientId } maximumLength={ 35 } />\n\t\t\t\t</span>\n\t\t\t\t{ blockInformation?.anchor && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__anchor\">\n\t\t\t\t\t\t{ blockInformation.anchor }\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t{ isLocked && (\n\t\t\t\t\t<span className=\"block-editor-list-view-block-select-button__lock\">\n\t\t\t\t\t\t<Icon icon={ lock } />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t</Button>\n\t\t</>\n\t);\n}\n\nexport default forwardRef( ListViewBlockSelectButton );\n"]}
@@ -26,6 +26,7 @@ import { useListViewContext } from './context';
26
26
  import { getBlockPositionDescription } from './utils';
27
27
  import { store as blockEditorStore } from '../../store';
28
28
  import useBlockDisplayInformation from '../use-block-display-information';
29
+ import { useBlockLock } from '../block-lock';
29
30
 
30
31
  function ListViewBlock(_ref) {
31
32
  let {
@@ -55,11 +56,21 @@ function ListViewBlock(_ref) {
55
56
  toggleBlockHighlight
56
57
  } = useDispatch(blockEditorStore);
57
58
  const blockInformation = useBlockDisplayInformation(clientId);
59
+ const {
60
+ isLocked
61
+ } = useBlockLock(clientId);
58
62
  const instanceId = useInstanceId(ListViewBlock);
59
63
  const descriptionId = `list-view-block-select-button__${instanceId}`;
60
64
  const blockPositionDescription = getBlockPositionDescription(position, siblingBlockCount, level);
61
- const blockAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block. This string indicates a link to select the block.
62
- __('%s link'), blockInformation.title) : __('Link');
65
+
66
+ let blockAriaLabel = __('Link');
67
+
68
+ if (blockInformation) {
69
+ blockAriaLabel = isLocked ? sprintf( // translators: %s: The title of the block. This string indicates a link to select the locked block.
70
+ __('%s link (locked)'), blockInformation.title) : sprintf( // translators: %s: The title of the block. This string indicates a link to select the block.
71
+ __('%s link'), blockInformation.title);
72
+ }
73
+
63
74
  const settingsAriaLabel = blockInformation ? sprintf( // translators: %s: The title of the block.
64
75
  __('Options for %s block'), blockInformation.title) : __('Options');
65
76
  const {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","useInstanceId","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","getBlockPositionDescription","store","blockEditorStore","useBlockDisplayInformation","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","cellRef","isHovered","setIsHovered","clientId","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","hideContainerBlockActions","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","toggleExpanded","stopPropagation","showBlockActions","hideBlockActions","colSpan","classes","dropdownClientIds","includes","ref","tabIndex","onFocus","className"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,uBAHP;AAIA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,IALD,QAMO,oBANP;AAOA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SACCC,kBADD,EAECC,oBAFD,QAGO,uBAHP;AAIA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,qBAAP,MAAkC,gDAAlC;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,2BAAT,QAA4C,SAA5C;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;;AAEA,SAASC,aAAT,OAeI;AAAA,MAfoB;AACvBC,IAAAA,KADuB;AAEvBC,IAAAA,SAFuB;AAGvBC,IAAAA,UAHuB;AAIvBC,IAAAA,gBAJuB;AAKvBC,IAAAA,WALuB;AAM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;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAG/E,YAFR;AAGC,MAAA,KAAK,EAAGgD,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbiC,QAAAA,GADa;AAEbG,QAAAA,SAAS,EAAE,oCAFE;AAGbF,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGb;AAX7B,MADC;AAAA,GAJH,CAnFF,CADD;AA2GA;;AAED,eAAejE,IAAI,CAAEc,aAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tpreventAnnouncement,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tconst blockAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t__( '%s link' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Link' );\n\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\n\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions: hideContainerBlockActions,\n\t\tisTreeGridMounted,\n\t\texpand,\n\t\tcollapse,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateSelection = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tconst showBlockActions =\n\t\twithExperimentalFeatures &&\n\t\t// hide actions for blocks like core/widget-areas\n\t\t( ! hideContainerBlockActions ||\n\t\t\t( hideContainerBlockActions && level > 1 ) );\n\n\tconst hideBlockActions = withExperimentalFeatures && ! showBlockActions;\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( hideBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': hideBlockActions,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t\taria-selected={ !! isSelected }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ updateSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/list-view/block.js"],"names":["classnames","__experimentalTreeGridCell","TreeGridCell","__experimentalTreeGridItem","TreeGridItem","useInstanceId","moreVertical","useState","useRef","useEffect","useCallback","memo","useDispatch","sprintf","__","ListViewLeaf","BlockMoverUpButton","BlockMoverDownButton","ListViewBlockContents","BlockSettingsDropdown","useListViewContext","getBlockPositionDescription","store","blockEditorStore","useBlockDisplayInformation","useBlockLock","ListViewBlock","block","isDragged","isSelected","isBranchSelected","selectBlock","position","level","rowCount","siblingBlockCount","showBlockMovers","path","isExpanded","selectedClientIds","preventAnnouncement","cellRef","isHovered","setIsHovered","clientId","isFirstSelectedBlock","isLastSelectedBlock","length","toggleBlockHighlight","blockInformation","isLocked","instanceId","descriptionId","blockPositionDescription","blockAriaLabel","title","settingsAriaLabel","__experimentalFeatures","withExperimentalFeatures","__experimentalPersistentListViewFeatures","withExperimentalPersistentListViewFeatures","__experimentalHideContainerBlockActions","hideContainerBlockActions","isTreeGridMounted","expand","collapse","hasSiblings","hasRenderedMovers","moverCellClassName","listViewBlockSettingsClassName","current","focus","highlightBlock","onMouseEnter","onMouseLeave","selectEditorBlock","event","preventDefault","updateSelection","newClientId","undefined","toggleExpanded","stopPropagation","showBlockActions","hideBlockActions","colSpan","classes","dropdownClientIds","includes","ref","tabIndex","onFocus","className"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,0BAA0B,IAAIC,YAD/B,EAECC,0BAA0B,IAAIC,YAF/B,QAGO,uBAHP;AAIA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SACCC,QADD,EAECC,MAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,IALD,QAMO,oBANP;AAOA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,OAAT,EAAkBC,EAAlB,QAA4B,iBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,QAAzB;AACA,SACCC,kBADD,EAECC,oBAFD,QAGO,uBAHP;AAIA,OAAOC,qBAAP,MAAkC,kBAAlC;AACA,OAAOC,qBAAP,MAAkC,gDAAlC;AACA,SAASC,kBAAT,QAAmC,WAAnC;AACA,SAASC,2BAAT,QAA4C,SAA5C;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,OAAOC,0BAAP,MAAuC,kCAAvC;AACA,SAASC,YAAT,QAA6B,eAA7B;;AAEA,SAASC,aAAT,OAeI;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,UADb;AAEC,MAAA,SAAS,EAAG,CAAE/C,QAAF,CAFb;AAGC,MAAA,GAAG,EAAG6C,GAHP;AAIC,MAAA,QAAQ,EAAGC,QAJZ;AAKC,MAAA,OAAO,EAAGC;AALX,MADC;AAAA,GADH,CAfD,CADD,CAnDF,EAkFGR,gBAAgB,IACjB,cAAC,YAAD;AACC,IAAA,SAAS,EAAGd,8BADb;AAEC,qBAAgB,CAAC,CAAExC;AAFpB,KAIG;AAAA,QAAE;AAAE4D,MAAAA,GAAF;AAAOC,MAAAA,QAAP;AAAiBC,MAAAA;AAAjB,KAAF;AAAA,WACD,cAAC,qBAAD;AACC,MAAA,SAAS,EAAGJ,iBADb;AAEC,MAAA,IAAI,EAAGjF,YAFR;AAGC,MAAA,KAAK,EAAGkD,iBAHT;AAIC,MAAA,WAAW,EAAG;AACbiC,QAAAA,GADa;AAEbG,QAAAA,SAAS,EAAE,oCAFE;AAGbF,QAAAA,QAHa;AAIbC,QAAAA;AAJa,OAJf;AAUC,MAAA,sBAAsB,MAVvB;AAWC,MAAA,yBAAyB,EAAGb;AAX7B,MADC;AAAA,GAJH,CAnFF,CADD;AA2GA;;AAED,eAAenE,IAAI,CAAEe,aAAF,CAAnB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalTreeGridCell as TreeGridCell,\n\t__experimentalTreeGridItem as TreeGridItem,\n} from '@wordpress/components';\nimport { useInstanceId } from '@wordpress/compose';\nimport { moreVertical } from '@wordpress/icons';\nimport {\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tuseCallback,\n\tmemo,\n} from '@wordpress/element';\nimport { useDispatch } from '@wordpress/data';\nimport { sprintf, __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ListViewLeaf from './leaf';\nimport {\n\tBlockMoverUpButton,\n\tBlockMoverDownButton,\n} from '../block-mover/button';\nimport ListViewBlockContents from './block-contents';\nimport BlockSettingsDropdown from '../block-settings-menu/block-settings-dropdown';\nimport { useListViewContext } from './context';\nimport { getBlockPositionDescription } from './utils';\nimport { store as blockEditorStore } from '../../store';\nimport useBlockDisplayInformation from '../use-block-display-information';\nimport { useBlockLock } from '../block-lock';\n\nfunction ListViewBlock( {\n\tblock,\n\tisDragged,\n\tisSelected,\n\tisBranchSelected,\n\tselectBlock,\n\tposition,\n\tlevel,\n\trowCount,\n\tsiblingBlockCount,\n\tshowBlockMovers,\n\tpath,\n\tisExpanded,\n\tselectedClientIds,\n\tpreventAnnouncement,\n} ) {\n\tconst cellRef = useRef( null );\n\tconst [ isHovered, setIsHovered ] = useState( false );\n\tconst { clientId } = block;\n\tconst isFirstSelectedBlock =\n\t\tisSelected && selectedClientIds[ 0 ] === clientId;\n\tconst isLastSelectedBlock =\n\t\tisSelected &&\n\t\tselectedClientIds[ selectedClientIds.length - 1 ] === clientId;\n\n\tconst { toggleBlockHighlight } = useDispatch( blockEditorStore );\n\n\tconst blockInformation = useBlockDisplayInformation( clientId );\n\tconst { isLocked } = useBlockLock( clientId );\n\tconst instanceId = useInstanceId( ListViewBlock );\n\tconst descriptionId = `list-view-block-select-button__${ instanceId }`;\n\tconst blockPositionDescription = getBlockPositionDescription(\n\t\tposition,\n\t\tsiblingBlockCount,\n\t\tlevel\n\t);\n\n\tlet blockAriaLabel = __( 'Link' );\n\tif ( blockInformation ) {\n\t\tblockAriaLabel = isLocked\n\t\t\t? sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the locked block.\n\t\t\t\t\t__( '%s link (locked)' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t )\n\t\t\t: sprintf(\n\t\t\t\t\t// translators: %s: The title of the block. This string indicates a link to select the block.\n\t\t\t\t\t__( '%s link' ),\n\t\t\t\t\tblockInformation.title\n\t\t\t );\n\t}\n\n\tconst settingsAriaLabel = blockInformation\n\t\t? sprintf(\n\t\t\t\t// translators: %s: The title of the block.\n\t\t\t\t__( 'Options for %s block' ),\n\t\t\t\tblockInformation.title\n\t\t )\n\t\t: __( 'Options' );\n\n\tconst {\n\t\t__experimentalFeatures: withExperimentalFeatures,\n\t\t__experimentalPersistentListViewFeatures: withExperimentalPersistentListViewFeatures,\n\t\t__experimentalHideContainerBlockActions: hideContainerBlockActions,\n\t\tisTreeGridMounted,\n\t\texpand,\n\t\tcollapse,\n\t} = useListViewContext();\n\n\tconst hasSiblings = siblingBlockCount > 0;\n\tconst hasRenderedMovers = showBlockMovers && hasSiblings;\n\tconst moverCellClassName = classnames(\n\t\t'block-editor-list-view-block__mover-cell',\n\t\t{ 'is-visible': isHovered || isSelected }\n\t);\n\n\tconst listViewBlockSettingsClassName = classnames(\n\t\t'block-editor-list-view-block__menu-cell',\n\t\t{ 'is-visible': isHovered || isFirstSelectedBlock }\n\t);\n\n\t// If ListView has experimental features related to the Persistent List View,\n\t// only focus the selected list item on mount; otherwise the list would always\n\t// try to steal the focus from the editor canvas.\n\tuseEffect( () => {\n\t\tif (\n\t\t\twithExperimentalPersistentListViewFeatures &&\n\t\t\t! isTreeGridMounted &&\n\t\t\tisSelected\n\t\t) {\n\t\t\tcellRef.current.focus();\n\t\t}\n\t}, [] );\n\n\tconst highlightBlock = withExperimentalPersistentListViewFeatures\n\t\t? toggleBlockHighlight\n\t\t: () => {};\n\n\tconst onMouseEnter = useCallback( () => {\n\t\tsetIsHovered( true );\n\t\thighlightBlock( clientId, true );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\tconst onMouseLeave = useCallback( () => {\n\t\tsetIsHovered( false );\n\t\thighlightBlock( clientId, false );\n\t}, [ clientId, setIsHovered, highlightBlock ] );\n\n\tconst selectEditorBlock = useCallback(\n\t\t( event ) => {\n\t\t\tselectBlock( event, clientId );\n\t\t\tevent.preventDefault();\n\t\t},\n\t\t[ clientId, selectBlock ]\n\t);\n\n\tconst updateSelection = useCallback(\n\t\t( newClientId ) => {\n\t\t\tselectBlock( undefined, newClientId );\n\t\t},\n\t\t[ selectBlock ]\n\t);\n\n\tconst toggleExpanded = useCallback(\n\t\t( event ) => {\n\t\t\t// Prevent shift+click from opening link in a new window when toggling.\n\t\t\tevent.preventDefault();\n\t\t\tevent.stopPropagation();\n\t\t\tif ( isExpanded === true ) {\n\t\t\t\tcollapse( clientId );\n\t\t\t} else if ( isExpanded === false ) {\n\t\t\t\texpand( clientId );\n\t\t\t}\n\t\t},\n\t\t[ clientId, expand, collapse, isExpanded ]\n\t);\n\n\tconst showBlockActions =\n\t\twithExperimentalFeatures &&\n\t\t// hide actions for blocks like core/widget-areas\n\t\t( ! hideContainerBlockActions ||\n\t\t\t( hideContainerBlockActions && level > 1 ) );\n\n\tconst hideBlockActions = withExperimentalFeatures && ! showBlockActions;\n\n\tlet colSpan;\n\tif ( hasRenderedMovers ) {\n\t\tcolSpan = 2;\n\t} else if ( hideBlockActions ) {\n\t\tcolSpan = 3;\n\t}\n\n\tconst classes = classnames( {\n\t\t'is-selected': isSelected,\n\t\t'is-first-selected': isFirstSelectedBlock,\n\t\t'is-last-selected': isLastSelectedBlock,\n\t\t'is-branch-selected':\n\t\t\twithExperimentalPersistentListViewFeatures && isBranchSelected,\n\t\t'is-dragging': isDragged,\n\t\t'has-single-cell': hideBlockActions,\n\t} );\n\n\t// Only include all selected blocks if the currently clicked on block\n\t// is one of the selected blocks. This ensures that if a user attempts\n\t// to alter a block that isn't part of the selection, they're still able\n\t// to do so.\n\tconst dropdownClientIds = selectedClientIds.includes( clientId )\n\t\t? selectedClientIds\n\t\t: [ clientId ];\n\n\treturn (\n\t\t<ListViewLeaf\n\t\t\tclassName={ classes }\n\t\t\tonMouseEnter={ onMouseEnter }\n\t\t\tonMouseLeave={ onMouseLeave }\n\t\t\tonFocus={ onMouseEnter }\n\t\t\tonBlur={ onMouseLeave }\n\t\t\tlevel={ level }\n\t\t\tposition={ position }\n\t\t\trowCount={ rowCount }\n\t\t\tpath={ path }\n\t\t\tid={ `list-view-block-${ clientId }` }\n\t\t\tdata-block={ clientId }\n\t\t\tisExpanded={ isExpanded }\n\t\t\taria-selected={ !! isSelected }\n\t\t>\n\t\t\t<TreeGridCell\n\t\t\t\tclassName=\"block-editor-list-view-block__contents-cell\"\n\t\t\t\tcolSpan={ colSpan }\n\t\t\t\tref={ cellRef }\n\t\t\t\taria-label={ blockAriaLabel }\n\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\taria-expanded={ isExpanded }\n\t\t\t\taria-describedby={ descriptionId }\n\t\t\t>\n\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t<div className=\"block-editor-list-view-block__contents-container\">\n\t\t\t\t\t\t<ListViewBlockContents\n\t\t\t\t\t\t\tblock={ block }\n\t\t\t\t\t\t\tonClick={ selectEditorBlock }\n\t\t\t\t\t\t\tonToggleExpanded={ toggleExpanded }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tposition={ position }\n\t\t\t\t\t\t\tsiblingBlockCount={ siblingBlockCount }\n\t\t\t\t\t\t\tlevel={ level }\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tisExpanded={ isExpanded }\n\t\t\t\t\t\t\tselectedClientIds={ selectedClientIds }\n\t\t\t\t\t\t\tpreventAnnouncement={ preventAnnouncement }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName=\"block-editor-list-view-block-select-button__description\"\n\t\t\t\t\t\t\tid={ descriptionId }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ blockPositionDescription }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</TreeGridCell>\n\t\t\t{ hasRenderedMovers && (\n\t\t\t\t<>\n\t\t\t\t\t<TreeGridCell\n\t\t\t\t\t\tclassName={ moverCellClassName }\n\t\t\t\t\t\twithoutGridItem\n\t\t\t\t\t>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverUpButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t\t<TreeGridItem>\n\t\t\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t\t\t<BlockMoverDownButton\n\t\t\t\t\t\t\t\t\torientation=\"vertical\"\n\t\t\t\t\t\t\t\t\tclientIds={ [ clientId ] }\n\t\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</TreeGridItem>\n\t\t\t\t\t</TreeGridCell>\n\t\t\t\t</>\n\t\t\t) }\n\n\t\t\t{ showBlockActions && (\n\t\t\t\t<TreeGridCell\n\t\t\t\t\tclassName={ listViewBlockSettingsClassName }\n\t\t\t\t\taria-selected={ !! isSelected }\n\t\t\t\t>\n\t\t\t\t\t{ ( { ref, tabIndex, onFocus } ) => (\n\t\t\t\t\t\t<BlockSettingsDropdown\n\t\t\t\t\t\t\tclientIds={ dropdownClientIds }\n\t\t\t\t\t\t\ticon={ moreVertical }\n\t\t\t\t\t\t\tlabel={ settingsAriaLabel }\n\t\t\t\t\t\t\ttoggleProps={ {\n\t\t\t\t\t\t\t\tref,\n\t\t\t\t\t\t\t\tclassName: 'block-editor-list-view-block__menu',\n\t\t\t\t\t\t\t\ttabIndex,\n\t\t\t\t\t\t\t\tonFocus,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tdisableOpenOnArrowDown\n\t\t\t\t\t\t\t__experimentalSelectBlock={ updateSelection }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</TreeGridCell>\n\t\t\t) }\n\t\t</ListViewLeaf>\n\t);\n}\n\nexport default memo( ListViewBlock );\n"]}
@@ -108,7 +108,13 @@ export default function useSelectionObserver() {
108
108
  }
109
109
 
110
110
  const clientId = getBlockClientId(extractSelectionStartNode(selection));
111
- const endClientId = getBlockClientId(extractSelectionEndNode(selection));
111
+ const endClientId = getBlockClientId(extractSelectionEndNode(selection)); // If the selection did not involve a block, return early.
112
+
113
+ if (clientId === undefined && endClientId === undefined) {
114
+ setContentEditableWrapper(node, false);
115
+ return;
116
+ }
117
+
112
118
  const isSingularSelection = clientId === endClientId;
113
119
 
114
120
  if (isSingularSelection) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","ownerDocument","defaultView","onSelectionChange","getSelection","rangeCount","isCollapsed","clientId","endClientId","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AACA,SAASC,gBAAT,QAAiC,iBAAjC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,yBAAT,CAAoCC,SAApC,EAAgD;AAC/C,QAA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,CAAiC,SAAjC,EAA4CZ,iBAA5C;AACA;;AAED,aAASa,cAAT,GAA0B;AACzBF,MAAAA,eAAe;AACfF,MAAAA,YAAY;AACZ;;AAEDA,IAAAA,YAAY,GA5DD,CA6DX;AACA;AACA;;AACApB,IAAAA,IAAI,CAACqB,gBAAL,CAAuB,SAAvB,EAAkCG,cAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACftB,MAAAA,IAAI,CAACuB,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GAtEiB,EAuElB,CAAEnB,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CC,eAA7C,CAvEkB,CAAnB;AAyEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst { getBlockParents } = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange() {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t// If no selection is found, end multi selection and disable the\n\t\t\t\t// contentEditable wrapper.\n\t\t\t\tif ( ! selection.rangeCount || selection.isCollapsed ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst clientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tconst endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\t\t\t\tconst isSingularSelection = clientId === endClientId;\n\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-selection-observer.js"],"names":["useSelect","useDispatch","useRefEffect","store","blockEditorStore","getBlockClientId","extractSelectionStartNode","selection","anchorNode","anchorOffset","nodeType","TEXT_NODE","childNodes","extractSelectionEndNode","focusNode","focusOffset","findDepth","a","b","depth","setContentEditableWrapper","node","value","contentEditable","focus","useSelectionObserver","multiSelect","selectBlock","selectionChange","getBlockParents","ownerDocument","defaultView","onSelectionChange","getSelection","rangeCount","isCollapsed","clientId","endClientId","undefined","isSingularSelection","startPath","endPath","addListeners","addEventListener","removeListeners","removeEventListener","resetListeners"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;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ACA;AACD;;AAED,aAASuB,YAAT,GAAwB;AACvBZ,MAAAA,aAAa,CAACa,gBAAd,CACC,iBADD,EAECX,iBAFD;AAIAD,MAAAA,WAAW,CAACY,gBAAZ,CAA8B,SAA9B,EAAyCX,iBAAzC;AACA;;AAED,aAASY,eAAT,GAA2B;AAC1Bd,MAAAA,aAAa,CAACe,mBAAd,CACC,iBADD,EAECb,iBAFD;AAIAD,MAAAA,WAAW,CAACc,mBAAZ,CAAiC,SAAjC,EAA4Cb,iBAA5C;AACA;;AAED,aAASc,cAAT,GAA0B;AACzBF,MAAAA,eAAe;AACfF,MAAAA,YAAY;AACZ;;AAEDA,IAAAA,YAAY,GAnED,CAoEX;AACA;AACA;;AACArB,IAAAA,IAAI,CAACsB,gBAAL,CAAuB,SAAvB,EAAkCG,cAAlC;AACA,WAAO,MAAM;AACZF,MAAAA,eAAe;AACfvB,MAAAA,IAAI,CAACwB,mBAAL,CAA0B,SAA1B,EAAqCC,cAArC;AACA,KAHD;AAIA,GA7EiB,EA8ElB,CAAEpB,WAAF,EAAeC,WAAf,EAA4BC,eAA5B,EAA6CC,eAA7C,CA9EkB,CAAnB;AAgFA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { getBlockClientId } from '../../utils/dom';\n\n/**\n * Extract the selection start node from the selection. When the anchor node is\n * not a text node, the selection offset is the index of a child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionStartNode( selection ) {\n\tconst { anchorNode, anchorOffset } = selection;\n\n\tif ( anchorNode.nodeType === anchorNode.TEXT_NODE ) {\n\t\treturn anchorNode;\n\t}\n\n\treturn anchorNode.childNodes[ anchorOffset ];\n}\n\n/**\n * Extract the selection end node from the selection. When the focus node is not\n * a text node, the selection offset is the index of a child node. The selection\n * reaches up to but excluding that child node.\n *\n * @param {Selection} selection The selection.\n *\n * @return {Element} The selection start node.\n */\nfunction extractSelectionEndNode( selection ) {\n\tconst { focusNode, focusOffset } = selection;\n\n\tif ( focusNode.nodeType === focusNode.TEXT_NODE ) {\n\t\treturn focusNode;\n\t}\n\n\treturn focusNode.childNodes[ focusOffset - 1 ];\n}\n\nfunction findDepth( a, b ) {\n\tlet depth = 0;\n\n\twhile ( a[ depth ] === b[ depth ] ) {\n\t\tdepth++;\n\t}\n\n\treturn depth;\n}\n\n/**\n * Sets the `contenteditable` wrapper element to `value`.\n *\n * @param {HTMLElement} node Block element.\n * @param {boolean} value `contentEditable` value (true or false)\n */\nfunction setContentEditableWrapper( node, value ) {\n\tnode.contentEditable = value;\n\t// Firefox doesn't automatically move focus.\n\tif ( value ) node.focus();\n}\n\n/**\n * Sets a multi-selection based on the native selection across blocks.\n */\nexport default function useSelectionObserver() {\n\tconst { multiSelect, selectBlock, selectionChange } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst { getBlockParents } = useSelect( blockEditorStore );\n\treturn useRefEffect(\n\t\t( node ) => {\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tfunction onSelectionChange() {\n\t\t\t\tconst selection = defaultView.getSelection();\n\n\t\t\t\t// If no selection is found, end multi selection and disable the\n\t\t\t\t// contentEditable wrapper.\n\t\t\t\tif ( ! selection.rangeCount || selection.isCollapsed ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst clientId = getBlockClientId(\n\t\t\t\t\textractSelectionStartNode( selection )\n\t\t\t\t);\n\t\t\t\tconst endClientId = getBlockClientId(\n\t\t\t\t\textractSelectionEndNode( selection )\n\t\t\t\t);\n\n\t\t\t\t// If the selection did not involve a block, return early.\n\t\t\t\tif ( clientId === undefined && endClientId === undefined ) {\n\t\t\t\t\tsetContentEditableWrapper( node, false );\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst isSingularSelection = clientId === endClientId;\n\n\t\t\t\tif ( isSingularSelection ) {\n\t\t\t\t\tselectBlock( clientId );\n\t\t\t\t} else {\n\t\t\t\t\tconst startPath = [\n\t\t\t\t\t\t...getBlockParents( clientId ),\n\t\t\t\t\t\tclientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst endPath = [\n\t\t\t\t\t\t...getBlockParents( endClientId ),\n\t\t\t\t\t\tendClientId,\n\t\t\t\t\t];\n\t\t\t\t\tconst depth = findDepth( startPath, endPath );\n\n\t\t\t\t\tmultiSelect( startPath[ depth ], endPath[ depth ] );\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfunction addListeners() {\n\t\t\t\townerDocument.addEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.addEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction removeListeners() {\n\t\t\t\townerDocument.removeEventListener(\n\t\t\t\t\t'selectionchange',\n\t\t\t\t\tonSelectionChange\n\t\t\t\t);\n\t\t\t\tdefaultView.removeEventListener( 'mouseup', onSelectionChange );\n\t\t\t}\n\n\t\t\tfunction resetListeners() {\n\t\t\t\tremoveListeners();\n\t\t\t\taddListeners();\n\t\t\t}\n\n\t\t\taddListeners();\n\t\t\t// We must allow rich text to set selection first. This ensures that\n\t\t\t// our `selectionchange` listener is always reset to be called after\n\t\t\t// the rich text one.\n\t\t\tnode.addEventListener( 'focusin', resetListeners );\n\t\t\treturn () => {\n\t\t\t\tremoveListeners();\n\t\t\t\tnode.removeEventListener( 'focusin', resetListeners );\n\t\t\t};\n\t\t},\n\t\t[ multiSelect, selectBlock, selectionChange, getBlockParents ]\n\t);\n}\n"]}
@@ -60,28 +60,44 @@ export function getValuesFromColors() {
60
60
  */
61
61
 
62
62
  /**
63
- * SVG and stylesheet needed for rendering the duotone filter.
63
+ * Stylesheet for rendering the duotone filter.
64
64
  *
65
65
  * @param {Object} props Duotone props.
66
66
  * @param {string} props.selector Selector to apply the filter to.
67
67
  * @param {string} props.id Unique id for this duotone filter.
68
- * @param {Values} props.values R, G, B, and A values to filter with.
69
68
  *
70
69
  * @return {WPElement} Duotone element.
71
70
  */
72
71
 
73
- function DuotoneFilter(_ref) {
72
+ function DuotoneStylesheet(_ref) {
74
73
  let {
75
74
  selector,
76
- id,
77
- values
75
+ id
78
76
  } = _ref;
79
- const stylesheet = `
77
+ const css = `
80
78
  ${selector} {
81
79
  filter: url( #${id} );
82
80
  }
83
81
  `;
84
- return createElement(Fragment, null, createElement(SVG, {
82
+ return createElement("style", null, css);
83
+ }
84
+ /**
85
+ * SVG for rendering the duotone filter.
86
+ *
87
+ * @param {Object} props Duotone props.
88
+ * @param {string} props.id Unique id for this duotone filter.
89
+ * @param {Values} props.values R, G, B, and A values to filter with.
90
+ *
91
+ * @return {WPElement} Duotone element.
92
+ */
93
+
94
+
95
+ function DuotoneFilter(_ref2) {
96
+ let {
97
+ id,
98
+ values
99
+ } = _ref2;
100
+ return createElement(SVG, {
85
101
  xmlnsXlink: "http://www.w3.org/1999/xlink",
86
102
  viewBox: "0 0 0 0",
87
103
  width: "0",
@@ -121,18 +137,40 @@ ${selector} {
121
137
  // Re-mask the image with the original transparency since the feColorMatrix above loses that information.
122
138
  in2: "SourceGraphic",
123
139
  operator: "in"
124
- })))), createElement("style", {
125
- dangerouslySetInnerHTML: {
126
- __html: stylesheet
127
- }
140
+ }))));
141
+ }
142
+ /**
143
+ * SVG and stylesheet needed for rendering the duotone filter.
144
+ *
145
+ * @param {Object} props Duotone props.
146
+ * @param {string} props.selector Selector to apply the filter to.
147
+ * @param {string} props.id Unique id for this duotone filter.
148
+ * @param {Values} props.values R, G, B, and A values to filter with.
149
+ *
150
+ * @return {WPElement} Duotone element.
151
+ */
152
+
153
+
154
+ function InlineDuotone(_ref3) {
155
+ let {
156
+ selector,
157
+ id,
158
+ values
159
+ } = _ref3;
160
+ return createElement(Fragment, null, createElement(DuotoneFilter, {
161
+ id: id,
162
+ values: values
163
+ }), createElement(DuotoneStylesheet, {
164
+ id: id,
165
+ selector: selector
128
166
  }));
129
167
  }
130
168
 
131
- function useMultiOriginPresets(_ref2) {
169
+ function useMultiOriginPresets(_ref4) {
132
170
  let {
133
171
  presetSetting,
134
172
  defaultSetting
135
- } = _ref2;
173
+ } = _ref4;
136
174
  const disableDefault = !useSetting(defaultSetting);
137
175
  const userPresets = useSetting(`${presetSetting}.custom`) || EMPTY_ARRAY;
138
176
  const themePresets = useSetting(`${presetSetting}.theme`) || EMPTY_ARRAY;
@@ -140,13 +178,13 @@ function useMultiOriginPresets(_ref2) {
140
178
  return useMemo(() => [...userPresets, ...themePresets, ...(disableDefault ? EMPTY_ARRAY : defaultPresets)], [disableDefault, userPresets, themePresets, defaultPresets]);
141
179
  }
142
180
 
143
- function DuotonePanel(_ref3) {
181
+ function DuotonePanel(_ref5) {
144
182
  var _style$color;
145
183
 
146
184
  let {
147
185
  attributes,
148
186
  setAttributes
149
- } = _ref3;
187
+ } = _ref5;
150
188
  const style = attributes === null || attributes === void 0 ? void 0 : attributes.style;
151
189
  const duotone = style === null || style === void 0 ? void 0 : (_style$color = style.color) === null || _style$color === void 0 ? void 0 : _style$color.duotone;
152
190
  const duotonePalette = useMultiOriginPresets({
@@ -281,7 +319,7 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
281
319
  const selectorsGroup = scopeSelector(`.editor-styles-wrapper .${id}`, duotoneSupport);
282
320
  const className = classnames(props === null || props === void 0 ? void 0 : props.className, id);
283
321
  const element = useContext(BlockList.__unstableElementContext);
284
- return createElement(Fragment, null, element && createPortal(createElement(DuotoneFilter, {
322
+ return createElement(Fragment, null, element && createPortal(createElement(InlineDuotone, {
285
323
  selector: selectorsGroup,
286
324
  id: id,
287
325
  values: getValuesFromColors(values)
@@ -289,6 +327,15 @@ const withDuotoneStyles = createHigherOrderComponent(BlockListBlock => props =>
289
327
  className: className
290
328
  })));
291
329
  }, 'withDuotoneStyles');
330
+ export function PresetDuotoneFilter(_ref6) {
331
+ let {
332
+ preset
333
+ } = _ref6;
334
+ return createElement(DuotoneFilter, {
335
+ id: `wp-duotone-${preset.slug}`,
336
+ values: getValuesFromColors(preset.colors)
337
+ });
338
+ }
292
339
  addFilter('blocks.registerBlockType', 'core/editor/duotone/add-attributes', addDuotoneAttributes);
293
340
  addFilter('editor.BlockEdit', 'core/editor/duotone/with-editor-controls', withDuotoneControls);
294
341
  addFilter('editor.BlockListBlock', 'core/editor/duotone/with-styles', withDuotoneStyles);