@pie-lib/editable-html-tip-tap 2.1.1 → 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.
Files changed (272) 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 +65 -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/styles/editorContainerStyles.d.ts +134 -0
  85. package/dist/theme.d.ts +9 -0
  86. package/dist/utils/helper.d.ts +9 -0
  87. package/dist/utils/helper.js +27 -0
  88. package/dist/utils/size.d.ts +9 -0
  89. package/dist/utils/size.js +14 -0
  90. package/package.json +51 -38
  91. package/CHANGELOG.json +0 -32
  92. package/CHANGELOG.md +0 -2532
  93. package/LICENSE.md +0 -5
  94. package/lib/components/CharacterPicker.js +0 -195
  95. package/lib/components/CharacterPicker.js.map +0 -1
  96. package/lib/components/EditableHtml.js +0 -375
  97. package/lib/components/EditableHtml.js.map +0 -1
  98. package/lib/components/MenuBar.js +0 -693
  99. package/lib/components/MenuBar.js.map +0 -1
  100. package/lib/components/TiptapContainer.js +0 -234
  101. package/lib/components/TiptapContainer.js.map +0 -1
  102. package/lib/components/characters/characterUtils.js +0 -378
  103. package/lib/components/characters/characterUtils.js.map +0 -1
  104. package/lib/components/characters/custom-popper.js +0 -44
  105. package/lib/components/characters/custom-popper.js.map +0 -1
  106. package/lib/components/common/done-button.js +0 -34
  107. package/lib/components/common/done-button.js.map +0 -1
  108. package/lib/components/common/toolbar-buttons.js +0 -144
  109. package/lib/components/common/toolbar-buttons.js.map +0 -1
  110. package/lib/components/icons/CssIcon.js +0 -25
  111. package/lib/components/icons/CssIcon.js.map +0 -1
  112. package/lib/components/icons/RespArea.js +0 -72
  113. package/lib/components/icons/RespArea.js.map +0 -1
  114. package/lib/components/icons/TableIcons.js +0 -53
  115. package/lib/components/icons/TableIcons.js.map +0 -1
  116. package/lib/components/icons/TextAlign.js +0 -157
  117. package/lib/components/icons/TextAlign.js.map +0 -1
  118. package/lib/components/image/AltDialog.js +0 -98
  119. package/lib/components/image/AltDialog.js.map +0 -1
  120. package/lib/components/image/ImageToolbar.js +0 -137
  121. package/lib/components/image/ImageToolbar.js.map +0 -1
  122. package/lib/components/image/InsertImageHandler.js +0 -135
  123. package/lib/components/image/InsertImageHandler.js.map +0 -1
  124. package/lib/components/media/MediaDialog.js +0 -594
  125. package/lib/components/media/MediaDialog.js.map +0 -1
  126. package/lib/components/media/MediaToolbar.js +0 -74
  127. package/lib/components/media/MediaToolbar.js.map +0 -1
  128. package/lib/components/media/MediaWrapper.js +0 -67
  129. package/lib/components/media/MediaWrapper.js.map +0 -1
  130. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +0 -84
  131. package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +0 -1
  132. package/lib/components/respArea/DragInTheBlank/choice.js +0 -250
  133. package/lib/components/respArea/DragInTheBlank/choice.js.map +0 -1
  134. package/lib/components/respArea/ExplicitConstructedResponse.js +0 -136
  135. package/lib/components/respArea/ExplicitConstructedResponse.js.map +0 -1
  136. package/lib/components/respArea/InlineDropdown.js +0 -165
  137. package/lib/components/respArea/InlineDropdown.js.map +0 -1
  138. package/lib/components/respArea/MathTemplated.js +0 -130
  139. package/lib/components/respArea/MathTemplated.js.map +0 -1
  140. package/lib/components/respArea/ToolbarIcon.js +0 -81
  141. package/lib/components/respArea/ToolbarIcon.js.map +0 -1
  142. package/lib/constants.js +0 -11
  143. package/lib/constants.js.map +0 -1
  144. package/lib/extensions/css.js +0 -217
  145. package/lib/extensions/css.js.map +0 -1
  146. package/lib/extensions/custom-toolbar-wrapper.js +0 -92
  147. package/lib/extensions/custom-toolbar-wrapper.js.map +0 -1
  148. package/lib/extensions/div-node.js +0 -83
  149. package/lib/extensions/div-node.js.map +0 -1
  150. package/lib/extensions/ensure-empty-root-div.js +0 -48
  151. package/lib/extensions/ensure-empty-root-div.js.map +0 -1
  152. package/lib/extensions/ensure-list-item-content-is-div.js +0 -64
  153. package/lib/extensions/ensure-list-item-content-is-div.js.map +0 -1
  154. package/lib/extensions/extended-list-item.js +0 -15
  155. package/lib/extensions/extended-list-item.js.map +0 -1
  156. package/lib/extensions/extended-table-cell.js +0 -22
  157. package/lib/extensions/extended-table-cell.js.map +0 -1
  158. package/lib/extensions/extended-table.js +0 -75
  159. package/lib/extensions/extended-table.js.map +0 -1
  160. package/lib/extensions/heading-paragraph.js +0 -61
  161. package/lib/extensions/heading-paragraph.js.map +0 -1
  162. package/lib/extensions/image-component.js +0 -348
  163. package/lib/extensions/image-component.js.map +0 -1
  164. package/lib/extensions/image.js +0 -134
  165. package/lib/extensions/image.js.map +0 -1
  166. package/lib/extensions/index.js +0 -46
  167. package/lib/extensions/index.js.map +0 -1
  168. package/lib/extensions/math.js +0 -343
  169. package/lib/extensions/math.js.map +0 -1
  170. package/lib/extensions/media.js +0 -243
  171. package/lib/extensions/media.js.map +0 -1
  172. package/lib/extensions/responseArea.js +0 -446
  173. package/lib/extensions/responseArea.js.map +0 -1
  174. package/lib/index.js +0 -30
  175. package/lib/index.js.map +0 -1
  176. package/lib/styles/editorContainerStyles.js +0 -137
  177. package/lib/styles/editorContainerStyles.js.map +0 -1
  178. package/lib/theme.js +0 -8
  179. package/lib/theme.js.map +0 -1
  180. package/lib/utils/helper.js +0 -73
  181. package/lib/utils/helper.js.map +0 -1
  182. package/lib/utils/size.js +0 -26
  183. package/lib/utils/size.js.map +0 -1
  184. package/src/__tests__/EditableHtml.test.jsx +0 -474
  185. package/src/__tests__/constants.test.js +0 -19
  186. package/src/__tests__/div-to-paragraph-conversion.test.jsx +0 -125
  187. package/src/__tests__/extensions.test.js +0 -208
  188. package/src/__tests__/index.test.jsx +0 -154
  189. package/src/__tests__/size-utils.test.js +0 -64
  190. package/src/__tests__/theme.test.js +0 -17
  191. package/src/components/CharacterPicker.jsx +0 -200
  192. package/src/components/EditableHtml.jsx +0 -438
  193. package/src/components/MenuBar.jsx +0 -549
  194. package/src/components/TiptapContainer.jsx +0 -219
  195. package/src/components/__tests__/AltDialog.test.jsx +0 -147
  196. package/src/components/__tests__/CharacterPicker.test.jsx +0 -219
  197. package/src/components/__tests__/CssIcon.test.jsx +0 -46
  198. package/src/components/__tests__/DragInTheBlank.test.jsx +0 -255
  199. package/src/components/__tests__/ExplicitConstructedResponse.test.jsx +0 -204
  200. package/src/components/__tests__/ImageToolbar.test.jsx +0 -128
  201. package/src/components/__tests__/InlineDropdown.test.jsx +0 -380
  202. package/src/components/__tests__/InsertImageHandler.test.js +0 -161
  203. package/src/components/__tests__/MediaDialog.test.jsx +0 -293
  204. package/src/components/__tests__/MediaToolbar.test.jsx +0 -74
  205. package/src/components/__tests__/MediaWrapper.test.jsx +0 -81
  206. package/src/components/__tests__/MenuBar.test.jsx +0 -249
  207. package/src/components/__tests__/RespArea.test.jsx +0 -122
  208. package/src/components/__tests__/TableIcons.test.jsx +0 -149
  209. package/src/components/__tests__/TextAlign.test.jsx +0 -167
  210. package/src/components/__tests__/TiptapContainer.test.jsx +0 -138
  211. package/src/components/__tests__/characterUtils.test.js +0 -166
  212. package/src/components/__tests__/choice.test.jsx +0 -171
  213. package/src/components/__tests__/custom-popper.test.jsx +0 -82
  214. package/src/components/__tests__/done-button.test.jsx +0 -54
  215. package/src/components/__tests__/toolbar-buttons.test.jsx +0 -234
  216. package/src/components/characters/characterUtils.js +0 -447
  217. package/src/components/characters/custom-popper.js +0 -38
  218. package/src/components/common/done-button.jsx +0 -27
  219. package/src/components/common/toolbar-buttons.jsx +0 -122
  220. package/src/components/icons/CssIcon.jsx +0 -15
  221. package/src/components/icons/RespArea.jsx +0 -71
  222. package/src/components/icons/TableIcons.jsx +0 -52
  223. package/src/components/icons/TextAlign.jsx +0 -114
  224. package/src/components/image/AltDialog.jsx +0 -82
  225. package/src/components/image/ImageToolbar.jsx +0 -99
  226. package/src/components/image/InsertImageHandler.js +0 -107
  227. package/src/components/media/MediaDialog.jsx +0 -596
  228. package/src/components/media/MediaToolbar.jsx +0 -49
  229. package/src/components/media/MediaWrapper.jsx +0 -39
  230. package/src/components/respArea/DragInTheBlank/DragInTheBlank.jsx +0 -76
  231. package/src/components/respArea/DragInTheBlank/choice.jsx +0 -256
  232. package/src/components/respArea/ExplicitConstructedResponse.jsx +0 -135
  233. package/src/components/respArea/InlineDropdown.jsx +0 -167
  234. package/src/components/respArea/MathTemplated.jsx +0 -124
  235. package/src/components/respArea/ToolbarIcon.jsx +0 -66
  236. package/src/components/respArea/__tests__/MathTemplated.test.jsx +0 -210
  237. package/src/constants.js +0 -5
  238. package/src/extensions/__tests__/css.test.js +0 -196
  239. package/src/extensions/__tests__/custom-toolbar-wrapper.test.jsx +0 -180
  240. package/src/extensions/__tests__/divNode.test.js +0 -87
  241. package/src/extensions/__tests__/ensure-empty-root-div.test.js +0 -57
  242. package/src/extensions/__tests__/ensure-list-item-content-is-div.test.js +0 -44
  243. package/src/extensions/__tests__/extended-list-item.test.js +0 -13
  244. package/src/extensions/__tests__/extended-table-cell.test.js +0 -22
  245. package/src/extensions/__tests__/extended-table.test.js +0 -183
  246. package/src/extensions/__tests__/image-component.test.jsx +0 -345
  247. package/src/extensions/__tests__/image.test.js +0 -237
  248. package/src/extensions/__tests__/math.test.js +0 -459
  249. package/src/extensions/__tests__/media-node-view.test.jsx +0 -298
  250. package/src/extensions/__tests__/media.test.js +0 -271
  251. package/src/extensions/__tests__/responseArea.test.js +0 -601
  252. package/src/extensions/css.js +0 -220
  253. package/src/extensions/custom-toolbar-wrapper.jsx +0 -78
  254. package/src/extensions/div-node.js +0 -86
  255. package/src/extensions/ensure-empty-root-div.js +0 -47
  256. package/src/extensions/ensure-list-item-content-is-div.js +0 -62
  257. package/src/extensions/extended-list-item.js +0 -10
  258. package/src/extensions/extended-table-cell.js +0 -19
  259. package/src/extensions/extended-table.js +0 -60
  260. package/src/extensions/heading-paragraph.js +0 -53
  261. package/src/extensions/image-component.jsx +0 -338
  262. package/src/extensions/image.js +0 -109
  263. package/src/extensions/index.js +0 -81
  264. package/src/extensions/math.js +0 -327
  265. package/src/extensions/media.js +0 -188
  266. package/src/extensions/responseArea.js +0 -401
  267. package/src/index.jsx +0 -5
  268. package/src/styles/editorContainerStyles.js +0 -145
  269. package/src/theme.js +0 -1
  270. package/src/utils/__tests__/helper.test.js +0 -126
  271. package/src/utils/helper.js +0 -69
  272. package/src/utils/size.js +0 -32
@@ -1,27 +0,0 @@
1
- import React from 'react';
2
-
3
- import IconButton from '@mui/material/IconButton';
4
- import Check from '@mui/icons-material/Check';
5
- import { styled } from '@mui/material/styles';
6
- import PropTypes from 'prop-types';
7
-
8
- const StyledIconButton = styled(IconButton)({
9
- verticalAlign: 'top',
10
- width: '28px',
11
- height: '28px',
12
- color: 'var(--editable-html-toolbar-check, #00bb00)',
13
- padding: '4px',
14
- });
15
-
16
- export const RawDoneButton = ({ onClick, doneButtonRef }) => (
17
- <StyledIconButton aria-label="Done" buttonRef={doneButtonRef} onClick={onClick}>
18
- <Check />
19
- </StyledIconButton>
20
- );
21
-
22
- RawDoneButton.propTypes = {
23
- onClick: PropTypes.func,
24
- doneButtonRef: PropTypes.func,
25
- };
26
-
27
- export const DoneButton = RawDoneButton;
@@ -1,122 +0,0 @@
1
- import React from 'react';
2
- import debug from 'debug';
3
- import { styled } from '@mui/material/styles';
4
- import PropTypes from 'prop-types';
5
-
6
- const StyledButton = styled('button', {
7
- shouldForwardProp: (prop) => !['active', 'disabled', 'extraStyles'].includes(prop),
8
- })(({ theme, active, disabled }) => ({
9
- color: active ? 'black' : 'grey',
10
- display: 'inline-flex',
11
- padding: '2px',
12
- background: 'none',
13
- border: 'none',
14
- cursor: disabled ? 'not-allowed' : 'pointer',
15
- '&:hover': {
16
- color: disabled ? 'grey' : 'black',
17
- },
18
- '&:focus': {
19
- outline: `2px solid ${theme.palette.grey[700]}`,
20
- },
21
- ...(disabled && {
22
- opacity: 0.7,
23
- }),
24
- }));
25
-
26
- const log = debug('pie-elements:editable-html:raw-button');
27
-
28
- export class RawButton extends React.Component {
29
- static propTypes = {
30
- onClick: PropTypes.func.isRequired,
31
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
32
- active: PropTypes.bool,
33
- disabled: PropTypes.bool,
34
- extraStyles: PropTypes.object,
35
- };
36
-
37
- constructor(props) {
38
- super(props);
39
- }
40
-
41
- onClick = (e) => {
42
- log('[onClick]');
43
- e.preventDefault();
44
- const { onClick } = this.props;
45
- onClick(e);
46
- };
47
-
48
- onKeyDown = (e) => {
49
- if (e.key === 'Enter' || e.key === ' ') {
50
- log('[onKeyDown]');
51
- e.preventDefault();
52
- const { onClick } = this.props;
53
- onClick(e);
54
- }
55
- };
56
-
57
- render() {
58
- const { active, children, disabled, extraStyles, ariaLabel } = this.props;
59
-
60
- return (
61
- <StyledButton
62
- style={extraStyles}
63
- active={active}
64
- disabled={disabled}
65
- onMouseDown={this.onClick}
66
- onKeyDown={this.onKeyDown}
67
- aria-label={ariaLabel}
68
- aria-pressed={active}
69
- tabIndex={0}
70
- >
71
- {children}
72
- </StyledButton>
73
- );
74
- }
75
- }
76
-
77
- export const Button = RawButton;
78
-
79
- export class RawMarkButton extends React.Component {
80
- static propTypes = {
81
- onToggle: PropTypes.func.isRequired,
82
- mark: PropTypes.string,
83
- label: PropTypes.string.isRequired,
84
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
85
- active: PropTypes.bool,
86
- };
87
-
88
- constructor(props) {
89
- super(props);
90
- }
91
-
92
- onToggle = (e) => {
93
- e.preventDefault();
94
- this.props.onToggle(this.props.mark);
95
- };
96
-
97
- onKeyDown = (e) => {
98
- if (e.key === 'Enter' || e.key === ' ') {
99
- e.preventDefault();
100
- this.props.onToggle(this.props.mark);
101
- }
102
- };
103
-
104
- render() {
105
- const { children, active, label } = this.props;
106
-
107
- return (
108
- <StyledButton
109
- active={active}
110
- onMouseDown={this.onToggle}
111
- aria-pressed={active}
112
- onKeyDown={this.onKeyDown}
113
- aria-label={label}
114
- tabIndex={0}
115
- >
116
- {children}
117
- </StyledButton>
118
- );
119
- }
120
- }
121
-
122
- export const MarkButton = RawMarkButton;
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import { styled } from '@mui/material/styles';
3
-
4
- const StyledCssIcon = styled('div')(({ theme }) => ({
5
- fontFamily: 'Cerebri Sans, Arial, sans-serif',
6
- fontSize: theme.typography.fontSize,
7
- fontWeight: 'bold',
8
- lineHeight: '14px',
9
- position: 'relative',
10
- whiteSpace: 'nowrap',
11
- }));
12
-
13
- const CssIcon = () => <StyledCssIcon>CSS</StyledCssIcon>;
14
-
15
- export default CssIcon;
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import ChevronRight from '@mui/icons-material/ChevronRight';
4
- import MoreVert from '@mui/icons-material/MoreVert';
5
- import { styled } from '@mui/material/styles';
6
-
7
- const getRotate = (direction) => {
8
- switch (direction) {
9
- case 'down':
10
- return 90;
11
-
12
- case 'up':
13
- return -90;
14
-
15
- case 'left':
16
- return 180;
17
-
18
- default:
19
- return 0;
20
- }
21
- };
22
-
23
- export const Chevron = (props) => {
24
- const { direction, style } = props;
25
- const rotate = getRotate(direction);
26
-
27
- return (
28
- <ChevronRight
29
- style={{
30
- transform: `rotate(${rotate}deg)`,
31
- ...style,
32
- }}
33
- />
34
- );
35
- };
36
-
37
- Chevron.propTypes = {
38
- direction: PropTypes.string,
39
- style: PropTypes.object,
40
- };
41
-
42
- export const GripIcon = ({ style }) => {
43
- return (
44
- <span style={style}>
45
- <MoreVert
46
- style={{
47
- margin: '0 -16px',
48
- }}
49
- />
50
- <MoreVert />
51
- </span>
52
- );
53
- };
54
-
55
- GripIcon.propTypes = {
56
- style: PropTypes.object,
57
- };
58
-
59
- const StyledToolbarIcon = styled('div')(({ theme }) => ({
60
- fontFamily: 'Cerebri Sans !important',
61
- fontSize: theme.typography.fontSize,
62
- fontWeight: 'bold',
63
- lineHeight: '14px',
64
- position: 'relative',
65
- top: '7px',
66
- width: '110px',
67
- height: '28px',
68
- whiteSpace: 'nowrap',
69
- }));
70
-
71
- export const ToolbarIcon = () => <StyledToolbarIcon>+ Response Area</StyledToolbarIcon>;
@@ -1,52 +0,0 @@
1
- import React from 'react';
2
- import { styled } from '@mui/material/styles';
3
-
4
- const StyledPath = styled('path')({
5
- fill: 'grey',
6
- '&:hover': {
7
- fill: 'black',
8
- },
9
- });
10
-
11
- const SvgIcon = (Component) => {
12
- return (props) => (
13
- <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="24" height="24" viewBox="0 0 24 24">
14
- <Component {...props} />
15
- </svg>
16
- );
17
- };
18
-
19
- export const AddRow = SvgIcon((props) => (
20
- <StyledPath
21
- {...props}
22
- d="M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"
23
- />
24
- ));
25
-
26
- export const RemoveRow = SvgIcon((props) => (
27
- <StyledPath
28
- {...props}
29
- d="M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z"
30
- />
31
- ));
32
-
33
- export const AddColumn = SvgIcon((props) => (
34
- <StyledPath
35
- {...props}
36
- d="M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"
37
- />
38
- ));
39
-
40
- export const RemoveColumn = SvgIcon((props) => (
41
- <StyledPath
42
- {...props}
43
- d="M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z"
44
- />
45
- ));
46
-
47
- export const RemoveTable = SvgIcon((props) => (
48
- <StyledPath
49
- {...props}
50
- d="M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z"
51
- />
52
- ));
@@ -1,114 +0,0 @@
1
- import React, { useState } from 'react';
2
- import Collapse from '@mui/material/Collapse';
3
- import List from '@mui/material/List';
4
- import ListItem from '@mui/material/ListItem';
5
-
6
- export const AlignLeft = () => (
7
- <svg width="20" height="20" viewBox="0 0 66 66" fill="none" xmlns="http://www.w3.org/2000/svg">
8
- <path
9
- d="M42.1875 4.75C42.1875 7.38672 39.9902 9.4375 37.5 9.4375H4.6875C2.05078 9.4375 0 7.38672 0 4.75C0 2.25977 2.05078 0.0625 4.6875 0.0625H37.5C39.9902 0.0625 42.1875 2.25977 42.1875 4.75ZM42.1875 42.25C42.1875 44.8867 39.9902 46.9375 37.5 46.9375H4.6875C2.05078 46.9375 0 44.8867 0 42.25C0 39.7598 2.05078 37.5625 4.6875 37.5625H37.5C39.9902 37.5625 42.1875 39.7598 42.1875 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z"
10
- fill="currentColor"
11
- />
12
- </svg>
13
- );
14
-
15
- export const AlignRight = () => (
16
- <svg width="20" height="20" viewBox="0 0 66 66" fill="none" xmlns="http://www.w3.org/2000/svg">
17
- <path
18
- d="M65.625 4.75C65.625 7.38672 63.4277 9.4375 60.9375 9.4375H28.125C25.4883 9.4375 23.4375 7.38672 23.4375 4.75C23.4375 2.25977 25.4883 0.0625 28.125 0.0625H60.9375C63.4277 0.0625 65.625 2.25977 65.625 4.75ZM65.625 42.25C65.625 44.8867 63.4277 46.9375 60.9375 46.9375H28.125C25.4883 46.9375 23.4375 44.8867 23.4375 42.25C23.4375 39.7598 25.4883 37.5625 28.125 37.5625H60.9375C63.4277 37.5625 65.625 39.7598 65.625 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z"
19
- fill="currentColor"
20
- />
21
- </svg>
22
- );
23
-
24
- export const AlignCenter = () => (
25
- <svg width="20" height="20" viewBox="0 0 66 66" fill="none" xmlns="http://www.w3.org/2000/svg">
26
- <path
27
- d="M51.5625 4.75C51.5625 7.38672 49.3652 9.4375 46.875 9.4375H18.75C16.1133 9.4375 14.0625 7.38672 14.0625 4.75C14.0625 2.25977 16.1133 0.0625 18.75 0.0625H46.875C49.3652 0.0625 51.5625 2.25977 51.5625 4.75ZM65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5ZM0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61ZM51.5625 42.25C51.5625 44.8867 49.3652 46.9375 46.875 46.9375H18.75C16.1133 46.9375 14.0625 44.8867 14.0625 42.25C14.0625 39.7598 16.1133 37.5625 18.75 37.5625H46.875C49.3652 37.5625 51.5625 39.7598 51.5625 42.25Z"
28
- fill="currentColor"
29
- />
30
- </svg>
31
- );
32
-
33
- export const AlignJustify = () => (
34
- <svg width="20" height="20" viewBox="0 0 66 66" fill="none" xmlns="http://www.w3.org/2000/svg">
35
- <path
36
- d="M65.625 4.75C65.625 7.38672 63.4277 9.4375 60.9375 9.4375H4.6875C2.05078 9.4375 0 7.38672 0 4.75C0 2.25977 2.05078 0.0625 4.6875 0.0625H60.9375C63.4277 0.0625 65.625 2.25977 65.625 4.75ZM65.625 42.25C65.625 44.8867 63.4277 46.9375 60.9375 46.9375H4.6875C2.05078 46.9375 0 44.8867 0 42.25C0 39.7598 2.05078 37.5625 4.6875 37.5625H60.9375C63.4277 37.5625 65.625 39.7598 65.625 42.25ZM0 23.5C0 21.0098 2.05078 18.8125 4.6875 18.8125H60.9375C63.4277 18.8125 65.625 21.0098 65.625 23.5C65.625 26.1367 63.4277 28.1875 60.9375 28.1875H4.6875C2.05078 28.1875 0 26.1367 0 23.5ZM65.625 61C65.625 63.6367 63.4277 65.6875 60.9375 65.6875H4.6875C2.05078 65.6875 0 63.6367 0 61C0 58.5098 2.05078 56.3125 4.6875 56.3125H60.9375C63.4277 56.3125 65.625 58.5098 65.625 61Z"
37
- fill="currentColor"
38
- />
39
- </svg>
40
- );
41
-
42
- export default ({ editor, onChange }) => {
43
- const [open, setOpen] = useState(false);
44
-
45
- let icon;
46
-
47
- switch (true) {
48
- case editor.isActive({ textAlign: 'right' }):
49
- icon = <AlignRight />;
50
- break;
51
- case editor.isActive({ textAlign: 'center' }):
52
- icon = <AlignCenter />;
53
- break;
54
- case editor.isActive({ textAlign: 'justify' }):
55
- icon = <AlignJustify />;
56
- break;
57
- default:
58
- icon = <AlignLeft />;
59
- break;
60
- }
61
-
62
- const applyAlignment = (event) => {
63
- const alignType = event.currentTarget?.getAttribute('value');
64
-
65
- if (alignType) {
66
- editor.commands.setTextAlign(alignType);
67
- }
68
-
69
- setOpen(false);
70
- };
71
-
72
- const onMouseDown = (event) => {
73
- event.preventDefault();
74
- event.stopPropagation();
75
- setOpen(!open);
76
- };
77
-
78
- return (
79
- <div>
80
- <div style={{ display: 'flex', alignItems: 'center' }} onClick={onMouseDown}>
81
- {icon}
82
- <span style={{ marginLeft: '5px', fontSize: '8px' }}>&#9660;</span>
83
- </div>
84
- <Collapse in={open} timeout="auto" unmountOnExit style={{ position: 'absolute' }}>
85
- <List
86
- component="div"
87
- disablePadding
88
- style={{
89
- background: '#fff',
90
- display: 'flex',
91
- flexDirection: 'row',
92
- padding: 0,
93
- }}
94
- >
95
- <ListItem button type="submit" value="left" aria-label="Align text left" onClick={applyAlignment}>
96
- <AlignLeft />
97
- </ListItem>
98
-
99
- <ListItem button type="submit" value="center" aria-label="Align text center" onClick={applyAlignment}>
100
- <AlignCenter />
101
- </ListItem>
102
-
103
- <ListItem button type="submit" value="right" aria-label="Align text right" onClick={applyAlignment}>
104
- <AlignRight />
105
- </ListItem>
106
-
107
- <ListItem button type="submit" value="justify" aria-label="Justify text" onClick={applyAlignment}>
108
- <AlignJustify />
109
- </ListItem>
110
- </List>
111
- </Collapse>
112
- </div>
113
- );
114
- };
@@ -1,82 +0,0 @@
1
- import React from 'react';
2
- import DialogContent from '@mui/material/DialogContent';
3
- import ArrowBackIos from '@mui/icons-material/ArrowBackIos';
4
- import TextField from '@mui/material/TextField';
5
- import DialogActions from '@mui/material/DialogActions';
6
- import Button from '@mui/material/Button';
7
- import Dialog from '@mui/material/Dialog';
8
- import PropTypes from 'prop-types';
9
-
10
- export class AltDialog extends React.Component {
11
- static propTypes = {
12
- onDone: PropTypes.func.isRequired,
13
- alt: PropTypes.string,
14
- };
15
-
16
- constructor(props) {
17
- super(props);
18
-
19
- const { alt } = props;
20
-
21
- this.state = {
22
- value: alt,
23
- };
24
- }
25
-
26
- closeDialog = () => {
27
- const allDialogs = document.querySelectorAll('#text-dialog');
28
-
29
- allDialogs.forEach(function (s) {
30
- return s.remove();
31
- });
32
- };
33
-
34
- onDone = () => {
35
- const { onDone } = this.props;
36
- const { value } = this.state;
37
-
38
- onDone(value);
39
- this.closeDialog();
40
- };
41
-
42
- handleOverflow = () => {
43
- document.body.style.removeProperty('overflow');
44
- };
45
-
46
- render() {
47
- const { value } = this.state;
48
-
49
- return (
50
- <Dialog
51
- open
52
- disablePortal
53
- onClose={this.closeDialog}
54
- id="text-dialog"
55
- hideBackdrop
56
- disableScrollLock
57
- onEntered={this.handleOverflow}
58
- >
59
- <DialogContent>
60
- <div style={{ display: 'flex' }}>
61
- <ArrowBackIos style={{ paddingTop: '6px' }} />
62
- <TextField
63
- multiline
64
- placeholder={'Enter an Alt Text description of this image'}
65
- helperText={
66
- 'Users with visual limitations rely on Alt Text, since screen readers cannot otherwise describe the contents of an image.'
67
- }
68
- value={value}
69
- onChange={(event) => this.setState({ value: event.target.value })}
70
- FormHelperTextProps={{ style: { fontSize: 14 } }}
71
- />
72
- </div>
73
- </DialogContent>
74
- <DialogActions>
75
- <Button onClick={this.onDone}>Done</Button>
76
- </DialogActions>
77
- </Dialog>
78
- );
79
- }
80
- }
81
-
82
- export default AltDialog;
@@ -1,99 +0,0 @@
1
- import PropTypes from 'prop-types';
2
- import React from 'react';
3
- import debug from 'debug';
4
- import ReactDOM from 'react-dom';
5
- import { styled } from '@mui/material/styles';
6
-
7
- import AltDialog from './AltDialog';
8
- import { MarkButton } from '../common/toolbar-buttons';
9
-
10
- const log = debug('@pie-lib:editable-html:plugins:image:image-toolbar');
11
-
12
- const StyledHolder = styled('div')(({ theme }) => ({
13
- paddingLeft: theme.spacing.unit,
14
- display: 'flex',
15
- alignItems: 'center',
16
- }));
17
-
18
- const StyledAltText = styled('span', {
19
- shouldForwardProp: (prop) => !['disabled', 'hasAlignmentButtons'].includes(prop),
20
- })(({ disabled, hasAlignmentButtons }) => ({
21
- ...(disabled && {
22
- opacity: 0.5,
23
- }),
24
- ...(hasAlignmentButtons && {
25
- borderLeft: '1px solid grey',
26
- paddingLeft: 8,
27
- marginLeft: 4,
28
- }),
29
- }));
30
-
31
- const AlignmentButton = ({ alignment, active, onClick }) => {
32
- return (
33
- <MarkButton active={active} onToggle={() => onClick(alignment)} label={alignment}>
34
- {alignment}
35
- </MarkButton>
36
- );
37
- };
38
-
39
- AlignmentButton.propTypes = {
40
- alignment: PropTypes.string.isRequired,
41
- active: PropTypes.bool.isRequired,
42
- onClick: PropTypes.func.isRequired,
43
- };
44
-
45
- export class ImageToolbar extends React.Component {
46
- static propTypes = {
47
- onChange: PropTypes.func.isRequired,
48
- alignment: PropTypes.string,
49
- alt: PropTypes.string,
50
- imageLoaded: PropTypes.bool,
51
- disableImageAlignmentButtons: PropTypes.bool,
52
- };
53
-
54
- onAltTextDone = (newAlt) => {
55
- log('[onAltTextDone]: alt:', newAlt);
56
-
57
- this.props.onChange({ alt: newAlt }, true);
58
- };
59
-
60
- onAlignmentClick = (alignment) => {
61
- log('[onAlignmentClick]: alignment:', alignment);
62
- this.props.onChange({ alignment });
63
- };
64
-
65
- renderDialog = () => {
66
- const { alt } = this.props;
67
- const popoverEl = document.createElement('div');
68
-
69
- const el = <AltDialog alt={alt} onDone={this.onAltTextDone} />;
70
-
71
- ReactDOM.render(el, popoverEl);
72
-
73
- document.body.appendChild(popoverEl);
74
- };
75
-
76
- render() {
77
- const { alignment, imageLoaded, disableImageAlignmentButtons } = this.props;
78
- return (
79
- <StyledHolder>
80
- {!disableImageAlignmentButtons && (
81
- <>
82
- <AlignmentButton alignment={'left'} active={alignment === 'left'} onClick={this.onAlignmentClick} />
83
- <AlignmentButton alignment={'center'} active={alignment === 'center'} onClick={this.onAlignmentClick} />
84
- <AlignmentButton alignment={'right'} active={alignment === 'right'} onClick={this.onAlignmentClick} />
85
- </>
86
- )}
87
- <StyledAltText
88
- disabled={!imageLoaded}
89
- hasAlignmentButtons={!disableImageAlignmentButtons}
90
- onMouseDown={(event) => imageLoaded && this.renderDialog(event)}
91
- >
92
- Alt text
93
- </StyledAltText>
94
- </StyledHolder>
95
- );
96
- }
97
- }
98
-
99
- export default ImageToolbar;
@@ -1,107 +0,0 @@
1
- import debug from 'debug';
2
-
3
- const log = debug('@pie-lib:editable-html:image:insert-image-handler');
4
-
5
- /**
6
- * Handles user selection, insertion (or cancellation) of an image into the editor.
7
- * @param {Block} placeholderBlock - a block that has been added to the editor as a place holder for the image
8
- * @param {Function} onFinish - a function to call if uploading fails or succeeds
9
- * @param {Function} getValue - a function to return the value of the editor
10
- * @param {Function} onChange - callback to notify changes applied by the handler
11
- * @param {Boolean} isPasted - a boolean that keeps track if the file is pasted
12
- */
13
- class InsertImageHandler {
14
- constructor(editor, nodeInfo, onFinish, isPasted = false) {
15
- this.editor = editor;
16
- this.nodeInfo = nodeInfo;
17
- this.node = nodeInfo[0];
18
- this.nodePos = nodeInfo[1];
19
- this.onFinish = onFinish;
20
- this.isPasted = isPasted;
21
- this.chosenFile = null;
22
- }
23
-
24
- cancel() {
25
- log('insert cancelled');
26
-
27
- try {
28
- this.deleteNode();
29
- this.onFinish(false);
30
- } catch (err) {
31
- //
32
- } finally {
33
- this.editor._insertingImage = false;
34
- }
35
- }
36
-
37
- updateNode(newAttrs) {
38
- const { state, view } = this.editor;
39
- const { tr } = state;
40
- const node = state.doc.nodeAt(this.nodePos);
41
-
42
- if (node) {
43
- const transaction = tr.setNodeMarkup(this.nodePos, undefined, { ...node.attrs, ...newAttrs });
44
-
45
- view.dispatch(transaction);
46
- }
47
- }
48
-
49
- deleteNode() {
50
- const { state, view } = this.editor;
51
- const { tr } = state;
52
-
53
- const transaction = tr.delete(this.nodePos, this.nodePos + this.node.nodeSize);
54
-
55
- view.dispatch(transaction);
56
- }
57
-
58
- done(err, src) {
59
- log('done: err:', err);
60
- if (err) {
61
- //eslint-disable-next-line
62
- console.log(err);
63
- this.onFinish(false);
64
- } else {
65
- this.updateNode({ loaded: true, src, percent: 100 });
66
- this.onFinish(true);
67
- }
68
-
69
- this.editor._insertingImage = false;
70
- }
71
-
72
- /**
73
- * Notify handler that the user chose a file - will create a change with a preview in the editor.
74
- *
75
- * @param {File} file - the file that the user chose using a file input.
76
- */
77
- fileChosen(file) {
78
- if (!file) {
79
- return;
80
- }
81
-
82
- // Save the chosen file to this.chosenFile
83
- this.chosenFile = file;
84
- this.editor._insertingImage = false;
85
-
86
- log('[fileChosen] file: ', file);
87
- const reader = new FileReader();
88
- reader.onload = () => {
89
- const dataURL = reader.result;
90
-
91
- this.updateNode({ src: dataURL });
92
- };
93
- reader.readAsDataURL(file);
94
- }
95
-
96
- progress(percent, bytes, total) {
97
- log('progress: ', percent, bytes, total);
98
- this.updateNode({ percent });
99
- }
100
-
101
- // Add a getter method to retrieve the chosen file
102
- getChosenFile() {
103
- return this.chosenFile;
104
- }
105
- }
106
-
107
- export default InsertImageHandler;