carbon-react 148.0.1 → 149.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 (267) 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/text-editor/__internal__/constants.d.ts +21 -0
  5. package/esm/components/text-editor/__internal__/constants.js +29 -0
  6. package/esm/components/text-editor/__internal__/helpers.d.ts +20 -0
  7. package/esm/components/text-editor/__internal__/helpers.js +84 -0
  8. package/esm/components/text-editor/__internal__/index.d.ts +2 -0
  9. package/esm/components/text-editor/__internal__/index.js +2 -0
  10. package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
  11. package/esm/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +28 -0
  12. package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
  13. package/esm/components/text-editor/__internal__/plugins/AutoLinker/index.js +1 -0
  14. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
  15. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +33 -0
  16. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
  17. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +59 -0
  18. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
  19. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +17 -0
  20. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
  21. package/esm/components/text-editor/__internal__/plugins/CharacterCounter/index.js +1 -0
  22. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
  23. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +40 -0
  24. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
  25. package/esm/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +34 -0
  26. package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
  27. package/esm/components/text-editor/__internal__/plugins/ContentEditor/index.js +1 -0
  28. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
  29. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/index.js +1 -0
  30. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
  31. package/esm/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +62 -0
  32. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
  33. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +1 -0
  34. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
  35. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +19 -0
  36. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
  37. package/esm/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.js +29 -0
  38. package/esm/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
  39. package/esm/components/text-editor/__internal__/plugins/OnChange/index.js +1 -0
  40. package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
  41. package/esm/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +25 -0
  42. package/esm/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
  43. package/esm/components/text-editor/__internal__/plugins/Placeholder/index.js +1 -0
  44. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
  45. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +17 -0
  46. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
  47. package/esm/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +8 -0
  48. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
  49. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +41 -0
  50. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
  51. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +1 -0
  52. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
  53. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +4 -0
  54. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
  55. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +41 -0
  56. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
  57. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +317 -0
  58. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
  59. package/esm/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +29 -0
  60. package/esm/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
  61. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
  62. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +111 -0
  63. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
  64. package/esm/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +57 -0
  65. package/esm/components/text-editor/__internal__/plugins/index.d.ts +9 -0
  66. package/esm/components/text-editor/__internal__/plugins/index.js +9 -0
  67. package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
  68. package/esm/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +71 -0
  69. package/esm/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
  70. package/esm/components/text-editor/__internal__/read-only-rte.component.js +62 -0
  71. package/esm/components/text-editor/__internal__/style.css +7 -0
  72. package/esm/components/text-editor/__internal__/utils.d.ts +4 -0
  73. package/esm/components/text-editor/__internal__/utils.js +14 -0
  74. package/esm/components/text-editor/index.d.ts +2 -1
  75. package/esm/components/text-editor/index.js +2 -1
  76. package/esm/components/text-editor/text-editor.component.d.ts +32 -28
  77. package/esm/components/text-editor/text-editor.component.js +139 -478
  78. package/esm/components/text-editor/text-editor.context.d.ts +6 -0
  79. package/esm/components/text-editor/text-editor.context.js +4 -0
  80. package/esm/components/text-editor/text-editor.style.d.ts +18 -11
  81. package/esm/components/text-editor/text-editor.style.js +55 -52
  82. package/esm/locales/de-de.js +0 -14
  83. package/esm/locales/en-gb.js +18 -14
  84. package/esm/locales/es-es.js +0 -14
  85. package/esm/locales/fr-ca.js +0 -14
  86. package/esm/locales/fr-fr.js +0 -14
  87. package/esm/locales/locale.d.ts +14 -14
  88. package/lib/__internal__/label/label.component.js +3 -0
  89. package/lib/components/note/note.component.d.ts +1 -2
  90. package/lib/components/note/note.component.js +6 -9
  91. package/lib/components/text-editor/__internal__/constants.d.ts +21 -0
  92. package/lib/components/text-editor/__internal__/constants.js +33 -0
  93. package/lib/components/text-editor/__internal__/helpers.d.ts +20 -0
  94. package/lib/components/text-editor/__internal__/helpers.js +91 -0
  95. package/lib/components/text-editor/__internal__/index.d.ts +2 -0
  96. package/lib/components/text-editor/__internal__/index.js +26 -0
  97. package/lib/components/text-editor/__internal__/package.json +6 -0
  98. package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.d.ts +3 -0
  99. package/lib/components/text-editor/__internal__/plugins/AutoLinker/auto-link.component.js +36 -0
  100. package/lib/components/text-editor/__internal__/plugins/AutoLinker/index.d.ts +1 -0
  101. package/lib/components/text-editor/__internal__/{editor-link → plugins/AutoLinker}/index.js +2 -2
  102. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/AutoLinker}/package.json +1 -1
  103. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.d.ts +10 -0
  104. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/__test__/character-counter.component.js +42 -0
  105. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.d.ts +9 -0
  106. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.component.js +68 -0
  107. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.d.ts +3 -0
  108. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/character-counter.style.js +24 -0
  109. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.d.ts +1 -0
  110. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/index.js +13 -0
  111. package/lib/components/text-editor/__internal__/plugins/CharacterCounter/package.json +6 -0
  112. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.d.ts +17 -0
  113. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.component.js +48 -0
  114. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.d.ts +6 -0
  115. package/lib/components/text-editor/__internal__/plugins/ContentEditor/content-editor.style.js +42 -0
  116. package/lib/components/text-editor/__internal__/plugins/ContentEditor/index.d.ts +1 -0
  117. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button → plugins/ContentEditor}/index.js +2 -2
  118. package/lib/components/text-editor/__internal__/plugins/ContentEditor/package.json +6 -0
  119. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/index.d.ts +1 -0
  120. package/lib/components/text-editor/__internal__/{label-wrapper → plugins/LinkMonitor}/index.js +2 -2
  121. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.d.ts +2 -0
  122. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/link-monitor.plugin.js +70 -0
  123. package/lib/components/text-editor/__internal__/plugins/LinkMonitor/package.json +6 -0
  124. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.d.ts +1 -0
  125. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/index.js +13 -0
  126. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.d.ts +11 -0
  127. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.component.js +28 -0
  128. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/link-previewer.style.d.ts +6 -0
  129. package/lib/components/text-editor/__internal__/{toolbar/toolbar-button/toolbar-button.style.js → plugins/LinkPreviewer/link-previewer.style.js} +21 -31
  130. package/lib/components/text-editor/__internal__/plugins/LinkPreviewer/package.json +6 -0
  131. package/lib/components/text-editor/__internal__/plugins/OnChange/index.d.ts +1 -0
  132. package/lib/components/text-editor/__internal__/plugins/OnChange/index.js +13 -0
  133. package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.d.ts +5 -0
  134. package/lib/components/text-editor/__internal__/plugins/OnChange/on-change.plugin.js +32 -0
  135. package/lib/components/text-editor/__internal__/plugins/OnChange/package.json +6 -0
  136. package/lib/components/text-editor/__internal__/plugins/Placeholder/index.d.ts +1 -0
  137. package/lib/components/text-editor/__internal__/plugins/Placeholder/index.js +13 -0
  138. package/lib/components/text-editor/__internal__/plugins/Placeholder/package.json +6 -0
  139. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.d.ts +14 -0
  140. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.component.js +25 -0
  141. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.d.ts +2 -0
  142. package/lib/components/text-editor/__internal__/plugins/Placeholder/placeholder.style.js +15 -0
  143. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.d.ts +4 -0
  144. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/bold.component.js +48 -0
  145. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.d.ts +6 -0
  146. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/common.js +5 -0
  147. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.d.ts +4 -0
  148. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/index.js +34 -0
  149. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.d.ts +4 -0
  150. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/italic.component.js +47 -0
  151. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.d.ts +5 -0
  152. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/list.component.js +325 -0
  153. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/package.json +6 -0
  154. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.d.ts +34 -0
  155. package/lib/components/text-editor/__internal__/plugins/Toolbar/buttons/save.component.js +36 -0
  156. package/lib/components/text-editor/__internal__/plugins/Toolbar/index.d.ts +1 -0
  157. package/lib/components/text-editor/__internal__/plugins/Toolbar/package.json +6 -0
  158. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.d.ts +12 -0
  159. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.component.js +120 -0
  160. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.d.ts +11 -0
  161. package/lib/components/text-editor/__internal__/plugins/Toolbar/toolbar.style.js +65 -0
  162. package/lib/components/text-editor/__internal__/plugins/index.d.ts +9 -0
  163. package/lib/components/text-editor/__internal__/plugins/index.js +69 -0
  164. package/lib/components/text-editor/__internal__/{toolbar → plugins}/package.json +1 -1
  165. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.d.ts +2 -0
  166. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/index.js +78 -0
  167. package/lib/components/text-editor/__internal__/plugins/useCursorAtEnd/package.json +6 -0
  168. package/lib/components/text-editor/__internal__/read-only-rte.component.d.ts +4 -0
  169. package/lib/components/text-editor/__internal__/read-only-rte.component.js +72 -0
  170. package/lib/components/text-editor/__internal__/style.css +7 -0
  171. package/lib/components/text-editor/__internal__/utils.d.ts +4 -0
  172. package/lib/components/text-editor/__internal__/utils.js +21 -0
  173. package/lib/components/text-editor/index.d.ts +2 -1
  174. package/lib/components/text-editor/index.js +7 -7
  175. package/lib/components/text-editor/text-editor.component.d.ts +32 -28
  176. package/lib/components/text-editor/text-editor.component.js +141 -477
  177. package/lib/components/text-editor/text-editor.context.d.ts +6 -0
  178. package/lib/components/text-editor/{__internal__/editor.context.js → text-editor.context.js} +1 -0
  179. package/lib/components/text-editor/text-editor.style.d.ts +18 -11
  180. package/lib/components/text-editor/text-editor.style.js +57 -53
  181. package/lib/locales/de-de.js +0 -14
  182. package/lib/locales/en-gb.js +18 -14
  183. package/lib/locales/es-es.js +0 -14
  184. package/lib/locales/fr-ca.js +0 -14
  185. package/lib/locales/fr-fr.js +0 -14
  186. package/lib/locales/locale.d.ts +14 -14
  187. package/package.json +6 -4
  188. package/esm/components/text-editor/__internal__/decorators/index.d.ts +0 -3
  189. package/esm/components/text-editor/__internal__/decorators/index.js +0 -3
  190. package/esm/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
  191. package/esm/components/text-editor/__internal__/decorators/link-decorator.js +0 -37
  192. package/esm/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
  193. package/esm/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -36
  194. package/esm/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
  195. package/esm/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -13
  196. package/esm/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
  197. package/esm/components/text-editor/__internal__/editor-link/index.js +0 -1
  198. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
  199. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -18
  200. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
  201. package/esm/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -11
  202. package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
  203. package/esm/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -1
  204. package/esm/components/text-editor/__internal__/editor.context.d.ts +0 -6
  205. package/esm/components/text-editor/__internal__/editor.context.js +0 -2
  206. package/esm/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
  207. package/esm/components/text-editor/__internal__/label-wrapper/index.js +0 -1
  208. package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
  209. package/esm/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -18
  210. package/esm/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
  211. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
  212. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/index.js +0 -1
  213. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
  214. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -50
  215. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
  216. package/esm/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.js +0 -38
  217. package/esm/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
  218. package/esm/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -158
  219. package/esm/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
  220. package/esm/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -28
  221. package/esm/components/text-editor/__internal__/utils/index.d.ts +0 -1
  222. package/esm/components/text-editor/__internal__/utils/index.js +0 -1
  223. package/esm/components/text-editor/__internal__/utils/utils.d.ts +0 -29
  224. package/esm/components/text-editor/__internal__/utils/utils.js +0 -174
  225. package/esm/components/text-editor/types.d.ts +0 -6
  226. package/esm/components/text-editor/types.js +0 -4
  227. package/lib/components/text-editor/__internal__/decorators/index.d.ts +0 -3
  228. package/lib/components/text-editor/__internal__/decorators/index.js +0 -10
  229. package/lib/components/text-editor/__internal__/decorators/link-decorator.d.ts +0 -8
  230. package/lib/components/text-editor/__internal__/decorators/link-decorator.js +0 -44
  231. package/lib/components/text-editor/__internal__/decorators/package.json +0 -6
  232. package/lib/components/text-editor/__internal__/editor-link/editor-link.component.d.ts +0 -9
  233. package/lib/components/text-editor/__internal__/editor-link/editor-link.component.js +0 -45
  234. package/lib/components/text-editor/__internal__/editor-link/editor-link.style.d.ts +0 -3
  235. package/lib/components/text-editor/__internal__/editor-link/editor-link.style.js +0 -20
  236. package/lib/components/text-editor/__internal__/editor-link/index.d.ts +0 -2
  237. package/lib/components/text-editor/__internal__/editor-link/package.json +0 -6
  238. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.d.ts +0 -11
  239. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.component.js +0 -25
  240. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.d.ts +0 -2
  241. package/lib/components/text-editor/__internal__/editor-validation-wrapper/editor-validation-wrapper.style.js +0 -18
  242. package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.d.ts +0 -2
  243. package/lib/components/text-editor/__internal__/editor-validation-wrapper/index.js +0 -13
  244. package/lib/components/text-editor/__internal__/editor-validation-wrapper/package.json +0 -6
  245. package/lib/components/text-editor/__internal__/editor.context.d.ts +0 -6
  246. package/lib/components/text-editor/__internal__/label-wrapper/index.d.ts +0 -2
  247. package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.d.ts +0 -12
  248. package/lib/components/text-editor/__internal__/label-wrapper/label-wrapper.component.js +0 -25
  249. package/lib/components/text-editor/__internal__/label-wrapper/package.json +0 -6
  250. package/lib/components/text-editor/__internal__/toolbar/index.d.ts +0 -2
  251. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/index.d.ts +0 -2
  252. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.d.ts +0 -25
  253. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.component.js +0 -56
  254. package/lib/components/text-editor/__internal__/toolbar/toolbar-button/toolbar-button.style.d.ts +0 -6
  255. package/lib/components/text-editor/__internal__/toolbar/toolbar.component.d.ts +0 -16
  256. package/lib/components/text-editor/__internal__/toolbar/toolbar.component.js +0 -167
  257. package/lib/components/text-editor/__internal__/toolbar/toolbar.style.d.ts +0 -4
  258. package/lib/components/text-editor/__internal__/toolbar/toolbar.style.js +0 -34
  259. package/lib/components/text-editor/__internal__/utils/index.d.ts +0 -1
  260. package/lib/components/text-editor/__internal__/utils/index.js +0 -90
  261. package/lib/components/text-editor/__internal__/utils/package.json +0 -6
  262. package/lib/components/text-editor/__internal__/utils/utils.d.ts +0 -29
  263. package/lib/components/text-editor/__internal__/utils/utils.js +0 -197
  264. package/lib/components/text-editor/types.d.ts +0 -6
  265. package/lib/components/text-editor/types.js +0 -10
  266. /package/esm/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
  267. /package/lib/components/text-editor/__internal__/{toolbar → plugins/Toolbar}/index.js +0 -0
@@ -1,11 +1,12 @@
1
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, { useState, useContext } from "react";
2
+ import React, { useState, useContext, useRef } from "react";
3
3
  import PropTypes from "prop-types";
4
4
  import Help from "../../components/help";
5
5
  import StyledLabel, { StyledLabelContainer } from "./label.style";
6
6
  import ValidationIcon from "../validations/validation-icon.component";
7
7
  import StyledIconWrapper from "./icon-wrapper.style";
8
8
  import { InputContext, InputGroupContext } from "../input-behaviour";
9
+ import createGuid from "../../__internal__/utils/helpers/guid";
9
10
  const shouldDisplayValidationIcon = ({
10
11
  error,
11
12
  warning,
@@ -57,6 +58,7 @@ export const Label = ({
57
58
  onMouseEnter: onGroupMouseEnter,
58
59
  onMouseLeave: onGroupMouseLeave
59
60
  } = useContext(InputGroupContext);
61
+ const guid = useRef(createGuid());
60
62
  const handleMouseEnter = () => {
61
63
  if (onMouseEnter) onMouseEnter();
62
64
  if (onGroupMouseEnter) onGroupMouseEnter();
@@ -107,6 +109,7 @@ export const Label = ({
107
109
  };
108
110
  return /*#__PURE__*/React.createElement(StyledLabelContainer, {
109
111
  "data-role": "label-container",
112
+ id: `label-container-${labelId ?? guid.current}`,
110
113
  align: alignment,
111
114
  inline: inline,
112
115
  width: width,
@@ -1,5 +1,4 @@
1
1
  import React from "react";
2
- import { EditorState } from "draft-js";
3
2
  import { MarginProps } from "styled-system";
4
3
  export interface NoteProps extends MarginProps {
5
4
  /** Adds a created on date to the Note footer */
@@ -9,7 +8,7 @@ export interface NoteProps extends MarginProps {
9
8
  /** Adds a name to the Note footer */
10
9
  name?: string;
11
10
  /** The rich text content to display in the Note */
12
- noteContent: EditorState;
11
+ noteContent: string;
13
12
  /** Callback to report a url when a link is added */
14
13
  onLinkAdded?: (url: string) => void;
15
14
  /** The previews to display of any links added to the Editor */
@@ -1,13 +1,12 @@
1
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
2
  import React from "react";
3
3
  import PropTypes from "prop-types";
4
- import { Editor } from "draft-js";
5
4
  import invariant from "invariant";
6
5
  import { StyledNote, StyledNoteContent, StyledNoteMain, StyledInlineControl, StyledTitleWrapper, StyledFooter, StyledFooterContent } from "./note.style";
7
6
  import StatusIcon from "./__internal__/status-icon";
8
7
  import { ActionPopover } from "../action-popover";
9
- import { getDecoratedValue } from "../text-editor/__internal__/utils";
10
- import EditorContext from "../text-editor/__internal__/editor.context";
8
+ import ReadOnlyEditor from "../text-editor/__internal__";
9
+ import TextEditorContext from "../text-editor/text-editor.context";
11
10
  import LinkPreview from "../link-preview";
12
11
  import Typography from "../typography";
13
12
  function hasExpectedDisplayName(child, displayName) {
@@ -42,10 +41,10 @@ export const Note = ({
42
41
  tooltipMessage: timeStamp
43
42
  }, text));
44
43
  };
45
- return /*#__PURE__*/React.createElement(EditorContext.Provider, {
44
+ return /*#__PURE__*/React.createElement(TextEditorContext.Provider, {
46
45
  value: {
47
46
  onLinkAdded,
48
- editMode: false
47
+ readOnly: true
49
48
  }
50
49
  }, /*#__PURE__*/React.createElement(StyledNote, _extends({
51
50
  width: width
@@ -58,10 +57,8 @@ export const Note = ({
58
57
  lineHeight: "21px",
59
58
  paddingBottom: "16px",
60
59
  variant: "h2"
61
- }, title) : /*#__PURE__*/React.createElement(StyledTitleWrapper, null, title)), /*#__PURE__*/React.createElement(Editor, {
62
- readOnly: true,
63
- editorState: getDecoratedValue(noteContent),
64
- onChange: /* istanbul ignore next */() => {}
60
+ }, title) : /*#__PURE__*/React.createElement(StyledTitleWrapper, null, title)), /*#__PURE__*/React.createElement(ReadOnlyEditor, {
61
+ value: noteContent
65
62
  })), inlineControl && /*#__PURE__*/React.createElement(StyledInlineControl, null, inlineControl)), /*#__PURE__*/React.createElement(StyledNoteContent, null, React.Children.map(previews, preview => /*#__PURE__*/React.isValidElement(preview) && hasExpectedDisplayName(preview, LinkPreview.displayName) ? /*#__PURE__*/React.cloneElement(preview, {
66
63
  as: "a",
67
64
  onClose: undefined
@@ -0,0 +1,21 @@
1
+ import { CodeNode } from "@lexical/code";
2
+ import { LinkNode } from "@lexical/link";
3
+ import { ListNode, ListItemNode, ListType } from "@lexical/list";
4
+ import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
5
+ import { HeadingNode, QuoteNode } from "@lexical/rich-text";
6
+ import { EditorThemeClasses, TextFormatType } from "lexical";
7
+ import "./style.css";
8
+ /** The default prefix applied to the editor's internal class names, IDs, etc. */
9
+ declare const COMPONENT_PREFIX = "carbon-rte";
10
+ /** The theme overrides needed to correctly style the editor */
11
+ declare const theme: EditorThemeClasses;
12
+ /** The available actions that can be used in the editor */
13
+ declare const TextEditorActionTypes: {
14
+ Bold: TextFormatType;
15
+ Italic: TextFormatType;
16
+ OrderedList: ListType;
17
+ UnorderedList: ListType;
18
+ };
19
+ /** The nodes supported by markdown */
20
+ declare const markdownNodes: (typeof LinkNode | typeof CodeNode | typeof ListNode | typeof ListItemNode | typeof HeadingNode | typeof QuoteNode | typeof HorizontalRuleNode)[];
21
+ export { COMPONENT_PREFIX, markdownNodes, TextEditorActionTypes, theme };
@@ -0,0 +1,29 @@
1
+ import { CodeNode } from "@lexical/code";
2
+ import { LinkNode, AutoLinkNode } from "@lexical/link";
3
+ import { ListNode, ListItemNode } from "@lexical/list";
4
+ import { HorizontalRuleNode } from "@lexical/react/LexicalHorizontalRuleNode";
5
+ import { HeadingNode, QuoteNode } from "@lexical/rich-text";
6
+ import "./style.css";
7
+
8
+ /** The default prefix applied to the editor's internal class names, IDs, etc. */
9
+ const COMPONENT_PREFIX = "carbon-rte";
10
+
11
+ /** The theme overrides needed to correctly style the editor */
12
+ const theme = {
13
+ text: {
14
+ bold: "textBold",
15
+ italic: "textItalic"
16
+ }
17
+ };
18
+
19
+ /** The available actions that can be used in the editor */
20
+ const TextEditorActionTypes = {
21
+ Bold: "bold",
22
+ Italic: "italic",
23
+ OrderedList: "number",
24
+ UnorderedList: "bullet"
25
+ };
26
+
27
+ /** The nodes supported by markdown */
28
+ const markdownNodes = [AutoLinkNode, CodeNode, LinkNode, ListNode, ListItemNode, HeadingNode, QuoteNode, HorizontalRuleNode];
29
+ export { COMPONENT_PREFIX, markdownNodes, TextEditorActionTypes, theme };
@@ -0,0 +1,20 @@
1
+ import { LexicalEditor } from "lexical";
2
+ /**
3
+ * This helper takes the current state of the editor and serializes it into two formats:
4
+ * 1. HTML
5
+ * 2. JSON
6
+ * This allows the editor state to be saved and restored at a later time, in a format suitable
7
+ * for the majority of customers' use cases.
8
+ */
9
+ declare const SerializeLexical: (editor: LexicalEditor) => {
10
+ htmlString: undefined;
11
+ json: undefined;
12
+ };
13
+ /**
14
+ * This helper takes an HTML string and deserializes it into the editor.
15
+ * This allows the editor to be restored from a previously saved state.
16
+ */
17
+ declare const DeserializeHTML: (html: string) => string;
18
+ /** Function to validate a given URL */
19
+ declare function validateUrl(url: string): boolean;
20
+ export { DeserializeHTML, SerializeLexical, validateUrl };
@@ -0,0 +1,84 @@
1
+ import { createHeadlessEditor } from "@lexical/headless";
2
+ import { $generateHtmlFromNodes, $generateNodesFromDOM } from "@lexical/html";
3
+ import { $getRoot, $getSelection } from "lexical";
4
+ import { markdownNodes, theme } from "./constants";
5
+
6
+ /**
7
+ * This helper takes the current state of the editor and serializes it into two formats:
8
+ * 1. HTML
9
+ * 2. JSON
10
+ * This allows the editor state to be saved and restored at a later time, in a format suitable
11
+ * for the majority of customers' use cases.
12
+ */
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
+ const SerializeLexical = editor => {
15
+ let htmlString;
16
+ let json;
17
+ editor.update(() => {
18
+ // Get the current editor state
19
+ const editorState = editor.getEditorState();
20
+ // Serialize the editor state to JSON
21
+ json = editorState.toJSON();
22
+ // Generate HTML from the editor state
23
+ htmlString = $generateHtmlFromNodes(editor, null);
24
+ });
25
+ return {
26
+ htmlString,
27
+ json
28
+ };
29
+ };
30
+
31
+ /**
32
+ * This helper takes an HTML string and deserializes it into the editor.
33
+ * This allows the editor to be restored from a previously saved state.
34
+ */
35
+ const DeserializeHTML = html => {
36
+ // Create a new headless editor instance. This allows us to process the editor state
37
+ // without needing to render the editor itself.
38
+ const editor = createHeadlessEditor({
39
+ namespace: "html-to-json",
40
+ // eslint-disable-next-line no-console
41
+ onError: console.error,
42
+ theme,
43
+ nodes: markdownNodes
44
+ });
45
+ let parsingError;
46
+ editor.update(() => {
47
+ // Parse the HTML string into a DOM
48
+ const parser = new DOMParser();
49
+ const dom = parser.parseFromString(html, "text/html");
50
+ // Generate nodes from the DOM
51
+ const nodes = $generateNodesFromDOM(editor, dom);
52
+ // Select the root of the editor
53
+ $getRoot().select();
54
+ // Insert the nodes into the editor
55
+ const selection = $getSelection();
56
+ /* istanbul ignore else */
57
+ if (selection) {
58
+ try {
59
+ selection.insertNodes(nodes);
60
+ } catch (err) {
61
+ /* istanbul ignore next */
62
+ parsingError = err;
63
+ }
64
+ }
65
+ }, {
66
+ discrete: true
67
+ });
68
+
69
+ /* istanbul ignore next */
70
+ if (parsingError) {
71
+ throw parsingError;
72
+ }
73
+
74
+ // Return the editor instance
75
+ const json = editor.getEditorState().toJSON();
76
+ return JSON.stringify(json);
77
+ };
78
+ const urlRegExp = new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);
79
+
80
+ /** Function to validate a given URL */
81
+ function validateUrl(url) {
82
+ return url === "https://" || urlRegExp.test(url);
83
+ }
84
+ export { DeserializeHTML, SerializeLexical, validateUrl };
@@ -0,0 +1,2 @@
1
+ export { default } from "./read-only-rte.component";
2
+ export { createEmpty, createFromHTML } from "./utils";
@@ -0,0 +1,2 @@
1
+ export { default } from "./read-only-rte.component";
2
+ export { createEmpty, createFromHTML } from "./utils";
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const AutoLinkerPlugin: () => React.JSX.Element;
3
+ export default AutoLinkerPlugin;
@@ -0,0 +1,28 @@
1
+ /* istanbul ignore file */
2
+ /**
3
+ * Owing to the nature of how this plugin runs, it is not possible to test it in isolation.
4
+ * It is tested as part of the TextEditor Playwright tests.
5
+ *
6
+ * The AutoLinkerPlugin component is a wrapper around the AutoLinkPlugin component provided
7
+ * by Lexical. It is used to automatically convert URLs and email addresses into clickable
8
+ * links.
9
+ *
10
+ * The regular expressions used to match URLs and email addresses are provided as per the
11
+ * Lexical documentation; as such not all edge cases may be covered.
12
+ */
13
+ import { AutoLinkPlugin, createLinkMatcherWithRegExp } from "@lexical/react/LexicalAutoLinkPlugin";
14
+ import React from "react";
15
+ import PropTypes from "prop-types";
16
+ const URL_REGEX = /((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/;
17
+ const EMAIL_REGEX = /(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
18
+ const MATCHERS = [createLinkMatcherWithRegExp(URL_REGEX, text => {
19
+ return text.startsWith("http") ? text : `https://${text}`;
20
+ }), createLinkMatcherWithRegExp(EMAIL_REGEX, text => {
21
+ return `mailto:${text}`;
22
+ })];
23
+ const AutoLinkerPlugin = () => {
24
+ return /*#__PURE__*/React.createElement(AutoLinkPlugin, {
25
+ matchers: MATCHERS
26
+ });
27
+ };
28
+ export default AutoLinkerPlugin;
@@ -0,0 +1 @@
1
+ export { default } from "./auto-link.component";
@@ -0,0 +1 @@
1
+ export { default } from "./auto-link.component";
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ import { LexicalEditor } from "lexical";
3
+ export interface CharacterCounterPluginProps {
4
+ /** The maximum number of characters to allow before showing the warning */
5
+ maxChars: number;
6
+ /** The Lexical editor instance */
7
+ editor: LexicalEditor;
8
+ }
9
+ declare const CharacterCounterPlugin: ({ maxChars, editor, }: CharacterCounterPluginProps) => React.JSX.Element;
10
+ export default CharacterCounterPlugin;
@@ -0,0 +1,33 @@
1
+ import React, { useEffect, useMemo, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { $getRoot } from "lexical";
4
+ const CharacterCounterPlugin = ({
5
+ maxChars,
6
+ editor
7
+ }) => {
8
+ const [rawContent, setRawContent] = useState("");
9
+
10
+ // Simplified update listener using Lexical v0.21.0 approach
11
+ useEffect(() => {
12
+ const removeListener = editor.registerUpdateListener(() => {
13
+ const editorState = editor.getEditorState();
14
+ editorState.read(() => {
15
+ const newContent = $getRoot().getTextContent();
16
+ setRawContent(newContent);
17
+ });
18
+ });
19
+ return () => {
20
+ removeListener();
21
+ };
22
+ }, [editor]);
23
+
24
+ // Calculate the number of characters remaining
25
+ const rawCharactersRemaining = useMemo(() => {
26
+ const activeCount = maxChars - (rawContent ? rawContent.length : 0);
27
+ return activeCount >= 0 ? activeCount : 0;
28
+ }, [maxChars, rawContent]);
29
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
30
+ "data-role": "visible-counter"
31
+ }, rawCharactersRemaining));
32
+ };
33
+ export default CharacterCounterPlugin;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ export interface CharacterCounterPluginProps {
3
+ /** The maximum number of characters to allow before showing the warning */
4
+ maxChars: number;
5
+ /** The namespace of the editor that this counter belongs to */
6
+ namespace: string;
7
+ }
8
+ declare const CharacterCounterPlugin: ({ maxChars, namespace, }: CharacterCounterPluginProps) => React.JSX.Element;
9
+ export default CharacterCounterPlugin;
@@ -0,0 +1,59 @@
1
+ import React, { useCallback, useEffect, useMemo, useState } from "react";
2
+ import PropTypes from "prop-types";
3
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
4
+ import { $getRoot } from "lexical";
5
+ import { StyledCharacterCounter, VisuallyHiddenCharacterCounter } from "./character-counter.style";
6
+ import useDebounce from "../../../../../hooks/__internal__/useDebounce";
7
+ import useLocale from "../../../../../hooks/__internal__/useLocale";
8
+ const CharacterCounterPlugin = ({
9
+ maxChars,
10
+ namespace
11
+ }) => {
12
+ const [rawContent, setRawContent] = useState("");
13
+ const [editor] = useLexicalComposerContext();
14
+ useEffect(() => {
15
+ // The character counter plugin listens for updates to the editor state
16
+ // independently to ensure updates do not conflict/interrupt other state
17
+ // changes
18
+ editor.registerUpdateListener(({
19
+ editorState
20
+ }) => {
21
+ editorState.read(() => {
22
+ const newContent = $getRoot().getTextContent();
23
+ setRawContent(newContent);
24
+ });
25
+ });
26
+ }, [editor]);
27
+
28
+ // Get the locale to enable translations
29
+ const locale = useLocale();
30
+
31
+ // Get the current locale and format the number
32
+ const getFormatNumber = useCallback(rawValue => {
33
+ return new Intl.NumberFormat(locale.locale()).format(rawValue);
34
+ }, [locale]);
35
+ const [debouncedValue, setDebouncedValue] = useState(0);
36
+
37
+ // Calculate the number of characters remaining
38
+ const rawCharactersRemaining = useMemo(() => {
39
+ // Calculate the number of characters remaining
40
+ const activeCount = maxChars - (rawContent ? rawContent.length : 0);
41
+ // Return the active count if it is greater than 0, otherwise return 0
42
+ return activeCount >= 0 ? activeCount : 0;
43
+ }, [rawContent, maxChars]);
44
+
45
+ // Use a debounced value to update the remaining character count for screen readers to use
46
+ /* istanbul ignore next */
47
+ const debouncedText = useDebounce(newValue => {
48
+ setDebouncedValue(newValue || 0);
49
+ }, 2000);
50
+ useEffect(() => {
51
+ debouncedText(rawCharactersRemaining);
52
+ }, [rawCharactersRemaining, debouncedText]);
53
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(StyledCharacterCounter, {
54
+ "data-role": `${namespace}-character-limit`
55
+ }, locale.textEditor.characterCounter(getFormatNumber(rawCharactersRemaining))), /*#__PURE__*/React.createElement(VisuallyHiddenCharacterCounter, {
56
+ "aria-live": "polite"
57
+ }, locale.textEditor.characterCounter(getFormatNumber(debouncedValue))));
58
+ };
59
+ export default CharacterCounterPlugin;
@@ -0,0 +1,3 @@
1
+ export declare const StyledCharacterCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const VisuallyHiddenCharacterCounter: import("styled-components").StyledComponent<"div", any, {}, never>;
3
+ export default StyledCharacterCounter;
@@ -0,0 +1,17 @@
1
+ import styled from "styled-components";
2
+ import visuallyHidden from "../../../../../style/utils/visually-hidden";
3
+ export const StyledCharacterCounter = styled.div`
4
+ text-align: left;
5
+ font-size: var(--fontSizes100);
6
+ margin-top: var(--spacing050);
7
+ margin-bottom: var(--spacing050);
8
+ color: var(--colorsUtilityYin055);
9
+ `;
10
+ export const VisuallyHiddenCharacterCounter = styled.div`
11
+ ::after {
12
+ content: " ";
13
+ }
14
+
15
+ ${visuallyHidden}
16
+ `;
17
+ export default StyledCharacterCounter;
@@ -0,0 +1 @@
1
+ export { default } from "./character-counter.component";
@@ -0,0 +1 @@
1
+ export { default } from "./character-counter.component";
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ export interface ContentEditorProps {
3
+ /** The active error message of the editor */
4
+ error?: string;
5
+ /** A hint string rendered before the editor but after the label. Intended to describe the purpose or content of the input. */
6
+ inputHint?: string;
7
+ /** The namespace of the editor that this content editor belongs to */
8
+ namespace: string;
9
+ /** The link previews to render at the foot of the editor */
10
+ previews?: React.JSX.Element[];
11
+ /** The number of rows to render in the editor */
12
+ rows?: number;
13
+ /** The active warning message of the editor */
14
+ warning?: string;
15
+ }
16
+ declare const ContentEditor: ({ error, inputHint, namespace, previews, rows, warning, }: ContentEditorProps) => React.JSX.Element;
17
+ export default ContentEditor;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * This is where the actual content editor is rendered. It uses the `ContentEditable` component from the `@lexical/react` package
3
+ * as per their documentation. It also uses the `LinkPreviewerPlugin` to render link previews.
4
+ */
5
+ import { ContentEditable } from "@lexical/react/LexicalContentEditable";
6
+ import React from "react";
7
+ import PropTypes from "prop-types";
8
+ import StyledContentEditable from "./content-editor.style";
9
+ import { LinkPreviewerPlugin, useCursorAtEnd } from "..";
10
+ const ContentEditor = ({
11
+ error,
12
+ inputHint,
13
+ namespace,
14
+ previews = [],
15
+ rows,
16
+ warning
17
+ }) => {
18
+ const focusAtEnd = useCursorAtEnd();
19
+ return /*#__PURE__*/React.createElement(StyledContentEditable, {
20
+ "data-role": `${namespace}-content-editable`,
21
+ error: error,
22
+ namespace: namespace,
23
+ rows: rows,
24
+ warning: warning
25
+ }, /*#__PURE__*/React.createElement(ContentEditable, {
26
+ "aria-describedby": inputHint && `${namespace}-input-hint`,
27
+ "aria-labelledby": `${namespace}-label`,
28
+ className: `${namespace}-editable`,
29
+ "data-role": `${namespace}-editable`,
30
+ onFocus: focusAtEnd
31
+ /** The following are automatically added by Lexical but violate WCAG 4.1.2 Name, Role, Value and so have been overriden */,
32
+ "aria-autocomplete": undefined,
33
+ "aria-readonly": undefined
34
+ }), /*#__PURE__*/React.createElement(LinkPreviewerPlugin, {
35
+ error: error,
36
+ previews: previews,
37
+ warning: warning
38
+ }));
39
+ };
40
+ export default ContentEditor;
@@ -0,0 +1,6 @@
1
+ import { ContentEditorProps } from "./content-editor.component";
2
+ interface StyledContentEditableProps extends ContentEditorProps {
3
+ showBorders?: boolean;
4
+ }
5
+ declare const StyledContentEditable: import("styled-components").StyledComponent<"div", any, StyledContentEditableProps, never>;
6
+ export default StyledContentEditable;
@@ -0,0 +1,34 @@
1
+ import styled, { css } from "styled-components";
2
+ const DEFAULT_EDITOR_HEIGHT = 210;
3
+ const FIXED_LINE_HEIGHT = 21;
4
+ const StyledContentEditable = styled.div`
5
+ ${({
6
+ error,
7
+ namespace,
8
+ rows,
9
+ warning
10
+ }) => css`
11
+ .${namespace}-editable {
12
+ min-height: ${rows && rows > 2 ? rows * FIXED_LINE_HEIGHT : DEFAULT_EDITOR_HEIGHT}px;
13
+ background-color: var(--colorsUtilityYang100);
14
+ border-top: 1px solid var(--colorsUtilityMajor200);
15
+ border-left: 1px solid var(--colorsUtilityMajor200);
16
+ border-right: 1px solid var(--colorsUtilityMajor200);
17
+ margin: 0;
18
+ padding: 2px 8px;
19
+ border-top-left-radius: var(--borderWidth600);
20
+ border-top-right-radius: var(--borderWidth600);
21
+ border-bottom-left-radius: 0;
22
+ border-bottom-right-radius: 0;
23
+
24
+ ${(error || warning) && css`
25
+ border: none;
26
+ `}
27
+
28
+ :focus {
29
+ outline: none;
30
+ }
31
+ }
32
+ `}
33
+ `;
34
+ export default StyledContentEditable;
@@ -0,0 +1 @@
1
+ export { default } from "./content-editor.component";
@@ -0,0 +1 @@
1
+ export { default } from "./content-editor.component";
@@ -0,0 +1 @@
1
+ export { default } from "./link-monitor.plugin";
@@ -0,0 +1 @@
1
+ export { default } from "./link-monitor.plugin";
@@ -0,0 +1,2 @@
1
+ declare const LinkMonitorPlugin: () => null;
2
+ export default LinkMonitorPlugin;
@@ -0,0 +1,62 @@
1
+ /* istanbul ignore file */
2
+ /**
3
+ * Owing to the nature of how this plugin runs, it is not possible to test it in isolation.
4
+ * It is tested as part of the TextEditor Playwright tests.
5
+ *
6
+ * The purpose of this plugin is to monitor the editor for any changes that result in the
7
+ * creation of AutoLinkNodes, and report these changes to the customer (e.g. to then
8
+ * generate link previews).
9
+ */
10
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
11
+ import { AutoLinkNode } from "@lexical/link";
12
+ import { useContext, useEffect } from "react";
13
+ import { validateUrl } from "../../helpers";
14
+ import TextEditorContext from "../../../text-editor.context";
15
+ const LinkMonitorPlugin = () => {
16
+ // Get the editor instance
17
+ const [editor] = useLexicalComposerContext();
18
+ // Get the onLinkAdded function from the context
19
+ const {
20
+ onLinkAdded
21
+ } = useContext(TextEditorContext);
22
+ useEffect(() => {
23
+ // Register a mutation listener for AutoLinkNodes
24
+ const removeAutoLinkMutationListener = editor.registerMutationListener(AutoLinkNode, (mutatedNodes, {
25
+ prevEditorState
26
+ }) => {
27
+ const isEditable = editor.isEditable();
28
+ if (!isEditable) return;
29
+
30
+ // For each AutoLinkNode, check if the text content is present and also a valid URL
31
+ for (const [nodeKey, mutation] of mutatedNodes) {
32
+ const node = editor.getElementByKey(nodeKey);
33
+ const textContent = node?.innerText;
34
+ if (textContent) {
35
+ const linkValid = validateUrl(textContent);
36
+ if (linkValid) {
37
+ // Assume link has been created, notify user
38
+ onLinkAdded?.(textContent, mutation);
39
+ }
40
+ } else {
41
+ // Assume link has been destroyed, notify user
42
+ const deletedData = prevEditorState?._nodeMap.get(nodeKey);
43
+ if (deletedData) {
44
+ const {
45
+ __url
46
+ } = deletedData;
47
+ onLinkAdded?.(__url, mutation);
48
+ }
49
+ }
50
+ }
51
+ }, {
52
+ skipInitialization: false
53
+ });
54
+
55
+ // Remove the mutation listener when the component is unmounted
56
+ return () => {
57
+ removeAutoLinkMutationListener();
58
+ };
59
+ }, [editor, onLinkAdded]);
60
+ return null;
61
+ };
62
+ export default LinkMonitorPlugin;
@@ -0,0 +1 @@
1
+ export { default } from "./link-previewer.component";
@@ -0,0 +1 @@
1
+ export { default } from "./link-previewer.component";
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ export interface LinkPreviewerProps {
3
+ /** The active error message of the editor */
4
+ error?: string;
5
+ /** The link previews to render at the foot of the editor */
6
+ previews?: React.JSX.Element[];
7
+ /** The active warning message of the editor */
8
+ warning?: string;
9
+ }
10
+ declare const LinkPreviewer: ({ error, previews, warning, }: LinkPreviewerProps) => React.JSX.Element;
11
+ export default LinkPreviewer;