react-native-enriched-html 1.0.0 → 1.0.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 (272) hide show
  1. package/android/src/main/java/com/swmansion/enriched/common/EnrichedSpanFlags.kt +39 -0
  2. package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedParser.java +43 -20
  3. package/android/src/main/java/com/swmansion/enriched/common/parser/EnrichedSpanFactory.kt +1 -0
  4. package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextSpanFactory.kt +1 -0
  5. package/android/src/main/java/com/swmansion/enriched/text/EnrichedTextView.kt +2 -1
  6. package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputSpannableFactory.kt +2 -1
  7. package/android/src/main/java/com/swmansion/enriched/textinput/EnrichedTextInputView.kt +8 -5
  8. package/android/src/main/java/com/swmansion/enriched/textinput/events/MentionHandler.kt +12 -2
  9. package/android/src/main/java/com/swmansion/enriched/textinput/events/OnMentionEvent.kt +6 -0
  10. package/android/src/main/java/com/swmansion/enriched/textinput/styles/AlignmentStyles.kt +6 -7
  11. package/android/src/main/java/com/swmansion/enriched/textinput/styles/InlineStyles.kt +13 -1
  12. package/android/src/main/java/com/swmansion/enriched/textinput/styles/ListStyles.kt +4 -3
  13. package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParagraphStyles.kt +4 -3
  14. package/android/src/main/java/com/swmansion/enriched/textinput/styles/ParametrizedStyles.kt +38 -11
  15. package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSelection.kt +2 -0
  16. package/android/src/main/java/com/swmansion/enriched/textinput/utils/EnrichedSpannable.kt +2 -1
  17. package/android/src/main/java/com/swmansion/enriched/textinput/utils/Utils.kt +2 -1
  18. package/cpp/parser/GumboNormalizer.c +61 -3
  19. package/cpp/tests/GumboParserTest.cpp +54 -0
  20. package/ios/EnrichedTextInputView.mm +37 -25
  21. package/ios/extensions/LayoutManagerExtension.mm +73 -62
  22. package/ios/extensions/StringExtension.mm +75 -0
  23. package/ios/htmlParser/HtmlParser.h +4 -1
  24. package/ios/htmlParser/HtmlParser.mm +23 -5
  25. package/ios/inputHtmlParser/InputHtmlParser.mm +6 -3
  26. package/ios/interfaces/StyleHeaders.h +4 -0
  27. package/ios/styles/LinkStyle.mm +20 -34
  28. package/ios/styles/MentionStyle.mm +55 -4
  29. package/ios/textHtmlParser/TextHtmlParser.mm +2 -1
  30. package/ios/utils/ParagraphAttributesUtils.mm +7 -0
  31. package/lib/module/index.js +1 -0
  32. package/lib/module/index.js.map +1 -1
  33. package/lib/module/utils/expandMentionStylesForIndicators.js +2 -3
  34. package/lib/module/utils/expandMentionStylesForIndicators.js.map +1 -1
  35. package/lib/module/utils/normalizeHtmlStyle.js +1 -1
  36. package/lib/module/utils/normalizeHtmlStyle.js.map +1 -1
  37. package/lib/module/web/EnrichedText.css +343 -0
  38. package/lib/module/web/EnrichedText.js +55 -0
  39. package/lib/module/web/EnrichedText.js.map +1 -0
  40. package/lib/module/web/EnrichedTextInput.js +54 -52
  41. package/lib/module/web/EnrichedTextInput.js.map +1 -1
  42. package/lib/module/web/constants/brokenImageGlyph.js +9 -0
  43. package/lib/module/web/constants/brokenImageGlyph.js.map +1 -0
  44. package/lib/module/web/constants/classNames.js +5 -0
  45. package/lib/module/web/constants/classNames.js.map +1 -0
  46. package/lib/module/web/emitLinkDetected.js +12 -0
  47. package/lib/module/web/emitLinkDetected.js.map +1 -0
  48. package/lib/module/web/formats/EnrichedBlockquote.js +1 -1
  49. package/lib/module/web/formats/EnrichedBlockquote.js.map +1 -1
  50. package/lib/module/web/formats/EnrichedCheckboxList.js +2 -2
  51. package/lib/module/web/formats/EnrichedCheckboxList.js.map +1 -1
  52. package/lib/module/web/formats/EnrichedCodeBlock.js +1 -1
  53. package/lib/module/web/formats/EnrichedCodeBlock.js.map +1 -1
  54. package/lib/module/web/formats/EnrichedHeading.js +1 -1
  55. package/lib/module/web/formats/EnrichedHeading.js.map +1 -1
  56. package/lib/module/web/formats/EnrichedImageNodeView.js +1 -1
  57. package/lib/module/web/formats/EnrichedImageNodeView.js.map +1 -1
  58. package/lib/module/web/formats/EnrichedLink.js +43 -3
  59. package/lib/module/web/formats/EnrichedLink.js.map +1 -1
  60. package/lib/module/web/formats/EnrichedOrderedList.js +2 -2
  61. package/lib/module/web/formats/EnrichedOrderedList.js.map +1 -1
  62. package/lib/module/web/formats/EnrichedTextAlign.js +82 -0
  63. package/lib/module/web/formats/EnrichedTextAlign.js.map +1 -0
  64. package/lib/module/web/formats/EnrichedUnorderedList.js +2 -2
  65. package/lib/module/web/formats/EnrichedUnorderedList.js.map +1 -1
  66. package/lib/module/web/formats/applyWrappingListToSelection.js +3 -2
  67. package/lib/module/web/formats/applyWrappingListToSelection.js.map +1 -1
  68. package/lib/module/web/formats/formatRules.js +39 -3
  69. package/lib/module/web/formats/formatRules.js.map +1 -1
  70. package/lib/module/web/formats/listKeyboard.js +4 -1
  71. package/lib/module/web/formats/listKeyboard.js.map +1 -1
  72. package/lib/module/web/normalization/checkboxHtmlNormalizer.js.map +1 -0
  73. package/lib/module/web/normalization/htmlNormalizer.js +514 -0
  74. package/lib/module/web/normalization/htmlNormalizer.js.map +1 -0
  75. package/lib/module/web/normalization/prepareHtmlForWeb.js +78 -0
  76. package/lib/module/web/normalization/prepareHtmlForWeb.js.map +1 -0
  77. package/lib/module/web/{tiptapHtmlNormalizer.js → normalization/tiptapHtmlNormalizer.js} +6 -2
  78. package/lib/module/web/normalization/tiptapHtmlNormalizer.js.map +1 -0
  79. package/lib/module/web/pmPlugins/AutolinkPlugin/autolinkRegex.js +27 -0
  80. package/lib/module/web/pmPlugins/AutolinkPlugin/autolinkRegex.js.map +1 -0
  81. package/lib/module/web/pmPlugins/AutolinkPlugin/index.js +178 -0
  82. package/lib/module/web/pmPlugins/AutolinkPlugin/index.js.map +1 -0
  83. package/lib/module/web/pmPlugins/MentionPlugin/index.js +1 -1
  84. package/lib/module/web/pmPlugins/MentionPlugin/index.js.map +1 -1
  85. package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js +23 -4
  86. package/lib/module/web/pmPlugins/MentionPlugin/makeMentionPluginState.js.map +1 -1
  87. package/lib/module/web/pmPlugins/MentionPlugin/setMention.js +17 -18
  88. package/lib/module/web/pmPlugins/MentionPlugin/setMention.js.map +1 -1
  89. package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.js +105 -0
  90. package/lib/module/web/pmPlugins/MentionPlugin/useMentionEvents.js.map +1 -0
  91. package/lib/module/web/pmPlugins/ShortcutPlugin.js +11 -0
  92. package/lib/module/web/pmPlugins/ShortcutPlugin.js.map +1 -1
  93. package/lib/module/web/pmPlugins/StrictMarksPlugin.js +2 -0
  94. package/lib/module/web/pmPlugins/StrictMarksPlugin.js.map +1 -1
  95. package/lib/module/web/pmPlugins/StripBoldInStyledHeadingsPlugin.js.map +1 -1
  96. package/lib/module/web/sanitization/htmlSanitizer.js +10 -0
  97. package/lib/module/web/sanitization/htmlSanitizer.js.map +1 -0
  98. package/lib/module/web/styleConversion/buildMentionRulesCSS.js +12 -6
  99. package/lib/module/web/styleConversion/buildMentionRulesCSS.js.map +1 -1
  100. package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js +159 -0
  101. package/lib/module/web/styleConversion/enrichedBaseStyleToCSSProperties.js.map +1 -0
  102. package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js +3 -155
  103. package/lib/module/web/styleConversion/enrichedInputStyleToCSSProperties.js.map +1 -1
  104. package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js +44 -0
  105. package/lib/module/web/styleConversion/enrichedTextStyleToCSSProperties.js.map +1 -0
  106. package/lib/module/web/styleConversion/{enrichedInputThemingToCSSProperties.js → enrichedThemingToCSSProperties.js} +3 -3
  107. package/lib/module/web/styleConversion/enrichedThemingToCSSProperties.js.map +1 -0
  108. package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js +87 -64
  109. package/lib/module/web/styleConversion/htmlStyleToCSSVariables.js.map +1 -1
  110. package/lib/module/web/styleConversion/inlineImageCSSVariables.js +7 -0
  111. package/lib/module/web/styleConversion/inlineImageCSSVariables.js.map +1 -0
  112. package/lib/module/web/useImageErrorFallback.js +33 -0
  113. package/lib/module/web/useImageErrorFallback.js.map +1 -0
  114. package/lib/module/web/useOnChangeHtml.js +1 -1
  115. package/lib/module/web/useOnChangeHtml.js.map +1 -1
  116. package/lib/module/web/useOnChangeState.js +6 -3
  117. package/lib/module/web/useOnChangeState.js.map +1 -1
  118. package/lib/module/web/useOnLinkDetected.js +32 -45
  119. package/lib/module/web/useOnLinkDetected.js.map +1 -1
  120. package/lib/module/web/usePressInteractions.js +19 -0
  121. package/lib/module/web/usePressInteractions.js.map +1 -0
  122. package/lib/module/web/useStableRef.js +13 -0
  123. package/lib/module/web/useStableRef.js.map +1 -0
  124. package/lib/typescript/src/index.d.ts +1 -0
  125. package/lib/typescript/src/index.d.ts.map +1 -1
  126. package/lib/typescript/src/native/EnrichedText.d.ts +1 -1
  127. package/lib/typescript/src/native/EnrichedText.d.ts.map +1 -1
  128. package/lib/typescript/src/native/EnrichedTextInput.d.ts +1 -1
  129. package/lib/typescript/src/native/EnrichedTextInput.d.ts.map +1 -1
  130. package/lib/typescript/src/types.d.ts +1 -1
  131. package/lib/typescript/src/types.d.ts.map +1 -1
  132. package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts +1 -1
  133. package/lib/typescript/src/utils/expandMentionStylesForIndicators.d.ts.map +1 -1
  134. package/lib/typescript/src/utils/normalizeHtmlStyle.d.ts.map +1 -1
  135. package/lib/typescript/src/web/EnrichedText.d.ts +4 -0
  136. package/lib/typescript/src/web/EnrichedText.d.ts.map +1 -0
  137. package/lib/typescript/src/web/EnrichedTextInput.d.ts +2 -2
  138. package/lib/typescript/src/web/EnrichedTextInput.d.ts.map +1 -1
  139. package/lib/typescript/src/web/constants/brokenImageGlyph.d.ts +3 -0
  140. package/lib/typescript/src/web/constants/brokenImageGlyph.d.ts.map +1 -0
  141. package/lib/typescript/src/web/constants/classNames.d.ts +3 -0
  142. package/lib/typescript/src/web/constants/classNames.d.ts.map +1 -0
  143. package/lib/typescript/src/web/emitLinkDetected.d.ts +10 -0
  144. package/lib/typescript/src/web/emitLinkDetected.d.ts.map +1 -0
  145. package/lib/typescript/src/web/formats/EnrichedBlockquote.d.ts.map +1 -1
  146. package/lib/typescript/src/web/formats/EnrichedCheckboxList.d.ts.map +1 -1
  147. package/lib/typescript/src/web/formats/EnrichedCodeBlock.d.ts.map +1 -1
  148. package/lib/typescript/src/web/formats/EnrichedHeading.d.ts.map +1 -1
  149. package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts +1 -1
  150. package/lib/typescript/src/web/formats/EnrichedImageNodeView.d.ts.map +1 -1
  151. package/lib/typescript/src/web/formats/EnrichedLink.d.ts +4 -1
  152. package/lib/typescript/src/web/formats/EnrichedLink.d.ts.map +1 -1
  153. package/lib/typescript/src/web/formats/EnrichedOrderedList.d.ts.map +1 -1
  154. package/lib/typescript/src/web/formats/EnrichedTextAlign.d.ts +2 -0
  155. package/lib/typescript/src/web/formats/EnrichedTextAlign.d.ts.map +1 -0
  156. package/lib/typescript/src/web/formats/EnrichedUnorderedList.d.ts.map +1 -1
  157. package/lib/typescript/src/web/formats/applyWrappingListToSelection.d.ts.map +1 -1
  158. package/lib/typescript/src/web/formats/formatRules.d.ts +3 -1
  159. package/lib/typescript/src/web/formats/formatRules.d.ts.map +1 -1
  160. package/lib/typescript/src/web/formats/listKeyboard.d.ts.map +1 -1
  161. package/lib/typescript/src/web/normalization/checkboxHtmlNormalizer.d.ts.map +1 -0
  162. package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts +2 -0
  163. package/lib/typescript/src/web/normalization/htmlNormalizer.d.ts.map +1 -0
  164. package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts +2 -0
  165. package/lib/typescript/src/web/normalization/prepareHtmlForWeb.d.ts.map +1 -0
  166. package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.d.ts +3 -0
  167. package/lib/typescript/src/web/normalization/tiptapHtmlNormalizer.d.ts.map +1 -0
  168. package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.d.ts +7 -0
  169. package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.d.ts.map +1 -0
  170. package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.d.ts +8 -0
  171. package/lib/typescript/src/web/pmPlugins/AutolinkPlugin/index.d.ts.map +1 -0
  172. package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts +1 -1
  173. package/lib/typescript/src/web/pmPlugins/MentionPlugin/index.d.ts.map +1 -1
  174. package/lib/typescript/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.d.ts.map +1 -1
  175. package/lib/typescript/src/web/pmPlugins/MentionPlugin/setMention.d.ts.map +1 -1
  176. package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.d.ts +4 -0
  177. package/lib/typescript/src/web/pmPlugins/MentionPlugin/useMentionEvents.d.ts.map +1 -0
  178. package/lib/typescript/src/web/pmPlugins/ShortcutPlugin.d.ts.map +1 -1
  179. package/lib/typescript/src/web/pmPlugins/StrictMarksPlugin.d.ts.map +1 -1
  180. package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts +6 -1
  181. package/lib/typescript/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.d.ts.map +1 -1
  182. package/lib/typescript/src/web/sanitization/htmlSanitizer.d.ts +2 -0
  183. package/lib/typescript/src/web/sanitization/htmlSanitizer.d.ts.map +1 -0
  184. package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts +2 -2
  185. package/lib/typescript/src/web/styleConversion/buildMentionRulesCSS.d.ts.map +1 -1
  186. package/lib/typescript/src/web/styleConversion/enrichedBaseStyleToCSSProperties.d.ts +8 -0
  187. package/lib/typescript/src/web/styleConversion/enrichedBaseStyleToCSSProperties.d.ts.map +1 -0
  188. package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts +2 -5
  189. package/lib/typescript/src/web/styleConversion/enrichedInputStyleToCSSProperties.d.ts.map +1 -1
  190. package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts +4 -0
  191. package/lib/typescript/src/web/styleConversion/enrichedTextStyleToCSSProperties.d.ts.map +1 -0
  192. package/lib/typescript/src/web/styleConversion/{enrichedInputThemingToCSSProperties.d.ts → enrichedThemingToCSSProperties.d.ts} +1 -1
  193. package/lib/typescript/src/web/styleConversion/enrichedThemingToCSSProperties.d.ts.map +1 -0
  194. package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts +5 -4
  195. package/lib/typescript/src/web/styleConversion/htmlStyleToCSSVariables.d.ts.map +1 -1
  196. package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.d.ts +3 -0
  197. package/lib/typescript/src/web/styleConversion/inlineImageCSSVariables.d.ts.map +1 -0
  198. package/lib/typescript/src/web/useImageErrorFallback.d.ts +3 -0
  199. package/lib/typescript/src/web/useImageErrorFallback.d.ts.map +1 -0
  200. package/lib/typescript/src/web/useOnChangeState.d.ts.map +1 -1
  201. package/lib/typescript/src/web/useOnLinkDetected.d.ts +2 -2
  202. package/lib/typescript/src/web/useOnLinkDetected.d.ts.map +1 -1
  203. package/lib/typescript/src/web/usePressInteractions.d.ts +2 -0
  204. package/lib/typescript/src/web/usePressInteractions.d.ts.map +1 -0
  205. package/lib/typescript/src/web/useStableRef.d.ts +3 -0
  206. package/lib/typescript/src/web/useStableRef.d.ts.map +1 -0
  207. package/package.json +54 -28
  208. package/src/index.tsx +1 -0
  209. package/src/types.ts +5 -3
  210. package/src/utils/expandMentionStylesForIndicators.ts +3 -3
  211. package/src/utils/normalizeHtmlStyle.ts +2 -1
  212. package/src/web/EnrichedText.css +343 -0
  213. package/src/web/EnrichedText.tsx +82 -0
  214. package/src/web/EnrichedTextInput.tsx +69 -55
  215. package/src/web/constants/brokenImageGlyph.ts +7 -0
  216. package/src/web/constants/classNames.ts +2 -0
  217. package/src/web/emitLinkDetected.ts +29 -0
  218. package/src/web/formats/EnrichedBlockquote.ts +2 -1
  219. package/src/web/formats/EnrichedCheckboxList.ts +5 -2
  220. package/src/web/formats/EnrichedCodeBlock.ts +2 -1
  221. package/src/web/formats/EnrichedHeading.ts +2 -1
  222. package/src/web/formats/EnrichedImageNodeView.tsx +1 -3
  223. package/src/web/formats/EnrichedLink.ts +59 -4
  224. package/src/web/formats/EnrichedOrderedList.ts +5 -2
  225. package/src/web/formats/EnrichedTextAlign.ts +88 -0
  226. package/src/web/formats/EnrichedUnorderedList.ts +5 -2
  227. package/src/web/formats/applyWrappingListToSelection.ts +4 -4
  228. package/src/web/formats/formatRules.ts +48 -4
  229. package/src/web/formats/listKeyboard.ts +6 -1
  230. package/src/web/normalization/htmlNormalizer.ts +656 -0
  231. package/src/web/normalization/prepareHtmlForWeb.ts +93 -0
  232. package/src/web/{tiptapHtmlNormalizer.ts → normalization/tiptapHtmlNormalizer.ts} +12 -2
  233. package/src/web/pmPlugins/AutolinkPlugin/autolinkRegex.ts +43 -0
  234. package/src/web/pmPlugins/AutolinkPlugin/index.ts +274 -0
  235. package/src/web/pmPlugins/MentionPlugin/index.ts +1 -1
  236. package/src/web/pmPlugins/MentionPlugin/makeMentionPluginState.ts +32 -5
  237. package/src/web/pmPlugins/MentionPlugin/setMention.ts +19 -29
  238. package/src/web/pmPlugins/MentionPlugin/useMentionEvents.ts +114 -0
  239. package/src/web/pmPlugins/ShortcutPlugin.ts +7 -0
  240. package/src/web/pmPlugins/StrictMarksPlugin.ts +3 -0
  241. package/src/web/pmPlugins/StripBoldInStyledHeadingsPlugin.ts +41 -36
  242. package/src/web/sanitization/htmlSanitizer.ts +8 -0
  243. package/src/web/styleConversion/buildMentionRulesCSS.ts +30 -11
  244. package/src/web/styleConversion/enrichedBaseStyleToCSSProperties.ts +228 -0
  245. package/src/web/styleConversion/enrichedInputStyleToCSSProperties.ts +6 -217
  246. package/src/web/styleConversion/enrichedTextStyleToCSSProperties.ts +53 -0
  247. package/src/web/styleConversion/{enrichedInputThemingToCSSProperties.ts → enrichedThemingToCSSProperties.ts} +4 -4
  248. package/src/web/styleConversion/htmlStyleToCSSVariables.ts +121 -70
  249. package/src/web/styleConversion/inlineImageCSSVariables.ts +6 -0
  250. package/src/web/useImageErrorFallback.ts +37 -0
  251. package/src/web/useOnChangeHtml.ts +1 -1
  252. package/src/web/useOnChangeState.ts +7 -5
  253. package/src/web/useOnLinkDetected.ts +38 -50
  254. package/src/web/usePressInteractions.tsx +22 -0
  255. package/src/web/useStableRef.ts +12 -0
  256. package/lib/module/web/EnrichedTextInput.css +0 -201
  257. package/lib/module/web/checkboxHtmlNormalizer.js.map +0 -1
  258. package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js +0 -100
  259. package/lib/module/web/pmPlugins/MentionPlugin/subscribeMentionEvents.js.map +0 -1
  260. package/lib/module/web/styleConversion/enrichedInputThemingToCSSProperties.js.map +0 -1
  261. package/lib/module/web/tiptapHtmlNormalizer.js.map +0 -1
  262. package/lib/typescript/src/web/checkboxHtmlNormalizer.d.ts.map +0 -1
  263. package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts +0 -4
  264. package/lib/typescript/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.d.ts.map +0 -1
  265. package/lib/typescript/src/web/styleConversion/enrichedInputThemingToCSSProperties.d.ts.map +0 -1
  266. package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts +0 -3
  267. package/lib/typescript/src/web/tiptapHtmlNormalizer.d.ts.map +0 -1
  268. package/src/web/EnrichedTextInput.css +0 -201
  269. package/src/web/pmPlugins/MentionPlugin/subscribeMentionEvents.ts +0 -105
  270. /package/lib/module/web/{checkboxHtmlNormalizer.js → normalization/checkboxHtmlNormalizer.js} +0 -0
  271. /package/lib/typescript/src/web/{checkboxHtmlNormalizer.d.ts → normalization/checkboxHtmlNormalizer.d.ts} +0 -0
  272. /package/src/web/{checkboxHtmlNormalizer.ts → normalization/checkboxHtmlNormalizer.ts} +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-enriched-html",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "HTML-based Rich Text solution for React Native",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -88,24 +88,26 @@
88
88
  "registry": "https://registry.npmjs.org/"
89
89
  },
90
90
  "dependencies": {
91
- "@tiptap/core": "3.20.4",
92
- "@tiptap/extension-blockquote": "3.20.4",
93
- "@tiptap/extension-bold": "3.20.4",
94
- "@tiptap/extension-code": "3.20.4",
95
- "@tiptap/extension-document": "3.20.4",
96
- "@tiptap/extension-heading": "3.20.4",
97
- "@tiptap/extension-history": "3.20.4",
98
- "@tiptap/extension-image": "3.20.4",
99
- "@tiptap/extension-italic": "3.20.4",
100
- "@tiptap/extension-link": "3.20.4",
101
- "@tiptap/extension-list": "3.20.4",
102
- "@tiptap/extension-paragraph": "3.20.4",
103
- "@tiptap/extension-strike": "3.20.4",
104
- "@tiptap/extension-text": "3.20.4",
105
- "@tiptap/extension-underline": "3.20.4",
106
- "@tiptap/extensions": "3.20.4",
107
- "@tiptap/pm": "3.20.4",
108
- "@tiptap/react": "3.20.4"
91
+ "@tiptap/core": "3.27.1",
92
+ "@tiptap/extension-blockquote": "3.27.1",
93
+ "@tiptap/extension-bold": "3.27.1",
94
+ "@tiptap/extension-code": "3.27.1",
95
+ "@tiptap/extension-document": "3.27.1",
96
+ "@tiptap/extension-heading": "3.27.1",
97
+ "@tiptap/extension-history": "3.27.1",
98
+ "@tiptap/extension-image": "3.27.1",
99
+ "@tiptap/extension-italic": "3.27.1",
100
+ "@tiptap/extension-link": "3.27.1",
101
+ "@tiptap/extension-list": "3.27.1",
102
+ "@tiptap/extension-paragraph": "3.27.1",
103
+ "@tiptap/extension-strike": "3.27.1",
104
+ "@tiptap/extension-text": "3.27.1",
105
+ "@tiptap/extension-text-align": "3.27.1",
106
+ "@tiptap/extension-underline": "3.27.1",
107
+ "@tiptap/extensions": "3.27.1",
108
+ "@tiptap/pm": "3.27.1",
109
+ "@tiptap/react": "3.27.1",
110
+ "dompurify": "3.4.11"
109
111
  },
110
112
  "devDependencies": {
111
113
  "@commitlint/config-conventional": "^19.6.0",
@@ -127,6 +129,7 @@
127
129
  "eslint-config-prettier": "^10.1.1",
128
130
  "eslint-plugin-prettier": "^5.2.3",
129
131
  "jest": "^29.7.0",
132
+ "jest-environment-jsdom": "^29.7.0",
130
133
  "playwright": "1.58.2",
131
134
  "prettier": "^3.0.3",
132
135
  "react": "19.1.0",
@@ -145,17 +148,40 @@
145
148
  "apps/example",
146
149
  "apps/example-web"
147
150
  ],
151
+ "resolutions": {
152
+ "shell-quote": "1.8.4"
153
+ },
148
154
  "packageManager": "yarn@4.13.0",
149
155
  "jest": {
150
- "preset": "react-native",
151
- "modulePathIgnorePatterns": [
152
- "<rootDir>/apps/example/node_modules",
153
- "<rootDir>/lib/"
154
- ],
155
- "testPathIgnorePatterns": [
156
- "/node_modules/",
157
- "<rootDir>/.playwright/",
158
- "<rootDir>/apps/example-web/"
156
+ "projects": [
157
+ {
158
+ "displayName": "native",
159
+ "preset": "react-native",
160
+ "modulePathIgnorePatterns": [
161
+ "<rootDir>/apps/example/node_modules",
162
+ "<rootDir>/lib/"
163
+ ],
164
+ "testPathIgnorePatterns": [
165
+ "/node_modules/",
166
+ "<rootDir>/.playwright/",
167
+ "<rootDir>/apps/example-web/",
168
+ "<rootDir>/src/web/"
169
+ ]
170
+ },
171
+ {
172
+ "displayName": "web",
173
+ "testEnvironment": "jsdom",
174
+ "testMatch": [
175
+ "<rootDir>/src/web/**/__tests__/**/*.test.{ts,tsx}"
176
+ ],
177
+ "modulePathIgnorePatterns": [
178
+ "<rootDir>/apps/example/node_modules",
179
+ "<rootDir>/lib/"
180
+ ],
181
+ "transform": {
182
+ "^.+\\.(js|ts|tsx)$": "babel-jest"
183
+ }
184
+ }
159
185
  ]
160
186
  },
161
187
  "commitlint": {
package/src/index.tsx CHANGED
@@ -1,4 +1,5 @@
1
1
  export { EnrichedTextInput } from './web/EnrichedTextInput';
2
+ export { EnrichedText } from './web/EnrichedText';
2
3
  export type {
3
4
  EnrichedInputStyle,
4
5
  EnrichedTextInputProps,
package/src/types.ts CHANGED
@@ -838,13 +838,15 @@ export interface EnrichedTextProps extends ViewProps {
838
838
  onMentionPress?: (event: OnMentionPressEvent) => void;
839
839
  }
840
840
 
841
- interface EnrichedTextMentionStyleProperties extends MentionStyleProperties {
841
+ export interface EnrichedTextMentionStyleProperties extends MentionStyleProperties {
842
842
  pressColor?: ColorValue;
843
843
  pressBackgroundColor?: ColorValue;
844
844
  }
845
845
 
846
- export interface EnrichedTextHtmlStyle
847
- extends Omit<HtmlStyle, 'a' | 'mention'> {
846
+ export interface EnrichedTextHtmlStyle extends Omit<
847
+ HtmlStyle,
848
+ 'a' | 'mention'
849
+ > {
848
850
  a?: HtmlStyle['a'] & {
849
851
  pressColor?: ColorValue;
850
852
  };
@@ -1,15 +1,15 @@
1
1
  import type { HtmlStyle, MentionStyleProperties } from '../types';
2
- import { DEFAULT_HTML_STYLE } from './defaultHtmlStyle';
3
2
  import { isMentionStyleRecord } from './isMentionStyleRecord';
4
3
 
5
4
  export function expandMentionStylesForIndicators(
6
5
  mention: HtmlStyle['mention'] | undefined,
7
- indicators: string[]
6
+ indicators: string[],
7
+ htmlStyleToMergeWith: HtmlStyle
8
8
  ): Record<string, MentionStyleProperties> {
9
9
  const out: Record<string, MentionStyleProperties> = {};
10
10
  for (const indicator of indicators) {
11
11
  out[indicator] = {
12
- ...DEFAULT_HTML_STYLE.mention,
12
+ ...htmlStyleToMergeWith.mention,
13
13
  ...(isMentionStyleRecord(mention)
14
14
  ? (mention[indicator] ?? mention.default ?? {})
15
15
  : mention),
@@ -36,7 +36,8 @@ const convertToHtmlStyleInternal = (
36
36
  ): HtmlStyleInternal => {
37
37
  const mentionStyles = expandMentionStylesForIndicators(
38
38
  style.mention,
39
- mentionIndicators
39
+ mentionIndicators,
40
+ DEFAULT_HTML_STYLE
40
41
  );
41
42
 
42
43
  let markerFontWeight: string | undefined;
@@ -0,0 +1,343 @@
1
+ .tiptap.ProseMirror p {
2
+ margin-top: 0;
3
+ margin-bottom: 0;
4
+ }
5
+
6
+ .tiptap.ProseMirror-focused {
7
+ outline: none;
8
+ }
9
+
10
+ .et-view {
11
+ white-space: pre-wrap;
12
+ overflow-wrap: anywhere;
13
+ }
14
+
15
+ .et-view p {
16
+ margin-top: 0;
17
+ margin-bottom: 0;
18
+ }
19
+
20
+ .eti-editor p.is-editor-empty:first-child::before {
21
+ color: var(--et-placeholder-text-color, #adb5bd);
22
+ content: attr(data-placeholder);
23
+ float: left;
24
+ height: 0;
25
+ pointer-events: none;
26
+ }
27
+
28
+ .eti-editor ::selection,
29
+ .et-view ::selection {
30
+ background-color: var(--et-selection-color, Highlight);
31
+ }
32
+
33
+ .eti-editor code,
34
+ .et-view code {
35
+ font-family: monospace;
36
+ background-color: var(--et-code-bg-color);
37
+ color: var(--et-code-color);
38
+ display: inline;
39
+ padding: 0;
40
+ line-height: inherit;
41
+ vertical-align: baseline;
42
+ }
43
+
44
+ .eti-editor h1,
45
+ .et-view h1 {
46
+ font-size: var(--et-h1-font-size);
47
+ font-weight: var(--et-h1-font-weight);
48
+ margin: 0;
49
+ line-height: normal;
50
+ }
51
+ .eti-editor h2,
52
+ .et-view h2 {
53
+ font-size: var(--et-h2-font-size);
54
+ font-weight: var(--et-h2-font-weight);
55
+ margin: 0;
56
+ line-height: normal;
57
+ }
58
+ .eti-editor h3,
59
+ .et-view h3 {
60
+ font-size: var(--et-h3-font-size);
61
+ font-weight: var(--et-h3-font-weight);
62
+ margin: 0;
63
+ line-height: normal;
64
+ }
65
+ .eti-editor h4,
66
+ .et-view h4 {
67
+ font-size: var(--et-h4-font-size);
68
+ font-weight: var(--et-h4-font-weight);
69
+ margin: 0;
70
+ line-height: normal;
71
+ }
72
+ .eti-editor h5,
73
+ .et-view h5 {
74
+ font-size: var(--et-h5-font-size);
75
+ font-weight: var(--et-h5-font-weight);
76
+ margin: 0;
77
+ line-height: normal;
78
+ }
79
+ .eti-editor h6,
80
+ .et-view h6 {
81
+ font-size: var(--et-h6-font-size);
82
+ font-weight: var(--et-h6-font-weight);
83
+ margin: 0;
84
+ line-height: normal;
85
+ }
86
+
87
+ .eti-editor blockquote,
88
+ .et-view blockquote {
89
+ border-left: var(--et-blockquote-border-width) solid
90
+ var(--et-blockquote-border-color);
91
+ padding-left: var(--et-blockquote-gap-width);
92
+ margin: 0;
93
+ color: var(--et-blockquote-color);
94
+ }
95
+
96
+ .eti-editor blockquote p,
97
+ .et-view blockquote p {
98
+ margin: 0;
99
+ }
100
+
101
+ .eti-editor codeblock,
102
+ .et-view codeblock {
103
+ display: block;
104
+ font-family: monospace;
105
+ background-color: var(--et-codeblock-bg-color);
106
+ color: var(--et-codeblock-color);
107
+ border-radius: var(--et-codeblock-border-radius);
108
+ }
109
+
110
+ .eti-editor codeblock p,
111
+ .et-view codeblock p {
112
+ margin: 0;
113
+ }
114
+
115
+ .eti-editor a,
116
+ .et-view a {
117
+ color: var(--et-link-color);
118
+ text-decoration-line: var(--et-link-text-decoration-line);
119
+ }
120
+
121
+ .eti-editor li,
122
+ .et-view li {
123
+ margin: 0;
124
+ min-height: 1.2em;
125
+ }
126
+
127
+ @supports (min-height: 1lh) {
128
+ .eti-editor li,
129
+ .et-view li {
130
+ min-height: 1lh;
131
+ }
132
+ }
133
+
134
+ /* Zero-width space to correctly display empty list elements */
135
+ .eti-editor ul:not([data-type]) > li > p:empty::after,
136
+ .et-view ul:not([data-type]) > li > p:empty::after,
137
+ .eti-editor ol > li > p:empty::after,
138
+ .et-view ol > li > p:empty::after,
139
+ .eti-editor ul[data-type='checkboxList'] > li > div:empty::after,
140
+ .et-view ul[data-type="checkbox"] > li > label:empty::after {
141
+ content: '\200b';
142
+ }
143
+
144
+ .eti-editor ul:not([data-type]),
145
+ .et-view ul:not([data-type]) {
146
+ margin: 0;
147
+ list-style: none;
148
+ padding-left: calc(var(--et-ul-margin-left, 16px) + var(--et-ul-gap-width, 16px));
149
+ }
150
+
151
+ .eti-editor ul:not([data-type]) > li,
152
+ .et-view ul:not([data-type]) > li {
153
+ margin: 0;
154
+ display: flex;
155
+ align-items: baseline;
156
+ }
157
+
158
+ .eti-editor ul:not([data-type]) > li::before,
159
+ .et-view ul:not([data-type]) > li::before {
160
+ content: '';
161
+ flex-shrink: 0;
162
+ width: var(--et-ul-bullet-size, 8px);
163
+ height: var(--et-ul-bullet-size, 8px);
164
+ border-radius: 50%;
165
+ background-color: var(--et-ul-bullet-color, currentColor);
166
+
167
+ margin-left: calc(-1 * (var(--et-ul-bullet-size, 8px) + var(--et-ul-gap-width, 16px)));
168
+ margin-right: var(--et-ul-gap-width, 16px);
169
+
170
+ position: relative;
171
+ top: -0.1em;
172
+ }
173
+
174
+ .eti-editor ol,
175
+ .et-view ol {
176
+ margin: 0;
177
+ list-style: none;
178
+ padding-left: calc(var(--et-ol-margin-left, 16px) + var(--et-ol-gap-width, 16px));
179
+ counter-reset: et-ol;
180
+ }
181
+
182
+ .eti-editor ol > li,
183
+ .et-view ol > li {
184
+ margin: 0;
185
+ counter-increment: et-ol;
186
+ display: flex;
187
+ align-items: baseline;
188
+ }
189
+
190
+ .eti-editor ol > li::before,
191
+ .et-view ol > li::before {
192
+ content: counter(et-ol) '.';
193
+ flex-shrink: 0;
194
+ width: var(--et-ol-margin-left, 16px);
195
+ text-align: right;
196
+ margin-right: calc(var(--et-ol-gap-width, 16px) / 2);
197
+ margin-left: calc(-1 * (var(--et-ol-margin-left, 16px) + (var(--et-ol-gap-width, 16px) / 2)));
198
+
199
+ color: var(--et-ol-marker-color, currentColor);
200
+ font-weight: var(--et-ol-marker-font-weight, inherit);
201
+ white-space: nowrap;
202
+ }
203
+
204
+ .eti-editor ul:not([data-type]) > li > p,
205
+ .et-view ul:not([data-type]) > li > p,
206
+ .eti-editor ol > li > p,
207
+ .et-view ol > li > p {
208
+ display: block;
209
+ flex: 1 1 auto;
210
+ min-width: 0;
211
+ margin: 0;
212
+ }
213
+
214
+ .eti-editor li p,
215
+ .et-view li p {
216
+ margin: 0;
217
+ }
218
+
219
+ .eti-editor .eti-inline-image {
220
+ vertical-align: text-bottom;
221
+ line-height: 0;
222
+ display: inline-block;
223
+ }
224
+
225
+ .eti-editor .eti-inline-image-img {
226
+ object-fit: contain;
227
+ }
228
+
229
+ .eti-editor .eti-inline-image--placeholder {
230
+ display: inline-block;
231
+ overflow: hidden;
232
+ color: inherit;
233
+ }
234
+
235
+ .eti-editor .eti-inline-image-broken-glyph {
236
+ display: block;
237
+ width: 100%;
238
+ height: 100%;
239
+ }
240
+
241
+ .eti-editor
242
+ .react-renderer.node-image.ProseMirror-selectednode
243
+ .eti-inline-image {
244
+ box-shadow: inset 0 0 0 999px Highlight;
245
+ }
246
+
247
+ .eti-editor ul[data-type='checkboxList'] {
248
+ margin: 0;
249
+ list-style: none;
250
+ padding-left: calc(var(--et-checkbox-margin-left, 16px) + var(--et-checkbox-gap-width, 16px));
251
+ }
252
+
253
+ .eti-editor ul[data-type='checkboxList'] > li {
254
+ margin: 0;
255
+ display: flex;
256
+ align-items: baseline;
257
+ }
258
+
259
+ .eti-editor ul[data-type='checkboxList'] > li > label {
260
+ display: inline-flex;
261
+ align-items: center;
262
+ flex-shrink: 0;
263
+ width: var(--et-checkbox-box-size, 24px);
264
+ height: var(--et-checkbox-box-size, 24px);
265
+
266
+ margin-left: calc(-1 * (var(--et-checkbox-box-size, 24px) + var(--et-checkbox-gap-width, 16px)));
267
+ margin-right: var(--et-checkbox-gap-width, 16px);
268
+
269
+ margin-top: 0;
270
+ position: relative;
271
+ top: 0.15em;
272
+ }
273
+
274
+ .eti-editor ul[data-type='checkboxList'] > li > label input[type='checkbox'] {
275
+ width: 100%;
276
+ height: 100%;
277
+ margin: 0;
278
+ flex-shrink: 0;
279
+ accent-color: var(--et-checkbox-box-color, #0000ff);
280
+ }
281
+
282
+ .eti-editor ul[data-type='checkboxList'] > li > div {
283
+ display: block;
284
+ flex: 1 1 auto;
285
+ min-width: 0;
286
+ margin: 0;
287
+ }
288
+
289
+ .et-view ul[data-type="checkbox"] {
290
+ margin: 0;
291
+ list-style: none;
292
+ padding-left: calc(
293
+ var(--et-checkbox-margin-left, 16px) + var(--et-checkbox-gap-width, 16px)
294
+ );
295
+ }
296
+
297
+ .et-view ul[data-type="checkbox"] > li {
298
+ margin: 0;
299
+ display: flex;
300
+ align-items: baseline;
301
+ }
302
+
303
+ .et-view ul[data-type="checkbox"] > li > input[type='checkbox'] {
304
+ flex-shrink: 0;
305
+
306
+ margin-left: calc(-1 * (var(--et-checkbox-box-size, 24px) + var(--et-checkbox-gap-width, 16px)));
307
+ margin-right: var(--et-checkbox-gap-width, 16px);
308
+ margin-bottom: 0;
309
+
310
+ width: var(--et-checkbox-box-size, 24px);
311
+ height: var(--et-checkbox-box-size, 24px);
312
+ accent-color: var(--et-checkbox-box-color, #0000ff);
313
+
314
+ /* disable checkbox press style as it's read-only */
315
+ pointer-events: none;
316
+ -webkit-tap-highlight-color: transparent;
317
+
318
+ margin-top: 0;
319
+ position: relative;
320
+ top: 0.15em;
321
+ }
322
+
323
+ .et-view ul[data-type="checkbox"] > li > label {
324
+ display: block;
325
+ flex: 1 1 auto;
326
+ min-width: 0;
327
+ margin: 0;
328
+ padding: 0;
329
+ }
330
+
331
+ .et-view img {
332
+ display: inline-block;
333
+ position: relative;
334
+ overflow: hidden;
335
+ vertical-align: text-bottom;
336
+ }
337
+
338
+ .et-view img.error {
339
+ content: linear-gradient(transparent, transparent);
340
+ background-color: currentColor;
341
+ -webkit-mask: var(--et-broken-image-glyph) no-repeat center / contain;
342
+ mask: var(--et-broken-image-glyph) no-repeat center / contain;
343
+ }
@@ -0,0 +1,82 @@
1
+ import { memo, useMemo, useRef, type CSSProperties } from 'react';
2
+ import type { EnrichedTextProps } from '../types';
3
+ import './EnrichedText.css';
4
+ import { enrichedTextStyleToCSSProperties } from './styleConversion/enrichedTextStyleToCSSProperties';
5
+ import {
6
+ htmlStyleToCSSVariables,
7
+ mergeWithDefaultEnrichedTextHtmlStyle,
8
+ } from './styleConversion/htmlStyleToCSSVariables';
9
+ import { ENRICHED_TEXT_CLASSNAME } from './constants/classNames';
10
+ import { enrichedInputThemingToCSSProperties } from './styleConversion/enrichedThemingToCSSProperties';
11
+ import { buildMentionRulesCSS } from './styleConversion/buildMentionRulesCSS';
12
+ import { sanitizeHtml } from './sanitization/htmlSanitizer';
13
+ import { prepareHtmlForWeb } from './normalization/prepareHtmlForWeb';
14
+ import { INLINE_IMAGE_CSS_VARIABLES } from './styleConversion/inlineImageCSSVariables';
15
+ import { useImageErrorFallback } from './useImageErrorFallback';
16
+ import { usePressInteractions } from './usePressInteractions';
17
+
18
+ export const EnrichedText = memo(
19
+ ({ children, htmlStyle, style, selectionColor }: EnrichedTextProps) => {
20
+ const containerRef = useRef<HTMLDivElement>(null);
21
+
22
+ const sanitizedHtml = useMemo(() => sanitizeHtml(children), [children]);
23
+
24
+ const finalHtml = useMemo(
25
+ () => prepareHtmlForWeb(sanitizedHtml),
26
+ [sanitizedHtml]
27
+ );
28
+
29
+ const resolvedHtmlStyle = useMemo(
30
+ () => mergeWithDefaultEnrichedTextHtmlStyle(htmlStyle),
31
+ [htmlStyle]
32
+ );
33
+
34
+ const textStyle: CSSProperties = useMemo(
35
+ () => enrichedTextStyleToCSSProperties(style ?? {}),
36
+ [style]
37
+ );
38
+
39
+ const cssVars = useMemo(
40
+ () => ({
41
+ ...htmlStyleToCSSVariables(resolvedHtmlStyle),
42
+ ...INLINE_IMAGE_CSS_VARIABLES,
43
+ }),
44
+ [resolvedHtmlStyle]
45
+ );
46
+
47
+ const themingStyle = useMemo(
48
+ () => enrichedInputThemingToCSSProperties({ selectionColor }),
49
+ [selectionColor]
50
+ );
51
+
52
+ const mentionRulesCSS = useMemo(
53
+ () => buildMentionRulesCSS(resolvedHtmlStyle),
54
+ [resolvedHtmlStyle]
55
+ );
56
+
57
+ const finalStyle = useMemo(
58
+ () =>
59
+ ({
60
+ ...textStyle,
61
+ ...themingStyle,
62
+ ...cssVars,
63
+ }) as CSSProperties,
64
+ [textStyle, themingStyle, cssVars]
65
+ );
66
+
67
+ usePressInteractions(containerRef);
68
+ useImageErrorFallback(containerRef);
69
+
70
+ return (
71
+ <>
72
+ {mentionRulesCSS ? <style>{mentionRulesCSS}</style> : null}
73
+ <div
74
+ ref={containerRef}
75
+ style={finalStyle}
76
+ className={ENRICHED_TEXT_CLASSNAME}
77
+ dangerouslySetInnerHTML={{ __html: finalHtml }}
78
+ />
79
+ </>
80
+ );
81
+ }
82
+ );