@wordpress/block-editor 12.3.5 → 12.3.7

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 (76) hide show
  1. package/build/components/block-draggable/index.js +6 -3
  2. package/build/components/block-draggable/index.js.map +1 -1
  3. package/build/components/iframe/index.js +21 -46
  4. package/build/components/iframe/index.js.map +1 -1
  5. package/build/components/inserter/reusable-block-rename-hint.js +1 -1
  6. package/build/components/inserter/reusable-block-rename-hint.js.map +1 -1
  7. package/build/components/link-control/constants.js +1 -1
  8. package/build/components/link-control/constants.js.map +1 -1
  9. package/build/components/link-control/search-create-button.js +5 -21
  10. package/build/components/link-control/search-create-button.js.map +1 -1
  11. package/build/components/link-control/search-item.js +13 -30
  12. package/build/components/link-control/search-item.js.map +1 -1
  13. package/build/components/link-control/search-results.js +2 -2
  14. package/build/components/link-control/search-results.js.map +1 -1
  15. package/build/components/rich-text/content.js +0 -36
  16. package/build/components/rich-text/content.js.map +1 -1
  17. package/build/components/rich-text/get-rich-text-values.js +112 -0
  18. package/build/components/rich-text/get-rich-text-values.js.map +1 -0
  19. package/build/components/use-block-display-information/index.js +7 -3
  20. package/build/components/use-block-display-information/index.js.map +1 -1
  21. package/build/hooks/margin.js +1 -1
  22. package/build/hooks/margin.js.map +1 -1
  23. package/build/hooks/padding.js +1 -1
  24. package/build/hooks/padding.js.map +1 -1
  25. package/build/private-apis.js +2 -2
  26. package/build/private-apis.js.map +1 -1
  27. package/build/store/selectors.js +1 -1
  28. package/build/store/selectors.js.map +1 -1
  29. package/build-module/components/block-draggable/index.js +6 -3
  30. package/build-module/components/block-draggable/index.js.map +1 -1
  31. package/build-module/components/iframe/index.js +22 -47
  32. package/build-module/components/iframe/index.js.map +1 -1
  33. package/build-module/components/inserter/reusable-block-rename-hint.js +1 -1
  34. package/build-module/components/inserter/reusable-block-rename-hint.js.map +1 -1
  35. package/build-module/components/link-control/constants.js +1 -1
  36. package/build-module/components/link-control/constants.js.map +1 -1
  37. package/build-module/components/link-control/search-create-button.js +7 -20
  38. package/build-module/components/link-control/search-create-button.js.map +1 -1
  39. package/build-module/components/link-control/search-item.js +14 -28
  40. package/build-module/components/link-control/search-item.js.map +1 -1
  41. package/build-module/components/link-control/search-results.js +3 -3
  42. package/build-module/components/link-control/search-results.js.map +1 -1
  43. package/build-module/components/rich-text/content.js +1 -36
  44. package/build-module/components/rich-text/content.js.map +1 -1
  45. package/build-module/components/rich-text/get-rich-text-values.js +99 -0
  46. package/build-module/components/rich-text/get-rich-text-values.js.map +1 -0
  47. package/build-module/components/use-block-display-information/index.js +7 -3
  48. package/build-module/components/use-block-display-information/index.js.map +1 -1
  49. package/build-module/hooks/margin.js +1 -1
  50. package/build-module/hooks/margin.js.map +1 -1
  51. package/build-module/hooks/padding.js +1 -1
  52. package/build-module/hooks/padding.js.map +1 -1
  53. package/build-module/private-apis.js +1 -1
  54. package/build-module/private-apis.js.map +1 -1
  55. package/build-module/store/selectors.js +1 -1
  56. package/build-module/store/selectors.js.map +1 -1
  57. package/build-style/style-rtl.css +20 -83
  58. package/build-style/style.css +20 -83
  59. package/package.json +5 -5
  60. package/src/components/block-draggable/index.js +13 -4
  61. package/src/components/iframe/index.js +16 -47
  62. package/src/components/inserter/reusable-block-rename-hint.js +1 -1
  63. package/src/components/link-control/constants.js +1 -1
  64. package/src/components/link-control/search-create-button.js +8 -26
  65. package/src/components/link-control/search-item.js +21 -43
  66. package/src/components/link-control/search-results.js +48 -46
  67. package/src/components/link-control/style.scss +25 -95
  68. package/src/components/link-control/test/index.js +6 -7
  69. package/src/components/rich-text/content.js +1 -46
  70. package/src/components/rich-text/get-rich-text-values.js +95 -0
  71. package/src/components/use-block-display-information/index.js +12 -5
  72. package/src/hooks/margin.js +4 -1
  73. package/src/hooks/padding.js +4 -1
  74. package/src/private-apis.js +1 -1
  75. package/src/store/selectors.js +1 -1
  76. package/src/store/test/selectors.js +1 -1
@@ -30,17 +30,20 @@ const BlockDraggable = ({
30
30
  const {
31
31
  canMoveBlocks,
32
32
  getBlockRootClientId,
33
- getBlockName
33
+ getBlockName,
34
+ getBlockAttributes
34
35
  } = select(blockEditorStore);
35
36
  const {
36
- getBlockType
37
+ getBlockType,
38
+ getActiveBlockVariation
37
39
  } = select(blocksStore);
38
40
  const rootClientId = getBlockRootClientId(clientIds[0]);
39
41
  const blockName = getBlockName(clientIds[0]);
42
+ const variation = getActiveBlockVariation(blockName, getBlockAttributes(clientIds[0]));
40
43
  return {
41
44
  srcRootClientId: rootClientId,
42
45
  isDraggable: canMoveBlocks(clientIds, rootClientId),
43
- icon: getBlockType(blockName)?.icon
46
+ icon: variation?.icon || getBlockType(blockName)?.icon
44
47
  };
45
48
  }, [clientIds]);
46
49
  const isDragging = useRef(false);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockType","rootClientId","blockName","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","window","requestAnimationFrame","length","onDraggableStart","onDraggableEnd"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,SAAT,QAA0B,uBAA1B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,SAAT,EAAoBC,MAApB,QAAkC,oBAAlC;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,kBAA/B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;AACA,SAASR,KAAK,IAAIS,gBAAlB,QAA0C,aAA1C;;AAEA,MAAMC,cAAc,GAAG,CAAE;AACxBC,EAAAA,QADwB;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encies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canMoveBlocks, getBlockRootClientId, getBlockName } =\n\t\t\t\tselect( blockEditorStore );\n\t\t\tconst { getBlockType } = select( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/block-draggable/index.js"],"names":["store","blocksStore","Draggable","useSelect","useDispatch","useEffect","useRef","BlockDraggableChip","useScrollWhenDragging","blockEditorStore","BlockDraggable","children","clientIds","cloneClassname","onDragStart","onDragEnd","srcRootClientId","isDraggable","icon","select","canMoveBlocks","getBlockRootClientId","getBlockName","getBlockAttributes","getBlockType","getActiveBlockVariation","rootClientId","blockName","variation","isDragging","startScrolling","scrollOnDragOver","stopScrolling","startDraggingBlocks","stopDraggingBlocks","current","draggable","transferData","type","srcClientIds","event","window","requestAnimationFrame","length","onDraggableStart","onDraggableEnd"],"mappings":";;AAAA;AACA;A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,CAACM,OAAX,GAAqB,KAArB;AAEAH,MAAAA,aAAa;;AAEb,UAAKjB,SAAL,EAAiB;AAChBA,QAAAA,SAAS;AACT;AACD,KA5BF;AA6BC,IAAA,2BAA2B,EAC1B,cAAC,kBAAD;AAAoB,MAAA,KAAK,EAAGH,SAAS,CAAC+B,MAAtC;AAA+C,MAAA,IAAI,EAAGzB;AAAtD;AA9BF,KAiCG,CAAE;AAAE0B,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,GAAF,KAA4C;AAC7C,WAAOlC,QAAQ,CAAE;AAChByB,MAAAA,SAAS,EAAE,IADK;AAEhBtB,MAAAA,WAAW,EAAE8B,gBAFG;AAGhB7B,MAAAA,SAAS,EAAE8B;AAHK,KAAF,CAAf;AAKA,GAvCF,CADD;AA2CA,CArGD;;AAuGA,eAAenC,cAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Draggable } from '@wordpress/components';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport BlockDraggableChip from './draggable-chip';\nimport useScrollWhenDragging from './use-scroll-when-dragging';\nimport { store as blockEditorStore } from '../../store';\n\nconst BlockDraggable = ( {\n\tchildren,\n\tclientIds,\n\tcloneClassname,\n\tonDragStart,\n\tonDragEnd,\n} ) => {\n\tconst { srcRootClientId, isDraggable, icon } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tcanMoveBlocks,\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\tgetBlockName,\n\t\t\t\tgetBlockAttributes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst { getBlockType, getActiveBlockVariation } =\n\t\t\t\tselect( blocksStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientIds[ 0 ] );\n\t\t\tconst blockName = getBlockName( clientIds[ 0 ] );\n\t\t\tconst variation = getActiveBlockVariation(\n\t\t\t\tblockName,\n\t\t\t\tgetBlockAttributes( clientIds[ 0 ] )\n\t\t\t);\n\n\t\t\treturn {\n\t\t\t\tsrcRootClientId: rootClientId,\n\t\t\t\tisDraggable: canMoveBlocks( clientIds, rootClientId ),\n\t\t\t\ticon: variation?.icon || getBlockType( blockName )?.icon,\n\t\t\t};\n\t\t},\n\t\t[ clientIds ]\n\t);\n\tconst isDragging = useRef( false );\n\tconst [ startScrolling, scrollOnDragOver, stopScrolling ] =\n\t\tuseScrollWhenDragging();\n\n\tconst { startDraggingBlocks, stopDraggingBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\t// Stop dragging blocks if the block draggable is unmounted.\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tif ( isDragging.current ) {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t}\n\t\t};\n\t}, [] );\n\n\tif ( ! isDraggable ) {\n\t\treturn children( { draggable: false } );\n\t}\n\n\tconst transferData = {\n\t\ttype: 'block',\n\t\tsrcClientIds: clientIds,\n\t\tsrcRootClientId,\n\t};\n\n\treturn (\n\t\t<Draggable\n\t\t\tcloneClassname={ cloneClassname }\n\t\t\t__experimentalTransferDataType=\"wp-blocks\"\n\t\t\ttransferData={ transferData }\n\t\t\tonDragStart={ ( event ) => {\n\t\t\t\t// Defer hiding the dragged source element to the next\n\t\t\t\t// frame to enable dragging.\n\t\t\t\twindow.requestAnimationFrame( () => {\n\t\t\t\t\tstartDraggingBlocks( clientIds );\n\t\t\t\t\tisDragging.current = true;\n\n\t\t\t\t\tstartScrolling( event );\n\n\t\t\t\t\tif ( onDragStart ) {\n\t\t\t\t\t\tonDragStart();\n\t\t\t\t\t}\n\t\t\t\t} );\n\t\t\t} }\n\t\t\tonDragOver={ scrollOnDragOver }\n\t\t\tonDragEnd={ () => {\n\t\t\t\tstopDraggingBlocks();\n\t\t\t\tisDragging.current = false;\n\n\t\t\t\tstopScrolling();\n\n\t\t\t\tif ( onDragEnd ) {\n\t\t\t\t\tonDragEnd();\n\t\t\t\t}\n\t\t\t} }\n\t\t\t__experimentalDragComponent={\n\t\t\t\t<BlockDraggableChip count={ clientIds.length } icon={ icon } />\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onDraggableStart, onDraggableEnd } ) => {\n\t\t\t\treturn children( {\n\t\t\t\t\tdraggable: true,\n\t\t\t\t\tonDragStart: onDraggableStart,\n\t\t\t\t\tonDragEnd: onDraggableEnd,\n\t\t\t\t} );\n\t\t\t} }\n\t\t</Draggable>\n\t);\n};\n\nexport default BlockDraggable;\n"]}
@@ -8,7 +8,7 @@ import classnames from 'classnames';
8
8
  * WordPress dependencies
9
9
  */
10
10
 
11
- import { useState, createPortal, forwardRef, useMemo, useReducer, useEffect } from '@wordpress/element';
11
+ import { useState, createPortal, forwardRef, useMemo, useEffect } from '@wordpress/element';
12
12
  import { __ } from '@wordpress/i18n';
13
13
  import { useResizeObserver, useMergeRefs, useRefEffect, useDisabled } from '@wordpress/compose';
14
14
  import { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';
@@ -71,36 +71,6 @@ function bubbleEvents(doc) {
71
71
  }
72
72
  }
73
73
 
74
- function useParsedAssets(html) {
75
- return useMemo(() => {
76
- const doc = document.implementation.createHTMLDocument('');
77
- doc.body.innerHTML = html;
78
- return Array.from(doc.body.children);
79
- }, [html]);
80
- }
81
-
82
- async function loadScript(head, {
83
- id,
84
- src
85
- }) {
86
- return new Promise((resolve, reject) => {
87
- const script = head.ownerDocument.createElement('script');
88
- script.id = id;
89
-
90
- if (src) {
91
- script.src = src;
92
-
93
- script.onload = () => resolve();
94
-
95
- script.onerror = () => reject();
96
- } else {
97
- resolve();
98
- }
99
-
100
- head.appendChild(script);
101
- });
102
- }
103
-
104
74
  function Iframe({
105
75
  contentRef,
106
76
  children,
@@ -112,20 +82,23 @@ function Iframe({
112
82
  forwardedRef: ref,
113
83
  ...props
114
84
  }) {
115
- var _assets$styles;
116
-
117
- const assets = useSelect(select => select(blockEditorStore).getSettings().__unstableResolvedAssets, []);
118
- const [, forceRender] = useReducer(() => ({}));
85
+ const {
86
+ styles = '',
87
+ scripts = ''
88
+ } = useSelect(select => select(blockEditorStore).getSettings().__unstableResolvedAssets, []);
119
89
  const [iframeDocument, setIframeDocument] = useState();
120
90
  const [bodyClasses, setBodyClasses] = useState([]);
121
91
  const compatStyles = useCompatibilityStyles();
122
- const scripts = useParsedAssets(assets?.scripts);
123
92
  const clearerRef = useBlockSelectionClearer();
124
93
  const [before, writingFlowRef, after] = useWritingFlow();
125
94
  const [contentResizeListener, {
126
95
  height: contentHeight
127
96
  }] = useResizeObserver();
128
97
  const setRef = useRefEffect(node => {
98
+ node._load = () => {
99
+ setIframeDocument(node.contentDocument);
100
+ };
101
+
129
102
  let iFrameDocument; // Prevent the default browser action for files dropped outside of dropzones.
130
103
 
131
104
  function preventFileDropDefault(event) {
@@ -142,14 +115,12 @@ function Iframe({
142
115
  } = contentDocument;
143
116
  iFrameDocument = contentDocument;
144
117
  bubbleEvents(contentDocument);
145
- setIframeDocument(contentDocument);
146
118
  clearerRef(documentElement); // Ideally ALL classes that are added through get_body_class should
147
119
  // be added in the editor too, which we'll somehow have to get from
148
120
  // the server in the future (which will run the PHP filters).
149
121
 
150
122
  setBodyClasses(Array.from(ownerDocument.body.classList).filter(name => name.startsWith('admin-color-') || name.startsWith('post-type-') || name === 'wp-embed-responsive'));
151
123
  contentDocument.dir = ownerDocument.dir;
152
- documentElement.removeChild(contentDocument.body);
153
124
 
154
125
  for (const compatStyle of compatStyles) {
155
126
  if (contentDocument.getElementById(compatStyle.id)) {
@@ -172,21 +143,25 @@ function Iframe({
172
143
  iFrameDocument?.removeEventListener('drop', preventFileDropDefault);
173
144
  };
174
145
  }, []);
175
- const headRef = useRefEffect(element => {
176
- scripts.reduce((promise, script) => promise.then(() => loadScript(element, script)), Promise.resolve()).finally(() => {
177
- // When script are loaded, re-render blocks to allow them
178
- // to initialise.
179
- forceRender();
180
- });
181
- }, []);
182
146
  const disabledRef = useDisabled({
183
147
  isDisabled: !readonly
184
148
  });
185
- const bodyRef = useMergeRefs([contentRef, clearerRef, writingFlowRef, disabledRef, headRef]); // Correct doctype is required to enable rendering in standards
149
+ const bodyRef = useMergeRefs([contentRef, clearerRef, writingFlowRef, disabledRef]); // Correct doctype is required to enable rendering in standards
186
150
  // mode. Also preload the styles to avoid a flash of unstyled
187
151
  // content.
188
152
 
189
- const html = '<!doctype html>' + '<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>' + ((_assets$styles = assets?.styles) !== null && _assets$styles !== void 0 ? _assets$styles : '');
153
+ const html = `<!doctype html>
154
+ <html>
155
+ <head>
156
+ <script>window.frameElement._load()</script>
157
+ <style>html{height:auto!important;min-height:100%;}body{margin:0}</style>
158
+ ${styles}
159
+ ${scripts}
160
+ </head>
161
+ <body>
162
+ <script>document.currentScript.parentElement.remove()</script>
163
+ </body>
164
+ </html>`;
190
165
  const [src, cleanup] = useMemo(() => {
191
166
  const _src = URL.createObjectURL(new window.Blob([html], {
192
167
  type: 'text/html'
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useReducer","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","store","blockEditorStore","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","useParsedAssets","html","document","implementation","createHTMLDocument","body","innerHTML","Array","from","children","loadScript","head","id","src","Promise","resolve","reject","script","ownerDocument","createElement","onload","onerror","appendChild","Iframe","contentRef","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","assets","select","getSettings","__unstableResolvedAssets","forceRender","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","scripts","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","iFrameDocument","preventFileDropDefault","onLoad","contentDocument","documentElement","classList","filter","startsWith","dir","removeChild","compatStyle","getElementById","cloneNode","console","warn","removeEventListener","headRef","element","reduce","promise","then","finally","disabledRef","isDisabled","bodyRef","styles","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","style","marginTop","marginBottom","transform","transition","IframeIfReady","isInitialised","__internalIsInitialized"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,OAJD,EAKCC,UALD,EAMCC,SAND,QAOO,oBAPP;AAQA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,YAFD,EAGCC,YAHD,EAICC,WAJD,QAKO,oBALP;AAMA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AACA,SAASC,sBAAT,QAAuC,4BAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,aAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,YAAT,CAAuBC,GAAvB,EAA6B;AAC5B,QAAM;AAAEC,IAAAA;AAAF,MAAkBD,GAAxB;AACA,QAAM;AAAEE,IAAAA;AAAF,MAAmBD,WAAzB;;AAEA,WAASE,WAAT,CAAsBC,KAAtB,EAA8B;AAC7B,UAAMC,SAAS,GAAGC,MAAM,CAACC,cAAP,CAAuBH,KAAvB,CAAlB;AACA,UAAMI,eAAe,GAAGH,SAAS,CAACI,WAAV,CAAsBC,IAA9C;AACA,UAAMC,WAAW,GAAGC,MAAM,CAAEJ,eAAF,CAA1B;AAEA,UAAMK,IAA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B,GAEGM,KAAK,CAACsD,KAAN,EAAaG,SAdV;AAePC,MAAAA,UAAU,EAAE;AAfL,KAFT;AAmBC,IAAA,GAAG,EAAGnI,YAAY,CAAE,CAAEwE,GAAF,EAAOoB,MAAP,CAAF,CAnBnB;AAoBC,IAAA,QAAQ,EAAG1B,QApBZ,CAqBC;AACA;AACA;AAvBD;AAwBC,IAAA,GAAG,EAAGZ,GAxBP;AAyBC,IAAA,KAAK,EAAGxD,EAAE,CAAE,eAAF;AAzBX,KA2BGiF,cAAc,IACftF,YAAY,CACX;AACC,IAAA,GAAG,EAAG6H,OADP;AAEC,IAAA,SAAS,EAAG/H,UAAU,CACrB,2BADqB,EAErB,uBAFqB,EAGrB,GAAG0F,WAHkB;AAFvB,KAQGQ,qBARH,EASC,cAAC,aAAD;AAAe,IAAA,QAAQ,EAAGV;AAA1B,KACG7B,QADH,CATD,CADW,EAcX6B,cAAc,CAACmB,eAdJ,CA5Bd,CAFD,EA+CGhC,QAAQ,IAAI,CAAZ,IAAiBsB,KA/CpB,CADD;AAmDA;;AAED,SAAS4C,aAAT,CAAwB3D,KAAxB,EAA+BD,GAA/B,EAAqC;AACpC,QAAM6D,aAAa,GAAGhI,SAAS,CAC5BsE,MAAF,IACCA,MAAM,CAAEjE,gBAAF,CAAN,CAA2BkE,WAA3B,GAAyC0D,uBAFZ,EAG9B,EAH8B,CAA/B,CADoC,CAOpC;AACA;AACA;AACA;AACA;;AACA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,MAAD,OAAa5D,KAAb;AAAqB,IAAA,YAAY,EAAGD;AAApC,IAAP;AACA;;AAED,eAAe9E,UAAU,CAAE0I,aAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseReducer,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction useParsedAssets( html ) {\n\treturn useMemo( () => {\n\t\tconst doc = document.implementation.createHTMLDocument( '' );\n\t\tdoc.body.innerHTML = html;\n\t\treturn Array.from( doc.body.children );\n\t}, [ html ] );\n}\n\nasync function loadScript( head, { id, src } ) {\n\treturn new Promise( ( resolve, reject ) => {\n\t\tconst script = head.ownerDocument.createElement( 'script' );\n\t\tscript.id = id;\n\t\tif ( src ) {\n\t\t\tscript.src = src;\n\t\t\tscript.onload = () => resolve();\n\t\t\tscript.onerror = () => reject();\n\t\t} else {\n\t\t\tresolve();\n\t\t}\n\t\thead.appendChild( script );\n\t} );\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst assets = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__unstableResolvedAssets,\n\t\t[]\n\t);\n\tconst [ , forceRender ] = useReducer( () => ( {} ) );\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst scripts = useParsedAssets( assets?.scripts );\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tsetIframeDocument( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\t\t\tdocumentElement.removeChild( contentDocument.body );\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\tcompatStyle\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst headRef = useRefEffect( ( element ) => {\n\t\tscripts\n\t\t\t.reduce(\n\t\t\t\t( promise, script ) =>\n\t\t\t\t\tpromise.then( () => loadScript( element, script ) ),\n\t\t\t\tPromise.resolve()\n\t\t\t)\n\t\t\t.finally( () => {\n\t\t\t\t// When script are loaded, re-render blocks to allow them\n\t\t\t\t// to initialise.\n\t\t\t\tforceRender();\n\t\t\t} );\n\t}, [] );\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t\theadRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html =\n\t\t'<!doctype html>' +\n\t\t'<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>' +\n\t\t( assets?.styles ?? '' );\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/iframe/index.js"],"names":["classnames","useState","createPortal","forwardRef","useMemo","useEffect","__","useResizeObserver","useMergeRefs","useRefEffect","useDisabled","__experimentalStyleProvider","StyleProvider","useSelect","useBlockSelectionClearer","useWritingFlow","useCompatibilityStyles","store","blockEditorStore","bubbleEvents","doc","defaultView","frameElement","bubbleEvent","event","prototype","Object","getPrototypeOf","constructorName","constructor","name","Constructor","window","init","key","MouseEvent","rect","getBoundingClientRect","clientX","left","clientY","top","newEvent","type","cancelled","dispatchEvent","preventDefault","eventTypes","addEventListener","Iframe","contentRef","children","tabIndex","scale","frameSize","expand","readonly","forwardedRef","ref","props","styles","scripts","select","getSettings","__unstableResolvedAssets","iframeDocument","setIframeDocument","bodyClasses","setBodyClasses","compatStyles","clearerRef","before","writingFlowRef","after","contentResizeListener","height","contentHeight","setRef","node","_load","contentDocument","iFrameDocument","preventFileDropDefault","onLoad","ownerDocument","documentElement","Array","from","body","classList","filter","startsWith","dir","compatStyle","getElementById","id","head","appendChild","cloneNode","console","warn","removeEventListener","disabledRef","isDisabled","bodyRef","html","src","cleanup","_src","URL","createObjectURL","Blob","revokeObjectURL","marginFromScaling","style","marginTop","marginBottom","transform","transition","IframeIfReady","isInitialised","__internalIsInitialized"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,UAHD,EAICC,OAJD,EAKCC,SALD,QAMO,oBANP;AAOA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SACCC,iBADD,EAECC,YAFD,EAGCC,YAHD,EAICC,WAJD,QAKO,oBALP;AAMA,SAASC,2BAA2B,IAAIC,aAAxC,QAA6D,uBAA7D;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,4BAAzC;AACA,SAASC,cAAT,QAA+B,iBAA/B;AACA,SAASC,sBAAT,QAAuC,4BAAv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;;AACA,MAAK,CAAED,aAAP,EAAuB;AACtB,WAAO,IAAP;AACA;;AAED,SAAO,cAAC,MAAD,OAAa7D,KAAb;AAAqB,IAAA,YAAY,EAAGD;AAApC,IAAP;AACA;;AAED,eAAevD,UAAU,CAAEoH,aAAF,CAAzB","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tuseState,\n\tcreatePortal,\n\tforwardRef,\n\tuseMemo,\n\tuseEffect,\n} from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tuseResizeObserver,\n\tuseMergeRefs,\n\tuseRefEffect,\n\tuseDisabled,\n} from '@wordpress/compose';\nimport { __experimentalStyleProvider as StyleProvider } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { useBlockSelectionClearer } from '../block-selection-clearer';\nimport { useWritingFlow } from '../writing-flow';\nimport { useCompatibilityStyles } from './use-compatibility-styles';\nimport { store as blockEditorStore } from '../../store';\n\n/**\n * Bubbles some event types (keydown, keypress, and dragover) to parent document\n * document to ensure that the keyboard shortcuts and drag and drop work.\n *\n * Ideally, we should remove event bubbling in the future. Keyboard shortcuts\n * should be context dependent, e.g. actions on blocks like Cmd+A should not\n * work globally outside the block editor.\n *\n * @param {Document} doc Document to attach listeners to.\n */\nfunction bubbleEvents( doc ) {\n\tconst { defaultView } = doc;\n\tconst { frameElement } = defaultView;\n\n\tfunction bubbleEvent( event ) {\n\t\tconst prototype = Object.getPrototypeOf( event );\n\t\tconst constructorName = prototype.constructor.name;\n\t\tconst Constructor = window[ constructorName ];\n\n\t\tconst init = {};\n\n\t\tfor ( const key in event ) {\n\t\t\tinit[ key ] = event[ key ];\n\t\t}\n\n\t\tif ( event instanceof defaultView.MouseEvent ) {\n\t\t\tconst rect = frameElement.getBoundingClientRect();\n\t\t\tinit.clientX += rect.left;\n\t\t\tinit.clientY += rect.top;\n\t\t}\n\n\t\tconst newEvent = new Constructor( event.type, init );\n\t\tconst cancelled = ! frameElement.dispatchEvent( newEvent );\n\n\t\tif ( cancelled ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t}\n\n\tconst eventTypes = [ 'dragover', 'mousemove' ];\n\n\tfor ( const name of eventTypes ) {\n\t\tdoc.addEventListener( name, bubbleEvent );\n\t}\n}\n\nfunction Iframe( {\n\tcontentRef,\n\tchildren,\n\ttabIndex = 0,\n\tscale = 1,\n\tframeSize = 0,\n\texpand = false,\n\treadonly,\n\tforwardedRef: ref,\n\t...props\n} ) {\n\tconst { styles = '', scripts = '' } = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__unstableResolvedAssets,\n\t\t[]\n\t);\n\tconst [ iframeDocument, setIframeDocument ] = useState();\n\tconst [ bodyClasses, setBodyClasses ] = useState( [] );\n\tconst compatStyles = useCompatibilityStyles();\n\tconst clearerRef = useBlockSelectionClearer();\n\tconst [ before, writingFlowRef, after ] = useWritingFlow();\n\tconst [ contentResizeListener, { height: contentHeight } ] =\n\t\tuseResizeObserver();\n\tconst setRef = useRefEffect( ( node ) => {\n\t\tnode._load = () => {\n\t\t\tsetIframeDocument( node.contentDocument );\n\t\t};\n\t\tlet iFrameDocument;\n\t\t// Prevent the default browser action for files dropped outside of dropzones.\n\t\tfunction preventFileDropDefault( event ) {\n\t\t\tevent.preventDefault();\n\t\t}\n\t\tfunction onLoad() {\n\t\t\tconst { contentDocument, ownerDocument } = node;\n\t\t\tconst { documentElement } = contentDocument;\n\t\t\tiFrameDocument = contentDocument;\n\n\t\t\tbubbleEvents( contentDocument );\n\t\t\tclearerRef( documentElement );\n\n\t\t\t// Ideally ALL classes that are added through get_body_class should\n\t\t\t// be added in the editor too, which we'll somehow have to get from\n\t\t\t// the server in the future (which will run the PHP filters).\n\t\t\tsetBodyClasses(\n\t\t\t\tArray.from( ownerDocument.body.classList ).filter(\n\t\t\t\t\t( name ) =>\n\t\t\t\t\t\tname.startsWith( 'admin-color-' ) ||\n\t\t\t\t\t\tname.startsWith( 'post-type-' ) ||\n\t\t\t\t\t\tname === 'wp-embed-responsive'\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tcontentDocument.dir = ownerDocument.dir;\n\n\t\t\tfor ( const compatStyle of compatStyles ) {\n\t\t\t\tif ( contentDocument.getElementById( compatStyle.id ) ) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tcontentDocument.head.appendChild(\n\t\t\t\t\tcompatStyle.cloneNode( true )\n\t\t\t\t);\n\n\t\t\t\t// eslint-disable-next-line no-console\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`${ compatStyle.id } was added to the iframe incorrectly. Please use block.json or enqueue_block_assets to add styles to the iframe.`,\n\t\t\t\t\tcompatStyle\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t\tiFrameDocument.addEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault,\n\t\t\t\tfalse\n\t\t\t);\n\t\t}\n\n\t\tnode.addEventListener( 'load', onLoad );\n\n\t\treturn () => {\n\t\t\tnode.removeEventListener( 'load', onLoad );\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'dragover',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t\tiFrameDocument?.removeEventListener(\n\t\t\t\t'drop',\n\t\t\t\tpreventFileDropDefault\n\t\t\t);\n\t\t};\n\t}, [] );\n\n\tconst disabledRef = useDisabled( { isDisabled: ! readonly } );\n\tconst bodyRef = useMergeRefs( [\n\t\tcontentRef,\n\t\tclearerRef,\n\t\twritingFlowRef,\n\t\tdisabledRef,\n\t] );\n\n\t// Correct doctype is required to enable rendering in standards\n\t// mode. Also preload the styles to avoid a flash of unstyled\n\t// content.\n\tconst html = `<!doctype html>\n<html>\n\t<head>\n\t\t<script>window.frameElement._load()</script>\n\t\t<style>html{height:auto!important;min-height:100%;}body{margin:0}</style>\n\t\t${ styles }\n\t\t${ scripts }\n\t</head>\n\t<body>\n\t\t<script>document.currentScript.parentElement.remove()</script>\n\t</body>\n</html>`;\n\n\tconst [ src, cleanup ] = useMemo( () => {\n\t\tconst _src = URL.createObjectURL(\n\t\t\tnew window.Blob( [ html ], { type: 'text/html' } )\n\t\t);\n\t\treturn [ _src, () => URL.revokeObjectURL( _src ) ];\n\t}, [ html ] );\n\n\tuseEffect( () => cleanup, [ cleanup ] );\n\n\t// We need to counter the margin created by scaling the iframe. If the scale\n\t// is e.g. 0.45, then the top + bottom margin is 0.55 (1 - scale). Just the\n\t// top or bottom margin is 0.55 / 2 ((1 - scale) / 2).\n\tconst marginFromScaling = ( contentHeight * ( 1 - scale ) ) / 2;\n\n\treturn (\n\t\t<>\n\t\t\t{ tabIndex >= 0 && before }\n\t\t\t<iframe\n\t\t\t\t{ ...props }\n\t\t\t\tstyle={ {\n\t\t\t\t\t...props.style,\n\t\t\t\t\theight: expand ? contentHeight : props.style?.height,\n\t\t\t\t\tmarginTop:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginTop,\n\t\t\t\t\tmarginBottom:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? -marginFromScaling + frameSize\n\t\t\t\t\t\t\t: props.style?.marginBottom,\n\t\t\t\t\ttransform:\n\t\t\t\t\t\tscale !== 1\n\t\t\t\t\t\t\t? `scale( ${ scale } )`\n\t\t\t\t\t\t\t: props.style?.transform,\n\t\t\t\t\ttransition: 'all .3s',\n\t\t\t\t} }\n\t\t\t\tref={ useMergeRefs( [ ref, setRef ] ) }\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t\t// Correct doctype is required to enable rendering in standards\n\t\t\t\t// mode. Also preload the styles to avoid a flash of unstyled\n\t\t\t\t// content.\n\t\t\t\tsrc={ src }\n\t\t\t\ttitle={ __( 'Editor canvas' ) }\n\t\t\t>\n\t\t\t\t{ iframeDocument &&\n\t\t\t\t\tcreatePortal(\n\t\t\t\t\t\t<body\n\t\t\t\t\t\t\tref={ bodyRef }\n\t\t\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t\t\t'block-editor-iframe__body',\n\t\t\t\t\t\t\t\t'editor-styles-wrapper',\n\t\t\t\t\t\t\t\t...bodyClasses\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ contentResizeListener }\n\t\t\t\t\t\t\t<StyleProvider document={ iframeDocument }>\n\t\t\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t\t</StyleProvider>\n\t\t\t\t\t\t</body>,\n\t\t\t\t\t\tiframeDocument.documentElement\n\t\t\t\t\t) }\n\t\t\t</iframe>\n\t\t\t{ tabIndex >= 0 && after }\n\t\t</>\n\t);\n}\n\nfunction IframeIfReady( props, ref ) {\n\tconst isInitialised = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockEditorStore ).getSettings().__internalIsInitialized,\n\t\t[]\n\t);\n\n\t// We shouldn't render the iframe until the editor settings are initialised.\n\t// The initial settings are needed to get the styles for the srcDoc, which\n\t// cannot be changed after the iframe is mounted. srcDoc is used to to set\n\t// the initial iframe HTML, which is required to avoid a flash of unstyled\n\t// content.\n\tif ( ! isInitialised ) {\n\t\treturn null;\n\t}\n\n\treturn <Iframe { ...props } forwardedRef={ ref } />;\n}\n\nexport default forwardRef( IframeIfReady );\n"]}
@@ -31,7 +31,7 @@ export default function ReusableBlocksRenameHint() {
31
31
  className: "reusable-blocks-menu-items__rename-hint"
32
32
  }, createElement("div", {
33
33
  className: "reusable-blocks-menu-items__rename-hint-content"
34
- }, __('Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.')), createElement(Button, {
34
+ }, __('Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.')), createElement(Button, {
35
35
  className: "reusable-blocks-menu-items__rename-hint-dismiss",
36
36
  icon: close,
37
37
  iconSize: "16",
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["Button","useDispatch","useSelect","focus","useRef","__","close","store","preferencesStore","PREFERENCE_NAME","ReusableBlocksRenameHint","isReusableBlocksRenameHint","select","get","ref","set","setPreference","previousElement","tabbable","findPrevious","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,MAAMC,eAAe,GAAG,oCAAxB;AAEA,eAAe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAGT,SAAS,CACzCU,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEJ,gBAAF,CAAN,CAA2BK,GAA3B,CAAgC,MAAhC,EAAwCJ,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GAD2C,EAG3C,EAH2C,CAA5C;AAMA,QAAMK,GAAG,GAAGV,MAAM,EAAlB;AAEA,QAAM;AAAEW,IAAAA,GAAG,EAAEC;AAAP,MAAyBf,WAAW,CAAEO,gBAAF,CAA1C;;AACA,MAAK,CAAEG,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGG,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,EAAE,CACH,oHADG,CADL,CADD,EAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGC,KAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAJX;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMY,eAAe,GAAGd,KAAK,CAACe,QAAN,CAAeC,YAAf,CACvBL,GAAG,CAACM,OADmB,CAAxB;AAGAH,MAAAA,eAAe,EAAEd,KAAjB;AACAa,MAAAA,aAAa,CAAE,MAAF,EAAUP,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now called patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/inserter/reusable-block-rename-hint.js"],"names":["Button","useDispatch","useSelect","focus","useRef","__","close","store","preferencesStore","PREFERENCE_NAME","ReusableBlocksRenameHint","isReusableBlocksRenameHint","select","get","ref","set","setPreference","previousElement","tabbable","findPrevious","current"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAT,QAAsB,gBAAtB;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAT,QAAsB,kBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,wBAA1C;AAEA,MAAMC,eAAe,GAAG,oCAAxB;AAEA,eAAe,SAASC,wBAAT,GAAoC;AAClD,QAAMC,0BAA0B,GAAGT,SAAS,CACzCU,MAAF;AAAA;;AAAA,0BACCA,MAAM,CAAEJ,gBAAF,CAAN,CAA2BK,GAA3B,CAAgC,MAAhC,EAAwCJ,eAAxC,CADD,qDAC8D,IAD9D;AAAA,GAD2C,EAG3C,EAH2C,CAA5C;AAMA,QAAMK,GAAG,GAAGV,MAAM,EAAlB;AAEA,QAAM;AAAEW,IAAAA,GAAG,EAAEC;AAAP,MAAyBf,WAAW,CAAEO,gBAAF,CAA1C;;AACA,MAAK,CAAEG,0BAAP,EAAoC;AACnC,WAAO,IAAP;AACA;;AAED,SACC;AAAK,IAAA,GAAG,EAAGG,GAAX;AAAiB,IAAA,SAAS,EAAC;AAA3B,KACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACGT,EAAE,CACH,oHADG,CADL,CADD,EAMC,cAAC,MAAD;AACC,IAAA,SAAS,EAAC,iDADX;AAEC,IAAA,IAAI,EAAGC,KAFR;AAGC,IAAA,QAAQ,EAAC,IAHV;AAIC,IAAA,KAAK,EAAGD,EAAE,CAAE,cAAF,CAJX;AAKC,IAAA,OAAO,EAAG,MAAM;AACf;AACA,YAAMY,eAAe,GAAGd,KAAK,CAACe,QAAN,CAAeC,YAAf,CACvBL,GAAG,CAACM,OADmB,CAAxB;AAGAH,MAAAA,eAAe,EAAEd,KAAjB;AACAa,MAAAA,aAAa,CAAE,MAAF,EAAUP,eAAV,EAA2B,KAA3B,CAAb;AACA,KAZF;AAaC,IAAA,WAAW,EAAG;AAbf,IAND,CADD;AAwBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { focus } from '@wordpress/dom';\nimport { useRef } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { close } from '@wordpress/icons';\nimport { store as preferencesStore } from '@wordpress/preferences';\n\nconst PREFERENCE_NAME = 'isResuableBlocksrRenameHintVisible';\n\nexport default function ReusableBlocksRenameHint() {\n\tconst isReusableBlocksRenameHint = useSelect(\n\t\t( select ) =>\n\t\t\tselect( preferencesStore ).get( 'core', PREFERENCE_NAME ) ?? true,\n\t\t[]\n\t);\n\n\tconst ref = useRef();\n\n\tconst { set: setPreference } = useDispatch( preferencesStore );\n\tif ( ! isReusableBlocksRenameHint ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div ref={ ref } className=\"reusable-blocks-menu-items__rename-hint\">\n\t\t\t<div className=\"reusable-blocks-menu-items__rename-hint-content\">\n\t\t\t\t{ __(\n\t\t\t\t\t'Reusable blocks are now synced patterns. A synced pattern will behave in exactly the same way as a reusable block.'\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<Button\n\t\t\t\tclassName=\"reusable-blocks-menu-items__rename-hint-dismiss\"\n\t\t\t\ticon={ close }\n\t\t\t\ticonSize=\"16\"\n\t\t\t\tlabel={ __( 'Dismiss hint' ) }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\t// Retain focus when dismissing the element.\n\t\t\t\t\tconst previousElement = focus.tabbable.findPrevious(\n\t\t\t\t\t\tref.current\n\t\t\t\t\t);\n\t\t\t\t\tpreviousElement?.focus();\n\t\t\t\t\tsetPreference( 'core', PREFERENCE_NAME, false );\n\t\t\t\t} }\n\t\t\t\tshowTooltip={ false }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"]}
@@ -7,7 +7,7 @@ import { __ } from '@wordpress/i18n'; // Used as a unique identifier for the "Cr
7
7
 
8
8
  export const CREATE_TYPE = '__CREATE__';
9
9
  export const TEL_TYPE = 'tel';
10
- export const URL_TYPE = 'URL';
10
+ export const URL_TYPE = 'link';
11
11
  export const MAILTO_TYPE = 'mailto';
12
12
  export const INTERNAL_TYPE = 'internal';
13
13
  export const LINK_ENTRY_TYPES = [URL_TYPE, MAILTO_TYPE, TEL_TYPE, INTERNAL_TYPE];
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["__","CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB,C,CAEA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,YAApB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,WAAW,GAAG,QAApB;AACP,OAAO,MAAMC,aAAa,GAAG,UAAtB;AAEP,OAAO,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;AAOP,OAAO,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAET,EAAE,CAAE,iBAAF;AAFV,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'URL';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/constants.js"],"names":["__","CREATE_TYPE","TEL_TYPE","URL_TYPE","MAILTO_TYPE","INTERNAL_TYPE","LINK_ENTRY_TYPES","DEFAULT_LINK_SETTINGS","id","title"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB,C,CAEA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG,YAApB;AACP,OAAO,MAAMC,QAAQ,GAAG,KAAjB;AACP,OAAO,MAAMC,QAAQ,GAAG,MAAjB;AACP,OAAO,MAAMC,WAAW,GAAG,QAApB;AACP,OAAO,MAAMC,aAAa,GAAG,UAAtB;AAEP,OAAO,MAAMC,gBAAgB,GAAG,CAC/BH,QAD+B,EAE/BC,WAF+B,EAG/BF,QAH+B,EAI/BG,aAJ+B,CAAzB;AAOP,OAAO,MAAME,qBAAqB,GAAG,CACpC;AACCC,EAAAA,EAAE,EAAE,eADL;AAECC,EAAAA,KAAK,EAAET,EAAE,CAAE,iBAAF;AAFV,CADoC,CAA9B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n// Used as a unique identifier for the \"Create\" option within search results.\n// Used to help distinguish the \"Create\" suggestion within the search results in\n// order to handle it as a unique case.\nexport const CREATE_TYPE = '__CREATE__';\nexport const TEL_TYPE = 'tel';\nexport const URL_TYPE = 'link';\nexport const MAILTO_TYPE = 'mailto';\nexport const INTERNAL_TYPE = 'internal';\n\nexport const LINK_ENTRY_TYPES = [\n\tURL_TYPE,\n\tMAILTO_TYPE,\n\tTEL_TYPE,\n\tINTERNAL_TYPE,\n];\n\nexport const DEFAULT_LINK_SETTINGS = [\n\t{\n\t\tid: 'opensInNewTab',\n\t\ttitle: __( 'Open in new tab' ),\n\t},\n];\n"]}
@@ -1,22 +1,16 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
6
  import { __, sprintf } from '@wordpress/i18n';
12
- import { Button } from '@wordpress/components';
7
+ import { MenuItem } from '@wordpress/components';
13
8
  import { createInterpolateElement } from '@wordpress/element';
14
- import { Icon, plus } from '@wordpress/icons';
9
+ import { plus } from '@wordpress/icons';
15
10
  export const LinkControlSearchCreate = ({
16
11
  searchTerm,
17
12
  onClick,
18
13
  itemProps,
19
- isSelected,
20
14
  buttonText
21
15
  }) => {
22
16
  if (!searchTerm) {
@@ -35,19 +29,12 @@ export const LinkControlSearchCreate = ({
35
29
  });
36
30
  }
37
31
 
38
- return createElement(Button, { ...itemProps,
39
- className: classnames('block-editor-link-control__search-create block-editor-link-control__search-item', {
40
- 'is-selected': isSelected
41
- }),
32
+ return createElement(MenuItem, { ...itemProps,
33
+ iconPosition: "left",
34
+ icon: plus,
35
+ className: "block-editor-link-control__search-item",
42
36
  onClick: onClick
43
- }, createElement(Icon, {
44
- className: "block-editor-link-control__search-item-icon",
45
- icon: plus
46
- }), createElement("span", {
47
- className: "block-editor-link-control__search-item-header"
48
- }, createElement("span", {
49
- className: "block-editor-link-control__search-item-title"
50
- }, text)));
37
+ }, text);
51
38
  };
52
39
  export default LinkControlSearchCreate;
53
40
  //# sourceMappingURL=search-create-button.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["classnames","__","sprintf","Button","createInterpolateElement","Icon","plus","LinkControlSearchCreate","searchTerm","onClick","itemProps","isSelected","buttonText","text","mark"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,IAAT,EAAeC,IAAf,QAA2B,kBAA3B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA,UAJwC;AAKxCC,EAAAA;AALwC,CAAF,KAMhC;AACN,MAAK,CAAEJ,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAIK,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEJ,UAAF,CADb,GAEGI,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAGT,wBAAwB,CAC9BF,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,yBAAF,CAFI,EAGNO,UAHM,CADuB,EAM9B;AAAEM,MAAAA,IAAI,EAAE;AAAR,KAN8B,CAA/B;AAQA;;AAED,SACC,cAAC,MAAD,OACMJ,SADN;AAEC,IAAA,SAAS,EAAGV,UAAU,CACrB,iFADqB,EAErB;AACC,qBAAeW;AADhB,KAFqB,CAFvB;AAQC,IAAA,OAAO,EAAGF;AARX,KAUC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,IAAI,EAAGH;AAFR,IAVD,EAeC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGO,IADH,CADD,CAfD,CADD;AAuBA,CAnDM;AAqDP,eAAeN,uBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { Icon, plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tisSelected,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<Button\n\t\t\t{ ...itemProps }\n\t\t\tclassName={ classnames(\n\t\t\t\t'block-editor-link-control__search-create block-editor-link-control__search-item',\n\t\t\t\t{\n\t\t\t\t\t'is-selected': isSelected,\n\t\t\t\t}\n\t\t\t) }\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ plus }\n\t\t\t/>\n\n\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-title\">\n\t\t\t\t\t{ text }\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t</Button>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-create-button.js"],"names":["__","sprintf","MenuItem","createInterpolateElement","plus","LinkControlSearchCreate","searchTerm","onClick","itemProps","buttonText","text","mark"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,QAAT,QAAyB,uBAAzB;AACA,SAASC,wBAAT,QAAyC,oBAAzC;AACA,SAASC,IAAT,QAAqB,kBAArB;AAEA,OAAO,MAAMC,uBAAuB,GAAG,CAAE;AACxCC,EAAAA,UADwC;AAExCC,EAAAA,OAFwC;AAGxCC,EAAAA,SAHwC;AAIxCC,EAAAA;AAJwC,CAAF,KAKhC;AACN,MAAK,CAAEH,UAAP,EAAoB;AACnB,WAAO,IAAP;AACA;;AAED,MAAII,IAAJ;;AACA,MAAKD,UAAL,EAAkB;AACjBC,IAAAA,IAAI,GACH,OAAOD,UAAP,KAAsB,UAAtB,GACGA,UAAU,CAAEH,UAAF,CADb,GAEGG,UAHJ;AAIA,GALD,MAKO;AACNC,IAAAA,IAAI,GAAGP,wBAAwB,CAC9BF,OAAO;AACN;AACAD,IAAAA,EAAE,CAAE,yBAAF,CAFI,EAGNM,UAHM,CADuB,EAM9B;AAAEK,MAAAA,IAAI,EAAE;AAAR,KAN8B,CAA/B;AAQA;;AAED,SACC,cAAC,QAAD,OACMH,SADN;AAEC,IAAA,YAAY,EAAC,MAFd;AAGC,IAAA,IAAI,EAAGJ,IAHR;AAIC,IAAA,SAAS,EAAC,wCAJX;AAKC,IAAA,OAAO,EAAGG;AALX,KAOGG,IAPH,CADD;AAWA,CAtCM;AAwCP,eAAeL,uBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { MenuItem } from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { plus } from '@wordpress/icons';\n\nexport const LinkControlSearchCreate = ( {\n\tsearchTerm,\n\tonClick,\n\titemProps,\n\tbuttonText,\n} ) => {\n\tif ( ! searchTerm ) {\n\t\treturn null;\n\t}\n\n\tlet text;\n\tif ( buttonText ) {\n\t\ttext =\n\t\t\ttypeof buttonText === 'function'\n\t\t\t\t? buttonText( searchTerm )\n\t\t\t\t: buttonText;\n\t} else {\n\t\ttext = createInterpolateElement(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Create: <mark>%s</mark>' ),\n\t\t\t\tsearchTerm\n\t\t\t),\n\t\t\t{ mark: <mark /> }\n\t\t);\n\t}\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={ plus }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t\tonClick={ onClick }\n\t\t>\n\t\t\t{ text }\n\t\t</MenuItem>\n\t);\n};\n\nexport default LinkControlSearchCreate;\n"]}
@@ -1,18 +1,13 @@
1
1
  import { createElement } from "@wordpress/element";
2
2
 
3
- /**
4
- * External dependencies
5
- */
6
- import classnames from 'classnames';
7
3
  /**
8
4
  * WordPress dependencies
9
5
  */
10
-
11
- import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
12
6
  import { __ } from '@wordpress/i18n';
13
- import { Button, TextHighlight } from '@wordpress/components';
7
+ import { MenuItem, TextHighlight } from '@wordpress/components';
14
8
  import { Icon, globe, page, tag, postList, category, file } from '@wordpress/icons';
15
9
  import { __unstableStripHTML as stripHTML } from '@wordpress/dom';
10
+ import { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';
16
11
  const ICONS_MAP = {
17
12
  post: postList,
18
13
  page,
@@ -46,36 +41,27 @@ function SearchItemIcon({
46
41
  export const LinkControlSearchItem = ({
47
42
  itemProps,
48
43
  suggestion,
49
- isSelected = false,
44
+ searchTerm,
50
45
  onClick,
51
46
  isURL = false,
52
- searchTerm = '',
53
47
  shouldShowType = false
54
48
  }) => {
55
- return createElement(Button, { ...itemProps,
49
+ const info = isURL ? __('Press ENTER to add this link') : filterURLForDisplay(safeDecodeURI(suggestion?.url));
50
+ return createElement(MenuItem, { ...itemProps,
51
+ info: info,
52
+ iconPosition: "left",
53
+ icon: createElement(SearchItemIcon, {
54
+ suggestion: suggestion,
55
+ isURL: isURL
56
+ }),
56
57
  onClick: onClick,
57
- className: classnames('block-editor-link-control__search-item', {
58
- 'is-selected': isSelected,
59
- 'is-url': isURL,
60
- 'is-entity': !isURL
61
- })
62
- }, createElement(SearchItemIcon, {
63
- suggestion: suggestion,
64
- isURL: isURL
65
- }), createElement("span", {
66
- className: "block-editor-link-control__search-item-header"
67
- }, createElement("span", {
68
- className: "block-editor-link-control__search-item-title"
58
+ shortcut: shouldShowType && getVisualTypeName(suggestion),
59
+ className: "block-editor-link-control__search-item"
69
60
  }, createElement(TextHighlight // The component expects a plain text string.
70
61
  , {
71
62
  text: stripHTML(suggestion.title),
72
63
  highlight: searchTerm
73
- })), createElement("span", {
74
- "aria-hidden": !isURL,
75
- className: "block-editor-link-control__search-item-info"
76
- }, !isURL && (filterURLForDisplay(safeDecodeURI(suggestion.url)) || ''), isURL && __('Press ENTER to add this link'))), shouldShowType && suggestion.type && createElement("span", {
77
- className: "block-editor-link-control__search-item-type"
78
- }, getVisualTypeName(suggestion)));
64
+ }));
79
65
  };
80
66
 
81
67
  function getVisualTypeName(suggestion) {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["classnames","safeDecodeURI","filterURLForDisplay","__","Button","TextHighlight","Icon","globe","page","tag","postList","category","file","__unstableStripHTML","stripHTML","ICONS_MAP","post","post_tag","attachment","SearchItemIcon","isURL","suggestion","icon","type","LinkControlSearchItem","itemProps","isSelected","onClick","searchTerm","shouldShowType","title","url","getVisualTypeName","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,E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,EAAG3B,UAAU,CAAE,wCAAF,EAA4C;AACjE,qBAAe0B,UADkD;AAEjE,gBAAUN,KAFuD;AAGjE,mBAAa,CAAEA;AAHkD,KAA5C;AAHvB,KASC,cAAC,cAAD;AAAgB,IAAA,UAAU,EAAGC,UAA7B;AAA0C,IAAA,KAAK,EAAGD;AAAlD,IATD,EAWC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,aAAD,CACC;AADD;AAEC,IAAA,IAAI,EAAGN,SAAS,CAAEO,UAAU,CAACS,KAAb,CAFjB;AAGC,IAAA,SAAS,EAAGF;AAHb,IADD,CADD,EAQC;AACC,mBAAc,CAAER,KADjB;AAEC,IAAA,SAAS,EAAC;AAFX,KAIG,CAAEA,KAAF,KACClB,mBAAmB,CACpBD,aAAa,CAAEoB,UAAU,CAACU,GAAb,CADO,CAAnB,IAGD,EAJA,CAJH,EASGX,KAAK,IAAIjB,EAAE,CAAE,8BAAF,CATd,CARD,CAXD,EA+BG0B,cAAc,IAAIR,UAAU,CAACE,IAA7B,IACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACGS,iBAAiB,CAAEX,UAAF,CADpB,CAhCF,CADD;AAuCA,CAhDM;;AAkDP,SAASW,iBAAT,CAA4BX,UAA5B,EAAyC;AACxC,MAAKA,UAAU,CAACY,WAAhB,EAA8B;AAC7B,WAAO,YAAP;AACA,GAHuC,CAKxC;;;AACA,SAAOZ,UAAU,CAACE,IAAX,KAAoB,UAApB,GAAiC,KAAjC,GAAyCF,UAAU,CAACE,IAA3D;AACA;;AAED,eAAeC,qBAAf","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';\nimport { __ } from '@wordpress/i18n';\nimport { Button, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tisSelected = false,\n\tonClick,\n\tisURL = false,\n\tsearchTerm = '',\n\tshouldShowType = false,\n} ) => {\n\treturn (\n\t\t<Button\n\t\t\t{ ...itemProps }\n\t\t\tonClick={ onClick }\n\t\t\tclassName={ classnames( 'block-editor-link-control__search-item', {\n\t\t\t\t'is-selected': isSelected,\n\t\t\t\t'is-url': isURL,\n\t\t\t\t'is-entity': ! isURL,\n\t\t\t} ) }\n\t\t>\n\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\n\t\t\t<span className=\"block-editor-link-control__search-item-header\">\n\t\t\t\t<span className=\"block-editor-link-control__search-item-title\">\n\t\t\t\t\t<TextHighlight\n\t\t\t\t\t\t// The component expects a plain text string.\n\t\t\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\t\t\thighlight={ searchTerm }\n\t\t\t\t\t/>\n\t\t\t\t</span>\n\t\t\t\t<span\n\t\t\t\t\taria-hidden={ ! isURL }\n\t\t\t\t\tclassName=\"block-editor-link-control__search-item-info\"\n\t\t\t\t>\n\t\t\t\t\t{ ! isURL &&\n\t\t\t\t\t\t( filterURLForDisplay(\n\t\t\t\t\t\t\tsafeDecodeURI( suggestion.url )\n\t\t\t\t\t\t) ||\n\t\t\t\t\t\t\t'' ) }\n\t\t\t\t\t{ isURL && __( 'Press ENTER to add this link' ) }\n\t\t\t\t</span>\n\t\t\t</span>\n\t\t\t{ shouldShowType && suggestion.type && (\n\t\t\t\t<span className=\"block-editor-link-control__search-item-type\">\n\t\t\t\t\t{ getVisualTypeName( suggestion ) }\n\t\t\t\t</span>\n\t\t\t) }\n\t\t</Button>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-item.js"],"names":["__","MenuItem","TextHighlight","Icon","globe","page","tag","postList","category","file","__unstableStripHTML","stripHTML","safeDecodeURI","filterURLForDisplay","ICONS_MAP","post","post_tag","attachment","SearchItemIcon","isURL","suggestion","icon","type","LinkControlSearchItem","itemProps","searchTerm","onClick","shouldShowType","info","url","getVisualTypeName","title","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,QAAT,EAAmBC,aAAnB,QAAwC,uBAAxC;AACA,SACCC,IADD,EAECC,KAFD,EAGCC,IAHD,EAICC,GAJD,EAKCC,QALD,EAMCC,QAND,EAOCC,IAPD,QAQO,kBARP;AASA,SAASC,mBAAmB,IAAIC,SAAhC,QAAiD,gBAAjD;AACA,SAASC,aAAT,EAAwBC,mBAAxB,QAAmD,gBAAnD;AAEA,MAAMC,SAAS,GAAG;AACjBC,EAAAA,IAAI,EAAER,QADW;AAEjBF,EAAAA,IAFiB;AAGjBW,EAAAA,QAAQ,EAAEV,GAHO;AAIjBE,EAAAA,QAJiB;AAKjBS,EAAAA,UAAU,EAAER;AALK,CAAlB;;AAQA,SAASS,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D,CADD;AAmBA,CA/BM;;AAiCP,SAASK,iBAAT,CAA4BV,UAA5B,EAAyC;AACxC,MAAKA,UAAU,CAACY,WAAhB,EAA8B;AAC7B,WAAO,YAAP;AACA,GAHuC,CAKxC;;;AACA,SAAOZ,UAAU,CAACE,IAAX,KAAoB,UAApB,GAAiC,KAAjC,GAAyCF,UAAU,CAACE,IAA3D;AACA;;AAED,eAAeC,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { MenuItem, TextHighlight } from '@wordpress/components';\nimport {\n\tIcon,\n\tglobe,\n\tpage,\n\ttag,\n\tpostList,\n\tcategory,\n\tfile,\n} from '@wordpress/icons';\nimport { __unstableStripHTML as stripHTML } from '@wordpress/dom';\nimport { safeDecodeURI, filterURLForDisplay } from '@wordpress/url';\n\nconst ICONS_MAP = {\n\tpost: postList,\n\tpage,\n\tpost_tag: tag,\n\tcategory,\n\tattachment: file,\n};\n\nfunction SearchItemIcon( { isURL, suggestion } ) {\n\tlet icon = null;\n\n\tif ( isURL ) {\n\t\ticon = globe;\n\t} else if ( suggestion.type in ICONS_MAP ) {\n\t\ticon = ICONS_MAP[ suggestion.type ];\n\t}\n\n\tif ( icon ) {\n\t\treturn (\n\t\t\t<Icon\n\t\t\t\tclassName=\"block-editor-link-control__search-item-icon\"\n\t\t\t\ticon={ icon }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn null;\n}\n\nexport const LinkControlSearchItem = ( {\n\titemProps,\n\tsuggestion,\n\tsearchTerm,\n\tonClick,\n\tisURL = false,\n\tshouldShowType = false,\n} ) => {\n\tconst info = isURL\n\t\t? __( 'Press ENTER to add this link' )\n\t\t: filterURLForDisplay( safeDecodeURI( suggestion?.url ) );\n\n\treturn (\n\t\t<MenuItem\n\t\t\t{ ...itemProps }\n\t\t\tinfo={ info }\n\t\t\ticonPosition=\"left\"\n\t\t\ticon={\n\t\t\t\t<SearchItemIcon suggestion={ suggestion } isURL={ isURL } />\n\t\t\t}\n\t\t\tonClick={ onClick }\n\t\t\tshortcut={ shouldShowType && getVisualTypeName( suggestion ) }\n\t\t\tclassName=\"block-editor-link-control__search-item\"\n\t\t>\n\t\t\t<TextHighlight\n\t\t\t\t// The component expects a plain text string.\n\t\t\t\ttext={ stripHTML( suggestion.title ) }\n\t\t\t\thighlight={ searchTerm }\n\t\t\t/>\n\t\t</MenuItem>\n\t);\n};\n\nfunction getVisualTypeName( suggestion ) {\n\tif ( suggestion.isFrontPage ) {\n\t\treturn 'front page';\n\t}\n\n\t// Rename 'post_tag' to 'tag'. Ideally, the API would return the localised CPT or taxonomy label.\n\treturn suggestion.type === 'post_tag' ? 'tag' : suggestion.type;\n}\n\nexport default LinkControlSearchItem;\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { __, sprintf } from '@wordpress/i18n';
7
- import { VisuallyHidden } from '@wordpress/components';
7
+ import { VisuallyHidden, MenuGroup } from '@wordpress/components';
8
8
  /**
9
9
  * External dependencies
10
10
  */
@@ -53,7 +53,7 @@ export default function LinkControlSearchResults({
53
53
  }, searchResultsLabel, createElement("div", { ...suggestionsListProps,
54
54
  className: resultsListClasses,
55
55
  "aria-labelledby": searchResultsLabelId
56
- }, suggestions.map((suggestion, index) => {
56
+ }, createElement(MenuGroup, null, suggestions.map((suggestion, index) => {
57
57
  if (shouldShowCreateSuggestion && CREATE_TYPE === suggestion.type) {
58
58
  return createElement(LinkControlSearchCreate, {
59
59
  searchTerm: currentInputValue,
@@ -88,6 +88,6 @@ export default function LinkControlSearchResults({
88
88
  shouldShowType: shouldShowSuggestionsTypes,
89
89
  isFrontPage: suggestion?.isFrontPage
90
90
  });
91
- })));
91
+ }))));
92
92
  }
93
93
  //# sourceMappingURL=search-results.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["__","sprintf","VisuallyHidden","classnames","LinkControlSearchCreate","LinkControlSearchItem","CREATE_TYPE","LINK_ENTRY_TYPES","LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","id","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,uBAA/B;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,wBAApC;AACA,OAAOC,qBAAP,MAAkC,eAAlC;AACA,SAASC,WAAT,EAAsBC,gBAAtB,QAA8C,aAA9C;AAEA,eAAe,SAASC,wBAAT,CAAmC;AACjDC,EAAAA,UADiD;AAEjDC,EAAAA,oBAFiD;AAGjDC,EAAAA,iBAHiD;AAIjDC,EAAAA,qBAJiD;AAKjDC,EAAAA,oBALiD;AAMjDC,EAAAA,wBANiD;AAOjDC,EAAAA,WAPiD;AAQjDC,EAAAA,kBARiD;AASjDC,EAAAA,SATiD;AAUjDC,EAAAA,oBAViD;AAWjDC,EAAAA,0BAXiD;AAYjDC,EAAAA;AAZiD,CAAnC,EAaX;AACH,QAAMC,kBAAkB,GAAGlB,UAAU,CACpC,2CADoC,EAEpC;AACC,kBAAcc;AADf,GAFoC,CAArC;AAOA,QAAMK,yBAAyB,GAC9BP,WAAW,CAACQ,MAAZ,KAAuB,CAAvB,IACAhB,gBAAgB,CAACiB,QAAjB,CAA2BT,WAAW,CAAE,CAAF,CAAX,CAAiBU,IAA5C,CAFD;AAGA,QAAMC,0BAA0B,GAC/BhB,oBAAoB,IACpB,CAAEY,yBADF,IAEA,CAAEJ,oBAHH,CAXG,CAeH;;AACA,Q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FmC,CAFrC;AAMC,MAAA,UAAU,EAAGD,UANd;AAOC,MAAA,KAAK,EAAGC,KAPT;AAQC,MAAA,OAAO,EAAG,MAAM;AACfrB,QAAAA,qBAAqB,CAAEoB,UAAF,CAArB;AACA,OAVF;AAWC,MAAA,UAAU,EAAGC,KAAK,KAAKjB,kBAXxB;AAYC,MAAA,KAAK,EAAGT,gBAAgB,CAACiB,QAAjB,CACPQ,UAAU,CAACP,IADJ,CAZT;AAeC,MAAA,UAAU,EAAGd,iBAfd;AAgBC,MAAA,cAAc,EAAGgB,0BAhBlB;AAiBC,MAAA,WAAW,EAAGK,UAAU,EAAEG;AAjB3B,MADD;AAqBA,GApDC,CALH,CAFD,CADD;AAgEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\tconst searchResultsLabel = (\n\t\t<VisuallyHidden id={ searchResultsLabelId }>\n\t\t\t{ labelText }\n\t\t</VisuallyHidden>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t{ searchResultsLabel }\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-labelledby={ searchResultsLabelId }\n\t\t\t>\n\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\tisURL={ LINK_ENTRY_TYPES.includes(\n\t\t\t\t\t\t\t\tsuggestion.type\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/block-editor/src/components/link-control/search-results.js"],"names":["__","sprintf","VisuallyHidden","MenuGroup","classnames","LinkControlSearchCreate","LinkControlSearchItem","CREATE_TYPE","LINK_ENTRY_TYPES","LinkControlSearchResults","instanceId","withCreateSuggestion","currentInputValue","handleSuggestionClick","suggestionsListProps","buildSuggestionItemProps","suggestions","selectedSuggestion","isLoading","isInitialSuggestions","createSuggestionButtonText","suggestionsQuery","resultsListClasses","isSingleDirectEntryResult","length","includes","type","shouldShowCreateSuggestion","shouldShowSuggestionsTypes","searchResultsLabelId","labelText","searchResultsLabel","map","suggestion","index","id","isFrontPage"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,EAAyBC,SAAzB,QAA0C,uBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,wBAApC;AACA,OAAOC,qBAAP,MAAkC,eAAlC;AACA,SAASC,WAAT,EAAsBC,gBAAtB,QAA8C,aAA9C;AAEA,eAAe,SAASC,wBAAT,CAAmC;AACjDC,EAAAA,UADiD;AAEjDC,EAAAA,oBAFiD;AAGjDC,EAAAA,iBAHiD;AAIjDC,EAAAA,qBAJiD;AAKjDC,EAAAA,oBALiD;AAMjDC,EAAAA,wBANiD;AAOjDC,EAAAA,WAPiD;AAQjDC,EAAAA,kBARiD;AASjDC,EAAAA,SATiD;AAUjDC,EAAAA,oBAViD;AAWjDC,EAAAA,0BAXiD;AAYjDC,EAAAA;AAZiD,CAAnC,EAaX;AACH,QAAMC,kBAAkB,GAAGlB,UAAU,CACpC,2CADoC,EAEpC;AACC,kBAAcc;AADf,GAFoC,CAArC;AAOA,QAAMK,yBAAyB,GAC9BP,WAAW,CAACQ,MAAZ,KAAuB,CAAvB,IACAhB,gBAAgB,CAACiB,QAAjB,CAA2BT,WAAW,CAAE,CAAF,CAAX,CAAiBU,IAA5C,CAFD;AAGA,QAAMC,0BAA0B,GAC/BhB,oBAAoB,IACpB,CAAEY,yBADF,IAEA,CAAEJ,oBAHH,CAXG,CAeH;;AACA,QAAMS,0BAA0B,GAAG,CAAEP,gBAAgB,EAAEK,IAAvD,CAhBG,CAkBH;AACA;AACA;;AACA,QAAMG,oBAAoB,GAAI,kDAAkDn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AAG,MAAM;AACfrB,QAAAA,qBAAqB,CAAEoB,UAAF,CAArB;AACA,OAVF;AAWC,MAAA,UAAU,EAAGC,KAAK,KAAKjB,kBAXxB;AAYC,MAAA,KAAK,EAAGT,gBAAgB,CAACiB,QAAjB,CACPQ,UAAU,CAACP,IADJ,CAZT;AAeC,MAAA,UAAU,EAAGd,iBAfd;AAgBC,MAAA,cAAc,EAAGgB,0BAhBlB;AAiBC,MAAA,WAAW,EAAGK,UAAU,EAAEG;AAjB3B,MADD;AAqBA,GApDC,CADH,CALD,CAFD,CADD;AAkEA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { VisuallyHidden, MenuGroup } from '@wordpress/components';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * Internal dependencies\n */\nimport LinkControlSearchCreate from './search-create-button';\nimport LinkControlSearchItem from './search-item';\nimport { CREATE_TYPE, LINK_ENTRY_TYPES } from './constants';\n\nexport default function LinkControlSearchResults( {\n\tinstanceId,\n\twithCreateSuggestion,\n\tcurrentInputValue,\n\thandleSuggestionClick,\n\tsuggestionsListProps,\n\tbuildSuggestionItemProps,\n\tsuggestions,\n\tselectedSuggestion,\n\tisLoading,\n\tisInitialSuggestions,\n\tcreateSuggestionButtonText,\n\tsuggestionsQuery,\n} ) {\n\tconst resultsListClasses = classnames(\n\t\t'block-editor-link-control__search-results',\n\t\t{\n\t\t\t'is-loading': isLoading,\n\t\t}\n\t);\n\n\tconst isSingleDirectEntryResult =\n\t\tsuggestions.length === 1 &&\n\t\tLINK_ENTRY_TYPES.includes( suggestions[ 0 ].type );\n\tconst shouldShowCreateSuggestion =\n\t\twithCreateSuggestion &&\n\t\t! isSingleDirectEntryResult &&\n\t\t! isInitialSuggestions;\n\t// If the query has a specified type, then we can skip showing them in the result. See #24839.\n\tconst shouldShowSuggestionsTypes = ! suggestionsQuery?.type;\n\n\t// According to guidelines aria-label should be added if the label\n\t// itself is not visible.\n\t// See: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/listbox_role\n\tconst searchResultsLabelId = `block-editor-link-control-search-results-label-${ instanceId }`;\n\tconst labelText = isInitialSuggestions\n\t\t? __( 'Suggestions' )\n\t\t: sprintf(\n\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t__( 'Search results for \"%s\"' ),\n\t\t\t\tcurrentInputValue\n\t\t );\n\tconst searchResultsLabel = (\n\t\t<VisuallyHidden id={ searchResultsLabelId }>\n\t\t\t{ labelText }\n\t\t</VisuallyHidden>\n\t);\n\n\treturn (\n\t\t<div className=\"block-editor-link-control__search-results-wrapper\">\n\t\t\t{ searchResultsLabel }\n\t\t\t<div\n\t\t\t\t{ ...suggestionsListProps }\n\t\t\t\tclassName={ resultsListClasses }\n\t\t\t\taria-labelledby={ searchResultsLabelId }\n\t\t\t>\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t{ suggestions.map( ( suggestion, index ) => {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tshouldShowCreateSuggestion &&\n\t\t\t\t\t\t\tCREATE_TYPE === suggestion.type\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkControlSearchCreate\n\t\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\t\tbuttonText={ createSuggestionButtonText }\n\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion )\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t// Intentionally only using `type` here as\n\t\t\t\t\t\t\t\t\t// the constant is enough to uniquely\n\t\t\t\t\t\t\t\t\t// identify the single \"CREATE\" suggestion.\n\t\t\t\t\t\t\t\t\tkey={ suggestion.type }\n\t\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tisSelected={ 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}\n\n\t\t\t\t\t\t// If we're not handling \"Create\" suggestions above then\n\t\t\t\t\t\t// we don't want them in the main results so exit early.\n\t\t\t\t\t\tif ( CREATE_TYPE === suggestion.type ) {\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t<LinkControlSearchItem\n\t\t\t\t\t\t\t\tkey={ `${ suggestion.id }-${ suggestion.type }` }\n\t\t\t\t\t\t\t\titemProps={ buildSuggestionItemProps(\n\t\t\t\t\t\t\t\t\tsuggestion,\n\t\t\t\t\t\t\t\t\tindex\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsuggestion={ suggestion }\n\t\t\t\t\t\t\t\tindex={ index }\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\thandleSuggestionClick( suggestion );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tisSelected={ index === selectedSuggestion }\n\t\t\t\t\t\t\t\tisURL={ LINK_ENTRY_TYPES.includes(\n\t\t\t\t\t\t\t\t\tsuggestion.type\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tsearchTerm={ currentInputValue }\n\t\t\t\t\t\t\t\tshouldShowType={ shouldShowSuggestionsTypes }\n\t\t\t\t\t\t\t\tisFrontPage={ suggestion?.isFrontPage }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
@@ -4,7 +4,7 @@ import { createElement } from "@wordpress/element";
4
4
  * WordPress dependencies
5
5
  */
6
6
  import { RawHTML } from '@wordpress/element';
7
- import { children as childrenSource, getSaveElement, __unstableGetBlockProps as getBlockProps } from '@wordpress/blocks';
7
+ import { children as childrenSource } from '@wordpress/blocks';
8
8
  import deprecated from '@wordpress/deprecated';
9
9
  /**
10
10
  * Internal dependencies
@@ -47,39 +47,4 @@ export const Content = ({
47
47
 
48
48
  return content;
49
49
  };
50
- Content.__unstableIsRichTextContent = {};
51
-
52
- function findContent(blocks, richTextValues = []) {
53
- if (!Array.isArray(blocks)) {
54
- blocks = [blocks];
55
- }
56
-
57
- for (const block of blocks) {
58
- if (block?.type?.__unstableIsRichTextContent === Content.__unstableIsRichTextContent) {
59
- richTextValues.push(block.props.value);
60
- continue;
61
- }
62
-
63
- if (block?.props?.children) {
64
- findContent(block.props.children, richTextValues);
65
- }
66
- }
67
-
68
- return richTextValues;
69
- }
70
-
71
- function _getSaveElement({
72
- name,
73
- attributes,
74
- innerBlocks
75
- }) {
76
- return getSaveElement(name, attributes, innerBlocks.map(_getSaveElement));
77
- }
78
-
79
- export function getRichTextValues(blocks = []) {
80
- getBlockProps.skipFilters = true;
81
- const values = findContent((Array.isArray(blocks) ? blocks : [blocks]).map(_getSaveElement));
82
- getBlockProps.skipFilters = false;
83
- return values;
84
- }
85
50
  //# sourceMappingURL=content.js.map