@wordpress/block-editor 14.14.0 → 14.14.2

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 (23) hide show
  1. package/build/components/block-popover/use-popover-scroll.js +2 -1
  2. package/build/components/block-popover/use-popover-scroll.js.map +1 -1
  3. package/build/components/inserter/block-patterns-explorer/pattern-list.js +3 -0
  4. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  5. package/build/components/link-control/search-input.js +2 -3
  6. package/build/components/link-control/search-input.js.map +1 -1
  7. package/build/components/writing-flow/use-tab-nav.js +21 -14
  8. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  9. package/build-module/components/block-popover/use-popover-scroll.js +2 -1
  10. package/build-module/components/block-popover/use-popover-scroll.js.map +1 -1
  11. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js +4 -1
  12. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -1
  13. package/build-module/components/link-control/search-input.js +2 -3
  14. package/build-module/components/link-control/search-input.js.map +1 -1
  15. package/build-module/components/writing-flow/use-tab-nav.js +21 -14
  16. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  17. package/package.json +34 -34
  18. package/src/components/block-popover/use-popover-scroll.js +2 -1
  19. package/src/components/inserter/block-patterns-explorer/pattern-list.js +7 -0
  20. package/src/components/link-control/search-input.js +2 -4
  21. package/src/components/link-control/test/index.js +46 -46
  22. package/src/components/media-replace-flow/test/index.js +1 -1
  23. package/src/components/writing-flow/use-tab-nav.js +22 -17
@@ -15,7 +15,7 @@ import { isInSameBlock, isInsideRootBlock } from '../../utils/dom';
15
15
  import { unlock } from '../../lock-unlock';
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  export default function useTabNav() {
18
- const container = useRef();
18
+ const containerRef = /** @type {typeof useRef<HTMLElement>} */useRef();
19
19
  const focusCaptureBeforeRef = useRef();
20
20
  const focusCaptureAfterRef = useRef();
21
21
  const {
@@ -35,19 +35,19 @@ export default function useTabNav() {
35
35
  // capturing on the focus capture elements.
36
36
  const noCaptureRef = useRef();
37
37
  function onFocusCapture(event) {
38
- const canvasElement = container.current.ownerDocument === event.target.ownerDocument ? container.current : container.current.ownerDocument.defaultView.frameElement;
38
+ const canvasElement = containerRef.current.ownerDocument === event.target.ownerDocument ? containerRef.current : containerRef.current.ownerDocument.defaultView.frameElement;
39
39
 
40
40
  // Do not capture incoming focus if set by us in WritingFlow.
41
41
  if (noCaptureRef.current) {
42
42
  noCaptureRef.current = null;
43
43
  } else if (hasMultiSelection()) {
44
- container.current.focus();
44
+ containerRef.current.focus();
45
45
  } else if (getSelectedBlockClientId()) {
46
46
  if (getLastFocus()?.current) {
47
47
  getLastFocus().current.focus();
48
48
  } else {
49
49
  // Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.
50
- container.current.querySelector(`[data-block="${getSelectedBlockClientId()}"]`).focus();
50
+ containerRef.current.querySelector(`[data-block="${getSelectedBlockClientId()}"]`).focus();
51
51
  }
52
52
  }
53
53
  // In "compose" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.
@@ -57,11 +57,11 @@ export default function useTabNav() {
57
57
 
58
58
  // If we have section within the section root, focus the first one.
59
59
  if (sectionBlocks.length) {
60
- container.current.querySelector(`[data-block="${sectionBlocks[0]}"]`).focus();
60
+ containerRef.current.querySelector(`[data-block="${sectionBlocks[0]}"]`).focus();
61
61
  }
62
62
  // If we don't have any section blocks, focus the section root.
63
63
  else if (sectionRootClientId) {
64
- container.current.querySelector(`[data-block="${sectionRootClientId}"]`).focus();
64
+ containerRef.current.querySelector(`[data-block="${sectionRootClientId}"]`).focus();
65
65
  } else {
66
66
  // If we don't have any section root, focus the canvas.
67
67
  canvasElement.focus();
@@ -70,7 +70,7 @@ export default function useTabNav() {
70
70
  const isBefore =
71
71
  // eslint-disable-next-line no-bitwise
72
72
  event.target.compareDocumentPosition(canvasElement) & event.target.DOCUMENT_POSITION_FOLLOWING;
73
- const tabbables = focus.tabbable.find(container.current);
73
+ const tabbables = focus.tabbable.find(containerRef.current);
74
74
  if (tabbables.length) {
75
75
  const next = isBefore ? tabbables[0] : tabbables[tabbables.length - 1];
76
76
  next.focus();
@@ -102,19 +102,26 @@ export default function useTabNav() {
102
102
  if (event.keyCode !== TAB) {
103
103
  return;
104
104
  }
105
- if (!hasMultiSelection() && !getSelectedBlockClientId()) {
105
+ if (
106
+ // Bails in case the focus capture elements aren’t present. They
107
+ // may be omitted to avoid silent tab stops in preview mode.
108
+ // See: https://github.com/WordPress/gutenberg/pull/59317
109
+ !focusCaptureAfterRef.current || !focusCaptureBeforeRef.current) {
106
110
  return;
107
111
  }
108
- const isShift = event.shiftKey;
112
+ const {
113
+ target,
114
+ shiftKey: isShift
115
+ } = event;
109
116
  const direction = isShift ? 'findPrevious' : 'findNext';
110
- const nextTabbable = focus.tabbable[direction](event.target);
117
+ const nextTabbable = focus.tabbable[direction](target);
111
118
 
112
119
  // We want to constrain the tabbing to the block and its child blocks.
113
120
  // If the preceding form element is within a different block,
114
121
  // such as two sibling image blocks in the placeholder state,
115
122
  // we want shift + tab from the first form element to move to the image
116
123
  // block toolbar and not the previous image block's form element.
117
- const currentBlock = event.target.closest('[data-block]');
124
+ const currentBlock = target.closest('[data-block]');
118
125
  const isElementPartOfSelectedBlock = currentBlock && nextTabbable && (isInSameBlock(currentBlock, nextTabbable) || isInsideRootBlock(currentBlock, nextTabbable));
119
126
 
120
127
  // Allow tabbing from the block wrapper to a form element,
@@ -151,7 +158,7 @@ export default function useTabNav() {
151
158
 
152
159
  // If focus disappears due to there being no blocks, move focus to
153
160
  // the writing flow wrapper.
154
- if (!event.relatedTarget && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
161
+ if (!event.relatedTarget && event.target.hasAttribute('data-block') && ownerDocument.activeElement === ownerDocument.body && getBlockCount() === 0) {
155
162
  node.focus();
156
163
  }
157
164
  }
@@ -171,7 +178,7 @@ export default function useTabNav() {
171
178
  if (event.target?.getAttribute('role') === 'region') {
172
179
  return;
173
180
  }
174
- if (container.current === event.target) {
181
+ if (containerRef.current === event.target) {
175
182
  return;
176
183
  }
177
184
  const isShift = event.shiftKey;
@@ -200,7 +207,7 @@ export default function useTabNav() {
200
207
  node.removeEventListener('focusout', onFocusOut);
201
208
  };
202
209
  }, []);
203
- const mergedRefs = useMergeRefs([container, ref]);
210
+ const mergedRefs = useMergeRefs([containerRef, ref]);
204
211
  return [before, mergedRefs, after];
205
212
  }
206
213
  //# sourceMappingURL=use-tab-nav.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["focus","isFormElement","TAB","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","jsx","_jsx","useTabNav","container","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","getBlockOrder","getLastFocus","getSectionRootClientId","isZoomOut","setLastFocus","noCaptureRef","onFocusCapture","event","canvasElement","current","ownerDocument","target","defaultView","frameElement","querySelector","sectionRootClientId","sectionBlocks","length","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","next","before","ref","tabIndex","onFocus","after","node","onKeyDown","defaultPrevented","keyCode","isShift","shiftKey","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","preventScroll","onFocusOut","relatedTarget","activeElement","body","preventScrollOnTab","getAttribute","preventDefault","addEventListener","removeEventListener","mergedRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst container = useRef();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainer.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? container.current\n\t\t\t\t: container.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainer.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainer.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( container.current );\n\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( ! hasMultiSelection() && ! getSelectedBlockClientId() ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( event.target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = event.target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( container.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ container, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,EAAEC,aAAa,QAAQ,gBAAgB;AACrD,SAASC,GAAG,QAAQ,qBAAqB;AACzC,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,YAAY,EAAEC,YAAY,QAAQ,oBAAoB;AAC/D,SAASC,MAAM,QAAQ,oBAAoB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,aAAa;AACvD,SAASC,aAAa,EAAEC,iBAAiB,QAAQ,iBAAiB;AAClE,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,eAAe,SAASC,SAASA,CAAA,EAAG;EACnC,MAAMC,SAAS,GAAGT,MAAM,CAAC,CAAC;EAC1B,MAAMU,qBAAqB,GAAGV,MAAM,CAAC,CAAC;EACtC,MAAMW,oBAAoB,GAAGX,MAAM,CAAC,CAAC;EAErC,MAAM;IACLY,iBAAiB;IACjBC,wBAAwB;IACxBC,aAAa;IACbC,aAAa;IACbC,YAAY;IACZC,sBAAsB;IACtBC;EACD,CAAC,GAAGb,MAAM,CAAET,SAAS,CAAEM,gBAAiB,CAAE,CAAC;EAC3C,MAAM;IAAEiB;EAAa,CAAC,GAAGd,MAAM,CAAER,WAAW,CAAEK,gBAAiB,CAAE,CAAC;;EAElE;EACA;EACA,MAAMkB,YAAY,GAAGpB,MAAM,CAAC,CAAC;EAE7B,SAASqB,cAAcA,CAAEC,KAAK,EAAG;IAChC,MAAMC,aAAa,GAClBd,SAAS,CAACe,OAAO,CAACC,aAAa,KAAKH,KAAK,CAACI,MAAM,CAACD,aAAa,GAC3Dh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GAAG3B,KAAK,CAAC4B,QAAQ;MAC9B,MAAMC,SAAS,GAAGF,OAAO,GAAG,cAAc,GAAG,UAAU;MACvD,MAAMvB,MAAM,GAAGjC,KAAK,CAAC4C,QAAQ,CAAEc,SAAS,CAAE,CAAE7B,KAAK,CAACI,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKhB,qBAAqB,CAACc,OAAO,IACxCE,MAAM,KAAKf,oBAAoB,CAACa,OAAO,EACtC;QACDF,KAAK,CAACyC,cAAc,CAAC,CAAC;QACtBrC,MAAM,CAACjC,KAAK,CAAE;UAAE+D,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAE/B;IAAc,CAAC,GAAGoB,IAAI;IAC9B,MAAM;MAAElB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACqC,gBAAgB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;IAC7DhB,IAAI,CAACmB,gBAAgB,CAAE,SAAS,EAAElB,SAAU,CAAC;IAC7CD,IAAI,CAACmB,gBAAgB,CAAE,UAAU,EAAEP,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZ9B,WAAW,CAACsC,mBAAmB,CAAE,SAAS,EAAEJ,kBAAmB,CAAC;MAChEhB,IAAI,CAACoB,mBAAmB,CAAE,SAAS,EAAEnB,SAAU,CAAC;MAChDD,IAAI,CAACoB,mBAAmB,CAAE,UAAU,EAAER,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMS,UAAU,GAAGnE,YAAY,CAAE,CAAEU,SAAS,EAAEgC,GAAG,CAAG,CAAC;EAErD,OAAO,CAAED,MAAM,EAAE0B,UAAU,EAAEtB,KAAK,CAAE;AACrC","ignoreList":[]}
1
+ {"version":3,"names":["focus","isFormElement","TAB","useSelect","useDispatch","useRefEffect","useMergeRefs","useRef","store","blockEditorStore","isInSameBlock","isInsideRootBlock","unlock","jsx","_jsx","useTabNav","containerRef","focusCaptureBeforeRef","focusCaptureAfterRef","hasMultiSelection","getSelectedBlockClientId","getBlockCount","getBlockOrder","getLastFocus","getSectionRootClientId","isZoomOut","setLastFocus","noCaptureRef","onFocusCapture","event","canvasElement","current","ownerDocument","target","defaultView","frameElement","querySelector","sectionRootClientId","sectionBlocks","length","isBefore","compareDocumentPosition","DOCUMENT_POSITION_FOLLOWING","tabbables","tabbable","find","next","before","ref","tabIndex","onFocus","after","node","onKeyDown","defaultPrevented","keyCode","shiftKey","isShift","direction","nextTabbable","currentBlock","closest","isElementPartOfSelectedBlock","preventScroll","onFocusOut","relatedTarget","hasAttribute","activeElement","body","preventScrollOnTab","getAttribute","preventDefault","addEventListener","removeEventListener","mergedRefs"],"sources":["@wordpress/block-editor/src/components/writing-flow/use-tab-nav.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { focus, isFormElement } from '@wordpress/dom';\nimport { TAB } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useRefEffect, useMergeRefs } from '@wordpress/compose';\nimport { useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { store as blockEditorStore } from '../../store';\nimport { isInSameBlock, isInsideRootBlock } from '../../utils/dom';\nimport { unlock } from '../../lock-unlock';\n\nexport default function useTabNav() {\n\tconst containerRef = /** @type {typeof useRef<HTMLElement>} */ ( useRef )();\n\tconst focusCaptureBeforeRef = useRef();\n\tconst focusCaptureAfterRef = useRef();\n\n\tconst {\n\t\thasMultiSelection,\n\t\tgetSelectedBlockClientId,\n\t\tgetBlockCount,\n\t\tgetBlockOrder,\n\t\tgetLastFocus,\n\t\tgetSectionRootClientId,\n\t\tisZoomOut,\n\t} = unlock( useSelect( blockEditorStore ) );\n\tconst { setLastFocus } = unlock( useDispatch( blockEditorStore ) );\n\n\t// Reference that holds the a flag for enabling or disabling\n\t// capturing on the focus capture elements.\n\tconst noCaptureRef = useRef();\n\n\tfunction onFocusCapture( event ) {\n\t\tconst canvasElement =\n\t\t\tcontainerRef.current.ownerDocument === event.target.ownerDocument\n\t\t\t\t? containerRef.current\n\t\t\t\t: containerRef.current.ownerDocument.defaultView.frameElement;\n\n\t\t// Do not capture incoming focus if set by us in WritingFlow.\n\t\tif ( noCaptureRef.current ) {\n\t\t\tnoCaptureRef.current = null;\n\t\t} else if ( hasMultiSelection() ) {\n\t\t\tcontainerRef.current.focus();\n\t\t} else if ( getSelectedBlockClientId() ) {\n\t\t\tif ( getLastFocus()?.current ) {\n\t\t\t\tgetLastFocus().current.focus();\n\t\t\t} else {\n\t\t\t\t// Handles when the last focus has not been set yet, or has been cleared by new blocks being added via the inserter.\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector(\n\t\t\t\t\t\t`[data-block=\"${ getSelectedBlockClientId() }\"]`\n\t\t\t\t\t)\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t}\n\t\t// In \"compose\" mode without a selected ID, we want to place focus on the section root when tabbing to the canvas.\n\t\telse if ( isZoomOut() ) {\n\t\t\tconst sectionRootClientId = getSectionRootClientId();\n\t\t\tconst sectionBlocks = getBlockOrder( sectionRootClientId );\n\n\t\t\t// If we have section within the section root, focus the first one.\n\t\t\tif ( sectionBlocks.length ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionBlocks[ 0 ] }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t}\n\t\t\t// If we don't have any section blocks, focus the section root.\n\t\t\telse if ( sectionRootClientId ) {\n\t\t\t\tcontainerRef.current\n\t\t\t\t\t.querySelector( `[data-block=\"${ sectionRootClientId }\"]` )\n\t\t\t\t\t.focus();\n\t\t\t} else {\n\t\t\t\t// If we don't have any section root, focus the canvas.\n\t\t\t\tcanvasElement.focus();\n\t\t\t}\n\t\t} else {\n\t\t\tconst isBefore =\n\t\t\t\t// eslint-disable-next-line no-bitwise\n\t\t\t\tevent.target.compareDocumentPosition( canvasElement ) &\n\t\t\t\tevent.target.DOCUMENT_POSITION_FOLLOWING;\n\t\t\tconst tabbables = focus.tabbable.find( containerRef.current );\n\t\t\tif ( tabbables.length ) {\n\t\t\t\tconst next = isBefore\n\t\t\t\t\t? tabbables[ 0 ]\n\t\t\t\t\t: tabbables[ tabbables.length - 1 ];\n\t\t\t\tnext.focus();\n\t\t\t}\n\t\t}\n\t}\n\n\tconst before = (\n\t\t<div\n\t\t\tref={ focusCaptureBeforeRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst after = (\n\t\t<div\n\t\t\tref={ focusCaptureAfterRef }\n\t\t\ttabIndex=\"0\"\n\t\t\tonFocus={ onFocusCapture }\n\t\t/>\n\t);\n\n\tconst ref = useRefEffect( ( node ) => {\n\t\tfunction onKeyDown( event ) {\n\t\t\tif ( event.defaultPrevented ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// In Edit mode, Tab should focus the first tabbable element after\n\t\t\t// the content, which is normally the sidebar (with block controls)\n\t\t\t// and Shift+Tab should focus the first tabbable element before the\n\t\t\t// content, which is normally the block toolbar.\n\t\t\t// Arrow keys can be used, and Tab and arrow keys can be used in\n\t\t\t// Navigation mode (press Esc), to navigate through blocks.\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\t// Bails in case the focus capture elements aren’t present. They\n\t\t\t\t// may be omitted to avoid silent tab stops in preview mode.\n\t\t\t\t// See: https://github.com/WordPress/gutenberg/pull/59317\n\t\t\t\t! focusCaptureAfterRef.current ||\n\t\t\t\t! focusCaptureBeforeRef.current\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst { target, shiftKey: isShift } = event;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst nextTabbable = focus.tabbable[ direction ]( target );\n\n\t\t\t// We want to constrain the tabbing to the block and its child blocks.\n\t\t\t// If the preceding form element is within a different block,\n\t\t\t// such as two sibling image blocks in the placeholder state,\n\t\t\t// we want shift + tab from the first form element to move to the image\n\t\t\t// block toolbar and not the previous image block's form element.\n\t\t\tconst currentBlock = target.closest( '[data-block]' );\n\t\t\tconst isElementPartOfSelectedBlock =\n\t\t\t\tcurrentBlock &&\n\t\t\t\tnextTabbable &&\n\t\t\t\t( isInSameBlock( currentBlock, nextTabbable ) ||\n\t\t\t\t\tisInsideRootBlock( currentBlock, nextTabbable ) );\n\n\t\t\t// Allow tabbing from the block wrapper to a form element,\n\t\t\t// and between form elements rendered in a block and its child blocks,\n\t\t\t// such as inside a placeholder. Form elements are generally\n\t\t\t// meant to be UI rather than part of the content. Ideally\n\t\t\t// these are not rendered in the content and perhaps in the\n\t\t\t// future they can be rendered in an iframe or shadow DOM.\n\t\t\tif (\n\t\t\t\tisFormElement( nextTabbable ) &&\n\t\t\t\tisElementPartOfSelectedBlock\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst next = isShift ? focusCaptureBeforeRef : focusCaptureAfterRef;\n\n\t\t\t// Disable focus capturing on the focus capture element, so it\n\t\t\t// doesn't refocus this block and so it allows default behaviour\n\t\t\t// (moving focus to the next tabbable element).\n\t\t\tnoCaptureRef.current = true;\n\n\t\t\t// Focusing the focus capture element, which is located above and\n\t\t\t// below the editor, should not scroll the page all the way up or\n\t\t\t// down.\n\t\t\tnext.current.focus( { preventScroll: true } );\n\t\t}\n\n\t\tfunction onFocusOut( event ) {\n\t\t\tsetLastFocus( { ...getLastFocus(), current: event.target } );\n\n\t\t\tconst { ownerDocument } = node;\n\n\t\t\t// If focus disappears due to there being no blocks, move focus to\n\t\t\t// the writing flow wrapper.\n\t\t\tif (\n\t\t\t\t! event.relatedTarget &&\n\t\t\t\tevent.target.hasAttribute( 'data-block' ) &&\n\t\t\t\townerDocument.activeElement === ownerDocument.body &&\n\t\t\t\tgetBlockCount() === 0\n\t\t\t) {\n\t\t\t\tnode.focus();\n\t\t\t}\n\t\t}\n\n\t\t// When tabbing back to an element in block list, this event handler prevents scrolling if the\n\t\t// focus capture divs (before/after) are outside of the viewport. (For example shift+tab back to a paragraph\n\t\t// when focus is on a sidebar element. This prevents the scrollable writing area from jumping either to the\n\t\t// top or bottom of the document.\n\t\t//\n\t\t// Note that it isn't possible to disable scrolling in the onFocus event. We need to intercept this\n\t\t// earlier in the keypress handler, and call focus( { preventScroll: true } ) instead.\n\t\t// https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus#parameters\n\t\tfunction preventScrollOnTab( event ) {\n\t\t\tif ( event.keyCode !== TAB ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( event.target?.getAttribute( 'role' ) === 'region' ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif ( containerRef.current === event.target ) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst isShift = event.shiftKey;\n\t\t\tconst direction = isShift ? 'findPrevious' : 'findNext';\n\t\t\tconst target = focus.tabbable[ direction ]( event.target );\n\t\t\t// Only do something when the next tabbable is a focus capture div (before/after)\n\t\t\tif (\n\t\t\t\ttarget === focusCaptureBeforeRef.current ||\n\t\t\t\ttarget === focusCaptureAfterRef.current\n\t\t\t) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\ttarget.focus( { preventScroll: true } );\n\t\t\t}\n\t\t}\n\n\t\tconst { ownerDocument } = node;\n\t\tconst { defaultView } = ownerDocument;\n\t\tdefaultView.addEventListener( 'keydown', preventScrollOnTab );\n\t\tnode.addEventListener( 'keydown', onKeyDown );\n\t\tnode.addEventListener( 'focusout', onFocusOut );\n\t\treturn () => {\n\t\t\tdefaultView.removeEventListener( 'keydown', preventScrollOnTab );\n\t\t\tnode.removeEventListener( 'keydown', onKeyDown );\n\t\t\tnode.removeEventListener( 'focusout', onFocusOut );\n\t\t};\n\t}, [] );\n\n\tconst mergedRefs = useMergeRefs( [ containerRef, ref ] );\n\n\treturn [ before, mergedRefs, after ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA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AAS,CAAE,CAAE7B,KAAK,CAACI,MAAO,CAAC;MAC1D;MACA,IACCA,MAAM,KAAKhB,qBAAqB,CAACc,OAAO,IACxCE,MAAM,KAAKf,oBAAoB,CAACa,OAAO,EACtC;QACDF,KAAK,CAAC0C,cAAc,CAAC,CAAC;QACtBtC,MAAM,CAACjC,KAAK,CAAE;UAAE+D,aAAa,EAAE;QAAK,CAAE,CAAC;MACxC;IACD;IAEA,MAAM;MAAE/B;IAAc,CAAC,GAAGoB,IAAI;IAC9B,MAAM;MAAElB;IAAY,CAAC,GAAGF,aAAa;IACrCE,WAAW,CAACsC,gBAAgB,CAAE,SAAS,EAAEH,kBAAmB,CAAC;IAC7DjB,IAAI,CAACoB,gBAAgB,CAAE,SAAS,EAAEnB,SAAU,CAAC;IAC7CD,IAAI,CAACoB,gBAAgB,CAAE,UAAU,EAAER,UAAW,CAAC;IAC/C,OAAO,MAAM;MACZ9B,WAAW,CAACuC,mBAAmB,CAAE,SAAS,EAAEJ,kBAAmB,CAAC;MAChEjB,IAAI,CAACqB,mBAAmB,CAAE,SAAS,EAAEpB,SAAU,CAAC;MAChDD,IAAI,CAACqB,mBAAmB,CAAE,UAAU,EAAET,UAAW,CAAC;IACnD,CAAC;EACF,CAAC,EAAE,EAAG,CAAC;EAEP,MAAMU,UAAU,GAAGpE,YAAY,CAAE,CAAEU,YAAY,EAAEgC,GAAG,CAAG,CAAC;EAExD,OAAO,CAAED,MAAM,EAAE2B,UAAU,EAAEvB,KAAK,CAAE;AACrC","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-editor",
3
- "version": "14.14.0",
3
+ "version": "14.14.2",
4
4
  "description": "Generic block editor.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -37,38 +37,38 @@
37
37
  "@emotion/react": "^11.7.1",
38
38
  "@emotion/styled": "^11.6.0",
39
39
  "@react-spring/web": "^9.4.5",
40
- "@wordpress/a11y": "^4.19.0",
41
- "@wordpress/api-fetch": "^7.19.0",
42
- "@wordpress/blob": "^4.19.0",
43
- "@wordpress/block-serialization-default-parser": "^5.19.0",
44
- "@wordpress/blocks": "^14.8.0",
45
- "@wordpress/commands": "^1.19.0",
46
- "@wordpress/components": "^29.5.0",
47
- "@wordpress/compose": "^7.19.0",
48
- "@wordpress/data": "^10.19.0",
49
- "@wordpress/date": "^5.19.0",
50
- "@wordpress/deprecated": "^4.19.0",
51
- "@wordpress/dom": "^4.19.0",
52
- "@wordpress/element": "^6.19.0",
53
- "@wordpress/escape-html": "^3.19.0",
54
- "@wordpress/hooks": "^4.19.0",
55
- "@wordpress/html-entities": "^4.19.0",
56
- "@wordpress/i18n": "^5.19.0",
57
- "@wordpress/icons": "^10.19.0",
58
- "@wordpress/is-shallow-equal": "^5.19.0",
59
- "@wordpress/keyboard-shortcuts": "^5.19.0",
60
- "@wordpress/keycodes": "^4.19.0",
61
- "@wordpress/notices": "^5.19.0",
62
- "@wordpress/preferences": "^4.19.0",
63
- "@wordpress/priority-queue": "^3.19.0",
64
- "@wordpress/private-apis": "^1.19.0",
65
- "@wordpress/rich-text": "^7.19.0",
66
- "@wordpress/style-engine": "^2.19.0",
67
- "@wordpress/token-list": "^3.19.0",
68
- "@wordpress/upload-media": "^0.4.0",
69
- "@wordpress/url": "^4.19.0",
70
- "@wordpress/warning": "^3.19.0",
71
- "@wordpress/wordcount": "^4.19.0",
40
+ "@wordpress/a11y": "^4.19.1",
41
+ "@wordpress/api-fetch": "^7.19.1",
42
+ "@wordpress/blob": "^4.19.1",
43
+ "@wordpress/block-serialization-default-parser": "^5.19.1",
44
+ "@wordpress/blocks": "^14.8.1",
45
+ "@wordpress/commands": "^1.19.1",
46
+ "@wordpress/components": "^29.5.1",
47
+ "@wordpress/compose": "^7.19.1",
48
+ "@wordpress/data": "^10.19.1",
49
+ "@wordpress/date": "^5.19.1",
50
+ "@wordpress/deprecated": "^4.19.1",
51
+ "@wordpress/dom": "^4.19.1",
52
+ "@wordpress/element": "^6.19.1",
53
+ "@wordpress/escape-html": "^3.19.1",
54
+ "@wordpress/hooks": "^4.19.1",
55
+ "@wordpress/html-entities": "^4.19.1",
56
+ "@wordpress/i18n": "^5.19.1",
57
+ "@wordpress/icons": "^10.19.1",
58
+ "@wordpress/is-shallow-equal": "^5.19.1",
59
+ "@wordpress/keyboard-shortcuts": "^5.19.1",
60
+ "@wordpress/keycodes": "^4.19.1",
61
+ "@wordpress/notices": "^5.19.1",
62
+ "@wordpress/preferences": "^4.19.1",
63
+ "@wordpress/priority-queue": "^3.19.1",
64
+ "@wordpress/private-apis": "^1.19.1",
65
+ "@wordpress/rich-text": "^7.19.1",
66
+ "@wordpress/style-engine": "^2.19.1",
67
+ "@wordpress/token-list": "^3.19.1",
68
+ "@wordpress/upload-media": "^0.4.1",
69
+ "@wordpress/url": "^4.19.1",
70
+ "@wordpress/warning": "^3.19.1",
71
+ "@wordpress/wordcount": "^4.19.1",
72
72
  "change-case": "^4.1.2",
73
73
  "clsx": "^2.1.1",
74
74
  "colord": "^2.7.0",
@@ -91,5 +91,5 @@
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "d6b0b20fa927b110140dc7fdd906a7e0bf662004"
94
+ "gitHead": "ebddb7a8df3d45e83f318436516d9b6225486703"
95
95
  }
@@ -14,7 +14,7 @@ const scrollContainerCache = new WeakMap();
14
14
  * @param {Object} contentRef
15
15
  */
16
16
  function usePopoverScroll( contentRef ) {
17
- return useRefEffect(
17
+ const effect = useRefEffect(
18
18
  ( node ) => {
19
19
  function onWheel( event ) {
20
20
  const { deltaX, deltaY } = event;
@@ -36,6 +36,7 @@ function usePopoverScroll( contentRef ) {
36
36
  },
37
37
  [ contentRef ]
38
38
  );
39
+ return contentRef ? effect : null;
39
40
  }
40
41
 
41
42
  export default usePopoverScroll;
@@ -21,6 +21,7 @@ import {
21
21
  INSERTER_PATTERN_TYPES,
22
22
  allPatternsCategory,
23
23
  myPatternsCategory,
24
+ starterPatternsCategory,
24
25
  } from '../block-patterns-tab/utils';
25
26
 
26
27
  function PatternsListHeader( { filterValue, filteredBlockPatternsLength } ) {
@@ -85,6 +86,12 @@ function PatternList( {
85
86
  ) {
86
87
  return true;
87
88
  }
89
+ if (
90
+ selectedCategory === starterPatternsCategory.name &&
91
+ pattern.blockTypes?.includes( 'core/post-content' )
92
+ ) {
93
+ return true;
94
+ }
88
95
  if ( selectedCategory === 'uncategorized' ) {
89
96
  const hasKnownCategory =
90
97
  pattern.categories?.some( ( category ) =>
@@ -114,18 +114,16 @@ const LinkControlSearchInput = forwardRef(
114
114
  }
115
115
  };
116
116
 
117
- const inputLabel = placeholder ?? __( 'Search or type URL' );
118
-
119
117
  return (
120
118
  <div className="block-editor-link-control__search-input-container">
121
119
  <URLInput
122
120
  disableSuggestions={ currentLink?.url === value }
123
- label={ inputLabel }
121
+ label={ __( 'Link' ) }
124
122
  hideLabelFromVision={ hideLabelFromVision }
125
123
  className={ className }
126
124
  value={ value }
127
125
  onChange={ onInputChange }
128
- placeholder={ inputLabel }
126
+ placeholder={ placeholder ?? __( 'Search or type URL' ) }
129
127
  __experimentalRenderSuggestions={
130
128
  showSuggestions ? handleRenderSuggestions : null
131
129
  }