@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
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { withStyles } from '@material-ui/core/styles';
|
|
4
|
-
import { mq } from '@pie-lib/math-input';
|
|
5
|
-
|
|
6
|
-
const MathTemplated = ({ attributes, value, classes, keyToDisplay }) => (
|
|
7
|
-
<span {...attributes} className={classes.spanContainer}>
|
|
8
|
-
<div className={classes.responseBox}>{keyToDisplay}</div>
|
|
9
|
-
<div className={classes.mathBlock}>
|
|
10
|
-
<mq.Static latex={value} />
|
|
11
|
-
</div>
|
|
12
|
-
</span>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
MathTemplated.propTypes = {
|
|
16
|
-
attributes: PropTypes.object,
|
|
17
|
-
classes: PropTypes.object.isRequired,
|
|
18
|
-
value: PropTypes.string,
|
|
19
|
-
keyToDisplay: PropTypes.string,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const styles = (theme) => ({
|
|
23
|
-
responseBox: {
|
|
24
|
-
background: theme.palette.grey['A100'],
|
|
25
|
-
color: theme.palette.grey['A700'],
|
|
26
|
-
display: 'inline-flex',
|
|
27
|
-
borderRight: '2px solid #C0C3CF',
|
|
28
|
-
boxSizing: 'border-box',
|
|
29
|
-
overflow: 'hidden',
|
|
30
|
-
fontSize: '12px',
|
|
31
|
-
minHeight: '36px',
|
|
32
|
-
height: '100%',
|
|
33
|
-
alignItems: 'center',
|
|
34
|
-
fontFamily: 'Symbola, Times New Roman, serif',
|
|
35
|
-
padding: '0 2px',
|
|
36
|
-
},
|
|
37
|
-
spanContainer: {
|
|
38
|
-
display: 'inline-flex',
|
|
39
|
-
border: '1px solid #C0C3CF',
|
|
40
|
-
margin: '1px 5px',
|
|
41
|
-
cursor: 'pointer',
|
|
42
|
-
alignItems: 'center',
|
|
43
|
-
justifyContent: 'center',
|
|
44
|
-
minWidth: '50px',
|
|
45
|
-
minHeight: '36px',
|
|
46
|
-
height: 'fit-content',
|
|
47
|
-
},
|
|
48
|
-
mathBlock: {
|
|
49
|
-
flex: 8,
|
|
50
|
-
color: 'var(--pie-text, black)',
|
|
51
|
-
padding: '4px !important',
|
|
52
|
-
display: 'flex',
|
|
53
|
-
alignItems: 'center',
|
|
54
|
-
justifyContent: 'center',
|
|
55
|
-
backgroundColor: 'var(--pie-background, rgba(255, 255, 255, 0))',
|
|
56
|
-
'& > .mq-math-mode sup.mq-nthroot': {
|
|
57
|
-
fontSize: '70% !important',
|
|
58
|
-
verticalAlign: '1em !important',
|
|
59
|
-
},
|
|
60
|
-
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
61
|
-
borderTop: '0.07em solid',
|
|
62
|
-
marginLeft: '-1.5px',
|
|
63
|
-
marginTop: '-2px !important',
|
|
64
|
-
paddingTop: '5px !important',
|
|
65
|
-
},
|
|
66
|
-
'& .mq-overarrow-inner': {
|
|
67
|
-
paddingTop: '0 !important',
|
|
68
|
-
border: 'none !important',
|
|
69
|
-
},
|
|
70
|
-
'& .mq-overarrow.mq-arrow-both': {
|
|
71
|
-
marginTop: '0px',
|
|
72
|
-
minWidth: '1.23em',
|
|
73
|
-
'& *': {
|
|
74
|
-
lineHeight: '1 !important',
|
|
75
|
-
},
|
|
76
|
-
'&:before': {
|
|
77
|
-
top: '-0.4em',
|
|
78
|
-
left: '-1px',
|
|
79
|
-
},
|
|
80
|
-
'&:after': {
|
|
81
|
-
top: '0px !important',
|
|
82
|
-
position: 'absolute !important',
|
|
83
|
-
right: '-2px',
|
|
84
|
-
},
|
|
85
|
-
'&.mq-empty:after': {
|
|
86
|
-
top: '-0.45em',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
'& .mq-overarrow.mq-arrow-right': {
|
|
90
|
-
'&:before': {
|
|
91
|
-
top: '-0.4em',
|
|
92
|
-
right: '-1px',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
'& .mq-overarrow-inner-right': {
|
|
96
|
-
display: 'none !important',
|
|
97
|
-
},
|
|
98
|
-
'& .mq-overarrow-inner-left': {
|
|
99
|
-
display: 'none !important',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
export default withStyles(styles)(MathTemplated);
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import { Inline } from 'slate';
|
|
4
|
-
import Snackbar from '@material-ui/core/Snackbar';
|
|
5
|
-
|
|
6
|
-
export const isNumber = (val) => !isNaN(parseFloat(val)) && isFinite(val);
|
|
7
|
-
|
|
8
|
-
export const insertSnackBar = (message) => {
|
|
9
|
-
const prevSnacks = document.querySelectorAll('.response-area-alert');
|
|
10
|
-
|
|
11
|
-
prevSnacks.forEach((s) => s.remove());
|
|
12
|
-
|
|
13
|
-
const newEl = document.createElement('div');
|
|
14
|
-
|
|
15
|
-
newEl.className = 'response-area-alert';
|
|
16
|
-
|
|
17
|
-
const el = (
|
|
18
|
-
<Snackbar
|
|
19
|
-
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
|
|
20
|
-
open={true}
|
|
21
|
-
ContentProps={{
|
|
22
|
-
'aria-describedby': 'message-id',
|
|
23
|
-
}}
|
|
24
|
-
message={<span id="message-id">{message}</span>}
|
|
25
|
-
/>
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
ReactDOM.render(el, newEl);
|
|
29
|
-
|
|
30
|
-
document.body.appendChild(newEl);
|
|
31
|
-
|
|
32
|
-
setTimeout(() => {
|
|
33
|
-
newEl.remove();
|
|
34
|
-
}, 2000);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const defaultECR = (index) =>
|
|
38
|
-
Inline.create({
|
|
39
|
-
type: 'explicit_constructed_response',
|
|
40
|
-
isVoid: true,
|
|
41
|
-
data: {
|
|
42
|
-
index,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
export const defaultMT = (index) =>
|
|
46
|
-
Inline.create({
|
|
47
|
-
type: 'math_templated',
|
|
48
|
-
isVoid: true,
|
|
49
|
-
data: {
|
|
50
|
-
index,
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export const defaultDIB = (opts, index) =>
|
|
55
|
-
Inline.create({
|
|
56
|
-
type: 'drag_in_the_blank',
|
|
57
|
-
isVoid: true,
|
|
58
|
-
data: {
|
|
59
|
-
index,
|
|
60
|
-
duplicates: opts.options.duplicates,
|
|
61
|
-
value: null,
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
export const defaultIDD = (index) =>
|
|
66
|
-
Inline.create({
|
|
67
|
-
object: 'inline',
|
|
68
|
-
type: 'inline_dropdown',
|
|
69
|
-
isVoid: true,
|
|
70
|
-
data: {
|
|
71
|
-
index,
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
export const getDefaultElement = (opts, index) => {
|
|
76
|
-
switch (opts.type) {
|
|
77
|
-
case 'explicit-constructed-response':
|
|
78
|
-
return defaultECR(index);
|
|
79
|
-
|
|
80
|
-
case 'math-templated':
|
|
81
|
-
return defaultMT(index);
|
|
82
|
-
|
|
83
|
-
case 'drag-in-the-blank':
|
|
84
|
-
return defaultDIB(opts, index);
|
|
85
|
-
|
|
86
|
-
default:
|
|
87
|
-
// inline-dropdown
|
|
88
|
-
return defaultIDD(index);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import EditTable from 'slate-edit-table';
|
|
2
|
-
import { isSelectionInTable } from 'slate-edit-table/dist/utils';
|
|
3
|
-
import { onEnter, onModEnter, onTab, onUpDown } from 'slate-edit-table/dist/handlers';
|
|
4
|
-
import TableOptions from 'slate-edit-table/dist/options';
|
|
5
|
-
import { clearCell } from 'slate-edit-table/dist/changes';
|
|
6
|
-
|
|
7
|
-
function onBackspace(event, change, editor, opts) {
|
|
8
|
-
const { value } = change;
|
|
9
|
-
const { startBlock, endBlock, selection, document } = value;
|
|
10
|
-
|
|
11
|
-
const startCell = document.getClosest(startBlock.key, opts.isCell);
|
|
12
|
-
const endCell = document.getClosest(endBlock.key, opts.isCell);
|
|
13
|
-
|
|
14
|
-
const startBlockIndex = startCell?.nodes?.findIndex((block) => block.key == startBlock.key);
|
|
15
|
-
|
|
16
|
-
// If a cursor is collapsed at the start of the first block, do nothing
|
|
17
|
-
if (startBlockIndex === 0 && selection.isAtStartOf(startBlock)) {
|
|
18
|
-
if (startBlock.isVoid) {
|
|
19
|
-
// Delete the block normally if it is a void block
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
event.preventDefault();
|
|
24
|
-
return change;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// If "normal" deletion, we continue
|
|
28
|
-
if (startCell === endCell) {
|
|
29
|
-
return undefined;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// If cursor is between multiple blocks,
|
|
33
|
-
// we clear the content of the cells.
|
|
34
|
-
event.preventDefault();
|
|
35
|
-
|
|
36
|
-
const { blocks } = value;
|
|
37
|
-
|
|
38
|
-
// Get all cells that contains the selection
|
|
39
|
-
const cells = blocks
|
|
40
|
-
.map((node) =>
|
|
41
|
-
node.type === opts.typeCell ? node : document.getClosest(node.key, (a) => a.type === opts.typeCell),
|
|
42
|
-
)
|
|
43
|
-
.toSet();
|
|
44
|
-
|
|
45
|
-
// If the cursor is at the very end of the first cell, ignore it.
|
|
46
|
-
// If the cursor is at the very start of the last cell, ignore it.
|
|
47
|
-
// This behavior is to compensate hanging selection behaviors:
|
|
48
|
-
// https://github.com/ianstormtaylor/slate/pull/1605
|
|
49
|
-
const ignoreFirstCell = value.selection.collapseToStart().isAtEndOf(cells.first());
|
|
50
|
-
const ignoreLastCell = value.selection.collapseToEnd().isAtStartOf(cells.last());
|
|
51
|
-
|
|
52
|
-
let cellsToClear = cells;
|
|
53
|
-
if (ignoreFirstCell) {
|
|
54
|
-
cellsToClear = cellsToClear.rest();
|
|
55
|
-
}
|
|
56
|
-
if (ignoreLastCell) {
|
|
57
|
-
cellsToClear = cellsToClear.butLast();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Clear all the selection
|
|
61
|
-
cellsToClear.forEach((cell) => clearCell(opts, change, cell));
|
|
62
|
-
|
|
63
|
-
// Update the selection properly, and avoid reset of selection
|
|
64
|
-
const updatedStartCell = change.value.document.getDescendant(cellsToClear.first().key);
|
|
65
|
-
return change.collapseToStartOf(updatedStartCell);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const KEY_ENTER = 'Enter';
|
|
69
|
-
const KEY_TAB = 'Tab';
|
|
70
|
-
const KEY_BACKSPACE = 'Backspace';
|
|
71
|
-
const KEY_DOWN = 'ArrowDown';
|
|
72
|
-
const KEY_UP = 'ArrowUp';
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* User is pressing a key in the editor
|
|
76
|
-
*/
|
|
77
|
-
function onKeyDown(opts, event, change, editor) {
|
|
78
|
-
// Only handle events in cells
|
|
79
|
-
if (!isSelectionInTable(opts, change.value)) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Build arguments list
|
|
84
|
-
const args = [event, change, editor, opts];
|
|
85
|
-
|
|
86
|
-
switch (event.key) {
|
|
87
|
-
case KEY_ENTER:
|
|
88
|
-
if (event.metaKey && opts.exitBlockType) {
|
|
89
|
-
return onModEnter(...args);
|
|
90
|
-
}
|
|
91
|
-
return onEnter(...args);
|
|
92
|
-
|
|
93
|
-
case KEY_TAB:
|
|
94
|
-
return onTab(...args);
|
|
95
|
-
case KEY_BACKSPACE:
|
|
96
|
-
return onBackspace(...args);
|
|
97
|
-
case KEY_DOWN:
|
|
98
|
-
case KEY_UP:
|
|
99
|
-
return onUpDown(...args);
|
|
100
|
-
default:
|
|
101
|
-
return undefined;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export default (opts) => {
|
|
106
|
-
const core = EditTable(opts);
|
|
107
|
-
|
|
108
|
-
const tableOpts = new TableOptions(opts);
|
|
109
|
-
|
|
110
|
-
core.onKeyDown = onKeyDown.bind(null, tableOpts);
|
|
111
|
-
|
|
112
|
-
return core;
|
|
113
|
-
};
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`table-toolbar snapshot renders 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
className="table-toolbar"
|
|
6
|
-
>
|
|
7
|
-
<div>
|
|
8
|
-
<WithStyles(RawButton)
|
|
9
|
-
onClick={[MockFunction]}
|
|
10
|
-
>
|
|
11
|
-
<WithStyles(Component) />
|
|
12
|
-
</WithStyles(RawButton)>
|
|
13
|
-
<WithStyles(RawButton)
|
|
14
|
-
onClick={[MockFunction]}
|
|
15
|
-
>
|
|
16
|
-
<WithStyles(Component) />
|
|
17
|
-
</WithStyles(RawButton)>
|
|
18
|
-
<WithStyles(RawButton)
|
|
19
|
-
onClick={[MockFunction]}
|
|
20
|
-
>
|
|
21
|
-
<WithStyles(Component) />
|
|
22
|
-
</WithStyles(RawButton)>
|
|
23
|
-
<WithStyles(RawButton)
|
|
24
|
-
onClick={[MockFunction]}
|
|
25
|
-
>
|
|
26
|
-
<WithStyles(Component) />
|
|
27
|
-
</WithStyles(RawButton)>
|
|
28
|
-
<WithStyles(RawButton)
|
|
29
|
-
onClick={[MockFunction]}
|
|
30
|
-
>
|
|
31
|
-
<WithStyles(Component) />
|
|
32
|
-
</WithStyles(RawButton)>
|
|
33
|
-
<WithStyles(RawButton)
|
|
34
|
-
active={true}
|
|
35
|
-
onClick={[MockFunction]}
|
|
36
|
-
>
|
|
37
|
-
<pure(BorderAllIcon) />
|
|
38
|
-
</WithStyles(RawButton)>
|
|
39
|
-
</div>
|
|
40
|
-
<WithStyles(RawDoneButton)
|
|
41
|
-
onClick={[Function]}
|
|
42
|
-
/>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|