@contentful/field-editor-rich-text 3.14.3 → 3.15.1

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 (323) hide show
  1. package/dist/cjs/ContentfulEditorProvider.js +8 -8
  2. package/dist/cjs/RichTextEditor.js +22 -20
  3. package/dist/cjs/RichTextEditor.styles.js +2 -1
  4. package/dist/cjs/SdkProvider.js +7 -5
  5. package/dist/cjs/SyncEditorChanges.js +15 -6
  6. package/dist/cjs/Toolbar/_tests_/toolbar.test.js +17 -15
  7. package/dist/cjs/Toolbar/components/EmbedEntityWidget.js +14 -10
  8. package/dist/cjs/Toolbar/components/EmbeddedEntityDropdownButton.js +10 -8
  9. package/dist/cjs/Toolbar/components/StickyToolbarWrapper.js +2 -2
  10. package/dist/cjs/Toolbar/index.js +33 -30
  11. package/dist/cjs/__fixtures__/FakeSdk.js +3 -3
  12. package/dist/cjs/__fixtures__/asset/index.js +10 -10
  13. package/dist/cjs/__fixtures__/content-type/index.js +1 -1
  14. package/dist/cjs/__fixtures__/entry/index.js +7 -7
  15. package/dist/cjs/__fixtures__/fixtures.js +8 -6
  16. package/dist/cjs/__fixtures__/locale/index.js +2 -2
  17. package/dist/cjs/__fixtures__/space/index.js +1 -1
  18. package/dist/cjs/constants/Schema.js +1 -0
  19. package/dist/cjs/dialogs/HypelinkDialog/HyperlinkDialog.js +43 -38
  20. package/dist/cjs/dialogs/openRichTextDialog.js +6 -4
  21. package/dist/cjs/dialogs/renderRichTextDialog.js +6 -4
  22. package/dist/cjs/helpers/__tests__/removeInternalMarks.test.js +10 -10
  23. package/dist/cjs/helpers/callbacks.js +3 -3
  24. package/dist/cjs/helpers/config.js +2 -2
  25. package/dist/cjs/helpers/editor.js +53 -44
  26. package/dist/cjs/helpers/environment.js +3 -3
  27. package/dist/cjs/helpers/formatDateAndTime.js +5 -4
  28. package/dist/cjs/helpers/getAllowedResourcesForNodeType.js +22 -5
  29. package/dist/cjs/helpers/getLinkedContentTypeIdsForNodeType.js +29 -5
  30. package/dist/cjs/helpers/nodeFactory.js +6 -6
  31. package/dist/cjs/helpers/sdkNavigatorSlideIn.js +14 -6
  32. package/dist/cjs/helpers/sdkNavigatorSlideIn.spec.js +3 -2
  33. package/dist/cjs/helpers/toSlateValue.js +14 -3
  34. package/dist/cjs/helpers/transformers.js +5 -5
  35. package/dist/cjs/helpers/validations.js +12 -9
  36. package/dist/cjs/index.js +7 -5
  37. package/dist/cjs/internal/constants.js +4 -2
  38. package/dist/cjs/internal/hooks.js +8 -6
  39. package/dist/cjs/internal/misc.js +15 -12
  40. package/dist/cjs/internal/queries.js +115 -108
  41. package/dist/cjs/internal/transforms.js +51 -48
  42. package/dist/cjs/internal/types/editor.js +3 -1
  43. package/dist/cjs/plugins/Break/createExitBreakPlugin.test.js +4 -3
  44. package/dist/cjs/plugins/Break/createResetNodePlugin.js +1 -0
  45. package/dist/cjs/plugins/Break/createSoftBreakPlugin.test.js +3 -3
  46. package/dist/cjs/plugins/CommandPalette/components/CommandList.js +35 -33
  47. package/dist/cjs/plugins/CommandPalette/components/CommandList.styles.js +1 -1
  48. package/dist/cjs/plugins/CommandPalette/components/CommandPrompt.js +7 -5
  49. package/dist/cjs/plugins/CommandPalette/hooks/useCommandList.js +7 -3
  50. package/dist/cjs/plugins/CommandPalette/onKeyDown.js +6 -1
  51. package/dist/cjs/plugins/CommandPalette/onKeyDown.spec.js +6 -4
  52. package/dist/cjs/plugins/CommandPalette/useCommands.js +3 -3
  53. package/dist/cjs/plugins/CommandPalette/utils/fetchEntries.js +2 -0
  54. package/dist/cjs/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
  55. package/dist/cjs/plugins/DragAndDrop/index.js +9 -1
  56. package/dist/cjs/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +10 -8
  57. package/dist/cjs/plugins/EmbeddedEntityBlock/index.js +3 -3
  58. package/dist/cjs/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +19 -17
  59. package/dist/cjs/plugins/EmbeddedEntityInline/LinkedEntityInline.js +9 -7
  60. package/dist/cjs/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +5 -5
  61. package/dist/cjs/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +17 -13
  62. package/dist/cjs/plugins/EmbeddedResourceInline/LinkedResourceInline.js +5 -5
  63. package/dist/cjs/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
  64. package/dist/cjs/plugins/Heading/components/Heading.js +13 -10
  65. package/dist/cjs/plugins/Heading/components/ToolbarHeadingButton.js +19 -11
  66. package/dist/cjs/plugins/Heading/createHeadingPlugin.js +7 -2
  67. package/dist/cjs/plugins/Hr/index.js +19 -14
  68. package/dist/cjs/plugins/Hyperlink/HyperlinkModal.js +32 -28
  69. package/dist/cjs/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
  70. package/dist/cjs/plugins/Hyperlink/components/EntityHyperlink.js +8 -6
  71. package/dist/cjs/plugins/Hyperlink/components/ResourceHyperlink.js +8 -6
  72. package/dist/cjs/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +6 -4
  73. package/dist/cjs/plugins/Hyperlink/components/UrlHyperlink.js +7 -5
  74. package/dist/cjs/plugins/Hyperlink/components/styles.js +1 -1
  75. package/dist/cjs/plugins/Hyperlink/createHyperlinkPlugin.js +10 -4
  76. package/dist/cjs/plugins/Hyperlink/useEntityInfo.js +6 -3
  77. package/dist/cjs/plugins/Hyperlink/useResourceEntityInfo.js +7 -5
  78. package/dist/cjs/plugins/Hyperlink/utils.js +6 -14
  79. package/dist/cjs/plugins/List/__tests__/createListPlugin.test.js +13 -13
  80. package/dist/cjs/plugins/List/__tests__/insertListBreak.test.js +29 -25
  81. package/dist/cjs/plugins/List/__tests__/insertListFragment.test.js +22 -22
  82. package/dist/cjs/plugins/List/components/List.js +9 -7
  83. package/dist/cjs/plugins/List/components/ListItem.js +6 -4
  84. package/dist/cjs/plugins/List/components/ToolbarListButton.js +7 -5
  85. package/dist/cjs/plugins/List/createListPlugin.js +4 -0
  86. package/dist/cjs/plugins/List/insertListBreak.js +13 -4
  87. package/dist/cjs/plugins/List/insertListFragment.js +18 -5
  88. package/dist/cjs/plugins/List/onKeyDownList.js +7 -4
  89. package/dist/cjs/plugins/List/transforms/insertListItem.js +17 -2
  90. package/dist/cjs/plugins/List/transforms/moveListItemDown.js +8 -2
  91. package/dist/cjs/plugins/List/transforms/moveListItems.js +7 -2
  92. package/dist/cjs/plugins/List/transforms/moveListItems.test.js +15 -14
  93. package/dist/cjs/plugins/List/transforms/toggleList.js +8 -3
  94. package/dist/cjs/plugins/List/transforms/toggleList.spec.js +28 -28
  95. package/dist/cjs/plugins/List/transforms/unwrapList.js +7 -2
  96. package/dist/cjs/plugins/List/utils.js +12 -11
  97. package/dist/cjs/plugins/List/withList.js +6 -2
  98. package/dist/cjs/plugins/Marks/Bold.js +9 -7
  99. package/dist/cjs/plugins/Marks/Code.js +15 -7
  100. package/dist/cjs/plugins/Marks/Italic.js +9 -7
  101. package/dist/cjs/plugins/Marks/Subscript.js +10 -8
  102. package/dist/cjs/plugins/Marks/Superscript.js +10 -8
  103. package/dist/cjs/plugins/Marks/Underline.js +6 -4
  104. package/dist/cjs/plugins/Marks/components/MarkToolbarButton.js +9 -7
  105. package/dist/cjs/plugins/Marks/helpers.js +5 -5
  106. package/dist/cjs/plugins/Normalizer/baseRules.js +2 -0
  107. package/dist/cjs/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
  108. package/dist/cjs/plugins/Normalizer/utils.js +4 -3
  109. package/dist/cjs/plugins/Normalizer/withNormalizer.js +23 -3
  110. package/dist/cjs/plugins/Paragraph/Paragraph.js +6 -4
  111. package/dist/cjs/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
  112. package/dist/cjs/plugins/Paragraph/createParagraphPlugin.js +3 -2
  113. package/dist/cjs/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -6
  114. package/dist/cjs/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
  115. package/dist/cjs/plugins/PasteHTML/utils/sanitizeAnchors.js +9 -0
  116. package/dist/cjs/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
  117. package/dist/cjs/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
  118. package/dist/cjs/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
  119. package/dist/cjs/plugins/Quote/components/Quote.js +6 -4
  120. package/dist/cjs/plugins/Quote/components/ToolbarQuoteButton.js +6 -4
  121. package/dist/cjs/plugins/Quote/createQuotePlugin.js +1 -0
  122. package/dist/cjs/plugins/Quote/toggleQuote.js +5 -5
  123. package/dist/cjs/plugins/Quote/withQuote.js +4 -2
  124. package/dist/cjs/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
  125. package/dist/cjs/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
  126. package/dist/cjs/plugins/Table/__tests__/helpers.test.js +4 -4
  127. package/dist/cjs/plugins/Table/actions/addColumn.js +5 -4
  128. package/dist/cjs/plugins/Table/actions/addRow.js +6 -3
  129. package/dist/cjs/plugins/Table/components/Cell.js +7 -5
  130. package/dist/cjs/plugins/Table/components/HeaderCell.js +7 -5
  131. package/dist/cjs/plugins/Table/components/Row.js +6 -4
  132. package/dist/cjs/plugins/Table/components/Table.js +8 -6
  133. package/dist/cjs/plugins/Table/components/TableActions.js +19 -16
  134. package/dist/cjs/plugins/Table/components/ToolbarButton.js +7 -4
  135. package/dist/cjs/plugins/Table/createTablePlugin.js +11 -1
  136. package/dist/cjs/plugins/Table/helpers.js +16 -12
  137. package/dist/cjs/plugins/Table/insertTableFragment.js +15 -2
  138. package/dist/cjs/plugins/Table/onKeyDownTable.js +10 -2
  139. package/dist/cjs/plugins/Table/tableTracking.js +6 -6
  140. package/dist/cjs/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
  141. package/dist/cjs/plugins/Text/createTextPlugin.js +22 -5
  142. package/dist/cjs/plugins/Tracking/createTrackingPlugin.js +5 -4
  143. package/dist/cjs/plugins/Tracking/utils.js +6 -3
  144. package/dist/cjs/plugins/Voids/createVoidsPlugin.js +5 -0
  145. package/dist/cjs/plugins/Voids/transformVoid.js +1 -0
  146. package/dist/cjs/plugins/index.js +15 -3
  147. package/dist/cjs/plugins/shared/EmbeddedBlockToolbarIcon.js +12 -10
  148. package/dist/cjs/plugins/shared/EmbeddedBlockUtil.js +16 -6
  149. package/dist/cjs/plugins/shared/EmbeddedInlineToolbarIcon.js +10 -8
  150. package/dist/cjs/plugins/shared/EmbeddedInlineUtil.js +9 -5
  151. package/dist/cjs/plugins/shared/FetchingWrappedAssetCard.js +13 -11
  152. package/dist/cjs/plugins/shared/FetchingWrappedEntryCard.js +14 -12
  153. package/dist/cjs/plugins/shared/FetchingWrappedResourceCard.js +14 -11
  154. package/dist/cjs/plugins/shared/LinkedBlockWrapper.js +8 -4
  155. package/dist/cjs/plugins/shared/LinkedInlineWrapper.js +10 -6
  156. package/dist/cjs/plugins/shared/ResourceNewBadge.js +5 -3
  157. package/dist/cjs/plugins/shared/ToolbarButton.js +8 -6
  158. package/dist/cjs/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +10 -5
  159. package/dist/cjs/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +11 -6
  160. package/dist/cjs/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +15 -13
  161. package/dist/cjs/plugins/shared/utils.js +20 -3
  162. package/dist/cjs/test-utils/assertOutput.js +1 -0
  163. package/dist/cjs/test-utils/hyperscript.d.js +1 -0
  164. package/dist/cjs/test-utils/randomId.js +3 -1
  165. package/dist/cjs/test-utils/validation.js +8 -5
  166. package/dist/esm/ContentfulEditorProvider.js +4 -1
  167. package/dist/esm/RichTextEditor.js +13 -13
  168. package/dist/esm/RichTextEditor.styles.js +1 -0
  169. package/dist/esm/SdkProvider.js +2 -2
  170. package/dist/esm/SyncEditorChanges.js +18 -3
  171. package/dist/esm/Toolbar/_tests_/toolbar.test.js +12 -12
  172. package/dist/esm/Toolbar/components/EmbedEntityWidget.js +10 -8
  173. package/dist/esm/Toolbar/components/EmbeddedEntityDropdownButton.js +6 -6
  174. package/dist/esm/Toolbar/components/StickyToolbarWrapper.js +1 -1
  175. package/dist/esm/Toolbar/index.js +28 -27
  176. package/dist/esm/__fixtures__/FakeSdk.js +3 -3
  177. package/dist/esm/constants/Schema.js +1 -0
  178. package/dist/esm/dialogs/HypelinkDialog/HyperlinkDialog.js +34 -31
  179. package/dist/esm/dialogs/openRichTextDialog.js +2 -2
  180. package/dist/esm/dialogs/renderRichTextDialog.js +2 -2
  181. package/dist/esm/helpers/__tests__/removeInternalMarks.test.js +10 -10
  182. package/dist/esm/helpers/callbacks.js +1 -1
  183. package/dist/esm/helpers/config.js +9 -1
  184. package/dist/esm/helpers/editor.js +22 -6
  185. package/dist/esm/helpers/extractNodes.js +3 -1
  186. package/dist/esm/helpers/formatDateAndTime.js +11 -2
  187. package/dist/esm/helpers/getAllowedResourcesForNodeType.js +19 -2
  188. package/dist/esm/helpers/getLinkedContentTypeIdsForNodeType.js +26 -2
  189. package/dist/esm/helpers/sdkNavigatorSlideIn.js +20 -6
  190. package/dist/esm/helpers/sdkNavigatorSlideIn.spec.js +1 -0
  191. package/dist/esm/helpers/toSlateValue.js +17 -3
  192. package/dist/esm/helpers/validations.js +5 -1
  193. package/dist/esm/internal/misc.js +23 -2
  194. package/dist/esm/internal/queries.js +11 -2
  195. package/dist/esm/internal/transforms.js +14 -3
  196. package/dist/esm/internal/types/editor.js +3 -1
  197. package/dist/esm/plugins/Break/createExitBreakPlugin.test.js +4 -3
  198. package/dist/esm/plugins/Break/createResetNodePlugin.js +1 -0
  199. package/dist/esm/plugins/Break/createSoftBreakPlugin.test.js +3 -3
  200. package/dist/esm/plugins/CommandPalette/components/CommandList.js +30 -30
  201. package/dist/esm/plugins/CommandPalette/components/CommandPrompt.js +2 -2
  202. package/dist/esm/plugins/CommandPalette/createCommandPalettePlugin.js +11 -1
  203. package/dist/esm/plugins/CommandPalette/hooks/useCommandList.js +2 -0
  204. package/dist/esm/plugins/CommandPalette/onKeyDown.js +5 -0
  205. package/dist/esm/plugins/CommandPalette/onKeyDown.spec.js +2 -2
  206. package/dist/esm/plugins/CommandPalette/useCommands.js +3 -3
  207. package/dist/esm/plugins/CommandPalette/utils/fetchEntries.js +2 -0
  208. package/dist/esm/plugins/CommandPalette/utils/trimLeadingSlash.js +6 -1
  209. package/dist/esm/plugins/DragAndDrop/index.js +9 -1
  210. package/dist/esm/plugins/EmbeddedEntityBlock/LinkedEntityBlock.js +6 -6
  211. package/dist/esm/plugins/EmbeddedEntityInline/FetchingWrappedInlineEntryCard.js +14 -14
  212. package/dist/esm/plugins/EmbeddedEntityInline/LinkedEntityInline.js +5 -5
  213. package/dist/esm/plugins/EmbeddedResourceBlock/LinkedResourceBlock.js +4 -4
  214. package/dist/esm/plugins/EmbeddedResourceInline/FetchingWrappedResourceInlineCard.js +13 -11
  215. package/dist/esm/plugins/EmbeddedResourceInline/LinkedResourceInline.js +4 -4
  216. package/dist/esm/plugins/Heading/__tests__/createHeadingPlugin.test.js +32 -32
  217. package/dist/esm/plugins/Heading/components/Heading.js +8 -7
  218. package/dist/esm/plugins/Heading/components/ToolbarHeadingButton.js +14 -8
  219. package/dist/esm/plugins/Heading/createHeadingPlugin.js +6 -1
  220. package/dist/esm/plugins/Hr/index.js +8 -5
  221. package/dist/esm/plugins/Hyperlink/HyperlinkModal.js +25 -23
  222. package/dist/esm/plugins/Hyperlink/__tests__/createHyperlinkPlugin.test.js +8 -8
  223. package/dist/esm/plugins/Hyperlink/components/EntityHyperlink.js +4 -4
  224. package/dist/esm/plugins/Hyperlink/components/ResourceHyperlink.js +4 -4
  225. package/dist/esm/plugins/Hyperlink/components/ToolbarHyperlinkButton.js +2 -2
  226. package/dist/esm/plugins/Hyperlink/components/UrlHyperlink.js +3 -3
  227. package/dist/esm/plugins/Hyperlink/createHyperlinkPlugin.js +5 -1
  228. package/dist/esm/plugins/Hyperlink/useEntityInfo.js +6 -3
  229. package/dist/esm/plugins/Hyperlink/useResourceEntityInfo.js +3 -3
  230. package/dist/esm/plugins/Hyperlink/utils.js +2 -7
  231. package/dist/esm/plugins/List/__tests__/createListPlugin.test.js +13 -13
  232. package/dist/esm/plugins/List/__tests__/insertListBreak.test.js +29 -25
  233. package/dist/esm/plugins/List/__tests__/insertListFragment.test.js +22 -22
  234. package/dist/esm/plugins/List/components/List.js +1 -1
  235. package/dist/esm/plugins/List/components/ListItem.js +1 -1
  236. package/dist/esm/plugins/List/components/ToolbarListButton.js +3 -3
  237. package/dist/esm/plugins/List/createListPlugin.js +4 -0
  238. package/dist/esm/plugins/List/insertListBreak.js +13 -4
  239. package/dist/esm/plugins/List/insertListFragment.js +18 -5
  240. package/dist/esm/plugins/List/onKeyDownList.js +5 -2
  241. package/dist/esm/plugins/List/transforms/insertListItem.js +20 -3
  242. package/dist/esm/plugins/List/transforms/moveListItemDown.js +8 -2
  243. package/dist/esm/plugins/List/transforms/moveListItems.js +7 -2
  244. package/dist/esm/plugins/List/transforms/moveListItems.test.js +15 -14
  245. package/dist/esm/plugins/List/transforms/toggleList.js +8 -3
  246. package/dist/esm/plugins/List/transforms/toggleList.spec.js +28 -28
  247. package/dist/esm/plugins/List/transforms/unwrapList.js +7 -2
  248. package/dist/esm/plugins/List/utils.js +7 -2
  249. package/dist/esm/plugins/List/withList.js +6 -2
  250. package/dist/esm/plugins/Marks/Bold.js +2 -2
  251. package/dist/esm/plugins/Marks/Code.js +8 -2
  252. package/dist/esm/plugins/Marks/Italic.js +2 -2
  253. package/dist/esm/plugins/Marks/Subscript.js +2 -2
  254. package/dist/esm/plugins/Marks/Superscript.js +2 -2
  255. package/dist/esm/plugins/Marks/Underline.js +2 -2
  256. package/dist/esm/plugins/Marks/components/MarkToolbarButton.js +4 -4
  257. package/dist/esm/plugins/Marks/helpers.js +1 -1
  258. package/dist/esm/plugins/Normalizer/baseRules.js +4 -0
  259. package/dist/esm/plugins/Normalizer/createNormalizerPlugin.test.js +12 -12
  260. package/dist/esm/plugins/Normalizer/utils.js +1 -0
  261. package/dist/esm/plugins/Normalizer/withNormalizer.js +22 -2
  262. package/dist/esm/plugins/Paragraph/Paragraph.js +1 -1
  263. package/dist/esm/plugins/Paragraph/__tests__/createParagraphPlugin.test.js +32 -32
  264. package/dist/esm/plugins/Paragraph/createParagraphPlugin.js +2 -1
  265. package/dist/esm/plugins/PasteHTML/createPasteHTMLPlugin.js +9 -3
  266. package/dist/esm/plugins/PasteHTML/utils/__tests__/sanitizeHTML.test.js +2 -0
  267. package/dist/esm/plugins/PasteHTML/utils/sanitizeAnchors.js +27 -1
  268. package/dist/esm/plugins/PasteHTML/utils/sanitizeHTML.js +17 -2
  269. package/dist/esm/plugins/PasteHTML/utils/sanitizeSheets.js +13 -1
  270. package/dist/esm/plugins/Quote/__test__/createQuotePlugin.test.js +21 -21
  271. package/dist/esm/plugins/Quote/components/Quote.js +1 -1
  272. package/dist/esm/plugins/Quote/components/ToolbarQuoteButton.js +2 -2
  273. package/dist/esm/plugins/Quote/createQuotePlugin.js +1 -0
  274. package/dist/esm/plugins/Quote/shouldResetQuote.js +6 -1
  275. package/dist/esm/plugins/Quote/toggleQuote.js +1 -1
  276. package/dist/esm/plugins/Quote/withQuote.js +4 -2
  277. package/dist/esm/plugins/SelectOnBackspace/createSelectOnBackspacePlugin.js +1 -0
  278. package/dist/esm/plugins/Table/__tests__/createTablePlugin.test.js +22 -22
  279. package/dist/esm/plugins/Table/__tests__/helpers.test.js +4 -4
  280. package/dist/esm/plugins/Table/actions/addColumn.js +2 -1
  281. package/dist/esm/plugins/Table/actions/addRow.js +3 -0
  282. package/dist/esm/plugins/Table/components/Cell.js +2 -2
  283. package/dist/esm/plugins/Table/components/HeaderCell.js +2 -2
  284. package/dist/esm/plugins/Table/components/Row.js +1 -1
  285. package/dist/esm/plugins/Table/components/Table.js +3 -3
  286. package/dist/esm/plugins/Table/components/TableActions.js +12 -11
  287. package/dist/esm/plugins/Table/components/ToolbarButton.js +3 -2
  288. package/dist/esm/plugins/Table/createTablePlugin.js +11 -1
  289. package/dist/esm/plugins/Table/helpers.js +10 -1
  290. package/dist/esm/plugins/Table/insertTableFragment.js +15 -2
  291. package/dist/esm/plugins/Table/onKeyDownTable.js +10 -2
  292. package/dist/esm/plugins/Table/tableTracking.js +6 -6
  293. package/dist/esm/plugins/Text/__tests__/createTextPlugin.test.js +19 -17
  294. package/dist/esm/plugins/Text/createTextPlugin.js +22 -5
  295. package/dist/esm/plugins/Tracking/createTrackingPlugin.js +2 -1
  296. package/dist/esm/plugins/Tracking/utils.js +1 -0
  297. package/dist/esm/plugins/Voids/createVoidsPlugin.js +5 -0
  298. package/dist/esm/plugins/Voids/transformVoid.js +4 -1
  299. package/dist/esm/plugins/index.js +12 -0
  300. package/dist/esm/plugins/shared/EmbeddedBlockToolbarIcon.js +5 -5
  301. package/dist/esm/plugins/shared/EmbeddedBlockUtil.js +15 -5
  302. package/dist/esm/plugins/shared/EmbeddedInlineToolbarIcon.js +5 -5
  303. package/dist/esm/plugins/shared/EmbeddedInlineUtil.js +8 -4
  304. package/dist/esm/plugins/shared/FetchingWrappedAssetCard.js +8 -8
  305. package/dist/esm/plugins/shared/FetchingWrappedEntryCard.js +9 -9
  306. package/dist/esm/plugins/shared/FetchingWrappedResourceCard.js +9 -8
  307. package/dist/esm/plugins/shared/LinkedBlockWrapper.js +7 -3
  308. package/dist/esm/plugins/shared/LinkedInlineWrapper.js +5 -3
  309. package/dist/esm/plugins/shared/ResourceNewBadge.js +1 -1
  310. package/dist/esm/plugins/shared/ToolbarButton.js +3 -3
  311. package/dist/esm/plugins/shared/__tests__/FetchingWrappedAssetCard.test.js +5 -2
  312. package/dist/esm/plugins/shared/__tests__/FetchingWrappedEntryCard.test.js +5 -2
  313. package/dist/esm/plugins/shared/__tests__/FetchingWrappedResourceCard.test.js +8 -8
  314. package/dist/esm/plugins/shared/utils.js +9 -0
  315. package/dist/esm/test-utils/assertOutput.js +1 -0
  316. package/dist/esm/test-utils/hyperscript.d.js +1 -0
  317. package/dist/esm/test-utils/jsx.js +5 -1
  318. package/dist/esm/test-utils/randomId.js +3 -1
  319. package/dist/esm/test-utils/setEmptyDataAttribute.js +4 -1
  320. package/dist/esm/test-utils/validation.js +7 -4
  321. package/dist/types/plugins/Hyperlink/utils.d.ts +0 -1
  322. package/dist/types/plugins/shared/utils.d.ts +1 -0
  323. package/package.json +2 -2
@@ -9,71 +9,71 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ INLINE_TYPES: function() {
13
+ return INLINE_TYPES;
14
+ },
12
15
  LINK_TYPES: function() {
13
16
  return LINK_TYPES;
14
17
  },
15
- isBlockSelected: function() {
16
- return isBlockSelected;
17
- },
18
- isRootLevel: function() {
19
- return isRootLevel;
20
- },
21
- getNodeEntryFromSelection: function() {
22
- return getNodeEntryFromSelection;
23
- },
24
- isNodeTypeSelected: function() {
25
- return isNodeTypeSelected;
26
- },
27
- moveToTheNextLine: function() {
28
- return moveToTheNextLine;
29
- },
30
- moveToTheNextChar: function() {
31
- return moveToTheNextChar;
18
+ focus: function() {
19
+ return focus;
32
20
  },
33
- insertEmptyParagraph: function() {
34
- return insertEmptyParagraph;
21
+ getAncestorPathFromSelection: function() {
22
+ return getAncestorPathFromSelection;
35
23
  },
36
24
  getElementFromCurrentSelection: function() {
37
25
  return getElementFromCurrentSelection;
38
26
  },
39
- isList: function() {
40
- return isList;
27
+ getNextNode: function() {
28
+ return getNextNode;
29
+ },
30
+ getNodeEntryFromSelection: function() {
31
+ return getNodeEntryFromSelection;
41
32
  },
42
33
  getTableSize: function() {
43
34
  return getTableSize;
44
35
  },
36
+ insertEmptyParagraph: function() {
37
+ return insertEmptyParagraph;
38
+ },
45
39
  insertLink: function() {
46
40
  return insertLink;
47
41
  },
48
- isLinkActive: function() {
49
- return isLinkActive;
42
+ isAtEndOfTextSelection: function() {
43
+ return isAtEndOfTextSelection;
50
44
  },
51
- unwrapLink: function() {
52
- return unwrapLink;
45
+ isBlockSelected: function() {
46
+ return isBlockSelected;
53
47
  },
54
- wrapLink: function() {
55
- return wrapLink;
48
+ isInlineOrText: function() {
49
+ return isInlineOrText;
56
50
  },
57
- getAncestorPathFromSelection: function() {
58
- return getAncestorPathFromSelection;
51
+ isLinkActive: function() {
52
+ return isLinkActive;
59
53
  },
60
- isAtEndOfTextSelection: function() {
61
- return isAtEndOfTextSelection;
54
+ isList: function() {
55
+ return isList;
62
56
  },
63
- getNextNode: function() {
64
- return getNextNode;
57
+ isNodeTypeSelected: function() {
58
+ return isNodeTypeSelected;
65
59
  },
66
- INLINE_TYPES: function() {
67
- return INLINE_TYPES;
60
+ isRootLevel: function() {
61
+ return isRootLevel;
68
62
  },
69
- isInlineOrText: function() {
70
- return isInlineOrText;
63
+ moveToTheNextChar: function() {
64
+ return moveToTheNextChar;
71
65
  },
72
- focus: function() {
73
- return focus;
66
+ moveToTheNextLine: function() {
67
+ return moveToTheNextLine;
74
68
  },
75
69
  toggleElement: function() {
76
70
  return toggleElement;
71
+ },
72
+ unwrapLink: function() {
73
+ return unwrapLink;
74
+ },
75
+ wrapLink: function() {
76
+ return wrapLink;
77
77
  }
78
78
  });
79
79
  const _richtexttypes = require("@contentful/rich-text-types");
@@ -145,7 +145,11 @@ function insertEmptyParagraph(editor, options) {
145
145
  function getElementFromCurrentSelection(editor) {
146
146
  if (!editor.selection) return [];
147
147
  return Array.from((0, _queries.getNodeEntries)(editor, {
148
- at: editor.selection,
148
+ /**
149
+ * editor.select is a Range, which includes anchor and focus, the beginning and the end of a selection
150
+ * when using only editor.selection.focus, we might get only the end of the selection, or where the text cursor is
151
+ * and in some cases getting the next element instead of the one we want
152
+ **/ at: editor.selection,
149
153
  match: (node)=>(0, _queries.isElement)(node)
150
154
  })).flat();
151
155
  }
@@ -185,11 +189,11 @@ function unwrapLink(editor) {
185
189
  match: (node)=>!(0, _queries.isEditor)(node) && (0, _queries.isElement)(node) && LINK_TYPES.includes(node.type)
186
190
  });
187
191
  }
188
- function wrapLink(editor, { text , url , target , type , path }) {
192
+ function wrapLink(editor, { text, url, target, type, path }) {
189
193
  if (isLinkActive(editor) && !path) {
190
194
  unwrapLink(editor);
191
195
  }
192
- const { selection } = editor;
196
+ const { selection } = editor;
193
197
  const isCollapsed = selection && (0, _queries.isRangeCollapsed)(selection);
194
198
  const link = {
195
199
  type,
@@ -210,6 +214,7 @@ function wrapLink(editor, { text , url , target , type , path }) {
210
214
  target
211
215
  };
212
216
  }
217
+ // TODO: always set the selection to the end of the inserted link
213
218
  if (path) {
214
219
  (0, _transforms.setNodes)(editor, link, {
215
220
  at: path
@@ -243,8 +248,9 @@ function getNextNode(editor) {
243
248
  const descendants = (0, _queries.getNodeDescendants)(editor, {
244
249
  from: editor.selection.focus.path
245
250
  });
251
+ // eslint-disable-next-line no-constant-condition -- TODO: explain this disable
246
252
  while(true){
247
- const { done , value } = descendants.next();
253
+ const { done, value } = descendants.next();
248
254
  if (done) {
249
255
  return null;
250
256
  }
@@ -257,20 +263,23 @@ function getNextNode(editor) {
257
263
  }
258
264
  const INLINE_TYPES = Object.values(_richtexttypes.INLINES);
259
265
  const isInlineOrText = (node)=>{
266
+ // either text or inline elements
260
267
  return (0, _queries.isText)(node) || (0, _queries.isElement)(node) && INLINE_TYPES.includes(node.type);
261
268
  };
262
269
  const focus = (editor)=>{
263
270
  const x = window.scrollX;
264
271
  const y = window.scrollY;
265
272
  (0, _misc.focusEditor)(editor);
273
+ // Safari has issues with `editor.focus({ preventScroll: true })`, it ignores the option `preventScroll`
266
274
  if (_environment.IS_SAFARI) {
267
275
  setTimeout(function() {
268
- window.scrollTo(x, y);
276
+ window.scrollTo(x, y); // restore position
269
277
  }, 0);
270
278
  }
271
279
  };
272
280
  function toggleElement(editor, options, editorOptions) {
273
281
  (0, _transforms.toggleNodeType)(editor, options, editorOptions);
282
+ // We must reset `data` from one element to another
274
283
  (0, _transforms.setNodes)(editor, {
275
284
  data: {}
276
285
  });
@@ -9,11 +9,11 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- IS_SAFARI: function() {
13
- return IS_SAFARI;
14
- },
15
12
  IS_CHROME: function() {
16
13
  return IS_CHROME;
14
+ },
15
+ IS_SAFARI: function() {
16
+ return IS_SAFARI;
17
17
  }
18
18
  });
19
19
  const IS_SAFARI = typeof navigator !== 'undefined' && /Version\/[\d.]+.*Safari/.test(navigator.userAgent);
@@ -1,3 +1,4 @@
1
+ // eslint-disable-next-line no-restricted-imports -- TODO: explain this disable
1
2
  "use strict";
2
3
  Object.defineProperty(exports, "__esModule", {
3
4
  value: true
@@ -12,14 +13,14 @@ _export(exports, {
12
13
  formatDate: function() {
13
14
  return formatDate;
14
15
  },
15
- formatTime: function() {
16
- return formatTime;
17
- },
18
16
  formatDateAndTime: function() {
19
17
  return formatDateAndTime;
18
+ },
19
+ formatTime: function() {
20
+ return formatTime;
20
21
  }
21
22
  });
22
- const _moment = _interop_require_default(require("moment"));
23
+ const _moment = /*#__PURE__*/ _interop_require_default(require("moment"));
23
24
  function _interop_require_default(obj) {
24
25
  return obj && obj.__esModule ? obj : {
25
26
  default: obj
@@ -1,16 +1,33 @@
1
- "use strict";
1
+ /* eslint-disable you-dont-need-lodash-underscore/find */ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "default", {
5
+ Object.defineProperty(exports, /**
6
+ * Given a field object and a rich text node type, return a list of allowed
7
+ * resources associated with the node type, based on that node type's
8
+ * `allowedResources` property.
9
+ *
10
+ * The navigation here is explained by the `nodes` validation having signature:
11
+ * { nodes: { [nodeType]: { allowedResources: AllowedResource[] } } }
12
+ *
13
+ * We defensively navigate through this object because
14
+ * 1) the field may not have a `validations` array,
15
+ * 2) the `validations` array may be empty,
16
+ * 3) the `validations` array may not have a `nodes` validation, and
17
+ * 4) the `nodes` validation may not validate the `nodeType`.
18
+ *
19
+ * @param {object} field
20
+ * @param {string} nodeType
21
+ * @returns {AllowedResource[]}
22
+ */ "default", {
6
23
  enumerable: true,
7
24
  get: function() {
8
25
  return getAllowedResourcesForNodeType;
9
26
  }
10
27
  });
11
- const _find = _interop_require_default(require("lodash/find"));
12
- const _flow = _interop_require_default(require("lodash/flow"));
13
- const _get = _interop_require_default(require("lodash/get"));
28
+ const _find = /*#__PURE__*/ _interop_require_default(require("lodash/find"));
29
+ const _flow = /*#__PURE__*/ _interop_require_default(require("lodash/flow"));
30
+ const _get = /*#__PURE__*/ _interop_require_default(require("lodash/get"));
14
31
  function _interop_require_default(obj) {
15
32
  return obj && obj.__esModule ? obj : {
16
33
  default: obj
@@ -1,16 +1,40 @@
1
- "use strict";
1
+ /* eslint-disable you-dont-need-lodash-underscore/find */ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- Object.defineProperty(exports, "default", {
5
+ Object.defineProperty(exports, /**
6
+ * Given a field object and a rich text node type, return a list of valid
7
+ * content type IDs associated with the node type, based on that node type's
8
+ * `linkContentType` validation.
9
+ *
10
+ * If there is no such validation or the validation is empty, return an empty
11
+ * array.
12
+ *
13
+ * The navigation here is explained by the `nodes` validation having signature:
14
+ * { nodes: { [nodeType]: validationObject[] } }
15
+ *
16
+ * We defensively navigate through this object because
17
+ * 1) the field may not have a `validations` array,
18
+ * 2) the `validations` array may be empty,
19
+ * 3) the `validations` array may not have a `nodes` validation,
20
+ * 4) the `nodes` validation may not validate the `nodeType`, and
21
+ * 5) the `nodeType` validations may not have a `linkContentType` validation.
22
+ *
23
+ * Note that passing an empty array will result in all possible content types
24
+ * being whitelisted.
25
+ *
26
+ * @param {object} field
27
+ * @param {string} nodeType
28
+ * @returns {string[]}
29
+ */ "default", {
6
30
  enumerable: true,
7
31
  get: function() {
8
32
  return getLinkedContentTypeIdsForNodeType;
9
33
  }
10
34
  });
11
- const _find = _interop_require_default(require("lodash/find"));
12
- const _flow = _interop_require_default(require("lodash/flow"));
13
- const _get = _interop_require_default(require("lodash/get"));
35
+ const _find = /*#__PURE__*/ _interop_require_default(require("lodash/find"));
36
+ const _flow = /*#__PURE__*/ _interop_require_default(require("lodash/flow"));
37
+ const _get = /*#__PURE__*/ _interop_require_default(require("lodash/get"));
14
38
  function _interop_require_default(obj) {
15
39
  return obj && obj.__esModule ? obj : {
16
40
  default: obj
@@ -9,20 +9,20 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- document: function() {
13
- return document;
14
- },
15
12
  block: function() {
16
13
  return block;
17
14
  },
15
+ document: function() {
16
+ return document;
17
+ },
18
18
  inline: function() {
19
19
  return inline;
20
20
  },
21
- text: function() {
22
- return text;
23
- },
24
21
  mark: function() {
25
22
  return mark;
23
+ },
24
+ text: function() {
25
+ return text;
26
26
  }
27
27
  });
28
28
  const document = (...content)=>({
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "watchCurrentSlide", {
8
8
  return watchCurrentSlide;
9
9
  }
10
10
  });
11
- const _noop = _interop_require_default(require("lodash/noop"));
11
+ const _noop = /*#__PURE__*/ _interop_require_default(require("lodash/noop"));
12
12
  function _interop_require_default(obj) {
13
13
  return obj && obj.__esModule ? obj : {
14
14
  default: obj
@@ -23,26 +23,34 @@ function watchCurrentSlide(navigator) {
23
23
  wasClosed: wasSlideClosed,
24
24
  isActive: !wasSlideClosed && lastSlideLevel === initialSlideLevel
25
25
  });
26
- const off = navigator.onSlideInNavigation(({ oldSlideLevel , newSlideLevel })=>{
26
+ const off = navigator.onSlideInNavigation(({ oldSlideLevel, newSlideLevel })=>{
27
27
  if (initialSlideLevel === undefined) {
28
28
  initialSlideLevel = oldSlideLevel;
29
29
  }
30
30
  lastSlideLevel = newSlideLevel;
31
31
  if (newSlideLevel < initialSlideLevel) {
32
32
  wasSlideClosed = true;
33
- off();
33
+ off(); // No more point in watching, slide got closed.
34
34
  onActiveCallbacks.clear();
35
35
  }
36
36
  if (status().isActive && newSlideLevel !== oldSlideLevel) {
37
37
  onActiveCallbacks.forEach((cb)=>cb());
38
38
  }
39
39
  });
40
- function unwatch() {
40
+ /**
41
+ * Call to unsubscribe from navigator events when the watcher is no longer
42
+ * needed.
43
+ */ function unwatch() {
41
44
  off();
42
45
  onActiveCallbacks.clear();
43
46
  }
44
- function onActive(cb) {
45
- if (wasSlideClosed) return _noop.default;
47
+ /**
48
+ * Fires immediately when the slide is currently active, or at the point when
49
+ * it becomes active again, if there are slides on top that get closed. Does not
50
+ * fire when the observed slide gets closed, and then re-opened through browser
51
+ * back, as this technically opens a new slide and editor instance.
52
+ */ function onActive(cb) {
53
+ if (wasSlideClosed) return _noop.default; // Can't re-activate already closed slide.
46
54
  if (status().isActive) {
47
55
  cb();
48
56
  }
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- const _cloneDeep = _interop_require_default(require("lodash/cloneDeep"));
6
- const _mitt = _interop_require_default(require("mitt"));
5
+ const _cloneDeep = /*#__PURE__*/ _interop_require_default(require("lodash/cloneDeep"));
6
+ const _mitt = /*#__PURE__*/ _interop_require_default(require("mitt"));
7
7
  const _sdkNavigatorSlideIn = require("./sdkNavigatorSlideIn");
8
8
  function _interop_require_default(obj) {
9
9
  return obj && obj.__esModule ? obj : {
@@ -204,6 +204,7 @@ describe('watchCurrentSlide().unwatch()', ()=>{
204
204
  newSlideLevel: 0
205
205
  });
206
206
  expect(spy).toHaveBeenCalledTimes(0);
207
+ // Demonstrate that normally this would fire an event if it wasn't for the unwatch()
207
208
  expect(spy2).toHaveBeenCalledTimes(1);
208
209
  });
209
210
  });
@@ -10,14 +10,17 @@ Object.defineProperty(exports, "toSlateValue", {
10
10
  });
11
11
  const _contentfulslatejsadapter = require("@contentful/contentful-slatejs-adapter");
12
12
  const _richtexttypes = require("@contentful/rich-text-types");
13
- const _Schema = _interop_require_default(require("../constants/Schema"));
13
+ const _Schema = /*#__PURE__*/ _interop_require_default(require("../constants/Schema"));
14
14
  function _interop_require_default(obj) {
15
15
  return obj && obj.__esModule ? obj : {
16
16
  default: obj
17
17
  };
18
18
  }
19
19
  const isTextElement = (node)=>'text' in node;
20
- function sanitizeIncomingSlateDoc(nodes = []) {
20
+ /**
21
+ * Ensures all nodes have a child leaf text element. This should be handled by
22
+ * Slate but its behavior has proven to be buggy and unpredictable.
23
+ */ function sanitizeIncomingSlateDoc(nodes = []) {
21
24
  return nodes.map((node)=>{
22
25
  if (isTextElement(node)) {
23
26
  return node;
@@ -40,11 +43,19 @@ function sanitizeIncomingSlateDoc(nodes = []) {
40
43
  });
41
44
  }
42
45
  const toSlateValue = (doc)=>{
43
- const hasContent = (doc)=>{
46
+ /**
47
+ * For legacy reasons, a document may not have any content at all
48
+ * e.g:
49
+ *
50
+ * {nodeType: document, data: {}, content: []}
51
+ *
52
+ * Rendering such document will break the Slate editor
53
+ */ const hasContent = (doc)=>{
44
54
  return (doc?.content || []).length > 0;
45
55
  };
46
56
  const slateDoc = (0, _contentfulslatejsadapter.toSlatejsDocument)({
47
57
  document: doc && hasContent(doc) ? doc : _richtexttypes.EMPTY_DOCUMENT,
58
+ // TODO: get rid of schema, https://github.com/contentful/field-editors/pull/1065#discussion_r826723248
48
59
  schema: _Schema.default
49
60
  });
50
61
  return sanitizeIncomingSlateDoc(slateDoc);
@@ -9,20 +9,20 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- transformRemove: function() {
13
- return transformRemove;
12
+ transformLift: function() {
13
+ return transformLift;
14
14
  },
15
15
  transformParagraphs: function() {
16
16
  return transformParagraphs;
17
17
  },
18
+ transformRemove: function() {
19
+ return transformRemove;
20
+ },
18
21
  transformUnwrap: function() {
19
22
  return transformUnwrap;
20
23
  },
21
24
  transformWrapIn: function() {
22
25
  return transformWrapIn;
23
- },
24
- transformLift: function() {
25
- return transformLift;
26
26
  }
27
27
  });
28
28
  const _transforms = require("../internal/transforms");
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ /* eslint-disable you-dont-need-lodash-underscore/find */ "use strict";
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
@@ -9,26 +9,26 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- VALIDATIONS: function() {
13
- return VALIDATIONS;
14
- },
15
12
  DEFAULT_ENABLED_NODE_TYPES: function() {
16
13
  return DEFAULT_ENABLED_NODE_TYPES;
17
14
  },
18
15
  VALIDATABLE_NODE_TYPES: function() {
19
16
  return VALIDATABLE_NODE_TYPES;
20
17
  },
21
- isNodeTypeEnabled: function() {
22
- return isNodeTypeEnabled;
18
+ VALIDATIONS: function() {
19
+ return VALIDATIONS;
23
20
  },
24
21
  isMarkEnabled: function() {
25
22
  return isMarkEnabled;
23
+ },
24
+ isNodeTypeEnabled: function() {
25
+ return isNodeTypeEnabled;
26
26
  }
27
27
  });
28
28
  const _richtexttypes = require("@contentful/rich-text-types");
29
- const _find = _interop_require_default(require("lodash/find"));
30
- const _flow = _interop_require_default(require("lodash/flow"));
31
- const _get = _interop_require_default(require("lodash/get"));
29
+ const _find = /*#__PURE__*/ _interop_require_default(require("lodash/find"));
30
+ const _flow = /*#__PURE__*/ _interop_require_default(require("lodash/flow"));
31
+ const _get = /*#__PURE__*/ _interop_require_default(require("lodash/get"));
32
32
  function _interop_require_default(obj) {
33
33
  return obj && obj.__esModule ? obj : {
34
34
  default: obj
@@ -44,9 +44,12 @@ const DEFAULT_ENABLED_NODE_TYPES = [
44
44
  'text'
45
45
  ];
46
46
  const VALIDATABLE_NODE_TYPES = [].concat(_richtexttypes.TOP_LEVEL_BLOCKS).filter((type)=>type !== _richtexttypes.BLOCKS.PARAGRAPH).concat(Object.values(_richtexttypes.INLINES));
47
+ // TODO: Memoize
47
48
  const getRichTextValidation = (field, validationType)=>(0, _flow.default)((v)=>(0, _find.default)(v, validationType), (v)=>(0, _get.default)(v, validationType))(field.validations);
48
49
  const isFormattingOptionEnabled = (field, validationType, nodeTypeOrMark)=>{
49
50
  const enabledFormattings = getRichTextValidation(field, validationType);
51
+ // TODO: In the future, validations will always be opt-in. In that case
52
+ // we don't need this step.
50
53
  if (enabledFormattings === undefined) {
51
54
  return true;
52
55
  }
package/dist/cjs/index.js CHANGED
@@ -9,12 +9,12 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- RichTextEditor: function() {
13
- return _RichTextEditor.default;
14
- },
15
12
  ConnectedRichTextEditor: function() {
16
13
  return _RichTextEditor.ConnectedRichTextEditor;
17
14
  },
15
+ RichTextEditor: function() {
16
+ return _RichTextEditor.default;
17
+ },
18
18
  openRichTextDialog: function() {
19
19
  return _openRichTextDialog.openRichTextDialog;
20
20
  },
@@ -22,7 +22,7 @@ _export(exports, {
22
22
  return _renderRichTextDialog.renderRichTextDialog;
23
23
  }
24
24
  });
25
- const _RichTextEditor = _interop_require_wildcard(require("./RichTextEditor"));
25
+ const _RichTextEditor = /*#__PURE__*/ _interop_require_wildcard(require("./RichTextEditor"));
26
26
  const _openRichTextDialog = require("./dialogs/openRichTextDialog");
27
27
  const _renderRichTextDialog = require("./dialogs/renderRichTextDialog");
28
28
  function _getRequireWildcardCache(nodeInterop) {
@@ -46,7 +46,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
46
46
  if (cache && cache.has(obj)) {
47
47
  return cache.get(obj);
48
48
  }
49
- var newObj = {};
49
+ var newObj = {
50
+ __proto__: null
51
+ };
50
52
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
51
53
  for(var key in obj){
52
54
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "ELEMENT_DEFAULT", {
8
8
  return ELEMENT_DEFAULT;
9
9
  }
10
10
  });
11
- const _platecommon = _interop_require_wildcard(require("@udecode/plate-common"));
11
+ const _platecommon = /*#__PURE__*/ _interop_require_wildcard(require("@udecode/plate-common"));
12
12
  function _getRequireWildcardCache(nodeInterop) {
13
13
  if (typeof WeakMap !== "function") return null;
14
14
  var cacheBabelInterop = new WeakMap();
@@ -30,7 +30,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
30
30
  if (cache && cache.has(obj)) {
31
31
  return cache.get(obj);
32
32
  }
33
- var newObj = {};
33
+ var newObj = {
34
+ __proto__: null
35
+ };
34
36
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
35
37
  for(var key in obj){
36
38
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -9,9 +9,6 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
- useReadOnly: function() {
13
- return useReadOnly;
14
- },
15
12
  usePlateEditorRef: function() {
16
13
  return usePlateEditorRef;
17
14
  },
@@ -20,10 +17,13 @@ _export(exports, {
20
17
  },
21
18
  usePlateSelectors: function() {
22
19
  return usePlateSelectors;
20
+ },
21
+ useReadOnly: function() {
22
+ return useReadOnly;
23
23
  }
24
24
  });
25
- const _platecommon = _interop_require_wildcard(require("@udecode/plate-common"));
26
- const _slatereact = _interop_require_wildcard(require("slate-react"));
25
+ const _platecommon = /*#__PURE__*/ _interop_require_wildcard(require("@udecode/plate-common"));
26
+ const _slatereact = /*#__PURE__*/ _interop_require_wildcard(require("slate-react"));
27
27
  function _getRequireWildcardCache(nodeInterop) {
28
28
  if (typeof WeakMap !== "function") return null;
29
29
  var cacheBabelInterop = new WeakMap();
@@ -45,7 +45,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
45
45
  if (cache && cache.has(obj)) {
46
46
  return cache.get(obj);
47
47
  }
48
- var newObj = {};
48
+ var newObj = {
49
+ __proto__: null
50
+ };
49
51
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
50
52
  for(var key in obj){
51
53
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -9,29 +9,29 @@ function _export(target, all) {
9
9
  });
10
10
  }
11
11
  _export(exports, {
12
+ blurEditor: function() {
13
+ return blurEditor;
14
+ },
12
15
  createPlateEditor: function() {
13
16
  return createPlateEditor;
14
17
  },
15
- normalizeInitialValue: function() {
16
- return normalizeInitialValue;
17
- },
18
18
  focusEditor: function() {
19
19
  return focusEditor;
20
20
  },
21
- blurEditor: function() {
22
- return blurEditor;
23
- },
24
- selectEditor: function() {
25
- return selectEditor;
26
- },
27
21
  fromDOMPoint: function() {
28
22
  return fromDOMPoint;
29
23
  },
30
24
  mockPlugin: function() {
31
25
  return mockPlugin;
26
+ },
27
+ normalizeInitialValue: function() {
28
+ return normalizeInitialValue;
29
+ },
30
+ selectEditor: function() {
31
+ return selectEditor;
32
32
  }
33
33
  });
34
- const _platecommon = _interop_require_wildcard(require("@udecode/plate-common"));
34
+ const _platecommon = /*#__PURE__*/ _interop_require_wildcard(require("@udecode/plate-common"));
35
35
  const _transforms = require("./transforms");
36
36
  function _getRequireWildcardCache(nodeInterop) {
37
37
  if (typeof WeakMap !== "function") return null;
@@ -54,7 +54,9 @@ function _interop_require_wildcard(obj, nodeInterop) {
54
54
  if (cache && cache.has(obj)) {
55
55
  return cache.get(obj);
56
56
  }
57
- var newObj = {};
57
+ var newObj = {
58
+ __proto__: null
59
+ };
58
60
  var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
59
61
  for(var key in obj){
60
62
  if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
@@ -101,5 +103,6 @@ const fromDOMPoint = (editor, domPoint, opts = {
101
103
  return _platecommon.toSlatePoint(editor, domPoint, opts);
102
104
  };
103
105
  const mockPlugin = (plugin)=>{
104
- return _platecommon.mockPlugin(plugin);
106
+ return _platecommon.mockPlugin(// TODO check if there is a way around this ugly casting
107
+ plugin);
105
108
  };