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
@@ -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;
@@ -0,0 +1,19 @@
1
+ import React, { useContext } from "react";
2
+ import PropTypes from "prop-types";
3
+ import TextEditorContext from "../../../text-editor.context";
4
+ import StyledLinkPreviewer from "./link-previewer.style";
5
+ const LinkPreviewer = ({
6
+ error,
7
+ previews = [],
8
+ warning
9
+ }) => {
10
+ const {
11
+ readOnly
12
+ } = useContext(TextEditorContext);
13
+ return /*#__PURE__*/React.createElement(StyledLinkPreviewer, {
14
+ error: error,
15
+ readOnly: readOnly,
16
+ warning: warning
17
+ }, previews);
18
+ };
19
+ export default LinkPreviewer;
@@ -0,0 +1,6 @@
1
+ import { LinkPreviewerProps } from "./link-previewer.component";
2
+ interface StyledLinkPreviewerProps extends LinkPreviewerProps {
3
+ readOnly?: boolean;
4
+ }
5
+ declare const StyledLinkPreviewer: import("styled-components").StyledComponent<"div", any, StyledLinkPreviewerProps, never>;
6
+ export default StyledLinkPreviewer;
@@ -0,0 +1,29 @@
1
+ import styled, { css } from "styled-components";
2
+ const StyledLinkPreviewer = styled.div`
3
+ ${({
4
+ error,
5
+ readOnly,
6
+ warning
7
+ }) => css`
8
+ border-bottom-left-radius: 0;
9
+ border-bottom-right-radius: 0;
10
+ background-color: var(--colorsUtilityYang100);
11
+ border-bottom: 1px solid var(--colorsUtilityMajor200);
12
+ border-left: 1px solid var(--colorsUtilityMajor200);
13
+ border-right: 1px solid var(--colorsUtilityMajor200);
14
+ margin: 0;
15
+ padding: 2px 8px;
16
+
17
+ ${(error || warning) && css`
18
+ border-left: none;
19
+ border-right: none;
20
+ border-bottom: none;
21
+ `}
22
+
23
+ ${readOnly && css`
24
+ border-bottom-left-radius: var(--borderWidth600);
25
+ border-bottom-right-radius: var(--borderWidth600);
26
+ `}
27
+ `}
28
+ `;
29
+ export default StyledLinkPreviewer;
@@ -0,0 +1 @@
1
+ export { default } from "./on-change.plugin";
@@ -0,0 +1 @@
1
+ export { default } from "./on-change.plugin";
@@ -0,0 +1,5 @@
1
+ import { EditorState } from "lexical";
2
+ declare const OnChangePlugin: (props: {
3
+ onChange: (editorState: EditorState) => void;
4
+ }) => null;
5
+ export default OnChangePlugin;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * This plugin listens to changes in the editor and calls the `onChange` prop with the new editor state.
3
+ */
4
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
5
+ import { useEffect } from "react";
6
+ const OnChangePlugin = props => {
7
+ // Get the editor instance
8
+ const [editor] = useLexicalComposerContext();
9
+ const {
10
+ onChange
11
+ } = props;
12
+
13
+ // Register an update listener to call the `onChange` prop
14
+ useEffect(() => {
15
+ return editor.registerUpdateListener(({
16
+ editorState
17
+ }) => {
18
+ const isEditable = editor.isEditable();
19
+ /* istanbul ignore else */
20
+ if (isEditable) onChange(editorState);
21
+ });
22
+ }, [editor, onChange]);
23
+ return null;
24
+ };
25
+ export default OnChangePlugin;
@@ -0,0 +1 @@
1
+ export { default } from "./placeholder.component";
@@ -0,0 +1 @@
1
+ export { default } from "./placeholder.component";
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The placeholder component does not reside in the editor in a traditional sense, but is instead rendered
3
+ * in a separate component which is then styled to appear as if it is part of the editor. This is by design
4
+ * in the Lexical project to allow for greater flexibility in the design of the editor (apparently).
5
+ */
6
+ import React from "react";
7
+ interface PlaceholderProps {
8
+ /** The namespace of the editor that this placeholder belongs to */
9
+ namespace: string;
10
+ /** The text to display in the placeholder */
11
+ text: string | undefined;
12
+ }
13
+ declare const Placeholder: ({ namespace, text }: PlaceholderProps) => React.JSX.Element;
14
+ export default Placeholder;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The placeholder component does not reside in the editor in a traditional sense, but is instead rendered
3
+ * in a separate component which is then styled to appear as if it is part of the editor. This is by design
4
+ * in the Lexical project to allow for greater flexibility in the design of the editor (apparently).
5
+ */
6
+ import React from "react";
7
+ import PropTypes from "prop-types";
8
+ import StyledPlaceholder from "./placeholder.style";
9
+ const Placeholder = ({
10
+ namespace,
11
+ text = ""
12
+ }) => {
13
+ return /*#__PURE__*/React.createElement(StyledPlaceholder, {
14
+ "data-role": `${namespace}-placeholder`
15
+ }, text);
16
+ };
17
+ export default Placeholder;
@@ -0,0 +1,2 @@
1
+ declare const StyledPlaceholder: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export default StyledPlaceholder;
@@ -0,0 +1,8 @@
1
+ import styled from "styled-components";
2
+ const StyledPlaceholder = styled.div`
3
+ position: absolute;
4
+ top: 16px;
5
+ color: var(--colorsUtilityYin055);
6
+ left: 10px;
7
+ `;
8
+ export default StyledPlaceholder;
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { FormattingButtonProps } from "./common";
3
+ declare const BoldButton: ({ isActive, namespace }: FormattingButtonProps) => React.JSX.Element;
4
+ export default BoldButton;
@@ -0,0 +1,41 @@
1
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
2
+ import { FORMAT_TEXT_COMMAND } from "lexical";
3
+ import React from "react";
4
+ import PropTypes from "prop-types";
5
+ import { FormattingButton } from "../toolbar.style";
6
+ import { TextEditorActionTypes } from "../../../constants";
7
+ import useLocale from "../../../../../../hooks/__internal__/useLocale";
8
+ // The `BoldButton` component is a button that applies bold formatting to the selected text in the editor.
9
+ const BoldButton = ({
10
+ isActive,
11
+ namespace
12
+ }) => {
13
+ // Get the locale to enable translations
14
+ const locale = useLocale();
15
+ // Get the editor instance
16
+ const [editor] = useLexicalComposerContext();
17
+
18
+ // When the button is clicked, dispatch the `FORMAT_TEXT_COMMAND` with the `Bold` action
19
+ const handleClick = () => {
20
+ const isEditable = editor.isEditable();
21
+
22
+ /* istanbul ignore else */
23
+ if (isEditable) {
24
+ // Focus the editor before dispatching the command
25
+ editor.focus();
26
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, TextEditorActionTypes.Bold);
27
+ }
28
+ };
29
+ return /*#__PURE__*/React.createElement(FormattingButton, {
30
+ size: "small",
31
+ "aria-label": locale.textEditor.boldAria(),
32
+ onClick: () => handleClick(),
33
+ iconType: "bold",
34
+ buttonType: isActive ? "primary" : "tertiary",
35
+ isActive: isActive,
36
+ "aria-pressed": isActive,
37
+ "data-role": `${namespace}-bold-button`,
38
+ tabIndex: 0
39
+ });
40
+ };
41
+ export default BoldButton;
@@ -0,0 +1,6 @@
1
+ export interface FormattingButtonProps {
2
+ /** Whether the button is active or not, relative to the text at the current cursor position */
3
+ isActive: boolean;
4
+ /** The namespace of the editor that this button belongs to */
5
+ namespace: string;
6
+ }
@@ -0,0 +1,4 @@
1
+ export { default as BoldButton } from "./bold.component";
2
+ export { default as ItalicButton } from "./italic.component";
3
+ export { default as ListControls } from "./list.component";
4
+ export { default as SaveButton } from "./save.component";
@@ -0,0 +1,4 @@
1
+ export { default as BoldButton } from "./bold.component";
2
+ export { default as ItalicButton } from "./italic.component";
3
+ export { default as ListControls } from "./list.component";
4
+ export { default as SaveButton } from "./save.component";
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { FormattingButtonProps } from "./common";
3
+ declare const ItalicButton: ({ isActive, namespace }: FormattingButtonProps) => React.JSX.Element;
4
+ export default ItalicButton;
@@ -0,0 +1,41 @@
1
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
2
+ import { FORMAT_TEXT_COMMAND } from "lexical";
3
+ import React from "react";
4
+ import PropTypes from "prop-types";
5
+ import { FormattingButton } from "../toolbar.style";
6
+ import { TextEditorActionTypes } from "../../../constants";
7
+ import useLocale from "../../../../../../hooks/__internal__/useLocale";
8
+
9
+ // The `ItalicButton` component is a button that applies italic formatting to the selected text in the editor.
10
+ const ItalicButton = ({
11
+ isActive,
12
+ namespace
13
+ }) => {
14
+ // Get the editor instance
15
+ const [editor] = useLexicalComposerContext();
16
+ // Get the locale to enable translations
17
+ const locale = useLocale();
18
+
19
+ // When the button is clicked, dispatch the `FORMAT_TEXT_COMMAND` with the `Italic` action
20
+ const handleClick = () => {
21
+ const isEditable = editor.isEditable();
22
+
23
+ /* istanbul ignore else */
24
+ if (isEditable)
25
+ // Focus the editor before dispatching the command
26
+ editor.focus();
27
+ editor.dispatchCommand(FORMAT_TEXT_COMMAND, TextEditorActionTypes.Italic);
28
+ };
29
+ return /*#__PURE__*/React.createElement(FormattingButton, {
30
+ size: "small",
31
+ "aria-label": locale.textEditor.italicAria(),
32
+ onClick: () => handleClick(),
33
+ iconType: "italic",
34
+ buttonType: isActive ? "primary" : "tertiary",
35
+ isActive: isActive,
36
+ "aria-pressed": isActive,
37
+ "data-role": `${namespace}-italic-button`,
38
+ tabIndex: -1
39
+ });
40
+ };
41
+ export default ItalicButton;
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ declare const ListControls: ({ namespace }: {
3
+ namespace: string;
4
+ }) => React.JSX.Element;
5
+ export default ListControls;
@@ -0,0 +1,317 @@
1
+ import { $createListNode, $isListItemNode, $isListNode, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, ListItemNode, ListNode, REMOVE_LIST_COMMAND, insertList, removeList } from "@lexical/list";
2
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
3
+ import { mergeRegister } from "@lexical/utils";
4
+ import { $getNodeByKey, $getSelection, $isRangeSelection, COMMAND_PRIORITY_LOW } from "lexical";
5
+ import React, { useCallback, useEffect, useState } from "react";
6
+ import PropTypes from "prop-types";
7
+ import { FormattingButton } from "../toolbar.style";
8
+ import { TextEditorActionTypes } from "../../../constants";
9
+ import useLocale from "../../../../../../hooks/__internal__/useLocale";
10
+
11
+ // The `ListControls` component is a set of buttons that allow the user to insert ordered and unordered lists into the editor.
12
+ const ListControls = ({
13
+ namespace
14
+ }) => {
15
+ // Get the editor instance
16
+ const [editor] = useLexicalComposerContext();
17
+ // Get the locale to enable translations
18
+ const locale = useLocale();
19
+ // Set the initial state of the list buttons
20
+ const [isOLActive, setIsOLActive] = useState(false);
21
+ const [isULActive, setIsULActive] = useState(false);
22
+
23
+ // Register the commands for inserting and removing lists
24
+ editor.registerCommand(INSERT_ORDERED_LIST_COMMAND, () => {
25
+ insertList(editor, TextEditorActionTypes.OrderedList);
26
+ return true;
27
+ }, COMMAND_PRIORITY_LOW);
28
+ editor.registerCommand(INSERT_UNORDERED_LIST_COMMAND, () => {
29
+ insertList(editor, TextEditorActionTypes.UnorderedList);
30
+ return true;
31
+ }, COMMAND_PRIORITY_LOW);
32
+ editor.registerCommand(REMOVE_LIST_COMMAND, () => {
33
+ removeList(editor);
34
+ return true;
35
+ }, COMMAND_PRIORITY_LOW);
36
+
37
+ // Recursive function to find the closest list item ancestor
38
+ const findListItemAncestor = node => {
39
+ let currentNode = node;
40
+ while (currentNode !== null) {
41
+ if (currentNode instanceof ListItemNode) {
42
+ return currentNode;
43
+ }
44
+ currentNode = currentNode?.getParent();
45
+ }
46
+ return null;
47
+ };
48
+ const updateToolbar = useCallback(() => {
49
+ const selection = $getSelection();
50
+ if (!selection) {
51
+ setIsOLActive(false);
52
+ setIsULActive(false);
53
+ return;
54
+ }
55
+ const selectedNodes = selection.getNodes();
56
+
57
+ /* istanbul ignore if */
58
+ if (selectedNodes.length === 0) {
59
+ setIsOLActive(false);
60
+ setIsULActive(false);
61
+ return;
62
+ }
63
+ const listItemNode = selectedNodes.map(findListItemAncestor).find(node => node !== null);
64
+ if (!listItemNode) {
65
+ setIsOLActive(false);
66
+ setIsULActive(false);
67
+ return;
68
+ }
69
+ let listNode = listItemNode.getParent();
70
+ /* istanbul ignore next */
71
+ while (listNode && !(listNode instanceof ListNode)) {
72
+ listNode = listNode.getParent();
73
+ }
74
+
75
+ /* istanbul ignore else */
76
+ if (listNode instanceof ListNode) {
77
+ setIsOLActive(listNode.getListType() === "number");
78
+ setIsULActive(listNode.getListType() === "bullet");
79
+ } else {
80
+ setIsOLActive(false);
81
+ setIsULActive(false);
82
+ }
83
+ }, []);
84
+
85
+ // Register an update listener to update the toolbar when the editor state changes
86
+ useEffect(() => {
87
+ return mergeRegister(editor.registerUpdateListener(({
88
+ editorState
89
+ }) => {
90
+ editorState.read(() => {
91
+ const isEditable = editor.isEditable();
92
+ /* istanbul ignore else */
93
+ if (isEditable) updateToolbar();
94
+ });
95
+ }));
96
+ }, [updateToolbar, editor]);
97
+
98
+ // When the ordered list button is clicked, insert or remove an ordered list
99
+ const handleOLClick = () => {
100
+ const isEditable = editor.isEditable();
101
+ /* istanbul ignore if */
102
+ if (!isEditable) return;
103
+
104
+ // Focus the editor before dispatching the command
105
+ editor.focus();
106
+ if (isOLActive) {
107
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
108
+ setIsOLActive(false);
109
+ } else {
110
+ editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
111
+ setIsOLActive(true);
112
+ }
113
+ // If the unordered list button is active, deactivate it
114
+ setIsULActive(false);
115
+ };
116
+
117
+ // When the unordered list button is clicked, insert or remove an unordered list
118
+ const handleULClick = () => {
119
+ const isEditable = editor.isEditable();
120
+ /* istanbul ignore if */
121
+ if (!isEditable) return;
122
+
123
+ // Focus the editor before dispatching the command
124
+ editor.focus();
125
+ if (isULActive) {
126
+ editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
127
+ setIsULActive(false);
128
+ } else {
129
+ editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
130
+ setIsULActive(true);
131
+ }
132
+ // If the ordered list button is active, deactivate it
133
+ setIsOLActive(false);
134
+ };
135
+
136
+ // Split an array into three parts: before a subset, the subset, and after the subset
137
+ function splitArray(allEntries, subsetEntries) {
138
+ let startIndex = -1;
139
+ for (let i = 0; i <= allEntries.length - subsetEntries.length; i++) {
140
+ if (allEntries.slice(i, i + subsetEntries.length).toString() === subsetEntries.toString()) {
141
+ startIndex = i;
142
+ break;
143
+ }
144
+ }
145
+
146
+ /* istanbul ignore if */
147
+ if (startIndex === -1) {
148
+ throw new Error("Subset B not found in array A");
149
+ }
150
+
151
+ // If the subset matches the full selection, return the original subset
152
+ if (startIndex === 0 && subsetEntries.length === allEntries.length) {
153
+ return {
154
+ beforeSubset: [],
155
+ subset: allEntries,
156
+ afterSubset: []
157
+ };
158
+ }
159
+
160
+ // Split A into three parts
161
+ const beforeSubset = allEntries.slice(0, startIndex);
162
+ const subset = allEntries.slice(startIndex, startIndex + subsetEntries.length);
163
+ const afterSubset = allEntries.slice(startIndex + subsetEntries.length);
164
+ return {
165
+ beforeSubset,
166
+ subset,
167
+ afterSubset
168
+ };
169
+ }
170
+
171
+ /* istanbul ignore next */
172
+ const alignListTypes = (lists, listType) => {
173
+ lists.forEach(list => {
174
+ editor.update(() => {
175
+ list.setListType(listType);
176
+ });
177
+ });
178
+ };
179
+
180
+ /* istanbul ignore next */
181
+ const convertListType = newType => {
182
+ editor.update(() => {
183
+ // Get the current selection
184
+ const selection = $getSelection();
185
+ // If the selection is not a range selection, return
186
+ if (!$isRangeSelection(selection)) return;
187
+
188
+ // Get the anchor node
189
+ const anchorNode = selection.anchor.getNode();
190
+
191
+ // Find the parent list node
192
+ let currentList = anchorNode.getParent();
193
+ while (currentList && !$isListNode(currentList)) {
194
+ currentList = currentList.getParent();
195
+ }
196
+
197
+ // If the parent node is not a list node, return
198
+ if (!currentList) {
199
+ return;
200
+ }
201
+
202
+ // Determine how many lists have been selected
203
+ const numberOfListsSelected = selection.getNodes().map(node => {
204
+ return node.getType() === "list" ? node : null;
205
+ }).filter(node => node !== null);
206
+
207
+ // If more than one list is selected, just align the list types to use the selected type
208
+ if (numberOfListsSelected.length > 1) {
209
+ alignListTypes(numberOfListsSelected, newType);
210
+ return;
211
+ }
212
+ const preSelectionList = [];
213
+ const selectionList = [];
214
+ const postSelectionList = [];
215
+
216
+ // Get the keys of the nodes in the selection, filtering out the current list node (the parent)
217
+ const selectionKeys = selection.getNodes().map(node => {
218
+ let _p = node.getParent();
219
+ // If we're not in a list item directly, get the parent of the node
220
+ if (!$isListItemNode(_p)) {
221
+ const nodeType = _p?.getType();
222
+ // If the node is a link or autolink, use the parent of the link node instead
223
+ if (nodeType && ["link", "autolink"].includes(nodeType)) {
224
+ _p = _p?.getParent() ?? null;
225
+ } else {
226
+ // This node is useless, return null
227
+ return null;
228
+ }
229
+ }
230
+ const _k = _p?.getKey();
231
+ if (_k !== currentList?.getKey()) return _k;
232
+ return null;
233
+ }).filter(key => key !== null && key !== undefined);
234
+ // Get the keys of the nodes in the current list node
235
+ const listKeys = currentList.getChildrenKeys();
236
+
237
+ // Remove duplicate keys from the selection
238
+ const uniqueSelectionKeys = Array.from(new Set(selectionKeys));
239
+
240
+ // Split the list keys into three parts: before the selection, the selection, and after the selection
241
+ const {
242
+ beforeSubset,
243
+ subset,
244
+ afterSubset
245
+ } = splitArray(listKeys, uniqueSelectionKeys);
246
+
247
+ // Get the nodes of the three parts
248
+ beforeSubset.forEach(key => {
249
+ const node = $getNodeByKey(key);
250
+ if ($isListItemNode(node)) preSelectionList.push(node);
251
+ });
252
+ subset.forEach(key => {
253
+ const node = $getNodeByKey(key);
254
+ if ($isListItemNode(node)) selectionList.push(node);
255
+ });
256
+ afterSubset.forEach(key => {
257
+ const node = $getNodeByKey(key);
258
+ if ($isListItemNode(node)) postSelectionList.push(node);
259
+ });
260
+
261
+ // Create new list nodes with the new list type
262
+ const originalListType = currentList.getListType();
263
+ const newPreNode = $createListNode(originalListType);
264
+ const newSelectionNode = $createListNode(newType);
265
+ const newPostNode = $createListNode(originalListType);
266
+ newPreNode.append(...preSelectionList);
267
+ newSelectionNode.append(...selectionList);
268
+ newPostNode.append(...postSelectionList);
269
+
270
+ // Insert the new nodes before the current list node if they have children
271
+ if (newPreNode.getChildren().length > 0) {
272
+ currentList.insertBefore(newPreNode);
273
+ }
274
+ if (newSelectionNode.getChildren().length > 0) {
275
+ if (newPreNode.getChildren().length > 0) {
276
+ newPreNode.insertAfter(newSelectionNode);
277
+ } else {
278
+ currentList.insertBefore(newSelectionNode);
279
+ }
280
+ }
281
+ if (newPostNode.getChildren().length > 0) {
282
+ if (newSelectionNode.getChildren().length > 0) {
283
+ newSelectionNode.insertAfter(newPostNode);
284
+ } else if (newPreNode.getChildren().length > 0) {
285
+ newPreNode.insertAfter(newPostNode);
286
+ } else {
287
+ currentList.insertBefore(newPostNode);
288
+ }
289
+ }
290
+
291
+ // Remove the current list node
292
+ currentList.remove();
293
+ });
294
+ };
295
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FormattingButton, {
296
+ size: "small",
297
+ "aria-label": locale.textEditor.unorderedListAria(),
298
+ onClick: () => isOLActive ? convertListType("bullet") : handleULClick(),
299
+ iconType: "bullet_list_dotted",
300
+ buttonType: isULActive ? "primary" : "tertiary",
301
+ isActive: isULActive,
302
+ "aria-pressed": isULActive,
303
+ "data-role": `${namespace}-unordered-list-button`,
304
+ tabIndex: -1
305
+ }), /*#__PURE__*/React.createElement(FormattingButton, {
306
+ size: "small",
307
+ "aria-label": locale.textEditor.orderedListAria(),
308
+ onClick: () => isULActive ? convertListType("number") : handleOLClick(),
309
+ iconType: "bullet_list_numbers",
310
+ buttonType: isOLActive ? "primary" : "tertiary",
311
+ isActive: isOLActive,
312
+ "aria-pressed": isOLActive,
313
+ "data-role": `${namespace}-ordered-list-button`,
314
+ tabIndex: -1
315
+ }));
316
+ };
317
+ export default ListControls;
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ interface SaveObjectProps {
3
+ detail: number;
4
+ format: number;
5
+ mode: string;
6
+ style: string;
7
+ text: string;
8
+ type: string;
9
+ version: number;
10
+ }
11
+ interface SaveProps {
12
+ children: SaveObjectProps[];
13
+ }
14
+ export interface SaveCallbackProps {
15
+ htmlString?: string;
16
+ json?: {
17
+ root: {
18
+ children: SaveProps[];
19
+ direction: string;
20
+ format: string;
21
+ indent: number;
22
+ type: string;
23
+ version: string;
24
+ };
25
+ };
26
+ }
27
+ interface SaveButtonProps {
28
+ /** The namespace of the editor that this button belongs to */
29
+ namespace: string;
30
+ /** The callback to call when the save button is clicked */
31
+ onSave: (value: SaveCallbackProps) => void;
32
+ }
33
+ declare const SaveButton: ({ namespace, onSave }: SaveButtonProps) => React.JSX.Element;
34
+ export default SaveButton;
@@ -0,0 +1,29 @@
1
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
2
+ import React from "react";
3
+ import PropTypes from "prop-types";
4
+ import { SerializeLexical } from "../../../helpers";
5
+ import Button from "../../../../../button";
6
+ import useLocale from "../../../../../../hooks/__internal__/useLocale";
7
+ // The `SaveButton` component is a button that saves the current state of the editor
8
+ const SaveButton = ({
9
+ namespace,
10
+ onSave
11
+ }) => {
12
+ // Get the editor instance
13
+ const [editor] = useLexicalComposerContext();
14
+ // Get the locale to enable translations
15
+ const locale = useLocale();
16
+ return /*#__PURE__*/React.createElement(Button, {
17
+ "data-role": `${namespace}-save-button`,
18
+ buttonType: "primary",
19
+ "aria-label": locale.textEditor.saveButtonAria(),
20
+ onClick: () => {
21
+ const isEditable = editor.isEditable();
22
+ /* istanbul ignore if */
23
+ if (!isEditable) return;
24
+ const values = SerializeLexical(editor);
25
+ onSave?.(values);
26
+ }
27
+ }, locale.textEditor.saveButton());
28
+ };
29
+ export default SaveButton;