@pie-lib/editable-html-tip-tap 2.1.2-next.3 → 2.1.2-next.30
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 +64 -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/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -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 +56 -40
- package/CHANGELOG.json +0 -32
- package/CHANGELOG.md +0 -2532
- 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,124 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { NodeViewWrapper } from '@tiptap/react';
|
|
4
|
-
import { mq } from '@pie-lib/math-input';
|
|
5
|
-
import { styled } from '@mui/material/styles';
|
|
6
|
-
|
|
7
|
-
const StyledSpanContainer = styled('span')(() => ({
|
|
8
|
-
display: 'inline-flex',
|
|
9
|
-
border: '1px solid #C0C3CF',
|
|
10
|
-
margin: '1px 5px',
|
|
11
|
-
cursor: 'pointer',
|
|
12
|
-
alignItems: 'center',
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
minWidth: '50px',
|
|
15
|
-
minHeight: '36px',
|
|
16
|
-
height: 'fit-content',
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
const StyledResponseBox = styled('div')(({ theme }) => ({
|
|
20
|
-
background: theme.palette.grey['A100'],
|
|
21
|
-
color: theme.palette.grey['A700'],
|
|
22
|
-
display: 'inline-flex',
|
|
23
|
-
borderRight: '2px solid #C0C3CF',
|
|
24
|
-
boxSizing: 'border-box',
|
|
25
|
-
overflow: 'hidden',
|
|
26
|
-
fontSize: '12px',
|
|
27
|
-
minHeight: '36px',
|
|
28
|
-
height: '100%',
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
fontFamily: 'Symbola, Times New Roman, serif',
|
|
31
|
-
padding: '0 2px',
|
|
32
|
-
}));
|
|
33
|
-
|
|
34
|
-
const StyledMathBlock = styled('div')(() => ({
|
|
35
|
-
flex: 8,
|
|
36
|
-
color: 'var(--pie-text, black)',
|
|
37
|
-
padding: '4px !important',
|
|
38
|
-
display: 'flex',
|
|
39
|
-
alignItems: 'center',
|
|
40
|
-
justifyContent: 'center',
|
|
41
|
-
backgroundColor: 'var(--pie-background, rgba(255, 255, 255, 0))',
|
|
42
|
-
'& > .mq-math-mode sup.mq-nthroot': {
|
|
43
|
-
fontSize: '70% !important',
|
|
44
|
-
verticalAlign: '1em !important',
|
|
45
|
-
},
|
|
46
|
-
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
47
|
-
borderTop: '0.07em solid',
|
|
48
|
-
marginLeft: '-1.5px',
|
|
49
|
-
marginTop: '-2px !important',
|
|
50
|
-
paddingTop: '5px !important',
|
|
51
|
-
},
|
|
52
|
-
'& .mq-overarrow-inner': {
|
|
53
|
-
paddingTop: '0 !important',
|
|
54
|
-
border: 'none !important',
|
|
55
|
-
},
|
|
56
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
57
|
-
marginTop: '0px',
|
|
58
|
-
minWidth: '1.23em',
|
|
59
|
-
'& *': {
|
|
60
|
-
lineHeight: '1 !important',
|
|
61
|
-
},
|
|
62
|
-
'&:before': {
|
|
63
|
-
top: '-0.4em',
|
|
64
|
-
left: '-1px',
|
|
65
|
-
},
|
|
66
|
-
'&:after': {
|
|
67
|
-
top: '0px !important',
|
|
68
|
-
position: 'absolute !important',
|
|
69
|
-
right: '-2px',
|
|
70
|
-
},
|
|
71
|
-
'&.mq-empty:after': {
|
|
72
|
-
top: '-0.45em',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
76
|
-
'&:before': {
|
|
77
|
-
top: '-0.4em',
|
|
78
|
-
right: '-1px',
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
'& .mq-overarrow-inner-right': {
|
|
82
|
-
display: 'none !important',
|
|
83
|
-
},
|
|
84
|
-
'& .mq-overarrow-inner-left': {
|
|
85
|
-
display: 'none !important',
|
|
86
|
-
},
|
|
87
|
-
}));
|
|
88
|
-
const MathTemplated = (props) => {
|
|
89
|
-
const { node, options, selected } = props;
|
|
90
|
-
const { attrs: attributes } = node;
|
|
91
|
-
const { value, index } = attributes;
|
|
92
|
-
|
|
93
|
-
// add 1 to index to display R 1 instead of R 0
|
|
94
|
-
const keyToDisplay = `R ${parseInt(index) + 1}`;
|
|
95
|
-
|
|
96
|
-
// console.log({nodeProps.children})
|
|
97
|
-
return (
|
|
98
|
-
<NodeViewWrapper
|
|
99
|
-
className="math-templated"
|
|
100
|
-
data-selected={selected}
|
|
101
|
-
style={{
|
|
102
|
-
display: 'inline-flex',
|
|
103
|
-
minHeight: '36px',
|
|
104
|
-
minWidth: '50px',
|
|
105
|
-
cursor: 'pointer',
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<StyledSpanContainer {...attributes}>
|
|
109
|
-
<StyledResponseBox>{keyToDisplay}</StyledResponseBox>
|
|
110
|
-
<StyledMathBlock>
|
|
111
|
-
<mq.Static latex={value} />
|
|
112
|
-
</StyledMathBlock>
|
|
113
|
-
</StyledSpanContainer>
|
|
114
|
-
</NodeViewWrapper>
|
|
115
|
-
);
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
MathTemplated.propTypes = {
|
|
119
|
-
attributes: PropTypes.object,
|
|
120
|
-
value: PropTypes.string,
|
|
121
|
-
keyToDisplay: PropTypes.string,
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
export default MathTemplated;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { styled } from '@mui/material/styles';
|
|
3
|
-
|
|
4
|
-
export const Chevron = (props) => {
|
|
5
|
-
const { direction, style } = props;
|
|
6
|
-
const rotate = (() => {
|
|
7
|
-
switch (direction) {
|
|
8
|
-
case 'down':
|
|
9
|
-
return 90;
|
|
10
|
-
case 'up':
|
|
11
|
-
return -90;
|
|
12
|
-
case 'left':
|
|
13
|
-
return 180;
|
|
14
|
-
default:
|
|
15
|
-
return 0;
|
|
16
|
-
}
|
|
17
|
-
})();
|
|
18
|
-
|
|
19
|
-
return (
|
|
20
|
-
<svg
|
|
21
|
-
style={{
|
|
22
|
-
transform: `rotate(${rotate}deg)`,
|
|
23
|
-
...style,
|
|
24
|
-
}}
|
|
25
|
-
width="24"
|
|
26
|
-
height="24"
|
|
27
|
-
viewBox="0 0 24 24"
|
|
28
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
-
>
|
|
30
|
-
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" fill="currentColor" />
|
|
31
|
-
</svg>
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export const GripIcon = ({ style }) => (
|
|
36
|
-
<span style={style}>
|
|
37
|
-
<svg
|
|
38
|
-
style={{
|
|
39
|
-
margin: '0 -16px',
|
|
40
|
-
}}
|
|
41
|
-
width="24"
|
|
42
|
-
height="24"
|
|
43
|
-
viewBox="0 0 24 24"
|
|
44
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
45
|
-
>
|
|
46
|
-
<path d="M9 3H7v2h2V3zm0 4H7v2h2V7zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm4-16h-2v2h2V3zm0 4h-2v2h2V7zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2z" />
|
|
47
|
-
</svg>
|
|
48
|
-
<svg width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
49
|
-
<path d="M9 3H7v2h2V3zm0 4H7v2h2V7zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm0 4H7v2h2v-2zm4-16h-2v2h2V3zm0 4h-2v2h2V7zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2zm0 4h-2v2h2v-2z" />
|
|
50
|
-
</svg>
|
|
51
|
-
</span>
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const StyledToolbarIcon = styled('div')(({ theme }) => ({
|
|
55
|
-
fontFamily: 'Cerebri Sans !important',
|
|
56
|
-
fontSize: theme.typography.fontSize,
|
|
57
|
-
fontWeight: 'bold',
|
|
58
|
-
lineHeight: '14px',
|
|
59
|
-
position: 'relative',
|
|
60
|
-
top: '7px',
|
|
61
|
-
width: '110px',
|
|
62
|
-
height: '28px',
|
|
63
|
-
whiteSpace: 'nowrap',
|
|
64
|
-
}));
|
|
65
|
-
|
|
66
|
-
export const ToolbarIcon = () => <StyledToolbarIcon>+ Response Area</StyledToolbarIcon>;
|
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
|
-
import MathTemplated from '../MathTemplated';
|
|
4
|
-
|
|
5
|
-
// Mock the dependencies
|
|
6
|
-
jest.mock('@tiptap/react', () => ({
|
|
7
|
-
NodeViewWrapper: ({ children, ...props }) => (
|
|
8
|
-
<div data-testid="node-view-wrapper" {...props}>
|
|
9
|
-
{children}
|
|
10
|
-
</div>
|
|
11
|
-
),
|
|
12
|
-
}));
|
|
13
|
-
|
|
14
|
-
jest.mock('@pie-lib/math-input', () => ({
|
|
15
|
-
mq: {
|
|
16
|
-
Static: ({ latex }) => (
|
|
17
|
-
<div data-testid="mq-static" data-latex={latex}>
|
|
18
|
-
{latex}
|
|
19
|
-
</div>
|
|
20
|
-
),
|
|
21
|
-
},
|
|
22
|
-
}));
|
|
23
|
-
|
|
24
|
-
describe('MathTemplated', () => {
|
|
25
|
-
const defaultProps = {
|
|
26
|
-
node: {
|
|
27
|
-
attrs: {
|
|
28
|
-
value: 'x^2 + y^2 = r^2',
|
|
29
|
-
index: 0,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
options: {},
|
|
33
|
-
selected: false,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
it('renders without crashing', () => {
|
|
37
|
-
const { container } = render(<MathTemplated {...defaultProps} />);
|
|
38
|
-
expect(container).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('renders NodeViewWrapper with correct className', () => {
|
|
42
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
43
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
44
|
-
expect(wrapper).toHaveClass('math-templated');
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('displays correct response key for index 0', () => {
|
|
48
|
-
const { getByText } = render(<MathTemplated {...defaultProps} />);
|
|
49
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('displays correct response key for index 1', () => {
|
|
53
|
-
const props = {
|
|
54
|
-
...defaultProps,
|
|
55
|
-
node: {
|
|
56
|
-
attrs: {
|
|
57
|
-
value: 'a + b',
|
|
58
|
-
index: 1,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
};
|
|
62
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
63
|
-
expect(getByText('R 2')).toBeInTheDocument();
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('displays correct response key for index 5', () => {
|
|
67
|
-
const props = {
|
|
68
|
-
...defaultProps,
|
|
69
|
-
node: {
|
|
70
|
-
attrs: {
|
|
71
|
-
value: 'c = d',
|
|
72
|
-
index: 5,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
77
|
-
expect(getByText('R 6')).toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('renders LaTeX value correctly', () => {
|
|
81
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
82
|
-
const mqStatic = getByTestId('mq-static');
|
|
83
|
-
expect(mqStatic).toHaveAttribute('data-latex', 'x^2 + y^2 = r^2');
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('renders different LaTeX value', () => {
|
|
87
|
-
const props = {
|
|
88
|
-
...defaultProps,
|
|
89
|
-
node: {
|
|
90
|
-
attrs: {
|
|
91
|
-
value: '\\frac{a}{b}',
|
|
92
|
-
index: 2,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
97
|
-
const mqStatic = getByTestId('mq-static');
|
|
98
|
-
expect(mqStatic).toHaveAttribute('data-latex', '\\frac{a}{b}');
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('passes selected prop to NodeViewWrapper', () => {
|
|
102
|
-
const props = {
|
|
103
|
-
...defaultProps,
|
|
104
|
-
selected: true,
|
|
105
|
-
};
|
|
106
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
107
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
108
|
-
expect(wrapper).toHaveAttribute('data-selected', 'true');
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('passes false selected prop to NodeViewWrapper', () => {
|
|
112
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
113
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
114
|
-
expect(wrapper).toHaveAttribute('data-selected', 'false');
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('applies correct inline styles to NodeViewWrapper', () => {
|
|
118
|
-
const { getByTestId } = render(<MathTemplated {...defaultProps} />);
|
|
119
|
-
const wrapper = getByTestId('node-view-wrapper');
|
|
120
|
-
expect(wrapper).toHaveStyle({
|
|
121
|
-
display: 'inline-flex',
|
|
122
|
-
minHeight: '36px',
|
|
123
|
-
minWidth: '50px',
|
|
124
|
-
cursor: 'pointer',
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('handles string index correctly', () => {
|
|
129
|
-
const props = {
|
|
130
|
-
...defaultProps,
|
|
131
|
-
node: {
|
|
132
|
-
attrs: {
|
|
133
|
-
value: 'test',
|
|
134
|
-
index: '3',
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
139
|
-
expect(getByText('R 4')).toBeInTheDocument();
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('handles empty value', () => {
|
|
143
|
-
const props = {
|
|
144
|
-
...defaultProps,
|
|
145
|
-
node: {
|
|
146
|
-
attrs: {
|
|
147
|
-
value: '',
|
|
148
|
-
index: 0,
|
|
149
|
-
},
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
153
|
-
const mqStatic = getByTestId('mq-static');
|
|
154
|
-
expect(mqStatic).toHaveAttribute('data-latex', '');
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
it('renders all styled components', () => {
|
|
158
|
-
const { container, getByText } = render(<MathTemplated {...defaultProps} />);
|
|
159
|
-
|
|
160
|
-
// Check for response box
|
|
161
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
162
|
-
|
|
163
|
-
// Check for math block with LaTeX
|
|
164
|
-
const mqStatic = container.querySelector('[data-testid="mq-static"]');
|
|
165
|
-
expect(mqStatic).toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
it('handles zero index', () => {
|
|
169
|
-
const props = {
|
|
170
|
-
...defaultProps,
|
|
171
|
-
node: {
|
|
172
|
-
attrs: {
|
|
173
|
-
value: 'x = 0',
|
|
174
|
-
index: 0,
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
};
|
|
178
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
179
|
-
expect(getByText('R 1')).toBeInTheDocument();
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('handles large index values', () => {
|
|
183
|
-
const props = {
|
|
184
|
-
...defaultProps,
|
|
185
|
-
node: {
|
|
186
|
-
attrs: {
|
|
187
|
-
value: 'x = 100',
|
|
188
|
-
index: 99,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
const { getByText } = render(<MathTemplated {...props} />);
|
|
193
|
-
expect(getByText('R 100')).toBeInTheDocument();
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
it('renders with complex LaTeX expression', () => {
|
|
197
|
-
const props = {
|
|
198
|
-
...defaultProps,
|
|
199
|
-
node: {
|
|
200
|
-
attrs: {
|
|
201
|
-
value: '\\sqrt{x^2 + y^2}',
|
|
202
|
-
index: 0,
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
};
|
|
206
|
-
const { getByTestId } = render(<MathTemplated {...props} />);
|
|
207
|
-
const mqStatic = getByTestId('mq-static');
|
|
208
|
-
expect(mqStatic).toHaveAttribute('data-latex', '\\sqrt{x^2 + y^2}');
|
|
209
|
-
});
|
|
210
|
-
});
|
package/src/constants.js
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
import { CSSMark, removeDialogs } from '../css';
|
|
2
|
-
|
|
3
|
-
jest.mock('@tiptap/core', () => ({
|
|
4
|
-
Mark: { create: jest.fn((config) => config) },
|
|
5
|
-
mergeAttributes: jest.fn((...args) => Object.assign({}, ...args)),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
jest.mock('react-dom', () => ({
|
|
9
|
-
render: jest.fn(),
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
describe('CSSMark', () => {
|
|
13
|
-
describe('configuration', () => {
|
|
14
|
-
it('has correct name', () => {
|
|
15
|
-
expect(CSSMark.name).toBe('cssmark');
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('addOptions', () => {
|
|
20
|
-
it('returns default options with empty classes array', () => {
|
|
21
|
-
const options = CSSMark.addOptions();
|
|
22
|
-
|
|
23
|
-
expect(options).toHaveProperty('classes');
|
|
24
|
-
expect(Array.isArray(options.classes)).toBe(true);
|
|
25
|
-
expect(options.classes).toHaveLength(0);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('addAttributes', () => {
|
|
30
|
-
it('returns class attribute configuration', () => {
|
|
31
|
-
const attributes = CSSMark.addAttributes();
|
|
32
|
-
|
|
33
|
-
expect(attributes).toHaveProperty('class');
|
|
34
|
-
expect(attributes.class).toHaveProperty('default', null);
|
|
35
|
-
expect(attributes.class).toHaveProperty('parseHTML');
|
|
36
|
-
expect(attributes.class).toHaveProperty('renderHTML');
|
|
37
|
-
expect(typeof attributes.class.parseHTML).toBe('function');
|
|
38
|
-
expect(typeof attributes.class.renderHTML).toBe('function');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it('parseHTML extracts class attribute', () => {
|
|
42
|
-
const attributes = CSSMark.addAttributes();
|
|
43
|
-
const mockEl = {
|
|
44
|
-
getAttribute: jest.fn((attr) => (attr === 'class' ? 'my-class' : null)),
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const result = attributes.class.parseHTML(mockEl);
|
|
48
|
-
|
|
49
|
-
expect(result).toBe('my-class');
|
|
50
|
-
expect(mockEl.getAttribute).toHaveBeenCalledWith('class');
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it('renderHTML returns empty object when no class', () => {
|
|
54
|
-
const attributes = CSSMark.addAttributes();
|
|
55
|
-
const result = attributes.class.renderHTML({ class: null });
|
|
56
|
-
|
|
57
|
-
expect(result).toEqual({});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
it('renderHTML returns class when present', () => {
|
|
61
|
-
const attributes = CSSMark.addAttributes();
|
|
62
|
-
const result = attributes.class.renderHTML({ class: 'my-class' });
|
|
63
|
-
|
|
64
|
-
expect(result).toEqual({ class: 'my-class' });
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
describe('parseHTML', () => {
|
|
69
|
-
beforeEach(() => {
|
|
70
|
-
CSSMark.options = { classes: ['allowed-class', 'another-class'] };
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('returns array with span[class] selector', () => {
|
|
74
|
-
const rules = CSSMark.parseHTML();
|
|
75
|
-
|
|
76
|
-
expect(Array.isArray(rules)).toBe(true);
|
|
77
|
-
expect(rules).toHaveLength(1);
|
|
78
|
-
expect(rules[0]).toHaveProperty('tag', 'span[class]');
|
|
79
|
-
expect(rules[0]).toHaveProperty('getAttrs');
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it('matches allowed classes', () => {
|
|
83
|
-
const rules = CSSMark.parseHTML();
|
|
84
|
-
const mockEl = {
|
|
85
|
-
getAttribute: jest.fn(() => 'allowed-class some-other'),
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
const result = rules[0].getAttrs(mockEl);
|
|
89
|
-
|
|
90
|
-
expect(result).toEqual({ class: 'allowed-class' });
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('returns false for non-allowed classes', () => {
|
|
94
|
-
const rules = CSSMark.parseHTML();
|
|
95
|
-
const mockEl = {
|
|
96
|
-
getAttribute: jest.fn(() => 'not-allowed'),
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const result = rules[0].getAttrs(mockEl);
|
|
100
|
-
|
|
101
|
-
expect(result).toBe(false);
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
it('handles empty class attribute', () => {
|
|
105
|
-
const rules = CSSMark.parseHTML();
|
|
106
|
-
const mockEl = {
|
|
107
|
-
getAttribute: jest.fn(() => ''),
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const result = rules[0].getAttrs(mockEl);
|
|
111
|
-
|
|
112
|
-
expect(result).toBe(false);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
describe('renderHTML', () => {
|
|
117
|
-
it('returns span with merged attributes', () => {
|
|
118
|
-
const result = CSSMark.renderHTML({
|
|
119
|
-
HTMLAttributes: { class: 'my-class' },
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
expect(result[0]).toBe('span');
|
|
123
|
-
expect(result[1]).toEqual({ class: 'my-class' });
|
|
124
|
-
expect(result[2]).toBe(0);
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
describe('addCommands', () => {
|
|
129
|
-
it('returns setCSSClass command', () => {
|
|
130
|
-
const commands = CSSMark.addCommands();
|
|
131
|
-
|
|
132
|
-
expect(commands).toHaveProperty('setCSSClass');
|
|
133
|
-
expect(typeof commands.setCSSClass).toBe('function');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('returns unsetCSSClass command', () => {
|
|
137
|
-
const commands = CSSMark.addCommands();
|
|
138
|
-
|
|
139
|
-
expect(commands).toHaveProperty('unsetCSSClass');
|
|
140
|
-
expect(typeof commands.unsetCSSClass).toBe('function');
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('returns openCSSClassDialog command', () => {
|
|
144
|
-
const commands = CSSMark.addCommands();
|
|
145
|
-
|
|
146
|
-
expect(commands).toHaveProperty('openCSSClassDialog');
|
|
147
|
-
expect(typeof commands.openCSSClassDialog).toBe('function');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('setCSSClass sets mark with class name', () => {
|
|
151
|
-
const context = { name: 'cssmark' };
|
|
152
|
-
const commands = CSSMark.addCommands.call(context);
|
|
153
|
-
const mockCommands = {
|
|
154
|
-
setMark: jest.fn(() => true),
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
const result = commands.setCSSClass('my-class')({ commands: mockCommands });
|
|
158
|
-
|
|
159
|
-
expect(mockCommands.setMark).toHaveBeenCalledWith('cssmark', { class: 'my-class' });
|
|
160
|
-
expect(result).toBe(true);
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
it('unsetCSSClass unsets mark', () => {
|
|
164
|
-
const context = { name: 'cssmark' };
|
|
165
|
-
const commands = CSSMark.addCommands.call(context);
|
|
166
|
-
const mockCommands = {
|
|
167
|
-
unsetMark: jest.fn(() => true),
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const result = commands.unsetCSSClass()({ commands: mockCommands });
|
|
171
|
-
|
|
172
|
-
expect(mockCommands.unsetMark).toHaveBeenCalledWith('cssmark');
|
|
173
|
-
expect(result).toBe(true);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
describe('removeDialogs', () => {
|
|
179
|
-
it('removes all elements with insert-css-dialog class', () => {
|
|
180
|
-
const mockElements = [{ remove: jest.fn() }, { remove: jest.fn() }];
|
|
181
|
-
|
|
182
|
-
document.querySelectorAll = jest.fn(() => mockElements);
|
|
183
|
-
|
|
184
|
-
removeDialogs();
|
|
185
|
-
|
|
186
|
-
expect(document.querySelectorAll).toHaveBeenCalledWith('.insert-css-dialog');
|
|
187
|
-
expect(mockElements[0].remove).toHaveBeenCalled();
|
|
188
|
-
expect(mockElements[1].remove).toHaveBeenCalled();
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it('handles no dialogs gracefully', () => {
|
|
192
|
-
document.querySelectorAll = jest.fn(() => []);
|
|
193
|
-
|
|
194
|
-
expect(() => removeDialogs()).not.toThrow();
|
|
195
|
-
});
|
|
196
|
-
});
|