@pie-lib/editable-html 11.21.2 → 11.21.3-next.155
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/CHANGELOG.md +6 -76
- package/esm/package.json +3 -0
- package/lib/block-tags.js +2 -3
- package/lib/block-tags.js.map +1 -1
- package/lib/constants.js +3 -6
- package/lib/constants.js.map +1 -1
- package/lib/editor.js +350 -481
- package/lib/editor.js.map +1 -1
- package/lib/index.js +18 -79
- package/lib/index.js.map +1 -1
- package/lib/parse-html.js +7 -7
- package/lib/parse-html.js.map +1 -1
- package/lib/plugins/characters/custom-popper.js +28 -44
- package/lib/plugins/characters/custom-popper.js.map +1 -1
- package/lib/plugins/characters/index.js +23 -63
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +3 -6
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +13 -25
- package/lib/plugins/css/icons/index.js.map +1 -1
- package/lib/plugins/css/index.js +34 -93
- package/lib/plugins/css/index.js.map +1 -1
- package/lib/plugins/customPlugin/index.js +10 -26
- package/lib/plugins/customPlugin/index.js.map +1 -1
- package/lib/plugins/html/icons/index.js +17 -25
- package/lib/plugins/html/icons/index.js.map +1 -1
- package/lib/plugins/html/index.js +4 -13
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/alt-dialog.js +20 -49
- package/lib/plugins/image/alt-dialog.js.map +1 -1
- package/lib/plugins/image/component.js +118 -194
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +48 -88
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +6 -46
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +10 -31
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +46 -106
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +27 -73
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +64 -116
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +27 -84
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +192 -307
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +40 -65
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +20 -49
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/rendering/index.js +5 -15
- package/lib/plugins/rendering/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +233 -251
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +17 -59
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/utils.js +38 -0
- package/lib/plugins/respArea/drag-in-the-blank/utils.js.map +1 -0
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -10
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +22 -45
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +5 -59
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +2 -10
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +91 -109
- package/lib/plugins/respArea/math-templated/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +12 -42
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +24 -41
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -1
- package/lib/plugins/table/icons/index.js +21 -35
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +48 -118
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +37 -86
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +25 -64
- package/lib/plugins/textAlign/icons/index.js.map +1 -1
- package/lib/plugins/textAlign/index.js +0 -8
- package/lib/plugins/textAlign/index.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +30 -79
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +16 -34
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +174 -202
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +0 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +59 -108
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +93 -162
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +5 -25
- package/lib/plugins/utils.js.map +1 -1
- package/lib/serialization.js +47 -153
- package/lib/serialization.js.map +1 -1
- package/lib/shared/alert-dialog.js +35 -42
- package/lib/theme.js +1 -2
- package/lib/theme.js.map +1 -1
- package/package.json +26 -14
- package/src/__tests__/editor-utils.test.js +162 -0
- package/src/__tests__/utils.js +1 -1
- package/src/editor.jsx +175 -153
- package/src/index.jsx +0 -3
- package/src/plugins/characters/custom-popper.js +25 -25
- package/src/plugins/characters/index.jsx +15 -5
- package/src/plugins/css/icons/index.jsx +11 -13
- package/src/plugins/css/index.jsx +16 -11
- package/src/plugins/html/icons/index.jsx +17 -14
- package/src/plugins/image/__tests__/component.test.jsx +61 -29
- package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +69 -17
- package/src/plugins/image/__tests__/image-toolbar.test.jsx +6 -4
- package/src/plugins/image/alt-dialog.jsx +9 -8
- package/src/plugins/image/component.jsx +68 -92
- package/src/plugins/image/image-toolbar.jsx +31 -28
- package/src/plugins/image/index.jsx +1 -1
- package/src/plugins/index.jsx +12 -10
- package/src/plugins/math/__tests__/index.test.jsx +45 -26
- package/src/plugins/math/index.jsx +1 -1
- package/src/plugins/media/index.jsx +6 -5
- package/src/plugins/media/media-dialog.js +65 -76
- package/src/plugins/media/media-toolbar.jsx +32 -33
- package/src/plugins/media/media-wrapper.jsx +10 -13
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +240 -167
- package/src/plugins/respArea/drag-in-the-blank/index.jsx +27 -56
- package/src/plugins/respArea/drag-in-the-blank/utils.js +14 -0
- package/src/plugins/respArea/icons/index.jsx +16 -16
- package/src/plugins/respArea/math-templated/index.jsx +88 -89
- package/src/plugins/respArea/utils.jsx +5 -3
- package/src/plugins/table/__tests__/table-toolbar.test.jsx +40 -7
- package/src/plugins/table/icons/index.jsx +16 -16
- package/src/plugins/table/index.jsx +35 -19
- package/src/plugins/table/table-toolbar.jsx +18 -19
- package/src/plugins/textAlign/icons/index.jsx +13 -4
- package/src/plugins/textAlign/index.jsx +0 -3
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +102 -69
- package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +14 -11
- package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +81 -35
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +44 -38
- package/src/plugins/toolbar/default-toolbar.jsx +18 -21
- package/src/plugins/toolbar/done-button.jsx +16 -22
- package/src/plugins/toolbar/editor-and-toolbar.jsx +134 -158
- package/src/plugins/toolbar/toolbar-buttons.jsx +30 -46
- package/src/plugins/toolbar/toolbar.jsx +57 -79
- package/src/serialization.jsx +3 -3
- package/src/__tests__/editor.test.jsx +0 -363
- 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/math/__tests__/__snapshots__/index.test.jsx.snap +0 -48
- package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +0 -44
- 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
|
@@ -1,363 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { htmlToValue, valueToHtml } from '../index';
|
|
3
|
-
import { Editor } from '../editor';
|
|
4
|
-
import { shallow, configure } from 'enzyme';
|
|
5
|
-
import debug from 'debug';
|
|
6
|
-
|
|
7
|
-
import { mockComponents } from './utils';
|
|
8
|
-
|
|
9
|
-
const log = debug('@pie-lib:editable-html:test');
|
|
10
|
-
|
|
11
|
-
const value = htmlToValue('hi');
|
|
12
|
-
|
|
13
|
-
const resizeWindow = (width, height) => {
|
|
14
|
-
window.innerWidth = width;
|
|
15
|
-
window.innerHeight = height;
|
|
16
|
-
window.dispatchEvent(new Event('resize'));
|
|
17
|
-
};
|
|
18
|
-
jest.mock('@pie-lib/math-toolbar', () => ({}));
|
|
19
|
-
jest.mock('@pie-lib/math-input', () => {
|
|
20
|
-
HorizontalKeypad: () => <div>HorizontalKeypad</div>;
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
expect.extend({
|
|
24
|
-
toEqualHtml(value, html) {
|
|
25
|
-
const v = valueToHtml(value);
|
|
26
|
-
const pass = v === html;
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
pass,
|
|
30
|
-
message: () => `expected ${html} to match ${v}`,
|
|
31
|
-
};
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
describe('logic', () => {
|
|
36
|
-
test('onFocus/onBlur saves the value', async () => {
|
|
37
|
-
const wrapper = shallow(
|
|
38
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
39
|
-
);
|
|
40
|
-
|
|
41
|
-
await wrapper.instance().onFocus();
|
|
42
|
-
|
|
43
|
-
const v = htmlToValue('hi');
|
|
44
|
-
|
|
45
|
-
expect(wrapper.state('stashedValue')).toEqualHtml('<div>hi</div>');
|
|
46
|
-
|
|
47
|
-
wrapper.instance().onChange({ value: htmlToValue('new value') });
|
|
48
|
-
|
|
49
|
-
expect(wrapper.state('value')).toEqualHtml('<div>new value</div>');
|
|
50
|
-
|
|
51
|
-
return wrapper
|
|
52
|
-
.instance()
|
|
53
|
-
.onBlur({})
|
|
54
|
-
.then(() => {
|
|
55
|
-
expect(wrapper.state('value')).toEqualHtml('<div>new value</div>');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
test('onFocus does not change focus if related target is a button from language keypad', async () => {
|
|
61
|
-
const wrapper = shallow(
|
|
62
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
const event = {
|
|
66
|
-
relatedTarget: {
|
|
67
|
-
tagName: 'button',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const change = {
|
|
72
|
-
focus: jest.fn(),
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
wrapper.instance().keypadInteractionDetected = true;
|
|
76
|
-
|
|
77
|
-
await wrapper.instance().onFocus(event, change);
|
|
78
|
-
|
|
79
|
-
expect(change.focus).not.toHaveBeenCalled();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test('onFocus changes focus if related target is not a button from language keypad', async () => {
|
|
83
|
-
const wrapper = shallow(
|
|
84
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
const event = {
|
|
88
|
-
relatedTarget: {
|
|
89
|
-
tagName: 'div',
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const change = {
|
|
94
|
-
focus: jest.fn(),
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
await wrapper.instance().onFocus(event, change);
|
|
98
|
-
|
|
99
|
-
expect(change.focus).toHaveBeenCalled();
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test('onFocus stashes the value', async () => {
|
|
103
|
-
const wrapper = shallow(
|
|
104
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
await wrapper.instance().onFocus();
|
|
108
|
-
|
|
109
|
-
expect(wrapper.state('stashedValue')).toEqualHtml('<div>hi</div>');
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
test('onBlur does not set focusToolbar if related target is RawDoneButton', async () => {
|
|
113
|
-
const wrapper = shallow(
|
|
114
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
const toolbarElement = document.createElement('div');
|
|
118
|
-
const relatedTarget = document.createElement('button');
|
|
119
|
-
relatedTarget.className = 'RawDoneButton';
|
|
120
|
-
toolbarElement.className = 'toolbar';
|
|
121
|
-
toolbarElement.appendChild(relatedTarget);
|
|
122
|
-
|
|
123
|
-
wrapper.instance().toolbarRef = toolbarElement;
|
|
124
|
-
wrapper.instance().doneButtonRef.current = relatedTarget;
|
|
125
|
-
|
|
126
|
-
const event = { relatedTarget };
|
|
127
|
-
|
|
128
|
-
await wrapper.instance().onBlur(event);
|
|
129
|
-
|
|
130
|
-
expect(wrapper.state('focusToolbar')).toBe(false);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
test('handleToolbarFocus sets focusToolbar to true', () => {
|
|
134
|
-
const wrapper = shallow(
|
|
135
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
wrapper.instance().handleToolbarFocus();
|
|
139
|
-
expect(wrapper.state('focusToolbar')).toBe(true);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
test('handleToolbarBlur sets focusToolbar to false if toolbar does not contain focus', (done) => {
|
|
143
|
-
const wrapper = shallow(
|
|
144
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
wrapper.instance().toolbarContainsFocus = jest.fn().mockReturnValue(false);
|
|
148
|
-
|
|
149
|
-
wrapper.instance().handleToolbarBlur();
|
|
150
|
-
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
expect(wrapper.state('focusToolbar')).toBe(false);
|
|
153
|
-
done();
|
|
154
|
-
}, 20);
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
test('handleToolbarBlur does not set focusToolbar to false if toolbar contains focus', (done) => {
|
|
158
|
-
const wrapper = shallow(
|
|
159
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
wrapper.instance().toolbarContainsFocus = jest.fn().mockReturnValue(true);
|
|
163
|
-
|
|
164
|
-
wrapper.setState({ focusToolbar: true });
|
|
165
|
-
|
|
166
|
-
wrapper.instance().handleToolbarBlur();
|
|
167
|
-
|
|
168
|
-
setTimeout(() => {
|
|
169
|
-
expect(wrapper.state('focusToolbar')).toBe(true);
|
|
170
|
-
done();
|
|
171
|
-
}, 20);
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
test('toolbarContainsFocus correctly detects focus within toolbar', () => {
|
|
175
|
-
const wrapper = shallow(
|
|
176
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const toolbarElement = document.createElement('div');
|
|
180
|
-
const activeElement = document.createElement('button');
|
|
181
|
-
toolbarElement.appendChild(activeElement);
|
|
182
|
-
|
|
183
|
-
Object.defineProperty(document, 'activeElement', {
|
|
184
|
-
value: activeElement,
|
|
185
|
-
configurable: true,
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
wrapper.instance().toolbarRef = toolbarElement;
|
|
189
|
-
|
|
190
|
-
expect(wrapper.instance().toolbarContainsFocus()).toBe(true);
|
|
191
|
-
|
|
192
|
-
Object.defineProperty(document, 'activeElement', {
|
|
193
|
-
value: document.createElement('div'),
|
|
194
|
-
configurable: true,
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
expect(wrapper.instance().toolbarContainsFocus()).toBe(false);
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
test('onBlur sets focusToolbar to true if related target is within toolbar', async () => {
|
|
201
|
-
const wrapper = shallow(
|
|
202
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
const toolbarElement = document.createElement('div');
|
|
206
|
-
const relatedTarget = document.createElement('button');
|
|
207
|
-
toolbarElement.className = 'toolbar';
|
|
208
|
-
toolbarElement.appendChild(relatedTarget);
|
|
209
|
-
|
|
210
|
-
wrapper.instance().toolbarRef = toolbarElement;
|
|
211
|
-
|
|
212
|
-
const event = { relatedTarget };
|
|
213
|
-
|
|
214
|
-
await wrapper.instance().onBlur(event);
|
|
215
|
-
|
|
216
|
-
expect(wrapper.state('focusToolbar')).toBe(true);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe('buildSizeStyle', () => {
|
|
220
|
-
const wrapper = (extras) => {
|
|
221
|
-
const props = Object.assign({}, extras);
|
|
222
|
-
return shallow(
|
|
223
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} {...props} />,
|
|
224
|
-
);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
it('builds width with px', () => {
|
|
228
|
-
const w = wrapper({ width: 100 });
|
|
229
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
230
|
-
width: '100px',
|
|
231
|
-
height: undefined,
|
|
232
|
-
minHeight: undefined,
|
|
233
|
-
maxHeight: undefined,
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
|
|
237
|
-
it('returns undefined for % ', () => {
|
|
238
|
-
const w = wrapper({ height: '100%', width: '100%' });
|
|
239
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
240
|
-
width: undefined,
|
|
241
|
-
height: undefined,
|
|
242
|
-
minHeight: undefined,
|
|
243
|
-
maxHeight: undefined,
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('builds height', () => {
|
|
248
|
-
const w = wrapper({ height: 100 });
|
|
249
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
250
|
-
width: undefined,
|
|
251
|
-
height: '100px',
|
|
252
|
-
minHeight: undefined,
|
|
253
|
-
maxHeight: undefined,
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it('builds minHeight', () => {
|
|
258
|
-
const w = wrapper({ minHeight: 100 });
|
|
259
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
260
|
-
width: undefined,
|
|
261
|
-
height: undefined,
|
|
262
|
-
minHeight: '100px',
|
|
263
|
-
maxHeight: undefined,
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('builds maxHeight', () => {
|
|
268
|
-
const w = wrapper({ maxHeight: 100 });
|
|
269
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
270
|
-
width: undefined,
|
|
271
|
-
height: undefined,
|
|
272
|
-
minHeight: undefined,
|
|
273
|
-
maxHeight: '100px',
|
|
274
|
-
});
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
it('builds width with calc()', () => {
|
|
278
|
-
const w = wrapper({ width: 'calc(10em + 42px)' });
|
|
279
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
280
|
-
width: 'calc(10em + 42px)',
|
|
281
|
-
height: undefined,
|
|
282
|
-
minHeight: undefined,
|
|
283
|
-
maxHeight: undefined,
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('builds width with ch', () => {
|
|
288
|
-
const w = wrapper({ width: '9ch' });
|
|
289
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
290
|
-
width: '9ch',
|
|
291
|
-
height: undefined,
|
|
292
|
-
minHeight: undefined,
|
|
293
|
-
maxHeight: undefined,
|
|
294
|
-
});
|
|
295
|
-
});
|
|
296
|
-
|
|
297
|
-
it('builds', () => {
|
|
298
|
-
const w = wrapper({});
|
|
299
|
-
expect(w.instance().buildSizeStyle()).toEqual({
|
|
300
|
-
width: undefined,
|
|
301
|
-
height: undefined,
|
|
302
|
-
minHeight: undefined,
|
|
303
|
-
maxHeight: undefined,
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
});
|
|
307
|
-
|
|
308
|
-
describe('onResize', () => {
|
|
309
|
-
it('should display html of current state on Resize', () => {
|
|
310
|
-
const wrapper = shallow(
|
|
311
|
-
<Editor editorRef={jest.fn()} value={value} classes={{}} onChange={jest.fn()} onRef={jest.fn()} />,
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
resizeWindow(500, 300);
|
|
315
|
-
expect(wrapper.state('value')).toEqualHtml('<div>hi</div>');
|
|
316
|
-
|
|
317
|
-
wrapper.instance().onChange({ value: htmlToValue('new value') });
|
|
318
|
-
resizeWindow(1024, 768);
|
|
319
|
-
expect(wrapper.state('value')).toEqualHtml('<div>new value</div>');
|
|
320
|
-
|
|
321
|
-
resizeWindow(500, 300);
|
|
322
|
-
expect(wrapper.state('value')).toEqualHtml('<div>new value</div>');
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
describe('MathMl', () => {
|
|
327
|
-
beforeEach(() => {});
|
|
328
|
-
|
|
329
|
-
it('should not call runSerializationOnMarkup if mathMl props are not there', () => {
|
|
330
|
-
const runSerializationOnMarkup = jest.fn();
|
|
331
|
-
|
|
332
|
-
const wrapper = shallow(
|
|
333
|
-
<Editor
|
|
334
|
-
editorRef={jest.fn()}
|
|
335
|
-
value={value}
|
|
336
|
-
classes={{}}
|
|
337
|
-
onChange={jest.fn()}
|
|
338
|
-
onRef={jest.fn()}
|
|
339
|
-
runSerializationOnMarkup={runSerializationOnMarkup}
|
|
340
|
-
/>,
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
expect(runSerializationOnMarkup).not.toHaveBeenCalled();
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
it('should call runSerializationOnMarkup if mmlEditing or mmlOutput are true', () => {
|
|
347
|
-
const runSerializationOnMarkup = jest.fn();
|
|
348
|
-
|
|
349
|
-
const wrapper = shallow(
|
|
350
|
-
<Editor
|
|
351
|
-
editorRef={jest.fn()}
|
|
352
|
-
value={value}
|
|
353
|
-
classes={{}}
|
|
354
|
-
onChange={jest.fn()}
|
|
355
|
-
onRef={jest.fn()}
|
|
356
|
-
runSerializationOnMarkup={runSerializationOnMarkup}
|
|
357
|
-
mathMlOptions={{ mmlOutput: true }}
|
|
358
|
-
/>,
|
|
359
|
-
);
|
|
360
|
-
|
|
361
|
-
expect(runSerializationOnMarkup).toHaveBeenCalled();
|
|
362
|
-
});
|
|
363
|
-
});
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`renders correctly 1`] = `
|
|
4
|
-
Array [
|
|
5
|
-
<span>
|
|
6
|
-
|
|
7
|
-
</span>,
|
|
8
|
-
<div
|
|
9
|
-
className=""
|
|
10
|
-
style={
|
|
11
|
-
Object {
|
|
12
|
-
"justifyContent": "flex-start",
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
>
|
|
16
|
-
<div
|
|
17
|
-
className="MuiLinearProgress-root-1 MuiLinearProgress-colorPrimary-2 MuiLinearProgress-indeterminate-5"
|
|
18
|
-
mode="determinate"
|
|
19
|
-
role="progressbar"
|
|
20
|
-
>
|
|
21
|
-
<div
|
|
22
|
-
className="MuiLinearProgress-bar-11 MuiLinearProgress-barColorPrimary-12 MuiLinearProgress-bar1Indeterminate-14"
|
|
23
|
-
style={Object {}}
|
|
24
|
-
/>
|
|
25
|
-
<div
|
|
26
|
-
className="MuiLinearProgress-bar-11 MuiLinearProgress-barColorPrimary-12 MuiLinearProgress-bar2Indeterminate-17"
|
|
27
|
-
style={Object {}}
|
|
28
|
-
/>
|
|
29
|
-
</div>
|
|
30
|
-
<div>
|
|
31
|
-
<img
|
|
32
|
-
className=""
|
|
33
|
-
onLoad={[Function]}
|
|
34
|
-
style={
|
|
35
|
-
Object {
|
|
36
|
-
"height": "50px",
|
|
37
|
-
"objectFit": "contain",
|
|
38
|
-
"width": "50px",
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/>
|
|
42
|
-
<div
|
|
43
|
-
className="resize"
|
|
44
|
-
/>
|
|
45
|
-
</div>
|
|
46
|
-
</div>,
|
|
47
|
-
<span>
|
|
48
|
-
|
|
49
|
-
</span>,
|
|
50
|
-
]
|
|
51
|
-
`;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`ImageToolbar onChange renders 1`] = `
|
|
4
|
-
<div>
|
|
5
|
-
<AlignmentButton
|
|
6
|
-
active={false}
|
|
7
|
-
alignment="left"
|
|
8
|
-
onClick={[Function]}
|
|
9
|
-
/>
|
|
10
|
-
<AlignmentButton
|
|
11
|
-
active={false}
|
|
12
|
-
alignment="center"
|
|
13
|
-
onClick={[Function]}
|
|
14
|
-
/>
|
|
15
|
-
<AlignmentButton
|
|
16
|
-
active={false}
|
|
17
|
-
alignment="right"
|
|
18
|
-
onClick={[Function]}
|
|
19
|
-
/>
|
|
20
|
-
<span
|
|
21
|
-
className="undefined"
|
|
22
|
-
onMouseDown={[Function]}
|
|
23
|
-
>
|
|
24
|
-
Alt text
|
|
25
|
-
</span>
|
|
26
|
-
</div>
|
|
27
|
-
`;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`renders correctly 1`] = `
|
|
4
|
-
<div
|
|
5
|
-
className="ImageToolbar-holder-1 holder"
|
|
6
|
-
>
|
|
7
|
-
<button
|
|
8
|
-
aria-label="left"
|
|
9
|
-
aria-pressed={false}
|
|
10
|
-
className="RawMarkButton-button-4"
|
|
11
|
-
onKeyDown={[Function]}
|
|
12
|
-
onMouseDown={[Function]}
|
|
13
|
-
tabIndex={0}
|
|
14
|
-
>
|
|
15
|
-
left
|
|
16
|
-
</button>
|
|
17
|
-
<button
|
|
18
|
-
aria-label="center"
|
|
19
|
-
aria-pressed={false}
|
|
20
|
-
className="RawMarkButton-button-4"
|
|
21
|
-
onKeyDown={[Function]}
|
|
22
|
-
onMouseDown={[Function]}
|
|
23
|
-
tabIndex={0}
|
|
24
|
-
>
|
|
25
|
-
center
|
|
26
|
-
</button>
|
|
27
|
-
<button
|
|
28
|
-
aria-label="right"
|
|
29
|
-
aria-pressed={false}
|
|
30
|
-
className="RawMarkButton-button-4"
|
|
31
|
-
onKeyDown={[Function]}
|
|
32
|
-
onMouseDown={[Function]}
|
|
33
|
-
tabIndex={0}
|
|
34
|
-
>
|
|
35
|
-
right
|
|
36
|
-
</button>
|
|
37
|
-
<span
|
|
38
|
-
className="ImageToolbar-disabled-2 ImageToolbar-altButton-3"
|
|
39
|
-
onMouseDown={[Function]}
|
|
40
|
-
>
|
|
41
|
-
Alt text
|
|
42
|
-
</span>
|
|
43
|
-
</div>
|
|
44
|
-
`;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`CustomToolbarComp render renders with default keypadMode 1`] = `
|
|
4
|
-
<MathToolbar
|
|
5
|
-
additionalKeys={Array []}
|
|
6
|
-
autoFocus={true}
|
|
7
|
-
controlledKeypadMode={true}
|
|
8
|
-
keypadMode="geometry"
|
|
9
|
-
latex="foo"
|
|
10
|
-
onChange={[Function]}
|
|
11
|
-
onDone={[Function]}
|
|
12
|
-
/>
|
|
13
|
-
`;
|
|
14
|
-
|
|
15
|
-
exports[`CustomToolbarComp render renders with default keypadMode 2`] = `
|
|
16
|
-
<MathToolbar
|
|
17
|
-
additionalKeys={Array []}
|
|
18
|
-
autoFocus={true}
|
|
19
|
-
controlledKeypadMode={true}
|
|
20
|
-
keypadMode={3}
|
|
21
|
-
latex="foo"
|
|
22
|
-
onChange={[Function]}
|
|
23
|
-
onDone={[Function]}
|
|
24
|
-
/>
|
|
25
|
-
`;
|
|
26
|
-
|
|
27
|
-
exports[`CustomToolbarComp render renders without default keypadMode 1`] = `
|
|
28
|
-
<MathToolbar
|
|
29
|
-
additionalKeys={Array []}
|
|
30
|
-
autoFocus={true}
|
|
31
|
-
controlledKeypadMode={true}
|
|
32
|
-
latex="foo"
|
|
33
|
-
onChange={[Function]}
|
|
34
|
-
onDone={[Function]}
|
|
35
|
-
/>
|
|
36
|
-
`;
|
|
37
|
-
|
|
38
|
-
exports[`CustomToolbarComp render renders without default keypadMode 2`] = `
|
|
39
|
-
<MathToolbar
|
|
40
|
-
additionalKeys={Array []}
|
|
41
|
-
autoFocus={true}
|
|
42
|
-
controlledKeypadMode={true}
|
|
43
|
-
keypadMode={3}
|
|
44
|
-
latex="foo"
|
|
45
|
-
onChange={[Function]}
|
|
46
|
-
onDone={[Function]}
|
|
47
|
-
/>
|
|
48
|
-
`;
|
|
@@ -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
|
-
`;
|