@wordpress/block-library 7.3.2 → 7.4.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 (266) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/archives/edit.js +1 -1
  3. package/build/archives/edit.js.map +1 -1
  4. package/build/audio/edit.js +1 -1
  5. package/build/audio/edit.js.map +1 -1
  6. package/build/audio/edit.native.js +1 -1
  7. package/build/audio/edit.native.js.map +1 -1
  8. package/build/categories/edit.js +8 -3
  9. package/build/categories/edit.js.map +1 -1
  10. package/build/categories/index.js +4 -0
  11. package/build/categories/index.js.map +1 -1
  12. package/build/column/index.js +10 -0
  13. package/build/column/index.js.map +1 -1
  14. package/build/comment-template/hooks.js +11 -3
  15. package/build/comment-template/hooks.js.map +1 -1
  16. package/build/comments-pagination/edit.js +18 -1
  17. package/build/comments-pagination/edit.js.map +1 -1
  18. package/build/comments-query-loop/edit.js +1 -1
  19. package/build/comments-query-loop/edit.js.map +1 -1
  20. package/build/comments-title/edit.js +149 -0
  21. package/build/comments-title/edit.js.map +1 -0
  22. package/build/comments-title/index.js +101 -0
  23. package/build/comments-title/index.js.map +1 -0
  24. package/build/embed/edit.js +12 -18
  25. package/build/embed/edit.js.map +1 -1
  26. package/build/embed/edit.native.js +1 -7
  27. package/build/embed/edit.native.js.map +1 -1
  28. package/build/embed/util.js +29 -4
  29. package/build/embed/util.js.map +1 -1
  30. package/build/file/inspector.js +2 -4
  31. package/build/file/inspector.js.map +1 -1
  32. package/build/gallery/edit.js +1 -1
  33. package/build/gallery/edit.js.map +1 -1
  34. package/build/gallery/v1/edit.js +1 -1
  35. package/build/gallery/v1/edit.js.map +1 -1
  36. package/build/html/edit.js +2 -2
  37. package/build/html/edit.js.map +1 -1
  38. package/build/image/edit.js +4 -6
  39. package/build/image/edit.js.map +1 -1
  40. package/build/image/edit.native.js +1 -1
  41. package/build/image/edit.native.js.map +1 -1
  42. package/build/image/image.js +1 -1
  43. package/build/image/image.js.map +1 -1
  44. package/build/index.js +3 -1
  45. package/build/index.js.map +1 -1
  46. package/build/index.native.js +14 -3
  47. package/build/index.native.js.map +1 -1
  48. package/build/latest-comments/edit.js +1 -1
  49. package/build/latest-comments/edit.js.map +1 -1
  50. package/build/loginout/edit.js +1 -1
  51. package/build/loginout/edit.js.map +1 -1
  52. package/build/media-text/edit.js +1 -2
  53. package/build/media-text/edit.js.map +1 -1
  54. package/build/media-text/edit.native.js +1 -1
  55. package/build/media-text/edit.native.js.map +1 -1
  56. package/build/navigation/edit/index.js +17 -1
  57. package/build/navigation/edit/index.js.map +1 -1
  58. package/build/navigation/edit/navigation-menu-selector.js +7 -2
  59. package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
  60. package/build/navigation/edit/unsaved-inner-blocks.js +5 -4
  61. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  62. package/build/navigation/index.js +1 -1
  63. package/build/navigation/view-modal.js +37 -0
  64. package/build/navigation/view-modal.js.map +1 -0
  65. package/build/navigation/view.js +1 -34
  66. package/build/navigation/view.js.map +1 -1
  67. package/build/paragraph/edit.native.js +6 -2
  68. package/build/paragraph/edit.native.js.map +1 -1
  69. package/build/post-author/edit.js +1 -1
  70. package/build/post-author/edit.js.map +1 -1
  71. package/build/post-excerpt/edit.js +1 -1
  72. package/build/post-excerpt/edit.js.map +1 -1
  73. package/build/quote/index.js +6 -0
  74. package/build/quote/index.js.map +1 -1
  75. package/build/quote/v2/edit.js +11 -3
  76. package/build/quote/v2/edit.js.map +1 -1
  77. package/build/rss/edit.js +1 -1
  78. package/build/rss/edit.js.map +1 -1
  79. package/build/search/edit.js +11 -9
  80. package/build/search/edit.js.map +1 -1
  81. package/build/spacer/constants.js +9 -0
  82. package/build/spacer/constants.js.map +1 -0
  83. package/build/spacer/controls.js +3 -3
  84. package/build/spacer/controls.js.map +1 -1
  85. package/build/spacer/controls.native.js +2 -2
  86. package/build/spacer/controls.native.js.map +1 -1
  87. package/build/spacer/edit.js +5 -6
  88. package/build/spacer/edit.js.map +1 -1
  89. package/build/table/edit.js +8 -2
  90. package/build/table/edit.js.map +1 -1
  91. package/build/tag-cloud/edit.js +1 -1
  92. package/build/tag-cloud/edit.js.map +1 -1
  93. package/build/video/edit.js +1 -1
  94. package/build/video/edit.js.map +1 -1
  95. package/build/video/edit.native.js +1 -1
  96. package/build/video/edit.native.js.map +1 -1
  97. package/build-module/archives/edit.js +1 -1
  98. package/build-module/archives/edit.js.map +1 -1
  99. package/build-module/audio/edit.js +1 -1
  100. package/build-module/audio/edit.js.map +1 -1
  101. package/build-module/audio/edit.native.js +1 -1
  102. package/build-module/audio/edit.native.js.map +1 -1
  103. package/build-module/categories/edit.js +8 -3
  104. package/build-module/categories/edit.js.map +1 -1
  105. package/build-module/categories/index.js +4 -0
  106. package/build-module/categories/index.js.map +1 -1
  107. package/build-module/column/index.js +10 -0
  108. package/build-module/column/index.js.map +1 -1
  109. package/build-module/comment-template/hooks.js +11 -3
  110. package/build-module/comment-template/hooks.js.map +1 -1
  111. package/build-module/comments-pagination/edit.js +19 -2
  112. package/build-module/comments-pagination/edit.js.map +1 -1
  113. package/build-module/comments-query-loop/edit.js +1 -1
  114. package/build-module/comments-query-loop/edit.js.map +1 -1
  115. package/build-module/comments-title/edit.js +133 -0
  116. package/build-module/comments-title/edit.js.map +1 -0
  117. package/build-module/comments-title/index.js +88 -0
  118. package/build-module/comments-title/index.js.map +1 -0
  119. package/build-module/embed/edit.js +13 -19
  120. package/build-module/embed/edit.js.map +1 -1
  121. package/build-module/embed/edit.native.js +2 -8
  122. package/build-module/embed/edit.native.js.map +1 -1
  123. package/build-module/embed/util.js +25 -3
  124. package/build-module/embed/util.js.map +1 -1
  125. package/build-module/file/inspector.js +2 -4
  126. package/build-module/file/inspector.js.map +1 -1
  127. package/build-module/gallery/edit.js +1 -1
  128. package/build-module/gallery/edit.js.map +1 -1
  129. package/build-module/gallery/v1/edit.js +1 -1
  130. package/build-module/gallery/v1/edit.js.map +1 -1
  131. package/build-module/html/edit.js +2 -2
  132. package/build-module/html/edit.js.map +1 -1
  133. package/build-module/image/edit.js +4 -6
  134. package/build-module/image/edit.js.map +1 -1
  135. package/build-module/image/edit.native.js +1 -1
  136. package/build-module/image/edit.native.js.map +1 -1
  137. package/build-module/image/image.js +1 -1
  138. package/build-module/image/image.js.map +1 -1
  139. package/build-module/index.js +2 -1
  140. package/build-module/index.js.map +1 -1
  141. package/build-module/index.native.js +14 -3
  142. package/build-module/index.native.js.map +1 -1
  143. package/build-module/latest-comments/edit.js +1 -1
  144. package/build-module/latest-comments/edit.js.map +1 -1
  145. package/build-module/loginout/edit.js +1 -1
  146. package/build-module/loginout/edit.js.map +1 -1
  147. package/build-module/media-text/edit.js +1 -2
  148. package/build-module/media-text/edit.js.map +1 -1
  149. package/build-module/media-text/edit.native.js +1 -1
  150. package/build-module/media-text/edit.native.js.map +1 -1
  151. package/build-module/navigation/edit/index.js +17 -1
  152. package/build-module/navigation/edit/index.js.map +1 -1
  153. package/build-module/navigation/edit/navigation-menu-selector.js +6 -2
  154. package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
  155. package/build-module/navigation/edit/unsaved-inner-blocks.js +5 -4
  156. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  157. package/build-module/navigation/index.js +1 -1
  158. package/build-module/navigation/view-modal.js +32 -0
  159. package/build-module/navigation/view-modal.js.map +1 -0
  160. package/build-module/navigation/view.js +1 -30
  161. package/build-module/navigation/view.js.map +1 -1
  162. package/build-module/paragraph/edit.native.js +6 -2
  163. package/build-module/paragraph/edit.native.js.map +1 -1
  164. package/build-module/post-author/edit.js +1 -1
  165. package/build-module/post-author/edit.js.map +1 -1
  166. package/build-module/post-excerpt/edit.js +1 -1
  167. package/build-module/post-excerpt/edit.js.map +1 -1
  168. package/build-module/quote/index.js +1 -1
  169. package/build-module/quote/index.js.map +1 -1
  170. package/build-module/quote/v2/edit.js +10 -3
  171. package/build-module/quote/v2/edit.js.map +1 -1
  172. package/build-module/rss/edit.js +1 -1
  173. package/build-module/rss/edit.js.map +1 -1
  174. package/build-module/search/edit.js +11 -9
  175. package/build-module/search/edit.js.map +1 -1
  176. package/build-module/spacer/constants.js +2 -0
  177. package/build-module/spacer/constants.js.map +1 -0
  178. package/build-module/spacer/controls.js +2 -2
  179. package/build-module/spacer/controls.js.map +1 -1
  180. package/build-module/spacer/controls.native.js +1 -1
  181. package/build-module/spacer/controls.native.js.map +1 -1
  182. package/build-module/spacer/edit.js +1 -1
  183. package/build-module/spacer/edit.js.map +1 -1
  184. package/build-module/table/edit.js +9 -3
  185. package/build-module/table/edit.js.map +1 -1
  186. package/build-module/tag-cloud/edit.js +1 -1
  187. package/build-module/tag-cloud/edit.js.map +1 -1
  188. package/build-module/video/edit.js +1 -1
  189. package/build-module/video/edit.js.map +1 -1
  190. package/build-module/video/edit.native.js +1 -1
  191. package/build-module/video/edit.native.js.map +1 -1
  192. package/build-style/comments-title/editor-rtl.css +79 -0
  193. package/build-style/comments-title/editor.css +79 -0
  194. package/build-style/common-rtl.css +32 -0
  195. package/build-style/common.css +32 -0
  196. package/build-style/editor-rtl.css +12 -0
  197. package/build-style/editor.css +12 -0
  198. package/build-style/post-comments-form/style-rtl.css +9 -0
  199. package/build-style/post-comments-form/style.css +9 -0
  200. package/build-style/style-rtl.css +79 -0
  201. package/build-style/style.css +79 -0
  202. package/build-style/table/editor-rtl.css +8 -0
  203. package/build-style/table/editor.css +8 -0
  204. package/build-style/table/style-rtl.css +38 -0
  205. package/build-style/table/style.css +38 -0
  206. package/package.json +28 -28
  207. package/src/archives/edit.js +1 -1
  208. package/src/audio/edit.js +1 -1
  209. package/src/audio/edit.native.js +1 -1
  210. package/src/categories/block.json +4 -0
  211. package/src/categories/edit.js +8 -2
  212. package/src/categories/index.php +1 -0
  213. package/src/column/block.json +10 -0
  214. package/src/comment-template/hooks.js +13 -1
  215. package/src/comment-template/index.php +13 -4
  216. package/src/comments-pagination/edit.js +23 -0
  217. package/src/comments-query-loop/edit.js +1 -0
  218. package/src/comments-title/block.json +70 -0
  219. package/src/comments-title/edit.js +197 -0
  220. package/src/comments-title/editor.scss +4 -0
  221. package/src/comments-title/index.js +18 -0
  222. package/src/comments-title/index.php +68 -0
  223. package/src/common.scss +24 -1
  224. package/src/editor.scss +1 -0
  225. package/src/embed/edit.js +19 -24
  226. package/src/embed/edit.native.js +9 -14
  227. package/src/embed/util.js +34 -2
  228. package/src/file/inspector.js +1 -3
  229. package/src/gallery/edit.js +1 -1
  230. package/src/gallery/v1/edit.js +1 -1
  231. package/src/html/edit.js +2 -2
  232. package/src/image/edit.js +2 -4
  233. package/src/image/edit.native.js +1 -1
  234. package/src/image/image.js +1 -1
  235. package/src/index.js +3 -0
  236. package/src/index.native.js +12 -2
  237. package/src/latest-comments/edit.js +1 -1
  238. package/src/loginout/edit.js +1 -1
  239. package/src/media-text/edit.js +1 -2
  240. package/src/media-text/edit.native.js +1 -1
  241. package/src/navigation/block.json +1 -1
  242. package/src/navigation/edit/index.js +24 -0
  243. package/src/navigation/edit/navigation-menu-selector.js +15 -9
  244. package/src/navigation/edit/unsaved-inner-blocks.js +5 -4
  245. package/src/navigation/index.php +5 -0
  246. package/src/navigation/view-modal.js +36 -0
  247. package/src/navigation/view.js +0 -35
  248. package/src/paragraph/edit.native.js +13 -1
  249. package/src/post-author/edit.js +1 -1
  250. package/src/post-comments-form/style.scss +11 -0
  251. package/src/post-excerpt/edit.js +1 -1
  252. package/src/quote/index.js +1 -1
  253. package/src/quote/v2/edit.js +3 -0
  254. package/src/rss/edit.js +1 -1
  255. package/src/search/edit.js +13 -7
  256. package/src/search/index.php +84 -33
  257. package/src/spacer/constants.js +1 -0
  258. package/src/spacer/controls.js +2 -2
  259. package/src/spacer/controls.native.js +1 -1
  260. package/src/spacer/edit.js +1 -2
  261. package/src/table/edit.js +11 -2
  262. package/src/table/editor.scss +13 -0
  263. package/src/table/style.scss +52 -0
  264. package/src/tag-cloud/edit.js +1 -1
  265. package/src/video/edit.js +1 -1
  266. package/src/video/edit.native.js +1 -1
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = Edit;
9
+
10
+ var _element = require("@wordpress/element");
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _blockEditor = require("@wordpress/block-editor");
15
+
16
+ var _i18n = require("@wordpress/i18n");
17
+
18
+ var _coreData = require("@wordpress/core-data");
19
+
20
+ var _components = require("@wordpress/components");
21
+
22
+ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
23
+
24
+ var _url = require("@wordpress/url");
25
+
26
+ var _headingLevelDropdown = _interopRequireDefault(require("../heading/heading-level-dropdown"));
27
+
28
+ /**
29
+ * External dependencies
30
+ */
31
+
32
+ /**
33
+ * WordPress dependencies
34
+ */
35
+
36
+ /**
37
+ * Internal dependencies
38
+ */
39
+ function Edit(_ref) {
40
+ let {
41
+ attributes: {
42
+ textAlign,
43
+ singleCommentLabel,
44
+ multipleCommentsLabel,
45
+ showPostTitle,
46
+ showCommentsCount,
47
+ level
48
+ },
49
+ setAttributes,
50
+ context: {
51
+ postType,
52
+ postId
53
+ }
54
+ } = _ref;
55
+ const TagName = 'h' + level;
56
+ const [commentsCount, setCommentsCount] = (0, _element.useState)();
57
+ const [editingMode, setEditingMode] = (0, _element.useState)('plural');
58
+ const [rawTitle] = (0, _coreData.useEntityProp)('postType', postType, 'title', postId);
59
+ const isSiteEditor = typeof postId === 'undefined';
60
+ const blockProps = (0, _blockEditor.useBlockProps)({
61
+ className: (0, _classnames.default)({
62
+ [`has-text-align-${textAlign}`]: textAlign
63
+ })
64
+ });
65
+ (0, _element.useEffect)(() => {
66
+ if (isSiteEditor) {
67
+ setCommentsCount(3);
68
+ return;
69
+ }
70
+
71
+ const currentPostId = postId;
72
+ (0, _apiFetch.default)({
73
+ path: (0, _url.addQueryArgs)('/wp/v2/comments', {
74
+ post: postId,
75
+ _fields: 'id'
76
+ }),
77
+ method: 'HEAD',
78
+ parse: false
79
+ }).then(res => {
80
+ // Stale requests will have the `currentPostId` of an older closure.
81
+ if (currentPostId === postId) {
82
+ setCommentsCount(parseInt(res.headers.get('X-WP-Total')));
83
+ }
84
+ }).catch(() => {
85
+ setCommentsCount(0);
86
+ });
87
+ }, [postId]);
88
+ const blockControls = (0, _element.createElement)(_blockEditor.BlockControls, {
89
+ group: "block"
90
+ }, (0, _element.createElement)(_blockEditor.AlignmentControl, {
91
+ value: textAlign,
92
+ onChange: newAlign => setAttributes({
93
+ textAlign: newAlign
94
+ })
95
+ }), (0, _element.createElement)(_headingLevelDropdown.default, {
96
+ selectedLevel: level,
97
+ onChange: newLevel => setAttributes({
98
+ level: newLevel
99
+ })
100
+ }));
101
+ const inspectorControls = (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
102
+ title: (0, _i18n.__)('Settings')
103
+ }, isSiteEditor && (0, _element.createElement)(_components.__experimentalToggleGroupControl, {
104
+ label: (0, _i18n.__)('Editing mode'),
105
+ onChange: setEditingMode,
106
+ value: editingMode
107
+ }, (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
108
+ label: (0, _i18n.__)('Singular'),
109
+ value: "singular"
110
+ }), (0, _element.createElement)(_components.__experimentalToggleGroupControlOption, {
111
+ label: (0, _i18n.__)('Plural'),
112
+ value: "plural"
113
+ })), (0, _element.createElement)(_components.ToggleControl, {
114
+ label: (0, _i18n.__)('Show post title'),
115
+ checked: showPostTitle,
116
+ onChange: value => setAttributes({
117
+ showPostTitle: value
118
+ })
119
+ }), (0, _element.createElement)(_components.ToggleControl, {
120
+ label: (0, _i18n.__)('Show comments count'),
121
+ checked: showCommentsCount,
122
+ onChange: value => setAttributes({
123
+ showCommentsCount: value
124
+ })
125
+ })));
126
+ const postTitle = isSiteEditor ? (0, _i18n.__)('"Post Title"') : `"${rawTitle}"`;
127
+ const singlePlaceholder = showPostTitle ? (0, _i18n.__)('One response to ') : (0, _i18n.__)('One response');
128
+ const multiplePlaceholder = showPostTitle ? (0, _i18n.__)('Responses to ') : (0, _i18n.__)('Responses');
129
+ return (0, _element.createElement)(_element.Fragment, null, blockControls, inspectorControls, (0, _element.createElement)(TagName, blockProps, editingMode === 'singular' || commentsCount === 1 ? (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.PlainText, {
130
+ __experimentalVersion: 2,
131
+ tagName: "span",
132
+ "aria-label": singlePlaceholder,
133
+ placeholder: singlePlaceholder,
134
+ value: singleCommentLabel,
135
+ onChange: newLabel => setAttributes({
136
+ singleCommentLabel: newLabel
137
+ })
138
+ }), showPostTitle ? postTitle : null) : (0, _element.createElement)(_element.Fragment, null, showCommentsCount ? commentsCount : null, (0, _element.createElement)(_blockEditor.PlainText, {
139
+ __experimentalVersion: 2,
140
+ tagName: "span",
141
+ "aria-label": showCommentsCount ? ` ${multiplePlaceholder}` : multiplePlaceholder,
142
+ placeholder: showCommentsCount ? ` ${multiplePlaceholder}` : multiplePlaceholder,
143
+ value: multipleCommentsLabel,
144
+ onChange: newLabel => setAttributes({
145
+ multipleCommentsLabel: newLabel
146
+ })
147
+ }), showPostTitle ? postTitle : null)));
148
+ }
149
+ //# sourceMappingURL=edit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-title/edit.js"],"names":["Edit","attributes","textAlign","singleCommentLabel","multipleCommentsLabel","showPostTitle","showCommentsCount","level","setAttributes","context","postType","postId","TagName","commentsCount","setCommentsCount","editingMode","setEditingMode","rawTitle","isSiteEditor","blockProps","className","currentPostId","path","post","_fields","method","parse","then","res","parseInt","headers","get","catch","blockControls","newAlign","newLevel","inspectorControls","value","postTitle","singlePlaceholder","multiplePlaceholder","newLabel"],"mappings":";;;;;;;;;AAuBA;;AApBA;;AAKA;;AAOA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;A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A,mBAXL;AAaC,IAAA,KAAK,EAAGpC,qBAbT;AAcC,IAAA,QAAQ,EAAKqC,QAAF,IACVjC,aAAa,CAAE;AACdJ,MAAAA,qBAAqB,EAAEqC;AADT,KAAF;AAff,IAFD,EAsBGpC,aAAa,GAAGiC,SAAH,GAAe,IAtB/B,CAlBF,CAHD,CADD;AAkDA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tuseBlockProps,\n\tPlainText,\n\tInspectorControls,\n} from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { useEntityProp } from '@wordpress/core-data';\nimport {\n\tPanelBody,\n\tToggleControl,\n\t__experimentalToggleGroupControl as ToggleGroupControl,\n\t__experimentalToggleGroupControlOption as ToggleGroupControlOption,\n} from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport HeadingLevelDropdown from '../heading/heading-level-dropdown';\n\nexport default function Edit( {\n\tattributes: {\n\t\ttextAlign,\n\t\tsingleCommentLabel,\n\t\tmultipleCommentsLabel,\n\t\tshowPostTitle,\n\t\tshowCommentsCount,\n\t\tlevel,\n\t},\n\tsetAttributes,\n\tcontext: { postType, postId },\n} ) {\n\tconst TagName = 'h' + level;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst [ editingMode, setEditingMode ] = useState( 'plural' );\n\tconst [ rawTitle ] = useEntityProp( 'postType', postType, 'title', postId );\n\tconst isSiteEditor = typeof postId === 'undefined';\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( isSiteEditor ) {\n\t\t\tsetCommentsCount( 3 );\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} )\n\t\t\t.then( ( res ) => {\n\t\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\t\tif ( currentPostId === postId ) {\n\t\t\t\t\tsetCommentsCount(\n\t\t\t\t\t\tparseInt( res.headers.get( 'X-WP-Total' ) )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} )\n\t\t\t.catch( () => {\n\t\t\t\tsetCommentsCount( 0 );\n\t\t\t} );\n\t}, [ postId ] );\n\n\tconst blockControls = (\n\t\t<BlockControls group=\"block\">\n\t\t\t<AlignmentControl\n\t\t\t\tvalue={ textAlign }\n\t\t\t\tonChange={ ( newAlign ) =>\n\t\t\t\t\tsetAttributes( { textAlign: newAlign } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<HeadingLevelDropdown\n\t\t\t\tselectedLevel={ level }\n\t\t\t\tonChange={ ( newLevel ) =>\n\t\t\t\t\tsetAttributes( { level: newLevel } )\n\t\t\t\t}\n\t\t\t/>\n\t\t</BlockControls>\n\t);\n\n\tconst inspectorControls = (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t{ isSiteEditor && (\n\t\t\t\t\t<ToggleGroupControl\n\t\t\t\t\t\tlabel={ __( 'Editing mode' ) }\n\t\t\t\t\t\tonChange={ setEditingMode }\n\t\t\t\t\t\tvalue={ editingMode }\n\t\t\t\t\t>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tlabel={ __( 'Singular' ) }\n\t\t\t\t\t\t\tvalue=\"singular\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<ToggleGroupControlOption\n\t\t\t\t\t\t\tlabel={ __( 'Plural' ) }\n\t\t\t\t\t\t\tvalue=\"plural\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToggleGroupControl>\n\t\t\t\t) }\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show post title' ) }\n\t\t\t\t\tchecked={ showPostTitle }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showPostTitle: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Show comments count' ) }\n\t\t\t\t\tchecked={ showCommentsCount }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { showCommentsCount: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n\n\tconst postTitle = isSiteEditor ? __( '\"Post Title\"' ) : `\"${ rawTitle }\"`;\n\n\tconst singlePlaceholder = showPostTitle\n\t\t? __( 'One response to ' )\n\t\t: __( 'One response' );\n\n\tconst multiplePlaceholder = showPostTitle\n\t\t? __( 'Responses to ' )\n\t\t: __( 'Responses' );\n\n\treturn (\n\t\t<>\n\t\t\t{ blockControls }\n\t\t\t{ inspectorControls }\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t{ editingMode === 'singular' || commentsCount === 1 ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\taria-label={ singlePlaceholder }\n\t\t\t\t\t\t\tplaceholder={ singlePlaceholder }\n\t\t\t\t\t\t\tvalue={ singleCommentLabel }\n\t\t\t\t\t\t\tonChange={ ( newLabel ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tsingleCommentLabel: newLabel,\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\t\t\t\t\t\t{ showPostTitle ? postTitle : null }\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t{ showCommentsCount ? commentsCount : null }\n\t\t\t\t\t\t<PlainText\n\t\t\t\t\t\t\t__experimentalVersion={ 2 }\n\t\t\t\t\t\t\ttagName=\"span\"\n\t\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\t\tshowCommentsCount\n\t\t\t\t\t\t\t\t\t? ` ${ multiplePlaceholder }`\n\t\t\t\t\t\t\t\t\t: multiplePlaceholder\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tplaceholder={\n\t\t\t\t\t\t\t\tshowCommentsCount\n\t\t\t\t\t\t\t\t\t? ` ${ multiplePlaceholder }`\n\t\t\t\t\t\t\t\t\t: multiplePlaceholder\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tvalue={ multipleCommentsLabel }\n\t\t\t\t\t\t\tonChange={ ( newLabel ) =>\n\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\tmultipleCommentsLabel: newLabel,\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\t\t\t\t\t\t{ showPostTitle ? postTitle : null }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</TagName>\n\t\t</>\n\t);\n}\n"]}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.settings = exports.name = exports.metadata = void 0;
9
+
10
+ var _icons = require("@wordpress/icons");
11
+
12
+ var _edit = _interopRequireDefault(require("./edit"));
13
+
14
+ /**
15
+ * WordPress dependencies
16
+ */
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ const metadata = {
22
+ $schema: "https://schemas.wp.org/trunk/block.json",
23
+ apiVersion: 2,
24
+ name: "core/comments-title",
25
+ title: "Comments Title",
26
+ category: "theme",
27
+ ancestor: ["core/comments-query-loop"],
28
+ description: "Displays a title with the number of comments",
29
+ textdomain: "default",
30
+ usesContext: ["postId", "postType"],
31
+ attributes: {
32
+ textAlign: {
33
+ type: "string"
34
+ },
35
+ singleCommentLabel: {
36
+ type: "string"
37
+ },
38
+ multipleCommentsLabel: {
39
+ type: "string"
40
+ },
41
+ showPostTitle: {
42
+ type: "boolean",
43
+ "default": true
44
+ },
45
+ showCommentsCount: {
46
+ type: "boolean",
47
+ "default": true
48
+ },
49
+ level: {
50
+ type: "number",
51
+ "default": 2
52
+ }
53
+ },
54
+ supports: {
55
+ anchor: false,
56
+ align: true,
57
+ html: false,
58
+ __experimentalBorder: {
59
+ radius: true,
60
+ color: true,
61
+ width: true,
62
+ style: true
63
+ },
64
+ color: {
65
+ gradients: true,
66
+ __experimentalDefaultControls: {
67
+ background: true,
68
+ text: true
69
+ }
70
+ },
71
+ spacing: {
72
+ margin: true,
73
+ padding: true
74
+ },
75
+ typography: {
76
+ fontSize: true,
77
+ lineHeight: true,
78
+ __experimentalFontStyle: true,
79
+ __experimentalFontWeight: true,
80
+ __experimentalFontFamily: true,
81
+ __experimentalTextTransform: true,
82
+ __experimentalDefaultControls: {
83
+ fontSize: true,
84
+ __experimentalFontFamily: true,
85
+ __experimentalFontStyle: true,
86
+ __experimentalFontWeight: true
87
+ }
88
+ }
89
+ }
90
+ };
91
+ exports.metadata = metadata;
92
+ const {
93
+ name
94
+ } = metadata;
95
+ exports.name = name;
96
+ const settings = {
97
+ icon: _icons.commentTitle,
98
+ edit: _edit.default
99
+ };
100
+ exports.settings = settings;
101
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["@wordpress/block-library/src/comments-title/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,mBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { commentTitle as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
@@ -111,17 +111,15 @@ const EmbedEdit = props => {
111
111
  };
112
112
  }, [attributesUrl]);
113
113
  /**
114
- * @return {Object} Attributes derived from the preview, merged with the current attributes.
114
+ * Returns the attributes derived from the preview, merged with the current attributes.
115
+ *
116
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
117
+ * @return {Object} Merged attributes.
115
118
  */
116
119
 
117
- const getMergedAttributes = () => {
118
- const {
119
- allowResponsive,
120
- className
121
- } = attributes;
122
- return { ...attributes,
123
- ...(0, _util.getAttributesFromPreview)(preview, title, className, responsive, allowResponsive)
124
- };
120
+ const getMergedAttributes = function () {
121
+ let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
122
+ return (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive, ignorePreviousClassName);
125
123
  };
126
124
 
127
125
  const toggleResponsive = () => {
@@ -156,15 +154,11 @@ const EmbedEdit = props => {
156
154
 
157
155
  (0, _element.useEffect)(() => {
158
156
  if (preview && !isEditingURL) {
159
- // Even though we set attributes that get derived from the preview,
160
- // we don't access them directly because for the initial render,
161
- // the `setAttributes` call will not have taken effect. If we're
162
- // rendering responsive content, setting the responsive classes
163
- // after the preview has been rendered can result in unwanted
164
- // clipping or scrollbars. The `getAttributesFromPreview` function
165
- // that `getMergedAttributes` uses is memoized so that we're not
166
- // calculating them on every render.
167
- setAttributes(getMergedAttributes());
157
+ // When obtaining an incoming preview, we set the attributes derived from
158
+ // the preview data. In this case when getting the merged attributes,
159
+ // we ignore the previous classname because it might not match the expected
160
+ // classes by the new preview.
161
+ setAttributes(getMergedAttributes(true));
168
162
 
169
163
  if (onReplace) {
170
164
  const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props, getMergedAttributes());
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","allowResponsive","className","toggleResponsive","newAllowResponsive","newURL","replace","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","target","value","caption","classFromPreview"],"mappings":";;;;;;;;;AAyBA;;AAtBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AA7BA;AACA;AACA;;AAcA;AACA;AACA;;AAGA;AACA;AACA;AAQA,MAAMA,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AACXC,MAAAA,gBADW;AAEXC,MAAAA,WAFW;AAGXC,MAAAA,UAHW;AAIXC,MAAAA,GAAG,EAAEC;AAJM,KADP;AAOLL,IAAAA,UAPK;AAQLM,IAAAA,UARK;AASLC,IAAAA,SATK;AAULC,IAAAA,aAVK;AAWLC,IAAAA,iBAXK;AAYLC,IAAAA;AAZK,MAaFX,KAbJ;AAeA,QAAMY,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,I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EAAGqB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB7C,aAAa,CAAE;AAAE8C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAG/C,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGmC,KAZT;AAaC,IAAA,iBAAiB,EAAGvC;AAbrB,IADD,CATD,CADD;AA6BA,CAlOD;;eAoOeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetAttributesFromPreview,\n\tgetEmbedInfoByProvider,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\t);\n\n\t/**\n\t * @return {Object} Attributes derived from the preview, merged with the current attributes.\n\t */\n\tconst getMergedAttributes = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\treturn {\n\t\t\t...attributes,\n\t\t\t...getAttributesFromPreview(\n\t\t\t\tpreview,\n\t\t\t\ttitle,\n\t\t\t\tclassName,\n\t\t\t\tresponsive,\n\t\t\t\tallowResponsive\n\t\t\t),\n\t\t};\n\t};\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// Even though we set attributes that get derived from the preview,\n\t\t\t// we don't access them directly because for the initial render,\n\t\t\t// the `setAttributes` call will not have taken effect. If we're\n\t\t\t// rendering responsive content, setting the responsive classes\n\t\t\t// after the preview has been rendered can result in unwanted\n\t\t\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t\t\t// that `getMergedAttributes` uses is memoized so that we're not\n\t\t\t// calculating them on every render.\n\t\t\tsetAttributes( getMergedAttributes() );\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","target","value","caption","classFromPreview"],"mappings":";;;;;;;;;AAyBA;;AAtBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AACA;;AACA;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AA,uBAAuB,EAAGnB,UAH3B;AAIC,IAAA,eAAe,EAAGuC,eAJnB;AAKC,IAAA,gBAAgB,EAAGD,gBALpB;AAMC,IAAA,oBAAoB,EAAG,MAAMxB,eAAe,CAAE,IAAF;AAN7C,IADD,EASC,4BAAC,gBAAD,EAAW+B,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAG5B,OADX;AAEC,IAAA,WAAW,EAAGlB,WAFf;AAGC,IAAA,SAAS,EAAGyC,SAHb;AAIC,IAAA,GAAG,EAAGvC,GAJP;AAKC,IAAA,IAAI,EAAG6B,IALR;AAMC,IAAA,OAAO,EAAGsB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB9C,aAAa,CAAE;AAAE+C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAGhD,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGoC,KAZT;AAaC,IAAA,iBAAiB,EAAGxC;AAbrB,IADD,CATD,CADD;AA6BA,CA7ND;;eA+NeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! attributesUrl ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( attributesUrl );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ attributesUrl ]\n\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
@@ -136,13 +136,7 @@ const EmbedEdit = props => {
136
136
 
137
137
  const getMergedAttributes = function () {
138
138
  let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
139
- const {
140
- allowResponsive,
141
- className
142
- } = attributes;
143
- return { ...attributes,
144
- ...(0, _util.getAttributesFromPreview)(preview, title, ignorePreviousClassName ? undefined : className, responsive, allowResponsive)
145
- };
139
+ return (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive, ignorePreviousClassName);
146
140
  };
147
141
 
148
142
  const toggleResponsive = () => {
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","ignorePreviousClassName","allowResponsive","className","toggleResponsive","newAllowResponsive","newURL","replace","upgradedBlock","onEditURL","value","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAjCA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,gBAAT;AAA2BC,MAAAA,WAA3B;AAAwCC,MAAAA,UAAxC;AAAoDC,M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,IAAA,KAAK,EAAGX,GAHT;AAIC,IAAA,KAAK,EAAGuD,SAJT;AAKC,IAAA,SAAS,EAAGtC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CA3QD;;eA6QevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetAttributesFromPreview,\n\tgetEmbedInfoByProvider,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] = useState(\n\t\tisEditingURL\n\t);\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! url ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t'getEmbedPreview',\n\t\t\t\t[ url ]\n\t\t\t);\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ url ]\n\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\treturn {\n\t\t\t...attributes,\n\t\t\t...getAttributesFromPreview(\n\t\t\t\tpreview,\n\t\t\t\ttitle,\n\t\t\t\tignorePreviousClassName ? undefined : className,\n\t\t\t\tresponsive,\n\t\t\t\tallowResponsive\n\t\t\t),\n\t\t};\n\t};\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect( () => setShowEmbedBottomSheet( isEditingURL ), [\n\t\tisEditingURL,\n\t] );\n\n\tconst onEditURL = useCallback( ( value ) => {\n\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t// for creating the new block.\n\t\tsetAttributes( { url: value } );\n\t\tsetIsEditingURL( false );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
1
+ {"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","onEditURL","value","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAjCA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,gBAAT;AAA2BC,MAAAA,WAA3B;AAAwCC,MAAAA,UAAxC;AAAoDC,MAAAA;AAApD,KADP;AAELL,IAAAA,UAFK;AAGLM,IAAAA,UAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,iBANK;AAOLC,IAAAA,OAPK;AAQLC,IAAAA;AARK,MASFZ,KATJ;AAWA,QAAMa,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,IAAAA,IAAI,EAAEC;AAFkB,GAAzB;AAIA,QAAMC,mBAAmB,GAAG,kCAAwBd,gBAAxB,CAA5B;AACA,QAAM;AAAEY,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MAAkBG,mBAAmB,IAAIJ,gBAA/C;AAE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IAAA,SAAS,EAAGuD,SANb;AAOC,IAAA,SAAS,EAAGP;AAPb,IADD,EAUC,4BAAC,gBAAD,EAAWE,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAGtD,KADT;AAEC,IAAA,SAAS,EAAG+C,SAFb;AAGC,IAAA,QAAQ,EAAGrC,QAHZ;AAIC,IAAA,IAAI,EAAGG,IAJR;AAKC,IAAA,iBAAiB,EAAGL,iBALrB;AAMC,IAAA,UAAU,EAAGH,UANd;AAOC,IAAA,KAAK,EAAGO,KAPT;AAQC,IAAA,OAAO,EAAGH,OARX;AASC,IAAA,OAAO,EAAGgB,OATX;AAUC,IAAA,qBAAqB,EAAGgC,qBAVzB;AAWC,IAAA,WAAW,EAAGvD,WAXf;AAYC,IAAA,IAAI,EAAGoC,IAZR;AAaC,IAAA,GAAG,EAAGlC,GAbP;AAcC,IAAA,kBAAkB,EAAG,CAAEW;AAdxB,IADD,CAVD,CA1BF,EAwDC,4BAAC,0BAAD,CACC;AADD;AAEC,IAAA,SAAS,MAFV;AAGC,IAAA,KAAK,EAAGX,GAHT;AAIC,IAAA,KAAK,EAAGuD,SAJT;AAKC,IAAA,SAAS,EAAGtC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CAtQD;;eAwQevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] = useState(\n\t\tisEditingURL\n\t);\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst {\n\t\tpreview,\n\t\tfetching,\n\t\tthemeSupportsResponsive,\n\t\tcannotEmbed,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEmbedPreview,\n\t\t\t\thasFinishedResolution,\n\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\tgetThemeSupports,\n\t\t\t} = select( coreStore );\n\t\t\tif ( ! url ) {\n\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t}\n\n\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t'getEmbedPreview',\n\t\t\t\t[ url ]\n\t\t\t);\n\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\tconst badEmbedProvider =\n\t\t\t\tembedPreview?.html === false &&\n\t\t\t\tembedPreview?.type === undefined;\n\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t// than generating a fallback response as other embeds do.\n\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\tconst validPreview =\n\t\t\t\t!! embedPreview && ! badEmbedProvider && ! wordpressCantEmbed;\n\n\t\t\treturn {\n\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\tthemeSupportsResponsive: getThemeSupports()[\n\t\t\t\t\t'responsive-embeds'\n\t\t\t\t],\n\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t};\n\t\t},\n\t\t[ url ]\n\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect( () => setShowEmbedBottomSheet( isEditingURL ), [\n\t\tisEditingURL,\n\t] );\n\n\tconst onEditURL = useCallback( ( value ) => {\n\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t// for creating the new block.\n\t\tsetAttributes( { url: value } );\n\t\tsetIsEditingURL( false );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
@@ -9,7 +9,7 @@ exports.createUpgradedEmbedBlock = void 0;
9
9
  exports.fallback = fallback;
10
10
  exports.getAttributesFromPreview = exports.findMoreSuitableBlock = void 0;
11
11
  exports.getClassNames = getClassNames;
12
- exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.getPhotoHtml = exports.getEmbedInfoByProvider = void 0;
12
+ exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.getPhotoHtml = exports.getMergedAttributesWithPreview = exports.getEmbedInfoByProvider = void 0;
13
13
 
14
14
  var _element = require("@wordpress/element");
15
15
 
@@ -146,9 +146,10 @@ const isFromWordPress = html => html && html.includes('class="wp-embedded-conten
146
146
  exports.isFromWordPress = isFromWordPress;
147
147
 
148
148
  const getPhotoHtml = photo => {
149
- // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
150
- // actually the full size photo. If thumbnails not found, use full image.
151
- const imageUrl = photo.thumbnail_url || photo.url;
149
+ // If full image url not found use thumbnail.
150
+ const imageUrl = photo.url || photo.thumbnail_url; // 100% width for the preview so it fits nicely into the document, some "thumbnails" are
151
+ // actually the full size photo.
152
+
152
153
  const photoPreview = (0, _element.createElement)("p", null, (0, _element.createElement)("img", {
153
154
  src: imageUrl,
154
155
  alt: photo.title,
@@ -369,5 +370,29 @@ const getAttributesFromPreview = (0, _memize.default)(function (preview, title,
369
370
  attributes.className = getClassNames(html, currentClassNames, isResponsive && allowResponsive);
370
371
  return attributes;
371
372
  });
373
+ /**
374
+ * Returns the attributes derived from the preview, merged with the current attributes.
375
+ *
376
+ * @param {Object} currentAttributes The current attributes of the block.
377
+ * @param {Object} preview The preview data.
378
+ * @param {string} title The block's title, e.g. Twitter.
379
+ * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
380
+ * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
381
+ * @return {Object} Merged attributes.
382
+ */
383
+
372
384
  exports.getAttributesFromPreview = getAttributesFromPreview;
385
+
386
+ const getMergedAttributesWithPreview = function (currentAttributes, preview, title, isResponsive) {
387
+ let ignorePreviousClassName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
388
+ const {
389
+ allowResponsive,
390
+ className
391
+ } = currentAttributes;
392
+ return { ...currentAttributes,
393
+ ...getAttributesFromPreview(preview, title, ignorePreviousClassName ? undefined : className, isResponsive, allowResponsive)
394
+ };
395
+ };
396
+
397
+ exports.getMergedAttributesWithPreview = getMergedAttributesWithPreview;
373
398
  //# sourceMappingURL=util.js.map