@pie-lib/editable-html 12.1.1-next.0 → 12.2.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/block-tags.js +0 -1
- package/lib/block-tags.js.map +1 -1
- package/lib/constants.js +0 -1
- package/lib/constants.js.map +1 -1
- package/lib/editor.js +6 -37
- package/lib/editor.js.map +1 -1
- package/lib/index.js +0 -16
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +0 -3
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +0 -1
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +6 -21
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +0 -2
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +0 -1
- package/lib/plugins/css/icons/index.js.map +1 -1
- package/lib/plugins/css/index.js +0 -12
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/customPlugin/index.js +0 -11
- package/lib/plugins/customPlugin/index.js.map +1 -1
- package/lib/plugins/html/icons/index.js +0 -1
- package/lib/plugins/html/icons/index.js.map +1 -1
- package/lib/plugins/html/index.js +0 -1
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +0 -5
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +0 -14
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +0 -3
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +0 -14
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +0 -1
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +4 -22
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +0 -12
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +3 -18
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +0 -13
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +0 -18
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +0 -2
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +0 -2
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/rendering/index.js +0 -10
- package/lib/plugins/rendering/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +0 -17
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +0 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/utils.js +0 -10
- package/lib/plugins/respArea/drag-in-the-blank/utils.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +0 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +0 -10
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +2 -13
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +0 -1
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +0 -1
- package/lib/plugins/respArea/math-templated/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +0 -6
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +0 -7
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
- package/lib/plugins/table/icons/index.js +0 -2
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +0 -18
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +0 -15
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +0 -15
- package/lib/plugins/textAlign/icons/index.js.map +1 -1
- package/lib/plugins/textAlign/index.js +0 -1
- package/lib/plugins/textAlign/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +0 -14
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +0 -1
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +0 -12
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +0 -1
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +0 -12
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +2 -16
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +0 -3
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +5 -29
- package/lib/serialization.js.map +1 -1
- package/lib/shared/alert-dialog.js +0 -1
- package/lib/theme.js +0 -1
- package/lib/theme.js.map +1 -1
- package/package.json +12 -8
- package/src/__tests__/editor-utils.test.js +1 -1
- package/src/__tests__/serialization.test.js +0 -1
- package/src/editor.jsx +18 -22
- package/src/index.jsx +2 -2
- package/src/plugins/characters/index.jsx +2 -2
- package/src/plugins/html/icons/index.jsx +1 -3
- package/src/plugins/html/index.jsx +2 -10
- package/src/plugins/image/__tests__/component.test.jsx +1 -1
- package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +1 -5
- package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -1
- package/src/plugins/image/__tests__/index.test.js +0 -3
- package/src/plugins/image/alt-dialog.jsx +4 -3
- package/src/plugins/index.jsx +1 -2
- package/src/plugins/list/__tests__/index.test.js +0 -2
- package/src/plugins/list/index.jsx +6 -6
- package/src/plugins/math/__tests__/index.test.jsx +1 -1
- package/src/plugins/math/index.jsx +2 -2
- package/src/plugins/media/media-dialog.js +6 -23
- package/src/plugins/media/media-toolbar.jsx +2 -8
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +11 -33
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +26 -26
- package/src/plugins/respArea/index.jsx +1 -1
- package/src/plugins/table/__tests__/index.test.jsx +5 -5
- package/src/plugins/table/index.jsx +1 -6
- package/src/plugins/table/table-toolbar.jsx +1 -1
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +2 -6
- package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +2 -2
- package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +1 -1
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +1 -1
- package/src/plugins/toolbar/done-button.jsx +1 -6
- package/src/plugins/toolbar/editor-and-toolbar.jsx +2 -7
- package/src/plugins/toolbar/toolbar.jsx +4 -3
- package/src/serialization.jsx +6 -6
- package/NEXT.CHANGELOG.json +0 -1
|
@@ -22,7 +22,8 @@ const matchYoutubeUrl = (url) => {
|
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const p =
|
|
25
|
+
const p =
|
|
26
|
+
/^(?:https?:\/\/)?(?:m\.|www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/;
|
|
26
27
|
if (url.match(p)) {
|
|
27
28
|
return url.match(p)[1];
|
|
28
29
|
}
|
|
@@ -433,19 +434,8 @@ export class MediaDialog extends React.Component {
|
|
|
433
434
|
|
|
434
435
|
render() {
|
|
435
436
|
const { open, disablePortal, type, edit, uploadSoundSupport } = this.props;
|
|
436
|
-
const {
|
|
437
|
-
|
|
438
|
-
height,
|
|
439
|
-
invalid,
|
|
440
|
-
starts,
|
|
441
|
-
width,
|
|
442
|
-
url,
|
|
443
|
-
mimeType,
|
|
444
|
-
formattedUrl,
|
|
445
|
-
updating,
|
|
446
|
-
tabValue,
|
|
447
|
-
fileUpload,
|
|
448
|
-
} = this.state;
|
|
437
|
+
const { ends, height, invalid, starts, width, url, mimeType, formattedUrl, updating, tabValue, fileUpload } =
|
|
438
|
+
this.state;
|
|
449
439
|
const isYoutube = matchYoutubeUrl(url);
|
|
450
440
|
const isInsertURL = tabValue === tabsTypeMap.insertUrl;
|
|
451
441
|
const isUploadMedia = tabValue === tabsTypeMap.uploadFile;
|
|
@@ -568,10 +558,7 @@ export class MediaDialog extends React.Component {
|
|
|
568
558
|
<audio controls="controls" controlsList="nodownload">
|
|
569
559
|
<source type={mimeType} src={fileUpload.url} />
|
|
570
560
|
</audio>
|
|
571
|
-
<StyledDeleteIcon
|
|
572
|
-
aria-label="delete"
|
|
573
|
-
onClick={this.handleRemoveFile}
|
|
574
|
-
size="large">
|
|
561
|
+
<StyledDeleteIcon aria-label="delete" onClick={this.handleRemoveFile} size="large">
|
|
575
562
|
<ActionDelete />
|
|
576
563
|
</StyledDeleteIcon>
|
|
577
564
|
</StyledRow>
|
|
@@ -587,11 +574,7 @@ export class MediaDialog extends React.Component {
|
|
|
587
574
|
) : !fileUpload.loading ? (
|
|
588
575
|
<input accept="audio/*" onChange={this.handleUploadFile} type="file" />
|
|
589
576
|
) : null}
|
|
590
|
-
{!!fileUpload.error &&
|
|
591
|
-
<StyledError variant="caption">
|
|
592
|
-
{fileUpload.error}
|
|
593
|
-
</StyledError>
|
|
594
|
-
)}
|
|
577
|
+
{!!fileUpload.error && <StyledError variant="caption">{fileUpload.error}</StyledError>}
|
|
595
578
|
</div>
|
|
596
579
|
</StyledUploadInput>
|
|
597
580
|
)}
|
|
@@ -39,14 +39,8 @@ class MediaToolbar extends React.Component {
|
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
41
|
<StyledMediaToolbar>
|
|
42
|
-
{hideEdit ? null :
|
|
43
|
-
|
|
44
|
-
Edit Settings
|
|
45
|
-
</StyledEditContainer>
|
|
46
|
-
)}
|
|
47
|
-
<StyledRemoveContainer onClick={onRemove}>
|
|
48
|
-
Remove
|
|
49
|
-
</StyledRemoveContainer>
|
|
42
|
+
{hideEdit ? null : <StyledEditContainer onClick={onEdit}>Edit Settings</StyledEditContainer>}
|
|
43
|
+
<StyledRemoveContainer onClick={onRemove}>Remove</StyledRemoveContainer>
|
|
50
44
|
</StyledMediaToolbar>
|
|
51
45
|
);
|
|
52
46
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import { useDraggable, useDroppable } from '@dnd-kit/core';
|
|
@@ -7,7 +7,7 @@ import { renderMath } from '@pie-lib/math-rendering';
|
|
|
7
7
|
import { styled } from '@mui/material/styles';
|
|
8
8
|
|
|
9
9
|
import { GripIcon } from '../icons';
|
|
10
|
-
import {
|
|
10
|
+
import { onRemoveResponse, onValueChange } from './utils';
|
|
11
11
|
|
|
12
12
|
const StyledContent = styled('span')(({ theme }) => ({
|
|
13
13
|
border: `solid 0px ${theme.palette.primary.main}`,
|
|
@@ -28,15 +28,7 @@ const StyledContent = styled('span')(({ theme }) => ({
|
|
|
28
28
|
},
|
|
29
29
|
}));
|
|
30
30
|
|
|
31
|
-
export function BlankContent({
|
|
32
|
-
n,
|
|
33
|
-
children,
|
|
34
|
-
isDragging,
|
|
35
|
-
isOver,
|
|
36
|
-
dragItem,
|
|
37
|
-
value,
|
|
38
|
-
style: externalStyle
|
|
39
|
-
}) {
|
|
31
|
+
export function BlankContent({ n, children, isDragging, isOver, dragItem, value, style: externalStyle }) {
|
|
40
32
|
const [hoveredElementSize, setHoveredElementSize] = useState(null);
|
|
41
33
|
const elementRef = useRef(null);
|
|
42
34
|
|
|
@@ -142,15 +134,7 @@ BlankContent.propTypes = {
|
|
|
142
134
|
style: PropTypes.object,
|
|
143
135
|
};
|
|
144
136
|
|
|
145
|
-
function DragDropChoice({
|
|
146
|
-
value,
|
|
147
|
-
disabled,
|
|
148
|
-
instanceId,
|
|
149
|
-
children,
|
|
150
|
-
n,
|
|
151
|
-
nodeProps,
|
|
152
|
-
opts,
|
|
153
|
-
}) {
|
|
137
|
+
function DragDropChoice({ value, disabled, instanceId, children, n, nodeProps, opts }) {
|
|
154
138
|
const {
|
|
155
139
|
attributes: dragAttributes,
|
|
156
140
|
listeners: dragListeners,
|
|
@@ -171,8 +155,7 @@ function DragDropChoice({
|
|
|
171
155
|
onRemove: (draggedData) => onRemoveResponse(nodeProps, draggedData.value),
|
|
172
156
|
onDrop: (draggedData, dropData) => {
|
|
173
157
|
// check if we're dropping into a blank
|
|
174
|
-
const isValidBlank =
|
|
175
|
-
dropData?.type === 'drag-in-the-blank-drop-choice';
|
|
158
|
+
const isValidBlank = dropData?.type === 'drag-in-the-blank-drop-choice';
|
|
176
159
|
|
|
177
160
|
if (!isValidBlank) return;
|
|
178
161
|
|
|
@@ -182,8 +165,8 @@ function DragDropChoice({
|
|
|
182
165
|
if (!opts.options.duplicates && draggedData.fromChoice) {
|
|
183
166
|
onRemoveResponse(nodeProps, draggedData.value);
|
|
184
167
|
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
168
|
+
},
|
|
169
|
+
},
|
|
187
170
|
});
|
|
188
171
|
|
|
189
172
|
const {
|
|
@@ -203,8 +186,7 @@ function DragDropChoice({
|
|
|
203
186
|
opts,
|
|
204
187
|
onDrop: (draggedData, dropData) => {
|
|
205
188
|
// check if we're dropping into a blank
|
|
206
|
-
const isValidBlank =
|
|
207
|
-
dropData?.type === 'drag-in-the-blank-drop-choice';
|
|
189
|
+
const isValidBlank = dropData?.type === 'drag-in-the-blank-drop-choice';
|
|
208
190
|
|
|
209
191
|
if (!isValidBlank) return;
|
|
210
192
|
|
|
@@ -232,8 +214,8 @@ function DragDropChoice({
|
|
|
232
214
|
// clear original blank - slight delay to ensure state updates correctly
|
|
233
215
|
setTimeout(() => onRemoveResponse(nodeProps, draggedData.value), 10);
|
|
234
216
|
}
|
|
235
|
-
}
|
|
236
|
-
}
|
|
217
|
+
},
|
|
218
|
+
},
|
|
237
219
|
});
|
|
238
220
|
|
|
239
221
|
const setNodeRef = (node) => {
|
|
@@ -262,11 +244,7 @@ function DragDropChoice({
|
|
|
262
244
|
</span>
|
|
263
245
|
);
|
|
264
246
|
|
|
265
|
-
const content = (
|
|
266
|
-
<StyledContent className={classnames(isOver && 'over')}>
|
|
267
|
-
{dragEl}
|
|
268
|
-
</StyledContent>
|
|
269
|
-
);
|
|
247
|
+
const content = <StyledContent className={classnames(isOver && 'over')}>{dragEl}</StyledContent>;
|
|
270
248
|
|
|
271
249
|
return content;
|
|
272
250
|
}
|
|
@@ -1,38 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import DragDropTile from './choice';
|
|
4
|
-
import {
|
|
4
|
+
import { onRemoveResponse, onValueChange } from './utils';
|
|
5
5
|
|
|
6
6
|
const DragDrop = ({ attributes, data, n, nodeProps, opts }) => {
|
|
7
7
|
const { inTable } = data;
|
|
8
8
|
|
|
9
9
|
return (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
<span
|
|
11
|
+
{...attributes}
|
|
12
|
+
style={{
|
|
13
|
+
display: 'inline-flex',
|
|
14
|
+
minHeight: '50px',
|
|
15
|
+
minWidth: '178px',
|
|
16
|
+
position: 'relative',
|
|
17
|
+
margin: inTable ? '10px' : '0 10px',
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
}}
|
|
20
|
+
>
|
|
21
|
+
<DragDropTile
|
|
22
|
+
n={n}
|
|
23
|
+
dragKey={n.key}
|
|
24
|
+
targetId={`drop-${n.key}`}
|
|
25
|
+
value={data}
|
|
26
|
+
duplicates={opts.options.duplicates}
|
|
27
|
+
onChange={(value) => onValueChange(nodeProps, n, value)}
|
|
28
|
+
removeResponse={(value) => onRemoveResponse(nodeProps, value)}
|
|
29
|
+
instanceId={nodeProps.editor?.props?.instanceId || 'default'}
|
|
30
|
+
nodeProps={nodeProps}
|
|
31
|
+
opts={opts}
|
|
20
32
|
>
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
targetId={`drop-${n.key}`}
|
|
25
|
-
value={data}
|
|
26
|
-
duplicates={opts.options.duplicates}
|
|
27
|
-
onChange={(value) => onValueChange(nodeProps, n, value)}
|
|
28
|
-
removeResponse={(value) => onRemoveResponse(nodeProps, value)}
|
|
29
|
-
instanceId={nodeProps.editor?.props?.instanceId || 'default'}
|
|
30
|
-
nodeProps={nodeProps}
|
|
31
|
-
opts={opts}
|
|
32
|
-
>
|
|
33
|
-
{nodeProps.children}
|
|
34
|
-
</DragDropTile>
|
|
35
|
-
</span>
|
|
33
|
+
{nodeProps.children}
|
|
34
|
+
</DragDropTile>
|
|
35
|
+
</span>
|
|
36
36
|
);
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import EditTable from 'slate-edit-table';
|
|
2
|
-
import TablePlugin, {
|
|
3
|
-
import {
|
|
2
|
+
import TablePlugin, { parseStyleString, reactAttributes, serialization } from '../index';
|
|
3
|
+
import { Block, Data, PathUtils } from 'slate';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
6
|
jest.mock('slate-edit-table', () => {
|
|
@@ -8,14 +8,14 @@ jest.mock('slate-edit-table', () => {
|
|
|
8
8
|
default: jest.fn().mockReturnThis(),
|
|
9
9
|
utils: {
|
|
10
10
|
isSelectionInTable: jest.fn().mockReturnValue(true),
|
|
11
|
-
createTable: jest.fn(function(c) {
|
|
11
|
+
createTable: jest.fn(function (c) {
|
|
12
12
|
return {
|
|
13
13
|
toJSON: jest.fn().mockReturnValue({ object: 'block', type: 'table' }),
|
|
14
14
|
};
|
|
15
15
|
}),
|
|
16
16
|
},
|
|
17
17
|
changes: {
|
|
18
|
-
insertTable: jest.fn(function(c) {
|
|
18
|
+
insertTable: jest.fn(function (c) {
|
|
19
19
|
return c;
|
|
20
20
|
}),
|
|
21
21
|
},
|
|
@@ -328,7 +328,7 @@ describe('serialization', () => {
|
|
|
328
328
|
const el = {
|
|
329
329
|
tagName: 'td',
|
|
330
330
|
childNodes: [],
|
|
331
|
-
getAttribute: jest.fn(function(name) {
|
|
331
|
+
getAttribute: jest.fn(function (name) {
|
|
332
332
|
const o = {
|
|
333
333
|
class: 'class name',
|
|
334
334
|
colspan: '1',
|
|
@@ -30,12 +30,7 @@ const Table = (props) => {
|
|
|
30
30
|
const nodeAttributes = dataToAttributes(props.node.data);
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
|
-
<StyledTable
|
|
34
|
-
{...props.attributes}
|
|
35
|
-
{...nodeAttributes}
|
|
36
|
-
onFocus={props.onFocus}
|
|
37
|
-
onBlur={props.onBlur}
|
|
38
|
-
>
|
|
33
|
+
<StyledTable {...props.attributes} {...nodeAttributes} onFocus={props.onFocus} onBlur={props.onBlur}>
|
|
39
34
|
<tbody>{props.children}</tbody>
|
|
40
35
|
</StyledTable>
|
|
41
36
|
);
|
|
@@ -5,7 +5,7 @@ import { DoneButton } from '../toolbar/done-button';
|
|
|
5
5
|
import BorderAll from '@mui/icons-material/BorderAll';
|
|
6
6
|
import { ToolbarButton } from '../toolbar/default-toolbar';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { AddColumn, AddRow, RemoveColumn, RemoveRow, RemoveTable } from './icons';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import debug from 'debug';
|
|
11
11
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render, screen
|
|
3
|
-
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
4
3
|
import { Value } from 'slate';
|
|
5
4
|
import { DefaultToolbar } from '../default-toolbar';
|
|
6
5
|
|
|
@@ -50,10 +49,7 @@ describe('default-toolbar', () => {
|
|
|
50
49
|
|
|
51
50
|
it('renders with 1 plugin', () => {
|
|
52
51
|
const { container } = render(
|
|
53
|
-
<DefaultToolbar
|
|
54
|
-
{...defaultProps}
|
|
55
|
-
plugins={[{ toolbar: { icon: <span>Icon1</span> }, name: 'plugin-one' }]}
|
|
56
|
-
/>,
|
|
52
|
+
<DefaultToolbar {...defaultProps} plugins={[{ toolbar: { icon: <span>Icon1</span> }, name: 'plugin-one' }]} />,
|
|
57
53
|
);
|
|
58
54
|
|
|
59
55
|
expect(container.firstChild).toBeInTheDocument();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { classObject, mockIconButton } from '../../../__tests__/utils';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import { EditorAndToolbar
|
|
3
|
+
import { Value } from 'slate';
|
|
4
|
+
import { EditorAndToolbar } from '../editor-and-toolbar';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
import { render, screen } from '@testing-library/react';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { classObject } from '../../../__tests__/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { RawButton, RawMarkButton } from '../toolbar-buttons';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { render, screen } from '@testing-library/react';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { classObject, mockMathInput } from '../../../__tests__/utils';
|
|
2
|
-
import {
|
|
2
|
+
import { Inline, Value } from 'slate';
|
|
3
3
|
import { Toolbar } from '../toolbar';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render, screen } from '@testing-library/react';
|
|
@@ -14,12 +14,7 @@ const StyledIconButton = styled(IconButton)({
|
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
export const RawDoneButton = ({ onClick, doneButtonRef }) => (
|
|
17
|
-
<StyledIconButton
|
|
18
|
-
aria-label="Done"
|
|
19
|
-
buttonRef={doneButtonRef}
|
|
20
|
-
onClick={onClick}
|
|
21
|
-
size="large"
|
|
22
|
-
>
|
|
17
|
+
<StyledIconButton aria-label="Done" buttonRef={doneButtonRef} onClick={onClick} size="large">
|
|
23
18
|
<Check />
|
|
24
19
|
</StyledIconButton>
|
|
25
20
|
);
|
|
@@ -193,19 +193,14 @@ export class EditorAndToolbar extends React.Component {
|
|
|
193
193
|
log('[render] inFocus: ', inFocus, 'value.isFocused:', value.isFocused, 'focused node: ', focusedNode);
|
|
194
194
|
|
|
195
195
|
return (
|
|
196
|
-
<Root
|
|
197
|
-
noBorder={toolbarOpts && toolbarOpts.noBorder}
|
|
198
|
-
error={toolbarOpts && toolbarOpts.error}
|
|
199
|
-
>
|
|
196
|
+
<Root noBorder={toolbarOpts && toolbarOpts.noBorder} error={toolbarOpts && toolbarOpts.error}>
|
|
200
197
|
<EditorHolder
|
|
201
198
|
inFocus={inFocus}
|
|
202
199
|
readOnly={readOnly}
|
|
203
200
|
disableUnderline={disableUnderline}
|
|
204
201
|
disableScrollbar={disableScrollbar}
|
|
205
202
|
>
|
|
206
|
-
<ChildrenContainer noPadding={toolbarOpts && toolbarOpts.noPadding}>
|
|
207
|
-
{clonedChildren}
|
|
208
|
-
</ChildrenContainer>
|
|
203
|
+
<ChildrenContainer noPadding={toolbarOpts && toolbarOpts.noPadding}>{clonedChildren}</ChildrenContainer>
|
|
209
204
|
</EditorHolder>
|
|
210
205
|
|
|
211
206
|
<Toolbar
|
|
@@ -5,11 +5,11 @@ import IconButton from '@mui/material/IconButton';
|
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import debug from 'debug';
|
|
7
7
|
import SlatePropTypes from 'slate-prop-types';
|
|
8
|
-
import debounce from 'lodash
|
|
8
|
+
import { debounce } from 'lodash-es';
|
|
9
9
|
|
|
10
10
|
import { DoneButton } from './done-button';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { findParentNode, findSingleNode } from '../utils';
|
|
13
13
|
import { styled } from '@mui/material/styles';
|
|
14
14
|
import DefaultToolbar from './default-toolbar';
|
|
15
15
|
import { removeDialogs as removeCharacterDialogs } from '../characters';
|
|
@@ -18,7 +18,8 @@ import { PIE_TOOLBAR__CLASS } from '../../constants';
|
|
|
18
18
|
const log = debug('@pie-lib:editable-html:plugins:toolbar');
|
|
19
19
|
|
|
20
20
|
const StyledToolbar = styled('div', {
|
|
21
|
-
shouldForwardProp: (prop) =>
|
|
21
|
+
shouldForwardProp: (prop) =>
|
|
22
|
+
!['hasDoneButton', 'position', 'alignment', 'focused', 'autoWidth', 'hidden'].includes(prop),
|
|
22
23
|
})(({ hasDoneButton, position, alignment, focused, autoWidth, hidden }) => ({
|
|
23
24
|
position: 'absolute',
|
|
24
25
|
zIndex: 10,
|
package/src/serialization.jsx
CHANGED
|
@@ -2,7 +2,7 @@ import Html from 'slate-html-serializer';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import debug from 'debug';
|
|
4
4
|
import { object as toStyleObject } from 'to-style';
|
|
5
|
-
import isEmpty from 'lodash
|
|
5
|
+
import { isEmpty } from 'lodash-es';
|
|
6
6
|
|
|
7
7
|
import { serialization as imgSerialization } from './plugins/image';
|
|
8
8
|
import { serialization as mathSerialization } from './plugins/math';
|
|
@@ -368,7 +368,7 @@ const serializer = new Html({
|
|
|
368
368
|
|
|
369
369
|
const _extends =
|
|
370
370
|
Object.assign ||
|
|
371
|
-
function(target) {
|
|
371
|
+
function (target) {
|
|
372
372
|
for (var i = 1; i < arguments.length; i++) {
|
|
373
373
|
var source = arguments[i];
|
|
374
374
|
|
|
@@ -403,7 +403,7 @@ serializer.deserialize = function deserialize(html) {
|
|
|
403
403
|
let nodes = this.deserializeElements(children);
|
|
404
404
|
|
|
405
405
|
// COMPAT: ensure that all top-level inline nodes are wrapped into a block.
|
|
406
|
-
nodes = nodes.reduce(function(memo, node, i, original) {
|
|
406
|
+
nodes = nodes.reduce(function (memo, node, i, original) {
|
|
407
407
|
if (node.object === 'block') {
|
|
408
408
|
memo.push(node);
|
|
409
409
|
return memo;
|
|
@@ -467,7 +467,7 @@ export const reduceMultipleBrs = (markup) => {
|
|
|
467
467
|
return markup.replace(/(<br\s*\/?>){3,}/gi, '<br>');
|
|
468
468
|
} catch (e) {
|
|
469
469
|
// eslint-disable-next-line no-console
|
|
470
|
-
console.log(
|
|
470
|
+
console.log("Couldn't remove <br/> tags: ", e);
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
return markup;
|
|
@@ -478,7 +478,7 @@ const reduceRedundantNewLineCharacters = (markup) => {
|
|
|
478
478
|
return markup.replace(/\n/gi, '');
|
|
479
479
|
} catch (e) {
|
|
480
480
|
// eslint-disable-next-line no-console
|
|
481
|
-
console.log(
|
|
481
|
+
console.log("Couldn't remove <br/> tags: ", e);
|
|
482
482
|
}
|
|
483
483
|
|
|
484
484
|
return markup;
|
|
@@ -605,7 +605,7 @@ export const htmlToValue = (html) => {
|
|
|
605
605
|
return serializer.deserialize(handleHtml(html));
|
|
606
606
|
} catch (e) {
|
|
607
607
|
// eslint-disable-next-line no-console
|
|
608
|
-
console.log(
|
|
608
|
+
console.log("Couldn't parse html: ", e);
|
|
609
609
|
return {};
|
|
610
610
|
}
|
|
611
611
|
};
|
package/NEXT.CHANGELOG.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[]
|