@toptal/picasso 19.2.0 → 19.3.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 (262) hide show
  1. package/Icon/Bold16.d.ts +10 -0
  2. package/Icon/Bold16.js +23 -0
  3. package/Icon/Bold16.js.map +1 -0
  4. package/Icon/Italic16.d.ts +10 -0
  5. package/Icon/Italic16.js +23 -0
  6. package/Icon/Italic16.js.map +1 -0
  7. package/Icon/ListOrdered16.d.ts +10 -0
  8. package/Icon/ListOrdered16.js +23 -0
  9. package/Icon/ListOrdered16.js.map +1 -0
  10. package/Icon/ListUnordered16.d.ts +10 -0
  11. package/Icon/ListUnordered16.js +23 -0
  12. package/Icon/ListUnordered16.js.map +1 -0
  13. package/Icon/index.d.ts +4 -0
  14. package/Icon/index.js +4 -0
  15. package/Icon/index.js.map +1 -1
  16. package/ListItem/styles.d.ts +1 -1
  17. package/QuillEditor/QuillEditor.d.ts +32 -0
  18. package/QuillEditor/QuillEditor.js +42 -0
  19. package/QuillEditor/QuillEditor.js.map +1 -0
  20. package/QuillEditor/constants.d.ts +1 -0
  21. package/QuillEditor/constants.js +2 -0
  22. package/QuillEditor/constants.js.map +1 -0
  23. package/QuillEditor/formats/bold.d.ts +8 -0
  24. package/QuillEditor/formats/bold.js +18 -0
  25. package/QuillEditor/formats/bold.js.map +1 -0
  26. package/QuillEditor/formats/header.d.ts +8 -0
  27. package/QuillEditor/formats/header.js +20 -0
  28. package/QuillEditor/formats/header.js.map +1 -0
  29. package/QuillEditor/formats/index.d.ts +3 -0
  30. package/QuillEditor/formats/index.js +4 -0
  31. package/QuillEditor/formats/index.js.map +1 -0
  32. package/QuillEditor/formats/use-typography-classes.d.ts +2 -0
  33. package/QuillEditor/formats/use-typography-classes.js +7 -0
  34. package/QuillEditor/formats/use-typography-classes.js.map +1 -0
  35. package/QuillEditor/hooks/index.d.ts +6 -0
  36. package/QuillEditor/hooks/index.js +7 -0
  37. package/QuillEditor/hooks/index.js.map +1 -0
  38. package/QuillEditor/hooks/useDefaultValue/index.d.ts +1 -0
  39. package/QuillEditor/hooks/useDefaultValue/index.js +2 -0
  40. package/QuillEditor/hooks/useDefaultValue/index.js.map +1 -0
  41. package/QuillEditor/hooks/useDefaultValue/useDefaultValue.d.ts +7 -0
  42. package/QuillEditor/hooks/useDefaultValue/useDefaultValue.js +15 -0
  43. package/QuillEditor/hooks/useDefaultValue/useDefaultValue.js.map +1 -0
  44. package/QuillEditor/hooks/useDisabledEditor/index.d.ts +1 -0
  45. package/QuillEditor/hooks/useDisabledEditor/index.js +2 -0
  46. package/QuillEditor/hooks/useDisabledEditor/index.js.map +1 -0
  47. package/QuillEditor/hooks/useDisabledEditor/useDisabledEditor.d.ts +6 -0
  48. package/QuillEditor/hooks/useDisabledEditor/useDisabledEditor.js +11 -0
  49. package/QuillEditor/hooks/useDisabledEditor/useDisabledEditor.js.map +1 -0
  50. package/QuillEditor/hooks/useFocus/index.d.ts +1 -0
  51. package/QuillEditor/hooks/useFocus/index.js +2 -0
  52. package/QuillEditor/hooks/useFocus/index.js.map +1 -0
  53. package/QuillEditor/hooks/useFocus/useFocus.d.ts +6 -0
  54. package/QuillEditor/hooks/useFocus/useFocus.js +13 -0
  55. package/QuillEditor/hooks/useFocus/useFocus.js.map +1 -0
  56. package/QuillEditor/hooks/useKeyBindings/index.d.ts +1 -0
  57. package/QuillEditor/hooks/useKeyBindings/index.js +2 -0
  58. package/QuillEditor/hooks/useKeyBindings/index.js.map +1 -0
  59. package/QuillEditor/hooks/useKeyBindings/useKeyBindings.d.ts +7 -0
  60. package/QuillEditor/hooks/useKeyBindings/useKeyBindings.js +32 -0
  61. package/QuillEditor/hooks/useKeyBindings/useKeyBindings.js.map +1 -0
  62. package/QuillEditor/hooks/useQuillInstance/index.d.ts +1 -0
  63. package/QuillEditor/hooks/useQuillInstance/index.js +2 -0
  64. package/QuillEditor/hooks/useQuillInstance/index.js.map +1 -0
  65. package/QuillEditor/hooks/useQuillInstance/useQuillInstance.d.ts +9 -0
  66. package/QuillEditor/hooks/useQuillInstance/useQuillInstance.js +68 -0
  67. package/QuillEditor/hooks/useQuillInstance/useQuillInstance.js.map +1 -0
  68. package/QuillEditor/hooks/useSubscribeToQuillEvents/index.d.ts +1 -0
  69. package/QuillEditor/hooks/useSubscribeToQuillEvents/index.js +2 -0
  70. package/QuillEditor/hooks/useSubscribeToQuillEvents/index.js.map +1 -0
  71. package/QuillEditor/hooks/useSubscribeToQuillEvents/useSubscribeToQuillEvents.d.ts +10 -0
  72. package/QuillEditor/hooks/useSubscribeToQuillEvents/useSubscribeToQuillEvents.js +64 -0
  73. package/QuillEditor/hooks/useSubscribeToQuillEvents/useSubscribeToQuillEvents.js.map +1 -0
  74. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/index.d.ts +1 -0
  75. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/index.js +2 -0
  76. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/index.js.map +1 -0
  77. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/useSubscribeToTextEditorEvents.d.ts +6 -0
  78. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/useSubscribeToTextEditorEvents.js +23 -0
  79. package/QuillEditor/hooks/useSubscribeToTextEditorEvents/useSubscribeToTextEditorEvents.js.map +1 -0
  80. package/QuillEditor/index.d.ts +4 -0
  81. package/QuillEditor/index.js +4 -0
  82. package/QuillEditor/index.js.map +1 -0
  83. package/QuillEditor/styles.d.ts +3 -0
  84. package/QuillEditor/styles.js +100 -0
  85. package/QuillEditor/styles.js.map +1 -0
  86. package/QuillEditor/types.d.ts +27 -0
  87. package/QuillEditor/types.js +2 -0
  88. package/QuillEditor/types.js.map +1 -0
  89. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/getCleanupOnAllContentRemovalHandler.d.ts +3 -0
  90. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/getCleanupOnAllContentRemovalHandler.js +22 -0
  91. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/getCleanupOnAllContentRemovalHandler.js.map +1 -0
  92. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/index.d.ts +1 -0
  93. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/index.js +2 -0
  94. package/QuillEditor/utils/getCleanupOnAllContentRemovalHandler/index.js.map +1 -0
  95. package/QuillEditor/utils/getEditorChangeHandler/getEditorChangeHandler.d.ts +7 -0
  96. package/QuillEditor/utils/getEditorChangeHandler/getEditorChangeHandler.js +41 -0
  97. package/QuillEditor/utils/getEditorChangeHandler/getEditorChangeHandler.js.map +1 -0
  98. package/QuillEditor/utils/getEditorChangeHandler/index.d.ts +1 -0
  99. package/QuillEditor/utils/getEditorChangeHandler/index.js +2 -0
  100. package/QuillEditor/utils/getEditorChangeHandler/index.js.map +1 -0
  101. package/QuillEditor/utils/getFormatChangeHandler/getFormatChangeHandler.d.ts +3 -0
  102. package/QuillEditor/utils/getFormatChangeHandler/getFormatChangeHandler.js +13 -0
  103. package/QuillEditor/utils/getFormatChangeHandler/getFormatChangeHandler.js.map +1 -0
  104. package/QuillEditor/utils/getFormatChangeHandler/index.d.ts +2 -0
  105. package/QuillEditor/utils/getFormatChangeHandler/index.js +3 -0
  106. package/QuillEditor/utils/getFormatChangeHandler/index.js.map +1 -0
  107. package/QuillEditor/utils/getSelectionChangeHandler/getSelectionChangeHandler.d.ts +4 -0
  108. package/QuillEditor/utils/getSelectionChangeHandler/getSelectionChangeHandler.js +19 -0
  109. package/QuillEditor/utils/getSelectionChangeHandler/getSelectionChangeHandler.js.map +1 -0
  110. package/QuillEditor/utils/getSelectionChangeHandler/index.d.ts +1 -0
  111. package/QuillEditor/utils/getSelectionChangeHandler/index.js +2 -0
  112. package/QuillEditor/utils/getSelectionChangeHandler/index.js.map +1 -0
  113. package/QuillEditor/utils/getTextChangeHandler/getTextChangeHandler.d.ts +3 -0
  114. package/QuillEditor/utils/getTextChangeHandler/getTextChangeHandler.js +22 -0
  115. package/QuillEditor/utils/getTextChangeHandler/getTextChangeHandler.js.map +1 -0
  116. package/QuillEditor/utils/getTextChangeHandler/index.d.ts +1 -0
  117. package/QuillEditor/utils/getTextChangeHandler/index.js +2 -0
  118. package/QuillEditor/utils/getTextChangeHandler/index.js.map +1 -0
  119. package/QuillEditor/utils/getTextLengthChangeHandler/getTextLengthChangeHandler.d.ts +4 -0
  120. package/QuillEditor/utils/getTextLengthChangeHandler/getTextLengthChangeHandler.js +9 -0
  121. package/QuillEditor/utils/getTextLengthChangeHandler/getTextLengthChangeHandler.js.map +1 -0
  122. package/QuillEditor/utils/getTextLengthChangeHandler/index.d.ts +1 -0
  123. package/QuillEditor/utils/getTextLengthChangeHandler/index.js +2 -0
  124. package/QuillEditor/utils/getTextLengthChangeHandler/index.js.map +1 -0
  125. package/QuillEditor/utils/remove-classes/index.d.ts +1 -0
  126. package/QuillEditor/utils/remove-classes/index.js +2 -0
  127. package/QuillEditor/utils/remove-classes/index.js.map +1 -0
  128. package/QuillEditor/utils/remove-classes/remove-classes.d.ts +2 -0
  129. package/QuillEditor/utils/remove-classes/remove-classes.js +3 -0
  130. package/QuillEditor/utils/remove-classes/remove-classes.js.map +1 -0
  131. package/QuillEditor/utils/remove-cursor-span/index.d.ts +1 -0
  132. package/QuillEditor/utils/remove-cursor-span/index.js +2 -0
  133. package/QuillEditor/utils/remove-cursor-span/index.js.map +1 -0
  134. package/QuillEditor/utils/remove-cursor-span/remove-cursor-span.d.ts +2 -0
  135. package/QuillEditor/utils/remove-cursor-span/remove-cursor-span.js +5 -0
  136. package/QuillEditor/utils/remove-cursor-span/remove-cursor-span.js.map +1 -0
  137. package/RichTextEditor/RichTextEditor.d.ts +63 -0
  138. package/RichTextEditor/RichTextEditor.js +77 -0
  139. package/RichTextEditor/RichTextEditor.js.map +1 -0
  140. package/RichTextEditor/hooks/index.d.ts +6 -0
  141. package/RichTextEditor/hooks/index.js +7 -0
  142. package/RichTextEditor/hooks/index.js.map +1 -0
  143. package/RichTextEditor/hooks/useCounter/index.d.ts +1 -0
  144. package/RichTextEditor/hooks/useCounter/index.js +2 -0
  145. package/RichTextEditor/hooks/useCounter/index.js.map +1 -0
  146. package/RichTextEditor/hooks/useCounter/useCounter.d.ts +14 -0
  147. package/RichTextEditor/hooks/useCounter/useCounter.js +68 -0
  148. package/RichTextEditor/hooks/useCounter/useCounter.js.map +1 -0
  149. package/RichTextEditor/hooks/useOnFocus/index.d.ts +1 -0
  150. package/RichTextEditor/hooks/useOnFocus/index.js +2 -0
  151. package/RichTextEditor/hooks/useOnFocus/index.js.map +1 -0
  152. package/RichTextEditor/hooks/useOnFocus/useOnFocus.d.ts +16 -0
  153. package/RichTextEditor/hooks/useOnFocus/useOnFocus.js +44 -0
  154. package/RichTextEditor/hooks/useOnFocus/useOnFocus.js.map +1 -0
  155. package/RichTextEditor/hooks/useOnSelectionChange/index.d.ts +1 -0
  156. package/RichTextEditor/hooks/useOnSelectionChange/index.js +2 -0
  157. package/RichTextEditor/hooks/useOnSelectionChange/index.js.map +1 -0
  158. package/RichTextEditor/hooks/useOnSelectionChange/useOnSelectionChange.d.ts +10 -0
  159. package/RichTextEditor/hooks/useOnSelectionChange/useOnSelectionChange.js +15 -0
  160. package/RichTextEditor/hooks/useOnSelectionChange/useOnSelectionChange.js.map +1 -0
  161. package/RichTextEditor/hooks/useOnTextFormat/index.d.ts +1 -0
  162. package/RichTextEditor/hooks/useOnTextFormat/index.js +2 -0
  163. package/RichTextEditor/hooks/useOnTextFormat/index.js.map +1 -0
  164. package/RichTextEditor/hooks/useOnTextFormat/useOnTextFormat.d.ts +10 -0
  165. package/RichTextEditor/hooks/useOnTextFormat/useOnTextFormat.js +30 -0
  166. package/RichTextEditor/hooks/useOnTextFormat/useOnTextFormat.js.map +1 -0
  167. package/RichTextEditor/hooks/useTextEditorState/index.d.ts +1 -0
  168. package/RichTextEditor/hooks/useTextEditorState/index.js +2 -0
  169. package/RichTextEditor/hooks/useTextEditorState/index.js.map +1 -0
  170. package/RichTextEditor/hooks/useTextEditorState/useTextEditorState.d.ts +7 -0
  171. package/RichTextEditor/hooks/useTextEditorState/useTextEditorState.js +8 -0
  172. package/RichTextEditor/hooks/useTextEditorState/useTextEditorState.js.map +1 -0
  173. package/RichTextEditor/hooks/useToolbarHandlers/index.d.ts +1 -0
  174. package/RichTextEditor/hooks/useToolbarHandlers/index.js +2 -0
  175. package/RichTextEditor/hooks/useToolbarHandlers/index.js.map +1 -0
  176. package/RichTextEditor/hooks/useToolbarHandlers/useToolbarHandlers.d.ts +16 -0
  177. package/RichTextEditor/hooks/useToolbarHandlers/useToolbarHandlers.js +61 -0
  178. package/RichTextEditor/hooks/useToolbarHandlers/useToolbarHandlers.js.map +1 -0
  179. package/RichTextEditor/index.d.ts +7 -0
  180. package/RichTextEditor/index.js +3 -0
  181. package/RichTextEditor/index.js.map +1 -0
  182. package/RichTextEditor/store/index.d.ts +9 -0
  183. package/RichTextEditor/store/index.js +11 -0
  184. package/RichTextEditor/store/index.js.map +1 -0
  185. package/RichTextEditor/store/toolbar/actionTypes.d.ts +9 -0
  186. package/RichTextEditor/store/toolbar/actionTypes.js +10 -0
  187. package/RichTextEditor/store/toolbar/actionTypes.js.map +1 -0
  188. package/RichTextEditor/store/toolbar/actions.d.ts +11 -0
  189. package/RichTextEditor/store/toolbar/actions.js +17 -0
  190. package/RichTextEditor/store/toolbar/actions.js.map +1 -0
  191. package/RichTextEditor/store/toolbar/index.d.ts +6 -0
  192. package/RichTextEditor/store/toolbar/index.js +7 -0
  193. package/RichTextEditor/store/toolbar/index.js.map +1 -0
  194. package/RichTextEditor/store/toolbar/initialState.d.ts +3 -0
  195. package/RichTextEditor/store/toolbar/initialState.js +11 -0
  196. package/RichTextEditor/store/toolbar/initialState.js.map +1 -0
  197. package/RichTextEditor/store/toolbar/reducer.d.ts +3 -0
  198. package/RichTextEditor/store/toolbar/reducer.js +22 -0
  199. package/RichTextEditor/store/toolbar/reducer.js.map +1 -0
  200. package/RichTextEditor/store/toolbar/types.d.ts +40 -0
  201. package/RichTextEditor/store/toolbar/types.js +2 -0
  202. package/RichTextEditor/store/toolbar/types.js.map +1 -0
  203. package/RichTextEditor/store/types.d.ts +5 -0
  204. package/RichTextEditor/store/types.js +2 -0
  205. package/RichTextEditor/store/types.js.map +1 -0
  206. package/RichTextEditor/styles.d.ts +3 -0
  207. package/RichTextEditor/styles.js +23 -0
  208. package/RichTextEditor/styles.js.map +1 -0
  209. package/RichTextEditor/types.d.ts +2 -0
  210. package/RichTextEditor/types.js +2 -0
  211. package/RichTextEditor/types.js.map +1 -0
  212. package/RichTextEditor/utils/convertFormat.d.ts +8 -0
  213. package/RichTextEditor/utils/convertFormat.js +19 -0
  214. package/RichTextEditor/utils/convertFormat.js.map +1 -0
  215. package/RichTextEditorButton/RichTextEditorButton.d.ts +18 -0
  216. package/RichTextEditorButton/RichTextEditorButton.js +38 -0
  217. package/RichTextEditorButton/RichTextEditorButton.js.map +1 -0
  218. package/RichTextEditorButton/index.d.ts +1 -0
  219. package/RichTextEditorButton/index.js +2 -0
  220. package/RichTextEditorButton/index.js.map +1 -0
  221. package/RichTextEditorButton/styles.d.ts +3 -0
  222. package/RichTextEditorButton/styles.js +16 -0
  223. package/RichTextEditorButton/styles.js.map +1 -0
  224. package/RichTextEditorCounter/RichTextEditorCounter.d.ts +10 -0
  225. package/RichTextEditorCounter/RichTextEditorCounter.js +17 -0
  226. package/RichTextEditorCounter/RichTextEditorCounter.js.map +1 -0
  227. package/RichTextEditorCounter/index.d.ts +1 -0
  228. package/RichTextEditorCounter/index.js +2 -0
  229. package/RichTextEditorCounter/index.js.map +1 -0
  230. package/RichTextEditorCounter/styles.d.ts +3 -0
  231. package/RichTextEditorCounter/styles.js +27 -0
  232. package/RichTextEditorCounter/styles.js.map +1 -0
  233. package/RichTextEditorToolbar/RichTextEditorToolbar.d.ts +22 -0
  234. package/RichTextEditorToolbar/RichTextEditorToolbar.js +44 -0
  235. package/RichTextEditorToolbar/RichTextEditorToolbar.js.map +1 -0
  236. package/RichTextEditorToolbar/index.d.ts +2 -0
  237. package/RichTextEditorToolbar/index.js +3 -0
  238. package/RichTextEditorToolbar/index.js.map +1 -0
  239. package/RichTextEditorToolbar/styles.d.ts +5 -0
  240. package/RichTextEditorToolbar/styles.js +27 -0
  241. package/RichTextEditorToolbar/styles.js.map +1 -0
  242. package/RichTextEditorToolbar/types.d.ts +6 -0
  243. package/RichTextEditorToolbar/types.js +2 -0
  244. package/RichTextEditorToolbar/types.js.map +1 -0
  245. package/Typography/Typography.js +11 -13
  246. package/Typography/Typography.js.map +1 -1
  247. package/Typography/styles.d.ts +1 -1
  248. package/Typography/styles.js +121 -114
  249. package/Typography/styles.js.map +1 -1
  250. package/Typography/utils/get-typography-class-name/get-typography-class-name.d.ts +3 -0
  251. package/Typography/utils/get-typography-class-name/get-typography-class-name.js +15 -0
  252. package/Typography/utils/get-typography-class-name/get-typography-class-name.js.map +1 -0
  253. package/Typography/utils/get-typography-class-name/index.d.ts +1 -0
  254. package/Typography/utils/get-typography-class-name/index.js +2 -0
  255. package/Typography/utils/get-typography-class-name/index.js.map +1 -0
  256. package/index.d.ts +2 -0
  257. package/index.js +1 -0
  258. package/index.js.map +1 -1
  259. package/package.json +6 -1
  260. package/Typography/utils/index.d.ts +0 -1
  261. package/Typography/utils/index.js +0 -2
  262. package/Typography/utils/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getFormatChangeHandler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE,eAAe,sBAAsB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import Quill, { SelectionChangeHandler } from 'quill';
2
+ import { SelectionHandler } from '../../types';
3
+ declare const getSelectionChangeHandler: (quill: Quill, onSelectionChange: SelectionHandler) => SelectionChangeHandler;
4
+ export default getSelectionChangeHandler;
@@ -0,0 +1,19 @@
1
+ const getSelectionChangeHandler = (quill, onSelectionChange) => {
2
+ const handler = (range, _, source) => {
3
+ const isSilentEvent = source === 'silent';
4
+ const isFromApi = source === 'api';
5
+ if (isSilentEvent) {
6
+ return;
7
+ }
8
+ if (isFromApi) {
9
+ return;
10
+ }
11
+ if (range) {
12
+ const format = quill.getFormat(range);
13
+ onSelectionChange(format);
14
+ }
15
+ };
16
+ return handler;
17
+ };
18
+ export default getSelectionChangeHandler;
19
+ //# sourceMappingURL=getSelectionChangeHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getSelectionChangeHandler.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getSelectionChangeHandler/getSelectionChangeHandler.tsx"],"names":[],"mappings":"AAIA,MAAM,yBAAyB,GAAG,CAChC,KAAY,EACZ,iBAAmC,EACnC,EAAE;IACF,MAAM,OAAO,GAA2B,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE;QAC3D,MAAM,aAAa,GAAG,MAAM,KAAK,QAAQ,CAAA;QACzC,MAAM,SAAS,GAAG,MAAM,KAAK,KAAK,CAAA;QAElC,IAAI,aAAa,EAAE;YACjB,OAAM;SACP;QAED,IAAI,SAAS,EAAE;YACb,OAAM;SACP;QAED,IAAI,KAAK,EAAE;YACT,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,KAAK,CAAe,CAAA;YAEnD,iBAAiB,CAAC,MAAM,CAAC,CAAA;SAC1B;IACH,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,eAAe,yBAAyB,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './getSelectionChangeHandler';
@@ -0,0 +1,2 @@
1
+ export { default } from './getSelectionChangeHandler';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getSelectionChangeHandler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import Quill, { TextChangeHandler } from 'quill';
2
+ declare const getTextChangeHandler: (quill: Quill, handleTextChange: (html: string) => void) => TextChangeHandler;
3
+ export default getTextChangeHandler;
@@ -0,0 +1,22 @@
1
+ import removeClasses from '../remove-classes';
2
+ import removeCursorSpan from '../remove-cursor-span';
3
+ const getTextChangeHandler = (quill, handleTextChange) => {
4
+ const handler = (_, __, source) => {
5
+ const isSilenetEvent = source === 'silent';
6
+ if (isSilenetEvent) {
7
+ return;
8
+ }
9
+ const isEmpty = quill.getLength() === 1;
10
+ if (isEmpty) {
11
+ handleTextChange('');
12
+ return;
13
+ }
14
+ const [cleanValue] = [quill.root.innerHTML]
15
+ .map(removeCursorSpan)
16
+ .map(removeClasses);
17
+ handleTextChange(cleanValue);
18
+ };
19
+ return handler;
20
+ };
21
+ export default getTextChangeHandler;
22
+ //# sourceMappingURL=getTextChangeHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTextChangeHandler.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getTextChangeHandler/getTextChangeHandler.tsx"],"names":[],"mappings":"AAEA,OAAO,aAAa,MAAM,mBAAmB,CAAA;AAC7C,OAAO,gBAAgB,MAAM,uBAAuB,CAAA;AAEpD,MAAM,oBAAoB,GAAG,CAC3B,KAAY,EACZ,gBAAwC,EACxC,EAAE;IACF,MAAM,OAAO,GAAsB,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;QACnD,MAAM,cAAc,GAAG,MAAM,KAAK,QAAQ,CAAA;QAE1C,IAAI,cAAc,EAAE;YAClB,OAAM;SACP;QAED,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAEvC,IAAI,OAAO,EAAE;YACX,gBAAgB,CAAC,EAAE,CAAC,CAAA;YAEpB,OAAM;SACP;QAED,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC;aACxC,GAAG,CAAC,gBAAgB,CAAC;aACrB,GAAG,CAAC,aAAa,CAAC,CAAA;QAErB,gBAAgB,CAAC,UAAU,CAAC,CAAA;IAC9B,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './getTextChangeHandler';
@@ -0,0 +1,2 @@
1
+ export { default } from './getTextChangeHandler';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getTextChangeHandler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,4 @@
1
+ import Quill, { TextChangeHandler } from 'quill';
2
+ import { TextLengthChangeHandler } from '../../types';
3
+ declare const getTextLengthChangeHandler: (quill: Quill, onTextLengthChange: TextLengthChangeHandler) => TextChangeHandler;
4
+ export default getTextLengthChangeHandler;
@@ -0,0 +1,9 @@
1
+ const getTextLengthChangeHandler = (quill, onTextLengthChange) => {
2
+ const handler = () => {
3
+ const currentLength = quill.getLength() - 1;
4
+ onTextLengthChange(currentLength);
5
+ };
6
+ return handler;
7
+ };
8
+ export default getTextLengthChangeHandler;
9
+ //# sourceMappingURL=getTextLengthChangeHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getTextLengthChangeHandler.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getTextLengthChangeHandler/getTextLengthChangeHandler.tsx"],"names":[],"mappings":"AAIA,MAAM,0BAA0B,GAAG,CACjC,KAAY,EACZ,kBAA2C,EAC3C,EAAE;IACF,MAAM,OAAO,GAAsB,GAAG,EAAE;QACtC,MAAM,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;QAE3C,kBAAkB,CAAC,aAAa,CAAC,CAAA;IACnC,CAAC,CAAA;IAED,OAAO,OAAO,CAAA;AAChB,CAAC,CAAA;AAED,eAAe,0BAA0B,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './getTextLengthChangeHandler';
@@ -0,0 +1,2 @@
1
+ export { default } from './getTextLengthChangeHandler';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/getTextLengthChangeHandler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './remove-classes';
@@ -0,0 +1,2 @@
1
+ export { default } from './remove-classes';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/remove-classes/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const removeClasses: (value: string) => string;
2
+ export default removeClasses;
@@ -0,0 +1,3 @@
1
+ const removeClasses = (value) => value.replace(/\sclass=".+?"/g, '');
2
+ export default removeClasses;
3
+ //# sourceMappingURL=remove-classes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-classes.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/remove-classes/remove-classes.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;AAE5E,eAAe,aAAa,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './remove-cursor-span';
@@ -0,0 +1,2 @@
1
+ export { default } from './remove-cursor-span';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/remove-cursor-span/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA"}
@@ -0,0 +1,2 @@
1
+ declare const removeCursorSpan: (value: string) => string;
2
+ export default removeCursorSpan;
@@ -0,0 +1,5 @@
1
+ /* eslint-disable-next-line no-irregular-whitespace */
2
+ const pattern = /(<(strong|em)>)?(<(strong|em)>)(<span class="ql-cursor"><\/span>)(<\/\4>)(<\/\2>)?/;
3
+ const removeCursorSpan = (value) => value.replace(pattern, '<br>');
4
+ export default removeCursorSpan;
5
+ //# sourceMappingURL=remove-cursor-span.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remove-cursor-span.js","sourceRoot":"","sources":["../../../../src/QuillEditor/utils/remove-cursor-span/remove-cursor-span.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,MAAM,OAAO,GAAG,qFAAqF,CAAA;AAErG,MAAM,gBAAgB,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;AAE1E,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1,63 @@
1
+ import React from 'react';
2
+ import { BaseProps } from '@toptal/picasso-shared';
3
+ import { ASTType } from '../RichText';
4
+ export declare type CounterMessageSetter = (limit: number, currLength: number, isError: boolean) => string;
5
+ export interface Props extends BaseProps {
6
+ /** Indicates that an element is to be focused on page load */
7
+ autoFocus?: boolean;
8
+ /** Default value in [HAST](https://github.com/syntax-tree/hast) format */
9
+ defaultValue?: ASTType;
10
+ /**
11
+ * This Boolean attribute indicates that the user cannot interact with the control.
12
+ */
13
+ disabled?: boolean;
14
+ /** unique identifier */
15
+ id: string;
16
+ /**
17
+ * Indicate wether the editor is in an error state
18
+ */
19
+ error?: boolean;
20
+ /**
21
+ * The maximum number of characters that the user can enter.
22
+ * If this value isn't specified, the user can enter an unlimited
23
+ * number of characters.
24
+ */
25
+ maxLength?: number;
26
+ /**
27
+ * The minimum number of characters required that the user should enter.
28
+ */
29
+ minLength?: number;
30
+ /**
31
+ * Custom counter message for minLength
32
+ */
33
+ minLengthMessage?: CounterMessageSetter;
34
+ /**
35
+ * Custom counter message for maxLength
36
+ */
37
+ maxLengthMessage?: CounterMessageSetter;
38
+ /**
39
+ * Callback on text change
40
+ */
41
+ onChange?: (value: string) => void;
42
+ /**
43
+ * Callback for blur event
44
+ */
45
+ onBlur?: () => void;
46
+ /**
47
+ * Callback for focus event
48
+ */
49
+ onFocus?: () => void;
50
+ /** The placeholder attribute specifies a short hint that describes the expected value of a text editor. */
51
+ placeholder?: string;
52
+ testIds?: {
53
+ wrapper?: string;
54
+ editor?: string;
55
+ headerSelect?: string;
56
+ boldButton?: string;
57
+ italicButton?: string;
58
+ unorderedListButton?: string;
59
+ orderedListButton?: string;
60
+ };
61
+ }
62
+ export declare const RichTextEditor: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLDivElement>>;
63
+ export default RichTextEditor;
@@ -0,0 +1,77 @@
1
+ import React, { forwardRef, useRef, useState } from 'react';
2
+ import { makeStyles } from '@material-ui/core/styles';
3
+ import cx from 'classnames';
4
+ import hastUtilToHtml from 'hast-util-to-html';
5
+ import hastSanitize from 'hast-util-sanitize';
6
+ import { noop } from '@toptal/picasso/utils';
7
+ import Container from '../Container';
8
+ import QuillEditor from '../QuillEditor';
9
+ import Toolbar from '../RichTextEditorToolbar';
10
+ import Counter from '../RichTextEditorCounter';
11
+ import styles from './styles';
12
+ import { useTextEditorState, useOnSelectionChange, useOnTextFormat, useOnFocus, useToolbarHandlers, useCounter } from './hooks';
13
+ const useStyles = makeStyles(styles, {
14
+ name: 'RichTextEditor'
15
+ });
16
+ export const RichTextEditor = forwardRef(function RichTextEditor({ 'data-testid': dataTestId, autoFocus = false, className, defaultValue, disabled, id, onChange = noop, onFocus = noop, onBlur = noop, placeholder, minLength, maxLength, minLengthMessage, maxLengthMessage, style, error, testIds }, ref) {
17
+ const classes = useStyles();
18
+ const toolbarRef = useRef(null);
19
+ const editorRef = useRef(null);
20
+ const wrapperRef = useRef(null);
21
+ const { dispatch, state } = useTextEditorState();
22
+ const { handleSelectionChange } = useOnSelectionChange({ dispatch });
23
+ const { handleTextFormat } = useOnTextFormat({ dispatch });
24
+ const { handleBold, handleItalic, handleHeader, handleOrdered, handleUnordered } = useToolbarHandlers({
25
+ editorRef,
26
+ handleTextFormat,
27
+ format: state.toolbar.format
28
+ });
29
+ const { isEditorFocused, handleFocus, handleBlur } = useOnFocus({
30
+ autoFocus,
31
+ editorRef,
32
+ toolbarRef,
33
+ wrapperRef,
34
+ onFocus,
35
+ onBlur,
36
+ dispatch
37
+ });
38
+ const [defaultValueInHtml] = useState(() => defaultValue ? hastUtilToHtml(hastSanitize(defaultValue)) : defaultValue);
39
+ const { counterMessage, counterError, handleCounterMessage } = useCounter({
40
+ minLength,
41
+ maxLength,
42
+ minLengthMessage,
43
+ maxLengthMessage
44
+ });
45
+ return (React.createElement(Container, { className: cx(classes.editorWrapper, {
46
+ [classes.disabled]: disabled,
47
+ [classes.focused]: isEditorFocused,
48
+ [classes.error]: error
49
+ }, className), tabIndex: -1, style: style, ref: node => {
50
+ if (typeof ref === 'function') {
51
+ ref(node);
52
+ }
53
+ else if (ref != null) {
54
+ ref.current = node;
55
+ }
56
+ wrapperRef.current = node;
57
+ }, "data-testid": (testIds === null || testIds === void 0 ? void 0 : testIds.wrapper) || dataTestId, onFocus: handleFocus, onBlur: handleBlur },
58
+ React.createElement(Toolbar, { ref: toolbarRef, disabled: disabled || state.toolbar.disabled, id: id, format: state.toolbar.format, onBoldClick: handleBold, onItalicClick: handleItalic, onUnorderedClick: handleUnordered, onOrderedClick: handleOrdered, onHeaderChange: handleHeader, testIds: {
59
+ headerSelect: testIds === null || testIds === void 0 ? void 0 : testIds.headerSelect,
60
+ boldButton: testIds === null || testIds === void 0 ? void 0 : testIds.boldButton,
61
+ italicButton: testIds === null || testIds === void 0 ? void 0 : testIds.italicButton,
62
+ unorderedListButton: testIds === null || testIds === void 0 ? void 0 : testIds.unorderedListButton,
63
+ orderedListButton: testIds === null || testIds === void 0 ? void 0 : testIds.orderedListButton
64
+ } }),
65
+ React.createElement(QuillEditor, { ref: editorRef, disabled: !!disabled, "data-testid": testIds === null || testIds === void 0 ? void 0 : testIds.editor, id: id, isFocused: isEditorFocused, placeholder: placeholder, onTextLengthChange: handleCounterMessage, onTextFormat: handleTextFormat, onSelectionChange: handleSelectionChange, onTextChange: onChange, defaultValue: defaultValueInHtml }),
66
+ counterMessage && (React.createElement(Counter, { error: counterError, message: counterMessage }))));
67
+ });
68
+ RichTextEditor.defaultProps = {
69
+ autoFocus: false,
70
+ onChange: noop,
71
+ onFocus: noop,
72
+ onBlur: noop,
73
+ disabled: false
74
+ };
75
+ RichTextEditor.displayName = 'RichTextEditor';
76
+ export default RichTextEditor;
77
+ //# sourceMappingURL=RichTextEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextEditor.js","sourceRoot":"","sources":["../../src/RichTextEditor/RichTextEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3D,OAAO,EAAE,UAAU,EAAS,MAAM,0BAA0B,CAAA;AAE5D,OAAO,EAAE,MAAM,YAAY,CAAA;AAC3B,OAAO,cAAc,MAAM,mBAAmB,CAAA;AAC9C,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAE5C,OAAO,SAAS,MAAM,cAAc,CAAA;AACpC,OAAO,WAAW,MAAM,gBAAgB,CAAA;AACxC,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,OAAO,MAAM,0BAA0B,CAAA;AAC9C,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,kBAAkB,EAClB,UAAU,EACX,MAAM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nSelectionChange';
3
+ export { default as useOnTextFormat } from './useOnTextFormat';
4
+ export { default as useTextEditorState } from './useTextEditorState';
5
+ export { default as useToolbarHandlers } from './useToolbarHandlers';
6
+ export { default as useCounter } from './useCounter';
@@ -0,0 +1,7 @@
1
+ export { default as useOnFocus } from './useOnFocus';
2
+ export { default as useOnSelectionChange } from './useOnSelectionChange';
3
+ export { default as useOnTextFormat } from './useOnTextFormat';
4
+ export { default as useTextEditorState } from './useTextEditorState';
5
+ export { default as useToolbarHandlers } from './useToolbarHandlers';
6
+ export { default as useCounter } from './useCounter';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/RichTextEditor/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAC9D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AACpE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './useCounter';
@@ -0,0 +1,2 @@
1
+ export { default } from './useCounter';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useCounter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { TextLengthChangeHandler } from '../../../QuillEditor';
2
+ import { CounterMessageSetter } from '../../RichTextEditor';
3
+ declare type Props = {
4
+ minLength?: number;
5
+ maxLength?: number;
6
+ minLengthMessage?: CounterMessageSetter;
7
+ maxLengthMessage?: CounterMessageSetter;
8
+ };
9
+ declare const useCounter: ({ minLength, maxLength, minLengthMessage, maxLengthMessage }: Props) => {
10
+ counterMessage: string;
11
+ counterError: boolean;
12
+ handleCounterMessage: TextLengthChangeHandler;
13
+ };
14
+ export default useCounter;
@@ -0,0 +1,68 @@
1
+ import { useCallback, useState } from 'react';
2
+ const CLOSE_TO_LIMIT = 10;
3
+ const defaultMinLengthMessage = (minLength, currLength, isError) => {
4
+ if (isError) {
5
+ return `${minLength} characters required, current count is ${currLength}`;
6
+ }
7
+ return `${currLength} characters entered`;
8
+ };
9
+ const defaultMaxLengthMessage = (maxLength, currLength, isError) => {
10
+ if (isError) {
11
+ return `${currLength - maxLength} over the limit`;
12
+ }
13
+ return `${maxLength - currLength} characters left`;
14
+ };
15
+ const getInitialCounterMessage = ({ minLength, maxLength, minLengthMessage = defaultMinLengthMessage, maxLengthMessage = defaultMaxLengthMessage }) => {
16
+ if (minLength) {
17
+ return minLengthMessage(minLength, 0, true);
18
+ }
19
+ if (maxLength) {
20
+ return maxLengthMessage(maxLength, 0, false);
21
+ }
22
+ return '';
23
+ };
24
+ const useCounter = ({ minLength, maxLength, minLengthMessage = defaultMinLengthMessage, maxLengthMessage = defaultMaxLengthMessage }) => {
25
+ const [message, setMesssage] = useState(() => getInitialCounterMessage({
26
+ minLength,
27
+ maxLength,
28
+ minLengthMessage,
29
+ maxLengthMessage
30
+ }));
31
+ const [isError, setIsError] = useState(!!minLength);
32
+ const handleCounterMessage = useCallback(currLength => {
33
+ if (minLength) {
34
+ if (currLength < minLength) {
35
+ setMesssage(minLengthMessage(minLength, currLength, true));
36
+ setIsError(true);
37
+ return;
38
+ }
39
+ else if (!maxLength) {
40
+ setMesssage(minLengthMessage(minLength, currLength, false));
41
+ setIsError(false);
42
+ return;
43
+ }
44
+ }
45
+ if (maxLength) {
46
+ if (maxLength - currLength <= CLOSE_TO_LIMIT &&
47
+ maxLength - currLength >= 0) {
48
+ setMesssage(maxLengthMessage(maxLength, currLength, false));
49
+ setIsError(true);
50
+ return;
51
+ }
52
+ if (currLength < maxLength) {
53
+ setMesssage(maxLengthMessage(maxLength, currLength, false));
54
+ setIsError(false);
55
+ return;
56
+ }
57
+ setMesssage(maxLengthMessage(maxLength, currLength, true));
58
+ setIsError(true);
59
+ }
60
+ }, [minLength, maxLength, minLengthMessage, maxLengthMessage]);
61
+ return {
62
+ counterMessage: message,
63
+ counterError: isError,
64
+ handleCounterMessage
65
+ };
66
+ };
67
+ export default useCounter;
68
+ //# sourceMappingURL=useCounter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCounter.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useCounter/useCounter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAY7C,MAAM,cAAc,GAAG,EAAE,CAAA;AACzB,MAAM,uBAAuB,GAAyB,CACpD,SAAS,EACT,UAAU,EACV,OAAO,EACP,EAAE;IACF,IAAI,OAAO,EAAE;QACX,OAAO,GAAG,SAAS,0CAA0C,UAAU,EAAE,CAAA;KAC1E;IAED,OAAO,GAAG,UAAU,qBAAqB,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,uBAAuB,GAAyB,CACpD,SAAS,EACT,UAAU,EACV,OAAO,EACP,EAAE;IACF,IAAI,OAAO,EAAE;QACX,OAAO,GAAG,UAAU,GAAG,SAAS,iBAAiB,CAAA;KAClD;IAED,OAAO,GAAG,SAAS,GAAG,UAAU,kBAAkB,CAAA;AACpD,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAAC,EAChC,SAAS,EACT,SAAS,EACT,gBAAgB,GAAG,uBAAuB,EAC1C,gBAAgB,GAAG,uBAAuB,EACpC,EAAE,EAAE;IACV,IAAI,SAAS,EAAE;QACb,OAAO,gBAAgB,CAAC,SAAS,EAAE,CAAC,EAAE,IA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AI,UAAU,GAAG,SAAS,EAAE;gBAC1B,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;gBAC3D,UAAU,CAAC,KAAK,CAAC,CAAA;gBAEjB,OAAM;aACP;YAED,WAAW,CAAC,gBAAgB,CAAC,SAAS,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC,CAAA;YAC1D,UAAU,CAAC,IAAI,CAAC,CAAA;SACjB;IACH,CAAC,EACD,CAAC,SAAS,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAC3D,CAAA;IAED,OAAO;QACL,cAAc,EAAE,OAAO;QACvB,YAAY,EAAE,OAAO;QACrB,oBAAoB;KACrB,CAAA;AACH,CAAC,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './useOnFocus';
@@ -0,0 +1,2 @@
1
+ export { default } from './useOnFocus';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useOnFocus/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { ActionsType } from '../../store';
2
+ declare type Props = {
3
+ autoFocus: boolean;
4
+ editorRef: React.RefObject<HTMLDivElement>;
5
+ toolbarRef: React.RefObject<HTMLDivElement>;
6
+ wrapperRef: React.RefObject<HTMLDivElement>;
7
+ onFocus: () => void;
8
+ onBlur: () => void;
9
+ dispatch: React.Dispatch<ActionsType>;
10
+ };
11
+ declare const useOnFocus: ({ autoFocus, editorRef, toolbarRef, wrapperRef, onFocus, onBlur, dispatch }: Props) => {
12
+ isEditorFocused: boolean;
13
+ handleFocus: (e: React.FocusEvent<HTMLDivElement>) => void;
14
+ handleBlur: (e: React.FocusEvent<HTMLDivElement>) => void;
15
+ };
16
+ export default useOnFocus;
@@ -0,0 +1,44 @@
1
+ import { useCallback, useState } from 'react';
2
+ import { actions as toolbarActions } from '../../store/toolbar';
3
+ const useOnFocus = ({ autoFocus, editorRef, toolbarRef, wrapperRef, onFocus, onBlur, dispatch }) => {
4
+ const [isEditorFocused, setIsEditorFocused] = useState(autoFocus);
5
+ const handleFocus = useCallback((e) => {
6
+ console.log('focus');
7
+ if (!editorRef.current || !toolbarRef.current || !wrapperRef) {
8
+ return;
9
+ }
10
+ toolbarActions.setDisabled(dispatch)(false);
11
+ const focusElement = e.target;
12
+ const isFocusElementInToolbar = toolbarRef.current.contains(focusElement);
13
+ if (isFocusElementInToolbar) {
14
+ return;
15
+ }
16
+ setIsEditorFocused(true);
17
+ onFocus();
18
+ }, [dispatch, onFocus, editorRef, toolbarRef, wrapperRef]);
19
+ const handleBlur = useCallback((e) => {
20
+ if (!toolbarRef.current || !editorRef.current) {
21
+ return;
22
+ }
23
+ const focusElement = e.relatedTarget;
24
+ const isFocusElementInToolbar = toolbarRef.current.contains(focusElement);
25
+ const isFocusElementInEditor = editorRef.current.contains(focusElement);
26
+ const isFocusElementWrapper = wrapperRef.current === focusElement;
27
+ if (isFocusElementInToolbar ||
28
+ isFocusElementInEditor ||
29
+ isFocusElementWrapper) {
30
+ return;
31
+ }
32
+ toolbarActions.setDisabled(dispatch)(true);
33
+ toolbarActions.resetFormat(dispatch)();
34
+ setIsEditorFocused(false);
35
+ onBlur();
36
+ }, [dispatch, onBlur, toolbarRef, editorRef, wrapperRef]);
37
+ return {
38
+ isEditorFocused,
39
+ handleFocus,
40
+ handleBlur
41
+ };
42
+ };
43
+ export default useOnFocus;
44
+ //# sourceMappingURL=useOnFocus.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnFocus.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useOnFocus/useOnFocus.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE7C,OAAO,EAAE,OAA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QACvE,MAAM,qBAAqB,GAAG,UAAU,CAAC,OAAO,KAAK,YAAY,CAAA;QAEjE,IACE,uBAAuB;YACvB,sBAAsB;YACtB,qBAAqB,EACrB;YACA,OAAM;SACP;QAED,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;QAE1C,cAAc,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAA;QAEtC,kBAAkB,CAAC,KAAK,CAAC,CAAA;QAEzB,MAAM,EAAE,CAAA;IACV,CAAC,EACD,CAAC,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,CACtD,CAAA;IAED,OAAO;QACL,eAAe;QACf,WAAW;QACX,UAAU;KACX,CAAA;AACH,CAAC,CAAA;AAED,eAAe,UAAU,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './useOnSelectionChange';
@@ -0,0 +1,2 @@
1
+ export { default } from './useOnSelectionChange';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useOnSelectionChange/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Dispatch } from 'react';
2
+ import { FormatType as EditorFormatType } from '../../../QuillEditor';
3
+ import { ActionsType } from '../../store';
4
+ declare type Props = {
5
+ dispatch: Dispatch<ActionsType>;
6
+ };
7
+ declare const useOnSelectionChange: ({ dispatch }: Props) => {
8
+ handleSelectionChange: (editorFormat: EditorFormatType) => void;
9
+ };
10
+ export default useOnSelectionChange;
@@ -0,0 +1,15 @@
1
+ import { useCallback } from 'react';
2
+ import { actions as toolbarActions } from '../../store/toolbar';
3
+ import { getToolbarFormatFromEditorFormat } from '../../utils/convertFormat';
4
+ const useOnSelectionChange = ({ dispatch }) => {
5
+ const handleSelectionChange = useCallback((editorFormat) => {
6
+ const { bold, italic, header, list } = getToolbarFormatFromEditorFormat(editorFormat);
7
+ toolbarActions.setBold(dispatch)(bold);
8
+ toolbarActions.setItalic(dispatch)(italic);
9
+ toolbarActions.setHeader(dispatch)(header);
10
+ toolbarActions.setList(dispatch)(list);
11
+ }, [dispatch]);
12
+ return { handleSelectionChange };
13
+ };
14
+ export default useOnSelectionChange;
15
+ //# sourceMappingURL=useOnSelectionChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOnSelectionChange.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useOnSelectionChange/useOnSelectionChange.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAY,WAAW,EAAE,MAAM,OAAO,CAAA;AAG7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAA;AAE/D,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAA;AAM5E,MAAM,oBAAoB,GAAG,CAAC,EAAE,QAAQ,EAAS,EAAE,EAAE;IACnD,MAAM,qBAAqB,GAAG,WAAW,CACvC,CAAC,YAA8B,EAAE,EAAE;QACjC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,gCAAgC,CACrE,YAAY,CACb,CAAA;QAED,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;QACtC,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;QAC1C,cAAc,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAA;QAC1C,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAA;IACxC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAA;IAED,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAClC,CAAC,CAAA;AAED,eAAe,oBAAoB,CAAA"}
@@ -0,0 +1 @@
1
+ export { default } from './useOnTextFormat';
@@ -0,0 +1,2 @@
1
+ export { default } from './useOnTextFormat';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/RichTextEditor/hooks/useOnTextFormat/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,10 @@
1
+ import { Dispatch } from 'react';
2
+ import { ActionsType } from '../../store';
3
+ import { TextFormatHandlerEvent } from '../../../QuillEditor';
4
+ declare type Props = {
5
+ dispatch: Dispatch<ActionsType>;
6
+ };
7
+ declare const useOnTextFormat: ({ dispatch }: Props) => {
8
+ handleTextFormat: (e: TextFormatHandlerEvent) => void;
9
+ };
10
+ export default useOnTextFormat;