@pareto-engineering/design-system 4.0.0-alpha.77 → 4.0.0-alpha.79

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 (210) hide show
  1. package/dist/cjs/a/AnimatedBlobs/AnimatedBlobs.js +1 -1
  2. package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +1 -1
  3. package/dist/cjs/a/AppContext/Context.js +1 -1
  4. package/dist/cjs/a/AppContext/ContextProvider.js +1 -1
  5. package/dist/cjs/a/BlurOverlay/BlurOverlay.js +1 -1
  6. package/dist/cjs/a/ContentTree/ContentTree.js +1 -1
  7. package/dist/cjs/a/ContentTree/common/Tree/Tree.js +1 -1
  8. package/dist/cjs/a/Conversation/Context.js +1 -1
  9. package/dist/cjs/a/Conversation/Conversation.js +1 -1
  10. package/dist/cjs/a/Conversation/common/Message/Message.js +1 -1
  11. package/dist/cjs/a/DatePicker/DatePicker.js +1 -1
  12. package/dist/cjs/a/DotInfo/DotInfo.js +1 -1
  13. package/dist/cjs/a/Figure/Figure.js +1 -1
  14. package/dist/cjs/a/HamburgerButton/HamburgerButton.js +1 -1
  15. package/dist/cjs/a/IconList/IconList.js +1 -1
  16. package/dist/cjs/a/IconList/common/Item/Item.js +1 -1
  17. package/dist/cjs/a/Label/Label.js +1 -1
  18. package/dist/cjs/a/LoadingCircle/LoadingCircle.js +1 -1
  19. package/dist/cjs/a/MetaCard/MetaCard.js +1 -1
  20. package/dist/cjs/a/People/People.js +1 -1
  21. package/dist/cjs/a/People/common/Person/Person.js +1 -1
  22. package/dist/cjs/a/People/styles.scss +1 -1
  23. package/dist/cjs/a/Popover/Popover.js +1 -1
  24. package/dist/cjs/a/ProgressBar/ProgressBar.js +1 -1
  25. package/dist/cjs/a/Quote/Quote.js +16 -6
  26. package/dist/cjs/a/Quote/styles.scss +16 -37
  27. package/dist/cjs/a/Removable/Removable.js +1 -1
  28. package/dist/cjs/a/SVG/SVG.js +1 -1
  29. package/dist/cjs/a/SVG/common/UseSVG/UseSVG.js +1 -1
  30. package/dist/cjs/a/SnapScroller/SnapScroller.js +1 -1
  31. package/dist/cjs/a/Spinner/Spinner.js +1 -1
  32. package/dist/cjs/a/TextSteps/TextSteps.js +1 -1
  33. package/dist/cjs/a/Timestamp/Timestamp.js +1 -1
  34. package/dist/cjs/a/Tip/Tip.js +1 -1
  35. package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +1 -1
  36. package/dist/cjs/a/Tooltip/Tooltip.js +71 -0
  37. package/dist/cjs/a/{LexicalPreview → Tooltip}/index.js +3 -3
  38. package/dist/cjs/a/Tooltip/styles.scss +56 -0
  39. package/dist/cjs/a/XMLEditor/XMLEditor.js +1 -1
  40. package/dist/cjs/a/index.js +8 -8
  41. package/dist/cjs/b/Button/Button.js +1 -1
  42. package/dist/cjs/b/Button/common/Group/Group.js +1 -1
  43. package/dist/cjs/b/Card/Card.js +1 -1
  44. package/dist/cjs/b/Card/common/Group/Group.js +1 -1
  45. package/dist/cjs/b/Card/common/Section/Section.js +1 -1
  46. package/dist/cjs/b/Logo/Logo.js +1 -1
  47. package/dist/cjs/b/Page/Context.js +1 -1
  48. package/dist/cjs/b/Page/Page.js +1 -1
  49. package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +5 -2
  50. package/dist/cjs/b/Page/common/Section/Section.js +1 -1
  51. package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +1 -1
  52. package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
  53. package/dist/cjs/b/Title/Title.js +1 -1
  54. package/dist/cjs/b/index.js +1 -8
  55. package/dist/cjs/c/Modal/Modal.js +1 -1
  56. package/dist/cjs/c/Modal/common/ModalHeader/ModalHeader.js +1 -1
  57. package/dist/cjs/c/Shortener/Shortener.js +1 -1
  58. package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +1 -1
  59. package/dist/cjs/f/FormInput/FormInput.js +1 -1
  60. package/dist/cjs/f/common/Debugger/Debugger.js +1 -1
  61. package/dist/cjs/f/common/Description/Description.js +1 -1
  62. package/dist/cjs/f/common/Label/Label.js +1 -1
  63. package/dist/cjs/f/fields/Checkbox/Checkbox.js +1 -1
  64. package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
  65. package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +1 -1
  66. package/dist/cjs/f/fields/EditorInput/EditorInput.js +37 -12
  67. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +256 -0
  68. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/index.js +13 -0
  69. package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  70. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +94 -0
  71. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/index.js +13 -0
  72. package/dist/cjs/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  73. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +94 -0
  74. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/index.js +13 -0
  75. package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  76. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +295 -0
  77. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/index.js +13 -0
  78. package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  79. package/dist/cjs/f/fields/EditorInput/common/index.js +24 -3
  80. package/dist/cjs/f/fields/EditorInput/styles.scss +116 -25
  81. package/dist/cjs/f/fields/LinkInput/LinkInput.js +1 -1
  82. package/dist/cjs/f/fields/QueryChoices/QueryChoices.js +1 -1
  83. package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +1 -1
  84. package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +1 -1
  85. package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +1 -1
  86. package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +1 -1
  87. package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +1 -1
  88. package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +1 -1
  89. package/dist/cjs/f/fields/RatingsInput/common/Rating/Rating.js +1 -1
  90. package/dist/cjs/f/fields/SelectInput/SelectInput.js +10 -3
  91. package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
  92. package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
  93. package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +14 -3
  94. package/dist/cjs/f/fields/SelectInput/styles.scss +1 -1
  95. package/dist/cjs/f/fields/TextInput/TextInput.js +1 -1
  96. package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +1 -1
  97. package/dist/cjs/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +28 -43
  98. package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +7 -8
  99. package/dist/cjs/g/ExpandableLexicalPreview/styles.scss +34 -0
  100. package/dist/cjs/g/index.js +12 -0
  101. package/dist/cjs/index.js +11 -0
  102. package/dist/cjs/test/QueryLoader/QueryLoader.js +1 -1
  103. package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +1 -1
  104. package/dist/cjs/utils/hooks/index.js +7 -0
  105. package/dist/cjs/utils/hooks/useOutsideClick.js +25 -0
  106. package/dist/cjs/utils/index.js +6 -0
  107. package/dist/es/a/People/styles.scss +1 -1
  108. package/dist/es/a/Quote/Quote.js +15 -5
  109. package/dist/es/a/Quote/styles.scss +16 -37
  110. package/dist/es/a/Tooltip/Tooltip.js +59 -0
  111. package/dist/es/a/Tooltip/index.js +2 -0
  112. package/dist/es/a/Tooltip/styles.scss +56 -0
  113. package/dist/es/a/index.js +2 -2
  114. package/dist/es/b/Page/common/PageHelmet/PageHelmet.js +4 -1
  115. package/dist/es/b/index.js +1 -2
  116. package/dist/es/f/fields/EditorInput/EditorInput.js +35 -11
  117. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +246 -0
  118. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
  119. package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  120. package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +83 -0
  121. package/dist/es/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
  122. package/dist/es/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  123. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +81 -0
  124. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
  125. package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  126. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +283 -0
  127. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
  128. package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  129. package/dist/es/f/fields/EditorInput/common/index.js +5 -2
  130. package/dist/es/f/fields/EditorInput/styles.scss +116 -25
  131. package/dist/es/f/fields/SelectInput/SelectInput.js +9 -2
  132. package/dist/es/f/fields/SelectInput/common/Single/Single.js +12 -1
  133. package/dist/es/f/fields/SelectInput/styles.scss +1 -1
  134. package/dist/es/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.js +29 -45
  135. package/dist/es/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +18 -21
  136. package/dist/es/g/ExpandableLexicalPreview/styles.scss +34 -0
  137. package/dist/es/g/index.js +1 -0
  138. package/dist/es/index.js +1 -0
  139. package/dist/es/utils/hooks/index.js +2 -1
  140. package/dist/es/utils/hooks/useOutsideClick.js +19 -0
  141. package/dist/es/utils/index.js +1 -1
  142. package/package.json +14 -6
  143. package/src/stories/a/Quote.stories.jsx +30 -10
  144. package/src/stories/a/Tooltip.stories.jsx +80 -0
  145. package/src/stories/a/XMLEditor.stories.jsx +6 -1
  146. package/src/stories/f/SelectInput.stories.jsx +18 -2
  147. package/src/stories/{b → g}/ExpandableLexicalPreview.stories.jsx +2 -1
  148. package/src/ui/a/People/styles.scss +1 -1
  149. package/src/ui/a/Quote/Quote.jsx +16 -9
  150. package/src/ui/a/Quote/styles.scss +16 -37
  151. package/src/ui/a/Tooltip/Tooltip.jsx +83 -0
  152. package/src/ui/a/Tooltip/index.js +2 -0
  153. package/src/ui/a/Tooltip/styles.scss +56 -0
  154. package/src/ui/a/index.js +1 -1
  155. package/src/ui/b/Page/common/PageHelmet/PageHelmet.jsx +6 -0
  156. package/src/ui/b/index.js +0 -1
  157. package/src/ui/f/fields/EditorInput/EditorInput.jsx +35 -5
  158. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.jsx +292 -0
  159. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
  160. package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
  161. package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +110 -0
  162. package/src/ui/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
  163. package/src/ui/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
  164. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.jsx +134 -0
  165. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
  166. package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
  167. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +431 -0
  168. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
  169. package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
  170. package/src/ui/f/fields/EditorInput/common/index.js +6 -0
  171. package/src/ui/f/fields/EditorInput/styles.scss +116 -25
  172. package/src/ui/f/fields/SelectInput/SelectInput.jsx +10 -2
  173. package/src/ui/f/fields/SelectInput/common/Single/Single.jsx +13 -1
  174. package/src/ui/f/fields/SelectInput/styles.scss +1 -1
  175. package/src/ui/{b → g}/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +43 -56
  176. package/src/ui/{b → g}/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +32 -36
  177. package/src/ui/g/ExpandableLexicalPreview/styles.scss +34 -0
  178. package/src/ui/g/index.js +1 -0
  179. package/src/ui/index.js +1 -0
  180. package/src/ui/utils/hooks/index.js +1 -0
  181. package/src/ui/utils/hooks/useOutsideClick.js +23 -0
  182. package/src/ui/utils/index.js +1 -1
  183. package/tests/__snapshots__/Storyshots.test.js.snap +914 -433
  184. package/tests/mockResizeObserver.js +9 -0
  185. package/tests/test-setup.js +3 -0
  186. package/dist/cjs/a/LexicalPreview/LexicalPreview.js +0 -90
  187. package/dist/cjs/a/LexicalPreview/styles.scss +0 -46
  188. package/dist/cjs/b/ExpandableLexicalPreview/styles.scss +0 -84
  189. package/dist/cjs/f/fields/EditorInput/common/Toolbar.js +0 -257
  190. package/dist/es/a/LexicalPreview/LexicalPreview.js +0 -80
  191. package/dist/es/a/LexicalPreview/index.js +0 -2
  192. package/dist/es/a/LexicalPreview/styles.scss +0 -46
  193. package/dist/es/b/ExpandableLexicalPreview/styles.scss +0 -84
  194. package/dist/es/f/fields/EditorInput/common/Toolbar.js +0 -246
  195. package/src/stories/a/LexicalPreview.stories.jsx +0 -28
  196. package/src/ui/a/LexicalPreview/LexicalPreview.jsx +0 -109
  197. package/src/ui/a/LexicalPreview/index.js +0 -2
  198. package/src/ui/a/LexicalPreview/styles.scss +0 -46
  199. package/src/ui/b/ExpandableLexicalPreview/styles.scss +0 -84
  200. package/src/ui/f/fields/EditorInput/common/Toolbar.jsx +0 -356
  201. package/src/ui/f/fields/EditorInput/common/index.jsx +0 -3
  202. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  203. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  204. /package/dist/cjs/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  205. /package/dist/es/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  206. /package/dist/es/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  207. /package/dist/es/{b → g}/ExpandableLexicalPreview/index.js +0 -0
  208. /package/src/ui/{b → g}/ExpandableLexicalPreview/common/ExpandButton/index.js +0 -0
  209. /package/src/ui/{b → g}/ExpandableLexicalPreview/common/index.js +0 -0
  210. /package/src/ui/{b → g}/ExpandableLexicalPreview/index.js +0 -0
@@ -1,356 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies -- required here */
2
- import * as React from 'react'
3
-
4
- import {
5
- useEffect,
6
- useState,
7
- useCallback,
8
- useRef,
9
- } from 'react'
10
-
11
- import {
12
- $getSelection,
13
- $isRangeSelection,
14
- FORMAT_TEXT_COMMAND,
15
- FORMAT_ELEMENT_COMMAND,
16
- UNDO_COMMAND,
17
- REDO_COMMAND,
18
- COMMAND_PRIORITY_NORMAL,
19
- createCommand,
20
- } from 'lexical'
21
- import {
22
- INSERT_ORDERED_LIST_COMMAND,
23
- INSERT_UNORDERED_LIST_COMMAND,
24
- REMOVE_LIST_COMMAND,
25
- $isListNode,
26
- ListNode,
27
- } from '@lexical/list'
28
- import {
29
- $isAtNodeEnd,
30
- } from '@lexical/selection'
31
- import {
32
- $isLinkNode,
33
- TOGGLE_LINK_COMMAND,
34
- } from '@lexical/link'
35
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'
36
- import { mergeRegister, $getNearestNodeOfType } from '@lexical/utils'
37
-
38
- import { Popover } from 'ui'
39
-
40
- import styleNames from '@pareto-engineering/bem/exports'
41
-
42
- const baseClassName = styleNames.base
43
-
44
- const componentClassName = 'toolbar'
45
-
46
- const getSelectedNode = (selection) => {
47
- const { anchor, focus } = selection
48
- const anchorNode = selection.anchor.getNode()
49
- const focusNode = selection.focus.getNode()
50
- if (anchorNode === focusNode) {
51
- return anchorNode
52
- }
53
- const isBackward = selection.isBackward()
54
- if (isBackward) {
55
- return $isAtNodeEnd(focus) ? anchorNode : focusNode
56
- }
57
- return $isAtNodeEnd(anchor) ? focusNode : anchorNode
58
- }
59
-
60
- const defaultColor = 'var(--paragraph)'
61
-
62
- const colorOptions = [
63
- 'red',
64
- 'blue',
65
- 'green',
66
- 'yellow',
67
- 'orange',
68
- 'purple',
69
- 'pink',
70
- 'brown',
71
- ]
72
-
73
- const Toolbar = () => {
74
- const [editor] = useLexicalComposerContext()
75
- const [isBold, setIsBold] = useState(false)
76
- const [isItalic, setIsItalic] = useState(false)
77
- const [isStrikethrough, setIsStrikethrough] = useState(false)
78
- const [blockType, setBlockType] = useState('paragraph')
79
- const [isLink, setIsLink] = useState(false)
80
- const [isUnderline, setIsUnderline] = useState(false)
81
- const [color, setColor] = useState(defaultColor)
82
-
83
- const colorMenuRef = useRef(false)
84
-
85
- const formatBulletList = () => {
86
- if (blockType !== 'ul') {
87
- editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND)
88
- } else {
89
- editor.dispatchCommand(REMOVE_LIST_COMMAND)
90
- }
91
- }
92
-
93
- const formatNumberedList = () => {
94
- if (blockType !== 'ol') {
95
- editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND)
96
- } else {
97
- editor.dispatchCommand(REMOVE_LIST_COMMAND)
98
- }
99
- }
100
-
101
- const formatLink = useCallback(() => {
102
- if (!isLink) {
103
- // eslint-disable-next-line no-alert
104
- const path = prompt('Enter the full URL. Ex: https://www.example.com')
105
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, path)
106
- } else {
107
- editor.dispatchCommand(TOGGLE_LINK_COMMAND, null)
108
- }
109
- }, [editor, isLink])
110
-
111
- const updateToolbar = useCallback(() => {
112
- const selection = $getSelection()
113
-
114
- // Check list selection
115
- if ($isRangeSelection(selection)) {
116
- const anchorNode = selection.anchor.getNode()
117
- const element = anchorNode.getKey() === 'root'
118
- ? anchorNode
119
- : anchorNode.getTopLevelElementOrThrow()
120
- if ($isListNode(element)) {
121
- const parentList = $getNearestNodeOfType(anchorNode, ListNode)
122
- const type = parentList ? parentList.getTag() : element.getTag()
123
- setBlockType(type)
124
- } else {
125
- setBlockType(element)
126
- }
127
-
128
- // Check nodes for color
129
- const nodes = selection.getNodes().filter((node) => node.getType() === 'text')
130
- nodes.forEach((node) => {
131
- const style = node.getStyle()
132
- const colorProperty = style.match(/color: ([^;]+)/)
133
- if (colorProperty) {
134
- setColor(colorProperty[1])
135
- return
136
- }
137
- setColor(false)
138
- })
139
-
140
- // Check selection text styles
141
- setIsBold(selection.hasFormat('bold'))
142
- setIsItalic(selection.hasFormat('italic'))
143
- setIsStrikethrough(selection.hasFormat('strikethrough'))
144
- setIsUnderline(selection.hasFormat('underline'))
145
- setIsLink(selection.hasFormat('link'))
146
-
147
- // Check links
148
- const node = getSelectedNode(selection)
149
- const parent = node.getParent()
150
- if ($isLinkNode(parent) || $isLinkNode(node)) {
151
- setIsLink(true)
152
- } else {
153
- setIsLink(false)
154
- }
155
- }
156
- }, [editor])
157
-
158
- const UPDATE_COLOR_COMMAND = createCommand()
159
-
160
- editor.registerCommand(UPDATE_COLOR_COMMAND, (payload) => {
161
- const selection = $getSelection()
162
- const nodes = selection?.extract().filter((node) => node.getType() === 'text')
163
- nodes?.forEach((node) => {
164
- const style = node.getStyle()
165
- const colorProperty = style?.match(/color: ([^;]+)/)
166
- if (colorProperty && color !== payload) {
167
- node.setStyle(style.replace(colorProperty[0], `color: ${payload}`))
168
- } else if (colorProperty) {
169
- node.setStyle(`color: ${defaultColor}`)
170
- } else {
171
- node.setStyle(`color: ${payload}`)
172
- }
173
- })
174
- }, COMMAND_PRIORITY_NORMAL)
175
-
176
- useEffect(() => mergeRegister(
177
- editor.registerUpdateListener(({ editorState }) => {
178
- editorState.read(() => {
179
- updateToolbar()
180
- })
181
- }),
182
- ), [updateToolbar, editor])
183
-
184
- const dispatchUpdateColor = useCallback((e, payload) => {
185
- e.stopPropagation()
186
- editor.dispatchCommand(UPDATE_COLOR_COMMAND, payload)
187
- }, [editor])
188
-
189
- return (
190
- <div className={`${baseClassName} ${componentClassName}`}>
191
- <div className="group">
192
- <button
193
- type="button"
194
- className={isBold ? 'active' : undefined}
195
- onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'bold')}
196
- >
197
- <span className="icon">
198
- |
199
- </span>
200
- </button>
201
- <button
202
- type="button"
203
- className={isItalic ? 'active' : undefined}
204
- onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'italic')}
205
- >
206
- <span className="icon">
207
- &#125;
208
- </span>
209
- </button>
210
- <button
211
- type="button"
212
- className={isUnderline ? 'active' : undefined}
213
- onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'underline')}
214
- >
215
- <span className="icon">
216
- ~
217
- </span>
218
- </button>
219
- <button
220
- type="button"
221
- className={isStrikethrough ? 'active' : undefined}
222
- onClick={() => editor.dispatchCommand(FORMAT_TEXT_COMMAND, 'strikethrough')}
223
- >
224
- <span className="icon">
225
- ?
226
- </span>
227
- </button>
228
- <button
229
- type="button"
230
- className={color && color !== defaultColor ? 'active color-menu-button' : 'color-menu-button'}
231
- onClick={() => editor.dispatchCommand(UPDATE_COLOR_COMMAND,
232
- color !== defaultColor ? defaultColor : color)}
233
- ref={colorMenuRef}
234
- style={{ position: 'relative' }}
235
- >
236
- <span
237
- className="icon"
238
- style={{
239
- color,
240
- }}
241
- >
242
- Q
243
- </span>
244
- <Popover
245
- parentRef={colorMenuRef}
246
- >
247
- <div className="color-menu">
248
- {
249
- colorOptions.map((option) => (
250
- <span
251
- role="button"
252
- className="icon color-option"
253
- style={{
254
- color:option,
255
- }}
256
- onClick={(e) => dispatchUpdateColor(e, option)}
257
- onKeyDown={(e) => dispatchUpdateColor(e, option)}
258
- tabIndex={0}
259
- key={option}
260
- >
261
- o
262
- </span>
263
- ))
264
- }
265
- </div>
266
- </Popover>
267
- </button>
268
-
269
- <button
270
- type="button"
271
- className={isLink ? 'active' : undefined}
272
- onClick={() => formatLink()}
273
- >
274
- <span className="icon">
275
- &#93;
276
- </span>
277
- </button>
278
- <button
279
- type="button"
280
- className={blockType === 'ul' ? 'active' : undefined}
281
- onClick={() => formatBulletList()}
282
- >
283
- <span className="icon">
284
- .
285
- </span>
286
- </button>
287
- <button
288
- type="button"
289
- className={blockType === 'ol' ? 'active' : undefined}
290
- onClick={() => formatNumberedList()}
291
- >
292
- <span className="icon">
293
- -
294
- </span>
295
- </button>
296
- </div>
297
-
298
- <div className="group">
299
- <button
300
- type="button"
301
- onClick={() => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'left')}
302
- >
303
- <span className="icon">
304
- ^
305
- </span>
306
- </button>
307
- <button
308
- type="button"
309
- onClick={() => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'center')}
310
- >
311
- <span className="icon">
312
- _
313
- </span>
314
- </button>
315
- <button
316
- type="button"
317
- onClick={() => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'right')}
318
- >
319
- <span className="icon">
320
- `
321
- </span>
322
- </button>
323
- <button
324
- type="button"
325
- onClick={() => editor.dispatchCommand(FORMAT_ELEMENT_COMMAND, 'justify')}
326
- >
327
- <span className="icon">
328
- &#123;
329
- </span>
330
- </button>
331
- </div>
332
-
333
- <div className="group">
334
- <button
335
- type="button"
336
- onClick={() => editor.dispatchCommand(UNDO_COMMAND)}
337
- >
338
- <span className="icon">
339
- \
340
- </span>
341
- </button>
342
- <button
343
- type="button"
344
- className="flip"
345
- onClick={() => editor.dispatchCommand(REDO_COMMAND)}
346
- >
347
- <span className="icon">
348
- \
349
- </span>
350
- </button>
351
- </div>
352
- </div>
353
- )
354
- }
355
-
356
- export default Toolbar
@@ -1,3 +0,0 @@
1
- export { default as Toolbar } from './Toolbar'
2
- export { default as TreeViewPlugin } from './TreeViewPlugin'
3
- export { default as StopPropagationPlugin } from './StopPropagationPlugin'