@pie-lib/editable-html-tip-tap 1.0.2 → 1.0.4
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/components/CharacterPicker.js +221 -0
- package/lib/components/CharacterPicker.js.map +1 -0
- package/lib/components/EditableHtml.js +323 -0
- package/lib/components/EditableHtml.js.map +1 -0
- package/lib/components/MenuBar.js +694 -0
- package/lib/components/MenuBar.js.map +1 -0
- package/lib/components/TiptapContainer.js +90 -0
- package/lib/components/TiptapContainer.js.map +1 -0
- package/lib/components/buttons/done-button.js +53 -0
- package/lib/components/characters/characterUtils.js +112 -0
- package/lib/components/characters/characterUtils.js.map +1 -0
- package/lib/components/characters/custom-popper.js +73 -0
- package/lib/components/characters/custom-popper.js.map +1 -0
- package/lib/components/common/done-button.js +53 -0
- package/lib/components/common/done-button.js.map +1 -0
- package/lib/components/common/toolbar-buttons.js +194 -0
- package/lib/components/icons/CssIcon.js +37 -0
- package/lib/components/icons/CssIcon.js.map +1 -0
- package/lib/components/icons/RespArea.js +95 -0
- package/lib/components/icons/RespArea.js.map +1 -0
- package/lib/components/icons/TableIcons.js +69 -0
- package/lib/components/icons/TableIcons.js.map +1 -0
- package/lib/components/icons/TextAlign.js +194 -0
- package/lib/components/icons/TextAlign.js.map +1 -0
- package/lib/components/icons/index.js +194 -0
- package/lib/components/image/AltDialog.js +129 -0
- package/lib/components/image/ImageToolbar.js +177 -0
- package/lib/components/image/ImageToolbar.js.map +1 -0
- package/lib/components/image/InsertImageHandler.js +115 -0
- package/lib/components/image/InsertImageHandler.js.map +1 -0
- package/lib/components/image/alt-dialog.js +2 -0
- package/lib/components/media/MediaDialog.js +709 -0
- package/lib/components/media/MediaDialog.js.map +1 -0
- package/lib/components/media/MediaToolbar.js +101 -0
- package/lib/components/media/MediaToolbar.js.map +1 -0
- package/lib/components/media/MediaWrapper.js +93 -0
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js +94 -0
- package/lib/components/respArea/DragInTheBlank/DragInTheBlank.js.map +1 -0
- package/lib/components/respArea/DragInTheBlank/choice.js +289 -0
- package/lib/components/respArea/DragInTheBlank/choice.js.map +1 -0
- package/lib/components/respArea/DragInTheBlank.js +94 -0
- package/lib/components/respArea/ExplicitConstructedResponse.js +120 -0
- package/lib/components/respArea/ExplicitConstructedResponse.js.map +1 -0
- package/lib/components/respArea/InlineDropdown.js +126 -0
- package/lib/components/respArea/InlineDropdown.js.map +1 -0
- package/lib/components/respArea/ToolbarIcon.js +105 -0
- package/lib/components/respArea/ToolbarIcon.js.map +1 -0
- package/lib/components/respArea/choice.js +2 -0
- package/lib/constants.js.map +1 -0
- package/lib/extensions/component.js +5 -5
- package/lib/extensions/component.js.map +1 -0
- package/lib/extensions/css.js.map +1 -0
- package/lib/extensions/custom-toolbar-wrapper.js +2 -4
- package/lib/extensions/custom-toolbar-wrapper.js.map +1 -0
- package/lib/extensions/extended-table.js +30 -0
- package/lib/extensions/extended-table.js.map +1 -0
- package/lib/extensions/image.js +2 -8
- package/lib/extensions/image.js.map +1 -0
- package/lib/extensions/index.js +52 -0
- package/lib/extensions/index.js.map +1 -0
- package/lib/extensions/math.js.map +1 -0
- package/lib/extensions/media.js +7 -7
- package/lib/extensions/media.js.map +1 -0
- package/lib/extensions/responseArea.js +7 -7
- package/lib/extensions/responseArea.js.map +1 -0
- package/lib/index.js +16 -1481
- package/lib/index.js.map +1 -0
- package/lib/plugins/index.js +8 -80
- package/lib/styles/editorContainerStyles.js +200 -0
- package/lib/styles/editorContainerStyles.js.map +1 -0
- package/lib/theme.js.map +1 -0
- package/lib/utils/size.js +34 -0
- package/lib/utils/size.js.map +1 -0
- package/package.json +1 -1
- package/src/components/CharacterPicker.jsx +185 -0
- package/src/components/EditableHtml.jsx +306 -0
- package/src/components/MenuBar.jsx +630 -0
- package/src/components/TiptapContainer.jsx +96 -0
- package/src/components/characters/characterUtils.js +127 -0
- package/src/{plugins/image/image-toolbar.jsx → components/image/ImageToolbar.jsx} +2 -2
- package/src/{plugins/image/insert-image-handler.js → components/image/InsertImageHandler.js} +0 -1
- package/src/{plugins/media/media-dialog.js → components/media/MediaDialog.js} +2 -2
- package/src/{plugins/respArea/drag-in-the-blank → components/respArea/DragInTheBlank}/choice.jsx +1 -1
- package/src/{plugins/respArea/inline-dropdown/index.jsx → components/respArea/InlineDropdown.jsx} +1 -1
- package/src/components/respArea/ToolbarIcon.jsx +68 -0
- package/src/extensions/component.jsx +2 -2
- package/src/extensions/custom-toolbar-wrapper.jsx +6 -7
- package/src/extensions/extended-table.js +27 -0
- package/src/extensions/image.js +2 -2
- package/src/extensions/index.js +76 -0
- package/src/extensions/media.js +12 -7
- package/src/extensions/responseArea.js +7 -7
- package/src/index.jsx +3 -1440
- package/src/styles/editorContainerStyles.js +203 -0
- package/src/utils/size.js +32 -0
- package/src/__tests__/editor.test.jsx +0 -363
- package/src/__tests__/serialization.test.js +0 -291
- package/src/block-tags.js +0 -17
- package/src/editor.jsx +0 -1197
- package/src/extensions/characters.js +0 -46
- package/src/old-index.jsx +0 -162
- package/src/parse-html.js +0 -8
- package/src/plugins/README.md +0 -27
- package/src/plugins/characters/index.jsx +0 -284
- package/src/plugins/characters/utils.js +0 -447
- package/src/plugins/css/index.jsx +0 -340
- package/src/plugins/customPlugin/index.jsx +0 -85
- package/src/plugins/html/icons/index.jsx +0 -19
- package/src/plugins/html/index.jsx +0 -72
- package/src/plugins/image/__tests__/__snapshots__/component.test.jsx.snap +0 -51
- package/src/plugins/image/__tests__/__snapshots__/image-toolbar-logic.test.jsx.snap +0 -27
- package/src/plugins/image/__tests__/__snapshots__/image-toolbar.test.jsx.snap +0 -44
- package/src/plugins/image/__tests__/component.test.jsx +0 -41
- package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +0 -42
- package/src/plugins/image/__tests__/image-toolbar.test.jsx +0 -11
- package/src/plugins/image/__tests__/index.test.js +0 -95
- package/src/plugins/image/__tests__/insert-image-handler.test.js +0 -113
- package/src/plugins/image/__tests__/mock-change.js +0 -15
- package/src/plugins/image/component.jsx +0 -343
- package/src/plugins/image/index.jsx +0 -227
- package/src/plugins/index.jsx +0 -377
- package/src/plugins/list/__tests__/index.test.js +0 -54
- package/src/plugins/list/index.jsx +0 -305
- package/src/plugins/math/__tests__/__snapshots__/index.test.jsx.snap +0 -48
- package/src/plugins/math/__tests__/index.test.jsx +0 -245
- package/src/plugins/math/index.jsx +0 -379
- package/src/plugins/media/__tests__/index.test.js +0 -75
- package/src/plugins/media/index.jsx +0 -325
- package/src/plugins/rendering/index.js +0 -31
- package/src/plugins/respArea/index.jsx +0 -299
- package/src/plugins/respArea/math-templated/index.jsx +0 -104
- package/src/plugins/respArea/utils.jsx +0 -90
- package/src/plugins/table/CustomTablePlugin.js +0 -113
- package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +0 -44
- package/src/plugins/table/__tests__/index.test.jsx +0 -401
- package/src/plugins/table/__tests__/table-toolbar.test.jsx +0 -42
- package/src/plugins/table/index.jsx +0 -427
- package/src/plugins/table/table-toolbar.jsx +0 -136
- package/src/plugins/textAlign/index.jsx +0 -23
- package/src/plugins/toolbar/__tests__/__snapshots__/default-toolbar.test.jsx.snap +0 -923
- package/src/plugins/toolbar/__tests__/__snapshots__/editor-and-toolbar.test.jsx.snap +0 -20
- package/src/plugins/toolbar/__tests__/__snapshots__/toolbar-buttons.test.jsx.snap +0 -36
- package/src/plugins/toolbar/__tests__/__snapshots__/toolbar.test.jsx.snap +0 -46
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +0 -94
- package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +0 -37
- package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +0 -51
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +0 -106
- package/src/plugins/toolbar/default-toolbar.jsx +0 -206
- package/src/plugins/toolbar/editor-and-toolbar.jsx +0 -257
- package/src/plugins/toolbar/index.jsx +0 -23
- package/src/plugins/toolbar/toolbar.jsx +0 -338
- package/src/plugins/utils.js +0 -31
- package/src/serialization.jsx +0 -621
- /package/src/{plugins → components}/characters/custom-popper.js +0 -0
- /package/src/{plugins/toolbar → components/common}/done-button.jsx +0 -0
- /package/src/{plugins/toolbar → components/common}/toolbar-buttons.jsx +0 -0
- /package/src/{plugins/css/icons/index.jsx → components/icons/CssIcon.jsx} +0 -0
- /package/src/{plugins/respArea/icons/index.jsx → components/icons/RespArea.jsx} +0 -0
- /package/src/{plugins/table/icons/index.jsx → components/icons/TableIcons.jsx} +0 -0
- /package/src/{plugins/textAlign/icons/index.jsx → components/icons/TextAlign.jsx} +0 -0
- /package/src/{plugins/image/alt-dialog.jsx → components/image/AltDialog.jsx} +0 -0
- /package/src/{plugins/media/media-toolbar.jsx → components/media/MediaToolbar.jsx} +0 -0
- /package/src/{plugins/media/media-wrapper.jsx → components/media/MediaWrapper.jsx} +0 -0
- /package/src/{plugins/respArea/drag-in-the-blank/index.jsx → components/respArea/DragInTheBlank/DragInTheBlank.jsx} +0 -0
- /package/src/{plugins/respArea/explicit-constructed-response/index.jsx → components/respArea/ExplicitConstructedResponse.jsx} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
|
+
import classNames from 'classnames';
|
|
3
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
+
|
|
5
|
+
import styles from '../styles/editorContainerStyles';
|
|
6
|
+
import { valueToSize } from '../utils/size';
|
|
7
|
+
|
|
8
|
+
import StyledMenuBar from './MenuBar';
|
|
9
|
+
|
|
10
|
+
function TiptapContainer(props) {
|
|
11
|
+
const {
|
|
12
|
+
editor,
|
|
13
|
+
disabled,
|
|
14
|
+
classes,
|
|
15
|
+
children,
|
|
16
|
+
disableUnderline,
|
|
17
|
+
disableScrollbar,
|
|
18
|
+
activePlugins,
|
|
19
|
+
toolbarOpts,
|
|
20
|
+
responseAreaProps,
|
|
21
|
+
autoFocus,
|
|
22
|
+
minWidth,
|
|
23
|
+
width,
|
|
24
|
+
maxWidth,
|
|
25
|
+
minHeight,
|
|
26
|
+
height,
|
|
27
|
+
maxHeight,
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
const holderNames = classNames(classes.editorHolder, {
|
|
31
|
+
[classes.readOnly]: disabled,
|
|
32
|
+
[classes.disabledUnderline]: disableUnderline,
|
|
33
|
+
[classes.disabledScrollbar]: disableScrollbar,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (editor && autoFocus) {
|
|
38
|
+
Promise.resolve().then(() => {
|
|
39
|
+
editor.commands.focus('end');
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [editor, autoFocus]);
|
|
43
|
+
|
|
44
|
+
const sizeStyle = useMemo(
|
|
45
|
+
() => ({
|
|
46
|
+
width: valueToSize(width),
|
|
47
|
+
minWidth: valueToSize(minWidth),
|
|
48
|
+
maxWidth: valueToSize(maxWidth),
|
|
49
|
+
height: valueToSize(height),
|
|
50
|
+
minHeight: valueToSize(minHeight),
|
|
51
|
+
maxHeight: valueToSize(maxHeight),
|
|
52
|
+
}),
|
|
53
|
+
[minWidth, width, maxWidth, minHeight, height, maxHeight],
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
className={classNames(
|
|
59
|
+
{
|
|
60
|
+
[classes.noBorder]: toolbarOpts && toolbarOpts.noBorder,
|
|
61
|
+
[classes.error]: toolbarOpts && toolbarOpts.error,
|
|
62
|
+
},
|
|
63
|
+
classes.root,
|
|
64
|
+
props.className,
|
|
65
|
+
)}
|
|
66
|
+
style={{ width: sizeStyle.width, minWidth: sizeStyle.minWidth, maxWidth: sizeStyle.maxWidth }}
|
|
67
|
+
>
|
|
68
|
+
<div className={holderNames}>
|
|
69
|
+
<div
|
|
70
|
+
className={classNames(
|
|
71
|
+
{
|
|
72
|
+
[classes.noPadding]: toolbarOpts && toolbarOpts.noPadding,
|
|
73
|
+
},
|
|
74
|
+
classes.children,
|
|
75
|
+
)}
|
|
76
|
+
>
|
|
77
|
+
{children}
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
|
|
81
|
+
{editor && (
|
|
82
|
+
<StyledMenuBar
|
|
83
|
+
editor={editor}
|
|
84
|
+
responseAreaProps={responseAreaProps}
|
|
85
|
+
toolbarOpts={toolbarOpts}
|
|
86
|
+
activePlugins={activePlugins}
|
|
87
|
+
onChange={props.onChange}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const EditorContainer = withStyles(styles)(TiptapContainer);
|
|
95
|
+
|
|
96
|
+
export default EditorContainer;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export const spanishConfig = {
|
|
2
|
+
characters: [
|
|
3
|
+
['á', 'é', 'í', 'ó', 'ú'],
|
|
4
|
+
['Á', 'É', 'Í', 'Ó', 'Ú'],
|
|
5
|
+
['—', '«', '»', 'ñ', 'ü'],
|
|
6
|
+
['-', '¿', '¡', 'Ñ', 'Ü'],
|
|
7
|
+
],
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const specialConfig = {
|
|
11
|
+
hasPreview: true,
|
|
12
|
+
characters: [
|
|
13
|
+
[
|
|
14
|
+
{
|
|
15
|
+
unicode: 'U+00A2',
|
|
16
|
+
description: 'CENT SIGN',
|
|
17
|
+
write: '¢',
|
|
18
|
+
label: '¢',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
unicode: 'U+00BF',
|
|
22
|
+
description: 'INVERTED QUESTION MARK',
|
|
23
|
+
write: '¿',
|
|
24
|
+
label: '¿',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
unicode: 'U+00B4',
|
|
28
|
+
description: 'ACUTE ACCENT',
|
|
29
|
+
write: '´',
|
|
30
|
+
label: '´',
|
|
31
|
+
extraProps: { style: { gridRow: 'span 2' } },
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
unicode: 'U+00E1',
|
|
35
|
+
description: 'LATIN SMALL LETTER A WITH ACUTE',
|
|
36
|
+
write: 'á',
|
|
37
|
+
label: 'á',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
unicode: 'U+00E9',
|
|
41
|
+
description: 'LATIN SMALL LETTER E WITH ACUTE',
|
|
42
|
+
write: 'é',
|
|
43
|
+
label: 'é',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
unicode: 'U+00ED',
|
|
47
|
+
description: 'LATIN SMALL LETTER I WITH ACUTE',
|
|
48
|
+
write: 'í',
|
|
49
|
+
label: 'í',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
unicode: 'U+00F3',
|
|
53
|
+
description: 'LATIN SMALL LETTER O WITH ACUTE',
|
|
54
|
+
write: 'ó',
|
|
55
|
+
label: 'ó',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
unicode: 'U+00FA',
|
|
59
|
+
description: 'LATIN SMALL LETTER U WITH ACUTE',
|
|
60
|
+
write: 'ú',
|
|
61
|
+
label: 'ú',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
unicode: 'U+00F1',
|
|
65
|
+
description: 'LATIN SMALL LETTER N WITH TILDE',
|
|
66
|
+
write: 'ñ',
|
|
67
|
+
label: 'ñ',
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
unicode: 'U+20AC',
|
|
73
|
+
description: 'EURO SIGN',
|
|
74
|
+
write: '€',
|
|
75
|
+
label: '€',
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
unicode: 'U+00A1',
|
|
79
|
+
description: 'INVERTED EXCLAMATION MARK',
|
|
80
|
+
write: '¡',
|
|
81
|
+
label: '¡',
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
unicode: 'U+00C1',
|
|
85
|
+
description: 'LATIN CAPITAL LETTER A WITH ACUTE',
|
|
86
|
+
write: 'Á',
|
|
87
|
+
label: 'Á',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
unicode: 'U+00C9',
|
|
91
|
+
description: 'LATIN CAPITAL LETTER E WITH ACUTE',
|
|
92
|
+
write: 'É',
|
|
93
|
+
label: 'É',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
unicode: 'U+00CD',
|
|
97
|
+
description: 'LATIN CAPITAL LETTER I WITH ACUTE',
|
|
98
|
+
write: 'Í',
|
|
99
|
+
label: 'Í',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
unicode: 'U+00D3',
|
|
103
|
+
description: 'LATIN CAPITAL LETTER O WITH ACUTE',
|
|
104
|
+
write: 'Ó',
|
|
105
|
+
label: 'Ó',
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
unicode: 'U+00DA',
|
|
109
|
+
description: 'LATIN CAPITAL LETTER U WITH ACUTE',
|
|
110
|
+
write: 'Ú',
|
|
111
|
+
label: 'Ú',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
unicode: 'U+00D1',
|
|
115
|
+
description: 'LATIN CAPITAL LETTER N WITH TILDE',
|
|
116
|
+
write: 'Ñ',
|
|
117
|
+
label: 'Ñ',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
// remaining rows kept identical to original utils.js...
|
|
121
|
+
],
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export const characterIcons = {
|
|
125
|
+
spanish: 'ñ',
|
|
126
|
+
special: '€',
|
|
127
|
+
};
|
|
@@ -5,8 +5,8 @@ import ReactDOM from 'react-dom';
|
|
|
5
5
|
import { withStyles } from '@material-ui/core/styles';
|
|
6
6
|
import classNames from 'classnames';
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import AltDialog from './AltDialog';
|
|
9
|
+
import { MarkButton } from '../common/toolbar-buttons';
|
|
10
10
|
|
|
11
11
|
const log = debug('@pie-lib:editable-html:plugins:image:image-toolbar');
|
|
12
12
|
|
|
@@ -107,7 +107,7 @@ export class MediaDialog extends React.Component {
|
|
|
107
107
|
super(props);
|
|
108
108
|
|
|
109
109
|
const { ends, height, src, starts, type, uploadSoundSupport, url, urlToUse, width } = props;
|
|
110
|
-
const showUploadFile = uploadSoundSupport?.add && uploadSoundSupport?.delete && type !== 'video';
|
|
110
|
+
const showUploadFile = uploadSoundSupport?.add && uploadSoundSupport?.delete && type !== 'video' && !src;
|
|
111
111
|
|
|
112
112
|
this.state = {
|
|
113
113
|
ends: ends || 0,
|
|
@@ -252,7 +252,7 @@ export class MediaDialog extends React.Component {
|
|
|
252
252
|
const { type } = this.props;
|
|
253
253
|
|
|
254
254
|
if (type && type === 'audio') {
|
|
255
|
-
this.checkAudio();
|
|
255
|
+
this.checkAudio(value);
|
|
256
256
|
return;
|
|
257
257
|
} else if (type && type === 'video') {
|
|
258
258
|
this.checkVideo(value);
|
package/src/{plugins/respArea/drag-in-the-blank → components/respArea/DragInTheBlank}/choice.jsx
RENAMED
|
@@ -7,7 +7,7 @@ import { renderMath } from '@pie-lib/math-rendering';
|
|
|
7
7
|
import { withStyles } from '@material-ui/core/styles';
|
|
8
8
|
import classnames from 'classnames';
|
|
9
9
|
|
|
10
|
-
import { GripIcon } from '
|
|
10
|
+
import { GripIcon } from '../../icons/RespArea';
|
|
11
11
|
|
|
12
12
|
const useStyles = withStyles((theme) => ({
|
|
13
13
|
content: {
|
package/src/{plugins/respArea/inline-dropdown/index.jsx → components/respArea/InlineDropdown.jsx}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState } from "react";
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { NodeViewWrapper } from '@tiptap/react';
|
|
4
|
-
import { Chevron } from '../icons';
|
|
4
|
+
import { Chevron } from '../icons/RespArea';
|
|
5
5
|
|
|
6
6
|
const InlineDropdown = (props) => {
|
|
7
7
|
const { editor, node, getPos, options, selected } = props;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { withStyles } from '@material-ui/core/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 styles = (theme) => ({
|
|
55
|
+
icon: {
|
|
56
|
+
fontFamily: 'Cerebri Sans !important',
|
|
57
|
+
fontSize: theme.typography.fontSize,
|
|
58
|
+
fontWeight: 'bold',
|
|
59
|
+
lineHeight: '14px',
|
|
60
|
+
position: 'relative',
|
|
61
|
+
top: '7px',
|
|
62
|
+
width: '110px',
|
|
63
|
+
height: '28px',
|
|
64
|
+
whiteSpace: 'nowrap',
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
export const ToolbarIcon = withStyles(styles)(({ classes }) => <div className={classes.icon}>+ Response Area</div>);
|
|
@@ -6,8 +6,8 @@ import debug from 'debug';
|
|
|
6
6
|
import LinearProgress from '@material-ui/core/LinearProgress';
|
|
7
7
|
import { withStyles } from '@material-ui/core/styles';
|
|
8
8
|
import { NodeViewWrapper } from '@tiptap/react';
|
|
9
|
-
import InsertImageHandler from '../
|
|
10
|
-
import ImageToolbar from '../
|
|
9
|
+
import InsertImageHandler from '../components/image/InsertImageHandler';
|
|
10
|
+
import ImageToolbar from '../components/image/ImageToolbar';
|
|
11
11
|
import CustomToolbarWrapper from './custom-toolbar-wrapper';
|
|
12
12
|
|
|
13
13
|
const log = debug('@pie-lib:editable-html:plugins:image:component');
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
|
-
import IconButton from
|
|
3
|
-
import Delete from
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { Toolbar } from "../plugins/toolbar/toolbar";
|
|
2
|
+
import IconButton from '@material-ui/core/IconButton';
|
|
3
|
+
import Delete from '@material-ui/icons/Delete';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { PIE_TOOLBAR__CLASS } from '../constants';
|
|
6
|
+
import { withStyles } from '@material-ui/core/styles';
|
|
7
|
+
import { DoneButton } from '../components/common/done-button';
|
|
9
8
|
|
|
10
9
|
function CustomToolbarWrapper(props) {
|
|
11
10
|
const {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Table } from '@tiptap/extension-table';
|
|
2
|
+
|
|
3
|
+
const ExtendedTable = Table.extend({
|
|
4
|
+
addAttributes() {
|
|
5
|
+
return {
|
|
6
|
+
border: { default: '1' },
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
renderHTML(props) {
|
|
10
|
+
const originalTable = this.parent(props);
|
|
11
|
+
const { border } = props.HTMLAttributes;
|
|
12
|
+
|
|
13
|
+
const previousStyle = `${originalTable[1].style}${originalTable[1].style.match(/.*; */) ? '' : ';'}`;
|
|
14
|
+
|
|
15
|
+
originalTable[1].style = `${previousStyle}
|
|
16
|
+
width: 100%;
|
|
17
|
+
color: var(--pie-text, black);
|
|
18
|
+
table-layout: fixed;
|
|
19
|
+
border-collapse: collapse;
|
|
20
|
+
background-color: var(--pie-background, rgba(255, 255, 255))`;
|
|
21
|
+
originalTable[1].border = border ? border : '1';
|
|
22
|
+
|
|
23
|
+
return originalTable;
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default ExtendedTable;
|
package/src/extensions/image.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
-
import {
|
|
3
|
-
import React
|
|
2
|
+
import { ReactNodeViewRenderer } from '@tiptap/react';
|
|
3
|
+
import React from 'react';
|
|
4
4
|
import ImageComponent from './component';
|
|
5
5
|
|
|
6
6
|
// ---- Tiptap Extension ---- //
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import compact from 'lodash/compact';
|
|
3
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
|
+
import debug from 'debug';
|
|
5
|
+
|
|
6
|
+
const log = debug('@pie-lib:editable-html:plugins');
|
|
7
|
+
export const ALL_PLUGINS = [
|
|
8
|
+
'bold',
|
|
9
|
+
// 'code',
|
|
10
|
+
'html',
|
|
11
|
+
'extraCSSRules',
|
|
12
|
+
'italic',
|
|
13
|
+
'underline',
|
|
14
|
+
'strikethrough',
|
|
15
|
+
'bulleted-list',
|
|
16
|
+
'numbered-list',
|
|
17
|
+
'image',
|
|
18
|
+
'math',
|
|
19
|
+
'languageCharacters',
|
|
20
|
+
'text-align',
|
|
21
|
+
'blockquote',
|
|
22
|
+
'h3',
|
|
23
|
+
'table',
|
|
24
|
+
'video',
|
|
25
|
+
'audio',
|
|
26
|
+
'responseArea',
|
|
27
|
+
'redo',
|
|
28
|
+
'undo',
|
|
29
|
+
'superscript',
|
|
30
|
+
'subscript',
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
export const DEFAULT_EXTENSIONS = ALL_PLUGINS.filter((plug) => !['responseArea', 'h3', 'blockquote'].includes(plug));
|
|
34
|
+
|
|
35
|
+
export const buildExtensions = (activeExtensions, customExtensions, opts) => {
|
|
36
|
+
log('[buildPlugins] opts: ', opts);
|
|
37
|
+
|
|
38
|
+
activeExtensions = activeExtensions || DEFAULT_EXTENSIONS;
|
|
39
|
+
|
|
40
|
+
const addIf = (key, shouldAdd = true) => activeExtensions.includes(key) && shouldAdd && key;
|
|
41
|
+
|
|
42
|
+
const imagePlugin = opts.image && opts.image.onDelete;
|
|
43
|
+
const mathPlugin = opts.math;
|
|
44
|
+
const respAreaPlugin = opts.responseArea && opts.responseArea.type;
|
|
45
|
+
const cssPlugin = !isEmpty(opts.extraCSSRules);
|
|
46
|
+
|
|
47
|
+
const languageCharactersPlugins = opts?.languageCharacters || [];
|
|
48
|
+
|
|
49
|
+
return compact([
|
|
50
|
+
addIf('table'),
|
|
51
|
+
addIf('bold'),
|
|
52
|
+
// addIf('code', MarkHotkey({ key: '`', type: 'code', icon: <Code /> })),
|
|
53
|
+
addIf('italic'),
|
|
54
|
+
addIf('strikethrough'),
|
|
55
|
+
addIf('underline'),
|
|
56
|
+
// icon should be modifies accordingly
|
|
57
|
+
addIf('superscript'),
|
|
58
|
+
// icon should be modifies accordingly
|
|
59
|
+
addIf('subscript'),
|
|
60
|
+
addIf('image', imagePlugin),
|
|
61
|
+
addIf('video'),
|
|
62
|
+
addIf('audio'),
|
|
63
|
+
addIf('math', mathPlugin),
|
|
64
|
+
...languageCharactersPlugins.map((plugin) => addIf('languageCharacters', plugin)),
|
|
65
|
+
addIf('text-align'),
|
|
66
|
+
addIf('blockquote'),
|
|
67
|
+
addIf('h3'),
|
|
68
|
+
addIf('bulleted-list'),
|
|
69
|
+
addIf('numbered-list'),
|
|
70
|
+
addIf('undo'),
|
|
71
|
+
addIf('redo'),
|
|
72
|
+
addIf('responseArea', respAreaPlugin),
|
|
73
|
+
addIf('css', cssPlugin),
|
|
74
|
+
addIf('html', !!opts.html),
|
|
75
|
+
]);
|
|
76
|
+
};
|
package/src/extensions/media.js
CHANGED
|
@@ -2,8 +2,8 @@ import React, { useEffect } from 'react';
|
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import { mergeAttributes, Node } from '@tiptap/core';
|
|
4
4
|
import { NodeViewWrapper, ReactNodeViewRenderer } from '@tiptap/react';
|
|
5
|
-
import MediaDialog from '../
|
|
6
|
-
import MediaToolbar from '../
|
|
5
|
+
import MediaDialog from '../components/media/MediaDialog';
|
|
6
|
+
import MediaToolbar from '../components/media/MediaToolbar';
|
|
7
7
|
|
|
8
8
|
export const Media = Node.create({
|
|
9
9
|
name: 'media',
|
|
@@ -136,15 +136,17 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
|
|
|
136
136
|
const handleEdit = () => {
|
|
137
137
|
insertDialog({
|
|
138
138
|
...node.attrs,
|
|
139
|
+
options: options,
|
|
139
140
|
edit: true,
|
|
140
141
|
callback: (val, data) => {
|
|
141
142
|
if (val) {
|
|
142
143
|
updateAttributes(data);
|
|
143
|
-
} else {
|
|
144
|
-
deleteNode();
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
editor
|
|
146
|
+
editor
|
|
147
|
+
.chain()
|
|
148
|
+
.focus()
|
|
149
|
+
.run();
|
|
148
150
|
},
|
|
149
151
|
});
|
|
150
152
|
};
|
|
@@ -161,7 +163,10 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
|
|
|
161
163
|
deleteNode();
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
editor
|
|
166
|
+
editor
|
|
167
|
+
.chain()
|
|
168
|
+
.focus()
|
|
169
|
+
.run();
|
|
165
170
|
},
|
|
166
171
|
});
|
|
167
172
|
}, []);
|
|
@@ -170,7 +175,7 @@ export default function MediaNodeView({ editor, node, updateAttributes, deleteNo
|
|
|
170
175
|
<NodeViewWrapper data-type={type} style={{ width, height }}>
|
|
171
176
|
{tag === 'audio' ? (
|
|
172
177
|
<audio controls controlsList="nodownload">
|
|
173
|
-
<source src={src} />
|
|
178
|
+
<source type="audio/mp3" src={src} />
|
|
174
179
|
</audio>
|
|
175
180
|
) : (
|
|
176
181
|
<iframe src={src} allowFullScreen frameBorder="0" />
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// InlineNodes.js
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { Node, ReactNodeViewRenderer, ReactRenderer } from
|
|
4
|
-
import ExplicitConstructedResponse from '../
|
|
5
|
-
import DragInTheBlank from '../
|
|
6
|
-
import InlineDropdown from '../
|
|
7
|
-
import { Extension } from
|
|
8
|
-
import { MathToolbar } from
|
|
9
|
-
import tippy from
|
|
3
|
+
import { Node, ReactNodeViewRenderer, ReactRenderer } from '@tiptap/react';
|
|
4
|
+
import ExplicitConstructedResponse from '../components/respArea/ExplicitConstructedResponse';
|
|
5
|
+
import DragInTheBlank from '../components/respArea/DragInTheBlank/DragInTheBlank';
|
|
6
|
+
import InlineDropdown from '../components/respArea/InlineDropdown';
|
|
7
|
+
import { Extension } from '@tiptap/core';
|
|
8
|
+
import { MathToolbar } from '@pie-lib/math-toolbar';
|
|
9
|
+
import tippy from 'tippy.js';
|
|
10
10
|
|
|
11
11
|
export const ResponseAreaExtension = Extension.create({
|
|
12
12
|
name: 'responseArea',
|