@wordpress/block-editor 12.12.2-next.f8d8eceb.0 → 12.14.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 (349) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/build/components/block-heading-level-dropdown/index.js +1 -1
  3. package/build/components/block-heading-level-dropdown/index.js.map +1 -1
  4. package/build/components/block-list/index.js +2 -9
  5. package/build/components/block-list/index.js.map +1 -1
  6. package/build/components/block-list-appender/index.js +16 -3
  7. package/build/components/block-list-appender/index.js.map +1 -1
  8. package/build/components/block-quick-navigation/index.js +6 -4
  9. package/build/components/block-quick-navigation/index.js.map +1 -1
  10. package/build/components/block-styles/index.js +0 -8
  11. package/build/components/block-styles/index.js.map +1 -1
  12. package/build/components/block-switcher/pattern-transformations-menu.js +18 -14
  13. package/build/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  14. package/build/components/block-tools/back-compat.js +2 -2
  15. package/build/components/block-tools/back-compat.js.map +1 -1
  16. package/build/components/block-tools/block-contextual-toolbar.js +11 -81
  17. package/build/components/block-tools/block-contextual-toolbar.js.map +1 -1
  18. package/build/components/block-tools/empty-block-inserter.js +56 -0
  19. package/build/components/block-tools/empty-block-inserter.js.map +1 -0
  20. package/build/components/block-tools/index.js +48 -9
  21. package/build/components/block-tools/index.js.map +1 -1
  22. package/build/components/block-tools/selected-block-tools.js +113 -0
  23. package/build/components/block-tools/selected-block-tools.js.map +1 -0
  24. package/build/components/block-tools/use-selected-block-tool-props.js +56 -0
  25. package/build/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  26. package/build/components/editable-text/index.js +1 -2
  27. package/build/components/editable-text/index.js.map +1 -1
  28. package/build/components/iframe/index.js +4 -3
  29. package/build/components/iframe/index.js.map +1 -1
  30. package/build/components/inserter/block-patterns-explorer/{explorer.js → index.js} +7 -7
  31. package/build/components/inserter/block-patterns-explorer/index.js.map +1 -0
  32. package/build/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  33. package/build/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  34. package/build/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -4
  35. package/build/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  36. package/build/components/inserter/block-patterns-tab/index.js +75 -0
  37. package/build/components/inserter/block-patterns-tab/index.js.map +1 -0
  38. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  39. package/build/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  40. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js +108 -0
  41. package/build/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  42. package/build/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +18 -34
  43. package/build/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  44. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js +55 -0
  45. package/build/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  46. package/build/components/inserter/block-patterns-tab/utils.js +70 -0
  47. package/build/components/inserter/block-patterns-tab/utils.js.map +1 -0
  48. package/build/components/inserter/media-tab/media-list.js +9 -5
  49. package/build/components/inserter/media-tab/media-list.js.map +1 -1
  50. package/build/components/inserter/media-tab/media-preview.js +15 -12
  51. package/build/components/inserter/media-tab/media-preview.js.map +1 -1
  52. package/build/components/inserter/menu.js +3 -4
  53. package/build/components/inserter/menu.js.map +1 -1
  54. package/build/components/link-control/index.js +6 -5
  55. package/build/components/link-control/index.js.map +1 -1
  56. package/build/components/list-view/block-select-button.js +39 -0
  57. package/build/components/list-view/block-select-button.js.map +1 -1
  58. package/build/components/list-view/block.js +16 -3
  59. package/build/components/list-view/block.js.map +1 -1
  60. package/build/components/list-view/index.js +3 -2
  61. package/build/components/list-view/index.js.map +1 -1
  62. package/build/components/navigable-toolbar/index.js +69 -18
  63. package/build/components/navigable-toolbar/index.js.map +1 -1
  64. package/build/components/provider/use-block-sync.js +1 -14
  65. package/build/components/provider/use-block-sync.js.map +1 -1
  66. package/build/components/resizable-box-popover/index.js +1 -1
  67. package/build/components/resizable-box-popover/index.js.map +1 -1
  68. package/build/components/rich-text/index.js +0 -1
  69. package/build/components/rich-text/index.js.map +1 -1
  70. package/build/components/rich-text/index.native.js +3 -1
  71. package/build/components/rich-text/index.native.js.map +1 -1
  72. package/build/components/rich-text/native/format-edit.js +45 -0
  73. package/build/components/rich-text/native/format-edit.js.map +1 -0
  74. package/build/components/rich-text/native/get-format-colors.native.js +41 -0
  75. package/build/components/rich-text/native/get-format-colors.native.js.map +1 -0
  76. package/build/components/rich-text/native/index.js +9 -0
  77. package/build/components/rich-text/native/index.js.map +1 -0
  78. package/build/components/rich-text/native/index.native.js +1158 -0
  79. package/build/components/rich-text/native/index.native.js.map +1 -0
  80. package/build/components/rich-text/native/toolbar-button-with-options.native.js +58 -0
  81. package/build/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  82. package/build/components/rich-text/native/use-format-types.js +111 -0
  83. package/build/components/rich-text/native/use-format-types.js.map +1 -0
  84. package/build/components/rich-text/use-paste-handler.js +2 -5
  85. package/build/components/rich-text/use-paste-handler.js.map +1 -1
  86. package/build/components/url-popover/image-url-input-ui.js +2 -1
  87. package/build/components/url-popover/image-url-input-ui.js.map +1 -1
  88. package/build/components/writing-flow/use-tab-nav.js +7 -3
  89. package/build/components/writing-flow/use-tab-nav.js.map +1 -1
  90. package/build/hooks/align.js +10 -10
  91. package/build/hooks/align.js.map +1 -1
  92. package/build/hooks/align.native.js +2 -2
  93. package/build/hooks/align.native.js.map +1 -1
  94. package/build/hooks/anchor.js +7 -6
  95. package/build/hooks/anchor.js.map +1 -1
  96. package/build/hooks/background.js +16 -4
  97. package/build/hooks/background.js.map +1 -1
  98. package/build/hooks/block-hooks.js +7 -8
  99. package/build/hooks/block-hooks.js.map +1 -1
  100. package/build/hooks/block-rename-ui.js +7 -5
  101. package/build/hooks/block-rename-ui.js.map +1 -1
  102. package/build/hooks/content-lock-ui.js +5 -5
  103. package/build/hooks/content-lock-ui.js.map +1 -1
  104. package/build/hooks/custom-class-name.js +8 -7
  105. package/build/hooks/custom-class-name.js.map +1 -1
  106. package/build/hooks/custom-fields.js +4 -4
  107. package/build/hooks/custom-fields.js.map +1 -1
  108. package/build/hooks/duotone.js +14 -22
  109. package/build/hooks/duotone.js.map +1 -1
  110. package/build/hooks/layout.js +90 -86
  111. package/build/hooks/layout.js.map +1 -1
  112. package/build/hooks/position.js +10 -9
  113. package/build/hooks/position.js.map +1 -1
  114. package/build/hooks/style.js +10 -13
  115. package/build/hooks/style.js.map +1 -1
  116. package/build/hooks/utils.js +30 -0
  117. package/build/hooks/utils.js.map +1 -1
  118. package/build/private-apis.js +3 -0
  119. package/build/private-apis.js.map +1 -1
  120. package/build/store/actions.js +30 -37
  121. package/build/store/actions.js.map +1 -1
  122. package/build/store/reducer.js +18 -0
  123. package/build/store/reducer.js.map +1 -1
  124. package/build/store/selectors.js +16 -13
  125. package/build/store/selectors.js.map +1 -1
  126. package/build-module/components/block-heading-level-dropdown/index.js +1 -1
  127. package/build-module/components/block-heading-level-dropdown/index.js.map +1 -1
  128. package/build-module/components/block-list/index.js +3 -10
  129. package/build-module/components/block-list/index.js.map +1 -1
  130. package/build-module/components/block-list-appender/index.js +16 -3
  131. package/build-module/components/block-list-appender/index.js.map +1 -1
  132. package/build-module/components/block-quick-navigation/index.js +7 -5
  133. package/build-module/components/block-quick-navigation/index.js.map +1 -1
  134. package/build-module/components/block-styles/index.js +0 -8
  135. package/build-module/components/block-styles/index.js.map +1 -1
  136. package/build-module/components/block-switcher/pattern-transformations-menu.js +17 -13
  137. package/build-module/components/block-switcher/pattern-transformations-menu.js.map +1 -1
  138. package/build-module/components/block-tools/back-compat.js +1 -1
  139. package/build-module/components/block-tools/back-compat.js.map +1 -1
  140. package/build-module/components/block-tools/block-contextual-toolbar.js +11 -80
  141. package/build-module/components/block-tools/block-contextual-toolbar.js.map +1 -1
  142. package/build-module/components/block-tools/empty-block-inserter.js +48 -0
  143. package/build-module/components/block-tools/empty-block-inserter.js.map +1 -0
  144. package/build-module/components/block-tools/index.js +48 -9
  145. package/build-module/components/block-tools/index.js.map +1 -1
  146. package/build-module/components/block-tools/selected-block-tools.js +105 -0
  147. package/build-module/components/block-tools/selected-block-tools.js.map +1 -0
  148. package/build-module/components/block-tools/use-selected-block-tool-props.js +50 -0
  149. package/build-module/components/block-tools/use-selected-block-tool-props.js.map +1 -0
  150. package/build-module/components/editable-text/index.js +1 -2
  151. package/build-module/components/editable-text/index.js.map +1 -1
  152. package/build-module/components/iframe/index.js +4 -3
  153. package/build-module/components/iframe/index.js.map +1 -1
  154. package/build-module/components/inserter/block-patterns-explorer/{explorer.js → index.js} +5 -5
  155. package/build-module/components/inserter/block-patterns-explorer/index.js.map +1 -0
  156. package/build-module/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +1 -1
  157. package/build-module/components/inserter/block-patterns-explorer/pattern-explorer-sidebar.js.map +1 -0
  158. package/build-module/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +2 -2
  159. package/build-module/components/inserter/block-patterns-explorer/pattern-list.js.map +1 -0
  160. package/build-module/components/inserter/block-patterns-tab/index.js +66 -0
  161. package/build-module/components/inserter/block-patterns-tab/index.js.map +1 -0
  162. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +42 -0
  163. package/build-module/components/inserter/block-patterns-tab/pattern-category-preview-panel.js.map +1 -0
  164. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js +100 -0
  165. package/build-module/components/inserter/block-patterns-tab/pattern-category-previews.js.map +1 -0
  166. package/build-module/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +7 -20
  167. package/build-module/components/inserter/block-patterns-tab/patterns-filter.js.map +1 -0
  168. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js +47 -0
  169. package/build-module/components/inserter/block-patterns-tab/use-pattern-categories.js.map +1 -0
  170. package/build-module/components/inserter/block-patterns-tab/utils.js +58 -0
  171. package/build-module/components/inserter/block-patterns-tab/utils.js.map +1 -0
  172. package/build-module/components/inserter/media-tab/media-list.js +9 -5
  173. package/build-module/components/inserter/media-tab/media-list.js.map +1 -1
  174. package/build-module/components/inserter/media-tab/media-preview.js +15 -12
  175. package/build-module/components/inserter/media-tab/media-preview.js.map +1 -1
  176. package/build-module/components/inserter/menu.js +4 -3
  177. package/build-module/components/inserter/menu.js.map +1 -1
  178. package/build-module/components/link-control/index.js +7 -6
  179. package/build-module/components/link-control/index.js.map +1 -1
  180. package/build-module/components/list-view/block-select-button.js +39 -0
  181. package/build-module/components/list-view/block-select-button.js.map +1 -1
  182. package/build-module/components/list-view/block.js +16 -3
  183. package/build-module/components/list-view/block.js.map +1 -1
  184. package/build-module/components/list-view/index.js +3 -2
  185. package/build-module/components/list-view/index.js.map +1 -1
  186. package/build-module/components/navigable-toolbar/index.js +69 -17
  187. package/build-module/components/navigable-toolbar/index.js.map +1 -1
  188. package/build-module/components/provider/use-block-sync.js +1 -14
  189. package/build-module/components/provider/use-block-sync.js.map +1 -1
  190. package/build-module/components/resizable-box-popover/index.js +1 -1
  191. package/build-module/components/resizable-box-popover/index.js.map +1 -1
  192. package/build-module/components/rich-text/index.js +0 -1
  193. package/build-module/components/rich-text/index.js.map +1 -1
  194. package/build-module/components/rich-text/index.native.js +3 -1
  195. package/build-module/components/rich-text/index.native.js.map +1 -1
  196. package/build-module/components/rich-text/native/format-edit.js +38 -0
  197. package/build-module/components/rich-text/native/format-edit.js.map +1 -0
  198. package/build-module/components/rich-text/native/get-format-colors.native.js +34 -0
  199. package/build-module/components/rich-text/native/get-format-colors.native.js.map +1 -0
  200. package/build-module/components/rich-text/native/index.js +2 -0
  201. package/build-module/components/rich-text/native/index.js.map +1 -0
  202. package/build-module/components/rich-text/native/index.native.js +1148 -0
  203. package/build-module/components/rich-text/native/index.native.js.map +1 -0
  204. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js +51 -0
  205. package/build-module/components/rich-text/native/toolbar-button-with-options.native.js.map +1 -0
  206. package/build-module/components/rich-text/native/use-format-types.js +104 -0
  207. package/build-module/components/rich-text/native/use-format-types.js.map +1 -0
  208. package/build-module/components/rich-text/use-paste-handler.js +2 -5
  209. package/build-module/components/rich-text/use-paste-handler.js.map +1 -1
  210. package/build-module/components/url-popover/image-url-input-ui.js +2 -1
  211. package/build-module/components/url-popover/image-url-input-ui.js.map +1 -1
  212. package/build-module/components/writing-flow/use-tab-nav.js +7 -3
  213. package/build-module/components/writing-flow/use-tab-nav.js.map +1 -1
  214. package/build-module/hooks/align.js +8 -8
  215. package/build-module/hooks/align.js.map +1 -1
  216. package/build-module/hooks/align.native.js +2 -2
  217. package/build-module/hooks/align.native.js.map +1 -1
  218. package/build-module/hooks/anchor.js +5 -4
  219. package/build-module/hooks/anchor.js.map +1 -1
  220. package/build-module/hooks/background.js +17 -5
  221. package/build-module/hooks/background.js.map +1 -1
  222. package/build-module/hooks/block-hooks.js +5 -6
  223. package/build-module/hooks/block-hooks.js.map +1 -1
  224. package/build-module/hooks/block-rename-ui.js +5 -3
  225. package/build-module/hooks/block-rename-ui.js.map +1 -1
  226. package/build-module/hooks/content-lock-ui.js +3 -3
  227. package/build-module/hooks/content-lock-ui.js.map +1 -1
  228. package/build-module/hooks/custom-class-name.js +6 -5
  229. package/build-module/hooks/custom-class-name.js.map +1 -1
  230. package/build-module/hooks/custom-fields.js +4 -4
  231. package/build-module/hooks/custom-fields.js.map +1 -1
  232. package/build-module/hooks/duotone.js +15 -23
  233. package/build-module/hooks/duotone.js.map +1 -1
  234. package/build-module/hooks/layout.js +90 -86
  235. package/build-module/hooks/layout.js.map +1 -1
  236. package/build-module/hooks/position.js +11 -10
  237. package/build-module/hooks/position.js.map +1 -1
  238. package/build-module/hooks/style.js +10 -13
  239. package/build-module/hooks/style.js.map +1 -1
  240. package/build-module/hooks/utils.js +30 -1
  241. package/build-module/hooks/utils.js.map +1 -1
  242. package/build-module/private-apis.js +4 -1
  243. package/build-module/private-apis.js.map +1 -1
  244. package/build-module/store/actions.js +29 -37
  245. package/build-module/store/actions.js.map +1 -1
  246. package/build-module/store/reducer.js +17 -0
  247. package/build-module/store/reducer.js.map +1 -1
  248. package/build-module/store/selectors.js +15 -13
  249. package/build-module/store/selectors.js.map +1 -1
  250. package/build-style/style-rtl.css +16 -15
  251. package/build-style/style.css +16 -15
  252. package/package.json +31 -31
  253. package/src/components/block-heading-level-dropdown/index.js +1 -1
  254. package/src/components/block-list/index.js +4 -18
  255. package/src/components/block-list-appender/index.js +20 -4
  256. package/src/components/block-quick-navigation/index.js +11 -5
  257. package/src/components/block-styles/index.js +0 -10
  258. package/src/components/block-switcher/pattern-transformations-menu.js +20 -14
  259. package/src/components/block-toolbar/style.scss +8 -0
  260. package/src/components/block-tools/back-compat.js +1 -1
  261. package/src/components/block-tools/block-contextual-toolbar.js +11 -134
  262. package/src/components/block-tools/empty-block-inserter.js +56 -0
  263. package/src/components/block-tools/index.js +72 -16
  264. package/src/components/block-tools/selected-block-tools.js +127 -0
  265. package/src/components/block-tools/style.scss +0 -10
  266. package/src/components/block-tools/use-selected-block-tool-props.js +66 -0
  267. package/src/components/editable-text/index.js +1 -8
  268. package/src/components/iframe/index.js +4 -3
  269. package/src/components/inserter/block-patterns-explorer/{explorer.js → index.js} +4 -4
  270. package/src/components/inserter/block-patterns-explorer/{patterns-list.js → pattern-list.js} +4 -1
  271. package/src/components/inserter/block-patterns-tab/index.js +118 -0
  272. package/src/components/inserter/block-patterns-tab/pattern-category-preview-panel.js +48 -0
  273. package/src/components/inserter/block-patterns-tab/pattern-category-previews.js +175 -0
  274. package/src/components/inserter/{block-patterns-filter.js → block-patterns-tab/patterns-filter.js} +15 -21
  275. package/src/components/inserter/block-patterns-tab/use-pattern-categories.js +96 -0
  276. package/src/components/inserter/block-patterns-tab/utils.js +76 -0
  277. package/src/components/inserter/media-tab/media-list.js +7 -7
  278. package/src/components/inserter/media-tab/media-preview.js +27 -22
  279. package/src/components/inserter/menu.js +4 -5
  280. package/src/components/link-control/README.md +2 -2
  281. package/src/components/link-control/index.js +15 -6
  282. package/src/components/link-control/style.scss +8 -5
  283. package/src/components/list-view/block-select-button.js +44 -1
  284. package/src/components/list-view/block.js +11 -11
  285. package/src/components/list-view/index.js +2 -0
  286. package/src/components/media-replace-flow/style.scss +2 -2
  287. package/src/components/navigable-toolbar/index.js +71 -25
  288. package/src/components/plain-text/README.md +3 -3
  289. package/src/components/provider/use-block-sync.js +2 -21
  290. package/src/components/resizable-box-popover/index.js +1 -1
  291. package/src/components/rich-text/README.md +9 -8
  292. package/src/components/rich-text/index.js +0 -1
  293. package/src/components/rich-text/index.native.js +3 -1
  294. package/src/components/rich-text/native/format-edit.js +44 -0
  295. package/src/components/rich-text/native/get-format-colors.native.js +54 -0
  296. package/src/components/rich-text/native/index.js +1 -0
  297. package/src/components/rich-text/native/index.native.js +1363 -0
  298. package/src/components/rich-text/native/style.native.scss +28 -0
  299. package/src/components/rich-text/native/test/__snapshots__/index.native.js.snap +79 -0
  300. package/src/components/rich-text/native/test/index.native.js +278 -0
  301. package/src/components/rich-text/native/test/performance/rich-text.native.js +44 -0
  302. package/src/components/rich-text/native/toolbar-button-with-options.native.js +61 -0
  303. package/src/components/rich-text/native/use-format-types.js +146 -0
  304. package/src/components/rich-text/use-paste-handler.js +1 -6
  305. package/src/components/url-popover/image-url-input-ui.js +1 -0
  306. package/src/components/writing-flow/use-tab-nav.js +8 -3
  307. package/src/hooks/align.js +8 -8
  308. package/src/hooks/align.native.js +2 -2
  309. package/src/hooks/anchor.js +21 -23
  310. package/src/hooks/background.js +28 -6
  311. package/src/hooks/block-hooks.js +20 -16
  312. package/src/hooks/block-rename-ui.js +6 -4
  313. package/src/hooks/content-lock-ui.js +3 -3
  314. package/src/hooks/custom-class-name.js +7 -6
  315. package/src/hooks/custom-fields.js +5 -5
  316. package/src/hooks/duotone.js +29 -38
  317. package/src/hooks/layout.js +114 -105
  318. package/src/hooks/position.js +8 -21
  319. package/src/hooks/style.js +17 -31
  320. package/src/hooks/test/align.js +4 -4
  321. package/src/hooks/utils.js +33 -1
  322. package/src/private-apis.js +4 -1
  323. package/src/store/actions.js +26 -72
  324. package/src/store/reducer.js +19 -0
  325. package/src/store/selectors.js +13 -19
  326. package/build/components/block-tools/selected-block-popover.js +0 -221
  327. package/build/components/block-tools/selected-block-popover.js.map +0 -1
  328. package/build/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  329. package/build/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  330. package/build/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  331. package/build/components/inserter/block-patterns-filter.js.map +0 -1
  332. package/build/components/inserter/block-patterns-tab.js +0 -270
  333. package/build/components/inserter/block-patterns-tab.js.map +0 -1
  334. package/build/store/utils.js +0 -22
  335. package/build/store/utils.js.map +0 -1
  336. package/build-module/components/block-tools/selected-block-popover.js +0 -213
  337. package/build-module/components/block-tools/selected-block-popover.js.map +0 -1
  338. package/build-module/components/inserter/block-patterns-explorer/explorer.js.map +0 -1
  339. package/build-module/components/inserter/block-patterns-explorer/patterns-list.js.map +0 -1
  340. package/build-module/components/inserter/block-patterns-explorer/sidebar.js.map +0 -1
  341. package/build-module/components/inserter/block-patterns-filter.js.map +0 -1
  342. package/build-module/components/inserter/block-patterns-tab.js +0 -254
  343. package/build-module/components/inserter/block-patterns-tab.js.map +0 -1
  344. package/build-module/store/utils.js +0 -16
  345. package/build-module/store/utils.js.map +0 -1
  346. package/src/components/block-tools/selected-block-popover.js +0 -265
  347. package/src/components/inserter/block-patterns-tab.js +0 -448
  348. package/src/store/utils.js +0 -12
  349. /package/src/components/inserter/block-patterns-explorer/{sidebar.js → pattern-explorer-sidebar.js} +0 -0
@@ -0,0 +1,1158 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = exports.RichText = void 0;
8
+ var _react = require("react");
9
+ var _reactNative = require("react-native");
10
+ var _memize = _interopRequireDefault(require("memize"));
11
+ var _colord = require("colord");
12
+ var _reactNativeAztec = _interopRequireDefault(require("@wordpress/react-native-aztec"));
13
+ var _reactNativeBridge = require("@wordpress/react-native-bridge");
14
+ var _blockEditor = require("@wordpress/block-editor");
15
+ var _element = require("@wordpress/element");
16
+ var _compose = require("@wordpress/compose");
17
+ var _data = require("@wordpress/data");
18
+ var _blocks = require("@wordpress/blocks");
19
+ var _htmlEntities = require("@wordpress/html-entities");
20
+ var _keycodes = require("@wordpress/keycodes");
21
+ var _url = require("@wordpress/url");
22
+ var _icons = require("@wordpress/icons");
23
+ var _i18n = require("@wordpress/i18n");
24
+ var _richText = require("@wordpress/rich-text");
25
+ var _useFormatTypes = require("./use-format-types");
26
+ var _formatEdit = _interopRequireDefault(require("./format-edit"));
27
+ var _getFormatColors = require("./get-format-colors");
28
+ var _style = _interopRequireDefault(require("./style.scss"));
29
+ var _toolbarButtonWithOptions = _interopRequireDefault(require("./toolbar-button-with-options"));
30
+ /* eslint no-console: ["error", { allow: ["warn"] }] */
31
+
32
+ /**
33
+ * External dependencies
34
+ */
35
+
36
+ /**
37
+ * WordPress dependencies
38
+ */
39
+
40
+ /**
41
+ * Internal dependencies
42
+ */
43
+
44
+ const unescapeSpaces = text => {
45
+ return text.replace(/ | /gi, ' ');
46
+ };
47
+
48
+ // The flattened color palettes array is memoized to ensure that the same array instance is
49
+ // returned for the colors palettes. This value might be used as a prop, so having the same
50
+ // instance will prevent unnecessary re-renders of the RichText component.
51
+ const flatColorPalettes = (0, _memize.default)(colorsPalettes => [...(colorsPalettes?.theme || []), ...(colorsPalettes?.custom || []), ...(colorsPalettes?.default || [])]);
52
+ const getSelectionColor = (0, _memize.default)((currentSelectionColor, defaultSelectionColor, baseGlobalStyles, isBlockBasedTheme) => {
53
+ let selectionColor = defaultSelectionColor;
54
+ if (currentSelectionColor) {
55
+ selectionColor = currentSelectionColor;
56
+ }
57
+ if (isBlockBasedTheme) {
58
+ const colordTextColor = (0, _colord.colord)(selectionColor);
59
+ const colordBackgroundColor = (0, _colord.colord)(baseGlobalStyles?.color?.background);
60
+ const isColordTextReadable = colordTextColor.isReadable(colordBackgroundColor);
61
+ if (!isColordTextReadable) {
62
+ selectionColor = baseGlobalStyles?.color?.text;
63
+ }
64
+ }
65
+ return selectionColor;
66
+ });
67
+ const gutenbergFormatNamesToAztec = {
68
+ 'core/bold': 'bold',
69
+ 'core/italic': 'italic',
70
+ 'core/strikethrough': 'strikethrough',
71
+ 'core/text-color': 'mark'
72
+ };
73
+ const EMPTY_PARAGRAPH_TAGS = '<p></p>';
74
+ const DEFAULT_FONT_SIZE = 16;
75
+ const MIN_LINE_HEIGHT = 1;
76
+ class RichText extends _element.Component {
77
+ constructor({
78
+ value,
79
+ selectionStart,
80
+ selectionEnd,
81
+ __unstableMultilineTag: multiline
82
+ }) {
83
+ super(...arguments);
84
+ this.isMultiline = false;
85
+ if (multiline === true || multiline === 'p' || multiline === 'li') {
86
+ this.multilineTag = multiline === true ? 'p' : multiline;
87
+ this.isMultiline = true;
88
+ }
89
+ if (this.multilineTag === 'li') {
90
+ this.multilineWrapperTags = ['ul', 'ol'];
91
+ }
92
+ this.isIOS = _reactNative.Platform.OS === 'ios';
93
+ this.createRecord = this.createRecord.bind(this);
94
+ this.restoreParagraphTags = this.restoreParagraphTags.bind(this);
95
+ this.onChangeFromAztec = this.onChangeFromAztec.bind(this);
96
+ this.onKeyDown = this.onKeyDown.bind(this);
97
+ this.handleEnter = this.handleEnter.bind(this);
98
+ this.handleDelete = this.handleDelete.bind(this);
99
+ this.onPaste = this.onPaste.bind(this);
100
+ this.onFocus = this.onFocus.bind(this);
101
+ this.onBlur = this.onBlur.bind(this);
102
+ this.onTextUpdate = this.onTextUpdate.bind(this);
103
+ this.onContentSizeChange = this.onContentSizeChange.bind(this);
104
+ this.onFormatChange = this.onFormatChange.bind(this);
105
+ this.formatToValue = (0, _memize.default)(this.formatToValue.bind(this), {
106
+ maxSize: 1
107
+ });
108
+ this.debounceCreateUndoLevel = (0, _compose.debounce)(this.onCreateUndoLevel, 1000);
109
+ // This prevents a bug in Aztec which triggers onSelectionChange twice on format change.
110
+ this.onSelectionChange = this.onSelectionChange.bind(this);
111
+ this.onSelectionChangeFromAztec = this.onSelectionChangeFromAztec.bind(this);
112
+ this.valueToFormat = this.valueToFormat.bind(this);
113
+ this.getHtmlToRender = this.getHtmlToRender.bind(this);
114
+ this.handleSuggestionFunc = this.handleSuggestionFunc.bind(this);
115
+ this.handleUserSuggestion = this.handleSuggestionFunc(_reactNativeBridge.showUserSuggestions, '@').bind(this);
116
+ this.handleXpostSuggestion = this.handleSuggestionFunc(_reactNativeBridge.showXpostSuggestions, '+').bind(this);
117
+ this.suggestionOptions = this.suggestionOptions.bind(this);
118
+ this.insertString = this.insertString.bind(this);
119
+ this.manipulateEventCounterToForceNativeToRefresh = this.manipulateEventCounterToForceNativeToRefresh.bind(this);
120
+ this.shouldDropEventFromAztec = this.shouldDropEventFromAztec.bind(this);
121
+ this.state = {
122
+ activeFormats: [],
123
+ selectedFormat: null,
124
+ height: 0,
125
+ currentFontSize: this.getFontSize(arguments[0])
126
+ };
127
+ this.needsSelectionUpdate = false;
128
+ this.savedContent = '';
129
+ this.isTouched = false;
130
+ this.lastAztecEventType = null;
131
+ this.lastHistoryValue = value;
132
+
133
+ // Internal values that are update synchronously, unlike props.
134
+ this.value = value;
135
+ this.selectionStart = selectionStart;
136
+ this.selectionEnd = selectionEnd;
137
+ }
138
+
139
+ /**
140
+ * Get the current record (value and selection) from props and state.
141
+ *
142
+ * @return {Object} The current record (value and selection).
143
+ */
144
+ getRecord() {
145
+ const {
146
+ selectionStart: start,
147
+ selectionEnd: end,
148
+ colorPalette
149
+ } = this.props;
150
+ const {
151
+ value
152
+ } = this.props;
153
+ const currentValue = this.formatToValue(value);
154
+ const {
155
+ formats,
156
+ replacements,
157
+ text
158
+ } = currentValue;
159
+ const {
160
+ activeFormats
161
+ } = this.state;
162
+ const newFormats = (0, _getFormatColors.getFormatColors)(value, formats, colorPalette);
163
+ return {
164
+ formats: newFormats,
165
+ replacements,
166
+ text,
167
+ start,
168
+ end,
169
+ activeFormats
170
+ };
171
+ }
172
+
173
+ /**
174
+ * Creates a RichText value "record" from the current content and selection
175
+ * information
176
+ *
177
+ *
178
+ * @return {Object} A RichText value with formats and selection.
179
+ */
180
+ createRecord() {
181
+ const {
182
+ preserveWhiteSpace
183
+ } = this.props;
184
+ const value = {
185
+ start: this.selectionStart,
186
+ end: this.selectionEnd,
187
+ ...(0, _richText.create)({
188
+ html: this.value,
189
+ range: null,
190
+ multilineTag: this.multilineTag,
191
+ multilineWrapperTags: this.multilineWrapperTags,
192
+ preserveWhiteSpace
193
+ })
194
+ };
195
+ const start = Math.min(this.selectionStart, value.text.length);
196
+ const end = Math.min(this.selectionEnd, value.text.length);
197
+ return {
198
+ ...value,
199
+ start,
200
+ end
201
+ };
202
+ }
203
+ valueToFormat(value) {
204
+ // Remove the outer root tags.
205
+ return this.removeRootTagsProducedByAztec((0, _richText.toHTMLString)({
206
+ value,
207
+ multilineTag: this.multilineTag
208
+ }));
209
+ }
210
+ getActiveFormatNames(record) {
211
+ const {
212
+ formatTypes
213
+ } = this.props;
214
+ return formatTypes.map(({
215
+ name
216
+ }) => name).filter(name => {
217
+ return (0, _richText.getActiveFormat)(record, name) !== undefined;
218
+ }).map(name => gutenbergFormatNamesToAztec[name]).filter(Boolean);
219
+ }
220
+ onFormatChange(record) {
221
+ const {
222
+ start = 0,
223
+ end = 0,
224
+ activeFormats = []
225
+ } = record;
226
+ const changeHandlers = Object.fromEntries(Object.entries(this.props).filter(([key]) => key.startsWith('format_on_change_functions_')));
227
+ Object.values(changeHandlers).forEach(changeHandler => {
228
+ changeHandler(record.formats, record.text);
229
+ });
230
+ this.value = this.valueToFormat(record);
231
+ this.props.onChange(this.value);
232
+ this.setState({
233
+ activeFormats
234
+ });
235
+ this.props.onSelectionChange(start, end);
236
+ this.selectionStart = start;
237
+ this.selectionEnd = end;
238
+ this.onCreateUndoLevel();
239
+ this.lastAztecEventType = 'format change';
240
+ }
241
+ insertString(record, string) {
242
+ if (record && string) {
243
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
244
+ const toInsert = (0, _richText.insert)(record, string);
245
+ this.onFormatChange(toInsert);
246
+ }
247
+ }
248
+ onCreateUndoLevel() {
249
+ const {
250
+ __unstableOnCreateUndoLevel: onCreateUndoLevel
251
+ } = this.props;
252
+ // If the content is the same, no level needs to be created.
253
+ if (this.lastHistoryValue === this.value) {
254
+ return;
255
+ }
256
+ onCreateUndoLevel();
257
+ this.lastHistoryValue = this.value;
258
+ }
259
+
260
+ /*
261
+ * Cleans up any root tags produced by aztec.
262
+ * TODO: This should be removed on a later version when aztec doesn't return the top tag of the text being edited
263
+ */
264
+ removeRootTagsProducedByAztec(html) {
265
+ let result = this.removeRootTag(this.props.tagName, html);
266
+ if (this.props.tagsToEliminate) {
267
+ this.props.tagsToEliminate.forEach(element => {
268
+ result = this.removeTag(element, result);
269
+ });
270
+ }
271
+ return result;
272
+ }
273
+ removeRootTag(tag, html) {
274
+ const openingTagRegexp = RegExp('^<' + tag + '[^>]*>', 'gim');
275
+ const closingTagRegexp = RegExp('</' + tag + '>$', 'gim');
276
+ return html.replace(openingTagRegexp, '').replace(closingTagRegexp, '');
277
+ }
278
+ removeTag(tag, html) {
279
+ const openingTagRegexp = RegExp('<' + tag + '>', 'gim');
280
+ const closingTagRegexp = RegExp('</' + tag + '>', 'gim');
281
+ return html.replace(openingTagRegexp, '').replace(closingTagRegexp, '');
282
+ }
283
+
284
+ /*
285
+ * Handles any case where the content of the AztecRN instance has changed
286
+ */
287
+ onChangeFromAztec(event) {
288
+ if (this.shouldDropEventFromAztec(event, 'onChange')) {
289
+ return;
290
+ }
291
+ const contentWithoutRootTag = this.removeRootTagsProducedByAztec(unescapeSpaces(event.nativeEvent.text));
292
+ // On iOS, onChange can be triggered after selection changes, even though there are no content changes.
293
+ if (contentWithoutRootTag === this.value) {
294
+ return;
295
+ }
296
+ this.lastEventCount = event.nativeEvent.eventCount;
297
+ this.comesFromAztec = true;
298
+ this.firedAfterTextChanged = true; // The onChange event always fires after the fact.
299
+ this.onTextUpdate(event);
300
+ this.lastAztecEventType = 'input';
301
+ }
302
+ onTextUpdate(event) {
303
+ const contentWithoutRootTag = this.removeRootTagsProducedByAztec(unescapeSpaces(event.nativeEvent.text));
304
+ let formattedContent = contentWithoutRootTag;
305
+ if (!this.isIOS) {
306
+ formattedContent = this.restoreParagraphTags(contentWithoutRootTag, this.multilineTag);
307
+ }
308
+ this.debounceCreateUndoLevel();
309
+ const refresh = this.value !== formattedContent;
310
+ this.value = formattedContent;
311
+
312
+ // We don't want to refresh if our goal is just to create a record.
313
+ if (refresh) {
314
+ this.props.onChange(formattedContent);
315
+ }
316
+ }
317
+ restoreParagraphTags(value, tag) {
318
+ if (tag === 'p' && (!value || !value.startsWith('<p>'))) {
319
+ return '<p>' + value + '</p>';
320
+ }
321
+ return value;
322
+ }
323
+
324
+ /*
325
+ * Handles any case where the content of the AztecRN instance has changed in size
326
+ */
327
+ onContentSizeChange(contentSize) {
328
+ this.setState(contentSize);
329
+ this.lastAztecEventType = 'content size change';
330
+ }
331
+ onKeyDown(event) {
332
+ if (event.defaultPrevented) {
333
+ return;
334
+ }
335
+
336
+ // Add stubs for conformance in downstream autocompleters logic.
337
+ this.customEditableOnKeyDown?.({
338
+ preventDefault: () => undefined,
339
+ ...event,
340
+ key: _reactNativeAztec.default.KeyCodes[event?.keyCode]
341
+ });
342
+ this.handleDelete(event);
343
+ this.handleEnter(event);
344
+ this.handleTriggerKeyCodes(event);
345
+ }
346
+ handleEnter(event) {
347
+ if (event.keyCode !== _keycodes.ENTER) {
348
+ return;
349
+ }
350
+ const {
351
+ onEnter
352
+ } = this.props;
353
+ if (!onEnter) {
354
+ return;
355
+ }
356
+ onEnter({
357
+ value: this.createRecord(),
358
+ onChange: this.onFormatChange,
359
+ shiftKey: event.shiftKey
360
+ });
361
+ this.lastAztecEventType = 'input';
362
+ }
363
+ handleDelete(event) {
364
+ if (this.shouldDropEventFromAztec(event, 'handleDelete')) {
365
+ return;
366
+ }
367
+ const {
368
+ keyCode
369
+ } = event;
370
+ if (keyCode !== _keycodes.DELETE && keyCode !== _keycodes.BACKSPACE) {
371
+ return;
372
+ }
373
+ const isReverse = keyCode === _keycodes.BACKSPACE;
374
+ const {
375
+ onDelete
376
+ } = this.props;
377
+ this.lastEventCount = event.nativeEvent.eventCount;
378
+ this.comesFromAztec = true;
379
+ this.firedAfterTextChanged = event.nativeEvent.firedAfterTextChanged;
380
+ const value = this.createRecord();
381
+ const {
382
+ start,
383
+ end,
384
+ text
385
+ } = value;
386
+ let newValue;
387
+
388
+ // Always handle full content deletion ourselves.
389
+ if (start === 0 && end !== 0 && end >= text.length) {
390
+ newValue = (0, _richText.remove)(value);
391
+ this.onFormatChange(newValue);
392
+ event.preventDefault();
393
+ return;
394
+ }
395
+
396
+ // Only process delete if the key press occurs at an uncollapsed edge.
397
+ if (!onDelete || !(0, _richText.isCollapsed)(value) || isReverse && start !== 0 || !isReverse && end !== text.length) {
398
+ return;
399
+ }
400
+ onDelete({
401
+ isReverse,
402
+ value
403
+ });
404
+ event.preventDefault();
405
+ this.lastAztecEventType = 'input';
406
+ }
407
+ handleTriggerKeyCodes(event) {
408
+ const {
409
+ keyCode
410
+ } = event;
411
+ const triggeredOption = this.suggestionOptions().find(option => {
412
+ const triggeredKeyCode = option.triggerChar.charCodeAt(0);
413
+ return triggeredKeyCode === keyCode;
414
+ });
415
+ if (triggeredOption) {
416
+ const record = this.getRecord();
417
+ const text = (0, _richText.getTextContent)(record);
418
+ // Only respond to the trigger if the selection is on the start of text or line
419
+ // or if the character before is a space.
420
+ const useTrigger = text.length === 0 || record.start === 0 || text.charAt(record.start - 1) === '\n' || text.charAt(record.start - 1) === ' ';
421
+ if (useTrigger && triggeredOption.onClick) {
422
+ triggeredOption.onClick();
423
+ } else {
424
+ this.insertString(record, triggeredOption.triggerChar);
425
+ }
426
+ }
427
+ }
428
+ suggestionOptions() {
429
+ const {
430
+ areMentionsSupported,
431
+ areXPostsSupported
432
+ } = this.props;
433
+ const allOptions = [{
434
+ supported: areMentionsSupported,
435
+ title: (0, _i18n.__)('Insert mention'),
436
+ onClick: this.handleUserSuggestion,
437
+ triggerChar: '@',
438
+ value: 'mention',
439
+ label: (0, _i18n.__)('Mention'),
440
+ icon: _icons.atSymbol
441
+ }, {
442
+ supported: areXPostsSupported,
443
+ title: (0, _i18n.__)('Insert crosspost'),
444
+ onClick: this.handleXpostSuggestion,
445
+ triggerChar: '+',
446
+ value: 'crosspost',
447
+ label: (0, _i18n.__)('Crosspost'),
448
+ icon: _icons.plus
449
+ }];
450
+ return allOptions.filter(op => op.supported);
451
+ }
452
+ handleSuggestionFunc(suggestionFunction, prefix) {
453
+ return () => {
454
+ const record = this.getRecord();
455
+ suggestionFunction().then(suggestion => {
456
+ this.insertString(record, `${prefix}${suggestion} `);
457
+ }).catch(() => {});
458
+ };
459
+ }
460
+
461
+ /**
462
+ * Handles a paste event from the native Aztec Wrapper.
463
+ *
464
+ * @param {Object} event The paste event which wraps `nativeEvent`.
465
+ */
466
+ onPaste(event) {
467
+ const {
468
+ onPaste,
469
+ onChange
470
+ } = this.props;
471
+ const {
472
+ activeFormats = []
473
+ } = this.state;
474
+ const {
475
+ pastedText,
476
+ pastedHtml,
477
+ files
478
+ } = event.nativeEvent;
479
+ const currentRecord = this.createRecord();
480
+ event.preventDefault();
481
+
482
+ // There is a selection, check if a URL is pasted.
483
+ if (!(0, _richText.isCollapsed)(currentRecord)) {
484
+ const trimmedText = (pastedHtml || pastedText).replace(/<[^>]+>/g, '').trim();
485
+
486
+ // A URL was pasted, turn the selection into a link.
487
+ if ((0, _url.isURL)(trimmedText)) {
488
+ const linkedRecord = (0, _richText.applyFormat)(currentRecord, {
489
+ type: 'a',
490
+ attributes: {
491
+ href: (0, _htmlEntities.decodeEntities)(trimmedText)
492
+ }
493
+ });
494
+ this.value = this.valueToFormat(linkedRecord);
495
+ onChange(this.value);
496
+
497
+ // Allows us to ask for this information when we get a report.
498
+ window.console.log('Created link:\n\n', trimmedText);
499
+ return;
500
+ }
501
+ }
502
+ if (onPaste) {
503
+ onPaste({
504
+ value: currentRecord,
505
+ onChange: this.onFormatChange,
506
+ html: pastedHtml,
507
+ plainText: pastedText,
508
+ files,
509
+ activeFormats
510
+ });
511
+ }
512
+ }
513
+ onFocus() {
514
+ this.isTouched = true;
515
+ const {
516
+ unstableOnFocus,
517
+ onSelectionChange
518
+ } = this.props;
519
+ if (unstableOnFocus) {
520
+ unstableOnFocus();
521
+ }
522
+
523
+ // We know for certain that on focus, the old selection is invalid. It
524
+ // will be recalculated on `selectionchange`.
525
+
526
+ onSelectionChange(this.selectionStart, this.selectionEnd);
527
+ this.lastAztecEventType = 'focus';
528
+ }
529
+ onBlur(event) {
530
+ this.isTouched = false;
531
+
532
+ // Check if value is up to date with latest state of native AztecView.
533
+ if (event.nativeEvent.text && event.nativeEvent.text !== this.props.value) {
534
+ this.onTextUpdate(event);
535
+ }
536
+ if (this.props.onBlur) {
537
+ this.props.onBlur(event);
538
+ }
539
+ this.lastAztecEventType = 'blur';
540
+ }
541
+ onSelectionChange(start, end) {
542
+ const hasChanged = this.selectionStart !== start || this.selectionEnd !== end;
543
+ this.selectionStart = start;
544
+ this.selectionEnd = end;
545
+
546
+ // This is a manual selection change event if onChange was not triggered just before
547
+ // and we did not just trigger a text update
548
+ // `onChange` could be the last event and could have been triggered a long time ago so
549
+ // this approach is not perfectly reliable.
550
+ const isManual = this.lastAztecEventType !== 'input' && this.props.value === this.value;
551
+ if (hasChanged && isManual) {
552
+ const value = this.createRecord();
553
+ const activeFormats = (0, _richText.getActiveFormats)(value);
554
+ this.setState({
555
+ activeFormats
556
+ });
557
+ }
558
+ this.props.onSelectionChange(start, end);
559
+ }
560
+ shouldDropEventFromAztec(event, logText) {
561
+ const shouldDrop = !this.isIOS && event.nativeEvent.eventCount <= this.lastEventCount;
562
+ if (shouldDrop) {
563
+ window.console.log(`Dropping ${logText} from Aztec as its event counter is older than latest sent to the native side. Got ${event.nativeEvent.eventCount} but lastEventCount is ${this.lastEventCount}.`);
564
+ }
565
+ return shouldDrop;
566
+ }
567
+ onSelectionChangeFromAztec(start, end, text, event) {
568
+ if (this.shouldDropEventFromAztec(event, 'onSelectionChange')) {
569
+ return;
570
+ }
571
+
572
+ // `end` can be less than `start` on iOS
573
+ // Let's fix that here so `rich-text/slice` can work properly.
574
+ const realStart = Math.min(start, end);
575
+ const realEnd = Math.max(start, end);
576
+
577
+ // Check and dicsard stray event, where the text and selection is equal to the ones already cached.
578
+ const contentWithoutRootTag = this.removeRootTagsProducedByAztec(unescapeSpaces(event.nativeEvent.text));
579
+ if (contentWithoutRootTag === this.value && realStart === this.selectionStart && realEnd === this.selectionEnd) {
580
+ return;
581
+ }
582
+ this.comesFromAztec = true;
583
+ this.firedAfterTextChanged = true; // Selection change event always fires after the fact.
584
+
585
+ // Update text before updating selection
586
+ // Make sure there are changes made to the content before upgrading it upward.
587
+ this.onTextUpdate(event);
588
+
589
+ // Aztec can send us selection change events after it has lost focus.
590
+ // For instance the autocorrect feature will complete a partially written
591
+ // word when resigning focus, causing a selection change event.
592
+ // Forwarding this selection change could cause this RichText to regain
593
+ // focus and start a focus loop.
594
+ //
595
+ // See https://github.com/wordpress-mobile/gutenberg-mobile/issues/1696
596
+ if (this.props.__unstableIsSelected) {
597
+ this.onSelectionChange(realStart, realEnd);
598
+ }
599
+ // Update lastEventCount to prevent Aztec from re-rendering the content it just sent.
600
+ this.lastEventCount = event.nativeEvent.eventCount;
601
+ this.lastAztecEventType = 'selection change';
602
+ }
603
+ isEmpty() {
604
+ return (0, _richText.isEmpty)(this.formatToValue(this.props.value));
605
+ }
606
+ formatToValue(value) {
607
+ const {
608
+ preserveWhiteSpace
609
+ } = this.props;
610
+ // Handle deprecated `children` and `node` sources.
611
+ if (Array.isArray(value)) {
612
+ return (0, _richText.create)({
613
+ html: _blocks.childrenBlock.toHTML(value),
614
+ multilineTag: this.multilineTag,
615
+ multilineWrapperTags: this.multilineWrapperTags,
616
+ preserveWhiteSpace
617
+ });
618
+ }
619
+ if (this.props.format === 'string') {
620
+ return (0, _richText.create)({
621
+ html: value,
622
+ multilineTag: this.multilineTag,
623
+ multilineWrapperTags: this.multilineWrapperTags,
624
+ preserveWhiteSpace
625
+ });
626
+ }
627
+
628
+ // Guard for blocks passing `null` in onSplit callbacks. May be removed
629
+ // if onSplit is revised to not pass a `null` value.
630
+ if (value === null) {
631
+ return (0, _richText.create)();
632
+ }
633
+ return value;
634
+ }
635
+ manipulateEventCounterToForceNativeToRefresh() {
636
+ if (this.isIOS) {
637
+ this.lastEventCount = undefined;
638
+ return;
639
+ }
640
+ if (typeof this.lastEventCount !== 'undefined') {
641
+ this.lastEventCount += 100; // bump by a hundred, hopefully native hasn't bombarded the JS side in the meantime.
642
+ } // no need to bump when 'undefined' as native side won't receive the key when the value is undefined, and that will cause force updating anyway,
643
+ // see https://github.com/WordPress/gutenberg/blob/82e578dcc75e67891c750a41a04c1e31994192fc/packages/react-native-aztec/android/src/main/java/org/wordpress/mobile/ReactNativeAztec/ReactAztecManager.java#L213-L215
644
+ }
645
+
646
+ shouldComponentUpdate(nextProps, nextState) {
647
+ if (nextProps.tagName !== this.props.tagName || nextProps.reversed !== this.props.reversed || nextProps.start !== this.props.start) {
648
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
649
+ this.value = undefined;
650
+ return true;
651
+ }
652
+
653
+ // TODO: Please re-introduce the check to avoid updating the content right after an `onChange` call.
654
+ // It was removed in https://github.com/WordPress/gutenberg/pull/12417 to fix undo/redo problem.
655
+
656
+ // If the component is changed React side (undo/redo/merging/splitting/custom text actions)
657
+ // we need to make sure the native is updated as well.
658
+
659
+ // Also, don't trust the "this.lastContent" as on Android, incomplete text events arrive
660
+ // with only some of the text, while the virtual keyboard's suggestion system does its magic.
661
+ // ** compare with this.lastContent for optimizing performance by not forcing Aztec with text it already has
662
+ // , but compare with props.value to not lose "half word" text because of Android virtual keyb autosuggestion behavior
663
+ if (typeof nextProps.value !== 'undefined' && typeof this.props.value !== 'undefined' && (!this.comesFromAztec || !this.firedAfterTextChanged) && nextProps.value !== this.props.value) {
664
+ // Gutenberg seems to try to mirror the caret state even on events that only change the content so,
665
+ // let's force caret update if state has selection set.
666
+ if (typeof nextProps.selectionStart !== 'undefined' && typeof nextProps.selectionEnd !== 'undefined') {
667
+ this.needsSelectionUpdate = true;
668
+ }
669
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
670
+ }
671
+
672
+ if (!this.comesFromAztec) {
673
+ if (typeof nextProps.selectionStart !== 'undefined' && typeof nextProps.selectionEnd !== 'undefined' && nextProps.selectionStart !== this.props.selectionStart && nextProps.selectionStart !== this.selectionStart && nextProps.__unstableIsSelected) {
674
+ this.needsSelectionUpdate = true;
675
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
676
+ }
677
+
678
+ // For font size changes from a prop value a force refresh
679
+ // is needed without the selection update.
680
+ if (nextProps?.fontSize !== this.props?.fontSize) {
681
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
682
+ }
683
+
684
+ if (nextProps?.style?.fontSize !== this.props?.style?.fontSize && nextState.currentFontSize !== this.state.currentFontSize || nextState.currentFontSize !== this.state.currentFontSize || nextProps?.style?.lineHeight !== this.props?.style?.lineHeight) {
685
+ this.needsSelectionUpdate = true;
686
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
687
+ }
688
+ }
689
+
690
+ return true;
691
+ }
692
+ componentDidMount() {
693
+ // Request focus if wrapping block is selected and parent hasn't inhibited the focus request. This method of focusing
694
+ // is trying to implement the web-side counterpart of BlockList's `focusTabbable` where the BlockList is focusing an
695
+ // inputbox by searching the DOM. We don't have the DOM in RN so, using the combination of blockIsSelected and __unstableMobileNoFocusOnMount
696
+ // to determine if we should focus the RichText.
697
+ if (this.props.blockIsSelected && !this.props.__unstableMobileNoFocusOnMount) {
698
+ this._editor.focus();
699
+ this.onSelectionChange(this.props.selectionStart || 0, this.props.selectionEnd || 0);
700
+ }
701
+ }
702
+ componentWillUnmount() {
703
+ if (this._editor.isFocused()) {
704
+ this._editor.blur();
705
+ }
706
+ }
707
+ componentDidUpdate(prevProps) {
708
+ const {
709
+ style,
710
+ tagName
711
+ } = this.props;
712
+ const {
713
+ currentFontSize
714
+ } = this.state;
715
+ if (this.props.value !== this.value) {
716
+ this.value = this.props.value;
717
+ }
718
+ const {
719
+ __unstableIsSelected: isSelected
720
+ } = this.props;
721
+ const {
722
+ __unstableIsSelected: prevIsSelected
723
+ } = prevProps;
724
+ if (isSelected && !prevIsSelected) {
725
+ this._editor.focus();
726
+ // Update selection props explicitly when component is selected as Aztec won't call onSelectionChange
727
+ // if its internal value hasn't change. When created, default value is 0, 0.
728
+ this.onSelectionChange(this.props.selectionStart || 0, this.props.selectionEnd || 0);
729
+ } else if (!isSelected && prevIsSelected) {
730
+ this._editor.blur();
731
+ }
732
+
733
+ // For font size values changes from the font size picker
734
+ // we compare previous values to refresh the selected font size,
735
+ // this is also used when the tag name changes
736
+ // e.g Heading block and a level change like h1->h2.
737
+ const currentFontSizeStyle = this.getParsedFontSize(style?.fontSize);
738
+ const prevFontSizeStyle = this.getParsedFontSize(prevProps?.style?.fontSize);
739
+ const isDifferentTag = prevProps.tagName !== tagName;
740
+ if (currentFontSize && (currentFontSizeStyle || prevFontSizeStyle) && currentFontSizeStyle !== currentFontSize || isDifferentTag) {
741
+ this.setState({
742
+ currentFontSize: this.getFontSize(this.props)
743
+ });
744
+ }
745
+ }
746
+ getHtmlToRender(record, tagName) {
747
+ // Save back to HTML from React tree.
748
+ let value = this.valueToFormat(record);
749
+ if (value === undefined) {
750
+ this.manipulateEventCounterToForceNativeToRefresh(); // force a refresh on the native side
751
+ value = '';
752
+ }
753
+ // On android if content is empty we need to send no content or else the placeholder will not show.
754
+ if (!this.isIOS && (value === '' || value === EMPTY_PARAGRAPH_TAGS)) {
755
+ return '';
756
+ }
757
+ if (tagName) {
758
+ let extraAttributes = ``;
759
+ if (tagName === `ol`) {
760
+ if (this.props.reversed) {
761
+ extraAttributes += ` reversed`;
762
+ }
763
+ if (this.props.start) {
764
+ extraAttributes += ` start=${this.props.start}`;
765
+ }
766
+ }
767
+ value = `<${tagName}${extraAttributes}>${value}</${tagName}>`;
768
+ }
769
+ return value;
770
+ }
771
+ getEditableProps() {
772
+ return {
773
+ // Overridable props.
774
+ style: {},
775
+ className: 'rich-text',
776
+ onKeyDown: () => null
777
+ };
778
+ }
779
+ getParsedFontSize(fontSize) {
780
+ var _getPxFromCssUnit;
781
+ const {
782
+ height,
783
+ width
784
+ } = _reactNative.Dimensions.get('window');
785
+ const cssUnitOptions = {
786
+ height,
787
+ width,
788
+ fontSize: DEFAULT_FONT_SIZE
789
+ };
790
+ if (!fontSize) {
791
+ return fontSize;
792
+ }
793
+ const selectedPxValue = (_getPxFromCssUnit = (0, _blockEditor.getPxFromCssUnit)(fontSize, cssUnitOptions)) !== null && _getPxFromCssUnit !== void 0 ? _getPxFromCssUnit : DEFAULT_FONT_SIZE;
794
+ return parseFloat(selectedPxValue);
795
+ }
796
+ getFontSize(props) {
797
+ const {
798
+ baseGlobalStyles,
799
+ tagName,
800
+ fontSize,
801
+ style
802
+ } = props;
803
+ const tagNameFontSize = baseGlobalStyles?.elements?.[tagName]?.typography?.fontSize;
804
+ let newFontSize = DEFAULT_FONT_SIZE;
805
+
806
+ // Disables line-height rendering for pre elements until we fix some issues with AztecAndroid.
807
+ if (tagName === 'pre' && !this.isIOS) {
808
+ return undefined;
809
+ }
810
+
811
+ // For block-based themes, get the default editor font size.
812
+ if (baseGlobalStyles?.typography?.fontSize && tagName === 'p') {
813
+ newFontSize = baseGlobalStyles?.typography?.fontSize;
814
+ }
815
+
816
+ // For block-based themes, get the default element font size
817
+ // e.g h1, h2.
818
+ if (tagNameFontSize) {
819
+ newFontSize = tagNameFontSize;
820
+ }
821
+
822
+ // For font size values provided from the styles,
823
+ // usually from values set from the font size picker.
824
+ if (style?.fontSize) {
825
+ newFontSize = style.fontSize;
826
+ }
827
+
828
+ // Fall-back to a font size provided from its props (if there's any)
829
+ // and there are no other default values to use.
830
+ if (fontSize && !tagNameFontSize && !style?.fontSize) {
831
+ newFontSize = fontSize;
832
+ }
833
+
834
+ // We need to always convert to px units because the selected value
835
+ // could be coming from the web where it could be stored as a different unit.
836
+ const selectedPxValue = this.getParsedFontSize(newFontSize);
837
+ return selectedPxValue;
838
+ }
839
+ getLineHeight() {
840
+ const {
841
+ baseGlobalStyles,
842
+ tagName,
843
+ lineHeight,
844
+ style
845
+ } = this.props;
846
+ const tagNameLineHeight = baseGlobalStyles?.elements?.[tagName]?.typography?.lineHeight;
847
+ let newLineHeight;
848
+
849
+ // Disables line-height rendering for pre elements until we fix some issues with AztecAndroid.
850
+ if (tagName === 'pre' && !this.isIOS) {
851
+ return undefined;
852
+ }
853
+ if (!this.getIsBlockBasedTheme()) {
854
+ return;
855
+ }
856
+
857
+ // For block-based themes, get the default editor line height.
858
+ if (baseGlobalStyles?.typography?.lineHeight && tagName === 'p') {
859
+ newLineHeight = parseFloat(baseGlobalStyles?.typography?.lineHeight);
860
+ }
861
+
862
+ // For block-based themes, get the default element line height
863
+ // e.g h1, h2.
864
+ if (tagNameLineHeight) {
865
+ newLineHeight = parseFloat(tagNameLineHeight);
866
+ }
867
+
868
+ // For line height values provided from the styles,
869
+ // usually from values set from the line height picker.
870
+ if (style?.lineHeight) {
871
+ newLineHeight = parseFloat(style.lineHeight);
872
+ }
873
+
874
+ // Fall-back to a line height provided from its props (if there's any)
875
+ // and there are no other default values to use.
876
+ if (lineHeight && !tagNameLineHeight && !style?.lineHeight) {
877
+ newLineHeight = lineHeight;
878
+ }
879
+
880
+ // Check the final value is not over the minimum supported value.
881
+ if (newLineHeight && newLineHeight < MIN_LINE_HEIGHT) {
882
+ newLineHeight = MIN_LINE_HEIGHT;
883
+ }
884
+
885
+ // Until we parse CSS values correctly, avoid passing NaN values to Aztec
886
+ if (isNaN(newLineHeight)) {
887
+ return undefined;
888
+ }
889
+ return newLineHeight;
890
+ }
891
+ getIsBlockBasedTheme() {
892
+ const {
893
+ baseGlobalStyles
894
+ } = this.props;
895
+ return baseGlobalStyles && Object.entries(baseGlobalStyles).length !== 0;
896
+ }
897
+ getBlockUseDefaultFont() {
898
+ // For block-based themes it enables using the defaultFont
899
+ // in Aztec for iOS so it allows customizing the font size
900
+ // for the Preformatted/Code and Heading blocks.
901
+ if (!this.isIOS) {
902
+ return;
903
+ }
904
+ const {
905
+ tagName
906
+ } = this.props;
907
+ const isBlockBasedTheme = this.getIsBlockBasedTheme();
908
+ const tagsToMatch = /pre|h([1-6])$/gm;
909
+ return isBlockBasedTheme && tagsToMatch.test(tagName);
910
+ }
911
+ getLinkTextColor(defaultColor) {
912
+ const {
913
+ style
914
+ } = this.props;
915
+ const customColor = style?.linkColor && (0, _colord.colord)(style.linkColor);
916
+ return customColor && customColor.isValid() ? customColor.toHex() : defaultColor;
917
+ }
918
+ getPlaceholderTextColor() {
919
+ var _ref, _ref2;
920
+ const {
921
+ baseGlobalStyles,
922
+ getStylesFromColorScheme,
923
+ placeholderTextColor,
924
+ style
925
+ } = this.props;
926
+
927
+ // Default placeholder text color.
928
+ const placeholderStyle = getStylesFromColorScheme(_style.default.richTextPlaceholder, _style.default.richTextPlaceholderDark);
929
+ const {
930
+ color: defaultPlaceholderTextColor
931
+ } = placeholderStyle;
932
+ // Custom 63% opacity for theme and inherited colors.
933
+ const placeholderOpacity = 'A1';
934
+
935
+ // Determine inherited placeholder color if available.
936
+ const inheritPlaceholderColor = style?.placeholderColor ? `${style.placeholderColor}${placeholderOpacity}` : undefined;
937
+
938
+ // If using block-based themes, derive the placeholder color from global styles.
939
+ const globalStylesPlaceholderColor = baseGlobalStyles?.color?.text ? `${baseGlobalStyles.color.text}${placeholderOpacity}` : undefined;
940
+ return (_ref = (_ref2 = inheritPlaceholderColor !== null && inheritPlaceholderColor !== void 0 ? inheritPlaceholderColor : placeholderTextColor) !== null && _ref2 !== void 0 ? _ref2 : globalStylesPlaceholderColor) !== null && _ref !== void 0 ? _ref : defaultPlaceholderTextColor;
941
+ }
942
+ render() {
943
+ const {
944
+ tagName,
945
+ style,
946
+ __unstableIsSelected: isSelected,
947
+ children,
948
+ getStylesFromColorScheme,
949
+ minWidth,
950
+ maxWidth,
951
+ formatTypes,
952
+ parentBlockStyles,
953
+ accessibilityLabel,
954
+ disableEditingMenu = false,
955
+ baseGlobalStyles,
956
+ selectionStart,
957
+ selectionEnd,
958
+ disableSuggestions,
959
+ containerWidth
960
+ } = this.props;
961
+ const {
962
+ currentFontSize
963
+ } = this.state;
964
+ const record = this.getRecord();
965
+ const html = this.getHtmlToRender(record, tagName);
966
+ const editableProps = this.getEditableProps();
967
+ const blockUseDefaultFont = this.getBlockUseDefaultFont();
968
+ const fontSize = currentFontSize;
969
+ const lineHeight = this.getLineHeight();
970
+ const {
971
+ color: defaultColor,
972
+ textDecorationColor: defaultTextDecorationColor,
973
+ fontFamily: defaultFontFamily
974
+ } = getStylesFromColorScheme(_style.default.richText, _style.default.richTextDark);
975
+ const linkTextColor = this.getLinkTextColor(defaultTextDecorationColor);
976
+ const currentSelectionStart = selectionStart !== null && selectionStart !== void 0 ? selectionStart : 0;
977
+ const currentSelectionEnd = selectionEnd !== null && selectionEnd !== void 0 ? selectionEnd : 0;
978
+ let selection = null;
979
+ if (this.needsSelectionUpdate) {
980
+ this.needsSelectionUpdate = false;
981
+ selection = {
982
+ start: currentSelectionStart,
983
+ end: currentSelectionEnd
984
+ };
985
+
986
+ // On AztecAndroid, setting the caret to an out-of-bounds position will crash the editor so, let's check for some cases.
987
+ if (!this.isIOS) {
988
+ // The following regular expression is used in Aztec here:
989
+ // https://github.com/wordpress-mobile/AztecEditor-Android/blob/b1fad439d56fa6d4aa0b78526fef355c59d00dd3/aztec/src/main/kotlin/org/wordpress/aztec/AztecParser.kt#L656
990
+ const brBeforeParaMatches = html.match(/(<br>)+<\/p>$/g);
991
+ if (brBeforeParaMatches) {
992
+ console.warn('Oops, BR tag(s) at the end of content. Aztec will remove them, adapting the selection...');
993
+ const count = (brBeforeParaMatches[0].match(/br/g) || []).length;
994
+ if (count > 0) {
995
+ let newSelectionStart = currentSelectionStart - count;
996
+ if (newSelectionStart < 0) {
997
+ newSelectionStart = 0;
998
+ }
999
+ let newSelectionEnd = currentSelectionEnd - count;
1000
+ if (newSelectionEnd < 0) {
1001
+ newSelectionEnd = 0;
1002
+ }
1003
+ selection = {
1004
+ start: newSelectionStart,
1005
+ end: newSelectionEnd
1006
+ };
1007
+ }
1008
+ }
1009
+ }
1010
+ }
1011
+ if (this.comesFromAztec) {
1012
+ this.comesFromAztec = false;
1013
+ this.firedAfterTextChanged = false;
1014
+ }
1015
+
1016
+ // Logic below assures that `RichText` width will always have equal value when container is almost fully filled.
1017
+ const width = maxWidth && this.state.width && maxWidth - this.state.width < 10 ? maxWidth : this.state.width;
1018
+ const containerStyles = [style?.padding && style?.backgroundColor && {
1019
+ padding: style.padding,
1020
+ backgroundColor: style.backgroundColor
1021
+ }, containerWidth && {
1022
+ width: containerWidth
1023
+ }];
1024
+ const defaultSelectionColor = getStylesFromColorScheme(_style.default['rich-text-selection'], _style.default['rich-text-selection--dark']).color;
1025
+ const selectionColor = getSelectionColor(this.props.selectionColor, defaultSelectionColor, baseGlobalStyles, this.getIsBlockBasedTheme());
1026
+ const EditableView = props => {
1027
+ this.customEditableOnKeyDown = props?.onKeyDown;
1028
+ return (0, _react.createElement)(_react.Fragment, null);
1029
+ };
1030
+ return (0, _react.createElement)(_reactNative.View, {
1031
+ style: containerStyles
1032
+ }, children && children({
1033
+ isSelected,
1034
+ value: record,
1035
+ onChange: this.onFormatChange,
1036
+ onFocus: () => {},
1037
+ editableProps,
1038
+ editableTagName: EditableView
1039
+ }), (0, _react.createElement)(_reactNativeAztec.default, {
1040
+ accessibilityLabel: accessibilityLabel,
1041
+ ref: ref => {
1042
+ this._editor = ref;
1043
+ if (this.props.setRef) {
1044
+ this.props.setRef(ref);
1045
+ }
1046
+ },
1047
+ style: {
1048
+ backgroundColor: _style.default.richText.backgroundColor,
1049
+ ...style,
1050
+ ...(this.isIOS && minWidth && maxWidth ? {
1051
+ width
1052
+ } : {
1053
+ maxWidth
1054
+ }),
1055
+ minHeight: this.state.height
1056
+ },
1057
+ blockUseDefaultFont: blockUseDefaultFont,
1058
+ text: {
1059
+ text: html,
1060
+ eventCount: this.lastEventCount,
1061
+ selection,
1062
+ linkTextColor,
1063
+ tag: tagName
1064
+ },
1065
+ placeholder: this.props.placeholder,
1066
+ placeholderTextColor: this.getPlaceholderTextColor(),
1067
+ deleteEnter: this.props.deleteEnter,
1068
+ onChange: this.onChangeFromAztec,
1069
+ onFocus: this.onFocus,
1070
+ onBlur: this.onBlur,
1071
+ onKeyDown: this.onKeyDown,
1072
+ triggerKeyCodes: disableEditingMenu ? [] : this.suggestionOptions().map(op => op.triggerChar),
1073
+ onPaste: this.onPaste,
1074
+ activeFormats: this.getActiveFormatNames(record),
1075
+ onContentSizeChange: this.onContentSizeChange,
1076
+ onSelectionChange: this.onSelectionChangeFromAztec,
1077
+ blockType: {
1078
+ tag: tagName
1079
+ },
1080
+ color: style && style.color || parentBlockStyles && parentBlockStyles.color || baseGlobalStyles && baseGlobalStyles?.color?.text || defaultColor,
1081
+ maxImagesWidth: 200,
1082
+ fontFamily: this.props.fontFamily || defaultFontFamily,
1083
+ fontSize: fontSize,
1084
+ lineHeight: lineHeight,
1085
+ fontWeight: this.props.fontWeight,
1086
+ fontStyle: this.props.fontStyle,
1087
+ disableEditingMenu: disableEditingMenu,
1088
+ isMultiline: this.isMultiline,
1089
+ textAlign: this.props.textAlign,
1090
+ ...(this.isIOS ? {
1091
+ maxWidth
1092
+ } : {}),
1093
+ minWidth: minWidth,
1094
+ id: this.props.id,
1095
+ selectionColor: selectionColor,
1096
+ disableAutocorrection: this.props.disableAutocorrection
1097
+ }), isSelected && (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(_formatEdit.default, {
1098
+ forwardedRef: this._editor,
1099
+ formatTypes: formatTypes,
1100
+ value: record,
1101
+ onChange: this.onFormatChange,
1102
+ onFocus: () => {}
1103
+ }), !disableSuggestions && (0, _react.createElement)(_blockEditor.BlockFormatControls, null, (0, _react.createElement)(_toolbarButtonWithOptions.default, {
1104
+ options: this.suggestionOptions()
1105
+ }))));
1106
+ }
1107
+ }
1108
+ exports.RichText = RichText;
1109
+ RichText.defaultProps = {
1110
+ format: 'string',
1111
+ value: '',
1112
+ tagName: 'div'
1113
+ };
1114
+ const withFormatTypes = WrappedComponent => props => {
1115
+ const {
1116
+ clientId,
1117
+ identifier,
1118
+ withoutInteractiveFormatting,
1119
+ allowedFormats
1120
+ } = props;
1121
+ const {
1122
+ formatTypes
1123
+ } = (0, _useFormatTypes.useFormatTypes)({
1124
+ clientId,
1125
+ identifier,
1126
+ withoutInteractiveFormatting,
1127
+ allowedFormats
1128
+ });
1129
+ return (0, _react.createElement)(WrappedComponent, {
1130
+ ...props,
1131
+ formatTypes: formatTypes
1132
+ });
1133
+ };
1134
+ var _default = (0, _compose.compose)([(0, _data.withSelect)((select, {
1135
+ clientId
1136
+ }) => {
1137
+ const {
1138
+ getBlockParents,
1139
+ getBlock,
1140
+ getSettings
1141
+ } = select('core/block-editor');
1142
+ const parents = getBlockParents(clientId, true);
1143
+ const parentBlock = parents ? getBlock(parents[0]) : undefined;
1144
+ const parentBlockStyles = parentBlock?.attributes?.childrenStyles;
1145
+ const settings = getSettings();
1146
+ const baseGlobalStyles = settings?.__experimentalGlobalStylesBaseStyles;
1147
+ const colorPalettes = settings?.__experimentalFeatures?.color?.palette;
1148
+ const colorPalette = colorPalettes ? flatColorPalettes(colorPalettes) : settings?.colors;
1149
+ return {
1150
+ areMentionsSupported: settings?.capabilities?.mentions === true,
1151
+ areXPostsSupported: settings?.capabilities?.xposts === true,
1152
+ parentBlockStyles,
1153
+ baseGlobalStyles,
1154
+ colorPalette
1155
+ };
1156
+ }), _compose.withPreferredColorScheme, withFormatTypes])(RichText);
1157
+ exports.default = _default;
1158
+ //# sourceMappingURL=index.native.js.map