@pie-lib/editable-html-tip-tap 2.1.1-next.3 → 2.1.2-next.0
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/components/CharacterPicker.d.ts +31 -0
- package/dist/components/CharacterPicker.js +131 -0
- package/dist/components/EditableHtml.d.ts +11 -0
- package/dist/components/EditableHtml.js +291 -0
- package/dist/components/MenuBar.d.ts +11 -0
- package/dist/components/MenuBar.js +462 -0
- package/dist/components/TiptapContainer.d.ts +11 -0
- package/dist/components/TiptapContainer.js +154 -0
- package/dist/components/characters/characterUtils.d.ts +35 -0
- package/dist/components/characters/characterUtils.js +465 -0
- package/dist/components/characters/custom-popper.d.ts +14 -0
- package/dist/components/characters/custom-popper.js +32 -0
- package/dist/components/common/done-button.d.ts +30 -0
- package/dist/components/common/done-button.js +26 -0
- package/dist/components/common/toolbar-buttons.d.ts +38 -0
- package/dist/components/common/toolbar-buttons.js +91 -0
- package/dist/components/icons/CssIcon.d.ts +11 -0
- package/dist/components/icons/CssIcon.js +14 -0
- package/dist/components/icons/RespArea.d.ts +26 -0
- package/dist/components/icons/RespArea.js +42 -0
- package/dist/components/icons/TableIcons.d.ts +14 -0
- package/dist/components/icons/TableIcons.js +32 -0
- package/dist/components/icons/TextAlign.d.ts +18 -0
- package/dist/components/icons/TextAlign.js +134 -0
- package/dist/components/image/AltDialog.d.ts +22 -0
- package/dist/components/image/AltDialog.js +61 -0
- package/dist/components/image/ImageToolbar.d.ts +24 -0
- package/dist/components/image/ImageToolbar.js +80 -0
- package/dist/components/image/InsertImageHandler.d.ts +32 -0
- package/dist/components/image/InsertImageHandler.js +53 -0
- package/dist/components/media/MediaDialog.d.ts +43 -0
- package/dist/components/media/MediaDialog.js +389 -0
- package/dist/components/media/MediaToolbar.d.ts +19 -0
- package/dist/components/media/MediaToolbar.js +41 -0
- package/dist/components/media/MediaWrapper.d.ts +19 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
- package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
- package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
- package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
- package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
- package/dist/components/respArea/ExplicitConstructedResponse.js +83 -0
- package/dist/components/respArea/InlineDropdown.d.ts +18 -0
- package/dist/components/respArea/InlineDropdown.js +119 -0
- package/dist/components/respArea/MathTemplated.d.ts +19 -0
- package/dist/components/respArea/MathTemplated.js +97 -0
- package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
- package/dist/components/respArea/ToolbarIcon.js +17 -0
- package/dist/components/respArea/inlineDropdownUtils.d.ts +15 -0
- package/dist/components/respArea/inlineDropdownUtils.js +15 -0
- package/dist/constants.d.ts +13 -0
- package/dist/constants.js +4 -0
- package/dist/extensions/css.d.ts +11 -0
- package/dist/extensions/css.js +115 -0
- package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
- package/dist/extensions/custom-toolbar-wrapper.js +61 -0
- package/dist/extensions/div-node.d.ts +10 -0
- package/dist/extensions/div-node.js +42 -0
- package/dist/extensions/ensure-empty-root-div.d.ts +14 -0
- package/dist/extensions/ensure-empty-root-div.js +24 -0
- package/dist/extensions/ensure-list-item-content-is-div.d.ts +15 -0
- package/dist/extensions/ensure-list-item-content-is-div.js +31 -0
- package/dist/extensions/extended-list-item.d.ts +13 -0
- package/dist/extensions/extended-list-item.js +5 -0
- package/dist/extensions/extended-table-cell.d.ts +10 -0
- package/dist/extensions/extended-table-cell.js +6 -0
- package/dist/extensions/extended-table.d.ts +17 -0
- package/dist/extensions/extended-table.js +34 -0
- package/dist/extensions/heading-paragraph.d.ts +17 -0
- package/dist/extensions/heading-paragraph.js +30 -0
- package/dist/extensions/image-component.d.ts +22 -0
- package/dist/extensions/image-component.js +220 -0
- package/dist/extensions/image.d.ts +10 -0
- package/dist/extensions/image.js +68 -0
- package/dist/extensions/index.d.ts +16 -0
- package/dist/extensions/index.js +65 -0
- package/dist/extensions/math.d.ts +15 -0
- package/dist/extensions/math.js +158 -0
- package/dist/extensions/media.d.ts +19 -0
- package/dist/extensions/media.js +149 -0
- package/dist/extensions/responseArea.d.ts +27 -0
- package/dist/extensions/responseArea.js +259 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +7 -0
- package/dist/styles/editorContainerStyles.d.ts +134 -0
- package/dist/theme.d.ts +9 -0
- package/dist/utils/helper.d.ts +9 -0
- package/dist/utils/helper.js +27 -0
- package/dist/utils/size.d.ts +9 -0
- package/dist/utils/size.js +14 -0
- package/package.json +51 -38
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2526
- package/LICENSE.md +0 -5
- package/lib/components/CharacterPicker.js +0 -195
- package/lib/components/CharacterPicker.js.map +0 -1
- package/lib/components/EditableHtml.js +0 -375
- package/lib/components/EditableHtml.js.map +0 -1
- package/lib/components/MenuBar.js +0 -693
- package/lib/components/MenuBar.js.map +0 -1
- package/lib/components/TiptapContainer.js +0 -234
- package/lib/components/TiptapContainer.js.map +0 -1
- package/lib/components/characters/characterUtils.js +0 -378
- package/lib/components/characters/characterUtils.js.map +0 -1
- package/lib/components/characters/custom-popper.js +0 -44
- package/lib/components/characters/custom-popper.js.map +0 -1
- package/lib/components/common/done-button.js +0 -34
- package/lib/components/common/done-button.js.map +0 -1
- package/lib/components/common/toolbar-buttons.js +0 -144
- package/lib/components/common/toolbar-buttons.js.map +0 -1
- package/lib/components/icons/CssIcon.js +0 -25
- package/lib/components/icons/CssIcon.js.map +0 -1
- package/lib/components/icons/RespArea.js +0 -72
- package/lib/components/icons/RespArea.js.map +0 -1
- package/lib/components/icons/TableIcons.js +0 -53
- package/lib/components/icons/TableIcons.js.map +0 -1
- package/lib/components/icons/TextAlign.js +0 -157
- package/lib/components/icons/TextAlign.js.map +0 -1
- package/lib/components/image/AltDialog.js +0 -98
- package/lib/components/image/AltDialog.js.map +0 -1
- package/lib/components/image/ImageToolbar.js +0 -137
- package/lib/components/image/ImageToolbar.js.map +0 -1
- package/lib/components/image/InsertImageHandler.js +0 -135
- package/lib/components/image/InsertImageHandler.js.map +0 -1
- package/lib/components/media/MediaDialog.js +0 -594
- package/lib/components/media/MediaDialog.js.map +0 -1
- package/lib/components/media/MediaToolbar.js +0 -74
- package/lib/components/media/MediaToolbar.js.map +0 -1
- package/lib/components/media/MediaWrapper.js +0 -67
- package/lib/components/media/MediaWrapper.js.map +0 -1
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
- package/lib/components/respArea/DragInTheBlank/choice.js +0 -250
- package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
- package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
- package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
- package/lib/components/respArea/InlineDropdown.js +0 -165
- package/lib/components/respArea/InlineDropdown.js.map +0 -1
- package/lib/components/respArea/MathTemplated.js +0 -130
- package/lib/components/respArea/MathTemplated.js.map +0 -1
- package/lib/components/respArea/ToolbarIcon.js +0 -81
- package/lib/components/respArea/ToolbarIcon.js.map +0 -1
- package/lib/constants.js +0 -11
- package/lib/constants.js.map +0 -1
- package/lib/extensions/css.js +0 -217
- package/lib/extensions/css.js.map +0 -1
- package/lib/extensions/custom-toolbar-wrapper.js +0 -92
- package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
- package/lib/extensions/div-node.js +0 -83
- package/lib/extensions/div-node.js.map +0 -1
- package/lib/extensions/ensure-empty-root-div.js +0 -48
- package/lib/extensions/ensure-empty-root-div.js.map +0 -1
- package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
- package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
- package/lib/extensions/extended-list-item.js +0 -15
- package/lib/extensions/extended-list-item.js.map +0 -1
- package/lib/extensions/extended-table-cell.js +0 -22
- package/lib/extensions/extended-table-cell.js.map +0 -1
- package/lib/extensions/extended-table.js +0 -75
- package/lib/extensions/extended-table.js.map +0 -1
- package/lib/extensions/heading-paragraph.js +0 -61
- package/lib/extensions/heading-paragraph.js.map +0 -1
- package/lib/extensions/image-component.js +0 -348
- package/lib/extensions/image-component.js.map +0 -1
- package/lib/extensions/image.js +0 -134
- package/lib/extensions/image.js.map +0 -1
- package/lib/extensions/index.js +0 -46
- package/lib/extensions/index.js.map +0 -1
- package/lib/extensions/math.js +0 -343
- package/lib/extensions/math.js.map +0 -1
- package/lib/extensions/media.js +0 -243
- package/lib/extensions/media.js.map +0 -1
- package/lib/extensions/responseArea.js +0 -446
- package/lib/extensions/responseArea.js.map +0 -1
- package/lib/index.js +0 -30
- package/lib/index.js.map +0 -1
- package/lib/styles/editorContainerStyles.js +0 -137
- package/lib/styles/editorContainerStyles.js.map +0 -1
- package/lib/theme.js +0 -8
- package/lib/theme.js.map +0 -1
- package/lib/utils/helper.js +0 -73
- package/lib/utils/helper.js.map +0 -1
- package/lib/utils/size.js +0 -26
- package/lib/utils/size.js.map +0 -1
- package/src/__tests__/EditableHtml.test.jsx +0 -474
- package/src/__tests__/constants.test.js +0 -19
- package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
- package/src/__tests__/extensions.test.js +0 -208
- package/src/__tests__/index.test.jsx +0 -154
- package/src/__tests__/size-utils.test.js +0 -64
- package/src/__tests__/theme.test.js +0 -17
- package/src/components/CharacterPicker.jsx +0 -200
- package/src/components/EditableHtml.jsx +0 -438
- package/src/components/MenuBar.jsx +0 -549
- package/src/components/TiptapContainer.jsx +0 -219
- package/src/components/__tests__/AltDialog.test.jsx +0 -147
- package/src/components/__tests__/CharacterPicker.test.jsx +0 -219
- package/src/components/__tests__/CssIcon.test.jsx +0 -46
- package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
- package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
- package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
- package/src/components/__tests__/InlineDropdown.test.jsx +0 -380
- package/src/components/__tests__/InsertImageHandler.test.js +0 -161
- package/src/components/__tests__/MediaDialog.test.jsx +0 -293
- package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
- package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
- package/src/components/__tests__/MenuBar.test.jsx +0 -249
- package/src/components/__tests__/RespArea.test.jsx +0 -122
- package/src/components/__tests__/TableIcons.test.jsx +0 -149
- package/src/components/__tests__/TextAlign.test.jsx +0 -167
- package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
- package/src/components/__tests__/characterUtils.test.js +0 -166
- package/src/components/__tests__/choice.test.jsx +0 -171
- package/src/components/__tests__/custom-popper.test.jsx +0 -82
- package/src/components/__tests__/done-button.test.jsx +0 -54
- package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
- package/src/components/characters/characterUtils.js +0 -447
- package/src/components/characters/custom-popper.js +0 -38
- package/src/components/common/done-button.jsx +0 -27
- package/src/components/common/toolbar-buttons.jsx +0 -122
- package/src/components/icons/CssIcon.jsx +0 -15
- package/src/components/icons/RespArea.jsx +0 -71
- package/src/components/icons/TableIcons.jsx +0 -52
- package/src/components/icons/TextAlign.jsx +0 -114
- package/src/components/image/AltDialog.jsx +0 -82
- package/src/components/image/ImageToolbar.jsx +0 -99
- package/src/components/image/InsertImageHandler.js +0 -107
- package/src/components/media/MediaDialog.jsx +0 -596
- package/src/components/media/MediaToolbar.jsx +0 -49
- package/src/components/media/MediaWrapper.jsx +0 -39
- package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
- package/src/components/respArea/DragInTheBlank/choice.jsx +0 -256
- package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
- package/src/components/respArea/InlineDropdown.jsx +0 -167
- package/src/components/respArea/MathTemplated.jsx +0 -124
- package/src/components/respArea/ToolbarIcon.jsx +0 -66
- package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
- package/src/constants.js +0 -5
- package/src/extensions/__tests__/css.test.js +0 -196
- package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
- package/src/extensions/__tests__/divNode.test.js +0 -87
- package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
- package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
- package/src/extensions/__tests__/extended-list-item.test.js +0 -13
- package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
- package/src/extensions/__tests__/extended-table.test.js +0 -183
- package/src/extensions/__tests__/image-component.test.jsx +0 -345
- package/src/extensions/__tests__/image.test.js +0 -237
- package/src/extensions/__tests__/math.test.js +0 -459
- package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
- package/src/extensions/__tests__/media.test.js +0 -271
- package/src/extensions/__tests__/responseArea.test.js +0 -601
- package/src/extensions/css.js +0 -220
- package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
- package/src/extensions/div-node.js +0 -86
- package/src/extensions/ensure-empty-root-div.js +0 -47
- package/src/extensions/ensure-list-item-content-is-div.js +0 -62
- package/src/extensions/extended-list-item.js +0 -10
- package/src/extensions/extended-table-cell.js +0 -19
- package/src/extensions/extended-table.js +0 -60
- package/src/extensions/heading-paragraph.js +0 -53
- package/src/extensions/image-component.jsx +0 -338
- package/src/extensions/image.js +0 -109
- package/src/extensions/index.js +0 -81
- package/src/extensions/math.js +0 -327
- package/src/extensions/media.js +0 -188
- package/src/extensions/responseArea.js +0 -401
- package/src/index.jsx +0 -5
- package/src/styles/editorContainerStyles.js +0 -145
- package/src/theme.js +0 -1
- package/src/utils/__tests__/helper.test.js +0 -126
- package/src/utils/helper.js +0 -69
- package/src/utils/size.js +0 -32
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState, useRef } from 'react';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
3
|
-
import { color } from '@pie-lib/render-ui';
|
|
4
|
-
import { valueToSize } from '../utils/size';
|
|
5
|
-
|
|
6
|
-
import StyledMenuBar from './MenuBar';
|
|
7
|
-
|
|
8
|
-
const StyledRoot = styled('div', {
|
|
9
|
-
shouldForwardProp: (prop) => !['noBorder', 'error'].includes(prop),
|
|
10
|
-
})(({ theme, noBorder, error }) => ({
|
|
11
|
-
position: 'relative',
|
|
12
|
-
padding: '0px',
|
|
13
|
-
border: noBorder ? 'none' : '1px solid #ccc',
|
|
14
|
-
borderRadius: '4px',
|
|
15
|
-
cursor: 'text',
|
|
16
|
-
'& [data-slate-editor="true"]': {
|
|
17
|
-
wordBreak: 'break-word',
|
|
18
|
-
overflow: 'visible',
|
|
19
|
-
maxHeight: '500px',
|
|
20
|
-
padding: '5px',
|
|
21
|
-
},
|
|
22
|
-
'&:first-child': {
|
|
23
|
-
marginTop: 0,
|
|
24
|
-
},
|
|
25
|
-
'& ul, & ol': {
|
|
26
|
-
padding: '0 1rem',
|
|
27
|
-
margin: '1.25rem 1rem 1.25rem 0.4rem',
|
|
28
|
-
},
|
|
29
|
-
'& ul li p, & ol li p': {
|
|
30
|
-
marginTop: '0.25em',
|
|
31
|
-
marginBottom: '0.25em',
|
|
32
|
-
},
|
|
33
|
-
'& h1, & h2, & h3, & h4, & h5, & h6': {
|
|
34
|
-
lineHeight: 1.1,
|
|
35
|
-
marginTop: '2.5rem',
|
|
36
|
-
textWrap: 'pretty',
|
|
37
|
-
},
|
|
38
|
-
'& h1, & h2': {
|
|
39
|
-
marginTop: '3.5rem',
|
|
40
|
-
marginBottom: '1.5rem',
|
|
41
|
-
},
|
|
42
|
-
'& h1': {
|
|
43
|
-
fontSize: '1.4rem',
|
|
44
|
-
},
|
|
45
|
-
'& h2': {
|
|
46
|
-
fontSize: '1.2rem',
|
|
47
|
-
},
|
|
48
|
-
'& h3': {
|
|
49
|
-
fontSize: '1.1rem',
|
|
50
|
-
},
|
|
51
|
-
'& h4, & h5, & h6': {
|
|
52
|
-
fontSize: '1rem',
|
|
53
|
-
},
|
|
54
|
-
'& code': {
|
|
55
|
-
backgroundColor: 'var(--purple-light)',
|
|
56
|
-
borderRadius: '0.4rem',
|
|
57
|
-
color: 'var(--black)',
|
|
58
|
-
fontSize: '0.85rem',
|
|
59
|
-
padding: '0.25em 0.3em',
|
|
60
|
-
},
|
|
61
|
-
'& pre': {
|
|
62
|
-
background: 'var(--black)',
|
|
63
|
-
borderRadius: '0.5rem',
|
|
64
|
-
color: 'var(--white)',
|
|
65
|
-
fontFamily: '\'JetBrainsMono\', monospace',
|
|
66
|
-
margin: '1.5rem 0',
|
|
67
|
-
padding: '0.75rem 1rem',
|
|
68
|
-
'& code': {
|
|
69
|
-
background: 'none',
|
|
70
|
-
color: 'inherit',
|
|
71
|
-
fontSize: '0.8rem',
|
|
72
|
-
padding: 0,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
'& blockquote': {
|
|
76
|
-
background: '#f9f9f9',
|
|
77
|
-
borderLeft: '5px solid #ccc',
|
|
78
|
-
margin: '1.5em 10px',
|
|
79
|
-
padding: '.5em 10px',
|
|
80
|
-
},
|
|
81
|
-
'& p': {
|
|
82
|
-
margin: '0',
|
|
83
|
-
},
|
|
84
|
-
'& table': {
|
|
85
|
-
tableLayout: 'fixed',
|
|
86
|
-
width: '100%',
|
|
87
|
-
borderCollapse: 'collapse',
|
|
88
|
-
color: color.text(),
|
|
89
|
-
backgroundColor: color.background(),
|
|
90
|
-
},
|
|
91
|
-
'& table:not([border="1"]) tr': {
|
|
92
|
-
borderTop: '1px solid #dfe2e5',
|
|
93
|
-
},
|
|
94
|
-
'& td, th': {
|
|
95
|
-
padding: '.6em 1em',
|
|
96
|
-
textAlign: 'center',
|
|
97
|
-
},
|
|
98
|
-
'& table:not([border="1"]) td, th': {
|
|
99
|
-
border: '1px solid #dfe2e5',
|
|
100
|
-
},
|
|
101
|
-
...(error && {
|
|
102
|
-
border: `2px solid ${theme.palette.error.main} !important`,
|
|
103
|
-
}),
|
|
104
|
-
}));
|
|
105
|
-
|
|
106
|
-
const StyledEditorHolder = styled('div', {
|
|
107
|
-
shouldForwardProp: (prop) => !['disableScrollbar', 'highlightShape'].includes(prop),
|
|
108
|
-
})(({ theme, disableScrollbar, highlightShape }) => ({
|
|
109
|
-
position: 'relative',
|
|
110
|
-
padding: '0px',
|
|
111
|
-
overflowY: 'auto',
|
|
112
|
-
color: color.text(),
|
|
113
|
-
backgroundColor: highlightShape ? theme.palette.action.selected : color.background(),
|
|
114
|
-
...(disableScrollbar && {
|
|
115
|
-
'&::-webkit-scrollbar': {
|
|
116
|
-
display: 'none',
|
|
117
|
-
},
|
|
118
|
-
scrollbarWidth: 'none',
|
|
119
|
-
'-ms-overflow-style': 'none',
|
|
120
|
-
}),
|
|
121
|
-
}));
|
|
122
|
-
|
|
123
|
-
const StyledChildren = styled('div', {
|
|
124
|
-
shouldForwardProp: (prop) => prop !== 'noPadding',
|
|
125
|
-
})(({ noPadding }) => ({
|
|
126
|
-
padding: noPadding ? 0 : '10px 8px',
|
|
127
|
-
}));
|
|
128
|
-
|
|
129
|
-
function TiptapContainer(props) {
|
|
130
|
-
const [adjustedWidth, setAdjustedWidth] = useState(null);
|
|
131
|
-
const rootRef = useRef(null);
|
|
132
|
-
const {
|
|
133
|
-
editor,
|
|
134
|
-
disabled,
|
|
135
|
-
children,
|
|
136
|
-
disableScrollbar,
|
|
137
|
-
activePlugins,
|
|
138
|
-
toolbarOpts,
|
|
139
|
-
responseAreaProps,
|
|
140
|
-
autoFocus,
|
|
141
|
-
minWidth,
|
|
142
|
-
width,
|
|
143
|
-
maxWidth,
|
|
144
|
-
minHeight,
|
|
145
|
-
height,
|
|
146
|
-
maxHeight,
|
|
147
|
-
highlightShape,
|
|
148
|
-
ref,
|
|
149
|
-
} = props;
|
|
150
|
-
|
|
151
|
-
useEffect(() => {
|
|
152
|
-
if (editor && rootRef.current) {
|
|
153
|
-
editor._tiptapContainerEl = rootRef.current;
|
|
154
|
-
}
|
|
155
|
-
}, [editor, rootRef.current]);
|
|
156
|
-
|
|
157
|
-
useEffect(() => {
|
|
158
|
-
if (editor && autoFocus) {
|
|
159
|
-
Promise.resolve().then(() => {
|
|
160
|
-
editor.commands.focus('end');
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
}, [editor, autoFocus]);
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
if (props.adjustWidthForLimit) {
|
|
167
|
-
const el = document.createElement('p');
|
|
168
|
-
|
|
169
|
-
el.style.visibility = 'hidden';
|
|
170
|
-
el.style.position = 'absolute';
|
|
171
|
-
el.textContent = 'W'.repeat(props.charactersLimit);
|
|
172
|
-
|
|
173
|
-
rootRef.current.appendChild(el);
|
|
174
|
-
|
|
175
|
-
setAdjustedWidth(`${el.offsetWidth + 27}px`);
|
|
176
|
-
|
|
177
|
-
el.remove();
|
|
178
|
-
}
|
|
179
|
-
}, [props.adjustWidthForLimit, props.charactersLimit]);
|
|
180
|
-
|
|
181
|
-
const sizeStyle = useMemo(
|
|
182
|
-
() => ({
|
|
183
|
-
width: valueToSize(adjustedWidth || width),
|
|
184
|
-
minWidth: valueToSize(minWidth),
|
|
185
|
-
maxWidth: valueToSize(maxWidth),
|
|
186
|
-
height: valueToSize(height),
|
|
187
|
-
minHeight: valueToSize(minHeight),
|
|
188
|
-
maxHeight: valueToSize(maxHeight),
|
|
189
|
-
}),
|
|
190
|
-
[adjustedWidth, minWidth, width, maxWidth, minHeight, height, maxHeight],
|
|
191
|
-
);
|
|
192
|
-
|
|
193
|
-
return (
|
|
194
|
-
<StyledRoot
|
|
195
|
-
noBorder={toolbarOpts && toolbarOpts.noBorder}
|
|
196
|
-
error={toolbarOpts && toolbarOpts.error}
|
|
197
|
-
className={props.className}
|
|
198
|
-
style={{ width: sizeStyle.width, minWidth: sizeStyle.minWidth, maxWidth: sizeStyle.maxWidth }}
|
|
199
|
-
ref={rootRef}
|
|
200
|
-
>
|
|
201
|
-
<StyledEditorHolder disableScrollbar={disableScrollbar} highlightShape={highlightShape}>
|
|
202
|
-
<StyledChildren noPadding={toolbarOpts && toolbarOpts.noPadding}>{children}</StyledChildren>
|
|
203
|
-
</StyledEditorHolder>
|
|
204
|
-
|
|
205
|
-
{editor && (
|
|
206
|
-
<StyledMenuBar
|
|
207
|
-
editor={editor}
|
|
208
|
-
responseAreaProps={responseAreaProps}
|
|
209
|
-
toolbarOpts={toolbarOpts}
|
|
210
|
-
activePlugins={activePlugins}
|
|
211
|
-
onChange={props.onChange}
|
|
212
|
-
autoWidthToolbar={props.autoWidthToolbar}
|
|
213
|
-
/>
|
|
214
|
-
)}
|
|
215
|
-
</StyledRoot>
|
|
216
|
-
);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
export default TiptapContainer;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render } from '@testing-library/react';
|
|
3
|
-
import { AltDialog } from '../image/AltDialog';
|
|
4
|
-
|
|
5
|
-
jest.mock('@mui/material/Dialog', () => ({
|
|
6
|
-
__esModule: true,
|
|
7
|
-
default: ({ children, open, id }) => open && <div id={id}>{children}</div>,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock('@mui/material/DialogContent', () => ({
|
|
11
|
-
__esModule: true,
|
|
12
|
-
default: ({ children }) => <div>{children}</div>,
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
jest.mock('@mui/material/DialogActions', () => ({
|
|
16
|
-
__esModule: true,
|
|
17
|
-
default: ({ children }) => <div>{children}</div>,
|
|
18
|
-
}));
|
|
19
|
-
|
|
20
|
-
jest.mock('@mui/material/Button', () => ({
|
|
21
|
-
__esModule: true,
|
|
22
|
-
default: ({ children, onClick }) => <button onClick={onClick}>{children}</button>,
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
jest.mock('@mui/material/TextField', () => ({
|
|
26
|
-
__esModule: true,
|
|
27
|
-
default: ({ value, onChange, placeholder, helperText, FormHelperTextProps, multiline }) => (
|
|
28
|
-
<div className="MuiTextField-root">
|
|
29
|
-
<textarea value={value || ''} onChange={onChange} placeholder={placeholder} data-multiline={multiline} />
|
|
30
|
-
{helperText && <div style={FormHelperTextProps?.style}>{helperText}</div>}
|
|
31
|
-
</div>
|
|
32
|
-
),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
jest.mock('@mui/icons-material/ArrowBackIos', () => ({
|
|
36
|
-
__esModule: true,
|
|
37
|
-
default: () => <svg data-testid="arrow-back-icon" />,
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
describe('AltDialog', () => {
|
|
41
|
-
const defaultProps = {
|
|
42
|
-
onDone: jest.fn(),
|
|
43
|
-
alt: 'Initial alt text',
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
beforeEach(() => {
|
|
47
|
-
jest.clearAllMocks();
|
|
48
|
-
document.body.innerHTML = '';
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('renders without crashing', () => {
|
|
52
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
53
|
-
expect(container).toBeInTheDocument();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('renders with initial alt text', () => {
|
|
57
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
58
|
-
const textarea = container.querySelector('textarea');
|
|
59
|
-
expect(textarea.value).toBe('Initial alt text');
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('renders placeholder text', () => {
|
|
63
|
-
const { getByPlaceholderText } = render(<AltDialog {...defaultProps} alt="" />);
|
|
64
|
-
expect(getByPlaceholderText('Enter an Alt Text description of this image')).toBeInTheDocument();
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('renders helper text', () => {
|
|
68
|
-
const { getByText } = render(<AltDialog {...defaultProps} />);
|
|
69
|
-
expect(
|
|
70
|
-
getByText(
|
|
71
|
-
'Users with visual limitations rely on Alt Text, since screen readers cannot otherwise describe the contents of an image.',
|
|
72
|
-
),
|
|
73
|
-
).toBeInTheDocument();
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('renders Done button', () => {
|
|
77
|
-
const { getByText } = render(<AltDialog {...defaultProps} />);
|
|
78
|
-
expect(getByText('Done')).toBeInTheDocument();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('renders ArrowBackIos icon', () => {
|
|
82
|
-
const { getByTestId } = render(<AltDialog {...defaultProps} />);
|
|
83
|
-
expect(getByTestId('arrow-back-icon')).toBeInTheDocument();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('updates value on text field change', () => {
|
|
87
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
88
|
-
const textarea = container.querySelector('textarea');
|
|
89
|
-
fireEvent.change(textarea, { target: { value: 'New alt text' } });
|
|
90
|
-
expect(textarea.value).toBe('New alt text');
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('calls onDone with value when Done button is clicked', () => {
|
|
94
|
-
const onDone = jest.fn();
|
|
95
|
-
// Mock document.querySelectorAll to avoid DOM manipulation issues
|
|
96
|
-
const mockQuerySelectorAll = jest.spyOn(document, 'querySelectorAll').mockReturnValue([]);
|
|
97
|
-
|
|
98
|
-
const { getByText, container } = render(<AltDialog {...defaultProps} onDone={onDone} />);
|
|
99
|
-
const textarea = container.querySelector('textarea');
|
|
100
|
-
fireEvent.change(textarea, { target: { value: 'Updated alt text' } });
|
|
101
|
-
fireEvent.click(getByText('Done'));
|
|
102
|
-
expect(onDone).toHaveBeenCalledWith('Updated alt text');
|
|
103
|
-
|
|
104
|
-
mockQuerySelectorAll.mockRestore();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it('closes dialog when Done button is clicked', () => {
|
|
108
|
-
// Mock document.querySelectorAll to avoid DOM manipulation issues
|
|
109
|
-
const mockQuerySelectorAll = jest.spyOn(document, 'querySelectorAll').mockReturnValue([]);
|
|
110
|
-
|
|
111
|
-
const { getByText, container } = render(<AltDialog {...defaultProps} />);
|
|
112
|
-
const dialog = container.querySelector('#text-dialog');
|
|
113
|
-
expect(dialog).toBeInTheDocument();
|
|
114
|
-
fireEvent.click(getByText('Done'));
|
|
115
|
-
|
|
116
|
-
mockQuerySelectorAll.mockRestore();
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('dialog is open', () => {
|
|
120
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
121
|
-
const dialog = container.querySelector('[id="text-dialog"]');
|
|
122
|
-
expect(dialog).toBeInTheDocument();
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('has correct dialog props', () => {
|
|
126
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
127
|
-
const dialog = container.querySelector('[id="text-dialog"]');
|
|
128
|
-
expect(dialog).toBeInTheDocument();
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it('text field is multiline', () => {
|
|
132
|
-
const { container } = render(<AltDialog {...defaultProps} />);
|
|
133
|
-
const textarea = container.querySelector('textarea');
|
|
134
|
-
expect(textarea.getAttribute('data-multiline')).toBe('true');
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('renders without alt text', () => {
|
|
138
|
-
const { getByPlaceholderText } = render(<AltDialog {...defaultProps} alt={undefined} />);
|
|
139
|
-
expect(getByPlaceholderText('Enter an Alt Text description of this image')).toBeInTheDocument();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('handles empty alt text', () => {
|
|
143
|
-
const { container } = render(<AltDialog {...defaultProps} alt="" />);
|
|
144
|
-
const textarea = container.querySelector('textarea');
|
|
145
|
-
expect(textarea.value).toBe('');
|
|
146
|
-
});
|
|
147
|
-
});
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { fireEvent, render, waitFor } from '@testing-library/react';
|
|
3
|
-
import { CharacterIcon, CharacterPicker } from '../CharacterPicker';
|
|
4
|
-
|
|
5
|
-
jest.mock('react-dom', () => ({
|
|
6
|
-
...jest.requireActual('react-dom'),
|
|
7
|
-
createPortal: (node) => node,
|
|
8
|
-
}));
|
|
9
|
-
|
|
10
|
-
jest.mock('@pie-lib/math-toolbar', () => ({
|
|
11
|
-
PureToolbar: ({ onChange, onDone, additionalKeys }) => (
|
|
12
|
-
<div data-testid="pure-toolbar">
|
|
13
|
-
<button onClick={() => onChange('á')} data-testid="char-button">
|
|
14
|
-
á
|
|
15
|
-
</button>
|
|
16
|
-
<button onClick={onDone} data-testid="done-button">
|
|
17
|
-
Done
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
),
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
jest.mock('../characters/custom-popper', () => ({
|
|
24
|
-
__esModule: true,
|
|
25
|
-
default: ({ children, onClose }) => (
|
|
26
|
-
<div data-testid="custom-popper">
|
|
27
|
-
{children}
|
|
28
|
-
<button onClick={onClose} data-testid="close-popper">
|
|
29
|
-
Close
|
|
30
|
-
</button>
|
|
31
|
-
</div>
|
|
32
|
-
),
|
|
33
|
-
}));
|
|
34
|
-
|
|
35
|
-
describe('CharacterIcon', () => {
|
|
36
|
-
it('renders with letter', () => {
|
|
37
|
-
const { getByText } = render(<CharacterIcon letter="ñ" />);
|
|
38
|
-
expect(getByText('ñ')).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renders with correct styling', () => {
|
|
42
|
-
const { container } = render(<CharacterIcon letter="€" />);
|
|
43
|
-
const div = container.firstChild;
|
|
44
|
-
expect(div).toHaveStyle({ fontSize: '24px', lineHeight: '24px' });
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
describe('CharacterPicker', () => {
|
|
49
|
-
const mockEditor = {
|
|
50
|
-
chain: jest.fn(() => ({
|
|
51
|
-
focus: jest.fn(() => ({
|
|
52
|
-
insertContent: jest.fn(() => ({ run: jest.fn() })),
|
|
53
|
-
})),
|
|
54
|
-
})),
|
|
55
|
-
options: {
|
|
56
|
-
element: document.createElement('div'),
|
|
57
|
-
},
|
|
58
|
-
view: {
|
|
59
|
-
coordsAtPos: jest.fn(() => ({ top: 100, left: 50 })),
|
|
60
|
-
dom: document.createElement('div'),
|
|
61
|
-
},
|
|
62
|
-
state: {
|
|
63
|
-
selection: { from: 0 },
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
beforeEach(() => {
|
|
68
|
-
jest.clearAllMocks();
|
|
69
|
-
// Reset the element to avoid "Cannot redefine property" error
|
|
70
|
-
mockEditor.options.element = document.createElement('div');
|
|
71
|
-
Object.defineProperty(mockEditor.options.element, 'getBoundingClientRect', {
|
|
72
|
-
value: jest.fn(() => ({ top: 0, left: 0, height: 100 })),
|
|
73
|
-
configurable: true,
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('returns null when opts has no characters', () => {
|
|
78
|
-
const { container } = render(<CharacterPicker editor={mockEditor} opts={{}} onClose={jest.fn()} />);
|
|
79
|
-
expect(container.firstChild).toBeNull();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('returns null when opts is not provided', () => {
|
|
83
|
-
const { container } = render(<CharacterPicker editor={mockEditor} opts={null} onClose={jest.fn()} />);
|
|
84
|
-
expect(container.firstChild).toBeNull();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('renders character picker with spanish config', () => {
|
|
88
|
-
const opts = {
|
|
89
|
-
language: 'spanish',
|
|
90
|
-
characters: [['á', 'é', 'í']],
|
|
91
|
-
};
|
|
92
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
93
|
-
expect(getByTestId('pure-toolbar')).toBeInTheDocument();
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('renders character picker with special config', () => {
|
|
97
|
-
const opts = {
|
|
98
|
-
language: 'special',
|
|
99
|
-
characters: [['€', '£']],
|
|
100
|
-
};
|
|
101
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
102
|
-
expect(getByTestId('pure-toolbar')).toBeInTheDocument();
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
it('handles character insertion', () => {
|
|
106
|
-
const opts = {
|
|
107
|
-
characters: [['á', 'é']],
|
|
108
|
-
};
|
|
109
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
110
|
-
fireEvent.click(getByTestId('char-button'));
|
|
111
|
-
expect(mockEditor.chain).toHaveBeenCalled();
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('calls onClose when done button is clicked', () => {
|
|
115
|
-
const onClose = jest.fn();
|
|
116
|
-
const opts = {
|
|
117
|
-
characters: [['á', 'é']],
|
|
118
|
-
};
|
|
119
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={onClose} />);
|
|
120
|
-
fireEvent.click(getByTestId('done-button'));
|
|
121
|
-
expect(onClose).toHaveBeenCalled();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('closes on outside click', async () => {
|
|
125
|
-
const onClose = jest.fn();
|
|
126
|
-
const opts = {
|
|
127
|
-
characters: [['á', 'é']],
|
|
128
|
-
};
|
|
129
|
-
render(<CharacterPicker editor={mockEditor} opts={opts} onClose={onClose} />);
|
|
130
|
-
|
|
131
|
-
await waitFor(() => {
|
|
132
|
-
setTimeout(() => {
|
|
133
|
-
fireEvent.click(document.body);
|
|
134
|
-
}, 0);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
expect(onClose).toHaveBeenCalled();
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it('does not close when clicking inside picker', async () => {
|
|
141
|
-
const onClose = jest.fn();
|
|
142
|
-
const opts = {
|
|
143
|
-
characters: [['á', 'é']],
|
|
144
|
-
};
|
|
145
|
-
const { container } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={onClose} />);
|
|
146
|
-
|
|
147
|
-
await waitFor(() => {
|
|
148
|
-
const picker = container.querySelector('.insert-character-dialog');
|
|
149
|
-
if (picker) {
|
|
150
|
-
fireEvent.mouseDown(picker);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
expect(onClose).not.toHaveBeenCalled();
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('renders with custom opts structure', () => {
|
|
158
|
-
const opts = {
|
|
159
|
-
characters: [
|
|
160
|
-
[
|
|
161
|
-
{ name: 'a', write: 'á', label: 'á' },
|
|
162
|
-
{ name: 'e', write: 'é', label: 'é' },
|
|
163
|
-
],
|
|
164
|
-
],
|
|
165
|
-
};
|
|
166
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
167
|
-
expect(getByTestId('pure-toolbar')).toBeInTheDocument();
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('renders with hasPreview option', () => {
|
|
171
|
-
const opts = {
|
|
172
|
-
hasPreview: true,
|
|
173
|
-
characters: [
|
|
174
|
-
[
|
|
175
|
-
{
|
|
176
|
-
name: 'euro',
|
|
177
|
-
write: '€',
|
|
178
|
-
label: '€',
|
|
179
|
-
description: 'Euro sign',
|
|
180
|
-
unicode: 'U+20AC',
|
|
181
|
-
},
|
|
182
|
-
],
|
|
183
|
-
],
|
|
184
|
-
};
|
|
185
|
-
const { getByTestId } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
186
|
-
expect(getByTestId('pure-toolbar')).toBeInTheDocument();
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('calculates position correctly', () => {
|
|
190
|
-
const opts = {
|
|
191
|
-
characters: [['á']],
|
|
192
|
-
};
|
|
193
|
-
const { container } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
194
|
-
const dialog = container.querySelector('.insert-character-dialog');
|
|
195
|
-
expect(dialog).toHaveStyle({ position: 'absolute' });
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it('adds data-toolbar-for attribute with editor instanceId', () => {
|
|
199
|
-
const editorWithInstanceId = {
|
|
200
|
-
...mockEditor,
|
|
201
|
-
instanceId: 'editor-123',
|
|
202
|
-
};
|
|
203
|
-
const opts = {
|
|
204
|
-
characters: [['á', 'é']],
|
|
205
|
-
};
|
|
206
|
-
const { container } = render(<CharacterPicker editor={editorWithInstanceId} opts={opts} onClose={jest.fn()} />);
|
|
207
|
-
const dialog = container.querySelector('.insert-character-dialog');
|
|
208
|
-
expect(dialog).toHaveAttribute('data-toolbar-for', 'editor-123');
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('renders without instanceId gracefully', () => {
|
|
212
|
-
const opts = {
|
|
213
|
-
characters: [['á', 'é']],
|
|
214
|
-
};
|
|
215
|
-
const { container } = render(<CharacterPicker editor={mockEditor} opts={opts} onClose={jest.fn()} />);
|
|
216
|
-
const dialog = container.querySelector('.insert-character-dialog');
|
|
217
|
-
expect(dialog).toBeInTheDocument();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import CssIcon from '../icons/CssIcon';
|
|
4
|
-
|
|
5
|
-
describe('CssIcon', () => {
|
|
6
|
-
it('renders without crashing', () => {
|
|
7
|
-
const { container } = render(<CssIcon />);
|
|
8
|
-
expect(container).toBeInTheDocument();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('renders CSS text', () => {
|
|
12
|
-
const { getByText } = render(<CssIcon />);
|
|
13
|
-
expect(getByText('CSS')).toBeInTheDocument();
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it('applies correct font family', () => {
|
|
17
|
-
const { getByText } = render(<CssIcon />);
|
|
18
|
-
const element = getByText('CSS');
|
|
19
|
-
// Font family is applied via styled component, just verify text renders
|
|
20
|
-
expect(element).toBeInTheDocument();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
it('applies bold font weight', () => {
|
|
24
|
-
const { getByText } = render(<CssIcon />);
|
|
25
|
-
const element = getByText('CSS');
|
|
26
|
-
expect(element).toHaveStyle({ fontWeight: 'bold' });
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('has correct line height', () => {
|
|
30
|
-
const { getByText } = render(<CssIcon />);
|
|
31
|
-
const element = getByText('CSS');
|
|
32
|
-
expect(element).toHaveStyle({ lineHeight: '14px' });
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('has relative positioning', () => {
|
|
36
|
-
const { getByText } = render(<CssIcon />);
|
|
37
|
-
const element = getByText('CSS');
|
|
38
|
-
expect(element).toHaveStyle({ position: 'relative' });
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('has nowrap white space', () => {
|
|
42
|
-
const { getByText } = render(<CssIcon />);
|
|
43
|
-
const element = getByText('CSS');
|
|
44
|
-
expect(element).toHaveStyle({ whiteSpace: 'nowrap' });
|
|
45
|
-
});
|
|
46
|
-
});
|