@madie/madie-design-system 1.2.71 → 1.2.73
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/components/RichTextEditor/index.jsx +358 -341
- package/dist/browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +1 -1
- package/dist/react/index.js.map +1 -1
- package/package.json +1 -1
- package/test/components/RichTextEditor.test.js +31 -29
|
@@ -40,213 +40,213 @@ const iconStyle = {
|
|
|
40
40
|
display: "block",
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
-
const MenuBar = ({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const MenuBar = ({editor, disabled}) => {
|
|
44
|
+
if (!editor) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
className="control-group"
|
|
50
|
+
role="toolbar"
|
|
51
|
+
aria-label="Text formatting toolbar"
|
|
52
|
+
data-testid="rich-text-editor-toolbar"
|
|
53
|
+
>
|
|
54
|
+
<div className="button-group">
|
|
55
|
+
<Tooltip
|
|
56
|
+
data-testid="undo-tooltip"
|
|
57
|
+
title="Undo"
|
|
58
|
+
placement="top"
|
|
59
|
+
enterDelay={1000}
|
|
60
|
+
arrow
|
|
61
|
+
>
|
|
62
|
+
<IconButton
|
|
63
|
+
key={"undo"}
|
|
64
|
+
onClick={() =>
|
|
65
|
+
editor.chain().focus().undo().run()
|
|
66
|
+
}
|
|
67
|
+
>
|
|
68
|
+
<UndoIcon/>
|
|
69
|
+
</IconButton>
|
|
70
|
+
</Tooltip>
|
|
71
|
+
<Tooltip
|
|
72
|
+
data-testid="redo-tooltip"
|
|
73
|
+
title="Redo"
|
|
74
|
+
placement="top"
|
|
75
|
+
enterDelay={1000}
|
|
76
|
+
arrow
|
|
77
|
+
>
|
|
78
|
+
<IconButton
|
|
79
|
+
key={"redo"}
|
|
80
|
+
onClick={() =>
|
|
81
|
+
editor.chain().focus().redo().run()
|
|
82
|
+
}
|
|
83
|
+
style={{borderRight: "solid 1px #9c9c9c"}}
|
|
84
|
+
>
|
|
85
|
+
<RedoIcon/>
|
|
86
|
+
</IconButton>
|
|
87
|
+
</Tooltip>
|
|
88
|
+
<Tooltip
|
|
89
|
+
data-testid="bold-tooltip"
|
|
90
|
+
title="Bold"
|
|
91
|
+
placement="top"
|
|
92
|
+
enterDelay={1000}
|
|
93
|
+
arrow
|
|
94
|
+
>
|
|
95
|
+
<IconButton
|
|
96
|
+
key={"bold"}
|
|
97
|
+
onClick={() =>
|
|
98
|
+
editor.chain().focus().toggleBold().run()
|
|
99
|
+
}
|
|
100
|
+
aria-label="Bold"
|
|
101
|
+
aria-pressed={editor.isActive("bold")}
|
|
102
|
+
className={editor.isActive("bold") ? "is-active" : ""}
|
|
103
|
+
disabled={disabled}
|
|
104
|
+
type="button"
|
|
105
|
+
>
|
|
106
|
+
<FormatBoldIcon/>
|
|
107
|
+
</IconButton>
|
|
108
|
+
</Tooltip>
|
|
109
|
+
<Tooltip
|
|
110
|
+
data-testid="italic-tooltip"
|
|
111
|
+
title="Italic"
|
|
112
|
+
placement="top"
|
|
113
|
+
enterDelay={1000}
|
|
114
|
+
arrow
|
|
115
|
+
>
|
|
116
|
+
<IconButton
|
|
117
|
+
key={"italic"}
|
|
118
|
+
onClick={() =>
|
|
119
|
+
editor.chain().focus().toggleItalic().run()
|
|
120
|
+
}
|
|
121
|
+
aria-label="Italic"
|
|
122
|
+
aria-pressed={editor.isActive("italic")}
|
|
123
|
+
className={editor.isActive("italic") ? "is-active" : ""}
|
|
124
|
+
disabled={disabled}
|
|
125
|
+
type="button"
|
|
126
|
+
>
|
|
127
|
+
<FormatItalicIcon/>
|
|
128
|
+
</IconButton>
|
|
129
|
+
</Tooltip>
|
|
130
|
+
<Tooltip
|
|
131
|
+
data-testid="underline-tooltip"
|
|
132
|
+
title="Underline"
|
|
133
|
+
placement="top"
|
|
134
|
+
enterDelay={1000}
|
|
135
|
+
arrow
|
|
136
|
+
>
|
|
137
|
+
<IconButton
|
|
138
|
+
key={"underline"}
|
|
139
|
+
onClick={() =>
|
|
140
|
+
editor.chain().focus().toggleUnderline().run()
|
|
141
|
+
}
|
|
142
|
+
aria-label="Underline"
|
|
143
|
+
aria-pressed={editor.isActive("underline")}
|
|
144
|
+
className={
|
|
145
|
+
editor.isActive("underline") ? "is-active" : ""
|
|
146
|
+
}
|
|
147
|
+
disabled={disabled}
|
|
148
|
+
type="button"
|
|
149
|
+
>
|
|
150
|
+
<FormatUnderlinedIcon/>
|
|
151
|
+
</IconButton>
|
|
152
|
+
</Tooltip>
|
|
153
|
+
<Tooltip
|
|
154
|
+
data-testid="strikethrough-tooltip"
|
|
155
|
+
title="Strikethrough"
|
|
156
|
+
placement="top"
|
|
157
|
+
enterDelay={1000}
|
|
158
|
+
arrow
|
|
159
|
+
>
|
|
160
|
+
<IconButton
|
|
161
|
+
key={"strike"}
|
|
162
|
+
onClick={() =>
|
|
163
|
+
editor.chain().focus().toggleStrike().run()
|
|
164
|
+
}
|
|
165
|
+
aria-label="Strikethrough"
|
|
166
|
+
aria-pressed={editor.isActive("strike")}
|
|
167
|
+
className={editor.isActive("strike") ? "is-active" : ""}
|
|
168
|
+
style={{borderRight: "solid 1px #9c9c9c"}}
|
|
169
|
+
disabled={disabled}
|
|
170
|
+
type="button"
|
|
171
|
+
>
|
|
172
|
+
<StrikethroughSIcon/>
|
|
173
|
+
</IconButton>
|
|
174
|
+
</Tooltip>
|
|
175
|
+
<Tooltip
|
|
176
|
+
data-testid="orderedlist-tooltip"
|
|
177
|
+
title="Ordered List"
|
|
178
|
+
placement="top"
|
|
179
|
+
enterDelay={1000}
|
|
180
|
+
arrow
|
|
53
181
|
>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
aria-pressed={editor.isActive("italic")}
|
|
123
|
-
className={editor.isActive("italic") ? "is-active" : ""}
|
|
124
|
-
disabled={disabled}
|
|
125
|
-
type="button"
|
|
126
|
-
>
|
|
127
|
-
<FormatItalicIcon />
|
|
128
|
-
</IconButton>
|
|
129
|
-
</Tooltip>
|
|
130
|
-
<Tooltip
|
|
131
|
-
data-testid="underline-tooltip"
|
|
132
|
-
title="Underline"
|
|
133
|
-
placement="top"
|
|
134
|
-
enterDelay={1000}
|
|
135
|
-
arrow
|
|
136
|
-
>
|
|
137
|
-
<IconButton
|
|
138
|
-
key={"underline"}
|
|
139
|
-
onClick={() =>
|
|
140
|
-
editor.chain().focus().toggleUnderline().run()
|
|
141
|
-
}
|
|
142
|
-
aria-label="Underline"
|
|
143
|
-
aria-pressed={editor.isActive("underline")}
|
|
144
|
-
className={
|
|
145
|
-
editor.isActive("underline") ? "is-active" : ""
|
|
146
|
-
}
|
|
147
|
-
disabled={disabled}
|
|
148
|
-
type="button"
|
|
149
|
-
>
|
|
150
|
-
<FormatUnderlinedIcon />
|
|
151
|
-
</IconButton>
|
|
152
|
-
</Tooltip>
|
|
153
|
-
<Tooltip
|
|
154
|
-
data-testid="strikethrough-tooltip"
|
|
155
|
-
title="Strikethrough"
|
|
156
|
-
placement="top"
|
|
157
|
-
enterDelay={1000}
|
|
158
|
-
arrow
|
|
159
|
-
>
|
|
160
|
-
<IconButton
|
|
161
|
-
key={"strike"}
|
|
162
|
-
onClick={() =>
|
|
163
|
-
editor.chain().focus().toggleStrike().run()
|
|
164
|
-
}
|
|
165
|
-
aria-label="Strikethrough"
|
|
166
|
-
aria-pressed={editor.isActive("strike")}
|
|
167
|
-
className={editor.isActive("strike") ? "is-active" : ""}
|
|
168
|
-
style={{ borderRight: "solid 1px #9c9c9c" }}
|
|
169
|
-
disabled={disabled}
|
|
170
|
-
type="button"
|
|
171
|
-
>
|
|
172
|
-
<StrikethroughSIcon />
|
|
173
|
-
</IconButton>
|
|
174
|
-
</Tooltip>
|
|
175
|
-
<Tooltip
|
|
176
|
-
data-testid="orderedlist-tooltip"
|
|
177
|
-
title="Ordered List"
|
|
178
|
-
placement="top"
|
|
179
|
-
enterDelay={1000}
|
|
180
|
-
arrow
|
|
181
|
-
>
|
|
182
|
-
<IconButton
|
|
183
|
-
key={"orderedList"}
|
|
184
|
-
onClick={() =>
|
|
185
|
-
editor.chain().focus().toggleOrderedList().run()
|
|
186
|
-
}
|
|
187
|
-
aria-label="Ordered List"
|
|
188
|
-
aria-pressed={editor.isActive("orderedList")}
|
|
189
|
-
className={
|
|
190
|
-
editor.isActive("orderedList") ? "is-active" : ""
|
|
191
|
-
}
|
|
192
|
-
disabled={disabled}
|
|
193
|
-
type="button"
|
|
194
|
-
>
|
|
195
|
-
<FormatListNumberedIcon />
|
|
196
|
-
</IconButton>
|
|
197
|
-
</Tooltip>
|
|
198
|
-
<Tooltip
|
|
199
|
-
data-testid="bulletedlist-tooltip"
|
|
200
|
-
title="Bulleted List"
|
|
201
|
-
placement="top"
|
|
202
|
-
enterDelay={1000}
|
|
203
|
-
arrow
|
|
204
|
-
>
|
|
205
|
-
<IconButton
|
|
206
|
-
key={"bulletList"}
|
|
207
|
-
onClick={() =>
|
|
208
|
-
editor.chain().focus().toggleBulletList().run()
|
|
209
|
-
}
|
|
210
|
-
aria-label="Bulleted List"
|
|
211
|
-
aria-pressed={editor.isActive("bulletList")}
|
|
212
|
-
className={
|
|
213
|
-
editor.isActive("bulletList") ? "is-active" : ""
|
|
214
|
-
}
|
|
215
|
-
style={{ borderRight: "solid 1px #9c9c9c" }}
|
|
216
|
-
disabled={disabled}
|
|
217
|
-
type="button"
|
|
218
|
-
>
|
|
219
|
-
<FormatListBulletedIcon />
|
|
220
|
-
</IconButton>
|
|
221
|
-
</Tooltip>
|
|
222
|
-
<Tooltip
|
|
223
|
-
data-testid="table-tooltip"
|
|
224
|
-
title="Table"
|
|
225
|
-
placement="top"
|
|
226
|
-
enterDelay={1000}
|
|
227
|
-
arrow
|
|
228
|
-
>
|
|
229
|
-
<IconButton
|
|
230
|
-
key={"insertTable"}
|
|
231
|
-
onClick={() =>
|
|
232
|
-
editor.commands.insertTable({
|
|
233
|
-
rows: 3,
|
|
234
|
-
cols: 3,
|
|
235
|
-
withHeaderRow: true,
|
|
236
|
-
})
|
|
237
|
-
}
|
|
238
|
-
aria-label="Insert Table"
|
|
239
|
-
className={
|
|
240
|
-
editor.isActive("insertTable") ? "is-active" : ""
|
|
241
|
-
}
|
|
242
|
-
disabled={disabled}
|
|
243
|
-
type="button"
|
|
244
|
-
>
|
|
245
|
-
|
|
246
|
-
<TableChartIcon />
|
|
247
|
-
</IconButton>
|
|
248
|
-
</Tooltip>
|
|
249
|
-
{editor.isActive("table") && (
|
|
182
|
+
<IconButton
|
|
183
|
+
key={"orderedList"}
|
|
184
|
+
onClick={() =>
|
|
185
|
+
editor.chain().focus().toggleOrderedList().run()
|
|
186
|
+
}
|
|
187
|
+
aria-label="Ordered List"
|
|
188
|
+
aria-pressed={editor.isActive("orderedList")}
|
|
189
|
+
className={
|
|
190
|
+
editor.isActive("orderedList") ? "is-active" : ""
|
|
191
|
+
}
|
|
192
|
+
disabled={disabled}
|
|
193
|
+
type="button"
|
|
194
|
+
>
|
|
195
|
+
<FormatListNumberedIcon/>
|
|
196
|
+
</IconButton>
|
|
197
|
+
</Tooltip>
|
|
198
|
+
<Tooltip
|
|
199
|
+
data-testid="bulletedlist-tooltip"
|
|
200
|
+
title="Bulleted List"
|
|
201
|
+
placement="top"
|
|
202
|
+
enterDelay={1000}
|
|
203
|
+
arrow
|
|
204
|
+
>
|
|
205
|
+
<IconButton
|
|
206
|
+
key={"bulletList"}
|
|
207
|
+
onClick={() =>
|
|
208
|
+
editor.chain().focus().toggleBulletList().run()
|
|
209
|
+
}
|
|
210
|
+
aria-label="Bulleted List"
|
|
211
|
+
aria-pressed={editor.isActive("bulletList")}
|
|
212
|
+
className={
|
|
213
|
+
editor.isActive("bulletList") ? "is-active" : ""
|
|
214
|
+
}
|
|
215
|
+
style={{borderRight: "solid 1px #9c9c9c"}}
|
|
216
|
+
disabled={disabled}
|
|
217
|
+
type="button"
|
|
218
|
+
>
|
|
219
|
+
<FormatListBulletedIcon/>
|
|
220
|
+
</IconButton>
|
|
221
|
+
</Tooltip>
|
|
222
|
+
<Tooltip
|
|
223
|
+
data-testid="table-tooltip"
|
|
224
|
+
title="Table"
|
|
225
|
+
placement="top"
|
|
226
|
+
enterDelay={1000}
|
|
227
|
+
arrow
|
|
228
|
+
>
|
|
229
|
+
<IconButton
|
|
230
|
+
key={"insertTable"}
|
|
231
|
+
onClick={() =>
|
|
232
|
+
editor.commands.insertTable({
|
|
233
|
+
rows: 3,
|
|
234
|
+
cols: 3,
|
|
235
|
+
withHeaderRow: true,
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
aria-label="Insert Table"
|
|
239
|
+
className={
|
|
240
|
+
editor.isActive("insertTable") ? "is-active" : ""
|
|
241
|
+
}
|
|
242
|
+
disabled={disabled}
|
|
243
|
+
type="button"
|
|
244
|
+
>
|
|
245
|
+
|
|
246
|
+
<TableChartIcon/>
|
|
247
|
+
</IconButton>
|
|
248
|
+
</Tooltip>
|
|
249
|
+
{editor.isActive("table") && (
|
|
250
250
|
<>
|
|
251
251
|
<Tooltip
|
|
252
252
|
data-testid="add-row-above-tooltip"
|
|
@@ -259,7 +259,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
259
259
|
key="addRowAbove"
|
|
260
260
|
onClick={() => editor.chain().focus().addRowBefore().run()}
|
|
261
261
|
>
|
|
262
|
-
<AddRowAboveIcon style={iconStyle}
|
|
262
|
+
<AddRowAboveIcon style={iconStyle}/>
|
|
263
263
|
</IconButton>
|
|
264
264
|
</Tooltip>
|
|
265
265
|
<Tooltip
|
|
@@ -273,7 +273,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
273
273
|
key="addRowBelow"
|
|
274
274
|
onClick={() => editor.chain().focus().addRowAfter().run()}
|
|
275
275
|
>
|
|
276
|
-
<AddRowBelowIcon style={iconStyle}
|
|
276
|
+
<AddRowBelowIcon style={iconStyle}/>
|
|
277
277
|
</IconButton>
|
|
278
278
|
</Tooltip>
|
|
279
279
|
|
|
@@ -288,7 +288,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
288
288
|
key="deleteRow"
|
|
289
289
|
onClick={() => editor.chain().focus().deleteRow().run()}
|
|
290
290
|
>
|
|
291
|
-
<DeleteRowIcon style={iconStyle}
|
|
291
|
+
<DeleteRowIcon style={iconStyle}/>
|
|
292
292
|
</IconButton>
|
|
293
293
|
</Tooltip>
|
|
294
294
|
<Tooltip
|
|
@@ -302,7 +302,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
302
302
|
key="addColumnRight"
|
|
303
303
|
onClick={() => editor.chain().focus().addColumnAfter().run()}
|
|
304
304
|
>
|
|
305
|
-
<AddColumnRightIcon style={iconStyle}
|
|
305
|
+
<AddColumnRightIcon style={iconStyle}/>
|
|
306
306
|
</IconButton>
|
|
307
307
|
</Tooltip>
|
|
308
308
|
<Tooltip
|
|
@@ -316,7 +316,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
316
316
|
key="addColumnLeft"
|
|
317
317
|
onClick={() => editor.chain().focus().addColumnBefore().run()}
|
|
318
318
|
>
|
|
319
|
-
<AddColumnLeftIcon style={iconStyle}
|
|
319
|
+
<AddColumnLeftIcon style={iconStyle}/>
|
|
320
320
|
</IconButton>
|
|
321
321
|
</Tooltip>
|
|
322
322
|
|
|
@@ -331,7 +331,7 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
331
331
|
key="deleteColumn"
|
|
332
332
|
onClick={() => editor.chain().focus().deleteColumn().run()}
|
|
333
333
|
>
|
|
334
|
-
<DeleteColumnIcon style={iconStyle}
|
|
334
|
+
<DeleteColumnIcon style={iconStyle}/>
|
|
335
335
|
</IconButton>
|
|
336
336
|
</Tooltip>
|
|
337
337
|
|
|
@@ -345,9 +345,9 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
345
345
|
<IconButton
|
|
346
346
|
key="deleteTable"
|
|
347
347
|
onClick={() => editor.chain().focus().deleteTable().run()}
|
|
348
|
-
style={{
|
|
348
|
+
style={{borderRight: "solid 1px #9c9c9c"}}
|
|
349
349
|
>
|
|
350
|
-
<DeleteTableIcon style={iconStyle}
|
|
350
|
+
<DeleteTableIcon style={iconStyle}/>
|
|
351
351
|
</IconButton>
|
|
352
352
|
</Tooltip>
|
|
353
353
|
</>
|
|
@@ -358,18 +358,77 @@ const MenuBar = ({ editor, disabled }) => {
|
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
const RichTextEditor = ({
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
361
|
+
name,
|
|
362
|
+
id,
|
|
363
|
+
error = false,
|
|
364
|
+
helperText,
|
|
365
|
+
required = false,
|
|
366
|
+
label,
|
|
367
|
+
onChange,
|
|
368
|
+
onBlur,
|
|
369
|
+
content,
|
|
370
|
+
disabled = false,
|
|
371
|
+
readOnly = false,
|
|
372
372
|
}) => {
|
|
373
|
+
const labelStyles = [
|
|
374
|
+
{
|
|
375
|
+
backgroundColor: "transparent",
|
|
376
|
+
borderColor: "#8C8C8C",
|
|
377
|
+
display: "inline-flex",
|
|
378
|
+
flexDirection: "row-reverse",
|
|
379
|
+
alignSelf: "baseline",
|
|
380
|
+
textTransform: "none",
|
|
381
|
+
// force it outside the select box
|
|
382
|
+
position: "initial",
|
|
383
|
+
transform: "translateX(0px) translateY(0px)",
|
|
384
|
+
fontFamily: "Rubik",
|
|
385
|
+
fontWeight: 500,
|
|
386
|
+
fontSize: 14,
|
|
387
|
+
color: "#333",
|
|
388
|
+
"& .MuiInputLabel-asterisk": {
|
|
389
|
+
color: "#AE1C1C !important",
|
|
390
|
+
marginRight: "3px !important", //this was
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
required && {
|
|
394
|
+
transform: "translateX(-12px) translateY(0px)",
|
|
395
|
+
"& .MuiInputLabel-asterisk": {
|
|
396
|
+
color: "#D92F2",
|
|
397
|
+
marginRight: "3px !important", //this was
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
error && {
|
|
401
|
+
color: "#AE1C1C !important",
|
|
402
|
+
},
|
|
403
|
+
];
|
|
404
|
+
|
|
405
|
+
if (readOnly) {
|
|
406
|
+
return (
|
|
407
|
+
<div className="rich-text-editor" data-testid={`${kebabCase(id)}-rich-text-editor`}>
|
|
408
|
+
<InputLabel
|
|
409
|
+
id={`${id}-label`}
|
|
410
|
+
shrink
|
|
411
|
+
required={required}
|
|
412
|
+
error={error}
|
|
413
|
+
htmlFor={id}
|
|
414
|
+
style={{marginBottom: 0, height: 16}} // force a height
|
|
415
|
+
sx={labelStyles}
|
|
416
|
+
disabled={false}
|
|
417
|
+
>
|
|
418
|
+
{label}
|
|
419
|
+
</InputLabel>
|
|
420
|
+
<p
|
|
421
|
+
className="rich-text-editor_read_only"
|
|
422
|
+
data-testid={`${id}-value`}
|
|
423
|
+
aria-labelledby={`${id}-label`}
|
|
424
|
+
dangerouslySetInnerHTML={{
|
|
425
|
+
__html: content ? DOMPurify.sanitize(content) : "-",
|
|
426
|
+
}}
|
|
427
|
+
/>
|
|
428
|
+
</div>
|
|
429
|
+
);
|
|
430
|
+
}
|
|
431
|
+
|
|
373
432
|
const editor = useEditor({
|
|
374
433
|
parseOptions: {
|
|
375
434
|
preserveWhitespace: 'full',
|
|
@@ -389,7 +448,7 @@ const RichTextEditor = ({
|
|
|
389
448
|
Underline,
|
|
390
449
|
Strike.extend({
|
|
391
450
|
strike: false, // disable default strike through
|
|
392
|
-
renderHTML({
|
|
451
|
+
renderHTML({HTMLAttributes}) {
|
|
393
452
|
return ["del", HTMLAttributes, 0];
|
|
394
453
|
},
|
|
395
454
|
}),
|
|
@@ -397,10 +456,10 @@ const RichTextEditor = ({
|
|
|
397
456
|
shouldRerenderOnTransaction: false,
|
|
398
457
|
content,
|
|
399
458
|
editable: !disabled,
|
|
400
|
-
onUpdate: ({
|
|
459
|
+
onUpdate: ({editor}) => {
|
|
401
460
|
const newValue = editor.getHTML();
|
|
402
461
|
onChange?.(newValue);
|
|
403
|
-
},
|
|
462
|
+
},
|
|
404
463
|
});
|
|
405
464
|
|
|
406
465
|
React.useEffect(() => {
|
|
@@ -413,137 +472,95 @@ const RichTextEditor = ({
|
|
|
413
472
|
}, [content, editor, disabled]);
|
|
414
473
|
|
|
415
474
|
React.useEffect(() => {
|
|
416
|
-
|
|
475
|
+
if (!editor || !onBlur || !name) return;
|
|
417
476
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
477
|
+
const handleBlur = () => {
|
|
478
|
+
onBlur({target: {name}});
|
|
479
|
+
};
|
|
421
480
|
|
|
422
|
-
|
|
481
|
+
editor.on("blur", handleBlur);
|
|
423
482
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
483
|
+
return () => {
|
|
484
|
+
editor.off("blur", handleBlur);
|
|
485
|
+
};
|
|
486
|
+
}, [editor, onBlur, name]);
|
|
428
487
|
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
flexDirection: "row-reverse",
|
|
447
|
-
alignSelf: "baseline",
|
|
448
|
-
textTransform: "none",
|
|
449
|
-
// force it outside the select box
|
|
450
|
-
position: "initial",
|
|
451
|
-
transform: "translateX(0px) translateY(0px)",
|
|
452
|
-
fontFamily: "Rubik",
|
|
453
|
-
fontWeight: 500,
|
|
454
|
-
fontSize: 14,
|
|
455
|
-
color: "#333",
|
|
456
|
-
"& .MuiInputLabel-asterisk": {
|
|
457
|
-
color: "#AE1C1C !important",
|
|
458
|
-
marginRight: "3px !important", //this was
|
|
459
|
-
},
|
|
460
|
-
},
|
|
461
|
-
required && {
|
|
462
|
-
transform: "translateX(-12px) translateY(0px)",
|
|
463
|
-
"& .MuiInputLabel-asterisk": {
|
|
464
|
-
color: "#D92F2",
|
|
465
|
-
marginRight: "3px !important", //this was
|
|
466
|
-
},
|
|
467
|
-
},
|
|
468
|
-
error && {
|
|
469
|
-
color: "#AE1C1C !important",
|
|
470
|
-
},
|
|
471
|
-
]}
|
|
472
|
-
>
|
|
473
|
-
{label}
|
|
474
|
-
</InputLabel>
|
|
475
|
-
|
|
476
|
-
{helperText && (
|
|
477
|
-
<FormHelperText
|
|
478
|
-
tabIndex={0}
|
|
479
|
-
aria-live="polite"
|
|
480
|
-
id={`${id}-helper-text`}
|
|
481
|
-
data-testid={`${id}-helper-text`}
|
|
482
|
-
sx={[
|
|
483
|
-
{
|
|
484
|
-
margin: "4px 0px 0px 0px",
|
|
485
|
-
color: "#515151",
|
|
486
|
-
lineHeight: 1,
|
|
487
|
-
},
|
|
488
|
-
error && {
|
|
489
|
-
color: "#AE1C1C !important",
|
|
490
|
-
},
|
|
491
|
-
]}
|
|
492
|
-
>
|
|
493
|
-
{helperText}
|
|
494
|
-
</FormHelperText>
|
|
495
|
-
)}
|
|
496
|
-
|
|
488
|
+
return (
|
|
489
|
+
<div
|
|
490
|
+
className="rich-text-editor"
|
|
491
|
+
data-testid={`${kebabCase(id)}-rich-text-editor`}
|
|
492
|
+
>
|
|
493
|
+
<InputLabel
|
|
494
|
+
id={`${id}-label`}
|
|
495
|
+
shrink
|
|
496
|
+
required={required}
|
|
497
|
+
error={error}
|
|
498
|
+
htmlFor={id}
|
|
499
|
+
style={{marginBottom: 0, height: 16}} // force a height
|
|
500
|
+
sx={labelStyles}
|
|
501
|
+
disabled
|
|
502
|
+
>
|
|
503
|
+
{label}
|
|
504
|
+
</InputLabel>
|
|
497
505
|
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
506
|
+
{helperText && (
|
|
507
|
+
<FormHelperText
|
|
508
|
+
tabIndex={0}
|
|
509
|
+
aria-live="polite"
|
|
510
|
+
id={`${id}-helper-text`}
|
|
511
|
+
data-testid={`${id}-helper-text`}
|
|
512
|
+
sx={[
|
|
513
|
+
{
|
|
514
|
+
margin: "4px 0px 0px 0px",
|
|
515
|
+
color: "#515151",
|
|
516
|
+
lineHeight: 1,
|
|
517
|
+
},
|
|
518
|
+
error && {
|
|
519
|
+
color: "#AE1C1C !important",
|
|
520
|
+
},
|
|
521
|
+
]}
|
|
522
|
+
>
|
|
523
|
+
{helperText}
|
|
524
|
+
</FormHelperText>
|
|
525
|
+
)}
|
|
526
|
+
<>
|
|
527
|
+
<MenuBar editor={editor} disabled={disabled}/>
|
|
528
|
+
<EditorContent
|
|
529
|
+
id={id}
|
|
530
|
+
tabIndex={0}
|
|
531
|
+
data-testid="rich-text-editor-content"
|
|
532
|
+
editor={editor}
|
|
533
|
+
aria-labelledby={`${id}-label`}
|
|
534
|
+
aria-describedby={
|
|
535
|
+
helperText ? `${id}-helper-text` : undefined
|
|
536
|
+
}
|
|
537
|
+
aria-multiline="true"
|
|
538
|
+
aria-required={required || undefined}
|
|
539
|
+
aria-invalid={error || undefined}
|
|
540
|
+
className={`${error ? "has-error" : ""}`}
|
|
541
|
+
/>
|
|
542
|
+
</>
|
|
543
|
+
</div>
|
|
544
|
+
);
|
|
528
545
|
};
|
|
529
546
|
|
|
530
547
|
RichTextEditor.propTypes = {
|
|
531
548
|
id: PropTypes.string,
|
|
532
|
-
|
|
549
|
+
name: PropTypes.string,
|
|
533
550
|
error: PropTypes.bool,
|
|
534
|
-
|
|
551
|
+
helperText: PropTypes.string,
|
|
535
552
|
required: PropTypes.bool,
|
|
536
553
|
label: PropTypes.string,
|
|
537
554
|
onChange: PropTypes.func,
|
|
538
|
-
|
|
555
|
+
onBlur: PropTypes.func,
|
|
539
556
|
content: PropTypes.any,
|
|
540
557
|
disabled: PropTypes.bool,
|
|
541
|
-
|
|
558
|
+
readOnly: PropTypes.bool,
|
|
542
559
|
};
|
|
543
560
|
|
|
544
561
|
MenuBar.propTypes = {
|
|
545
562
|
editor: PropTypes.any,
|
|
546
|
-
|
|
563
|
+
disabled: PropTypes.bool,
|
|
547
564
|
};
|
|
548
565
|
|
|
549
|
-
export default RichTextEditor;
|
|
566
|
+
export default RichTextEditor;
|