@pareto-engineering/design-system 4.0.0-alpha.39 → 4.0.0-alpha.41
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/People/common/Person/Person.js +4 -4
- package/dist/cjs/a/People/styles.scss +10 -4
- package/dist/cjs/b/Card/common/Group/Group.js +1 -1
- package/dist/cjs/f/fields/EditorInput/EditorInput.js +191 -0
- package/dist/cjs/f/fields/EditorInput/common/Toolbar.js +193 -0
- package/dist/cjs/f/fields/EditorInput/common/TreeViewPlugin.js +19 -0
- package/dist/cjs/f/fields/EditorInput/common/index.js +20 -0
- package/dist/cjs/f/fields/EditorInput/index.js +13 -0
- package/dist/cjs/f/fields/EditorInput/styles.scss +119 -0
- package/dist/cjs/f/fields/QueryCombobox/common/Combobox/Combobox.js +1 -1
- package/dist/cjs/f/fields/QueryCombobox/styles.scss +4 -1
- package/dist/cjs/f/fields/index.js +8 -1
- package/dist/es/a/People/common/Person/Person.js +4 -4
- package/dist/es/a/People/styles.scss +10 -4
- package/dist/es/b/Card/common/Group/Group.js +1 -1
- package/dist/es/f/fields/EditorInput/EditorInput.js +186 -0
- package/dist/es/f/fields/EditorInput/common/Toolbar.js +182 -0
- package/dist/es/f/fields/EditorInput/common/TreeViewPlugin.js +11 -0
- package/dist/es/f/fields/EditorInput/common/index.js +2 -0
- package/dist/es/f/fields/EditorInput/index.js +2 -0
- package/dist/es/f/fields/EditorInput/styles.scss +119 -0
- package/dist/es/f/fields/QueryCombobox/common/Combobox/Combobox.js +1 -1
- package/dist/es/f/fields/QueryCombobox/styles.scss +4 -1
- package/dist/es/f/fields/index.js +2 -1
- package/package.json +5 -3
- package/src/stories/a/People.stories.jsx +20 -0
- package/src/stories/f/EditorInput.stories.jsx +88 -0
- package/src/ui/a/People/common/Person/Person.jsx +4 -4
- package/src/ui/a/People/styles.scss +10 -4
- package/src/ui/b/Card/common/Group/Group.jsx +1 -1
- package/src/ui/f/fields/EditorInput/EditorInput.jsx +237 -0
- package/src/ui/f/fields/EditorInput/common/Toolbar.jsx +254 -0
- package/src/ui/f/fields/EditorInput/common/TreeViewPlugin.jsx +16 -0
- package/src/ui/f/fields/EditorInput/common/index.jsx +2 -0
- package/src/ui/f/fields/EditorInput/index.js +2 -0
- package/src/ui/f/fields/EditorInput/styles.scss +119 -0
- package/src/ui/f/fields/QueryCombobox/common/Combobox/Combobox.jsx +1 -0
- package/src/ui/f/fields/QueryCombobox/styles.scss +4 -1
- package/src/ui/f/fields/index.js +1 -0
- package/tests/__snapshots__/Storyshots.test.js.snap +703 -4
|
@@ -41,9 +41,9 @@ const Person = _ref => {
|
|
|
41
41
|
alt: `${name}, ${role}`
|
|
42
42
|
}), /*#__PURE__*/React.createElement("div", {
|
|
43
43
|
className: "details"
|
|
44
|
-
}, /*#__PURE__*/React.createElement("p", {
|
|
44
|
+
}, name && /*#__PURE__*/React.createElement("p", {
|
|
45
45
|
className: "name"
|
|
46
|
-
}, name), /*#__PURE__*/React.createElement("p", {
|
|
46
|
+
}, name), role && /*#__PURE__*/React.createElement("p", {
|
|
47
47
|
className: "role"
|
|
48
48
|
}, role)));
|
|
49
49
|
};
|
|
@@ -67,11 +67,11 @@ Person.propTypes = {
|
|
|
67
67
|
/**
|
|
68
68
|
* The person's name
|
|
69
69
|
*/
|
|
70
|
-
name: _propTypes.default.string
|
|
70
|
+
name: _propTypes.default.string,
|
|
71
71
|
/**
|
|
72
72
|
* The person's role
|
|
73
73
|
*/
|
|
74
|
-
role: _propTypes.default.string
|
|
74
|
+
role: _propTypes.default.string,
|
|
75
75
|
/**
|
|
76
76
|
* The base color of the person's component
|
|
77
77
|
*/
|
|
@@ -11,7 +11,9 @@ $default-padding:var(--u);
|
|
|
11
11
|
$default-horizontal-margin: .5em;
|
|
12
12
|
|
|
13
13
|
$default-grid-gap: 1em;
|
|
14
|
-
$default-
|
|
14
|
+
$default-margin: 1.5rem;
|
|
15
|
+
$default-image-margin: var(--default-image-margin, #{$default-margin});
|
|
16
|
+
$default-color: var(--default-color, var(--grey));
|
|
15
17
|
|
|
16
18
|
.#{bem.$base}.people {
|
|
17
19
|
display: grid;
|
|
@@ -29,18 +31,22 @@ $default-image-padding: 1.5rem;
|
|
|
29
31
|
.image {
|
|
30
32
|
border-radius: $default-border-radius;
|
|
31
33
|
height: var(--image-size);
|
|
32
|
-
margin-right: $default-image-
|
|
34
|
+
margin-right: $default-image-margin;
|
|
33
35
|
width: var(--image-size);
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
.details {
|
|
37
39
|
align-items: flex-start;
|
|
38
|
-
color:
|
|
40
|
+
color: $default-color;
|
|
39
41
|
display: flex;
|
|
40
42
|
flex-direction: column;
|
|
41
43
|
|
|
44
|
+
p:only-child {
|
|
45
|
+
margin: 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
42
48
|
.name {
|
|
43
|
-
color:
|
|
49
|
+
color: $default-color;
|
|
44
50
|
margin-bottom: .1em;
|
|
45
51
|
}
|
|
46
52
|
|
|
@@ -30,7 +30,7 @@ const Group = _ref => {
|
|
|
30
30
|
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
31
31
|
}, []);
|
|
32
32
|
const Wrapper = type === 'snap-scroller' ? _.SnapScroller : 'div';
|
|
33
|
-
const wrapperProps = type === 'snap-scroller' ? {
|
|
33
|
+
const wrapperProps = type === 'snap-scroller' && desktopType !== 'snap-scroller' ? {
|
|
34
34
|
noScrollOnDesktop: true
|
|
35
35
|
} : {};
|
|
36
36
|
return /*#__PURE__*/React.createElement(Wrapper, _extends({
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _formik = require("formik");
|
|
9
|
+
var _LexicalComposer = require("@lexical/react/LexicalComposer");
|
|
10
|
+
var _LexicalRichTextPlugin = require("@lexical/react/LexicalRichTextPlugin");
|
|
11
|
+
var _LexicalContentEditable = require("@lexical/react/LexicalContentEditable");
|
|
12
|
+
var _LexicalOnChangePlugin = require("@lexical/react/LexicalOnChangePlugin");
|
|
13
|
+
var _LexicalHistoryPlugin = require("@lexical/react/LexicalHistoryPlugin");
|
|
14
|
+
var _LexicalLinkPlugin = require("@lexical/react/LexicalLinkPlugin");
|
|
15
|
+
var _LexicalListPlugin = require("@lexical/react/LexicalListPlugin");
|
|
16
|
+
var _LexicalTabIndentationPlugin = require("@lexical/react/LexicalTabIndentationPlugin");
|
|
17
|
+
var _link = require("@lexical/link");
|
|
18
|
+
var _list = require("@lexical/list");
|
|
19
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
20
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
21
|
+
var _common = require("../../common");
|
|
22
|
+
var _common2 = require("./common");
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
25
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } /* @pareto-engineering/generator-front 1.0.12 */ /* eslint-disable import/no-extraneous-dependencies -- required here */ // Local Definitions
|
|
26
|
+
const baseClassName = _exports.default.base;
|
|
27
|
+
const componentClassName = 'editor-input';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* This is the component description.
|
|
31
|
+
*/
|
|
32
|
+
const EditorInput = _ref => {
|
|
33
|
+
let {
|
|
34
|
+
id,
|
|
35
|
+
className: userClassName,
|
|
36
|
+
style,
|
|
37
|
+
name,
|
|
38
|
+
label,
|
|
39
|
+
// validate,
|
|
40
|
+
resize,
|
|
41
|
+
color,
|
|
42
|
+
rows,
|
|
43
|
+
optional,
|
|
44
|
+
labelColor,
|
|
45
|
+
description,
|
|
46
|
+
disabled,
|
|
47
|
+
labelSpan,
|
|
48
|
+
desktopLabelSpan,
|
|
49
|
+
inputSpan,
|
|
50
|
+
desktopInputSpan,
|
|
51
|
+
showDebugger
|
|
52
|
+
// ...otherProps
|
|
53
|
+
} = _ref;
|
|
54
|
+
(0, React.useInsertionEffect)(() => {
|
|
55
|
+
Promise.resolve().then(() => _interopRequireWildcard(require("./styles.scss")));
|
|
56
|
+
}, []);
|
|
57
|
+
const formik = (0, _formik.useFormikContext)();
|
|
58
|
+
const setInitialValue = () => {
|
|
59
|
+
const value = formik.values[name];
|
|
60
|
+
return value || undefined;
|
|
61
|
+
};
|
|
62
|
+
const onChange = state => {
|
|
63
|
+
formik.setValues({
|
|
64
|
+
...formik.values,
|
|
65
|
+
[name]: JSON.stringify(state)
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const initialConfig = {
|
|
69
|
+
nameSpace: name,
|
|
70
|
+
editable: !disabled,
|
|
71
|
+
editorState: setInitialValue(),
|
|
72
|
+
theme: {
|
|
73
|
+
text: {
|
|
74
|
+
italic: 'italic',
|
|
75
|
+
strikethrough: 'strikethrough',
|
|
76
|
+
underline: 'underlined'
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
nodes: [_link.AutoLinkNode, _link.LinkNode, _list.ListNode, _list.ListItemNode]
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/React.createElement(_LexicalComposer.LexicalComposer, {
|
|
82
|
+
initialConfig: initialConfig
|
|
83
|
+
}, /*#__PURE__*/React.createElement(_common.FormLabel, {
|
|
84
|
+
name: name,
|
|
85
|
+
color: labelColor,
|
|
86
|
+
optional: optional,
|
|
87
|
+
columnSpan: labelSpan,
|
|
88
|
+
desktopColumnSpan: desktopLabelSpan
|
|
89
|
+
// {...otherProps}
|
|
90
|
+
}, label), /*#__PURE__*/React.createElement(_common.InputWrapper, {
|
|
91
|
+
id: id,
|
|
92
|
+
className: [baseClassName, componentClassName, userClassName, `y-${color}`, disabled && 'disabled'].filter(e => e).join(' '),
|
|
93
|
+
style: {
|
|
94
|
+
...style,
|
|
95
|
+
'--resize': resize,
|
|
96
|
+
'--rows': `${rows}em`
|
|
97
|
+
},
|
|
98
|
+
columnSpan: inputSpan,
|
|
99
|
+
desktopColumnSpan: desktopInputSpan
|
|
100
|
+
}, !disabled && /*#__PURE__*/React.createElement(_common2.Toolbar, null), /*#__PURE__*/React.createElement(_LexicalRichTextPlugin.RichTextPlugin, {
|
|
101
|
+
contentEditable: /*#__PURE__*/React.createElement(_LexicalContentEditable.ContentEditable, {
|
|
102
|
+
id: name,
|
|
103
|
+
className: "content-editable"
|
|
104
|
+
})
|
|
105
|
+
}), /*#__PURE__*/React.createElement(_LexicalOnChangePlugin.OnChangePlugin, {
|
|
106
|
+
onChange: onChange
|
|
107
|
+
}), /*#__PURE__*/React.createElement(_LexicalLinkPlugin.LinkPlugin, null), /*#__PURE__*/React.createElement(_LexicalListPlugin.ListPlugin, null), /*#__PURE__*/React.createElement(_LexicalTabIndentationPlugin.TabIndentationPlugin, null), /*#__PURE__*/React.createElement(_LexicalHistoryPlugin.HistoryPlugin, null), /*#__PURE__*/React.createElement(_common.FormDescription, {
|
|
108
|
+
className: "s-1",
|
|
109
|
+
description: description,
|
|
110
|
+
name: name
|
|
111
|
+
}), showDebugger && /*#__PURE__*/React.createElement(_common2.TreeViewPlugin, null)));
|
|
112
|
+
};
|
|
113
|
+
EditorInput.propTypes = {
|
|
114
|
+
/**
|
|
115
|
+
* The HTML id for this element
|
|
116
|
+
*/
|
|
117
|
+
id: _propTypes.default.string,
|
|
118
|
+
/**
|
|
119
|
+
* The HTML class names for this element
|
|
120
|
+
*/
|
|
121
|
+
className: _propTypes.default.string,
|
|
122
|
+
/**
|
|
123
|
+
* The React-written, css properties for this element.
|
|
124
|
+
*/
|
|
125
|
+
style: _propTypes.default.objectOf(_propTypes.default.string),
|
|
126
|
+
/**
|
|
127
|
+
* The input name (html - and Formik state)
|
|
128
|
+
*/
|
|
129
|
+
name: _propTypes.default.string.isRequired,
|
|
130
|
+
/**
|
|
131
|
+
* The input label
|
|
132
|
+
*/
|
|
133
|
+
label: _propTypes.default.string.isRequired,
|
|
134
|
+
/**
|
|
135
|
+
* The input value validator function
|
|
136
|
+
*/
|
|
137
|
+
// validate:PropTypes.func,
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The number of rows int the text area
|
|
141
|
+
*/
|
|
142
|
+
rows: _propTypes.default.number,
|
|
143
|
+
/**
|
|
144
|
+
* Color of the text
|
|
145
|
+
*/
|
|
146
|
+
color: _propTypes.default.string,
|
|
147
|
+
/**
|
|
148
|
+
* Label base color
|
|
149
|
+
*/
|
|
150
|
+
labelColor: _propTypes.default.string,
|
|
151
|
+
/**
|
|
152
|
+
* Text area description
|
|
153
|
+
*/
|
|
154
|
+
description: _propTypes.default.string,
|
|
155
|
+
/**
|
|
156
|
+
* Whether the text area should be disabled
|
|
157
|
+
*/
|
|
158
|
+
disabled: _propTypes.default.bool,
|
|
159
|
+
/**
|
|
160
|
+
* Whether the input is optional or not
|
|
161
|
+
*/
|
|
162
|
+
optional: _propTypes.default.bool,
|
|
163
|
+
/**
|
|
164
|
+
* The number of columns the label should span
|
|
165
|
+
*/
|
|
166
|
+
labelSpan: _propTypes.default.number,
|
|
167
|
+
/**
|
|
168
|
+
* The number of columns the input should span
|
|
169
|
+
*/
|
|
170
|
+
inputSpan: _propTypes.default.number,
|
|
171
|
+
/**
|
|
172
|
+
* The number of columns the label should span on desktop
|
|
173
|
+
*/
|
|
174
|
+
desktopLabelSpan: _propTypes.default.number,
|
|
175
|
+
/**
|
|
176
|
+
* The number of columns the input should span on desktop
|
|
177
|
+
*/
|
|
178
|
+
desktopInputSpan: _propTypes.default.number,
|
|
179
|
+
/**
|
|
180
|
+
* The resize property of the text area
|
|
181
|
+
*/
|
|
182
|
+
resize: _propTypes.default.oneOf(['none', 'both', 'horizontal', 'vertical'])
|
|
183
|
+
};
|
|
184
|
+
EditorInput.defaultProps = {
|
|
185
|
+
rows: 10,
|
|
186
|
+
disabled: false,
|
|
187
|
+
color: 'paragraph',
|
|
188
|
+
resize: 'vertical'
|
|
189
|
+
};
|
|
190
|
+
var _default = /*#__PURE__*/(0, React.memo)(EditorInput);
|
|
191
|
+
exports.default = _default;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _lexical = require("lexical");
|
|
9
|
+
var _list = require("@lexical/list");
|
|
10
|
+
var _selection = require("@lexical/selection");
|
|
11
|
+
var _link = require("@lexical/link");
|
|
12
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
13
|
+
var _utils = require("@lexical/utils");
|
|
14
|
+
var _exports = _interopRequireDefault(require("@pareto-engineering/bem/exports"));
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
17
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
|
+
/* eslint-disable import/no-extraneous-dependencies -- required here */
|
|
19
|
+
|
|
20
|
+
const baseClassName = _exports.default.base;
|
|
21
|
+
const componentClassName = 'toolbar';
|
|
22
|
+
const getSelectedNode = selection => {
|
|
23
|
+
const {
|
|
24
|
+
anchor,
|
|
25
|
+
focus
|
|
26
|
+
} = selection;
|
|
27
|
+
const anchorNode = selection.anchor.getNode();
|
|
28
|
+
const focusNode = selection.focus.getNode();
|
|
29
|
+
if (anchorNode === focusNode) {
|
|
30
|
+
return anchorNode;
|
|
31
|
+
}
|
|
32
|
+
const isBackward = selection.isBackward();
|
|
33
|
+
if (isBackward) {
|
|
34
|
+
return (0, _selection.$isAtNodeEnd)(focus) ? anchorNode : focusNode;
|
|
35
|
+
}
|
|
36
|
+
return (0, _selection.$isAtNodeEnd)(anchor) ? focusNode : anchorNode;
|
|
37
|
+
};
|
|
38
|
+
const Toolbar = () => {
|
|
39
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
40
|
+
const [isBold, setIsBold] = (0, React.useState)(false);
|
|
41
|
+
const [isItalic, setIsItalic] = (0, React.useState)(false);
|
|
42
|
+
const [isStrikethrough, setIsStrikethrough] = (0, React.useState)(false);
|
|
43
|
+
const [blockType, setBlockType] = (0, React.useState)('paragraph');
|
|
44
|
+
const [isLink, setIsLink] = (0, React.useState)(false);
|
|
45
|
+
const [isUnderline, setIsUnderline] = (0, React.useState)(false);
|
|
46
|
+
const formatBulletList = () => {
|
|
47
|
+
if (blockType !== 'ul') {
|
|
48
|
+
editor.dispatchCommand(_list.INSERT_UNORDERED_LIST_COMMAND);
|
|
49
|
+
} else {
|
|
50
|
+
editor.dispatchCommand(_list.REMOVE_LIST_COMMAND);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const formatNumberedList = () => {
|
|
54
|
+
if (blockType !== 'ol') {
|
|
55
|
+
editor.dispatchCommand(_list.INSERT_ORDERED_LIST_COMMAND);
|
|
56
|
+
} else {
|
|
57
|
+
editor.dispatchCommand(_list.REMOVE_LIST_COMMAND);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const formatLink = (0, React.useCallback)(() => {
|
|
61
|
+
if (!isLink) {
|
|
62
|
+
// eslint-disable-next-line no-alert
|
|
63
|
+
const path = prompt('Enter the full URL. Ex: https://www.example.com');
|
|
64
|
+
editor.dispatchCommand(_link.TOGGLE_LINK_COMMAND, path);
|
|
65
|
+
} else {
|
|
66
|
+
editor.dispatchCommand(_link.TOGGLE_LINK_COMMAND, null);
|
|
67
|
+
}
|
|
68
|
+
}, [editor, isLink]);
|
|
69
|
+
const updateToolbar = (0, React.useCallback)(() => {
|
|
70
|
+
const selection = (0, _lexical.$getSelection)();
|
|
71
|
+
|
|
72
|
+
// Check list selection
|
|
73
|
+
if ((0, _lexical.$isRangeSelection)(selection)) {
|
|
74
|
+
const anchorNode = selection.anchor.getNode();
|
|
75
|
+
const element = anchorNode.getKey() === 'root' ? anchorNode : anchorNode.getTopLevelElementOrThrow();
|
|
76
|
+
if ((0, _list.$isListNode)(element)) {
|
|
77
|
+
const parentList = (0, _utils.$getNearestNodeOfType)(anchorNode, _list.ListNode);
|
|
78
|
+
const type = parentList ? parentList.getTag() : element.getTag();
|
|
79
|
+
setBlockType(type);
|
|
80
|
+
} else {
|
|
81
|
+
setBlockType(element);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Check selection text styles
|
|
85
|
+
setIsBold(selection.hasFormat('bold'));
|
|
86
|
+
setIsItalic(selection.hasFormat('italic'));
|
|
87
|
+
setIsStrikethrough(selection.hasFormat('strikethrough'));
|
|
88
|
+
setIsUnderline(selection.hasFormat('underline'));
|
|
89
|
+
setIsLink(selection.hasFormat('link'));
|
|
90
|
+
|
|
91
|
+
// Check links
|
|
92
|
+
const node = getSelectedNode(selection);
|
|
93
|
+
const parent = node.getParent();
|
|
94
|
+
if ((0, _link.$isLinkNode)(parent) || (0, _link.$isLinkNode)(node)) {
|
|
95
|
+
setIsLink(true);
|
|
96
|
+
} else {
|
|
97
|
+
setIsLink(false);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}, [editor]);
|
|
101
|
+
(0, React.useEffect)(() => (0, _utils.mergeRegister)(editor.registerUpdateListener(_ref => {
|
|
102
|
+
let {
|
|
103
|
+
editorState
|
|
104
|
+
} = _ref;
|
|
105
|
+
editorState.read(() => {
|
|
106
|
+
updateToolbar();
|
|
107
|
+
});
|
|
108
|
+
})), [updateToolbar, editor]);
|
|
109
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
110
|
+
className: `${baseClassName} ${componentClassName}`
|
|
111
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
112
|
+
className: "group"
|
|
113
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
114
|
+
type: "button",
|
|
115
|
+
className: isBold ? 'active' : undefined,
|
|
116
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, 'bold')
|
|
117
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
118
|
+
className: "icon"
|
|
119
|
+
}, "|")), /*#__PURE__*/React.createElement("button", {
|
|
120
|
+
type: "button",
|
|
121
|
+
className: isItalic ? 'active' : undefined,
|
|
122
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, 'italic')
|
|
123
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
124
|
+
className: "icon"
|
|
125
|
+
}, "}")), /*#__PURE__*/React.createElement("button", {
|
|
126
|
+
type: "button",
|
|
127
|
+
className: isUnderline ? 'active' : undefined,
|
|
128
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, 'underline')
|
|
129
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
130
|
+
className: "icon"
|
|
131
|
+
}, "~")), /*#__PURE__*/React.createElement("button", {
|
|
132
|
+
type: "button",
|
|
133
|
+
className: isStrikethrough ? 'active' : undefined,
|
|
134
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_TEXT_COMMAND, 'strikethrough')
|
|
135
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
136
|
+
className: "icon"
|
|
137
|
+
}, "?")), /*#__PURE__*/React.createElement("button", {
|
|
138
|
+
type: "button",
|
|
139
|
+
className: isLink ? 'active' : undefined,
|
|
140
|
+
onClick: () => formatLink()
|
|
141
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
142
|
+
className: "icon"
|
|
143
|
+
}, "]")), /*#__PURE__*/React.createElement("button", {
|
|
144
|
+
type: "button",
|
|
145
|
+
className: blockType === 'ul' ? 'active' : undefined,
|
|
146
|
+
onClick: () => formatBulletList()
|
|
147
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
148
|
+
className: "icon"
|
|
149
|
+
}, ".")), /*#__PURE__*/React.createElement("button", {
|
|
150
|
+
type: "button",
|
|
151
|
+
className: blockType === 'ol' ? 'active' : undefined,
|
|
152
|
+
onClick: () => formatNumberedList()
|
|
153
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
154
|
+
className: "icon"
|
|
155
|
+
}, "-"))), /*#__PURE__*/React.createElement("div", {
|
|
156
|
+
className: "group"
|
|
157
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
158
|
+
type: "button",
|
|
159
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_ELEMENT_COMMAND, 'left')
|
|
160
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
161
|
+
className: "icon"
|
|
162
|
+
}, "^")), /*#__PURE__*/React.createElement("button", {
|
|
163
|
+
type: "button",
|
|
164
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_ELEMENT_COMMAND, 'center')
|
|
165
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
166
|
+
className: "icon"
|
|
167
|
+
}, "_")), /*#__PURE__*/React.createElement("button", {
|
|
168
|
+
type: "button",
|
|
169
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_ELEMENT_COMMAND, 'right')
|
|
170
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
171
|
+
className: "icon"
|
|
172
|
+
}, "`")), /*#__PURE__*/React.createElement("button", {
|
|
173
|
+
type: "button",
|
|
174
|
+
onClick: () => editor.dispatchCommand(_lexical.FORMAT_ELEMENT_COMMAND, 'justify')
|
|
175
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
176
|
+
className: "icon"
|
|
177
|
+
}, "{"))), /*#__PURE__*/React.createElement("div", {
|
|
178
|
+
className: "group"
|
|
179
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
180
|
+
type: "button",
|
|
181
|
+
onClick: () => editor.dispatchCommand(_lexical.UNDO_COMMAND)
|
|
182
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
183
|
+
className: "icon"
|
|
184
|
+
}, "\\")), /*#__PURE__*/React.createElement("button", {
|
|
185
|
+
type: "button",
|
|
186
|
+
className: "flip",
|
|
187
|
+
onClick: () => editor.dispatchCommand(_lexical.REDO_COMMAND)
|
|
188
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
189
|
+
className: "icon"
|
|
190
|
+
}, "\\"))));
|
|
191
|
+
};
|
|
192
|
+
var _default = Toolbar;
|
|
193
|
+
exports.default = _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _LexicalComposerContext = require("@lexical/react/LexicalComposerContext");
|
|
9
|
+
var _LexicalTreeView = require("@lexical/react/LexicalTreeView");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
const TreeViewPlugin = () => {
|
|
12
|
+
const [editor] = (0, _LexicalComposerContext.useLexicalComposerContext)();
|
|
13
|
+
return /*#__PURE__*/_react.default.createElement(_LexicalTreeView.TreeView, {
|
|
14
|
+
viewClassName: "tree-view-output",
|
|
15
|
+
editor: editor
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
var _default = TreeViewPlugin;
|
|
19
|
+
exports.default = _default;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Toolbar", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _Toolbar.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "TreeViewPlugin", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _TreeViewPlugin.default;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _Toolbar = _interopRequireDefault(require("./Toolbar"));
|
|
19
|
+
var _TreeViewPlugin = _interopRequireDefault(require("./TreeViewPlugin"));
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "EditorInput", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _EditorInput.default;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _EditorInput = _interopRequireDefault(require("./EditorInput"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* @pareto-engineering/generator-front 1.0.12 */
|
|
2
|
+
/* stylelint-disable max-nesting-depth -- required here */
|
|
3
|
+
|
|
4
|
+
@use "@pareto-engineering/bem";
|
|
5
|
+
@use "@pareto-engineering/styles/src/mixins";
|
|
6
|
+
@use "@pareto-engineering/styles/src/globals" as *;
|
|
7
|
+
|
|
8
|
+
$default-gap: calc(var(--gap) / 2);
|
|
9
|
+
$default-padding: .55em .75em;
|
|
10
|
+
$default-border: 1px solid var(--outline-inputs);
|
|
11
|
+
$default-input-border-radius: var(--theme-default-input-border-radius);
|
|
12
|
+
$default-border: var(--theme-default-input-border);
|
|
13
|
+
$focus-border: var(--theme-focus-input-border);
|
|
14
|
+
$active-background: var(--hard-background-inputs);
|
|
15
|
+
$default-background: var(--background-inputs);
|
|
16
|
+
$disabled-background: var(--background-inputs-30);
|
|
17
|
+
|
|
18
|
+
.#{bem.$base}.editor-input {
|
|
19
|
+
&.#{bem.$base}.input-wrapper {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
|
|
23
|
+
> .#{bem.$base}.toolbar {
|
|
24
|
+
display: flex;
|
|
25
|
+
gap: $default-gap;
|
|
26
|
+
margin-bottom: .25em;
|
|
27
|
+
|
|
28
|
+
> .group {
|
|
29
|
+
> button {
|
|
30
|
+
background: $default-background;
|
|
31
|
+
border: $default-border;
|
|
32
|
+
padding: $default-padding;
|
|
33
|
+
|
|
34
|
+
&.active {
|
|
35
|
+
background-color: $active-background;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.flip {
|
|
41
|
+
transform: scaleX(-1);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&:not(.disabled) {
|
|
46
|
+
&:hover,
|
|
47
|
+
&:focus,
|
|
48
|
+
&:active {
|
|
49
|
+
> .textarea {
|
|
50
|
+
border: $focus-border;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
&.disabled {
|
|
56
|
+
> .textarea {
|
|
57
|
+
background: $disabled-background;
|
|
58
|
+
color: var(--metadata);
|
|
59
|
+
cursor: not-allowed;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
> .content-editable {
|
|
64
|
+
background: $default-background;
|
|
65
|
+
border: $default-border;
|
|
66
|
+
border-radius: $default-input-border-radius;
|
|
67
|
+
color: var(--y);
|
|
68
|
+
height: var(--rows);
|
|
69
|
+
outline: none;
|
|
70
|
+
overflow: auto;
|
|
71
|
+
padding: $default-padding;
|
|
72
|
+
resize: var(--resize);
|
|
73
|
+
width: 100%;
|
|
74
|
+
|
|
75
|
+
li:has(ol, ul) {
|
|
76
|
+
list-style-type: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
p,
|
|
80
|
+
span,
|
|
81
|
+
strong,
|
|
82
|
+
em,
|
|
83
|
+
li {
|
|
84
|
+
&.underlined {
|
|
85
|
+
text-decoration: underline;
|
|
86
|
+
|
|
87
|
+
&.strikethrough {
|
|
88
|
+
text-decoration: underline line-through;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.strikethrough {
|
|
93
|
+
text-decoration: line-through;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&.italic {
|
|
97
|
+
font-style: italic;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
:first-child {
|
|
102
|
+
margin-top: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&::placeholder {
|
|
106
|
+
color: var(--metadata);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
> .tree-view-output {
|
|
112
|
+
background: $default-background;
|
|
113
|
+
border: $default-border;
|
|
114
|
+
border-radius: $default-input-border-radius;
|
|
115
|
+
max-height: 20em;
|
|
116
|
+
overflow: auto;
|
|
117
|
+
padding: $default-padding;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
@@ -99,7 +99,7 @@ const Combobox = _ref => {
|
|
|
99
99
|
desktopColumnSpan: desktopLabelSpan
|
|
100
100
|
}), label), /*#__PURE__*/React.createElement(_common.InputWrapper, _extends({
|
|
101
101
|
id: id,
|
|
102
|
-
className: [baseClassName, componentClassName, userClassName].filter(e => e).join(' '),
|
|
102
|
+
className: [baseClassName, componentClassName, userClassName, `y-${color}`].filter(e => e).join(' '),
|
|
103
103
|
style: style,
|
|
104
104
|
ref: parentRef
|
|
105
105
|
}, getComboboxProps(), {
|
|
@@ -14,7 +14,9 @@ $default-border: var(--theme-default-input-border);
|
|
|
14
14
|
$hover-border: var(--theme-hover-input-border);
|
|
15
15
|
$focus-border: var(--theme-focus-input-border);
|
|
16
16
|
$default-background: var(--background-inputs);
|
|
17
|
+
$on-default-background: var(--paragraph);
|
|
17
18
|
$disabled-background: var(--background-inputs-30);
|
|
19
|
+
$on-disabled-background: var(--on-background-inputs-30);
|
|
18
20
|
|
|
19
21
|
.#{bem.$base}.combobox,
|
|
20
22
|
.#{bem.$base}.multiple-combobox {
|
|
@@ -74,7 +76,7 @@ $disabled-background: var(--background-inputs-30);
|
|
|
74
76
|
background: $default-background;
|
|
75
77
|
border: $default-border;
|
|
76
78
|
border-radius: calc(var(--theme-default-border-radius) / 2);
|
|
77
|
-
color:
|
|
79
|
+
color: $on-default-background;
|
|
78
80
|
outline: none;
|
|
79
81
|
padding: $default-input-padding;
|
|
80
82
|
|
|
@@ -84,6 +86,7 @@ $disabled-background: var(--background-inputs-30);
|
|
|
84
86
|
|
|
85
87
|
&:disabled {
|
|
86
88
|
background-color: $disabled-background;
|
|
89
|
+
color: $on-disabled-background;
|
|
87
90
|
}
|
|
88
91
|
|
|
89
92
|
&:not(:disabled) {
|