@pareto-engineering/design-system 4.0.0-alpha.77 → 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/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/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/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/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/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/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 +746 -378
- 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,246 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useState, useRef } from 'react';
|
|
4
|
+
import { $createParagraphNode, $getSelection, $isRangeSelection, DEPRECATED_$isGridSelection } from 'lexical';
|
|
5
|
+
import { $createHeadingNode, $createQuoteNode } from '@lexical/rich-text';
|
|
6
|
+
import { $setBlocksType } from '@lexical/selection';
|
|
7
|
+
import { INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND } from '@lexical/list';
|
|
8
|
+
import { $createCodeNode } from '@lexical/code';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
11
|
+
import "./styles.scss";
|
|
12
|
+
import { Popover } from "../../../../../a";
|
|
13
|
+
import { useOutsideClick } from "../../../../../utils";
|
|
14
|
+
import { blockTypeToBlockName } from "../ToolbarPlugin/ToolbarPlugin";
|
|
15
|
+
|
|
16
|
+
// Local Definitions
|
|
17
|
+
|
|
18
|
+
const baseClassName = styleNames.base;
|
|
19
|
+
const componentClassName = 'block-format-drop-down';
|
|
20
|
+
const iconsMap = {
|
|
21
|
+
bullet: {
|
|
22
|
+
icon: '.',
|
|
23
|
+
className: 'icon'
|
|
24
|
+
},
|
|
25
|
+
check: {
|
|
26
|
+
icon: '4',
|
|
27
|
+
className: 'ai-icon'
|
|
28
|
+
},
|
|
29
|
+
code: {
|
|
30
|
+
icon: '6',
|
|
31
|
+
className: 'ai-icon'
|
|
32
|
+
},
|
|
33
|
+
h1: {
|
|
34
|
+
icon: '1',
|
|
35
|
+
className: 'ai-icon'
|
|
36
|
+
},
|
|
37
|
+
h2: {
|
|
38
|
+
icon: '2',
|
|
39
|
+
className: 'ai-icon'
|
|
40
|
+
},
|
|
41
|
+
h3: {
|
|
42
|
+
icon: '3',
|
|
43
|
+
className: 'ai-icon'
|
|
44
|
+
},
|
|
45
|
+
number: {
|
|
46
|
+
icon: '-',
|
|
47
|
+
className: 'icon'
|
|
48
|
+
},
|
|
49
|
+
paragraph: {
|
|
50
|
+
icon: 'N',
|
|
51
|
+
className: 'ai-icon'
|
|
52
|
+
},
|
|
53
|
+
quote: {
|
|
54
|
+
icon: '5',
|
|
55
|
+
className: 'ai-icon'
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* This is the component description.
|
|
60
|
+
*/
|
|
61
|
+
const BlockFormatDropDown = ({
|
|
62
|
+
id,
|
|
63
|
+
className: userClassName,
|
|
64
|
+
style,
|
|
65
|
+
editor,
|
|
66
|
+
blockType
|
|
67
|
+
// ...otherProps
|
|
68
|
+
}) => {
|
|
69
|
+
const formatParagraph = () => {
|
|
70
|
+
editor.update(() => {
|
|
71
|
+
const selection = $getSelection();
|
|
72
|
+
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
73
|
+
$setBlocksType(selection, () => $createParagraphNode());
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const formatHeading = headingSize => {
|
|
78
|
+
if (blockType !== headingSize) {
|
|
79
|
+
editor.update(() => {
|
|
80
|
+
const selection = $getSelection();
|
|
81
|
+
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
82
|
+
$setBlocksType(selection, () => $createHeadingNode(headingSize));
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const formatBulletList = () => {
|
|
88
|
+
if (blockType !== 'bullet') {
|
|
89
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
90
|
+
} else {
|
|
91
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
const formatCheckList = () => {
|
|
95
|
+
if (blockType !== 'check') {
|
|
96
|
+
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined);
|
|
97
|
+
} else {
|
|
98
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const formatNumberedList = () => {
|
|
102
|
+
if (blockType !== 'number') {
|
|
103
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
104
|
+
} else {
|
|
105
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const formatQuote = () => {
|
|
109
|
+
if (blockType !== 'quote') {
|
|
110
|
+
editor.update(() => {
|
|
111
|
+
const selection = $getSelection();
|
|
112
|
+
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
113
|
+
$setBlocksType(selection, () => $createQuoteNode());
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const formatCode = () => {
|
|
119
|
+
if (blockType !== 'code') {
|
|
120
|
+
editor.update(() => {
|
|
121
|
+
let selection = $getSelection();
|
|
122
|
+
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
123
|
+
if (selection.isCollapsed()) {
|
|
124
|
+
$setBlocksType(selection, () => $createCodeNode());
|
|
125
|
+
} else {
|
|
126
|
+
const textContent = selection.getTextContent();
|
|
127
|
+
const codeNode = $createCodeNode();
|
|
128
|
+
selection.insertNodes([codeNode]);
|
|
129
|
+
selection = $getSelection();
|
|
130
|
+
if ($isRangeSelection(selection)) selection.insertRawText(textContent);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
const parentRef = useRef(null);
|
|
137
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
138
|
+
useOutsideClick(parentRef, () => setIsOpen(false));
|
|
139
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
140
|
+
id: id,
|
|
141
|
+
className: [baseClassName, componentClassName, userClassName, 'group'].filter(e => e).join(' '),
|
|
142
|
+
style: style,
|
|
143
|
+
ref: parentRef,
|
|
144
|
+
type: "button",
|
|
145
|
+
onClick: () => setIsOpen(!isOpen)
|
|
146
|
+
// {...otherProps}
|
|
147
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
148
|
+
className: iconsMap[blockType].className
|
|
149
|
+
}, iconsMap[blockType].icon), /*#__PURE__*/React.createElement("span", null, blockTypeToBlockName[blockType]), /*#__PURE__*/React.createElement("span", {
|
|
150
|
+
className: "icon"
|
|
151
|
+
}, "V"), isOpen && /*#__PURE__*/React.createElement(Popover, {
|
|
152
|
+
parentRef: parentRef,
|
|
153
|
+
isOpen: isOpen,
|
|
154
|
+
color: "background-far"
|
|
155
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
156
|
+
className: `item ${blockType === 'paragraph' ? 'active' : ''}`,
|
|
157
|
+
onClick: formatParagraph,
|
|
158
|
+
type: "button"
|
|
159
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
160
|
+
className: "ai-icon"
|
|
161
|
+
}, "N"), /*#__PURE__*/React.createElement("span", {
|
|
162
|
+
className: "text"
|
|
163
|
+
}, "Normal")), /*#__PURE__*/React.createElement("button", {
|
|
164
|
+
className: `item ${blockType === 'h1' ? 'active' : ''}`,
|
|
165
|
+
onClick: () => formatHeading('h1'),
|
|
166
|
+
type: "button"
|
|
167
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
168
|
+
className: "ai-icon"
|
|
169
|
+
}, "1"), /*#__PURE__*/React.createElement("span", {
|
|
170
|
+
className: "text"
|
|
171
|
+
}, "Heading 1")), /*#__PURE__*/React.createElement("button", {
|
|
172
|
+
className: `item ${blockType === 'h2' ? 'active' : ''}`,
|
|
173
|
+
onClick: () => formatHeading('h2'),
|
|
174
|
+
type: "button"
|
|
175
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
176
|
+
className: "ai-icon"
|
|
177
|
+
}, "2"), /*#__PURE__*/React.createElement("span", {
|
|
178
|
+
className: "text"
|
|
179
|
+
}, "Heading 2")), /*#__PURE__*/React.createElement("button", {
|
|
180
|
+
className: `item ${blockType === 'h3' ? 'active' : ''}`,
|
|
181
|
+
onClick: () => formatHeading('h3'),
|
|
182
|
+
type: "button"
|
|
183
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
184
|
+
className: "ai-icon"
|
|
185
|
+
}, "3"), /*#__PURE__*/React.createElement("span", {
|
|
186
|
+
className: "text"
|
|
187
|
+
}, "Heading 3")), /*#__PURE__*/React.createElement("button", {
|
|
188
|
+
className: `item ${blockType === 'bullet' ? 'active' : ''}`,
|
|
189
|
+
onClick: formatBulletList,
|
|
190
|
+
type: "button"
|
|
191
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
192
|
+
className: "icon"
|
|
193
|
+
}, "."), /*#__PURE__*/React.createElement("span", {
|
|
194
|
+
className: "text"
|
|
195
|
+
}, "Bullet List")), /*#__PURE__*/React.createElement("button", {
|
|
196
|
+
className: `item ${blockType === 'number' ? 'active' : ''}`,
|
|
197
|
+
onClick: formatNumberedList,
|
|
198
|
+
type: "button"
|
|
199
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
200
|
+
className: "icon"
|
|
201
|
+
}, "-"), /*#__PURE__*/React.createElement("span", {
|
|
202
|
+
className: "text"
|
|
203
|
+
}, "Numbered List")), /*#__PURE__*/React.createElement("button", {
|
|
204
|
+
className: `item ${blockType === 'check' ? 'active' : ''}`,
|
|
205
|
+
onClick: formatCheckList,
|
|
206
|
+
type: "button"
|
|
207
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
208
|
+
className: "ai-icon"
|
|
209
|
+
}, "4"), /*#__PURE__*/React.createElement("span", {
|
|
210
|
+
className: "text"
|
|
211
|
+
}, "Check List")), /*#__PURE__*/React.createElement("button", {
|
|
212
|
+
className: `item ${blockType === 'quote' ? 'active' : ''}`,
|
|
213
|
+
onClick: formatQuote,
|
|
214
|
+
type: "button"
|
|
215
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
216
|
+
className: "ai-icon"
|
|
217
|
+
}, "5"), /*#__PURE__*/React.createElement("span", {
|
|
218
|
+
className: "text"
|
|
219
|
+
}, "Quote")), /*#__PURE__*/React.createElement("button", {
|
|
220
|
+
className: `item ${blockType === 'code' ? 'active' : ''}`,
|
|
221
|
+
onClick: formatCode,
|
|
222
|
+
type: "button"
|
|
223
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
224
|
+
className: "ai-icon"
|
|
225
|
+
}, "6"), /*#__PURE__*/React.createElement("span", {
|
|
226
|
+
className: "text"
|
|
227
|
+
}, "Code Block"))));
|
|
228
|
+
};
|
|
229
|
+
BlockFormatDropDown.propTypes = {
|
|
230
|
+
/**
|
|
231
|
+
* The HTML id for this element
|
|
232
|
+
*/
|
|
233
|
+
id: PropTypes.string,
|
|
234
|
+
/**
|
|
235
|
+
* The HTML class names for this element
|
|
236
|
+
*/
|
|
237
|
+
className: PropTypes.string,
|
|
238
|
+
/**
|
|
239
|
+
* The React-written, css properties for this element.
|
|
240
|
+
*/
|
|
241
|
+
style: PropTypes.objectOf(PropTypes.string)
|
|
242
|
+
};
|
|
243
|
+
BlockFormatDropDown.defaultProps = {
|
|
244
|
+
// someProp:false
|
|
245
|
+
};
|
|
246
|
+
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,83 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useRef, useEffect, useState } from 'react';
|
|
4
|
+
import { ColorPicker as ReactColorPicker, useColor } from 'react-color-palette';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
7
|
+
import "./styles.scss";
|
|
8
|
+
import { Popover } from "../../../../../a";
|
|
9
|
+
import { useOutsideClick } from "../../../../../utils";
|
|
10
|
+
// Local Definitions
|
|
11
|
+
|
|
12
|
+
const baseClassName = styleNames.base;
|
|
13
|
+
const componentClassName = 'color-picker';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This is the component description.
|
|
17
|
+
*/
|
|
18
|
+
const ColorPicker = ({
|
|
19
|
+
id,
|
|
20
|
+
className: userClassName,
|
|
21
|
+
style,
|
|
22
|
+
icon,
|
|
23
|
+
color,
|
|
24
|
+
onChange
|
|
25
|
+
// ...otherProps
|
|
26
|
+
}) => {
|
|
27
|
+
const [colorValue, setColor] = useColor(color);
|
|
28
|
+
const parentRef = useRef(null);
|
|
29
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
30
|
+
useOutsideClick(parentRef, () => setIsOpen(false));
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const {
|
|
33
|
+
hex
|
|
34
|
+
} = colorValue;
|
|
35
|
+
if (hex) {
|
|
36
|
+
onChange(hex);
|
|
37
|
+
}
|
|
38
|
+
}, [colorValue]);
|
|
39
|
+
return (
|
|
40
|
+
/*#__PURE__*/
|
|
41
|
+
// eslint-disable-next-line jsx-a11y/control-has-associated-label
|
|
42
|
+
React.createElement("div", {
|
|
43
|
+
id: id,
|
|
44
|
+
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
45
|
+
style: style,
|
|
46
|
+
ref: parentRef
|
|
47
|
+
// {...otherProps}
|
|
48
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
49
|
+
type: "button",
|
|
50
|
+
onClick: () => setIsOpen(!isOpen)
|
|
51
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
className: "icon"
|
|
53
|
+
}, icon), /*#__PURE__*/React.createElement("span", {
|
|
54
|
+
className: "icon"
|
|
55
|
+
}, "V")), /*#__PURE__*/React.createElement(Popover, {
|
|
56
|
+
parentRef: parentRef,
|
|
57
|
+
isOpen: isOpen,
|
|
58
|
+
color: "background-far"
|
|
59
|
+
}, /*#__PURE__*/React.createElement(ReactColorPicker, {
|
|
60
|
+
color: colorValue,
|
|
61
|
+
onChange: setColor,
|
|
62
|
+
hideInput: true
|
|
63
|
+
})))
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
ColorPicker.propTypes = {
|
|
67
|
+
/**
|
|
68
|
+
* The HTML id for this element
|
|
69
|
+
*/
|
|
70
|
+
id: PropTypes.string,
|
|
71
|
+
/**
|
|
72
|
+
* The HTML class names for this element
|
|
73
|
+
*/
|
|
74
|
+
className: PropTypes.string,
|
|
75
|
+
/**
|
|
76
|
+
* The React-written, css properties for this element.
|
|
77
|
+
*/
|
|
78
|
+
style: PropTypes.objectOf(PropTypes.string)
|
|
79
|
+
};
|
|
80
|
+
ColorPicker.defaultProps = {
|
|
81
|
+
// someProp:false
|
|
82
|
+
};
|
|
83
|
+
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,81 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { useState, useRef, useCallback } from 'react';
|
|
4
|
+
import { $getSelection, $isRangeSelection } from 'lexical';
|
|
5
|
+
import { $patchStyleText } from '@lexical/selection';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import styleNames from '@pareto-engineering/bem/exports';
|
|
8
|
+
import "./styles.scss";
|
|
9
|
+
import { Popover } from "../../../../../a";
|
|
10
|
+
import { useOutsideClick } from "../../../../../utils";
|
|
11
|
+
|
|
12
|
+
// Local Definitions
|
|
13
|
+
|
|
14
|
+
const baseClassName = styleNames.base;
|
|
15
|
+
const componentClassName = 'font-size-drop-down';
|
|
16
|
+
const FONT_SIZE_OPTIONS = [['10px', '10px'], ['11px', '11px'], ['12px', '12px'], ['13px', '13px'], ['14px', '14px'], ['15px', '15px'], ['16px', '16px'], ['17px', '17px'], ['18px', '18px'], ['19px', '19px'], ['20px', '20px']];
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This is the component description.
|
|
20
|
+
*/
|
|
21
|
+
const FontSizeDropDown = ({
|
|
22
|
+
id,
|
|
23
|
+
className: userClassName,
|
|
24
|
+
style,
|
|
25
|
+
editor,
|
|
26
|
+
value
|
|
27
|
+
// ...otherProps
|
|
28
|
+
}) => {
|
|
29
|
+
const parentRef = useRef(null);
|
|
30
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
31
|
+
useOutsideClick(parentRef, () => setIsOpen(false));
|
|
32
|
+
const handleClick = useCallback(option => {
|
|
33
|
+
editor.update(() => {
|
|
34
|
+
const selection = $getSelection();
|
|
35
|
+
if ($isRangeSelection(selection)) {
|
|
36
|
+
$patchStyleText(selection, {
|
|
37
|
+
'font-size': option
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}, [editor]);
|
|
42
|
+
return /*#__PURE__*/React.createElement("button", {
|
|
43
|
+
id: id,
|
|
44
|
+
className: [baseClassName, componentClassName, userClassName, 'group'].filter(e => e).join(' '),
|
|
45
|
+
style: style,
|
|
46
|
+
ref: parentRef,
|
|
47
|
+
type: "button",
|
|
48
|
+
onClick: () => setIsOpen(!isOpen)
|
|
49
|
+
// {...otherProps}
|
|
50
|
+
}, /*#__PURE__*/React.createElement("span", null, value), /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
className: "icon"
|
|
52
|
+
}, "V"), isOpen && /*#__PURE__*/React.createElement(Popover, {
|
|
53
|
+
parentRef: parentRef,
|
|
54
|
+
isOpen: isOpen,
|
|
55
|
+
color: "background-far"
|
|
56
|
+
}, FONT_SIZE_OPTIONS.map(([option, text]) => /*#__PURE__*/React.createElement("button", {
|
|
57
|
+
className: `item ${value === option ? 'active' : ''}`,
|
|
58
|
+
onClick: () => handleClick(option),
|
|
59
|
+
type: "button"
|
|
60
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
61
|
+
className: "text"
|
|
62
|
+
}, text)))));
|
|
63
|
+
};
|
|
64
|
+
FontSizeDropDown.propTypes = {
|
|
65
|
+
/**
|
|
66
|
+
* The HTML id for this element
|
|
67
|
+
*/
|
|
68
|
+
id: PropTypes.string,
|
|
69
|
+
/**
|
|
70
|
+
* The HTML class names for this element
|
|
71
|
+
*/
|
|
72
|
+
className: PropTypes.string,
|
|
73
|
+
/**
|
|
74
|
+
* The React-written, css properties for this element.
|
|
75
|
+
*/
|
|
76
|
+
style: PropTypes.objectOf(PropTypes.string)
|
|
77
|
+
};
|
|
78
|
+
FontSizeDropDown.defaultProps = {
|
|
79
|
+
// someProp:false
|
|
80
|
+
};
|
|
81
|
+
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
|
+
}
|