@pareto-engineering/design-system 4.0.0-alpha.76 → 4.0.0-alpha.78
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.
- package/dist/cjs/a/AnimatedBlobs/AnimatedBlobs.js +1 -1
- package/dist/cjs/a/AnimatedGradient/AnimatedGradient.js +1 -1
- package/dist/cjs/a/AppContext/Context.js +1 -1
- package/dist/cjs/a/AppContext/ContextProvider.js +1 -1
- package/dist/cjs/a/BlurOverlay/BlurOverlay.js +1 -1
- package/dist/cjs/a/ContentTree/ContentTree.js +1 -1
- package/dist/cjs/a/ContentTree/common/Tree/Tree.js +1 -1
- package/dist/cjs/a/Conversation/Context.js +1 -1
- package/dist/cjs/a/Conversation/Conversation.js +1 -1
- package/dist/cjs/a/Conversation/common/Message/Message.js +1 -1
- package/dist/cjs/a/DatePicker/DatePicker.js +1 -1
- package/dist/cjs/a/DotInfo/DotInfo.js +1 -1
- package/dist/cjs/a/Figure/Figure.js +1 -1
- package/dist/cjs/a/HamburgerButton/HamburgerButton.js +1 -1
- package/dist/cjs/a/IconList/IconList.js +1 -1
- package/dist/cjs/a/IconList/common/Item/Item.js +1 -1
- package/dist/cjs/a/Label/Label.js +1 -1
- package/dist/cjs/a/LexicalPreview/LexicalPreview.js +1 -1
- package/dist/cjs/a/LoadingCircle/LoadingCircle.js +1 -1
- package/dist/cjs/a/MetaCard/MetaCard.js +1 -1
- package/dist/cjs/a/People/People.js +1 -1
- package/dist/cjs/a/People/common/Person/Person.js +1 -1
- package/dist/cjs/a/People/styles.scss +1 -1
- package/dist/cjs/a/Popover/Popover.js +1 -1
- package/dist/cjs/a/ProgressBar/ProgressBar.js +1 -1
- package/dist/cjs/a/Quote/Quote.js +16 -6
- package/dist/cjs/a/Quote/styles.scss +16 -37
- package/dist/cjs/a/Removable/Removable.js +1 -1
- package/dist/cjs/a/SVG/SVG.js +1 -1
- package/dist/cjs/a/SVG/common/UseSVG/UseSVG.js +1 -1
- package/dist/cjs/a/SnapScroller/SnapScroller.js +1 -1
- package/dist/cjs/a/Spinner/Spinner.js +1 -1
- package/dist/cjs/a/TextSteps/TextSteps.js +1 -1
- package/dist/cjs/a/Timestamp/Timestamp.js +1 -1
- package/dist/cjs/a/Tip/Tip.js +1 -1
- package/dist/cjs/a/ToggleSwitch/ToggleSwitch.js +1 -1
- package/dist/cjs/a/Tooltip/Tooltip.js +71 -0
- package/dist/cjs/a/Tooltip/index.js +13 -0
- package/dist/cjs/a/Tooltip/styles.scss +53 -0
- package/dist/cjs/a/XMLEditor/XMLEditor.js +1 -1
- package/dist/cjs/a/index.js +8 -1
- package/dist/cjs/b/Button/Button.js +1 -1
- package/dist/cjs/b/Button/common/Group/Group.js +1 -1
- package/dist/cjs/b/Card/Card.js +1 -1
- package/dist/cjs/b/Card/common/Group/Group.js +1 -1
- package/dist/cjs/b/Card/common/Section/Section.js +1 -1
- package/dist/cjs/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +3 -3
- package/dist/cjs/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +3 -3
- package/dist/cjs/b/Logo/Logo.js +1 -1
- package/dist/cjs/b/Page/Context.js +1 -1
- package/dist/cjs/b/Page/Page.js +1 -1
- package/dist/cjs/b/Page/common/PageHelmet/PageHelmet.js +1 -1
- package/dist/cjs/b/Page/common/Section/Section.js +1 -1
- package/dist/cjs/b/SocialMediaButton/SocialMediaButton.js +1 -1
- package/dist/cjs/b/ThemeSelector/ThemeSelector.js +1 -1
- package/dist/cjs/b/Title/Title.js +1 -1
- package/dist/cjs/c/Modal/Modal.js +1 -1
- package/dist/cjs/c/Modal/common/ModalHeader/ModalHeader.js +1 -1
- package/dist/cjs/c/Shortener/Shortener.js +1 -1
- package/dist/cjs/c/SocialMediaShareButton/SocialMediaShareButton.js +1 -1
- package/dist/cjs/f/FormInput/FormInput.js +1 -1
- package/dist/cjs/f/common/Debugger/Debugger.js +1 -1
- package/dist/cjs/f/common/Description/Description.js +1 -1
- package/dist/cjs/f/common/Description/styles.scss +1 -2
- package/dist/cjs/f/common/Label/Label.js +1 -1
- package/dist/cjs/f/fields/Checkbox/Checkbox.js +1 -1
- package/dist/cjs/f/fields/ChoicesInput/ChoicesInput.js +1 -1
- package/dist/cjs/f/fields/ChoicesInput/common/Choice/Choice.js +1 -1
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +20 -9
- package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +256 -0
- package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/index.js +13 -0
- package/dist/cjs/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
- package/dist/cjs/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +94 -0
- package/dist/cjs/f/fields/EditorInput/common/ColorPicker/index.js +13 -0
- package/dist/cjs/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
- package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +94 -0
- package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/index.js +13 -0
- package/dist/cjs/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +295 -0
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/index.js +13 -0
- package/dist/cjs/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
- package/dist/cjs/f/fields/EditorInput/common/index.js +24 -3
- package/dist/cjs/f/fields/EditorInput/styles.scss +109 -25
- package/dist/cjs/f/fields/LinkInput/LinkInput.js +1 -1
- package/dist/cjs/f/fields/QueryChoices/QueryChoices.js +1 -1
- package/dist/cjs/f/fields/QueryCombobox/QueryCombobox.js +1 -1
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +1 -1
- package/dist/cjs/f/fields/QueryCombobox/common/Menu/Menu.js +1 -1
- package/dist/cjs/f/fields/QueryCombobox/common/MultipleCombobox/MultipleCombobox.js +1 -1
- package/dist/cjs/f/fields/QuerySelect/QuerySelect.js +1 -1
- package/dist/cjs/f/fields/RatingsInput/RatingsInput.js +1 -1
- package/dist/cjs/f/fields/RatingsInput/common/Rating/Rating.js +1 -1
- package/dist/cjs/f/fields/SelectInput/SelectInput.js +1 -1
- package/dist/cjs/f/fields/SelectInput/common/Menu/Menu.js +1 -1
- package/dist/cjs/f/fields/SelectInput/common/Multiple/Multiple.js +1 -1
- package/dist/cjs/f/fields/SelectInput/common/Single/Single.js +1 -1
- package/dist/cjs/f/fields/TextInput/TextInput.js +1 -1
- package/dist/cjs/f/fields/TextInput/styles.scss +5 -2
- package/dist/cjs/f/fields/TextareaInput/TextareaInput.js +1 -1
- package/dist/cjs/test/QueryLoader/QueryLoader.js +1 -1
- package/dist/cjs/test/QueryLoader/common/PreloadedTestData/PreloadedTestData.js +1 -1
- package/dist/cjs/utils/hooks/index.js +7 -0
- package/dist/cjs/utils/hooks/useOutsideClick.js +25 -0
- package/dist/cjs/utils/index.js +6 -0
- package/dist/es/a/People/styles.scss +1 -1
- package/dist/es/a/Quote/Quote.js +15 -5
- package/dist/es/a/Quote/styles.scss +16 -37
- package/dist/es/a/Tooltip/Tooltip.js +59 -0
- package/dist/es/a/Tooltip/index.js +2 -0
- package/dist/es/a/Tooltip/styles.scss +53 -0
- package/dist/es/a/index.js +2 -1
- package/dist/es/b/ExpandableLexicalPreview/ExpandableLexicalPreview.js +1 -1
- package/dist/es/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.js +1 -1
- package/dist/es/f/common/Description/styles.scss +1 -2
- package/dist/es/f/fields/EditorInput/EditorInput.js +20 -9
- package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.js +246 -0
- package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
- package/dist/es/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
- package/dist/es/f/fields/EditorInput/common/ColorPicker/ColorPicker.js +83 -0
- package/dist/es/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
- package/dist/es/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
- package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.js +81 -0
- package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
- package/dist/es/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.js +283 -0
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
- package/dist/es/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
- package/dist/es/f/fields/EditorInput/common/index.js +5 -2
- package/dist/es/f/fields/EditorInput/styles.scss +109 -25
- package/dist/es/f/fields/TextInput/styles.scss +5 -2
- package/dist/es/utils/hooks/index.js +2 -1
- package/dist/es/utils/hooks/useOutsideClick.js +19 -0
- package/dist/es/utils/index.js +1 -1
- package/package.json +13 -5
- package/src/stories/a/Quote.stories.jsx +30 -10
- package/src/stories/a/Tooltip.stories.jsx +80 -0
- package/src/stories/a/XMLEditor.stories.jsx +6 -1
- package/src/ui/a/People/styles.scss +1 -1
- package/src/ui/a/Quote/Quote.jsx +16 -9
- package/src/ui/a/Quote/styles.scss +16 -37
- package/src/ui/a/Tooltip/Tooltip.jsx +83 -0
- package/src/ui/a/Tooltip/index.js +2 -0
- package/src/ui/a/Tooltip/styles.scss +53 -0
- package/src/ui/a/index.js +1 -0
- package/src/ui/b/ExpandableLexicalPreview/ExpandableLexicalPreview.jsx +1 -1
- package/src/ui/b/ExpandableLexicalPreview/common/ExpandButton/ExpandButton.jsx +1 -1
- package/src/ui/f/common/Description/styles.scss +1 -2
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +21 -4
- package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/BlockFormatDropDown.jsx +292 -0
- package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/index.js +2 -0
- package/src/ui/f/fields/EditorInput/common/BlockFormatDropDown/styles.scss +55 -0
- package/src/ui/f/fields/EditorInput/common/ColorPicker/ColorPicker.jsx +110 -0
- package/src/ui/f/fields/EditorInput/common/ColorPicker/index.js +2 -0
- package/src/ui/f/fields/EditorInput/common/ColorPicker/styles.scss +36 -0
- package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/FontSizeDropDown.jsx +134 -0
- package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/index.js +2 -0
- package/src/ui/f/fields/EditorInput/common/FontSizeDropDown/styles.scss +55 -0
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/ToolbarPlugin.jsx +431 -0
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/index.js +2 -0
- package/src/ui/f/fields/EditorInput/common/ToolbarPlugin/styles.scss +56 -0
- package/src/ui/f/fields/EditorInput/common/index.js +6 -0
- package/src/ui/f/fields/EditorInput/styles.scss +109 -25
- package/src/ui/f/fields/TextInput/styles.scss +5 -2
- package/src/ui/utils/hooks/index.js +1 -0
- package/src/ui/utils/hooks/useOutsideClick.js +23 -0
- package/src/ui/utils/index.js +1 -1
- package/tests/__snapshots__/Storyshots.test.js.snap +777 -409
- package/tests/mockResizeObserver.js +9 -0
- package/tests/test-setup.js +3 -0
- package/dist/cjs/f/fields/EditorInput/common/Toolbar.js +0 -257
- package/dist/es/f/fields/EditorInput/common/Toolbar.js +0 -246
- package/src/ui/f/fields/EditorInput/common/Toolbar.jsx +0 -356
- package/src/ui/f/fields/EditorInput/common/index.jsx +0 -3
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useState, useRef } from 'react'
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
$createParagraphNode,
|
|
8
|
+
$getSelection,
|
|
9
|
+
$isRangeSelection,
|
|
10
|
+
DEPRECATED_$isGridSelection,
|
|
11
|
+
} from 'lexical'
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
$createHeadingNode,
|
|
15
|
+
$createQuoteNode,
|
|
16
|
+
} from '@lexical/rich-text'
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
$setBlocksType,
|
|
20
|
+
} from '@lexical/selection'
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
INSERT_CHECK_LIST_COMMAND,
|
|
24
|
+
INSERT_ORDERED_LIST_COMMAND,
|
|
25
|
+
INSERT_UNORDERED_LIST_COMMAND,
|
|
26
|
+
REMOVE_LIST_COMMAND,
|
|
27
|
+
} from '@lexical/list'
|
|
28
|
+
|
|
29
|
+
import { $createCodeNode } from '@lexical/code'
|
|
30
|
+
|
|
31
|
+
import PropTypes from 'prop-types'
|
|
32
|
+
|
|
33
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
34
|
+
|
|
35
|
+
import './styles.scss'
|
|
36
|
+
|
|
37
|
+
import { Popover } from 'ui/a'
|
|
38
|
+
|
|
39
|
+
import { useOutsideClick } from 'ui/utils'
|
|
40
|
+
|
|
41
|
+
import { blockTypeToBlockName } from '../ToolbarPlugin/ToolbarPlugin'
|
|
42
|
+
|
|
43
|
+
// Local Definitions
|
|
44
|
+
|
|
45
|
+
const baseClassName = styleNames.base
|
|
46
|
+
|
|
47
|
+
const componentClassName = 'block-format-drop-down'
|
|
48
|
+
|
|
49
|
+
const iconsMap = {
|
|
50
|
+
bullet :{ icon: '.', className: 'icon' },
|
|
51
|
+
check :{ icon: '4', className: 'ai-icon' },
|
|
52
|
+
code :{ icon: '6', className: 'ai-icon' },
|
|
53
|
+
h1 :{ icon: '1', className: 'ai-icon' },
|
|
54
|
+
h2 :{ icon: '2', className: 'ai-icon' },
|
|
55
|
+
h3 :{ icon: '3', className: 'ai-icon' },
|
|
56
|
+
number :{ icon: '-', className: 'icon' },
|
|
57
|
+
paragraph:{ icon: 'N', className: 'ai-icon' },
|
|
58
|
+
quote :{ icon: '5', className: 'ai-icon' },
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* This is the component description.
|
|
63
|
+
*/
|
|
64
|
+
const BlockFormatDropDown = ({
|
|
65
|
+
id,
|
|
66
|
+
className:userClassName,
|
|
67
|
+
style,
|
|
68
|
+
editor,
|
|
69
|
+
blockType,
|
|
70
|
+
// ...otherProps
|
|
71
|
+
}) => {
|
|
72
|
+
const formatParagraph = () => {
|
|
73
|
+
editor.update(() => {
|
|
74
|
+
const selection = $getSelection()
|
|
75
|
+
if (
|
|
76
|
+
$isRangeSelection(selection)
|
|
77
|
+
|| DEPRECATED_$isGridSelection(selection)
|
|
78
|
+
) {
|
|
79
|
+
$setBlocksType(selection, () => $createParagraphNode())
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const formatHeading = (headingSize) => {
|
|
85
|
+
if (blockType !== headingSize) {
|
|
86
|
+
editor.update(() => {
|
|
87
|
+
const selection = $getSelection()
|
|
88
|
+
if (
|
|
89
|
+
$isRangeSelection(selection)
|
|
90
|
+
|| DEPRECATED_$isGridSelection(selection)
|
|
91
|
+
) {
|
|
92
|
+
$setBlocksType(selection, () => $createHeadingNode(headingSize))
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const formatBulletList = () => {
|
|
99
|
+
if (blockType !== 'bullet') {
|
|
100
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined)
|
|
101
|
+
} else {
|
|
102
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const formatCheckList = () => {
|
|
107
|
+
if (blockType !== 'check') {
|
|
108
|
+
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined)
|
|
109
|
+
} else {
|
|
110
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const formatNumberedList = () => {
|
|
115
|
+
if (blockType !== 'number') {
|
|
116
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined)
|
|
117
|
+
} else {
|
|
118
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const formatQuote = () => {
|
|
123
|
+
if (blockType !== 'quote') {
|
|
124
|
+
editor.update(() => {
|
|
125
|
+
const selection = $getSelection()
|
|
126
|
+
if (
|
|
127
|
+
$isRangeSelection(selection)
|
|
128
|
+
|| DEPRECATED_$isGridSelection(selection)
|
|
129
|
+
) {
|
|
130
|
+
$setBlocksType(selection, () => $createQuoteNode())
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const formatCode = () => {
|
|
137
|
+
if (blockType !== 'code') {
|
|
138
|
+
editor.update(() => {
|
|
139
|
+
let selection = $getSelection()
|
|
140
|
+
|
|
141
|
+
if (
|
|
142
|
+
$isRangeSelection(selection)
|
|
143
|
+
|| DEPRECATED_$isGridSelection(selection)
|
|
144
|
+
) {
|
|
145
|
+
if (selection.isCollapsed()) {
|
|
146
|
+
$setBlocksType(selection, () => $createCodeNode())
|
|
147
|
+
} else {
|
|
148
|
+
const textContent = selection.getTextContent()
|
|
149
|
+
const codeNode = $createCodeNode()
|
|
150
|
+
selection.insertNodes([codeNode])
|
|
151
|
+
selection = $getSelection()
|
|
152
|
+
if ($isRangeSelection(selection)) selection.insertRawText(textContent)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const parentRef = useRef(null)
|
|
160
|
+
|
|
161
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
162
|
+
|
|
163
|
+
useOutsideClick(parentRef, () => setIsOpen(false))
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<button
|
|
167
|
+
id={id}
|
|
168
|
+
className={[
|
|
169
|
+
baseClassName,
|
|
170
|
+
componentClassName,
|
|
171
|
+
userClassName,
|
|
172
|
+
'group',
|
|
173
|
+
]
|
|
174
|
+
.filter((e) => e)
|
|
175
|
+
.join(' ')}
|
|
176
|
+
style={style}
|
|
177
|
+
ref={parentRef}
|
|
178
|
+
type="button"
|
|
179
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
180
|
+
// {...otherProps}
|
|
181
|
+
>
|
|
182
|
+
<span className={iconsMap[blockType].className}>
|
|
183
|
+
{iconsMap[blockType].icon}
|
|
184
|
+
</span>
|
|
185
|
+
<span>{blockTypeToBlockName[blockType]}</span>
|
|
186
|
+
<span className="icon">V</span>
|
|
187
|
+
{isOpen && (
|
|
188
|
+
<Popover
|
|
189
|
+
parentRef={parentRef}
|
|
190
|
+
isOpen={isOpen}
|
|
191
|
+
color="background-far"
|
|
192
|
+
>
|
|
193
|
+
<button
|
|
194
|
+
className={`item ${blockType === 'paragraph' ? 'active' : ''}`}
|
|
195
|
+
onClick={formatParagraph}
|
|
196
|
+
type="button"
|
|
197
|
+
>
|
|
198
|
+
<span className="ai-icon">N</span>
|
|
199
|
+
<span className="text">Normal</span>
|
|
200
|
+
</button>
|
|
201
|
+
<button
|
|
202
|
+
className={`item ${blockType === 'h1' ? 'active' : ''}`}
|
|
203
|
+
onClick={() => formatHeading('h1')}
|
|
204
|
+
type="button"
|
|
205
|
+
>
|
|
206
|
+
<span className="ai-icon">1</span>
|
|
207
|
+
<span className="text">Heading 1</span>
|
|
208
|
+
</button>
|
|
209
|
+
<button
|
|
210
|
+
className={`item ${blockType === 'h2' ? 'active' : ''}`}
|
|
211
|
+
onClick={() => formatHeading('h2')}
|
|
212
|
+
type="button"
|
|
213
|
+
>
|
|
214
|
+
<span className="ai-icon">2</span>
|
|
215
|
+
<span className="text">Heading 2</span>
|
|
216
|
+
</button>
|
|
217
|
+
<button
|
|
218
|
+
className={`item ${blockType === 'h3' ? 'active' : ''}`}
|
|
219
|
+
onClick={() => formatHeading('h3')}
|
|
220
|
+
type="button"
|
|
221
|
+
>
|
|
222
|
+
<span className="ai-icon">3</span>
|
|
223
|
+
<span className="text">Heading 3</span>
|
|
224
|
+
</button>
|
|
225
|
+
<button
|
|
226
|
+
className={`item ${blockType === 'bullet' ? 'active' : ''}`}
|
|
227
|
+
onClick={formatBulletList}
|
|
228
|
+
type="button"
|
|
229
|
+
>
|
|
230
|
+
<span className="icon">.</span>
|
|
231
|
+
<span className="text">Bullet List</span>
|
|
232
|
+
</button>
|
|
233
|
+
<button
|
|
234
|
+
className={`item ${blockType === 'number' ? 'active' : ''}`}
|
|
235
|
+
onClick={formatNumberedList}
|
|
236
|
+
type="button"
|
|
237
|
+
>
|
|
238
|
+
<span className="icon">-</span>
|
|
239
|
+
<span className="text">Numbered List</span>
|
|
240
|
+
</button>
|
|
241
|
+
<button
|
|
242
|
+
className={`item ${blockType === 'check' ? 'active' : ''}`}
|
|
243
|
+
onClick={formatCheckList}
|
|
244
|
+
type="button"
|
|
245
|
+
>
|
|
246
|
+
<span className="ai-icon">4</span>
|
|
247
|
+
<span className="text">Check List</span>
|
|
248
|
+
</button>
|
|
249
|
+
<button
|
|
250
|
+
className={`item ${blockType === 'quote' ? 'active' : ''}`}
|
|
251
|
+
onClick={formatQuote}
|
|
252
|
+
type="button"
|
|
253
|
+
>
|
|
254
|
+
<span className="ai-icon">5</span>
|
|
255
|
+
<span className="text">Quote</span>
|
|
256
|
+
</button>
|
|
257
|
+
<button
|
|
258
|
+
className={`item ${blockType === 'code' ? 'active' : ''}`}
|
|
259
|
+
onClick={formatCode}
|
|
260
|
+
type="button"
|
|
261
|
+
>
|
|
262
|
+
<span className="ai-icon">6</span>
|
|
263
|
+
<span className="text">Code Block</span>
|
|
264
|
+
</button>
|
|
265
|
+
</Popover>
|
|
266
|
+
)}
|
|
267
|
+
</button>
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
BlockFormatDropDown.propTypes = {
|
|
272
|
+
/**
|
|
273
|
+
* The HTML id for this element
|
|
274
|
+
*/
|
|
275
|
+
id:PropTypes.string,
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The HTML class names for this element
|
|
279
|
+
*/
|
|
280
|
+
className:PropTypes.string,
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* The React-written, css properties for this element.
|
|
284
|
+
*/
|
|
285
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
BlockFormatDropDown.defaultProps = {
|
|
289
|
+
// someProp:false
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
export default BlockFormatDropDown
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-width: 15em;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.block-format-drop-down {
|
|
8
|
+
align-items: center;
|
|
9
|
+
background-color: var(--x);
|
|
10
|
+
border: 0;
|
|
11
|
+
color: var(--on-background-inputs);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: calc(var(--gap) / 2);
|
|
15
|
+
margin-inline: calc(var(--theme-default-padding) / 4);
|
|
16
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
&:hover {
|
|
20
|
+
background: var(--hard-x);
|
|
21
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
> .#{bem.$base}.popover {
|
|
25
|
+
background-color: var(--background-far);
|
|
26
|
+
border: 1px solid var(--hard-background-cards);
|
|
27
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
28
|
+
color: var(--heading);
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
32
|
+
width: $default-width;
|
|
33
|
+
|
|
34
|
+
> .item {
|
|
35
|
+
align-items: center;
|
|
36
|
+
background-color: var(--x);
|
|
37
|
+
border: 0;
|
|
38
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
39
|
+
color: var(--paragraph);
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
display: flex;
|
|
42
|
+
gap: calc(var(--gap) / 2);
|
|
43
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
44
|
+
transition: all .2s;
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
background-color: var(--hard-x);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.active {
|
|
51
|
+
background-color: var(--hard-ui-main);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useRef, useEffect, useState } from 'react'
|
|
5
|
+
|
|
6
|
+
import { ColorPicker as ReactColorPicker, useColor } from 'react-color-palette'
|
|
7
|
+
|
|
8
|
+
import PropTypes from 'prop-types'
|
|
9
|
+
|
|
10
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
11
|
+
|
|
12
|
+
import './styles.scss'
|
|
13
|
+
|
|
14
|
+
import { Popover } from 'ui/a'
|
|
15
|
+
|
|
16
|
+
import { useOutsideClick } from 'ui/utils'
|
|
17
|
+
// Local Definitions
|
|
18
|
+
|
|
19
|
+
const baseClassName = styleNames.base
|
|
20
|
+
|
|
21
|
+
const componentClassName = 'color-picker'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This is the component description.
|
|
25
|
+
*/
|
|
26
|
+
const ColorPicker = ({
|
|
27
|
+
id,
|
|
28
|
+
className:userClassName,
|
|
29
|
+
style,
|
|
30
|
+
icon,
|
|
31
|
+
color,
|
|
32
|
+
onChange,
|
|
33
|
+
// ...otherProps
|
|
34
|
+
}) => {
|
|
35
|
+
const [colorValue, setColor] = useColor(color)
|
|
36
|
+
|
|
37
|
+
const parentRef = useRef(null)
|
|
38
|
+
|
|
39
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
40
|
+
|
|
41
|
+
useOutsideClick(parentRef, () => setIsOpen(false))
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
const { hex } = colorValue
|
|
45
|
+
if (hex) {
|
|
46
|
+
onChange(hex)
|
|
47
|
+
}
|
|
48
|
+
}, [colorValue])
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
52
|
+
<div
|
|
53
|
+
id={id}
|
|
54
|
+
className={[
|
|
55
|
+
|
|
56
|
+
baseClassName,
|
|
57
|
+
|
|
58
|
+
componentClassName,
|
|
59
|
+
userClassName,
|
|
60
|
+
]
|
|
61
|
+
.filter((e) => e)
|
|
62
|
+
.join(' ')}
|
|
63
|
+
style={style}
|
|
64
|
+
ref={parentRef}
|
|
65
|
+
// {...otherProps}
|
|
66
|
+
>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
70
|
+
>
|
|
71
|
+
<span className="icon">{icon}</span>
|
|
72
|
+
<span className="icon">V</span>
|
|
73
|
+
</button>
|
|
74
|
+
<Popover
|
|
75
|
+
parentRef={parentRef}
|
|
76
|
+
isOpen={isOpen}
|
|
77
|
+
color="background-far"
|
|
78
|
+
>
|
|
79
|
+
<ReactColorPicker
|
|
80
|
+
color={colorValue}
|
|
81
|
+
onChange={setColor}
|
|
82
|
+
hideInput
|
|
83
|
+
/>
|
|
84
|
+
</Popover>
|
|
85
|
+
</div>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
ColorPicker.propTypes = {
|
|
90
|
+
/**
|
|
91
|
+
* The HTML id for this element
|
|
92
|
+
*/
|
|
93
|
+
id:PropTypes.string,
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* The HTML class names for this element
|
|
97
|
+
*/
|
|
98
|
+
className:PropTypes.string,
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The React-written, css properties for this element.
|
|
102
|
+
*/
|
|
103
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ColorPicker.defaultProps = {
|
|
107
|
+
// someProp:false
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export default ColorPicker
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
@use "react-color-palette/css";
|
|
5
|
+
|
|
6
|
+
$default-width: 20rem;
|
|
7
|
+
|
|
8
|
+
.#{bem.$base}.color-picker {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
> button {
|
|
13
|
+
align-items: center;
|
|
14
|
+
background-color: var(--x);
|
|
15
|
+
border: 0;
|
|
16
|
+
color: var(--on-background-inputs);
|
|
17
|
+
display: flex;
|
|
18
|
+
gap: calc(var(--gap) / 2);
|
|
19
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
20
|
+
|
|
21
|
+
&:hover {
|
|
22
|
+
background: var(--hard-x);
|
|
23
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
> .#{bem.$base}.popover {
|
|
29
|
+
background-color: var(--background-far);
|
|
30
|
+
border: 1px solid var(--hard-background-cards);
|
|
31
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
32
|
+
color: var(--heading);
|
|
33
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
34
|
+
width: $default-width;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react'
|
|
3
|
+
|
|
4
|
+
import { useState, useRef, useCallback } from 'react'
|
|
5
|
+
|
|
6
|
+
import { $getSelection, $isRangeSelection } from 'lexical'
|
|
7
|
+
|
|
8
|
+
import { $patchStyleText } from '@lexical/selection'
|
|
9
|
+
|
|
10
|
+
import PropTypes from 'prop-types'
|
|
11
|
+
|
|
12
|
+
import styleNames from '@pareto-engineering/bem/exports'
|
|
13
|
+
|
|
14
|
+
import './styles.scss'
|
|
15
|
+
|
|
16
|
+
import { Popover } from 'ui/a'
|
|
17
|
+
|
|
18
|
+
import { useOutsideClick } from 'ui/utils'
|
|
19
|
+
|
|
20
|
+
// Local Definitions
|
|
21
|
+
|
|
22
|
+
const baseClassName = styleNames.base
|
|
23
|
+
|
|
24
|
+
const componentClassName = 'font-size-drop-down'
|
|
25
|
+
|
|
26
|
+
const FONT_SIZE_OPTIONS = [
|
|
27
|
+
['10px', '10px'],
|
|
28
|
+
['11px', '11px'],
|
|
29
|
+
['12px', '12px'],
|
|
30
|
+
['13px', '13px'],
|
|
31
|
+
['14px', '14px'],
|
|
32
|
+
['15px', '15px'],
|
|
33
|
+
['16px', '16px'],
|
|
34
|
+
['17px', '17px'],
|
|
35
|
+
['18px', '18px'],
|
|
36
|
+
['19px', '19px'],
|
|
37
|
+
['20px', '20px'],
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* This is the component description.
|
|
42
|
+
*/
|
|
43
|
+
const FontSizeDropDown = ({
|
|
44
|
+
id,
|
|
45
|
+
className:userClassName,
|
|
46
|
+
style,
|
|
47
|
+
editor,
|
|
48
|
+
value,
|
|
49
|
+
// ...otherProps
|
|
50
|
+
}) => {
|
|
51
|
+
const parentRef = useRef(null)
|
|
52
|
+
|
|
53
|
+
const [isOpen, setIsOpen] = useState(false)
|
|
54
|
+
|
|
55
|
+
useOutsideClick(parentRef, () => setIsOpen(false))
|
|
56
|
+
|
|
57
|
+
const handleClick = useCallback(
|
|
58
|
+
(option) => {
|
|
59
|
+
editor.update(() => {
|
|
60
|
+
const selection = $getSelection()
|
|
61
|
+
if ($isRangeSelection(selection)) {
|
|
62
|
+
$patchStyleText(selection, {
|
|
63
|
+
'font-size':option,
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
},
|
|
68
|
+
[editor],
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<button
|
|
73
|
+
id={id}
|
|
74
|
+
className={[
|
|
75
|
+
baseClassName,
|
|
76
|
+
componentClassName,
|
|
77
|
+
userClassName,
|
|
78
|
+
'group',
|
|
79
|
+
]
|
|
80
|
+
.filter((e) => e)
|
|
81
|
+
.join(' ')}
|
|
82
|
+
style={style}
|
|
83
|
+
ref={parentRef}
|
|
84
|
+
type="button"
|
|
85
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
86
|
+
// {...otherProps}
|
|
87
|
+
>
|
|
88
|
+
<span>{value}</span>
|
|
89
|
+
<span className="icon">
|
|
90
|
+
V
|
|
91
|
+
</span>
|
|
92
|
+
{isOpen && (
|
|
93
|
+
<Popover
|
|
94
|
+
parentRef={parentRef}
|
|
95
|
+
isOpen={isOpen}
|
|
96
|
+
color="background-far"
|
|
97
|
+
>
|
|
98
|
+
{FONT_SIZE_OPTIONS.map(([option, text]) => (
|
|
99
|
+
<button
|
|
100
|
+
className={`item ${value === option ? 'active' : ''}`}
|
|
101
|
+
onClick={() => handleClick(option)}
|
|
102
|
+
type="button"
|
|
103
|
+
>
|
|
104
|
+
<span className="text">{text}</span>
|
|
105
|
+
</button>
|
|
106
|
+
))}
|
|
107
|
+
</Popover>
|
|
108
|
+
)}
|
|
109
|
+
</button>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
FontSizeDropDown.propTypes = {
|
|
114
|
+
/**
|
|
115
|
+
* The HTML id for this element
|
|
116
|
+
*/
|
|
117
|
+
id:PropTypes.string,
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* The HTML class names for this element
|
|
121
|
+
*/
|
|
122
|
+
className:PropTypes.string,
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* The React-written, css properties for this element.
|
|
126
|
+
*/
|
|
127
|
+
style:PropTypes.objectOf(PropTypes.string),
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
FontSizeDropDown.defaultProps = {
|
|
131
|
+
// someProp:false
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export default FontSizeDropDown
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
|
|
3
|
+
@use "@pareto-engineering/bem";
|
|
4
|
+
|
|
5
|
+
$default-width: 4.5rem;
|
|
6
|
+
|
|
7
|
+
.#{bem.$base}.font-size-drop-down {
|
|
8
|
+
align-items: center;
|
|
9
|
+
background-color: var(--x);
|
|
10
|
+
border: 0;
|
|
11
|
+
color: var(--on-background-inputs);
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
display: flex;
|
|
14
|
+
gap: calc(var(--gap) / 2);
|
|
15
|
+
margin-inline: calc(var(--theme-default-padding) / 4);
|
|
16
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
17
|
+
position: relative;
|
|
18
|
+
|
|
19
|
+
&:hover {
|
|
20
|
+
background: var(--hard-x);
|
|
21
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
> .#{bem.$base}.popover {
|
|
25
|
+
background-color: var(--background-far);
|
|
26
|
+
border: 1px solid var(--hard-background-cards);
|
|
27
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
28
|
+
color: var(--heading);
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
32
|
+
width: $default-width;
|
|
33
|
+
|
|
34
|
+
> .item {
|
|
35
|
+
align-items: center;
|
|
36
|
+
background-color: var(--x);
|
|
37
|
+
border: 0;
|
|
38
|
+
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
39
|
+
color: var(--paragraph);
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
display: flex;
|
|
42
|
+
gap: calc(var(--gap) / 2);
|
|
43
|
+
padding: calc(var(--theme-default-padding) / 2);
|
|
44
|
+
transition: all .2s;
|
|
45
|
+
|
|
46
|
+
&:hover {
|
|
47
|
+
background-color: var(--hard-x);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.active {
|
|
51
|
+
background-color: var(--hard-ui-main);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|