@wordpress/block-editor 11.1.0 → 11.2.0

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 (201) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE.md +1 -1
  3. package/build/components/block-actions/index.js +9 -0
  4. package/build/components/block-actions/index.js.map +1 -1
  5. package/build/components/block-inspector/index.js +4 -2
  6. package/build/components/block-inspector/index.js.map +1 -1
  7. package/build/components/block-preview/auto.js +1 -4
  8. package/build/components/block-preview/auto.js.map +1 -1
  9. package/build/components/block-settings-menu/block-settings-dropdown.js +4 -1
  10. package/build/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  11. package/build/components/block-styles/index.js +3 -1
  12. package/build/components/block-styles/index.js.map +1 -1
  13. package/build/components/block-tools/use-block-toolbar-popover-props.js +43 -10
  14. package/build/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  15. package/build/components/default-style-picker/index.js +1 -0
  16. package/build/components/default-style-picker/index.js.map +1 -1
  17. package/build/components/font-sizes/with-font-sizes.js +5 -8
  18. package/build/components/font-sizes/with-font-sizes.js.map +1 -1
  19. package/build/components/iframe/index.js +37 -8
  20. package/build/components/iframe/index.js.map +1 -1
  21. package/build/components/iframe/use-compatibility-styles.js +6 -1
  22. package/build/components/iframe/use-compatibility-styles.js.map +1 -1
  23. package/build/components/image-size-control/index.js +1 -0
  24. package/build/components/image-size-control/index.js.map +1 -1
  25. package/build/components/inserter/block-patterns-tab.js +4 -4
  26. package/build/components/inserter/block-patterns-tab.js.map +1 -1
  27. package/build/components/inserter/index.js +3 -2
  28. package/build/components/inserter/index.js.map +1 -1
  29. package/build/components/inserter/menu.js +11 -5
  30. package/build/components/inserter/menu.js.map +1 -1
  31. package/build/components/inspector-controls/groups.js +3 -1
  32. package/build/components/inspector-controls/groups.js.map +1 -1
  33. package/build/components/inspector-controls-tabs/position-controls-panel.js +46 -0
  34. package/build/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  35. package/build/components/inspector-controls-tabs/settings-tab.js +3 -1
  36. package/build/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  37. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  38. package/build/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  39. package/build/components/link-control/search-input.js +1 -0
  40. package/build/components/link-control/search-input.js.map +1 -1
  41. package/build/components/off-canvas-editor/appender.js +2 -38
  42. package/build/components/off-canvas-editor/appender.js.map +1 -1
  43. package/build/components/off-canvas-editor/block-contents.js +38 -5
  44. package/build/components/off-canvas-editor/block-contents.js.map +1 -1
  45. package/build/components/off-canvas-editor/block.js +7 -25
  46. package/build/components/off-canvas-editor/block.js.map +1 -1
  47. package/build/components/off-canvas-editor/index.js +7 -4
  48. package/build/components/off-canvas-editor/index.js.map +1 -1
  49. package/build/components/provider/index.js +3 -1
  50. package/build/components/provider/index.js.map +1 -1
  51. package/build/components/rich-text/use-enter.js +4 -5
  52. package/build/components/rich-text/use-enter.js.map +1 -1
  53. package/build/components/url-input/button.js +1 -0
  54. package/build/components/url-input/button.js.map +1 -1
  55. package/build/components/url-input/index.js +15 -1
  56. package/build/components/url-input/index.js.map +1 -1
  57. package/build/components/url-popover/link-editor.js +1 -0
  58. package/build/components/url-popover/link-editor.js.map +1 -1
  59. package/build/components/use-paste-styles/index.js +188 -0
  60. package/build/components/use-paste-styles/index.js.map +1 -0
  61. package/build/components/writing-flow/use-arrow-nav.js +22 -29
  62. package/build/components/writing-flow/use-arrow-nav.js.map +1 -1
  63. package/build/hooks/index.js +2 -0
  64. package/build/hooks/index.js.map +1 -1
  65. package/build/hooks/metadata.js +1 -1
  66. package/build/hooks/metadata.js.map +1 -1
  67. package/build/hooks/position.js +376 -0
  68. package/build/hooks/position.js.map +1 -0
  69. package/build/hooks/supports.js +328 -0
  70. package/build/hooks/supports.js.map +1 -0
  71. package/build/store/reducer.js +6 -2
  72. package/build/store/reducer.js.map +1 -1
  73. package/build/store/selectors.js +8 -6
  74. package/build/store/selectors.js.map +1 -1
  75. package/build-module/components/block-actions/index.js +6 -0
  76. package/build-module/components/block-actions/index.js.map +1 -1
  77. package/build-module/components/block-inspector/index.js +3 -2
  78. package/build-module/components/block-inspector/index.js.map +1 -1
  79. package/build-module/components/block-preview/auto.js +1 -4
  80. package/build-module/components/block-preview/auto.js.map +1 -1
  81. package/build-module/components/block-settings-menu/block-settings-dropdown.js +4 -1
  82. package/build-module/components/block-settings-menu/block-settings-dropdown.js.map +1 -1
  83. package/build-module/components/block-styles/index.js +2 -1
  84. package/build-module/components/block-styles/index.js.map +1 -1
  85. package/build-module/components/block-tools/use-block-toolbar-popover-props.js +42 -11
  86. package/build-module/components/block-tools/use-block-toolbar-popover-props.js.map +1 -1
  87. package/build-module/components/default-style-picker/index.js +1 -0
  88. package/build-module/components/default-style-picker/index.js.map +1 -1
  89. package/build-module/components/font-sizes/with-font-sizes.js +5 -7
  90. package/build-module/components/font-sizes/with-font-sizes.js.map +1 -1
  91. package/build-module/components/iframe/index.js +36 -9
  92. package/build-module/components/iframe/index.js.map +1 -1
  93. package/build-module/components/iframe/use-compatibility-styles.js +6 -1
  94. package/build-module/components/iframe/use-compatibility-styles.js.map +1 -1
  95. package/build-module/components/image-size-control/index.js +1 -0
  96. package/build-module/components/image-size-control/index.js.map +1 -1
  97. package/build-module/components/inserter/block-patterns-tab.js +4 -4
  98. package/build-module/components/inserter/block-patterns-tab.js.map +1 -1
  99. package/build-module/components/inserter/index.js +3 -2
  100. package/build-module/components/inserter/index.js.map +1 -1
  101. package/build-module/components/inserter/menu.js +11 -5
  102. package/build-module/components/inserter/menu.js.map +1 -1
  103. package/build-module/components/inspector-controls/groups.js +3 -1
  104. package/build-module/components/inspector-controls/groups.js.map +1 -1
  105. package/build-module/components/inspector-controls-tabs/position-controls-panel.js +33 -0
  106. package/build-module/components/inspector-controls-tabs/position-controls-panel.js.map +1 -0
  107. package/build-module/components/inspector-controls-tabs/settings-tab.js +2 -1
  108. package/build-module/components/inspector-controls-tabs/settings-tab.js.map +1 -1
  109. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js +4 -11
  110. package/build-module/components/inspector-controls-tabs/use-inspector-controls-tabs.js.map +1 -1
  111. package/build-module/components/link-control/search-input.js +1 -0
  112. package/build-module/components/link-control/search-input.js.map +1 -1
  113. package/build-module/components/off-canvas-editor/appender.js +3 -36
  114. package/build-module/components/off-canvas-editor/appender.js.map +1 -1
  115. package/build-module/components/off-canvas-editor/block-contents.js +37 -7
  116. package/build-module/components/off-canvas-editor/block-contents.js.map +1 -1
  117. package/build-module/components/off-canvas-editor/block.js +9 -27
  118. package/build-module/components/off-canvas-editor/block.js.map +1 -1
  119. package/build-module/components/off-canvas-editor/index.js +7 -4
  120. package/build-module/components/off-canvas-editor/index.js.map +1 -1
  121. package/build-module/components/provider/index.js +3 -1
  122. package/build-module/components/provider/index.js.map +1 -1
  123. package/build-module/components/rich-text/use-enter.js +4 -5
  124. package/build-module/components/rich-text/use-enter.js.map +1 -1
  125. package/build-module/components/url-input/button.js +1 -0
  126. package/build-module/components/url-input/button.js.map +1 -1
  127. package/build-module/components/url-input/index.js +14 -1
  128. package/build-module/components/url-input/index.js.map +1 -1
  129. package/build-module/components/url-popover/link-editor.js +1 -0
  130. package/build-module/components/url-popover/link-editor.js.map +1 -1
  131. package/build-module/components/use-paste-styles/index.js +174 -0
  132. package/build-module/components/use-paste-styles/index.js.map +1 -0
  133. package/build-module/components/writing-flow/use-arrow-nav.js +22 -29
  134. package/build-module/components/writing-flow/use-arrow-nav.js.map +1 -1
  135. package/build-module/hooks/index.js +1 -0
  136. package/build-module/hooks/index.js.map +1 -1
  137. package/build-module/hooks/metadata.js +1 -1
  138. package/build-module/hooks/metadata.js.map +1 -1
  139. package/build-module/hooks/position.js +337 -0
  140. package/build-module/hooks/position.js.map +1 -0
  141. package/build-module/hooks/supports.js +257 -0
  142. package/build-module/hooks/supports.js.map +1 -0
  143. package/build-module/store/reducer.js +6 -2
  144. package/build-module/store/reducer.js.map +1 -1
  145. package/build-module/store/selectors.js +7 -5
  146. package/build-module/store/selectors.js.map +1 -1
  147. package/build-style/content-rtl.css +57 -0
  148. package/build-style/content.css +57 -0
  149. package/build-style/style-rtl.css +27 -58
  150. package/build-style/style.css +27 -58
  151. package/package.json +29 -29
  152. package/src/components/block-actions/index.js +5 -0
  153. package/src/components/block-inspector/index.js +3 -1
  154. package/src/components/block-preview/auto.js +2 -4
  155. package/src/components/block-settings-menu/block-settings-dropdown.js +4 -0
  156. package/src/components/block-styles/index.js +4 -1
  157. package/src/components/block-tools/use-block-toolbar-popover-props.js +68 -12
  158. package/src/components/button-block-appender/{style.scss → content.scss} +0 -0
  159. package/src/components/default-style-picker/index.js +1 -0
  160. package/src/components/font-sizes/with-font-sizes.js +33 -33
  161. package/src/components/iframe/index.js +52 -19
  162. package/src/components/iframe/use-compatibility-styles.js +6 -0
  163. package/src/components/image-size-control/index.js +1 -0
  164. package/src/components/inserter/block-patterns-tab.js +7 -4
  165. package/src/components/inserter/index.js +46 -41
  166. package/src/components/inserter/menu.js +8 -4
  167. package/src/components/inserter/test/__snapshots__/index.native.js.snap +117 -0
  168. package/src/components/inserter/test/index.native.js +255 -1
  169. package/src/components/inspector-controls/groups.js +2 -0
  170. package/src/components/inspector-controls-tabs/position-controls-panel.js +37 -0
  171. package/src/components/inspector-controls-tabs/settings-tab.js +2 -0
  172. package/src/components/inspector-controls-tabs/style.scss +15 -0
  173. package/src/components/inspector-controls-tabs/use-inspector-controls-tabs.js +3 -8
  174. package/src/components/link-control/search-input.js +1 -0
  175. package/src/components/link-control/style.scss +1 -0
  176. package/src/components/list-view/style.scss +13 -3
  177. package/src/components/off-canvas-editor/appender.js +2 -52
  178. package/src/components/off-canvas-editor/block-contents.js +84 -23
  179. package/src/components/off-canvas-editor/block.js +28 -60
  180. package/src/components/off-canvas-editor/index.js +12 -2
  181. package/src/components/provider/index.js +4 -1
  182. package/src/components/rich-text/use-enter.js +4 -4
  183. package/src/components/url-input/README.md +5 -0
  184. package/src/components/url-input/button.js +1 -0
  185. package/src/components/url-input/index.js +15 -1
  186. package/src/components/url-popover/link-editor.js +1 -0
  187. package/src/components/use-paste-styles/index.js +230 -0
  188. package/src/components/writing-flow/use-arrow-nav.js +20 -28
  189. package/src/content.scss +1 -0
  190. package/src/hooks/index.js +1 -0
  191. package/src/hooks/metadata.js +1 -2
  192. package/src/hooks/position.js +375 -0
  193. package/src/hooks/position.scss +18 -0
  194. package/src/hooks/supports.js +302 -0
  195. package/src/hooks/test/__snapshots__/align.native.js.snap +73 -0
  196. package/src/hooks/test/align.native.js +133 -0
  197. package/src/store/reducer.js +7 -2
  198. package/src/store/selectors.js +5 -5
  199. package/src/store/test/reducer.js +45 -3
  200. package/src/store/test/selectors.js +12 -9
  201. package/src/style.scss +2 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["classnames","scrollIntoView","__","sprintf","_n","Component","createRef","UP","DOWN","ENTER","TAB","BaseControl","Button","Spinner","withSpokenMessages","Popover","compose","debounce","withInstanceId","withSafeTimeout","withSelect","isURL","store","blockEditorStore","isFunction","maybeFunc","URLInput","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","suggestionsRequest","state","suggestions","showSuggestions","isUpdatingSuggestions","suggestionsValue","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","target","keyCode","selectionStart","preventDefault","setSelectionRange","onSubmit","suggestion","previousIndex","nextIndex","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","currentInputValue","map","title","select","getSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,EAAsBC,EAAtB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,SAApB,QAAqC,oBAArC;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,KAAnB,EAA0BC,GAA1B,QAAqC,qBAArC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,OAHD,EAICC,kBAJD,EAKCC,OALD,QAMO,uBANP;AAOA,SACCC,OADD,EAECC,QAFD,EAGCC,cAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBrB,SAAvB,CAAiC;AAChCsB,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UA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B,CAAEa,MAApB,CAPG;AAQzB0D,QAAAA,iBAAiB,EAAEvE;AARM,OAAF,CAAxB;AAUA;;AAED,WACC,cAAC,OAAD;AAAS,MAAA,SAAS,EAAC,QAAnB;AAA4B,MAAA,YAAY,EAAG;AAA3C,OACC,kCACMkE,oBADN;AAEC,MAAA,SAAS,EAAG/G,UAAU,CACrB,qCADqB,EAEpB,GAAGkG,SAAW,eAFM;AAFvB,QAOGxD,WAAW,CAAC2E,GAAZ,CAAiB,CAAEjC,UAAF,EAAcrB,KAAd,KAClB,cAAC,MAAD,eACMiD,wBAAwB,CAAE5B,UAAF,EAAcrB,KAAd,CAD9B;AAEC,MAAA,GAAG,EAAGqB,UAAU,CAACoB,EAFlB;AAGC,MAAA,SAAS,EAAGxG,UAAU,CACrB,oCADqB,EAErB;AACC,uBAAe+D,KAAK,KAAKjB;AAD1B,OAFqB,CAHvB;AASC,MAAA,OAAO,EAAG,MAAM,KAAKZ,aAAL,CAAoBkD,UAApB;AATjB,QAWGA,UAAU,CAACkC,KAXd,CADC,CAPH,CADD,CADD;AA2BA;;AAxgB+B;AA2gBjC;AACA;AACA;;;AACA,eAAetG,OAAO,CACrBG,eADqB,EAErBL,kBAFqB,EAGrBI,cAHqB,EAIrBE,UAAU,CAAE,CAAEmG,MAAF,EAAU3F,KAAV,KAAqB;AAChC;AACA;AACA,MAAKJ,UAAU,CAAEI,KAAK,CAACqC,kCAAR,CAAf,EAA8D;AAC7D;AACA;;AACD,QAAM;AAAEuD,IAAAA;AAAF,MAAkBD,MAAM,CAAEhG,gBAAF,CAA9B;AACA,SAAO;AACN0C,IAAAA,kCAAkC,EACjCuD,WAAW,GAAGvD;AAFT,GAAP;AAIA,CAXS,CAJW,CAAP,CAgBZvC,QAhBY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.suggestionsRequest = null;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tisUpdatingSuggestions: false,\n\t\t\tsuggestionsValue: null,\n\t\t\tselectedSuggestion: null,\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tthis.suggestionsRequest = null;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t__experimentalShowInitialSuggestions && ! ( value && value.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.suggestionsRequest?.cancel?.();\n\t\t\tthis.suggestionsRequest = null;\n\n\t\t\tthis.setState( {\n\t\t\t\tsuggestions: [],\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tsuggestionsValue: value,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisUpdatingSuggestions: true,\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tsuggestionsValue: value,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tloading: false,\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tthis.props.onChange( event.target.value );\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl { ...controlProps }>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tsuggestionsValue,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tif ( ! showSuggestions || suggestions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif ( isFunction( renderSuggestions ) ) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions: ! suggestionsValue?.length,\n\t\t\t\tcurrentInputValue: suggestionsValue,\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...buildSuggestionItemProps( suggestion, index ) }\n\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedSuggestion,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => this.handleOnClick( suggestion ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-input/index.js"],"names":["classnames","scrollIntoView","deprecated","__","sprintf","_n","Component","createRef","UP","DOWN","ENTER","TAB","BaseControl","Button","Spinner","withSpokenMessages","Popover","compose","debounce","withInstanceId","withSafeTimeout","withSelect","isURL","store","blockEditorStore","isFunction","maybeFunc","URLInput","constructor","props","onChange","bind","onFocus","onKeyDown","selectLink","handleOnClick","bindSuggestionNode","autocompleteRef","inputRef","updateSuggestions","suggestionNodes","suggestionsRequest","state","suggestions","showSuggestions","isUpdatingSuggestions","suggestionsValue","selectedSuggestion","suggestionsListboxId","suggestionOptionIdPrefix","componentDidUpdate","prevProps","value","__experimentalShowInitialSuggestions","scrollingIntoView","current","onlyScrollIfNeeded","setTimeout","disableSuggestions","length","componentDidMount","shouldShowInitialSuggestions","componentWillUnmount","cancel","index","ref","__experimentalFetchLinkSuggestions","fetchLinkSuggestions","__experimentalHandleURLSuggestions","handleURLSuggestions","isInitialSuggestions","trim","setState","loading","request","then","debouncedSpeak","catch","event","target","keyCode","selectionStart","preventDefault","setSelectionRange","onSubmit","suggestion","previousIndex","nextIndex","speak","url","focus","getDerivedStateFromProps","instanceId","shouldShowSuggestions","hasValue","render","renderControl","renderSuggestions","__nextHasNoMarginBottom","label","className","isFullWidth","placeholder","__experimentalRenderControl","inputId","controlProps","id","inputProps","required","type","role","undefined","since","version","hint","__experimentalRenderSuggestions","suggestionsListProps","buildSuggestionItemProps","tabIndex","isLoading","handleSuggestionClick","currentInputValue","map","title","select","getSettings"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,OAAOC,cAAP,MAA2B,sBAA3B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,uBAAvB;AACA,SAASC,EAAT,EAAaC,OAAb,EAAsBC,EAAtB,QAAgC,iBAAhC;AACA,SAASC,SAAT,EAAoBC,SAApB,QAAqC,oBAArC;AACA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,KAAnB,EAA0BC,GAA1B,QAAqC,qBAArC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,OAHD,EAICC,kBAJD,EAKCC,OALD,QAMO,uBANP;AAOA,SACCC,OADD,EAECC,QAFD,EAGCC,cAHD,EAICC,eAJD,QAKO,oBALP;AAMA,SAASC,UAAT,QAA2B,iBAA3B;AACA,SAASC,KAAT,QAAsB,gBAAtB;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,UAAT,CAAqBC,SAArB,EAAiC;AAChC,SAAO,OAAOA,SAAP,KAAqB,UAA5B;AACA;;AAED,MAAMC,QAAN,SAAuBrB,SAAvB,CAAiC;AAChCsB,EAAAA,WAAW,CAAEC,KAAF,EAAU;AACpB,UAAOA,KAAP;AAEA,SAAKC,QAAL,GAAgB,KAAKA,QAAL,CAAcC,IAAd,CAAoB,IAApB,CAAhB;AACA,SAAKC,OAAL,GAAe,KAAKA,OAAL,CAAaD,IAAb,CAAmB,IAAnB,CAAf;AACA,SAAKE,SAAL,GAAiB,KAAKA,SAAL,CAAeF,IAAf,CAAqB,IAArB,CAAjB;AACA,SAAKG,UAAL,GAAkB,KAAKA,UAAL,CAAgBH,IAAhB,CAAsB,IAAtB,CAAlB;A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W,GAAG3D;AAFT,GAAP;AAIA,CAXS,CAJW,CAAP,CAgBZvC,QAhBY,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport scrollIntoView from 'dom-scroll-into-view';\n\n/**\n * WordPress dependencies\n */\nimport deprecated from '@wordpress/deprecated';\nimport { __, sprintf, _n } from '@wordpress/i18n';\nimport { Component, createRef } from '@wordpress/element';\nimport { UP, DOWN, ENTER, TAB } from '@wordpress/keycodes';\nimport {\n\tBaseControl,\n\tButton,\n\tSpinner,\n\twithSpokenMessages,\n\tPopover,\n} from '@wordpress/components';\nimport {\n\tcompose,\n\tdebounce,\n\twithInstanceId,\n\twithSafeTimeout,\n} from '@wordpress/compose';\nimport { withSelect } from '@wordpress/data';\nimport { isURL } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Whether the argument is a function.\n *\n * @param {*} maybeFunc The argument to check.\n * @return {boolean} True if the argument is a function, false otherwise.\n */\nfunction isFunction( maybeFunc ) {\n\treturn typeof maybeFunc === 'function';\n}\n\nclass URLInput extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\n\t\tthis.onChange = this.onChange.bind( this );\n\t\tthis.onFocus = this.onFocus.bind( this );\n\t\tthis.onKeyDown = this.onKeyDown.bind( this );\n\t\tthis.selectLink = this.selectLink.bind( this );\n\t\tthis.handleOnClick = this.handleOnClick.bind( this );\n\t\tthis.bindSuggestionNode = this.bindSuggestionNode.bind( this );\n\t\tthis.autocompleteRef = props.autocompleteRef || createRef();\n\t\tthis.inputRef = createRef();\n\t\tthis.updateSuggestions = debounce(\n\t\t\tthis.updateSuggestions.bind( this ),\n\t\t\t200\n\t\t);\n\n\t\tthis.suggestionNodes = [];\n\n\t\tthis.suggestionsRequest = null;\n\n\t\tthis.state = {\n\t\t\tsuggestions: [],\n\t\t\tshowSuggestions: false,\n\t\t\tisUpdatingSuggestions: false,\n\t\t\tsuggestionsValue: null,\n\t\t\tselectedSuggestion: null,\n\t\t\tsuggestionsListboxId: '',\n\t\t\tsuggestionOptionIdPrefix: '',\n\t\t};\n\t}\n\n\tcomponentDidUpdate( prevProps ) {\n\t\tconst { showSuggestions, selectedSuggestion } = this.state;\n\t\tconst { value, __experimentalShowInitialSuggestions = false } =\n\t\t\tthis.props;\n\n\t\t// Only have to worry about scrolling selected suggestion into view\n\t\t// when already expanded.\n\t\tif (\n\t\t\tshowSuggestions &&\n\t\t\tselectedSuggestion !== null &&\n\t\t\tthis.suggestionNodes[ selectedSuggestion ] &&\n\t\t\t! this.scrollingIntoView\n\t\t) {\n\t\t\tthis.scrollingIntoView = true;\n\t\t\tscrollIntoView(\n\t\t\t\tthis.suggestionNodes[ selectedSuggestion ],\n\t\t\t\tthis.autocompleteRef.current,\n\t\t\t\t{\n\t\t\t\t\tonlyScrollIfNeeded: true,\n\t\t\t\t}\n\t\t\t);\n\n\t\t\tthis.props.setTimeout( () => {\n\t\t\t\tthis.scrollingIntoView = false;\n\t\t\t}, 100 );\n\t\t}\n\n\t\t// Update suggestions when the value changes.\n\t\tif (\n\t\t\tprevProps.value !== value &&\n\t\t\t! this.props.disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions\n\t\t) {\n\t\t\tif ( value?.length ) {\n\t\t\t\t// If the new value is not empty we need to update with suggestions for it.\n\t\t\t\tthis.updateSuggestions( value );\n\t\t\t} else if ( __experimentalShowInitialSuggestions ) {\n\t\t\t\t// If the new value is empty and we can show initial suggestions, then show initial suggestions.\n\t\t\t\tthis.updateSuggestions();\n\t\t\t}\n\t\t}\n\t}\n\n\tcomponentDidMount() {\n\t\tif ( this.shouldShowInitialSuggestions() ) {\n\t\t\tthis.updateSuggestions();\n\t\t}\n\t}\n\n\tcomponentWillUnmount() {\n\t\tthis.suggestionsRequest?.cancel?.();\n\t\tthis.suggestionsRequest = null;\n\t}\n\n\tbindSuggestionNode( index ) {\n\t\treturn ( ref ) => {\n\t\t\tthis.suggestionNodes[ index ] = ref;\n\t\t};\n\t}\n\n\tshouldShowInitialSuggestions() {\n\t\tconst { __experimentalShowInitialSuggestions = false, value } =\n\t\t\tthis.props;\n\t\treturn (\n\t\t\t__experimentalShowInitialSuggestions && ! ( value && value.length )\n\t\t);\n\t}\n\n\tupdateSuggestions( value = '' ) {\n\t\tconst {\n\t\t\t__experimentalFetchLinkSuggestions: fetchLinkSuggestions,\n\t\t\t__experimentalHandleURLSuggestions: handleURLSuggestions,\n\t\t} = this.props;\n\n\t\tif ( ! fetchLinkSuggestions ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Initial suggestions may only show if there is no value\n\t\t// (note: this includes whitespace).\n\t\tconst isInitialSuggestions = ! value?.length;\n\n\t\t// Trim only now we've determined whether or not it originally had a \"length\"\n\t\t// (even if that value was all whitespace).\n\t\tvalue = value.trim();\n\n\t\t// Allow a suggestions request if:\n\t\t// - there are at least 2 characters in the search input (except manual searches where\n\t\t// search input length is not required to trigger a fetch)\n\t\t// - this is a direct entry (eg: a URL)\n\t\tif (\n\t\t\t! isInitialSuggestions &&\n\t\t\t( value.length < 2 || ( ! handleURLSuggestions && isURL( value ) ) )\n\t\t) {\n\t\t\tthis.suggestionsRequest?.cancel?.();\n\t\t\tthis.suggestionsRequest = null;\n\n\t\t\tthis.setState( {\n\t\t\t\tsuggestions: [],\n\t\t\t\tshowSuggestions: false,\n\t\t\t\tsuggestionsValue: value,\n\t\t\t\tselectedSuggestion: null,\n\t\t\t\tloading: false,\n\t\t\t} );\n\n\t\t\treturn;\n\t\t}\n\n\t\tthis.setState( {\n\t\t\tisUpdatingSuggestions: true,\n\t\t\tselectedSuggestion: null,\n\t\t\tloading: true,\n\t\t} );\n\n\t\tconst request = fetchLinkSuggestions( value, {\n\t\t\tisInitialSuggestions,\n\t\t} );\n\n\t\trequest\n\t\t\t.then( ( suggestions ) => {\n\t\t\t\t// A fetch Promise doesn't have an abort option. It's mimicked by\n\t\t\t\t// comparing the request reference in on the instance, which is\n\t\t\t\t// reset or deleted on subsequent requests or unmounting.\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tsuggestions,\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tsuggestionsValue: value,\n\t\t\t\t\tloading: false,\n\t\t\t\t\tshowSuggestions: !! suggestions.length,\n\t\t\t\t} );\n\n\t\t\t\tif ( !! suggestions.length ) {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %s: number of results. */\n\t\t\t\t\t\t\t_n(\n\t\t\t\t\t\t\t\t'%d result found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\t'%d results found, use up and down arrow keys to navigate.',\n\t\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tsuggestions.length\n\t\t\t\t\t\t),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tthis.props.debouncedSpeak(\n\t\t\t\t\t\t__( 'No results.' ),\n\t\t\t\t\t\t'assertive'\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tif ( this.suggestionsRequest !== request ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.setState( {\n\t\t\t\t\tisUpdatingSuggestions: false,\n\t\t\t\t\tloading: false,\n\t\t\t\t} );\n\t\t\t} );\n\n\t\t// Note that this assignment is handled *before* the async search request\n\t\t// as a Promise always resolves on the next tick of the event loop.\n\t\tthis.suggestionsRequest = request;\n\t}\n\n\tonChange( event ) {\n\t\tthis.props.onChange( event.target.value );\n\t}\n\n\tonFocus() {\n\t\tconst { suggestions } = this.state;\n\t\tconst { disableSuggestions, value } = this.props;\n\n\t\t// When opening the link editor, if there's a value present, we want to load the suggestions pane with the results for this input search value\n\t\t// Don't re-run the suggestions on focus if there are already suggestions present (prevents searching again when tabbing between the input and buttons)\n\t\tif (\n\t\t\tvalue &&\n\t\t\t! disableSuggestions &&\n\t\t\t! this.state.isUpdatingSuggestions &&\n\t\t\t! ( suggestions && suggestions.length )\n\t\t) {\n\t\t\t// Ensure the suggestions are updated with the current input value.\n\t\t\tthis.updateSuggestions( value );\n\t\t}\n\t}\n\n\tonKeyDown( event ) {\n\t\tconst { showSuggestions, selectedSuggestion, suggestions, loading } =\n\t\t\tthis.state;\n\n\t\t// If the suggestions are not shown or loading, we shouldn't handle the arrow keys\n\t\t// We shouldn't preventDefault to allow block arrow keys navigation.\n\t\tif ( ! showSuggestions || ! suggestions.length || loading ) {\n\t\t\t// In the Windows version of Firefox the up and down arrows don't move the caret\n\t\t\t// within an input field like they do for Mac Firefox/Chrome/Safari. This causes\n\t\t\t// a form of focus trapping that is disruptive to the user experience. This disruption\n\t\t\t// only happens if the caret is not in the first or last position in the text input.\n\t\t\t// See: https://github.com/WordPress/gutenberg/issues/5693#issuecomment-436684747\n\t\t\tswitch ( event.keyCode ) {\n\t\t\t\t// When UP is pressed, if the caret is at the start of the text, move it to the 0\n\t\t\t\t// position.\n\t\t\t\tcase UP: {\n\t\t\t\t\tif ( 0 !== event.target.selectionStart ) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to position 0.\n\t\t\t\t\t\tevent.target.setSelectionRange( 0, 0 );\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t// When DOWN is pressed, if the caret is not at the end of the text, move it to the\n\t\t\t\t// last position.\n\t\t\t\tcase DOWN: {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.props.value.length !== event.target.selectionStart\n\t\t\t\t\t) {\n\t\t\t\t\t\tevent.preventDefault();\n\n\t\t\t\t\t\t// Set the input caret to the last position.\n\t\t\t\t\t\tevent.target.setSelectionRange(\n\t\t\t\t\t\t\tthis.props.value.length,\n\t\t\t\t\t\t\tthis.props.value.length\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\n\t\t\t\t// Submitting while loading should trigger onSubmit.\n\t\t\t\tcase ENTER: {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tconst suggestion =\n\t\t\tthis.state.suggestions[ this.state.selectedSuggestion ];\n\n\t\tswitch ( event.keyCode ) {\n\t\t\tcase UP: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst previousIndex = ! selectedSuggestion\n\t\t\t\t\t? suggestions.length - 1\n\t\t\t\t\t: selectedSuggestion - 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: previousIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase DOWN: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tconst nextIndex =\n\t\t\t\t\tselectedSuggestion === null ||\n\t\t\t\t\tselectedSuggestion === suggestions.length - 1\n\t\t\t\t\t\t? 0\n\t\t\t\t\t\t: selectedSuggestion + 1;\n\t\t\t\tthis.setState( {\n\t\t\t\t\tselectedSuggestion: nextIndex,\n\t\t\t\t} );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase TAB: {\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\t\t\t\t\t// Announce a link has been selected when tabbing away from the input field.\n\t\t\t\t\tthis.props.speak( __( 'Link selected.' ) );\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase ENTER: {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( this.state.selectedSuggestion !== null ) {\n\t\t\t\t\tthis.selectLink( suggestion );\n\n\t\t\t\t\tif ( this.props.onSubmit ) {\n\t\t\t\t\t\tthis.props.onSubmit( suggestion, event );\n\t\t\t\t\t}\n\t\t\t\t} else if ( this.props.onSubmit ) {\n\t\t\t\t\tthis.props.onSubmit( null, event );\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tselectLink( suggestion ) {\n\t\tthis.props.onChange( suggestion.url, suggestion );\n\t\tthis.setState( {\n\t\t\tselectedSuggestion: null,\n\t\t\tshowSuggestions: false,\n\t\t} );\n\t}\n\n\thandleOnClick( suggestion ) {\n\t\tthis.selectLink( suggestion );\n\t\t// Move focus to the input field when a link suggestion is clicked.\n\t\tthis.inputRef.current.focus();\n\t}\n\n\tstatic getDerivedStateFromProps(\n\t\t{\n\t\t\tvalue,\n\t\t\tinstanceId,\n\t\t\tdisableSuggestions,\n\t\t\t__experimentalShowInitialSuggestions = false,\n\t\t},\n\t\t{ showSuggestions }\n\t) {\n\t\tlet shouldShowSuggestions = showSuggestions;\n\n\t\tconst hasValue = value && value.length;\n\n\t\tif ( ! __experimentalShowInitialSuggestions && ! hasValue ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\tif ( disableSuggestions === true ) {\n\t\t\tshouldShowSuggestions = false;\n\t\t}\n\n\t\treturn {\n\t\t\tshowSuggestions: shouldShowSuggestions,\n\t\t\tsuggestionsListboxId: `block-editor-url-input-suggestions-${ instanceId }`,\n\t\t\tsuggestionOptionIdPrefix: `block-editor-url-input-suggestion-${ instanceId }`,\n\t\t};\n\t}\n\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ this.renderControl() }\n\t\t\t\t{ this.renderSuggestions() }\n\t\t\t</>\n\t\t);\n\t}\n\n\trenderControl() {\n\t\tconst {\n\t\t\t/** Start opting into the new margin-free styles that will become the default in a future version. */\n\t\t\t__nextHasNoMarginBottom = false,\n\t\t\tlabel = null,\n\t\t\tclassName,\n\t\t\tisFullWidth,\n\t\t\tinstanceId,\n\t\t\tplaceholder = __( 'Paste URL or type to search' ),\n\t\t\t__experimentalRenderControl: renderControl,\n\t\t\tvalue = '',\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tloading,\n\t\t\tshowSuggestions,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t} = this.state;\n\n\t\tconst inputId = `url-input-control-${ instanceId }`;\n\n\t\tconst controlProps = {\n\t\t\tid: inputId, // Passes attribute to label for the for attribute\n\t\t\tlabel,\n\t\t\tclassName: classnames( 'block-editor-url-input', className, {\n\t\t\t\t'is-full-width': isFullWidth,\n\t\t\t} ),\n\t\t};\n\n\t\tconst inputProps = {\n\t\t\tid: inputId,\n\t\t\tvalue,\n\t\t\trequired: true,\n\t\t\tclassName: 'block-editor-url-input__input',\n\t\t\ttype: 'text',\n\t\t\tonChange: this.onChange,\n\t\t\tonFocus: this.onFocus,\n\t\t\tplaceholder,\n\t\t\tonKeyDown: this.onKeyDown,\n\t\t\trole: 'combobox',\n\t\t\t'aria-label': label ? undefined : __( 'URL' ), // Ensure input always has an accessible label\n\t\t\t'aria-expanded': showSuggestions,\n\t\t\t'aria-autocomplete': 'list',\n\t\t\t'aria-controls': suggestionsListboxId,\n\t\t\t'aria-activedescendant':\n\t\t\t\tselectedSuggestion !== null\n\t\t\t\t\t? `${ suggestionOptionIdPrefix }-${ selectedSuggestion }`\n\t\t\t\t\t: undefined,\n\t\t\tref: this.inputRef,\n\t\t};\n\n\t\tif ( renderControl ) {\n\t\t\treturn renderControl( controlProps, inputProps, loading );\n\t\t}\n\n\t\tif ( ! __nextHasNoMarginBottom ) {\n\t\t\tdeprecated( 'Bottom margin styles for wp.blockEditor.URLInput', {\n\t\t\t\tsince: '6.2',\n\t\t\t\tversion: '6.5',\n\t\t\t\thint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version',\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<BaseControl\n\t\t\t\t__nextHasNoMarginBottom={ __nextHasNoMarginBottom }\n\t\t\t\t{ ...controlProps }\n\t\t\t>\n\t\t\t\t<input { ...inputProps } />\n\t\t\t\t{ loading && <Spinner /> }\n\t\t\t</BaseControl>\n\t\t);\n\t}\n\n\trenderSuggestions() {\n\t\tconst {\n\t\t\tclassName,\n\t\t\t__experimentalRenderSuggestions: renderSuggestions,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tshowSuggestions,\n\t\t\tsuggestions,\n\t\t\tsuggestionsValue,\n\t\t\tselectedSuggestion,\n\t\t\tsuggestionsListboxId,\n\t\t\tsuggestionOptionIdPrefix,\n\t\t\tloading,\n\t\t} = this.state;\n\n\t\tif ( ! showSuggestions || suggestions.length === 0 ) {\n\t\t\treturn null;\n\t\t}\n\n\t\tconst suggestionsListProps = {\n\t\t\tid: suggestionsListboxId,\n\t\t\tref: this.autocompleteRef,\n\t\t\trole: 'listbox',\n\t\t};\n\n\t\tconst buildSuggestionItemProps = ( suggestion, index ) => {\n\t\t\treturn {\n\t\t\t\trole: 'option',\n\t\t\t\ttabIndex: '-1',\n\t\t\t\tid: `${ suggestionOptionIdPrefix }-${ index }`,\n\t\t\t\tref: this.bindSuggestionNode( index ),\n\t\t\t\t'aria-selected': index === selectedSuggestion,\n\t\t\t};\n\t\t};\n\n\t\tif ( isFunction( renderSuggestions ) ) {\n\t\t\treturn renderSuggestions( {\n\t\t\t\tsuggestions,\n\t\t\t\tselectedSuggestion,\n\t\t\t\tsuggestionsListProps,\n\t\t\t\tbuildSuggestionItemProps,\n\t\t\t\tisLoading: loading,\n\t\t\t\thandleSuggestionClick: this.handleOnClick,\n\t\t\t\tisInitialSuggestions: ! suggestionsValue?.length,\n\t\t\t\tcurrentInputValue: suggestionsValue,\n\t\t\t} );\n\t\t}\n\n\t\treturn (\n\t\t\t<Popover placement=\"bottom\" focusOnMount={ false }>\n\t\t\t\t<div\n\t\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-url-input__suggestions',\n\t\t\t\t\t\t`${ className }__suggestions`\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t{ ...buildSuggestionItemProps( suggestion, index ) }\n\t\t\t\t\t\t\tkey={ suggestion.id }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-url-input__suggestion',\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t'is-selected': index === selectedSuggestion,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tonClick={ () => this.handleOnClick( suggestion ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ suggestion.title }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t) ) }\n\t\t\t\t</div>\n\t\t\t</Popover>\n\t\t);\n\t}\n}\n\n/**\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/block-editor/src/components/url-input/README.md\n */\nexport default compose(\n\twithSafeTimeout,\n\twithSpokenMessages,\n\twithInstanceId,\n\twithSelect( ( select, props ) => {\n\t\t// If a link suggestions handler is already provided then\n\t\t// bail.\n\t\tif ( isFunction( props.__experimentalFetchLinkSuggestions ) ) {\n\t\t\treturn;\n\t\t}\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\t__experimentalFetchLinkSuggestions:\n\t\t\t\tgetSettings().__experimentalFetchLinkSuggestions,\n\t\t};\n\t} )\n)( URLInput );\n"]}
@@ -28,6 +28,7 @@ export default function LinkEditor(_ref) {
28
28
  return createElement("form", _extends({
29
29
  className: classnames('block-editor-url-popover__link-editor', className)
30
30
  }, props), createElement(URLInput, {
31
+ __nextHasNoMarginBottom: true,
31
32
  value: value,
32
33
  onChange: onChangeInputValue,
33
34
  autocompleteRef: autocompleteRef
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/link-editor.js"],"names":["classnames","__","Button","keyboardReturn","URLInput","LinkEditor","autocompleteRef","className","onChangeInputValue","value","props"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,cAArB;AAEA,eAAe,SAASC,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,eADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,kBAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAMhC;AACH,SACC;AACC,IAAA,SAAS,EAAGV,UAAU,CACrB,uCADqB,EAErBO,SAFqB;AADvB,KAKMG,KALN,GAOC,cAAC,QAAD;AACC,IAAA,KAAK,EAAGD,KADT;AAEC,IAAA,QAAQ,EAAGD,kBAFZ;AAGC,IAAA,eAAe,EAAGF;AAHnB,IAPD,EAYC,cAAC,MAAD;AACC,IAAA,IAAI,EAAGH,cADR;AAEC,IAAA,KAAK,EAAGF,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,IAAI,EAAC;AAHN,IAZD,CADD;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLInput from '../url-input';\n\nexport default function LinkEditor( {\n\tautocompleteRef,\n\tclassName,\n\tonChangeInputValue,\n\tvalue,\n\t...props\n} ) {\n\treturn (\n\t\t<form\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-url-popover__link-editor',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<URLInput\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeInputValue }\n\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/url-popover/link-editor.js"],"names":["classnames","__","Button","keyboardReturn","URLInput","LinkEditor","autocompleteRef","className","onChangeInputValue","value","props"],"mappings":";;;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,cAAT,QAA+B,kBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,QAAP,MAAqB,cAArB;AAEA,eAAe,SAASC,UAAT,OAMX;AAAA,MANgC;AACnCC,IAAAA,eADmC;AAEnCC,IAAAA,SAFmC;AAGnCC,IAAAA,kBAHmC;AAInCC,IAAAA,KAJmC;AAKnC,OAAGC;AALgC,GAMhC;AACH,SACC;AACC,IAAA,SAAS,EAAGV,UAAU,CACrB,uCADqB,EAErBO,SAFqB;AADvB,KAKMG,KALN,GAOC,cAAC,QAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAGD,KAFT;AAGC,IAAA,QAAQ,EAAGD,kBAHZ;AAIC,IAAA,eAAe,EAAGF;AAJnB,IAPD,EAaC,cAAC,MAAD;AACC,IAAA,IAAI,EAAGH,cADR;AAEC,IAAA,KAAK,EAAGF,EAAE,CAAE,OAAF,CAFX;AAGC,IAAA,IAAI,EAAC;AAHN,IAbD,CADD;AAqBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { keyboardReturn } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport URLInput from '../url-input';\n\nexport default function LinkEditor( {\n\tautocompleteRef,\n\tclassName,\n\tonChangeInputValue,\n\tvalue,\n\t...props\n} ) {\n\treturn (\n\t\t<form\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-url-popover__link-editor',\n\t\t\t\tclassName\n\t\t\t) }\n\t\t\t{ ...props }\n\t\t>\n\t\t\t<URLInput\n\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ onChangeInputValue }\n\t\t\t\tautocompleteRef={ autocompleteRef }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\ticon={ keyboardReturn }\n\t\t\t\tlabel={ __( 'Apply' ) }\n\t\t\t\ttype=\"submit\"\n\t\t\t/>\n\t\t</form>\n\t);\n}\n"]}
@@ -0,0 +1,174 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useCallback } from '@wordpress/element';
5
+ import { getBlockType, parse } from '@wordpress/blocks';
6
+ import { useDispatch, useRegistry } from '@wordpress/data';
7
+ import { store as noticesStore } from '@wordpress/notices';
8
+ import { __, sprintf } from '@wordpress/i18n';
9
+ /**
10
+ * Internal dependencies
11
+ */
12
+
13
+ import { store as blockEditorStore } from '../../store';
14
+ import { hasAlignSupport, hasBorderSupport, hasBackgroundColorSupport, hasTextColorSupport, hasGradientSupport, hasCustomClassNameSupport, hasFontFamilySupport, hasFontSizeSupport, hasLayoutSupport, hasStyleSupport } from '../../hooks/supports';
15
+ /**
16
+ * Determine if the copied text looks like serialized blocks or not.
17
+ * Since plain text will always get parsed into a freeform block,
18
+ * we check that if the parsed blocks is anything other than that.
19
+ *
20
+ * @param {string} text The copied text.
21
+ * @return {boolean} True if the text looks like serialized blocks, false otherwise.
22
+ */
23
+
24
+ function hasSerializedBlocks(text) {
25
+ try {
26
+ const blocks = parse(text, {
27
+ __unstableSkipMigrationLogs: true,
28
+ __unstableSkipAutop: true
29
+ });
30
+
31
+ if (blocks.length === 1 && blocks[0].name === 'core/freeform') {
32
+ // It's likely that the text is just plain text and not serialized blocks.
33
+ return false;
34
+ }
35
+
36
+ return true;
37
+ } catch (err) {
38
+ // Parsing error, the text is not serialized blocks.
39
+ // (Even though that it technically won't happen)
40
+ return false;
41
+ }
42
+ }
43
+ /**
44
+ * Style attributes are attributes being added in `block-editor/src/hooks/*`.
45
+ * (Except for some unrelated to style like `anchor` or `settings`.)
46
+ * They generally represent the default block supports.
47
+ */
48
+
49
+
50
+ const STYLE_ATTRIBUTES = {
51
+ align: hasAlignSupport,
52
+ borderColor: nameOrType => hasBorderSupport(nameOrType, 'color'),
53
+ backgroundColor: hasBackgroundColorSupport,
54
+ textColor: hasTextColorSupport,
55
+ gradient: hasGradientSupport,
56
+ className: hasCustomClassNameSupport,
57
+ fontFamily: hasFontFamilySupport,
58
+ fontSize: hasFontSizeSupport,
59
+ layout: hasLayoutSupport,
60
+ style: hasStyleSupport
61
+ };
62
+ /**
63
+ * Get the "style attributes" from a given block to a target block.
64
+ *
65
+ * @param {WPBlock} sourceBlock The source block.
66
+ * @param {WPBlock} targetBlock The target block.
67
+ * @return {Object} the filtered attributes object.
68
+ */
69
+
70
+ function getStyleAttributes(sourceBlock, targetBlock) {
71
+ return Object.entries(STYLE_ATTRIBUTES).reduce((attributes, _ref) => {
72
+ let [attributeKey, hasSupport] = _ref;
73
+
74
+ // Only apply the attribute if both blocks support it.
75
+ if (hasSupport(sourceBlock.name) && hasSupport(targetBlock.name)) {
76
+ // Override attributes that are not present in the block to their defaults.
77
+ attributes[attributeKey] = sourceBlock.attributes[attributeKey];
78
+ }
79
+
80
+ return attributes;
81
+ }, {});
82
+ }
83
+ /**
84
+ * Update the target blocks with style attributes recursively.
85
+ *
86
+ * @param {WPBlock[]} targetBlocks The target blocks to be updated.
87
+ * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.
88
+ * @param {Function} updateBlockAttributes The function to update the attributes.
89
+ */
90
+
91
+
92
+ function recursivelyUpdateBlockAttributes(targetBlocks, sourceBlocks, updateBlockAttributes) {
93
+ for (let index = 0; index < Math.min(sourceBlocks.length, targetBlocks.length); index += 1) {
94
+ updateBlockAttributes(targetBlocks[index].clientId, getStyleAttributes(sourceBlocks[index], targetBlocks[index]));
95
+ recursivelyUpdateBlockAttributes(targetBlocks[index].innerBlocks, sourceBlocks[index].innerBlocks, updateBlockAttributes);
96
+ }
97
+ }
98
+ /**
99
+ * A hook to return a pasteStyles event function for handling pasting styles to blocks.
100
+ *
101
+ * @return {Function} A function to update the styles to the blocks.
102
+ */
103
+
104
+
105
+ export default function usePasteStyles() {
106
+ const registry = useRegistry();
107
+ const {
108
+ updateBlockAttributes
109
+ } = useDispatch(blockEditorStore);
110
+ const {
111
+ createSuccessNotice,
112
+ createWarningNotice,
113
+ createErrorNotice
114
+ } = useDispatch(noticesStore);
115
+ return useCallback(async targetBlocks => {
116
+ let html = '';
117
+
118
+ try {
119
+ // `http:` sites won't have the clipboard property on navigator.
120
+ // (with the exception of localhost.)
121
+ if (!window.navigator.clipboard) {
122
+ createErrorNotice(__('Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'), {
123
+ type: 'snackbar'
124
+ });
125
+ return;
126
+ }
127
+
128
+ html = await window.navigator.clipboard.readText();
129
+ } catch (error) {
130
+ // Possibly the permission is denied.
131
+ createErrorNotice(__('Unable to paste styles. Please allow browser clipboard permissions before continuing.'), {
132
+ type: 'snackbar'
133
+ });
134
+ return;
135
+ } // Abort if the copied text is empty or doesn't look like serialized blocks.
136
+
137
+
138
+ if (!html || !hasSerializedBlocks(html)) {
139
+ createWarningNotice(__("Unable to paste styles. Block styles couldn't be found within the copied content."), {
140
+ type: 'snackbar'
141
+ });
142
+ return;
143
+ }
144
+
145
+ const copiedBlocks = parse(html);
146
+
147
+ if (copiedBlocks.length === 1) {
148
+ // Apply styles of the block to all the target blocks.
149
+ registry.batch(() => {
150
+ recursivelyUpdateBlockAttributes(targetBlocks, targetBlocks.map(() => copiedBlocks[0]), updateBlockAttributes);
151
+ });
152
+ } else {
153
+ registry.batch(() => {
154
+ recursivelyUpdateBlockAttributes(targetBlocks, copiedBlocks, updateBlockAttributes);
155
+ });
156
+ }
157
+
158
+ if (targetBlocks.length === 1) {
159
+ var _getBlockType;
160
+
161
+ const title = (_getBlockType = getBlockType(targetBlocks[0].name)) === null || _getBlockType === void 0 ? void 0 : _getBlockType.title;
162
+ createSuccessNotice(sprintf( // Translators: Name of the block being pasted, e.g. "Paragraph".
163
+ __('Pasted styles to %s.'), title), {
164
+ type: 'snackbar'
165
+ });
166
+ } else {
167
+ createSuccessNotice(sprintf( // Translators: The number of the blocks.
168
+ __('Pasted styles to %d blocks.'), targetBlocks.length), {
169
+ type: 'snackbar'
170
+ });
171
+ }
172
+ }, [registry.batch, updateBlockAttributes, createSuccessNotice, createWarningNotice, createErrorNotice]);
173
+ }
174
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/use-paste-styles/index.js"],"names":["useCallback","getBlockType","parse","useDispatch","useRegistry","store","noticesStore","__","sprintf","blockEditorStore","hasAlignSupport","hasBorderSupport","hasBackgroundColorSupport","hasTextColorSupport","hasGradientSupport","hasCustomClassNameSupport","hasFontFamilySupport","hasFontSizeSupport","hasLayoutSupport","hasStyleSupport","hasSerializedBlocks","text","blocks","__unstableSkipMigrationLogs","__unstableSkipAutop","length","name","err","STYLE_ATTRIBUTES","align","borderColor","nameOrType","backgroundColor","textColor","gradient","className","fontFamily","fontSize","layout","style","getStyleAttributes","sourceBlock","targetBlock","Object","entries","reduce","attributes","attributeKey","hasSupport","recursivelyUpdateBlockAttributes","targetBlocks","sourceBlocks","updateBlockAttributes","index","Math","min","clientId","innerBlocks","usePasteStyles","registry","createSuccessNotice","createWarningNotice","createErrorNotice","html","window","navigator","clipboard","type","readText","error","copiedBlocks","batch","map","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBA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B,MAAMF,YAAY,CAAE,CAAF,CAApC,CAF+B,EAG/BlB,qBAH+B,CAAhC;AAKA,OAND;AAOA,KATD,MASO;AACNO,MAAAA,QAAQ,CAACY,KAAT,CAAgB,MAAM;AACrBtB,QAAAA,gCAAgC,CAC/BC,YAD+B,EAE/BoB,YAF+B,EAG/BlB,qBAH+B,CAAhC;AAKA,OAND;AAOA;;AAED,QAAKF,YAAY,CAACzB,MAAb,KAAwB,CAA7B,EAAiC;AAAA;;AAChC,YAAMgD,KAAK,oBAAGxE,YAAY,CAAEiD,YAAY,CAAE,CAAF,CAAZ,CAAkBxB,IAApB,CAAf,kDAAG,cAAwC+C,KAAtD;AACAb,MAAAA,mBAAmB,CAClBpD,OAAO,EACN;AACAD,MAAAA,EAAE,CAAE,sBAAF,CAFI,EAGNkE,KAHM,CADW,EAMlB;AAAEN,QAAAA,IAAI,EAAE;AAAR,OANkB,CAAnB;AAQA,KAVD,MAUO;AACNP,MAAAA,mBAAmB,CAClBpD,OAAO,EACN;AACAD,MAAAA,EAAE,CAAE,6BAAF,CAFI,EAGN2C,YAAY,CAACzB,MAHP,CADW,EAMlB;AAAE0C,QAAAA,IAAI,EAAE;AAAR,OANkB,CAAnB;AAQA;AACD,GApFgB,EAqFjB,CACCR,QAAQ,CAACY,KADV,EAECnB,qBAFD,EAGCQ,mBAHD,EAICC,mBAJD,EAKCC,iBALD,CArFiB,CAAlB;AA6FA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { getBlockType, parse } from '@wordpress/blocks';\nimport { useDispatch, useRegistry } from '@wordpress/data';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport {\n\thasAlignSupport,\n\thasBorderSupport,\n\thasBackgroundColorSupport,\n\thasTextColorSupport,\n\thasGradientSupport,\n\thasCustomClassNameSupport,\n\thasFontFamilySupport,\n\thasFontSizeSupport,\n\thasLayoutSupport,\n\thasStyleSupport,\n} from '../../hooks/supports';\n\n/**\n * Determine if the copied text looks like serialized blocks or not.\n * Since plain text will always get parsed into a freeform block,\n * we check that if the parsed blocks is anything other than that.\n *\n * @param {string} text The copied text.\n * @return {boolean} True if the text looks like serialized blocks, false otherwise.\n */\nfunction hasSerializedBlocks( text ) {\n\ttry {\n\t\tconst blocks = parse( text, {\n\t\t\t__unstableSkipMigrationLogs: true,\n\t\t\t__unstableSkipAutop: true,\n\t\t} );\n\t\tif ( blocks.length === 1 && blocks[ 0 ].name === 'core/freeform' ) {\n\t\t\t// It's likely that the text is just plain text and not serialized blocks.\n\t\t\treturn false;\n\t\t}\n\t\treturn true;\n\t} catch ( err ) {\n\t\t// Parsing error, the text is not serialized blocks.\n\t\t// (Even though that it technically won't happen)\n\t\treturn false;\n\t}\n}\n\n/**\n * Style attributes are attributes being added in `block-editor/src/hooks/*`.\n * (Except for some unrelated to style like `anchor` or `settings`.)\n * They generally represent the default block supports.\n */\nconst STYLE_ATTRIBUTES = {\n\talign: hasAlignSupport,\n\tborderColor: ( nameOrType ) => hasBorderSupport( nameOrType, 'color' ),\n\tbackgroundColor: hasBackgroundColorSupport,\n\ttextColor: hasTextColorSupport,\n\tgradient: hasGradientSupport,\n\tclassName: hasCustomClassNameSupport,\n\tfontFamily: hasFontFamilySupport,\n\tfontSize: hasFontSizeSupport,\n\tlayout: hasLayoutSupport,\n\tstyle: hasStyleSupport,\n};\n\n/**\n * Get the \"style attributes\" from a given block to a target block.\n *\n * @param {WPBlock} sourceBlock The source block.\n * @param {WPBlock} targetBlock The target block.\n * @return {Object} the filtered attributes object.\n */\nfunction getStyleAttributes( sourceBlock, targetBlock ) {\n\treturn Object.entries( STYLE_ATTRIBUTES ).reduce(\n\t\t( attributes, [ attributeKey, hasSupport ] ) => {\n\t\t\t// Only apply the attribute if both blocks support it.\n\t\t\tif (\n\t\t\t\thasSupport( sourceBlock.name ) &&\n\t\t\t\thasSupport( targetBlock.name )\n\t\t\t) {\n\t\t\t\t// Override attributes that are not present in the block to their defaults.\n\t\t\t\tattributes[ attributeKey ] =\n\t\t\t\t\tsourceBlock.attributes[ attributeKey ];\n\t\t\t}\n\t\t\treturn attributes;\n\t\t},\n\t\t{}\n\t);\n}\n\n/**\n * Update the target blocks with style attributes recursively.\n *\n * @param {WPBlock[]} targetBlocks The target blocks to be updated.\n * @param {WPBlock[]} sourceBlocks The source blocks to get th style attributes from.\n * @param {Function} updateBlockAttributes The function to update the attributes.\n */\nfunction recursivelyUpdateBlockAttributes(\n\ttargetBlocks,\n\tsourceBlocks,\n\tupdateBlockAttributes\n) {\n\tfor (\n\t\tlet index = 0;\n\t\tindex < Math.min( sourceBlocks.length, targetBlocks.length );\n\t\tindex += 1\n\t) {\n\t\tupdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].clientId,\n\t\t\tgetStyleAttributes( sourceBlocks[ index ], targetBlocks[ index ] )\n\t\t);\n\n\t\trecursivelyUpdateBlockAttributes(\n\t\t\ttargetBlocks[ index ].innerBlocks,\n\t\t\tsourceBlocks[ index ].innerBlocks,\n\t\t\tupdateBlockAttributes\n\t\t);\n\t}\n}\n\n/**\n * A hook to return a pasteStyles event function for handling pasting styles to blocks.\n *\n * @return {Function} A function to update the styles to the blocks.\n */\nexport default function usePasteStyles() {\n\tconst registry = useRegistry();\n\tconst { updateBlockAttributes } = useDispatch( blockEditorStore );\n\tconst { createSuccessNotice, createWarningNotice, createErrorNotice } =\n\t\tuseDispatch( noticesStore );\n\n\treturn useCallback(\n\t\tasync ( targetBlocks ) => {\n\t\t\tlet html = '';\n\t\t\ttry {\n\t\t\t\t// `http:` sites won't have the clipboard property on navigator.\n\t\t\t\t// (with the exception of localhost.)\n\t\t\t\tif ( ! window.navigator.clipboard ) {\n\t\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Unable to paste styles. This feature is only available on secure (https) sites in supporting browsers.'\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thtml = await window.navigator.clipboard.readText();\n\t\t\t} catch ( error ) {\n\t\t\t\t// Possibly the permission is denied.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Unable to paste styles. Please allow browser clipboard permissions before continuing.'\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if the copied text is empty or doesn't look like serialized blocks.\n\t\t\tif ( ! html || ! hasSerializedBlocks( html ) ) {\n\t\t\t\tcreateWarningNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t\"Unable to paste styles. Block styles couldn't be found within the copied content.\"\n\t\t\t\t\t),\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst copiedBlocks = parse( html );\n\n\t\t\tif ( copiedBlocks.length === 1 ) {\n\t\t\t\t// Apply styles of the block to all the target blocks.\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\ttargetBlocks.map( () => copiedBlocks[ 0 ] ),\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tregistry.batch( () => {\n\t\t\t\t\trecursivelyUpdateBlockAttributes(\n\t\t\t\t\t\ttargetBlocks,\n\t\t\t\t\t\tcopiedBlocks,\n\t\t\t\t\t\tupdateBlockAttributes\n\t\t\t\t\t);\n\t\t\t\t} );\n\t\t\t}\n\n\t\t\tif ( targetBlocks.length === 1 ) {\n\t\t\t\tconst title = getBlockType( targetBlocks[ 0 ].name )?.title;\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: Name of the block being pasted, e.g. \"Paragraph\".\n\t\t\t\t\t\t__( 'Pasted styles to %s.' ),\n\t\t\t\t\t\ttitle\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tcreateSuccessNotice(\n\t\t\t\t\tsprintf(\n\t\t\t\t\t\t// Translators: The number of the blocks.\n\t\t\t\t\t\t__( 'Pasted styles to %d blocks.' ),\n\t\t\t\t\t\ttargetBlocks.length\n\t\t\t\t\t),\n\t\t\t\t\t{ type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tregistry.batch,\n\t\t\tupdateBlockAttributes,\n\t\t\tcreateSuccessNotice,\n\t\t\tcreateWarningNotice,\n\t\t\tcreateErrorNotice,\n\t\t]\n\t);\n}\n"]}
@@ -132,6 +132,12 @@ export default function useArrowNav() {
132
132
  }
133
133
 
134
134
  function onKeyDown(event) {
135
+ // Abort if navigation has already been handled (e.g. RichText
136
+ // inline boundaries).
137
+ if (event.defaultPrevented) {
138
+ return;
139
+ }
140
+
135
141
  const {
136
142
  keyCode,
137
143
  target,
@@ -155,25 +161,22 @@ export default function useArrowNav() {
155
161
  } = node;
156
162
  const {
157
163
  defaultView
158
- } = ownerDocument; // If there is a multi-selection, the arrow keys should collapse the
164
+ } = ownerDocument;
165
+
166
+ if (!isNav) {
167
+ return;
168
+ } // If there is a multi-selection, the arrow keys should collapse the
159
169
  // selection to the start or end of the selection.
160
170
 
161
- if (hasMultiSelection()) {
162
- // Only handle if we have a full selection (not a native partial
163
- // selection).
164
- if (!__unstableIsFullySelected()) {
165
- return;
166
- }
167
171
 
168
- if (event.defaultPrevented) {
172
+ if (hasMultiSelection()) {
173
+ if (shiftKey) {
169
174
  return;
170
- }
175
+ } // Only handle if we have a full selection (not a native partial
176
+ // selection).
171
177
 
172
- if (!isNav) {
173
- return;
174
- }
175
178
 
176
- if (shiftKey) {
179
+ if (!__unstableIsFullySelected()) {
177
180
  return;
178
181
  }
179
182
 
@@ -185,6 +188,12 @@ export default function useArrowNav() {
185
188
  selectBlock(getMultiSelectedBlocksEndClientId(), -1);
186
189
  }
187
190
 
191
+ return;
192
+ } // Abort if our current target is not a candidate for navigation
193
+ // (e.g. preserve native input behaviors).
194
+
195
+
196
+ if (!isNavigationCandidate(target, keyCode, hasModifier)) {
188
197
  return;
189
198
  } // When presing any key other than up or down, the initial vertical
190
199
  // position must ALWAYS be reset. The vertical position is saved so
@@ -199,22 +208,6 @@ export default function useArrowNav() {
199
208
  verticalRect = null;
200
209
  } else if (!verticalRect) {
201
210
  verticalRect = computeCaretRect(defaultView);
202
- } // Abort if navigation has already been handled (e.g. RichText
203
- // inline boundaries).
204
-
205
-
206
- if (event.defaultPrevented) {
207
- return;
208
- }
209
-
210
- if (!isNav) {
211
- return;
212
- } // Abort if our current target is not a candidate for navigation
213
- // (e.g. preserve native input behaviors).
214
-
215
-
216
- if (!isNavigationCandidate(target, keyCode, hasModifier)) {
217
- return;
218
211
  } // In the case of RTL scripts, right means previous and left means
219
212
  // next, which is the exact reverse of LTR.
220
213
 
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"names":["computeCaretRect","focus","isHorizontalEdge","isVerticalEdge","placeCaretAtHorizontalEdge","placeCaretAtVerticalEdge","isRTL","UP","DOWN","LEFT","RIGHT","useDispatch","useSelect","useRefEffect","getBlockClientId","isInSameBlock","store","blockEditorStore","isNavigationCandidate","element","keyCode","hasModifier","isVertical","tagName","simpleInputTypes","includes","getAttribute","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focusable","find","reverse","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","children","length","firstElementChild","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","selectBlock","verticalRect","onMouseDown","isClosestTabbableABlock","closestTabbable","onKeyDown","event","shiftKey","ctrlKey","altKey","metaKey","isUp","isDown","isLeft","isRight","isHorizontal","isNav","isNavEdge","ownerDocument","defaultView","defaultPrevented","preventDefault","isReverseDir","keepCaretInsideBlock","undefined","getSelection","isCollapsed","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,gBADD,EAECC,KAFD,EAGCC,gBAHD,EAICC,cAJD,EAKCC,0BALD,EAMCC,wBAND,EAOCC,KAPD,QAQO,gBARP;AASA,SAASC,EAAT,EAAaC,IAAb,EAAmBC,IAAnB,EAAyBC,KAAzB,QAAsC,qBAAtC;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SAASC,gBAAT,EAA2BC,aAA3B,QAAgD,iBAAhD;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qBAAT,CAAgCC,OAAhC,EAAyCC,OAAzC,EAAkDC,WAAlD,EAAgE;AACtE,QAAMC,UAAU,GAAGF,OAAO,KAAKb,EAAZ,IAAkBa,OAAO,KAAKZ,IAAjD,CADsE,CAGtE;;AACA,MAAKc,UAAU,IAAI,CAAED,WAArB,EAAmC;AAClC,WAAO,IAAP;AACA;;AAED,QAAM;AAAEE,IAAAA;AAAF,MAAcJ,OAApB,CARsE,CAUtE;;AACA,MAAKI,OAAO,KAAK,OAAjB,EAA2B;AAC1B,UAAMC,gBAAgB,GAAG,CACxB,QADwB,EAExB,UAFwB,EAGxB,OAHwB,EAIxB,MAJwB,EAKxB,OALwB,EAMxB,OANwB,EAOxB,OAPwB,EAQxB,QARwB,CAAzB;AAUA,WAAOA,gBAAgB,CAACC,QAAjB,CA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CoD,YAFyC,EAGzCvC,IAHyC,CAA1C;AAKArC,QAAAA,0BAA0B,CAAE0D,eAAF,EAAmBjC,SAAnB,CAA1B;AACAmC,QAAAA,KAAK,CAACe,cAAN;AACA;AACD;;AAEDtC,IAAAA,IAAI,CAAC4C,gBAAL,CAAuB,WAAvB,EAAoCzB,WAApC;AACAnB,IAAAA,IAAI,CAAC4C,gBAAL,CAAuB,SAAvB,EAAkCtB,SAAlC;AACA,WAAO,MAAM;AACZtB,MAAAA,IAAI,CAAC6C,mBAAL,CAA0B,WAA1B,EAAuC1B,WAAvC;AACAnB,MAAAA,IAAI,CAAC6C,mBAAL,CAA0B,SAA1B,EAAqCvB,SAArC;AACA,KAHD;AAIA,GA7JkB,EA6JhB,EA7JgB,CAAnB;AA8JA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId, isInSameBlock } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\n\t// Currently, all elements support unmodified vertical navigation.\n\tif ( isVertical && ! hasModifier ) {\n\t\treturn true;\n\t}\n\n\tconst { tagName } = element;\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( element.getAttribute( 'type' ) );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable nodes.\n\t\tif ( node.isContentEditable && node.contentEditable !== 'true' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( onlyVertical ) {\n\t\t\tconst nodeRect = node.getBoundingClientRect();\n\n\t\t\tif (\n\t\t\t\tnodeRect.left >= targetRect.right ||\n\t\t\t\tnodeRect.right <= targetRect.left\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn focusableNodes.find( isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\tconst { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =\n\t\t\t\tevent;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( ! isNav ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/writing-flow/use-arrow-nav.js"],"names":["computeCaretRect","focus","isHorizontalEdge","isVerticalEdge","placeCaretAtHorizontalEdge","placeCaretAtVerticalEdge","isRTL","UP","DOWN","LEFT","RIGHT","useDispatch","useSelect","useRefEffect","getBlockClientId","isInSameBlock","store","blockEditorStore","isNavigationCandidate","element","keyCode","hasModifier","isVertical","tagName","simpleInputTypes","includes","getAttribute","getClosestTabbable","target","isReverse","containerElement","onlyVertical","focusableNodes","focusable","find","reverse","slice","indexOf","targetRect","getBoundingClientRect","isTabCandidate","node","children","length","firstElementChild","tabbable","isTabbableIndex","isContentEditable","contentEditable","nodeRect","left","right","useArrowNav","getMultiSelectedBlocksStartClientId","getMultiSelectedBlocksEndClientId","getSettings","hasMultiSelection","__unstableIsFullySelected","selectBlock","verticalRect","onMouseDown","isClosestTabbableABlock","closestTabbable","onKeyDown","event","defaultPrevented","shiftKey","ctrlKey","altKey","metaKey","isUp","isDown","isLeft","isRight","isHorizontal","isNav","isNavEdge","ownerDocument","defaultView","preventDefault","isReverseDir","keepCaretInsideBlock","undefined","getSelection","isCollapsed","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,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,CAA0B,SAA1B,EAAqCvB,SAArC;AACA,KAHD;AAIA,GArJkB,EAqJhB,EArJgB,CAAnB;AAsJA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcomputeCaretRect,\n\tfocus,\n\tisHorizontalEdge,\n\tisVerticalEdge,\n\tplaceCaretAtHorizontalEdge,\n\tplaceCaretAtVerticalEdge,\n\tisRTL,\n} from '@wordpress/dom';\nimport { UP, DOWN, LEFT, RIGHT } from '@wordpress/keycodes';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useRefEffect } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { getBlockClientId, isInSameBlock } from '../../utils/dom';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Returns true if the element should consider edge navigation upon a keyboard\n * event of the given directional key code, or false otherwise.\n *\n * @param {Element} element HTML element to test.\n * @param {number} keyCode KeyboardEvent keyCode to test.\n * @param {boolean} hasModifier Whether a modifier is pressed.\n *\n * @return {boolean} Whether element should consider edge navigation.\n */\nexport function isNavigationCandidate( element, keyCode, hasModifier ) {\n\tconst isVertical = keyCode === UP || keyCode === DOWN;\n\n\t// Currently, all elements support unmodified vertical navigation.\n\tif ( isVertical && ! hasModifier ) {\n\t\treturn true;\n\t}\n\n\tconst { tagName } = element;\n\n\t// Native inputs should not navigate horizontally, unless they are simple types that don't need left/right arrow keys.\n\tif ( tagName === 'INPUT' ) {\n\t\tconst simpleInputTypes = [\n\t\t\t'button',\n\t\t\t'checkbox',\n\t\t\t'color',\n\t\t\t'file',\n\t\t\t'image',\n\t\t\t'radio',\n\t\t\t'reset',\n\t\t\t'submit',\n\t\t];\n\t\treturn simpleInputTypes.includes( element.getAttribute( 'type' ) );\n\t}\n\n\t// Native textareas should not navigate horizontally.\n\treturn tagName !== 'TEXTAREA';\n}\n\n/**\n * Returns the optimal tab target from the given focused element in the desired\n * direction. A preference is made toward text fields, falling back to the block\n * focus stop if no other candidates exist for the block.\n *\n * @param {Element} target Currently focused text field.\n * @param {boolean} isReverse True if considering as the first field.\n * @param {Element} containerElement Element containing all blocks.\n * @param {boolean} onlyVertical Whether to only consider tabbable elements\n * that are visually above or under the\n * target.\n *\n * @return {?Element} Optimal tab target, if one exists.\n */\nexport function getClosestTabbable(\n\ttarget,\n\tisReverse,\n\tcontainerElement,\n\tonlyVertical\n) {\n\t// Since the current focus target is not guaranteed to be a text field, find\n\t// all focusables. Tabbability is considered later.\n\tlet focusableNodes = focus.focusable.find( containerElement );\n\n\tif ( isReverse ) {\n\t\tfocusableNodes.reverse();\n\t}\n\n\t// Consider as candidates those focusables after the current target. It's\n\t// assumed this can only be reached if the target is focusable (on its\n\t// keydown event), so no need to verify it exists in the set.\n\tfocusableNodes = focusableNodes.slice(\n\t\tfocusableNodes.indexOf( target ) + 1\n\t);\n\n\tlet targetRect;\n\n\tif ( onlyVertical ) {\n\t\ttargetRect = target.getBoundingClientRect();\n\t}\n\n\tfunction isTabCandidate( node ) {\n\t\t// Skip if there's only one child that is content editable (and thus a\n\t\t// better candidate).\n\t\tif (\n\t\t\tnode.children.length === 1 &&\n\t\t\tisInSameBlock( node, node.firstElementChild ) &&\n\t\t\tnode.firstElementChild.getAttribute( 'contenteditable' ) === 'true'\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Not a candidate if the node is not tabbable.\n\t\tif ( ! focus.tabbable.isTabbableIndex( node ) ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Skip focusable elements such as links within content editable nodes.\n\t\tif ( node.isContentEditable && node.contentEditable !== 'true' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tif ( onlyVertical ) {\n\t\t\tconst nodeRect = node.getBoundingClientRect();\n\n\t\t\tif (\n\t\t\t\tnodeRect.left >= targetRect.right ||\n\t\t\t\tnodeRect.right <= targetRect.left\n\t\t\t) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\n\t\treturn true;\n\t}\n\n\treturn focusableNodes.find( isTabCandidate );\n}\n\nexport default function useArrowNav() {\n\tconst {\n\t\tgetMultiSelectedBlocksStartClientId,\n\t\tgetMultiSelectedBlocksEndClientId,\n\t\tgetSettings,\n\t\thasMultiSelection,\n\t\t__unstableIsFullySelected,\n\t} = useSelect( blockEditorStore );\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\treturn useRefEffect( ( node ) => {\n\t\t// Here a DOMRect is stored while moving the caret vertically so\n\t\t// vertical position of the start position can be restored. This is to\n\t\t// recreate browser behaviour across blocks.\n\t\tlet verticalRect;\n\n\t\tfunction onMouseDown() {\n\t\t\tverticalRect = null;\n\t\t}\n\n\t\tfunction isClosestTabbableABlock( target, isReverse ) {\n\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\ttarget,\n\t\t\t\tisReverse,\n\t\t\t\tnode\n\t\t\t);\n\t\t\treturn closestTabbable && getBlockClientId( closestTabbable );\n\t\t}\n\n\t\tfunction onKeyDown( event ) {\n\t\t\t// Abort if navigation has already been handled (e.g. RichText\n\t\t\t// inline boundaries).\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { keyCode, target, shiftKey, ctrlKey, altKey, metaKey } =\n\t\t\t\tevent;\n\t\t\tconst isUp = keyCode === UP;\n\t\t\tconst isDown = keyCode === DOWN;\n\t\t\tconst isLeft = keyCode === LEFT;\n\t\t\tconst isRight = keyCode === RIGHT;\n\t\t\tconst isReverse = isUp || isLeft;\n\t\t\tconst isHorizontal = isLeft || isRight;\n\t\t\tconst isVertical = isUp || isDown;\n\t\t\tconst isNav = isHorizontal || isVertical;\n\t\t\tconst hasModifier = shiftKey || ctrlKey || altKey || metaKey;\n\t\t\tconst isNavEdge = isVertical ? isVerticalEdge : isHorizontalEdge;\n\t\t\tconst { ownerDocument } = node;\n\t\t\tconst { defaultView } = ownerDocument;\n\n\t\t\tif ( ! isNav ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// If there is a multi-selection, the arrow keys should collapse the\n\t\t\t// selection to the start or end of the selection.\n\t\t\tif ( hasMultiSelection() ) {\n\t\t\t\tif ( shiftKey ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Only handle if we have a full selection (not a native partial\n\t\t\t\t// selection).\n\t\t\t\tif ( ! __unstableIsFullySelected() ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tevent.preventDefault();\n\n\t\t\t\tif ( isReverse ) {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksStartClientId() );\n\t\t\t\t} else {\n\t\t\t\t\tselectBlock( getMultiSelectedBlocksEndClientId(), -1 );\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Abort if our current target is not a candidate for navigation\n\t\t\t// (e.g. preserve native input behaviors).\n\t\t\tif ( ! isNavigationCandidate( target, keyCode, hasModifier ) ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// When presing any key other than up or down, the initial vertical\n\t\t\t// position must ALWAYS be reset. The vertical position is saved so\n\t\t\t// it can be restored as well as possible on sebsequent vertical\n\t\t\t// arrow key presses. It may not always be possible to restore the\n\t\t\t// exact same position (such as at an empty line), so it wouldn't be\n\t\t\t// good to compute the position right before any vertical arrow key\n\t\t\t// press.\n\t\t\tif ( ! isVertical ) {\n\t\t\t\tverticalRect = null;\n\t\t\t} else if ( ! verticalRect ) {\n\t\t\t\tverticalRect = computeCaretRect( defaultView );\n\t\t\t}\n\n\t\t\t// In the case of RTL scripts, right means previous and left means\n\t\t\t// next, which is the exact reverse of LTR.\n\t\t\tconst isReverseDir = isRTL( target ) ? ! isReverse : isReverse;\n\t\t\tconst { keepCaretInsideBlock } = getSettings();\n\n\t\t\tif ( shiftKey ) {\n\t\t\t\tif (\n\t\t\t\t\tisClosestTabbableABlock( target, isReverse ) &&\n\t\t\t\t\tisNavEdge( target, isReverse )\n\t\t\t\t) {\n\t\t\t\t\tnode.contentEditable = true;\n\t\t\t\t\t// Firefox doesn't automatically move focus.\n\t\t\t\t\tnode.focus();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisVertical &&\n\t\t\t\tisVerticalEdge( target, isReverse ) &&\n\t\t\t\t// When Alt is pressed, only intercept if the caret is also at\n\t\t\t\t// the horizontal edge.\n\t\t\t\t( altKey ? isHorizontalEdge( target, isReverseDir ) : true ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverse,\n\t\t\t\t\tnode,\n\t\t\t\t\ttrue\n\t\t\t\t);\n\n\t\t\t\tif ( closestTabbable ) {\n\t\t\t\t\tplaceCaretAtVerticalEdge(\n\t\t\t\t\t\tclosestTabbable,\n\t\t\t\t\t\t// When Alt is pressed, place the caret at the furthest\n\t\t\t\t\t\t// horizontal edge and the furthest vertical edge.\n\t\t\t\t\t\taltKey ? ! isReverse : isReverse,\n\t\t\t\t\t\taltKey ? undefined : verticalRect\n\t\t\t\t\t);\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} else if (\n\t\t\t\tisHorizontal &&\n\t\t\t\tdefaultView.getSelection().isCollapsed &&\n\t\t\t\tisHorizontalEdge( target, isReverseDir ) &&\n\t\t\t\t! keepCaretInsideBlock\n\t\t\t) {\n\t\t\t\tconst closestTabbable = getClosestTabbable(\n\t\t\t\t\ttarget,\n\t\t\t\t\tisReverseDir,\n\t\t\t\t\tnode\n\t\t\t\t);\n\t\t\t\tplaceCaretAtHorizontalEdge( closestTabbable, isReverse );\n\t\t\t\tevent.preventDefault();\n\t\t\t}\n\t\t}\n\n\t\tnode.addEventListener( 'mousedown', onMouseDown );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'mousedown', onMouseDown );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t};\n\t}, [] );\n}\n"]}
@@ -14,6 +14,7 @@ import './color';
14
14
  import './duotone';
15
15
  import './font-size';
16
16
  import './border';
17
+ import './position';
17
18
  import './layout';
18
19
  import './content-lock-ui';
19
20
  import './metadata';
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":["useCustomSides","useLayoutClasses","useLayoutStyles","getBorderClassesAndStyles","useBorderProps","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","getTypographyClassesAndStyles","getGapCSSValue","useCachedTruthy"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,UAAP;AACA,OAAO,SAAP;AACA,OAAO,QAAP;AACA,OAAO,UAAP;AACA,OAAO,cAAP;AACA,OAAO,qBAAP;AACA,OAAO,wBAAP;AACA,OAAO,SAAP;AACA,OAAO,YAAP;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAO,aAAP;AACA,OAAO,UAAP;AACA,OAAO,UAAP;AACA,OAAO,mBAAP;AACA,OAAO,YAAP;AACA,OAAO,iBAAP;AAEA,SAASA,cAAT,QAA+B,cAA/B;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,UAAlD;AACA,SAASC,yBAAT,EAAoCC,cAApC,QAA0D,oBAA1D;AACA,SAASC,wBAAT,EAAmCC,aAAnC,QAAwD,mBAAxD;AACA,SAASC,0BAAT,QAA2C,qBAA3C;AACA,SAASC,6BAAT,QAA8C,wBAA9C;AACA,SAASC,cAAT,QAA+B,OAA/B;AACA,SAASC,eAAT,QAAgC,qBAAhC","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './aria-label';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './settings';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border';\nimport './layout';\nimport './content-lock-ui';\nimport './metadata';\nimport './metadata-name';\n\nexport { useCustomSides } from './dimensions';\nexport { useLayoutClasses, useLayoutStyles } from './layout';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getTypographyClassesAndStyles } from './use-typography-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/index.js"],"names":["useCustomSides","useLayoutClasses","useLayoutStyles","getBorderClassesAndStyles","useBorderProps","getColorClassesAndStyles","useColorProps","getSpacingClassesAndStyles","getTypographyClassesAndStyles","getGapCSSValue","useCachedTruthy"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,UAAP;AACA,OAAO,SAAP;AACA,OAAO,QAAP;AACA,OAAO,UAAP;AACA,OAAO,cAAP;AACA,OAAO,qBAAP;AACA,OAAO,wBAAP;AACA,OAAO,SAAP;AACA,OAAO,YAAP;AACA,OAAO,SAAP;AACA,OAAO,WAAP;AACA,OAAO,aAAP;AACA,OAAO,UAAP;AACA,OAAO,YAAP;AACA,OAAO,UAAP;AACA,OAAO,mBAAP;AACA,OAAO,YAAP;AACA,OAAO,iBAAP;AAEA,SAASA,cAAT,QAA+B,cAA/B;AACA,SAASC,gBAAT,EAA2BC,eAA3B,QAAkD,UAAlD;AACA,SAASC,yBAAT,EAAoCC,cAApC,QAA0D,oBAA1D;AACA,SAASC,wBAAT,EAAmCC,aAAnC,QAAwD,mBAAxD;AACA,SAASC,0BAAT,QAA2C,qBAA3C;AACA,SAASC,6BAAT,QAA8C,wBAA9C;AACA,SAASC,cAAT,QAA+B,OAA/B;AACA,SAASC,eAAT,QAAgC,qBAAhC","sourcesContent":["/**\n * Internal dependencies\n */\nimport './compat';\nimport './align';\nimport './lock';\nimport './anchor';\nimport './aria-label';\nimport './custom-class-name';\nimport './generated-class-name';\nimport './style';\nimport './settings';\nimport './color';\nimport './duotone';\nimport './font-size';\nimport './border';\nimport './position';\nimport './layout';\nimport './content-lock-ui';\nimport './metadata';\nimport './metadata-name';\n\nexport { useCustomSides } from './dimensions';\nexport { useLayoutClasses, useLayoutStyles } from './layout';\nexport { getBorderClassesAndStyles, useBorderProps } from './use-border-props';\nexport { getColorClassesAndStyles, useColorProps } from './use-color-props';\nexport { getSpacingClassesAndStyles } from './use-spacing-props';\nexport { getTypographyClassesAndStyles } from './use-typography-props';\nexport { getGapCSSValue } from './gap';\nexport { useCachedTruthy } from './use-cached-truthy';\n"]}
@@ -26,7 +26,7 @@ export function addMetaAttribute(blockTypeSettings) {
26
26
  return blockTypeSettings;
27
27
  }
28
28
 
29
- const supportsBlockNaming = hasBlockMetadataSupport(blockTypeSettings, 'name', false);
29
+ const supportsBlockNaming = hasBlockMetadataSupport(blockTypeSettings, 'name');
30
30
 
31
31
  if (supportsBlockNaming) {
32
32
  blockTypeSettings.attributes = { ...blockTypeSettings.attributes,
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/hooks/metadata.js"],"names":["addFilter","getBlockSupport","META_ATTRIBUTE_NAME","hasBlockMetadataSupport","blockType","feature","support","addMetaAttribute","blockTypeSettings","attributes","type","supportsBlockNaming","addSaveProps","extraProps"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA,MAAMC,mBAAmB,GAAG,UAA5B;AAEA,OAAO,SAASC,uBAAT,CAAkCC,SAAlC,EAA4D;AAAA,MAAfC,OAAe,uEAAL,EAAK;AAClE,QAAMC,OAAO,GAAGL,eAAe,CAAEG,SAAF,EAAa,wBAAb,CAA/B;AACA,SAAO,CAAC,EAAI,SAASE,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAID,OAAJ,CAA/B,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,gBAAT,CAA2BC,iBAA3B,EAA+C;AAAA;;AACrD;AACA,MAAKA,iBAAL,aAAKA,iBAAL,wCAAKA,iBAAiB,CAAEC,UAAxB,4EAAK,sBAAiCP,mBAAjC,CAAL,mDAAK,uBAAwDQ,IAA7D,EAAoE;AACnE,WAAOF,iBAAP;AACA;;AAED,QAAMG,mBAAmB,GAAGR,uBAAuB,CAClDK,iBADkD,EAElD,MAFkD,EAGlD,KAHkD,CAAnD;;AAMA,MAAKG,mBAAL,EAA2B;AAC1BH,IAAAA,iBAAiB,CAACC,UAAlB,GAA+B,EAC9B,GAAGD,iBAAiB,CAACC,UADS;AAE9B,OAAEP,mBAAF,GAAyB;AACxBQ,QAAAA,IAAI,EAAE;AADkB;AAFK,KAA/B;AAMA;;AAED,SAAOF,iBAAP;AACA;AAED,OAAO,SAASI,YAAT,CAAuBC,UAAvB,EAAmCT,SAAnC,EAA8CK,UAA9C,EAA2D;AACjE,MAAKN,uBAAuB,CAAEC,SAAF,CAA5B,EAA4C;AAC3CS,IAAAA,UAAU,CAAEX,mBAAF,CAAV,GAAoCO,UAAU,CAAEP,mBAAF,CAA9C;AACA;;AAED,SAAOW,UAAP;AACA;AAEDb,SAAS,CACR,0BADQ,EAER,gCAFQ,EAGRO,gBAHQ,CAAT;AAMAP,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRY,YAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\n\nconst META_ATTRIBUTE_NAME = 'metadata';\n\nexport function hasBlockMetadataSupport( blockType, feature = '' ) {\n\tconst support = getBlockSupport( blockType, '__experimentalMetadata' );\n\treturn !! ( true === support || support?.[ feature ] );\n}\n\n/**\n * Filters registered block settings, extending attributes to include `metadata`.\n *\n * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012\n *\n * @param {Object} blockTypeSettings Original block settings.\n * @return {Object} Filtered block settings.\n */\nexport function addMetaAttribute( blockTypeSettings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( blockTypeSettings?.attributes?.[ META_ATTRIBUTE_NAME ]?.type ) {\n\t\treturn blockTypeSettings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockMetadataSupport(\n\t\tblockTypeSettings,\n\t\t'name',\n\t\tfalse\n\t);\n\n\tif ( supportsBlockNaming ) {\n\t\tblockTypeSettings.attributes = {\n\t\t\t...blockTypeSettings.attributes,\n\t\t\t[ META_ATTRIBUTE_NAME ]: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn blockTypeSettings;\n}\n\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockMetadataSupport( blockType ) ) {\n\t\textraProps[ META_ATTRIBUTE_NAME ] = attributes[ META_ATTRIBUTE_NAME ];\n\t}\n\n\treturn extraProps;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addMetaAttribute',\n\taddMetaAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/metadata/save-props',\n\taddSaveProps\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/hooks/metadata.js"],"names":["addFilter","getBlockSupport","META_ATTRIBUTE_NAME","hasBlockMetadataSupport","blockType","feature","support","addMetaAttribute","blockTypeSettings","attributes","type","supportsBlockNaming","addSaveProps","extraProps"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,kBAA1B;AACA,SAASC,eAAT,QAAgC,mBAAhC;AAEA,MAAMC,mBAAmB,GAAG,UAA5B;AAEA,OAAO,SAASC,uBAAT,CAAkCC,SAAlC,EAA4D;AAAA,MAAfC,OAAe,uEAAL,EAAK;AAClE,QAAMC,OAAO,GAAGL,eAAe,CAAEG,SAAF,EAAa,wBAAb,CAA/B;AACA,SAAO,CAAC,EAAI,SAASE,OAAT,IAAoBA,OAApB,aAAoBA,OAApB,eAAoBA,OAAO,CAAID,OAAJ,CAA/B,CAAR;AACA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASE,gBAAT,CAA2BC,iBAA3B,EAA+C;AAAA;;AACrD;AACA,MAAKA,iBAAL,aAAKA,iBAAL,wCAAKA,iBAAiB,CAAEC,UAAxB,4EAAK,sBAAiCP,mBAAjC,CAAL,mDAAK,uBAAwDQ,IAA7D,EAAoE;AACnE,WAAOF,iBAAP;AACA;;AAED,QAAMG,mBAAmB,GAAGR,uBAAuB,CAClDK,iBADkD,EAElD,MAFkD,CAAnD;;AAKA,MAAKG,mBAAL,EAA2B;AAC1BH,IAAAA,iBAAiB,CAACC,UAAlB,GAA+B,EAC9B,GAAGD,iBAAiB,CAACC,UADS;AAE9B,OAAEP,mBAAF,GAAyB;AACxBQ,QAAAA,IAAI,EAAE;AADkB;AAFK,KAA/B;AAMA;;AAED,SAAOF,iBAAP;AACA;AAED,OAAO,SAASI,YAAT,CAAuBC,UAAvB,EAAmCT,SAAnC,EAA8CK,UAA9C,EAA2D;AACjE,MAAKN,uBAAuB,CAAEC,SAAF,CAA5B,EAA4C;AAC3CS,IAAAA,UAAU,CAAEX,mBAAF,CAAV,GAAoCO,UAAU,CAAEP,mBAAF,CAA9C;AACA;;AAED,SAAOW,UAAP;AACA;AAEDb,SAAS,CACR,0BADQ,EAER,gCAFQ,EAGRO,gBAHQ,CAAT;AAMAP,SAAS,CACR,kCADQ,EAER,0BAFQ,EAGRY,YAHQ,CAAT","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { getBlockSupport } from '@wordpress/blocks';\n\nconst META_ATTRIBUTE_NAME = 'metadata';\n\nexport function hasBlockMetadataSupport( blockType, feature = '' ) {\n\tconst support = getBlockSupport( blockType, '__experimentalMetadata' );\n\treturn !! ( true === support || support?.[ feature ] );\n}\n\n/**\n * Filters registered block settings, extending attributes to include `metadata`.\n *\n * see: https://github.com/WordPress/gutenberg/pull/40393/files#r864632012\n *\n * @param {Object} blockTypeSettings Original block settings.\n * @return {Object} Filtered block settings.\n */\nexport function addMetaAttribute( blockTypeSettings ) {\n\t// Allow blocks to specify their own attribute definition with default values if needed.\n\tif ( blockTypeSettings?.attributes?.[ META_ATTRIBUTE_NAME ]?.type ) {\n\t\treturn blockTypeSettings;\n\t}\n\n\tconst supportsBlockNaming = hasBlockMetadataSupport(\n\t\tblockTypeSettings,\n\t\t'name'\n\t);\n\n\tif ( supportsBlockNaming ) {\n\t\tblockTypeSettings.attributes = {\n\t\t\t...blockTypeSettings.attributes,\n\t\t\t[ META_ATTRIBUTE_NAME ]: {\n\t\t\t\ttype: 'object',\n\t\t\t},\n\t\t};\n\t}\n\n\treturn blockTypeSettings;\n}\n\nexport function addSaveProps( extraProps, blockType, attributes ) {\n\tif ( hasBlockMetadataSupport( blockType ) ) {\n\t\textraProps[ META_ATTRIBUTE_NAME ] = attributes[ META_ATTRIBUTE_NAME ];\n\t}\n\n\treturn extraProps;\n}\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/metadata/addMetaAttribute',\n\taddMetaAttribute\n);\n\naddFilter(\n\t'blocks.getSaveContent.extraProps',\n\t'core/metadata/save-props',\n\taddSaveProps\n);\n"]}