carbon-react 148.0.0 → 149.0.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 (269) hide show
  1. package/esm/__internal__/label/label.component.js +4 -1
  2. package/esm/components/note/note.component.d.ts +1 -2
  3. package/esm/components/note/note.component.js +6 -9
  4. package/esm/components/tabs/__internal__/tab-title/tab-title.style.js +2 -1
  5. package/esm/components/text-editor/__internal__/constants.d.ts +21 -0
  6. package/esm/components/text-editor/__internal__/constants.js +29 -0
  7. package/esm/components/text-editor/__internal__/helpers.d.ts +20 -0
  8. package/esm/components/text-editor/__internal__/helpers.js +84 -0
  9. package/esm/components/text-editor/__internal__/index.d.ts +2 -0
  10. package/esm/components/text-editor/__internal__/index.js +2 -0
  11. package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
  12. package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +28 -0
  13. package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
  14. package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.js +1 -0
  15. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
  16. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +33 -0
  17. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
  18. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +59 -0
  19. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
  20. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +17 -0
  21. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
  22. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.js +1 -0
  23. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
  24. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +40 -0
  25. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
  26. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +34 -0
  27. package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
  28. package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.js +1 -0
  29. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
  30. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.js +1 -0
  31. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
  32. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +62 -0
  33. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
  34. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +1 -0
  35. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
  36. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +19 -0
  37. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
  38. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.js +29 -0
  39. package/esm/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
  40. package/esm/components/text-editor/__internal__/plugins/OnChange/index.js +1 -0
  41. package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
  42. package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +25 -0
  43. package/esm/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
  44. package/esm/components/text-editor/__internal__/plugins/Placeholder/index.js +1 -0
  45. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
  46. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +17 -0
  47. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
  48. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +8 -0
  49. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
  50. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +41 -0
  51. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
  52. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +1 -0
  53. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
  54. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +4 -0
  55. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
  56. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +41 -0
  57. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
  58. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +317 -0
  59. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
  60. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +29 -0
  61. package/esm/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
  62. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
  63. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +111 -0
  64. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
  65. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +57 -0
  66. package/esm/components/text-editor/__internal__/plugins/index.d.ts +9 -0
  67. package/esm/components/text-editor/__internal__/plugins/index.js +9 -0
  68. package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
  69. package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +71 -0
  70. package/esm/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
  71. package/esm/components/text-editor/__internal__/read-only-rte.component.js +62 -0
  72. package/esm/components/text-editor/__internal__/style.css +7 -0
  73. package/esm/components/text-editor/__internal__/utils.d.ts +4 -0
  74. package/esm/components/text-editor/__internal__/utils.js +14 -0
  75. package/esm/components/text-editor/index.d.ts +2 -1
  76. package/esm/components/text-editor/index.js +2 -1
  77. package/esm/components/text-editor/text-editor.component.d.ts +32 -28
  78. package/esm/components/text-editor/text-editor.component.js +139 -478
  79. package/esm/components/text-editor/text-editor.context.d.ts +6 -0
  80. package/esm/components/text-editor/text-editor.context.js +4 -0
  81. package/esm/components/text-editor/text-editor.style.d.ts +18 -11
  82. package/esm/components/text-editor/text-editor.style.js +55 -52
  83. package/esm/locales/de-de.js +0 -14
  84. package/esm/locales/en-gb.js +18 -14
  85. package/esm/locales/es-es.js +0 -14
  86. package/esm/locales/fr-ca.js +0 -14
  87. package/esm/locales/fr-fr.js +0 -14
  88. package/esm/locales/locale.d.ts +14 -14
  89. package/lib/__internal__/label/label.component.js +3 -0
  90. package/lib/components/note/note.component.d.ts +1 -2
  91. package/lib/components/note/note.component.js +6 -9
  92. package/lib/components/tabs/__internal__/tab-title/tab-title.style.js +2 -1
  93. package/lib/components/text-editor/__internal__/constants.d.ts +21 -0
  94. package/lib/components/text-editor/__internal__/constants.js +33 -0
  95. package/lib/components/text-editor/__internal__/helpers.d.ts +20 -0
  96. package/lib/components/text-editor/__internal__/helpers.js +91 -0
  97. package/lib/components/text-editor/__internal__/index.d.ts +2 -0
  98. package/lib/components/text-editor/__internal__/index.js +26 -0
  99. package/lib/components/text-editor/__internal__/package.json +6 -0
  100. package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
  101. package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +36 -0
  102. package/lib/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
  103. package/lib/components/text-editor/__internal__/{editor-link → plugins/AutoLinker}/index.js +2 -2
  104. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/AutoLinker}/package.json +1 -1
  105. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
  106. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +42 -0
  107. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
  108. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +68 -0
  109. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
  110. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +24 -0
  111. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
  112. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.js +13 -0
  113. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/package.json +6 -0
  114. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
  115. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +48 -0
  116. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
  117. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +42 -0
  118. package/lib/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
  119. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/ContentEditor}/index.js +2 -2
  120. package/lib/components/text-editor/__internal__/plugins/ContentEditor/package.json +6 -0
  121. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
  122. package/lib/components/text-editor/__internal__/{label-wrapper → plugins/LinkMonitor}/index.js +2 -2
  123. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
  124. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +70 -0
  125. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/package.json +6 -0
  126. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
  127. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +13 -0
  128. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
  129. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +28 -0
  130. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
  131. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button/toolbar-button.style.js → plugins/LinkPreviewer/link-previewer.style.js} +21 -31
  132. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/package.json +6 -0
  133. package/lib/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
  134. package/lib/components/text-editor/__internal__/plugins/OnChange/index.js +13 -0
  135. package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
  136. package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +32 -0
  137. package/lib/components/text-editor/__internal__/plugins/OnChange/package.json +6 -0
  138. package/lib/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
  139. package/lib/components/text-editor/__internal__/plugins/Placeholder/index.js +13 -0
  140. package/lib/components/text-editor/__internal__/plugins/Placeholder/package.json +6 -0
  141. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
  142. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +25 -0
  143. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
  144. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +15 -0
  145. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
  146. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +48 -0
  147. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
  148. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +5 -0
  149. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
  150. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +34 -0
  151. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
  152. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +47 -0
  153. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
  154. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +325 -0
  155. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/package.json +6 -0
  156. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
  157. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +36 -0
  158. package/lib/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
  159. package/lib/components/text-editor/__internal__/plugins/Toolbar/package.json +6 -0
  160. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
  161. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +120 -0
  162. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
  163. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +65 -0
  164. package/lib/components/text-editor/__internal__/plugins/index.d.ts +9 -0
  165. package/lib/components/text-editor/__internal__/plugins/index.js +69 -0
  166. package/lib/components/text-editor/__internal__/{toolbar → plugins}/package.json +1 -1
  167. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
  168. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +78 -0
  169. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/package.json +6 -0
  170. package/lib/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
  171. package/lib/components/text-editor/__internal__/read-only-rte.component.js +72 -0
  172. package/lib/components/text-editor/__internal__/style.css +7 -0
  173. package/lib/components/text-editor/__internal__/utils.d.ts +4 -0
  174. package/lib/components/text-editor/__internal__/utils.js +21 -0
  175. package/lib/components/text-editor/index.d.ts +2 -1
  176. package/lib/components/text-editor/index.js +7 -7
  177. package/lib/components/text-editor/text-editor.component.d.ts +32 -28
  178. package/lib/components/text-editor/text-editor.component.js +141 -477
  179. package/lib/components/text-editor/text-editor.context.d.ts +6 -0
  180. package/lib/components/text-editor/{__internal__/editor.context.js → text-editor.context.js} +1 -0
  181. package/lib/components/text-editor/text-editor.style.d.ts +18 -11
  182. package/lib/components/text-editor/text-editor.style.js +57 -53
  183. package/lib/locales/de-de.js +0 -14
  184. package/lib/locales/en-gb.js +18 -14
  185. package/lib/locales/es-es.js +0 -14
  186. package/lib/locales/fr-ca.js +0 -14
  187. package/lib/locales/fr-fr.js +0 -14
  188. package/lib/locales/locale.d.ts +14 -14
  189. package/package.json +7 -4
  190. package/esm/components/text-editor/__internal__/decorators/index.d.ts +0 -3
  191. package/esm/components/text-editor/__internal__/decorators/index.js +0 -3
  192. package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
  193. package/esm/components/text-editor/__internal__/decorators/link-decorator.js +0 -37
  194. package/esm/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
  195. package/esm/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -36
  196. package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
  197. package/esm/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -13
  198. package/esm/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
  199. package/esm/components/text-editor/__internal__/editor-link/index.js +0 -1
  200. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
  201. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -18
  202. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
  203. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -11
  204. package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
  205. package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -1
  206. package/esm/components/text-editor/__internal__/editor.context.d.ts +0 -6
  207. package/esm/components/text-editor/__internal__/editor.context.js +0 -2
  208. package/esm/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
  209. package/esm/components/text-editor/__internal__/label-wrapper/index.js +0 -1
  210. package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
  211. package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -18
  212. package/esm/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
  213. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
  214. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.js +0 -1
  215. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
  216. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -50
  217. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
  218. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +0 -38
  219. package/esm/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
  220. package/esm/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -158
  221. package/esm/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
  222. package/esm/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -28
  223. package/esm/components/text-editor/__internal__/utils/index.d.ts +0 -1
  224. package/esm/components/text-editor/__internal__/utils/index.js +0 -1
  225. package/esm/components/text-editor/__internal__/utils/utils.d.ts +0 -29
  226. package/esm/components/text-editor/__internal__/utils/utils.js +0 -174
  227. package/esm/components/text-editor/types.d.ts +0 -6
  228. package/esm/components/text-editor/types.js +0 -4
  229. package/lib/components/text-editor/__internal__/decorators/index.d.ts +0 -3
  230. package/lib/components/text-editor/__internal__/decorators/index.js +0 -10
  231. package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
  232. package/lib/components/text-editor/__internal__/decorators/link-decorator.js +0 -44
  233. package/lib/components/text-editor/__internal__/decorators/package.json +0 -6
  234. package/lib/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
  235. package/lib/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -45
  236. package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
  237. package/lib/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -20
  238. package/lib/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
  239. package/lib/components/text-editor/__internal__/editor-link/package.json +0 -6
  240. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
  241. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -25
  242. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
  243. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -18
  244. package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
  245. package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -13
  246. package/lib/components/text-editor/__internal__/editor-validation-wrapper/package.json +0 -6
  247. package/lib/components/text-editor/__internal__/editor.context.d.ts +0 -6
  248. package/lib/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
  249. package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
  250. package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -25
  251. package/lib/components/text-editor/__internal__/label-wrapper/package.json +0 -6
  252. package/lib/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
  253. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
  254. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
  255. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -56
  256. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
  257. package/lib/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
  258. package/lib/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -167
  259. package/lib/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
  260. package/lib/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -34
  261. package/lib/components/text-editor/__internal__/utils/index.d.ts +0 -1
  262. package/lib/components/text-editor/__internal__/utils/index.js +0 -90
  263. package/lib/components/text-editor/__internal__/utils/package.json +0 -6
  264. package/lib/components/text-editor/__internal__/utils/utils.d.ts +0 -29
  265. package/lib/components/text-editor/__internal__/utils/utils.js +0 -197
  266. package/lib/components/text-editor/types.d.ts +0 -6
  267. package/lib/components/text-editor/types.js +0 -10
  268. /package/esm/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
  269. /package/lib/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
@@ -1,500 +1,161 @@
1
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useRef, useState, useContext } from "react";
1
+ /* eslint-disable no-console */
2
+ import { LexicalComposer } from "@lexical/react/LexicalComposer";
3
+ import { ClickableLinkPlugin } from "@lexical/react/LexicalClickableLinkPlugin";
4
+ import { EditorRefPlugin } from "@lexical/react/LexicalEditorRefPlugin";
5
+ import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
6
+ import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
7
+ import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
8
+ import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
9
+ import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
10
+ import { ListPlugin } from "@lexical/react/LexicalListPlugin";
11
+ import { $getRoot } from "lexical";
12
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
13
  import PropTypes from "prop-types";
4
- import { ContentState, EditorState, RichUtils, getDefaultKeyBinding, Modifier, Editor } from "draft-js";
5
- import { computeBlockType, getContent, getContentInfo, getDecoratedValue, getSelectedLength, moveSelectionToEnd, resetBlockType, isASCIIChar, replaceText, hasInlineStyle, hasBlockStyle, blockStyleFn } from "./__internal__/utils";
6
- import { StyledEditorWrapper, StyledEditorOutline, StyledEditorContainer } from "./text-editor.style";
7
- import ValidationWrapper from "./__internal__/editor-validation-wrapper";
8
- import Toolbar from "./__internal__/toolbar";
9
14
  import Label from "../../__internal__/label";
10
- import Events from "../../__internal__/utils/helpers/events";
11
- import guid from "../../__internal__/utils/helpers/guid";
12
- import LabelWrapper from "./__internal__/label-wrapper";
13
- import { BOLD, ITALIC, UNORDERED_LIST, ORDERED_LIST } from "./types";
14
- import NewValidationContext from "../carbon-provider/__internal__/new-validation.context";
15
- import { ErrorBorder, StyledHintText } from "../textbox/textbox.style";
16
- import ValidationMessage from "../../__internal__/validation-message";
17
- import useInputAccessibility from "../../hooks/__internal__/useInputAccessibility";
18
- import Box from "../box";
19
- import useCharacterCount from "../../hooks/__internal__/useCharacterCount";
20
- import EditorContext from "./__internal__/editor.context";
21
- const NUMBERS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
22
- const INLINE_STYLES = [BOLD, ITALIC];
23
- const TextEditor = /*#__PURE__*/React.forwardRef(({
15
+ import useDebounce from "../../hooks/__internal__/useDebounce";
16
+ import useLocale from "../../hooks/__internal__/useLocale";
17
+ import { COMPONENT_PREFIX, markdownNodes, theme } from "./__internal__/constants";
18
+ import { validateUrl } from "./__internal__/helpers";
19
+ import { AutoLinkerPlugin, CharacterCounterPlugin, ContentEditor, LinkMonitorPlugin, OnChangePlugin, Placeholder, ToolbarPlugin } from "./__internal__/plugins";
20
+ import TextEditorContext from "./text-editor.context";
21
+ import StyledTextEditor, { StyledEditorToolbarWrapper, StyledHintText, StyledValidationMessage, StyledWrapper } from "./text-editor.style";
22
+ import { createEmpty } from "./__internal__";
23
+ export const TextEditor = ({
24
24
  characterLimit = 3000,
25
+ error,
26
+ inputHint,
27
+ isOptional = false,
25
28
  labelText,
29
+ namespace = COMPONENT_PREFIX,
30
+ onCancel,
26
31
  onChange,
27
- value,
28
- required,
29
- error,
30
- warning,
31
- info,
32
- toolbarElements,
33
- rows,
34
- previews,
35
32
  onLinkAdded,
36
- inputHint,
37
- isOptional,
38
- ...rest
39
- }, ref) => {
40
- const {
41
- validationRedesignOptIn
42
- } = useContext(NewValidationContext);
33
+ onSave,
34
+ placeholder,
35
+ previews = [],
36
+ readOnly = false,
37
+ required = false,
38
+ rows,
39
+ warning,
40
+ value
41
+ }) => {
42
+ const editorRef = useRef(undefined);
43
+ const locale = useLocale();
44
+ const [characterLimitWarning, setCharacterLimitWarning] = useState(undefined);
43
45
  const [isFocused, setIsFocused] = useState(false);
44
- const [inlines, setInlines] = useState([]);
45
- const [activeInlines, setActiveInlines] = useState({});
46
- const [focusToolbar, setFocusToolbar] = useState(false);
47
- const editorRef = useRef(null);
48
- const wrapper = useRef(null);
49
- const editor = ref || editorRef;
50
- const contentLength = getContent(value).getPlainText("").length;
51
- const moveCursor = useRef(contentLength > 0);
52
- const lastKeyPressed = useRef();
53
- const inputHintId = useRef(`${guid()}-hint`);
54
- const {
55
- current: id
56
- } = useRef(guid());
57
- const {
58
- labelId,
59
- validationId,
60
- ariaDescribedBy
61
- } = useInputAccessibility({
62
- id,
63
- validationRedesignOptIn,
64
- error,
65
- warning,
66
- info,
67
- label: labelText
68
- });
69
- const [characterCount, visuallyHiddenHintId] = useCharacterCount(getContent(value).getPlainText(""), characterLimit, isFocused ? "polite" : "off");
70
- const combinedAriaDescribedBy = [ariaDescribedBy, inputHint ? inputHintId.current : undefined, visuallyHiddenHintId].filter(Boolean).join(" ");
71
- if (rows && (typeof rows !== "number" || rows < 2)) {
72
- // eslint-disable-next-line no-console
73
- console.warn(`Prop rows must be a number value that is 2 or greater to override the min-height of the \`${TextEditor.displayName}\``);
74
- }
75
- const keyBindingFn = ev => {
76
- if (Events.isTabKey(ev) && !Events.isShiftKey(ev)) {
77
- setFocusToolbar(true);
78
- }
79
- return getDefaultKeyBinding(ev);
80
- };
81
- const BLOCK_TYPES = ["unordered-list-item", "ordered-list-item"];
82
- const handleKeyCommand = command => {
83
- // bail out if the enter is pressed and limit has been reached
84
- if (command.includes("split-block") && contentLength === characterLimit) {
85
- return "handled";
86
- }
46
+ const [cancelTrigger, setCancelTrigger] = useState(false);
47
+ const debounceWaitTime = 500;
48
+ const initialConfig = useMemo(() => {
49
+ return {
50
+ namespace,
51
+ nodes: markdownNodes,
52
+ onError: console.error,
53
+ theme,
54
+ editorState: value,
55
+ editable: !readOnly
56
+ };
57
+ }, [namespace, readOnly, value]);
87
58
 
88
- // if the backspace or enter is pressed get block type and text
89
- if (command.includes("backspace") || command.includes("split-block")) {
90
- const {
91
- blockLength,
92
- blockType
93
- } = getContentInfo(value);
94
-
95
- // if a block control is active and there is no text, deactivate it and reset the block
96
- if (BLOCK_TYPES.includes(blockType) && !blockLength) {
97
- onChange(resetBlockType(value, "unstyled"));
98
- return "handled";
99
- }
59
+ // OnChangePlugin is tested separately
60
+ /* istanbul ignore next */
61
+ const handleChange = useDebounce(newState => {
62
+ const currentTextContent = newState.read(() => $getRoot().getTextContent());
63
+ if (onChange) {
64
+ onChange?.(currentTextContent);
100
65
  }
101
- const style = command.toUpperCase();
102
66
 
103
- // if formatting shortcut used eg. command is "bold" or "italic"
104
- if (style === BOLD || style === ITALIC) {
105
- const update = RichUtils.handleKeyCommand(value, command);
67
+ // If the character limit is set, check if the limit has been exceeded
68
+ if (characterLimit > 0) {
69
+ const currentDiff = characterLimit - currentTextContent.length;
70
+ // If the character limit has been exceeded, show the character limit warning
71
+ setCharacterLimitWarning(currentDiff < 0 ? locale.textEditor.characterLimit(Math.abs(currentDiff)) : undefined);
72
+ }
73
+ }, debounceWaitTime);
74
+ const handleCancel = useCallback(() => {
75
+ const editor = editorRef.current;
76
+ /* istanbul ignore next */
77
+ const isEditable = editor?.isEditable() || false;
78
+ /* istanbul ignore if */
79
+ if (!isEditable) return;
106
80
 
107
- // istanbul ignore else
108
- if (update) {
109
- onChange(update);
110
- setActiveInlines({
111
- ...activeInlines,
112
- [style]: !hasInlineStyle(value, style)
113
- });
114
- return "handled";
115
- }
116
- }
117
- return "not-handled";
118
- };
119
- const handleBeforeInput = (str, newState) => {
120
- // short circuit if exceeds character limit
121
- if (contentLength >= characterLimit) {
122
- return "handled";
81
+ /* istanbul ignore else */
82
+ if (onCancel) {
83
+ setCancelTrigger(prev => !prev);
84
+ onCancel();
123
85
  }
124
- setActiveInlines({});
86
+ }, [onCancel]);
125
87
 
126
- // there is a bug in how DraftJS handles the macOS double-space-period feature, this is added to catch this and
127
- // prevent the editor from crashing until a fix can be added to their codebase
128
- if (lastKeyPressed.current === " " && !isASCIIChar(str)) {
129
- lastKeyPressed.current = null;
130
- onChange(replaceText(newState, " ", newState.getCurrentInlineStyle()));
131
- return "handled";
132
- }
133
- if (str === " ") {
134
- lastKeyPressed.current = str;
135
- return "not-handled";
136
- }
137
- lastKeyPressed.current = null;
138
- // short circuit if str does not match expected chars
139
- if (![".", "*"].includes(str)) {
140
- return "not-handled";
141
- }
142
- const {
143
- blockType,
144
- blockLength,
145
- blockText
146
- } = getContentInfo(value);
147
- if (blockLength === 1 && NUMBERS.includes(blockText) && str === "." || blockLength === 0 && str === "*") {
148
- const newBlockType = computeBlockType(str, blockType);
149
- const hasNumberList = hasBlockStyle(value, ORDERED_LIST);
150
- const hasBulletList = hasBlockStyle(value, UNORDERED_LIST);
151
- if (BLOCK_TYPES.includes(newBlockType) && !hasNumberList && !hasBulletList) {
152
- onChange(resetBlockType(value, newBlockType));
153
- setActiveInlines({
154
- BOLD: hasInlineStyle(value, BOLD),
155
- ITALIC: hasInlineStyle(value, ITALIC)
156
- });
157
- return "handled";
158
- }
159
- }
160
- onChange(value);
161
- return "not-handled";
162
- };
163
- const handlePastedText = pastedText => {
164
- const selectedTextLength = getSelectedLength(value);
165
- const newLength = contentLength + pastedText?.length - selectedTextLength;
166
- // if the pastedText will exceed the limit trim the excess
167
- if (newLength > characterLimit) {
168
- const newContentState = Modifier.insertText(getContent(value), value.getSelection(), pastedText.substring(0, characterLimit - contentLength));
169
- const newState = EditorState.push(value, newContentState, "insert-fragment");
170
- onChange(newState);
171
- return "handled";
172
- }
173
- setActiveInlines({});
174
- return "not-handled";
175
- };
176
- const getEditorState = () => {
177
- let editorState = getDecoratedValue(value);
178
-
179
- // should the cursor position be forced to the end of the content
180
- if (contentLength > 0 && moveCursor.current && isFocused) {
181
- editorState = moveSelectionToEnd(editorState);
182
- moveCursor.current = false;
183
- }
184
- return editorState;
185
- };
186
- const editorState = getEditorState();
187
- const activeControls = {
188
- BOLD: activeInlines.BOLD !== undefined ? activeInlines.BOLD : hasInlineStyle(editorState, BOLD),
189
- ITALIC: activeInlines.ITALIC !== undefined ? activeInlines.ITALIC : hasInlineStyle(editorState, ITALIC),
190
- "unordered-list-item": hasBlockStyle(editorState, UNORDERED_LIST),
191
- "ordered-list-item": hasBlockStyle(editorState, ORDERED_LIST)
192
- };
193
- const handleEditorFocus = useCallback(focusValue => {
194
- moveCursor.current = true;
195
- if (focusValue && typeof editor === "object" && editor.current !== document.activeElement) {
196
- editor.current?.focus();
197
- setFocusToolbar(false);
198
- }
199
- setIsFocused(focusValue);
200
- }, [editor]);
201
- const handleInlineStyleChange = (ev, style) => {
202
- ev.preventDefault();
203
- setActiveInlines({
204
- ...activeInlines,
205
- [style]: !hasInlineStyle(value, style)
206
- });
207
- handleEditorFocus(true);
208
- setInlines([...inlines, style]);
209
- };
210
- const handleBlockStyleChange = (ev, newBlockType) => {
211
- ev.preventDefault();
212
- handleEditorFocus(true);
213
- onChange(RichUtils.toggleBlockType(value, newBlockType));
214
- const temp = [];
215
- INLINE_STYLES.forEach(style => {
216
- if (activeInlines[style] !== undefined) {
217
- temp.push(style);
218
- }
219
- });
220
- setInlines(temp);
221
- };
88
+ // Reset the value of the editor when the cancel trigger is updated (implements reset on cancel)
222
89
  useEffect(() => {
223
- // apply the inline styling, having it run in as an effect ensures that styles can be added
224
- // even when the editor is not focused
225
- INLINE_STYLES.forEach(style => {
226
- const preserveStyle = activeInlines[style] !== undefined && activeInlines[style] !== hasInlineStyle(value, style);
227
- if (preserveStyle && value.getSelection().isCollapsed() || isFocused && inlines.includes(style)) {
228
- onChange(RichUtils.toggleInlineStyle(value, style));
229
- setInlines(inlines.filter(inline => inline !== style));
230
- }
231
- if (preserveStyle && !value.getSelection().isCollapsed()) {
232
- setActiveInlines({
233
- ...activeInlines,
234
- [style]: undefined
235
- });
236
- }
237
- });
238
- }, [activeInlines, contentLength, editorState, inlines, isFocused, onChange, value]);
239
- const handlePreviewClose = (onClose, url) => {
240
- // istanbul ignore else
241
- if (url) onClose(url);
90
+ const editor = editorRef.current;
91
+ const safeValue = value || createEmpty();
242
92
 
243
- // istanbul ignore else
244
- if (typeof editor === "object") {
245
- editor.current?.focus();
246
- }
247
- };
248
- useEffect(() => {
249
- if (required) {
250
- const editableElement = wrapper.current?.querySelector("div[contenteditable='true']");
251
- editableElement?.setAttribute("required", "");
252
- editableElement?.setAttribute("aria-required", "true");
253
- }
254
- }, [required]);
255
- return /*#__PURE__*/React.createElement(EditorContext.Provider, {
93
+ /* istanbul ignore else */
94
+ if (editor) {
95
+ const newEditorState = editor.parseEditorState(safeValue);
96
+ editor.setEditorState(newEditorState);
97
+ }
98
+ }, [cancelTrigger, value]);
99
+ const toolbarProps = useMemo(() => ({
100
+ namespace,
101
+ onCancel: onCancel ? handleCancel : undefined,
102
+ onSave
103
+ }), [handleCancel, namespace, onCancel, onSave]);
104
+ return /*#__PURE__*/React.createElement(TextEditorContext.Provider, {
256
105
  value: {
257
106
  onLinkAdded,
258
- editMode: true
107
+ readOnly
259
108
  }
260
- }, /*#__PURE__*/React.createElement(StyledEditorWrapper, _extends({
261
- ref: wrapper,
262
- "data-role": "text-editor-wrapper"
263
- }, rest), /*#__PURE__*/React.createElement(LabelWrapper, {
264
- onClick: () => handleEditorFocus(true)
265
109
  }, /*#__PURE__*/React.createElement(Label, {
266
- labelId: labelId,
267
110
  isRequired: required,
268
- optional: isOptional
269
- }, labelText)), inputHint && /*#__PURE__*/React.createElement(StyledHintText, {
270
- id: inputHintId.current
271
- }, inputHint), /*#__PURE__*/React.createElement(Box, {
272
- position: "relative"
273
- }, validationRedesignOptIn && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(ValidationMessage, {
274
- error: error,
275
- validationId: validationId,
276
- warning: warning
277
- }), (error || warning) && /*#__PURE__*/React.createElement(ErrorBorder, {
278
- warning: !!(!error && warning)
279
- })), /*#__PURE__*/React.createElement(StyledEditorOutline, {
280
- isFocused: isFocused,
281
- hasError: !!error,
282
- "data-role": "editor-outline"
283
- }, /*#__PURE__*/React.createElement(StyledEditorContainer, {
284
- "data-component": "text-editor-container",
285
- hasError: !!error,
286
- rows: rows,
287
- hasPreview: !!React.Children.count(previews)
288
- }, !validationRedesignOptIn && (error || warning || info) && /*#__PURE__*/React.createElement(ValidationWrapper, {
111
+ optional: isOptional,
112
+ labelId: `${namespace}-label`
113
+ }, labelText), inputHint && /*#__PURE__*/React.createElement(StyledHintText, {
114
+ "data-role": `${namespace}-input-hint`,
115
+ id: `${namespace}-input-hint`
116
+ }, inputHint), /*#__PURE__*/React.createElement(LexicalComposer, {
117
+ initialConfig: initialConfig
118
+ }, /*#__PURE__*/React.createElement(EditorRefPlugin, {
119
+ editorRef: editorRef
120
+ }), /*#__PURE__*/React.createElement(StyledWrapper, {
121
+ "data-role": `${namespace}-wrapper`,
122
+ error: error || undefined,
123
+ namespace: namespace,
124
+ warning: characterLimitWarning || warning || undefined
125
+ }, (error || characterLimitWarning || warning) && /*#__PURE__*/React.createElement(StyledValidationMessage, {
289
126
  error: error,
290
- warning: warning,
291
- info: info
292
- }), /*#__PURE__*/React.createElement(Editor, {
293
- ref: editor,
294
- onFocus: () => handleEditorFocus(true),
295
- onBlur: () => handleEditorFocus(false),
296
- editorState: editorState,
297
- onChange: onChange,
298
- handleBeforeInput: handleBeforeInput,
299
- handlePastedText: handlePastedText,
300
- handleKeyCommand: handleKeyCommand,
301
- ariaLabelledBy: labelId,
302
- ariaDescribedBy: combinedAriaDescribedBy,
303
- blockStyleFn: blockStyleFn,
304
- keyBindingFn: keyBindingFn,
305
- tabIndex: 0
306
- }), React.Children.map(previews, preview => {
307
- if (/*#__PURE__*/React.isValidElement(preview)) {
308
- const {
309
- onClose
310
- } = preview?.props;
311
- return /*#__PURE__*/React.cloneElement(preview, {
312
- as: "div",
313
- onClose: onClose ? url => handlePreviewClose(onClose, url) : undefined
314
- });
315
- }
316
- return null;
317
- }), /*#__PURE__*/React.createElement(Toolbar, {
318
- setBlockStyle: (ev, newBlockType) => handleBlockStyleChange(ev, newBlockType),
319
- setInlineStyle: (ev, inlineStyle) => handleInlineStyleChange(ev, inlineStyle),
320
- activeControls: activeControls,
321
- canFocus: focusToolbar,
322
- toolbarElements: toolbarElements
323
- }))), characterCount)));
324
- });
325
- if (process.env.NODE_ENV !== "production") {
326
- TextEditor.propTypes = {
327
- "characterLimit": PropTypes.number,
328
- "error": PropTypes.string,
329
- "info": PropTypes.string,
330
- "inputHint": PropTypes.string,
331
- "isOptional": PropTypes.bool,
332
- "labelText": PropTypes.string.isRequired,
333
- "m": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
334
- "__@toStringTag": PropTypes.string.isRequired,
335
- "description": PropTypes.string,
336
- "toString": PropTypes.func.isRequired,
337
- "valueOf": PropTypes.func.isRequired
338
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
339
- "__@toStringTag": PropTypes.string.isRequired,
340
- "description": PropTypes.string,
341
- "toString": PropTypes.func.isRequired,
342
- "valueOf": PropTypes.func.isRequired
343
- }), PropTypes.string]),
344
- "margin": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
345
- "__@toStringTag": PropTypes.string.isRequired,
346
- "description": PropTypes.string,
347
- "toString": PropTypes.func.isRequired,
348
- "valueOf": PropTypes.func.isRequired
349
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
350
- "__@toStringTag": PropTypes.string.isRequired,
351
- "description": PropTypes.string,
352
- "toString": PropTypes.func.isRequired,
353
- "valueOf": PropTypes.func.isRequired
354
- }), PropTypes.string]),
355
- "marginBottom": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
356
- "__@toStringTag": PropTypes.string.isRequired,
357
- "description": PropTypes.string,
358
- "toString": PropTypes.func.isRequired,
359
- "valueOf": PropTypes.func.isRequired
360
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
361
- "__@toStringTag": PropTypes.string.isRequired,
362
- "description": PropTypes.string,
363
- "toString": PropTypes.func.isRequired,
364
- "valueOf": PropTypes.func.isRequired
365
- }), PropTypes.string]),
366
- "marginLeft": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
367
- "__@toStringTag": PropTypes.string.isRequired,
368
- "description": PropTypes.string,
369
- "toString": PropTypes.func.isRequired,
370
- "valueOf": PropTypes.func.isRequired
371
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
372
- "__@toStringTag": PropTypes.string.isRequired,
373
- "description": PropTypes.string,
374
- "toString": PropTypes.func.isRequired,
375
- "valueOf": PropTypes.func.isRequired
376
- }), PropTypes.string]),
377
- "marginRight": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
378
- "__@toStringTag": PropTypes.string.isRequired,
379
- "description": PropTypes.string,
380
- "toString": PropTypes.func.isRequired,
381
- "valueOf": PropTypes.func.isRequired
382
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
383
- "__@toStringTag": PropTypes.string.isRequired,
384
- "description": PropTypes.string,
385
- "toString": PropTypes.func.isRequired,
386
- "valueOf": PropTypes.func.isRequired
387
- }), PropTypes.string]),
388
- "marginTop": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
389
- "__@toStringTag": PropTypes.string.isRequired,
390
- "description": PropTypes.string,
391
- "toString": PropTypes.func.isRequired,
392
- "valueOf": PropTypes.func.isRequired
393
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
394
- "__@toStringTag": PropTypes.string.isRequired,
395
- "description": PropTypes.string,
396
- "toString": PropTypes.func.isRequired,
397
- "valueOf": PropTypes.func.isRequired
398
- }), PropTypes.string]),
399
- "marginX": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
400
- "__@toStringTag": PropTypes.string.isRequired,
401
- "description": PropTypes.string,
402
- "toString": PropTypes.func.isRequired,
403
- "valueOf": PropTypes.func.isRequired
404
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
405
- "__@toStringTag": PropTypes.string.isRequired,
406
- "description": PropTypes.string,
407
- "toString": PropTypes.func.isRequired,
408
- "valueOf": PropTypes.func.isRequired
409
- }), PropTypes.string]),
410
- "marginY": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
411
- "__@toStringTag": PropTypes.string.isRequired,
412
- "description": PropTypes.string,
413
- "toString": PropTypes.func.isRequired,
414
- "valueOf": PropTypes.func.isRequired
415
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
416
- "__@toStringTag": PropTypes.string.isRequired,
417
- "description": PropTypes.string,
418
- "toString": PropTypes.func.isRequired,
419
- "valueOf": PropTypes.func.isRequired
420
- }), PropTypes.string]),
421
- "mb": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
422
- "__@toStringTag": PropTypes.string.isRequired,
423
- "description": PropTypes.string,
424
- "toString": PropTypes.func.isRequired,
425
- "valueOf": PropTypes.func.isRequired
426
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
427
- "__@toStringTag": PropTypes.string.isRequired,
428
- "description": PropTypes.string,
429
- "toString": PropTypes.func.isRequired,
430
- "valueOf": PropTypes.func.isRequired
431
- }), PropTypes.string]),
432
- "ml": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
433
- "__@toStringTag": PropTypes.string.isRequired,
434
- "description": PropTypes.string,
435
- "toString": PropTypes.func.isRequired,
436
- "valueOf": PropTypes.func.isRequired
437
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
438
- "__@toStringTag": PropTypes.string.isRequired,
439
- "description": PropTypes.string,
440
- "toString": PropTypes.func.isRequired,
441
- "valueOf": PropTypes.func.isRequired
442
- }), PropTypes.string]),
443
- "mr": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
444
- "__@toStringTag": PropTypes.string.isRequired,
445
- "description": PropTypes.string,
446
- "toString": PropTypes.func.isRequired,
447
- "valueOf": PropTypes.func.isRequired
448
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
449
- "__@toStringTag": PropTypes.string.isRequired,
450
- "description": PropTypes.string,
451
- "toString": PropTypes.func.isRequired,
452
- "valueOf": PropTypes.func.isRequired
453
- }), PropTypes.string]),
454
- "mt": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
455
- "__@toStringTag": PropTypes.string.isRequired,
456
- "description": PropTypes.string,
457
- "toString": PropTypes.func.isRequired,
458
- "valueOf": PropTypes.func.isRequired
459
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
460
- "__@toStringTag": PropTypes.string.isRequired,
461
- "description": PropTypes.string,
462
- "toString": PropTypes.func.isRequired,
463
- "valueOf": PropTypes.func.isRequired
464
- }), PropTypes.string]),
465
- "mx": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
466
- "__@toStringTag": PropTypes.string.isRequired,
467
- "description": PropTypes.string,
468
- "toString": PropTypes.func.isRequired,
469
- "valueOf": PropTypes.func.isRequired
470
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
471
- "__@toStringTag": PropTypes.string.isRequired,
472
- "description": PropTypes.string,
473
- "toString": PropTypes.func.isRequired,
474
- "valueOf": PropTypes.func.isRequired
475
- }), PropTypes.string]),
476
- "my": PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.oneOf([null]), PropTypes.number, PropTypes.shape({
477
- "__@toStringTag": PropTypes.string.isRequired,
478
- "description": PropTypes.string,
479
- "toString": PropTypes.func.isRequired,
480
- "valueOf": PropTypes.func.isRequired
481
- }), PropTypes.string])), PropTypes.number, PropTypes.object, PropTypes.shape({
482
- "__@toStringTag": PropTypes.string.isRequired,
483
- "description": PropTypes.string,
484
- "toString": PropTypes.func.isRequired,
485
- "valueOf": PropTypes.func.isRequired
486
- }), PropTypes.string]),
487
- "onChange": PropTypes.func.isRequired,
488
- "onLinkAdded": PropTypes.func,
489
- "previews": PropTypes.node,
490
- "required": PropTypes.bool,
491
- "rows": PropTypes.number,
492
- "toolbarElements": PropTypes.node,
493
- "value": PropTypes.object.isRequired,
494
- "warning": PropTypes.string
495
- };
496
- }
497
- export { TextEditor };
498
- export const TextEditorState = EditorState;
499
- export const TextEditorContentState = ContentState;
127
+ "data-role": `${namespace}-validation-message`
128
+ }, error || characterLimitWarning || warning), /*#__PURE__*/React.createElement(StyledEditorToolbarWrapper, {
129
+ "data-role": `${namespace}-editor-toolbar-wrapper`,
130
+ id: `${namespace}-editor-toolbar-wrapper`,
131
+ onBlur: () => setIsFocused(false),
132
+ onFocus: () => setIsFocused(true),
133
+ focused: isFocused
134
+ }, /*#__PURE__*/React.createElement(StyledTextEditor, {
135
+ "data-role": `${namespace}-editor`
136
+ }, /*#__PURE__*/React.createElement(RichTextPlugin, {
137
+ contentEditable: /*#__PURE__*/React.createElement(ContentEditor, {
138
+ error: error,
139
+ inputHint: inputHint,
140
+ namespace: namespace,
141
+ previews: previews,
142
+ rows: rows,
143
+ warning: warning
144
+ }),
145
+ placeholder: /*#__PURE__*/React.createElement(Placeholder, {
146
+ namespace: namespace,
147
+ text: placeholder
148
+ }),
149
+ ErrorBoundary: LexicalErrorBoundary
150
+ }), /*#__PURE__*/React.createElement(ListPlugin, null), /*#__PURE__*/React.createElement(HistoryPlugin, null), /*#__PURE__*/React.createElement(MarkdownShortcutPlugin, null), /*#__PURE__*/React.createElement(OnChangePlugin, {
151
+ onChange: handleChange
152
+ }), /*#__PURE__*/React.createElement(LinkPlugin, {
153
+ validateUrl: validateUrl
154
+ }), /*#__PURE__*/React.createElement(ClickableLinkPlugin, {
155
+ newTab: true
156
+ }), /*#__PURE__*/React.createElement(AutoLinkerPlugin, null)), !readOnly && /*#__PURE__*/React.createElement(ToolbarPlugin, toolbarProps), /*#__PURE__*/React.createElement(LinkMonitorPlugin, null)), characterLimit > 0 && !readOnly && /*#__PURE__*/React.createElement(CharacterCounterPlugin, {
157
+ maxChars: characterLimit,
158
+ namespace: namespace
159
+ }))));
160
+ };
500
161
  export default TextEditor;
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ declare const _default: React.Context<{
3
+ onLinkAdded?: ((link: string, state: string) => void) | undefined;
4
+ readOnly?: boolean | undefined;
5
+ }>;
6
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+
3
+ // This is the context that is used to enable cross-component communication
4
+ export default /*#__PURE__*/React.createContext({});