@pie-lib/editable-html-tip-tap 2.1.2-next.29 → 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.
Files changed (276) hide show
  1. package/dist/components/CharacterPicker.d.ts +31 -0
  2. package/dist/components/CharacterPicker.js +131 -0
  3. package/dist/components/EditableHtml.d.ts +11 -0
  4. package/dist/components/EditableHtml.js +291 -0
  5. package/dist/components/MenuBar.d.ts +11 -0
  6. package/dist/components/MenuBar.js +462 -0
  7. package/dist/components/TiptapContainer.d.ts +11 -0
  8. package/dist/components/TiptapContainer.js +154 -0
  9. package/dist/components/characters/characterUtils.d.ts +35 -0
  10. package/dist/components/characters/characterUtils.js +465 -0
  11. package/dist/components/characters/custom-popper.d.ts +14 -0
  12. package/dist/components/characters/custom-popper.js +32 -0
  13. package/dist/components/common/done-button.d.ts +30 -0
  14. package/dist/components/common/done-button.js +26 -0
  15. package/dist/components/common/toolbar-buttons.d.ts +38 -0
  16. package/dist/components/common/toolbar-buttons.js +91 -0
  17. package/dist/components/icons/CssIcon.d.ts +11 -0
  18. package/dist/components/icons/CssIcon.js +14 -0
  19. package/dist/components/icons/RespArea.d.ts +26 -0
  20. package/dist/components/icons/RespArea.js +42 -0
  21. package/dist/components/icons/TableIcons.d.ts +14 -0
  22. package/dist/components/icons/TableIcons.js +32 -0
  23. package/dist/components/icons/TextAlign.d.ts +18 -0
  24. package/dist/components/icons/TextAlign.js +134 -0
  25. package/dist/components/image/AltDialog.d.ts +22 -0
  26. package/dist/components/image/AltDialog.js +61 -0
  27. package/dist/components/image/ImageToolbar.d.ts +24 -0
  28. package/dist/components/image/ImageToolbar.js +80 -0
  29. package/dist/components/image/InsertImageHandler.d.ts +32 -0
  30. package/dist/components/image/InsertImageHandler.js +53 -0
  31. package/dist/components/media/MediaDialog.d.ts +43 -0
  32. package/dist/components/media/MediaDialog.js +389 -0
  33. package/dist/components/media/MediaToolbar.d.ts +19 -0
  34. package/dist/components/media/MediaToolbar.js +41 -0
  35. package/dist/components/media/MediaWrapper.d.ts +19 -0
  36. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.d.ts +23 -0
  37. package/dist/components/respArea/DragInTheBlank/DragInTheBlank.js +58 -0
  38. package/dist/components/respArea/DragInTheBlank/choice.d.ts +56 -0
  39. package/dist/components/respArea/DragInTheBlank/choice.js +156 -0
  40. package/dist/components/respArea/ExplicitConstructedResponse.d.ts +20 -0
  41. package/dist/components/respArea/ExplicitConstructedResponse.js +83 -0
  42. package/dist/components/respArea/InlineDropdown.d.ts +18 -0
  43. package/dist/components/respArea/InlineDropdown.js +119 -0
  44. package/dist/components/respArea/MathTemplated.d.ts +19 -0
  45. package/dist/components/respArea/MathTemplated.js +97 -0
  46. package/dist/components/respArea/ToolbarIcon.d.ts +14 -0
  47. package/dist/components/respArea/ToolbarIcon.js +17 -0
  48. package/dist/components/respArea/inlineDropdownUtils.d.ts +15 -0
  49. package/dist/components/respArea/inlineDropdownUtils.js +15 -0
  50. package/dist/constants.d.ts +13 -0
  51. package/dist/constants.js +4 -0
  52. package/dist/extensions/css.d.ts +11 -0
  53. package/dist/extensions/css.js +115 -0
  54. package/dist/extensions/custom-toolbar-wrapper.d.ts +11 -0
  55. package/dist/extensions/custom-toolbar-wrapper.js +61 -0
  56. package/dist/extensions/div-node.d.ts +10 -0
  57. package/dist/extensions/div-node.js +42 -0
  58. package/dist/extensions/ensure-empty-root-div.d.ts +14 -0
  59. package/dist/extensions/ensure-empty-root-div.js +24 -0
  60. package/dist/extensions/ensure-list-item-content-is-div.d.ts +15 -0
  61. package/dist/extensions/ensure-list-item-content-is-div.js +31 -0
  62. package/dist/extensions/extended-list-item.d.ts +13 -0
  63. package/dist/extensions/extended-list-item.js +5 -0
  64. package/dist/extensions/extended-table-cell.d.ts +10 -0
  65. package/dist/extensions/extended-table-cell.js +6 -0
  66. package/dist/extensions/extended-table.d.ts +17 -0
  67. package/dist/extensions/extended-table.js +34 -0
  68. package/dist/extensions/heading-paragraph.d.ts +17 -0
  69. package/dist/extensions/heading-paragraph.js +30 -0
  70. package/dist/extensions/image-component.d.ts +22 -0
  71. package/dist/extensions/image-component.js +220 -0
  72. package/dist/extensions/image.d.ts +10 -0
  73. package/dist/extensions/image.js +68 -0
  74. package/dist/extensions/index.d.ts +16 -0
  75. package/dist/extensions/index.js +64 -0
  76. package/dist/extensions/math.d.ts +15 -0
  77. package/dist/extensions/math.js +158 -0
  78. package/dist/extensions/media.d.ts +19 -0
  79. package/dist/extensions/media.js +149 -0
  80. package/dist/extensions/responseArea.d.ts +27 -0
  81. package/dist/extensions/responseArea.js +259 -0
  82. package/dist/index.d.ts +13 -0
  83. package/dist/index.js +7 -0
  84. package/dist/node_modules/.bun/clsx@2.1.1/node_modules/clsx/dist/clsx.js +16 -0
  85. package/dist/styles/editorContainerStyles.d.ts +134 -0
  86. package/dist/theme.d.ts +9 -0
  87. package/dist/utils/helper.d.ts +9 -0
  88. package/dist/utils/helper.js +27 -0
  89. package/dist/utils/size.d.ts +9 -0
  90. package/dist/utils/size.js +14 -0
  91. package/package.json +40 -24
  92. package/CHANGELOG.json +0 -32
  93. package/CHANGELOG.md +0 -2532
  94. package/LICENSE.md +0 -5
  95. package/lib/components/CharacterPicker.js +0 -201
  96. package/lib/components/CharacterPicker.js.map +0 -1
  97. package/lib/components/EditableHtml.js +0 -376
  98. package/lib/components/EditableHtml.js.map +0 -1
  99. package/lib/components/MenuBar.js +0 -696
  100. package/lib/components/MenuBar.js.map +0 -1
  101. package/lib/components/TiptapContainer.js +0 -234
  102. package/lib/components/TiptapContainer.js.map +0 -1
  103. package/lib/components/characters/characterUtils.js +0 -378
  104. package/lib/components/characters/characterUtils.js.map +0 -1
  105. package/lib/components/characters/custom-popper.js +0 -44
  106. package/lib/components/characters/custom-popper.js.map +0 -1
  107. package/lib/components/common/done-button.js +0 -34
  108. package/lib/components/common/done-button.js.map +0 -1
  109. package/lib/components/common/toolbar-buttons.js +0 -144
  110. package/lib/components/common/toolbar-buttons.js.map +0 -1
  111. package/lib/components/icons/CssIcon.js +0 -25
  112. package/lib/components/icons/CssIcon.js.map +0 -1
  113. package/lib/components/icons/RespArea.js +0 -72
  114. package/lib/components/icons/RespArea.js.map +0 -1
  115. package/lib/components/icons/TableIcons.js +0 -53
  116. package/lib/components/icons/TableIcons.js.map +0 -1
  117. package/lib/components/icons/TextAlign.js +0 -157
  118. package/lib/components/icons/TextAlign.js.map +0 -1
  119. package/lib/components/image/AltDialog.js +0 -98
  120. package/lib/components/image/AltDialog.js.map +0 -1
  121. package/lib/components/image/ImageToolbar.js +0 -137
  122. package/lib/components/image/ImageToolbar.js.map +0 -1
  123. package/lib/components/image/InsertImageHandler.js +0 -135
  124. package/lib/components/image/InsertImageHandler.js.map +0 -1
  125. package/lib/components/media/MediaDialog.js +0 -594
  126. package/lib/components/media/MediaDialog.js.map +0 -1
  127. package/lib/components/media/MediaToolbar.js +0 -74
  128. package/lib/components/media/MediaToolbar.js.map +0 -1
  129. package/lib/components/media/MediaWrapper.js +0 -67
  130. package/lib/components/media/MediaWrapper.js.map +0 -1
  131. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
  132. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
  133. package/lib/components/respArea/DragInTheBlank/choice.js +0 -250
  134. package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
  135. package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
  136. package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
  137. package/lib/components/respArea/InlineDropdown.js +0 -209
  138. package/lib/components/respArea/InlineDropdown.js.map +0 -1
  139. package/lib/components/respArea/MathTemplated.js +0 -130
  140. package/lib/components/respArea/MathTemplated.js.map +0 -1
  141. package/lib/components/respArea/ToolbarIcon.js +0 -81
  142. package/lib/components/respArea/ToolbarIcon.js.map +0 -1
  143. package/lib/components/respArea/inlineDropdownUtils.js +0 -67
  144. package/lib/components/respArea/inlineDropdownUtils.js.map +0 -1
  145. package/lib/constants.js +0 -11
  146. package/lib/constants.js.map +0 -1
  147. package/lib/extensions/css.js +0 -217
  148. package/lib/extensions/css.js.map +0 -1
  149. package/lib/extensions/custom-toolbar-wrapper.js +0 -92
  150. package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
  151. package/lib/extensions/div-node.js +0 -83
  152. package/lib/extensions/div-node.js.map +0 -1
  153. package/lib/extensions/ensure-empty-root-div.js +0 -48
  154. package/lib/extensions/ensure-empty-root-div.js.map +0 -1
  155. package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
  156. package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
  157. package/lib/extensions/extended-list-item.js +0 -15
  158. package/lib/extensions/extended-list-item.js.map +0 -1
  159. package/lib/extensions/extended-table-cell.js +0 -22
  160. package/lib/extensions/extended-table-cell.js.map +0 -1
  161. package/lib/extensions/extended-table.js +0 -75
  162. package/lib/extensions/extended-table.js.map +0 -1
  163. package/lib/extensions/heading-paragraph.js +0 -61
  164. package/lib/extensions/heading-paragraph.js.map +0 -1
  165. package/lib/extensions/image-component.js +0 -348
  166. package/lib/extensions/image-component.js.map +0 -1
  167. package/lib/extensions/image.js +0 -134
  168. package/lib/extensions/image.js.map +0 -1
  169. package/lib/extensions/index.js +0 -46
  170. package/lib/extensions/index.js.map +0 -1
  171. package/lib/extensions/math.js +0 -342
  172. package/lib/extensions/math.js.map +0 -1
  173. package/lib/extensions/media.js +0 -243
  174. package/lib/extensions/media.js.map +0 -1
  175. package/lib/extensions/responseArea.js +0 -446
  176. package/lib/extensions/responseArea.js.map +0 -1
  177. package/lib/index.js +0 -37
  178. package/lib/index.js.map +0 -1
  179. package/lib/styles/editorContainerStyles.js +0 -137
  180. package/lib/styles/editorContainerStyles.js.map +0 -1
  181. package/lib/theme.js +0 -8
  182. package/lib/theme.js.map +0 -1
  183. package/lib/utils/helper.js +0 -73
  184. package/lib/utils/helper.js.map +0 -1
  185. package/lib/utils/size.js +0 -26
  186. package/lib/utils/size.js.map +0 -1
  187. package/src/__tests__/EditableHtml.test.jsx +0 -554
  188. package/src/__tests__/constants.test.js +0 -19
  189. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  190. package/src/__tests__/extensions.test.js +0 -208
  191. package/src/__tests__/index.test.jsx +0 -154
  192. package/src/__tests__/size-utils.test.js +0 -64
  193. package/src/__tests__/theme.test.js +0 -17
  194. package/src/components/CharacterPicker.jsx +0 -207
  195. package/src/components/EditableHtml.jsx +0 -440
  196. package/src/components/MenuBar.jsx +0 -554
  197. package/src/components/TiptapContainer.jsx +0 -219
  198. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  199. package/src/components/__tests__/CharacterPicker.test.jsx +0 -261
  200. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  201. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  202. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
  203. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  204. package/src/components/__tests__/InlineDropdown.test.jsx +0 -388
  205. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  206. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  207. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  208. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  209. package/src/components/__tests__/MenuBar.test.jsx +0 -250
  210. package/src/components/__tests__/RespArea.test.jsx +0 -122
  211. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  212. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  213. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  214. package/src/components/__tests__/characterUtils.test.js +0 -166
  215. package/src/components/__tests__/choice.test.jsx +0 -171
  216. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  217. package/src/components/__tests__/done-button.test.jsx +0 -54
  218. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  219. package/src/components/characters/characterUtils.js +0 -447
  220. package/src/components/characters/custom-popper.js +0 -38
  221. package/src/components/common/done-button.jsx +0 -27
  222. package/src/components/common/toolbar-buttons.jsx +0 -122
  223. package/src/components/icons/CssIcon.jsx +0 -15
  224. package/src/components/icons/RespArea.jsx +0 -71
  225. package/src/components/icons/TableIcons.jsx +0 -52
  226. package/src/components/icons/TextAlign.jsx +0 -114
  227. package/src/components/image/AltDialog.jsx +0 -82
  228. package/src/components/image/ImageToolbar.jsx +0 -99
  229. package/src/components/image/InsertImageHandler.js +0 -107
  230. package/src/components/media/MediaDialog.jsx +0 -596
  231. package/src/components/media/MediaToolbar.jsx +0 -49
  232. package/src/components/media/MediaWrapper.jsx +0 -39
  233. package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
  234. package/src/components/respArea/DragInTheBlank/choice.jsx +0 -256
  235. package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
  236. package/src/components/respArea/InlineDropdown.jsx +0 -220
  237. package/src/components/respArea/MathTemplated.jsx +0 -124
  238. package/src/components/respArea/ToolbarIcon.jsx +0 -66
  239. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  240. package/src/components/respArea/inlineDropdownUtils.js +0 -79
  241. package/src/constants.js +0 -5
  242. package/src/extensions/__tests__/css.test.js +0 -196
  243. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  244. package/src/extensions/__tests__/divNode.test.js +0 -87
  245. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  246. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  247. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  248. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  249. package/src/extensions/__tests__/extended-table.test.js +0 -183
  250. package/src/extensions/__tests__/image-component.test.jsx +0 -345
  251. package/src/extensions/__tests__/image.test.js +0 -237
  252. package/src/extensions/__tests__/math.test.js +0 -603
  253. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  254. package/src/extensions/__tests__/media.test.js +0 -271
  255. package/src/extensions/__tests__/responseArea.test.js +0 -601
  256. package/src/extensions/css.js +0 -220
  257. package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
  258. package/src/extensions/div-node.js +0 -86
  259. package/src/extensions/ensure-empty-root-div.js +0 -47
  260. package/src/extensions/ensure-list-item-content-is-div.js +0 -62
  261. package/src/extensions/extended-list-item.js +0 -10
  262. package/src/extensions/extended-table-cell.js +0 -19
  263. package/src/extensions/extended-table.js +0 -60
  264. package/src/extensions/heading-paragraph.js +0 -53
  265. package/src/extensions/image-component.jsx +0 -338
  266. package/src/extensions/image.js +0 -109
  267. package/src/extensions/index.js +0 -81
  268. package/src/extensions/math.js +0 -326
  269. package/src/extensions/media.js +0 -188
  270. package/src/extensions/responseArea.js +0 -401
  271. package/src/index.jsx +0 -5
  272. package/src/styles/editorContainerStyles.js +0 -145
  273. package/src/theme.js +0 -1
  274. package/src/utils/__tests__/helper.test.js +0 -126
  275. package/src/utils/helper.js +0 -69
  276. 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
- });
@@ -1,79 +0,0 @@
1
- import { NodeSelection } from 'prosemirror-state';
2
-
3
- export const HOLD_INLINE_DROPDOWN_TOOLBAR_INDEX = '_holdInlineDropdownToolbarIndex';
4
-
5
- export const findInlineDropdownPos = (editor, index) => {
6
- let foundPos = null;
7
-
8
- editor.state.doc.descendants((n, p) => {
9
- if (n.type?.name === 'inline_dropdown' && String(n.attrs?.index) === String(index)) {
10
- foundPos = p;
11
- return false;
12
- }
13
-
14
- return true;
15
- });
16
-
17
- return foundPos;
18
- };
19
-
20
- export const holdInlineDropdownToolbar = (editor, index) => {
21
- editor[HOLD_INLINE_DROPDOWN_TOOLBAR_INDEX] = index;
22
- };
23
-
24
- export const releaseInlineDropdownToolbarHold = (editor) => {
25
- delete editor[HOLD_INLINE_DROPDOWN_TOOLBAR_INDEX];
26
- };
27
-
28
- export const isInlineDropdownToolbarHeld = (editor, index) =>
29
- editor[HOLD_INLINE_DROPDOWN_TOOLBAR_INDEX] != null &&
30
- String(editor[HOLD_INLINE_DROPDOWN_TOOLBAR_INDEX]) === String(index);
31
-
32
- export const selectInlineDropdownNode = (editor, index, fallbackPos) => {
33
- const pos = findInlineDropdownPos(editor, index) ?? fallbackPos;
34
-
35
- if (pos == null) {
36
- return null;
37
- }
38
-
39
- const { tr } = editor.state;
40
- const nodeAtPos = tr.doc.nodeAt(pos);
41
-
42
- if (!nodeAtPos) {
43
- return null;
44
- }
45
-
46
- const { selection } = tr;
47
-
48
- if (selection.from === pos && selection.to === pos + nodeAtPos.nodeSize) {
49
- return pos;
50
- }
51
-
52
- tr.setSelection(NodeSelection.create(tr.doc, pos));
53
- editor.view.dispatch(tr);
54
-
55
- return pos;
56
- };
57
-
58
- export const deleteInlineDropdownByIndex = (editor, index, fallbackPos) => {
59
- const pos = findInlineDropdownPos(editor, index) ?? fallbackPos;
60
-
61
- if (pos == null) {
62
- releaseInlineDropdownToolbarHold(editor);
63
- return false;
64
- }
65
-
66
- const { tr } = editor.state;
67
- const nodeAtPos = tr.doc.nodeAt(pos);
68
-
69
- if (!nodeAtPos) {
70
- releaseInlineDropdownToolbarHold(editor);
71
- return false;
72
- }
73
-
74
- tr.delete(pos, pos + nodeAtPos.nodeSize);
75
- editor.view.dispatch(tr);
76
- releaseInlineDropdownToolbarHold(editor);
77
-
78
- return true;
79
- };
package/src/constants.js DELETED
@@ -1,5 +0,0 @@
1
- export const PIE_TOOLBAR__CLASS = 'pie-toolbar';
2
-
3
- export default {
4
- PIE_TOOLBAR__CLASS,
5
- };
@@ -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
- });