@wordpress/block-library 8.10.0 → 8.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (278) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/block/edit.native.js +17 -10
  3. package/build/block/edit.native.js.map +1 -1
  4. package/build/code/index.js +1 -0
  5. package/build/code/index.js.map +1 -1
  6. package/build/column/index.js +1 -1
  7. package/build/columns/transforms.js +1 -5
  8. package/build/columns/transforms.js.map +1 -1
  9. package/build/cover/edit/resizable-cover-popover.js +3 -3
  10. package/build/cover/edit/resizable-cover-popover.js.map +1 -1
  11. package/build/file/interactivity.js +19 -0
  12. package/build/file/interactivity.js.map +1 -0
  13. package/build/file/{utils.js → utils/index.js} +1 -1
  14. package/build/file/utils/index.js.map +1 -0
  15. package/build/freeform/modal.js +20 -17
  16. package/build/freeform/modal.js.map +1 -1
  17. package/build/gallery/v1/edit.js +1 -7
  18. package/build/gallery/v1/edit.js.map +1 -1
  19. package/build/gallery/v1/gallery-image.native.js +1 -3
  20. package/build/gallery/v1/gallery-image.native.js.map +1 -1
  21. package/build/group/transforms.js +0 -5
  22. package/build/group/transforms.js.map +1 -1
  23. package/build/image/deprecated.js +2 -4
  24. package/build/image/deprecated.js.map +1 -1
  25. package/build/image/edit.js +13 -11
  26. package/build/image/edit.js.map +1 -1
  27. package/build/image/image.js +7 -12
  28. package/build/image/image.js.map +1 -1
  29. package/build/image/index.js +3 -0
  30. package/build/image/index.js.map +1 -1
  31. package/build/image/interactivity.js +102 -0
  32. package/build/image/interactivity.js.map +1 -0
  33. package/build/image/save.js +2 -4
  34. package/build/image/save.js.map +1 -1
  35. package/build/image/utils.js +10 -18
  36. package/build/image/utils.js.map +1 -1
  37. package/build/latest-posts/edit.native.js +1 -3
  38. package/build/latest-posts/edit.native.js.map +1 -1
  39. package/build/list/edit.js +1 -1
  40. package/build/list/edit.js.map +1 -1
  41. package/build/list-item/edit.native.js +1 -1
  42. package/build/list-item/edit.native.js.map +1 -1
  43. package/build/list-item/transforms.js +4 -1
  44. package/build/list-item/transforms.js.map +1 -1
  45. package/build/media-text/deprecated.js +4 -6
  46. package/build/media-text/deprecated.js.map +1 -1
  47. package/build/media-text/edit.js +13 -11
  48. package/build/media-text/edit.js.map +1 -1
  49. package/build/media-text/media-container.js +3 -3
  50. package/build/media-text/media-container.js.map +1 -1
  51. package/build/media-text/save.js +1 -3
  52. package/build/media-text/save.js.map +1 -1
  53. package/build/navigation/constants.js +3 -1
  54. package/build/navigation/constants.js.map +1 -1
  55. package/build/navigation/edit/inner-blocks.js +1 -0
  56. package/build/navigation/edit/inner-blocks.js.map +1 -1
  57. package/build/navigation/edit/leaf-more-menu.js +148 -0
  58. package/build/navigation/edit/leaf-more-menu.js.map +1 -0
  59. package/build/navigation/edit/menu-inspector-controls.js +53 -8
  60. package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
  61. package/build/navigation/edit/navigation-menu-delete-control.js +6 -6
  62. package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  63. package/build/navigation/edit/unsaved-inner-blocks.js +8 -19
  64. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  65. package/build/navigation/interactivity.js +24 -6
  66. package/build/navigation/interactivity.js.map +1 -1
  67. package/build/navigation-link/edit.js +6 -4
  68. package/build/navigation-link/edit.js.map +1 -1
  69. package/build/navigation-link/update-attributes.js +5 -5
  70. package/build/navigation-link/update-attributes.js.map +1 -1
  71. package/build/navigation-submenu/edit.js +6 -4
  72. package/build/navigation-submenu/edit.js.map +1 -1
  73. package/build/pattern/edit.js +42 -8
  74. package/build/pattern/edit.js.map +1 -1
  75. package/build/pattern/index.js +12 -5
  76. package/build/pattern/index.js.map +1 -1
  77. package/build/pattern/v1/edit.js +57 -0
  78. package/build/pattern/v1/edit.js.map +1 -0
  79. package/build/post-title/edit.js +10 -3
  80. package/build/post-title/edit.js.map +1 -1
  81. package/build/quote/transforms.js +9 -12
  82. package/build/quote/transforms.js.map +1 -1
  83. package/build/social-link/edit.js +21 -4
  84. package/build/social-link/edit.js.map +1 -1
  85. package/build/template-part/edit/index.js +1 -7
  86. package/build/template-part/edit/index.js.map +1 -1
  87. package/build/template-part/edit/utils/hooks.js +2 -2
  88. package/build/template-part/edit/utils/hooks.js.map +1 -1
  89. package/build/utils/interactivity/directives.js +50 -22
  90. package/build/utils/interactivity/directives.js.map +1 -1
  91. package/build/utils/interactivity/hooks.js +76 -12
  92. package/build/utils/interactivity/hooks.js.map +1 -1
  93. package/build/utils/interactivity/portals.js +108 -0
  94. package/build/utils/interactivity/portals.js.map +1 -0
  95. package/build-module/block/edit.native.js +7 -1
  96. package/build-module/block/edit.native.js.map +1 -1
  97. package/build-module/code/index.js +1 -0
  98. package/build-module/code/index.js.map +1 -1
  99. package/build-module/column/index.js +1 -1
  100. package/build-module/columns/transforms.js +1 -5
  101. package/build-module/columns/transforms.js.map +1 -1
  102. package/build-module/cover/edit/resizable-cover-popover.js +3 -3
  103. package/build-module/cover/edit/resizable-cover-popover.js.map +1 -1
  104. package/build-module/file/interactivity.js +15 -0
  105. package/build-module/file/interactivity.js.map +1 -0
  106. package/build-module/file/{utils.js → utils/index.js} +1 -1
  107. package/build-module/file/utils/index.js.map +1 -0
  108. package/build-module/freeform/modal.js +19 -18
  109. package/build-module/freeform/modal.js.map +1 -1
  110. package/build-module/gallery/v1/edit.js +1 -6
  111. package/build-module/gallery/v1/edit.js.map +1 -1
  112. package/build-module/gallery/v1/gallery-image.native.js +1 -2
  113. package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
  114. package/build-module/group/transforms.js +0 -5
  115. package/build-module/group/transforms.js.map +1 -1
  116. package/build-module/image/deprecated.js +2 -3
  117. package/build-module/image/deprecated.js.map +1 -1
  118. package/build-module/image/edit.js +12 -11
  119. package/build-module/image/edit.js.map +1 -1
  120. package/build-module/image/image.js +7 -11
  121. package/build-module/image/image.js.map +1 -1
  122. package/build-module/image/index.js +3 -0
  123. package/build-module/image/index.js.map +1 -1
  124. package/build-module/image/interactivity.js +99 -0
  125. package/build-module/image/interactivity.js.map +1 -0
  126. package/build-module/image/save.js +2 -3
  127. package/build-module/image/save.js.map +1 -1
  128. package/build-module/image/utils.js +10 -17
  129. package/build-module/image/utils.js.map +1 -1
  130. package/build-module/latest-posts/edit.native.js +1 -2
  131. package/build-module/latest-posts/edit.native.js.map +1 -1
  132. package/build-module/list/edit.js +1 -1
  133. package/build-module/list/edit.js.map +1 -1
  134. package/build-module/list-item/edit.native.js +1 -1
  135. package/build-module/list-item/edit.native.js.map +1 -1
  136. package/build-module/list-item/transforms.js +5 -2
  137. package/build-module/list-item/transforms.js.map +1 -1
  138. package/build-module/media-text/deprecated.js +4 -5
  139. package/build-module/media-text/deprecated.js.map +1 -1
  140. package/build-module/media-text/edit.js +13 -12
  141. package/build-module/media-text/edit.js.map +1 -1
  142. package/build-module/media-text/media-container.js +3 -3
  143. package/build-module/media-text/media-container.js.map +1 -1
  144. package/build-module/media-text/save.js +1 -2
  145. package/build-module/media-text/save.js.map +1 -1
  146. package/build-module/navigation/constants.js +1 -0
  147. package/build-module/navigation/constants.js.map +1 -1
  148. package/build-module/navigation/edit/inner-blocks.js +2 -1
  149. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  150. package/build-module/navigation/edit/leaf-more-menu.js +132 -0
  151. package/build-module/navigation/edit/leaf-more-menu.js.map +1 -0
  152. package/build-module/navigation/edit/menu-inspector-controls.js +52 -9
  153. package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
  154. package/build-module/navigation/edit/navigation-menu-delete-control.js +7 -7
  155. package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
  156. package/build-module/navigation/edit/unsaved-inner-blocks.js +8 -16
  157. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  158. package/build-module/navigation/interactivity.js +24 -6
  159. package/build-module/navigation/interactivity.js.map +1 -1
  160. package/build-module/navigation-link/edit.js +6 -4
  161. package/build-module/navigation-link/edit.js.map +1 -1
  162. package/build-module/navigation-link/update-attributes.js +4 -4
  163. package/build-module/navigation-link/update-attributes.js.map +1 -1
  164. package/build-module/navigation-submenu/edit.js +6 -4
  165. package/build-module/navigation-submenu/edit.js.map +1 -1
  166. package/build-module/pattern/edit.js +42 -9
  167. package/build-module/pattern/edit.js.map +1 -1
  168. package/build-module/pattern/index.js +12 -3
  169. package/build-module/pattern/index.js.map +1 -1
  170. package/build-module/pattern/v1/edit.js +48 -0
  171. package/build-module/pattern/v1/edit.js.map +1 -0
  172. package/build-module/post-title/edit.js +10 -3
  173. package/build-module/post-title/edit.js.map +1 -1
  174. package/build-module/quote/transforms.js +9 -12
  175. package/build-module/quote/transforms.js.map +1 -1
  176. package/build-module/social-link/edit.js +20 -5
  177. package/build-module/social-link/edit.js.map +1 -1
  178. package/build-module/template-part/edit/index.js +1 -6
  179. package/build-module/template-part/edit/index.js.map +1 -1
  180. package/build-module/template-part/edit/utils/hooks.js +1 -1
  181. package/build-module/template-part/edit/utils/hooks.js.map +1 -1
  182. package/build-module/utils/interactivity/directives.js +49 -22
  183. package/build-module/utils/interactivity/directives.js.map +1 -1
  184. package/build-module/utils/interactivity/hooks.js +77 -13
  185. package/build-module/utils/interactivity/hooks.js.map +1 -1
  186. package/build-module/utils/interactivity/portals.js +100 -0
  187. package/build-module/utils/interactivity/portals.js.map +1 -0
  188. package/build-style/common-rtl.css +1 -1
  189. package/build-style/common.css +1 -1
  190. package/build-style/cover/style-rtl.css +1 -2
  191. package/build-style/cover/style.css +1 -2
  192. package/build-style/editor-rtl.css +68 -0
  193. package/build-style/editor.css +68 -0
  194. package/build-style/file/editor-rtl.css +3 -0
  195. package/build-style/file/editor.css +3 -0
  196. package/build-style/freeform/editor-rtl.css +29 -0
  197. package/build-style/freeform/editor.css +29 -0
  198. package/build-style/gallery/style-rtl.css +2 -4
  199. package/build-style/gallery/style.css +2 -4
  200. package/build-style/image/style-rtl.css +98 -0
  201. package/build-style/image/style.css +98 -0
  202. package/build-style/navigation/editor-rtl.css +36 -0
  203. package/build-style/navigation/editor.css +36 -0
  204. package/build-style/post-comments-form/style-rtl.css +1 -1
  205. package/build-style/post-comments-form/style.css +1 -1
  206. package/build-style/style-rtl.css +103 -9
  207. package/build-style/style.css +103 -9
  208. package/build-style/video/style-rtl.css +1 -2
  209. package/build-style/video/style.css +1 -2
  210. package/package.json +32 -32
  211. package/src/block/edit.native.js +18 -4
  212. package/src/buttons/test/edit.native.js +0 -9
  213. package/src/code/block.json +1 -0
  214. package/src/column/block.json +1 -1
  215. package/src/columns/test/__snapshots__/transforms.native.js.snap +1 -1
  216. package/src/columns/test/transforms.native.js +3 -5
  217. package/src/columns/transforms.js +2 -8
  218. package/src/comments/index.php +1 -6
  219. package/src/cover/edit/resizable-cover-popover.js +2 -1
  220. package/src/file/editor.scss +4 -0
  221. package/src/file/interactivity.js +15 -0
  222. package/src/freeform/editor.scss +45 -0
  223. package/src/freeform/modal.js +22 -19
  224. package/src/gallery/v1/edit.js +1 -6
  225. package/src/gallery/v1/gallery-image.native.js +1 -2
  226. package/src/group/test/__snapshots__/transforms.native.js.snap +1 -1
  227. package/src/group/test/transforms.native.js +3 -5
  228. package/src/group/transforms.js +0 -7
  229. package/src/image/block.json +3 -0
  230. package/src/image/deprecated.js +2 -3
  231. package/src/image/edit.js +18 -18
  232. package/src/image/image.js +8 -11
  233. package/src/image/index.php +75 -2
  234. package/src/image/interactivity.js +113 -0
  235. package/src/image/save.js +4 -3
  236. package/src/image/style.scss +113 -0
  237. package/src/image/utils.js +11 -18
  238. package/src/latest-posts/edit.native.js +1 -4
  239. package/src/list/edit.js +1 -1
  240. package/src/list/test/edit.native.js +80 -1
  241. package/src/list-item/edit.native.js +1 -1
  242. package/src/list-item/transforms.js +4 -2
  243. package/src/media-text/deprecated.js +4 -5
  244. package/src/media-text/edit.js +12 -10
  245. package/src/media-text/media-container.js +3 -3
  246. package/src/media-text/save.js +1 -2
  247. package/src/navigation/constants.js +5 -0
  248. package/src/navigation/edit/inner-blocks.js +6 -1
  249. package/src/navigation/edit/leaf-more-menu.js +170 -0
  250. package/src/navigation/edit/menu-inspector-controls.js +78 -10
  251. package/src/navigation/edit/navigation-menu-delete-control.js +29 -29
  252. package/src/navigation/edit/unsaved-inner-blocks.js +11 -24
  253. package/src/navigation/editor.scss +10 -0
  254. package/src/navigation/index.php +4 -1
  255. package/src/navigation/interactivity.js +9 -2
  256. package/src/navigation-link/edit.js +8 -2
  257. package/src/navigation-link/update-attributes.js +2 -2
  258. package/src/navigation-submenu/edit.js +8 -2
  259. package/src/pattern/block.json +4 -0
  260. package/src/pattern/edit.js +53 -16
  261. package/src/pattern/index.js +5 -4
  262. package/src/pattern/index.php +14 -1
  263. package/src/pattern/v1/edit.js +57 -0
  264. package/src/post-comments-form/style.scss +3 -1
  265. package/src/post-title/edit.js +50 -44
  266. package/src/quote/test/__snapshots__/transforms.native.js.snap +1 -1
  267. package/src/quote/test/transforms.native.js +3 -5
  268. package/src/quote/transforms.js +9 -13
  269. package/src/social-link/edit.js +51 -26
  270. package/src/template-part/edit/index.js +4 -6
  271. package/src/template-part/edit/utils/hooks.js +1 -1
  272. package/src/template-part/index.php +2 -2
  273. package/src/utils/interactivity/directives.js +27 -6
  274. package/src/utils/interactivity/hooks.js +83 -14
  275. package/src/utils/interactivity/portals.js +98 -0
  276. package/build/file/utils.js.map +0 -1
  277. package/build-module/file/utils.js.map +0 -1
  278. /package/src/file/{utils.js → utils/index.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- import { h, options, createContext } from 'preact';
4
+ import { h, options, createContext, cloneElement } from 'preact';
5
5
  import { useRef, useMemo } from 'preact/hooks';
6
6
  /**
7
7
  * Internal dependencies
@@ -13,40 +13,109 @@ const context = createContext( {} );
13
13
 
14
14
  // WordPress Directives.
15
15
  const directiveMap = {};
16
- export const directive = ( name, cb ) => {
16
+ const directivePriorities = {};
17
+ export const directive = ( name, cb, { priority = 10 } = {} ) => {
17
18
  directiveMap[ name ] = cb;
19
+ directivePriorities[ name ] = priority;
18
20
  };
19
21
 
20
22
  // Resolve the path to some property of the store object.
21
23
  const resolve = ( path, ctx ) => {
22
- // If path starts with !, remove it and save a flag.
23
- const hasNegationOperator =
24
- path[ 0 ] === '!' && !! ( path = path.slice( 1 ) );
25
24
  let current = { ...store, context: ctx };
26
25
  path.split( '.' ).forEach( ( p ) => ( current = current[ p ] ) );
27
- return hasNegationOperator ? ! current : current;
26
+ return current;
28
27
  };
29
28
 
30
29
  // Generate the evaluate function.
31
30
  const getEvaluate =
32
31
  ( { ref } = {} ) =>
33
32
  ( path, extraArgs = {} ) => {
33
+ // If path starts with !, remove it and save a flag.
34
+ const hasNegationOperator =
35
+ path[ 0 ] === '!' && !! ( path = path.slice( 1 ) );
34
36
  const value = resolve( path, extraArgs.context );
35
- return typeof value === 'function'
36
- ? value( {
37
- ref: ref.current,
38
- ...store,
39
- ...extraArgs,
40
- } )
41
- : value;
37
+ const returnValue =
38
+ typeof value === 'function'
39
+ ? value( {
40
+ ref: ref.current,
41
+ ...store,
42
+ ...extraArgs,
43
+ } )
44
+ : value;
45
+ return hasNegationOperator ? ! returnValue : returnValue;
42
46
  };
43
47
 
48
+ // Separate directives by priority. The resulting array contains objects
49
+ // of directives grouped by same priority, and sorted in ascending order.
50
+ const usePriorityLevels = ( directives ) =>
51
+ useMemo( () => {
52
+ const byPriority = Object.entries( directives ).reduce(
53
+ ( acc, [ name, values ] ) => {
54
+ const priority = directivePriorities[ name ];
55
+ if ( ! acc[ priority ] ) acc[ priority ] = {};
56
+ acc[ priority ][ name ] = values;
57
+
58
+ return acc;
59
+ },
60
+ {}
61
+ );
62
+
63
+ return Object.entries( byPriority )
64
+ .sort( ( [ p1 ], [ p2 ] ) => p1 - p2 )
65
+ .map( ( [ , obj ] ) => obj );
66
+ }, [ directives ] );
67
+
44
68
  // Directive wrapper.
45
69
  const Directive = ( { type, directives, props: originalProps } ) => {
46
70
  const ref = useRef( null );
47
71
  const element = h( type, { ...originalProps, ref } );
48
- const props = { ...originalProps, children: element };
49
72
  const evaluate = useMemo( () => getEvaluate( { ref } ), [] );
73
+
74
+ // Add wrappers recursively for each priority level.
75
+ const byPriorityLevel = usePriorityLevels( directives );
76
+ return (
77
+ <RecursivePriorityLevel
78
+ directives={ byPriorityLevel }
79
+ element={ element }
80
+ evaluate={ evaluate }
81
+ originalProps={ originalProps }
82
+ />
83
+ );
84
+ };
85
+
86
+ // Priority level wrapper.
87
+ const RecursivePriorityLevel = ( {
88
+ directives: [ directives, ...rest ],
89
+ element,
90
+ evaluate,
91
+ originalProps,
92
+ } ) => {
93
+ // This element needs to be a fresh copy so we are not modifying an already
94
+ // rendered element with Preact's internal properties initialized. This
95
+ // prevents an error with changes in `element.props.children` not being
96
+ // reflected in `element.__k`.
97
+ element = cloneElement( element );
98
+
99
+ // Recursively render the wrapper for the next priority level.
100
+ //
101
+ // Note that, even though we're instantiating a vnode with a
102
+ // `RecursivePriorityLevel` here, its render function will not be executed
103
+ // just yet. Actually, it will be delayed until the current render function
104
+ // has finished. That ensures directives in the current priorty level have
105
+ // run (and thus modified the passed `element`) before the next level.
106
+ const children =
107
+ rest.length > 0 ? (
108
+ <RecursivePriorityLevel
109
+ directives={ rest }
110
+ element={ element }
111
+ evaluate={ evaluate }
112
+ originalProps={ originalProps }
113
+ />
114
+ ) : (
115
+ element
116
+ );
117
+
118
+ const props = { ...originalProps, children };
50
119
  const directiveArgs = { directives, props, element, context, evaluate };
51
120
 
52
121
  for ( const d in directives ) {
@@ -0,0 +1,98 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ import { createElement, render } from 'preact';
5
+
6
+ /**
7
+ * @param {import('../../src/index').RenderableProps<{ context: any }>} props
8
+ */
9
+ function ContextProvider( props ) {
10
+ this.getChildContext = () => props.context;
11
+ return props.children;
12
+ }
13
+
14
+ /**
15
+ * Portal component
16
+ *
17
+ * @this {import('./internal').Component}
18
+ * @param {object | null | undefined} props
19
+ *
20
+ * TODO: use createRoot() instead of fake root
21
+ */
22
+ function Portal( props ) {
23
+ const _this = this;
24
+ const container = props._container;
25
+
26
+ _this.componentWillUnmount = function () {
27
+ render( null, _this._temp );
28
+ _this._temp = null;
29
+ _this._container = null;
30
+ };
31
+
32
+ // When we change container we should clear our old container and
33
+ // indicate a new mount.
34
+ if ( _this._container && _this._container !== container ) {
35
+ _this.componentWillUnmount();
36
+ }
37
+
38
+ // When props.vnode is undefined/false/null we are dealing with some kind of
39
+ // conditional vnode. This should not trigger a render.
40
+ if ( props._vnode ) {
41
+ if ( ! _this._temp ) {
42
+ _this._container = container;
43
+
44
+ // Create a fake DOM parent node that manages a subset of `container`'s children:
45
+ _this._temp = {
46
+ nodeType: 1,
47
+ parentNode: container,
48
+ childNodes: [],
49
+ appendChild( child ) {
50
+ this.childNodes.push( child );
51
+ _this._container.appendChild( child );
52
+ },
53
+ insertBefore( child ) {
54
+ this.childNodes.push( child );
55
+ _this._container.appendChild( child );
56
+ },
57
+ removeChild( child ) {
58
+ this.childNodes.splice(
59
+ // eslint-disable-next-line no-bitwise
60
+ this.childNodes.indexOf( child ) >>> 1,
61
+ 1
62
+ );
63
+ _this._container.removeChild( child );
64
+ },
65
+ };
66
+ }
67
+
68
+ // Render our wrapping element into temp.
69
+ render(
70
+ createElement(
71
+ ContextProvider,
72
+ { context: _this.context },
73
+ props._vnode
74
+ ),
75
+ _this._temp
76
+ );
77
+ }
78
+ // When we come from a conditional render, on a mounted
79
+ // portal we should clear the DOM.
80
+ else if ( _this._temp ) {
81
+ _this.componentWillUnmount();
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Create a `Portal` to continue rendering the vnode tree at a different DOM node
87
+ *
88
+ * @param {import('./internal').VNode} vnode The vnode to render
89
+ * @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
90
+ */
91
+ export function createPortal( vnode, container ) {
92
+ const el = createElement( Portal, {
93
+ _vnode: vnode,
94
+ _container: container,
95
+ } );
96
+ el.containerInfo = container;
97
+ return el;
98
+ }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/file/utils.js"],"names":["browserSupportsPdfs","window","navigator","userAgent","indexOf","maxTouchPoints","ActiveXObject","createActiveXObject","type","ax","e","undefined","hidePdfEmbedsOnUnsupportedBrowsers","embeds","document","getElementsByClassName","Array","from","forEach","embed","style","display"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAG,MAAM;AACxC;AACA,MAAKC,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,MAApC,IAA+C,CAAC,CAArD,EAAyD;AACxD,WAAO,KAAP;AACA,GAJuC,CAMxC;;;AACA,MAAKH,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,SAApC,IAAkD,CAAC,CAAxD,EAA4D;AAC3D,WAAO,KAAP;AACA,GATuC,CAWxC;;;AACA,MACCH,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,WAApC,IAAoD,CAAC,CAArD,IACAH,MAAM,CAACC,SAAP,CAAiBG,cADjB,IAEAJ,MAAM,CAACC,SAAP,CAAiBG,cAAjB,GAAkC,CAHnC,EAIE;AACD,WAAO,KAAP;AACA,GAlBuC,CAoBxC;;;AACA,MACC,CAAC,EAAIJ,MAAM,CAACK,aAAP,IAAwB,mBAAmBL,MAA/C,CAAD,IACA,EACCM,mBAAmB,CAAE,aAAF,CAAnB,IACAA,mBAAmB,CAAE,aAAF,CAFpB,CAFD,EAME;AACD,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA,CAhCM;AAkCP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACA,MAAMA,mBAAmB,GAAKC,IAAF,IAAY;AACvC,MAAIC,EAAJ;;AACA,MAAI;AACHA,IAAAA,EAAE,GAAG,IAAIR,MAAM,CAACK,aAAX,CAA0BE,IAA1B,CAAL;AACA,GAFD,CAEE,OAAQE,CAAR,EAAY;AACbD,IAAAA,EAAE,GAAGE,SAAL;AACA;;AACD,SAAOF,EAAP;AACA,CARD;AAUA;AACA;AACA;AACA;;;AACO,MAAMG,kCAAkC,GAAG,MAAM;AACvD,MAAK,CAAEZ,mBAAmB,EAA1B,EAA+B;AAC9B,UAAMa,MAAM,GAAGC,QAAQ,CAACC,sBAAT,CACd,sBADc,CAAf;AAGAC,IAAAA,KAAK,CAACC,IAAN,CAAYJ,MAAZ,EAAqBK,OAArB,CAAgCC,KAAF,IAAa;AAC1CA,MAAAA,KAAK,CAACC,KAAN,CAAYC,OAAZ,GAAsB,MAAtB;AACA,KAFD;AAGA;AACD,CATM","sourcesContent":["/**\n * Uses a combination of user agent matching and feature detection to determine whether\n * the current browser supports rendering PDFs inline.\n *\n * @return {boolean} Whether or not the browser supports inline PDFs.\n */\nexport const browserSupportsPdfs = () => {\n\t// Most mobile devices include \"Mobi\" in their UA.\n\tif ( window.navigator.userAgent.indexOf( 'Mobi' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// Android tablets are the noteable exception.\n\tif ( window.navigator.userAgent.indexOf( 'Android' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// iPad pretends to be a Mac.\n\tif (\n\t\twindow.navigator.userAgent.indexOf( 'Macintosh' ) > -1 &&\n\t\twindow.navigator.maxTouchPoints &&\n\t\twindow.navigator.maxTouchPoints > 2\n\t) {\n\t\treturn false;\n\t}\n\n\t// IE only supports PDFs when there's an ActiveX object available for it.\n\tif (\n\t\t!! ( window.ActiveXObject || 'ActiveXObject' in window ) &&\n\t\t! (\n\t\t\tcreateActiveXObject( 'AcroPDF.PDF' ) ||\n\t\t\tcreateActiveXObject( 'PDF.PdfCtrl' )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n};\n\n/**\n * Helper function for creating ActiveX objects, catching any errors that are thrown\n * when it's generated.\n *\n * @param {string} type The name of the ActiveX object to create.\n * @return {window.ActiveXObject|undefined} The generated ActiveXObject, or null if it failed.\n */\nconst createActiveXObject = ( type ) => {\n\tlet ax;\n\ttry {\n\t\tax = new window.ActiveXObject( type );\n\t} catch ( e ) {\n\t\tax = undefined;\n\t}\n\treturn ax;\n};\n\n/**\n * Hides all .wp-block-file__embed elements on the document. This function is only intended\n * to be run on the front-end, it may have weird side effects running in the block editor.\n */\nexport const hidePdfEmbedsOnUnsupportedBrowsers = () => {\n\tif ( ! browserSupportsPdfs() ) {\n\t\tconst embeds = document.getElementsByClassName(\n\t\t\t'wp-block-file__embed'\n\t\t);\n\t\tArray.from( embeds ).forEach( ( embed ) => {\n\t\t\tembed.style.display = 'none';\n\t\t} );\n\t}\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/file/utils.js"],"names":["browserSupportsPdfs","window","navigator","userAgent","indexOf","maxTouchPoints","ActiveXObject","createActiveXObject","type","ax","e","undefined","hidePdfEmbedsOnUnsupportedBrowsers","embeds","document","getElementsByClassName","Array","from","forEach","embed","style","display"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMA,mBAAmB,GAAG,MAAM;AACxC;AACA,MAAKC,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,MAApC,IAA+C,CAAC,CAArD,EAAyD;AACxD,WAAO,KAAP;AACA,GAJuC,CAMxC;;;AACA,MAAKH,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,SAApC,IAAkD,CAAC,CAAxD,EAA4D;AAC3D,WAAO,KAAP;AACA,GATuC,CAWxC;;;AACA,MACCH,MAAM,CAACC,SAAP,CAAiBC,SAAjB,CAA2BC,OAA3B,CAAoC,WAApC,IAAoD,CAAC,CAArD,IACAH,MAAM,CAACC,SAAP,CAAiBG,cADjB,IAEAJ,MAAM,CAACC,SAAP,CAAiBG,cAAjB,GAAkC,CAHnC,EAIE;AACD,WAAO,KAAP;AACA,GAlBuC,CAoBxC;;;AACA,MACC,CAAC,EAAIJ,MAAM,CAACK,aAAP,IAAwB,mBAAmBL,MAA/C,CAAD,IACA,EACCM,mBAAmB,CAAE,aAAF,CAAnB,IACAA,mBAAmB,CAAE,aAAF,CAFpB,CAFD,EAME;AACD,WAAO,KAAP;AACA;;AAED,SAAO,IAAP;AACA,CAhCM;AAkCP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMA,mBAAmB,GAAKC,IAAF,IAAY;AACvC,MAAIC,EAAJ;;AACA,MAAI;AACHA,IAAAA,EAAE,GAAG,IAAIR,MAAM,CAACK,aAAX,CAA0BE,IAA1B,CAAL;AACA,GAFD,CAEE,OAAQE,CAAR,EAAY;AACbD,IAAAA,EAAE,GAAGE,SAAL;AACA;;AACD,SAAOF,EAAP;AACA,CARD;AAUA;AACA;AACA;AACA;;;AACA,OAAO,MAAMG,kCAAkC,GAAG,MAAM;AACvD,MAAK,CAAEZ,mBAAmB,EAA1B,EAA+B;AAC9B,UAAMa,MAAM,GAAGC,QAAQ,CAACC,sBAAT,CACd,sBADc,CAAf;AAGAC,IAAAA,KAAK,CAACC,IAAN,CAAYJ,MAAZ,EAAqBK,OAArB,CAAgCC,KAAF,IAAa;AAC1CA,MAAAA,KAAK,CAACC,KAAN,CAAYC,OAAZ,GAAsB,MAAtB;AACA,KAFD;AAGA;AACD,CATM","sourcesContent":["/**\n * Uses a combination of user agent matching and feature detection to determine whether\n * the current browser supports rendering PDFs inline.\n *\n * @return {boolean} Whether or not the browser supports inline PDFs.\n */\nexport const browserSupportsPdfs = () => {\n\t// Most mobile devices include \"Mobi\" in their UA.\n\tif ( window.navigator.userAgent.indexOf( 'Mobi' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// Android tablets are the noteable exception.\n\tif ( window.navigator.userAgent.indexOf( 'Android' ) > -1 ) {\n\t\treturn false;\n\t}\n\n\t// iPad pretends to be a Mac.\n\tif (\n\t\twindow.navigator.userAgent.indexOf( 'Macintosh' ) > -1 &&\n\t\twindow.navigator.maxTouchPoints &&\n\t\twindow.navigator.maxTouchPoints > 2\n\t) {\n\t\treturn false;\n\t}\n\n\t// IE only supports PDFs when there's an ActiveX object available for it.\n\tif (\n\t\t!! ( window.ActiveXObject || 'ActiveXObject' in window ) &&\n\t\t! (\n\t\t\tcreateActiveXObject( 'AcroPDF.PDF' ) ||\n\t\t\tcreateActiveXObject( 'PDF.PdfCtrl' )\n\t\t)\n\t) {\n\t\treturn false;\n\t}\n\n\treturn true;\n};\n\n/**\n * Helper function for creating ActiveX objects, catching any errors that are thrown\n * when it's generated.\n *\n * @param {string} type The name of the ActiveX object to create.\n * @return {window.ActiveXObject|undefined} The generated ActiveXObject, or null if it failed.\n */\nconst createActiveXObject = ( type ) => {\n\tlet ax;\n\ttry {\n\t\tax = new window.ActiveXObject( type );\n\t} catch ( e ) {\n\t\tax = undefined;\n\t}\n\treturn ax;\n};\n\n/**\n * Hides all .wp-block-file__embed elements on the document. This function is only intended\n * to be run on the front-end, it may have weird side effects running in the block editor.\n */\nexport const hidePdfEmbedsOnUnsupportedBrowsers = () => {\n\tif ( ! browserSupportsPdfs() ) {\n\t\tconst embeds = document.getElementsByClassName(\n\t\t\t'wp-block-file__embed'\n\t\t);\n\t\tArray.from( embeds ).forEach( ( embed ) => {\n\t\t\tembed.style.display = 'none';\n\t\t} );\n\t}\n};\n"]}
File without changes