@atlaskit/editor-plugin-table 2.0.1 → 2.1.1
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 +12 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/version.json +1 -1
- package/package.json +5 -6
- package/src/__tests__/integration/layout.ts +1 -6
- package/src/__tests__/unit/analytics.ts +0 -21
- package/src/__tests__/unit/commands/misc.ts +0 -2
- package/src/__tests__/unit/commands/sort.ts +0 -131
- package/src/__tests__/unit/commands.ts +2 -264
- package/src/__tests__/unit/copy-paste.ts +1 -36
- package/src/__tests__/unit/event-handlers.ts +1 -113
- package/src/__tests__/unit/get-toolbar-config.ts +0 -29
- package/src/__tests__/unit/index.ts +3 -101
- package/src/__tests__/unit/layout.ts +1 -64
- package/src/__tests__/unit/nodeviews/cell.ts +1 -48
- package/src/__tests__/unit/pm-plugins/main.ts +1 -3
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +2 -20
- package/src/__tests__/unit/sort-column.ts +21 -148
- package/src/__tests__/unit/utils/collapse.ts +3 -39
- package/.eslintrc.js +0 -37
- package/src/__tests__/unit/color-picker.ts +0 -110
- package/src/__tests__/unit/floating-toolbar.ts +0 -95
- package/src/__tests__/unit/keymap.ts +0 -609
- package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +0 -110
- package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +0 -574
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 2.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`48ebe1fa732`](https://bitbucket.org/atlassian/atlassian-frontend/commits/48ebe1fa732) - [ED-18895] Moved table integration tests to dedicated editor plugin test package to avoid circular dependencies
|
|
14
|
+
|
|
3
15
|
## 2.0.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/version.json
CHANGED
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"releaseModel": "continuous"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@atlaskit/adf-schema": "^26.
|
|
31
|
-
"@atlaskit/editor-common": "^74.
|
|
30
|
+
"@atlaskit/adf-schema": "^26.2.0",
|
|
31
|
+
"@atlaskit/editor-common": "^74.19.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
|
-
"@atlaskit/editor-plugin-analytics": "^0.0
|
|
34
|
-
"@atlaskit/editor-plugin-content-insertion": "^0.0.
|
|
33
|
+
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
34
|
+
"@atlaskit/editor-plugin-content-insertion": "^0.0.6",
|
|
35
35
|
"@atlaskit/editor-shared-styles": "^2.4.0",
|
|
36
36
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
37
37
|
"@atlaskit/icon": "^21.12.0",
|
|
@@ -61,7 +61,6 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
64
|
-
"@atlaskit/editor-core": "^185.11.0",
|
|
65
64
|
"@atlaskit/editor-plugin-decorations": "^0.1.0",
|
|
66
65
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
67
66
|
"@atlaskit/editor-plugin-grid": "^0.1.0",
|
|
@@ -22,8 +22,6 @@ import {
|
|
|
22
22
|
mountEditor,
|
|
23
23
|
} from '@atlaskit/editor-test-helpers/testing-example-page';
|
|
24
24
|
|
|
25
|
-
import messages from '@atlaskit/editor-core/src/messages';
|
|
26
|
-
|
|
27
25
|
BrowserTestCase(
|
|
28
26
|
'Avoid overflow when table scale to wide',
|
|
29
27
|
{ skip: ['safari', 'firefox'] },
|
|
@@ -175,10 +173,7 @@ BrowserTestCase(
|
|
|
175
173
|
|
|
176
174
|
await page.waitForSelector('.extension-container p');
|
|
177
175
|
await page.click('.extension-container p');
|
|
178
|
-
await changeSelectedNodeLayout(
|
|
179
|
-
page,
|
|
180
|
-
messages.layoutFixedWidth.defaultMessage,
|
|
181
|
-
);
|
|
176
|
+
await changeSelectedNodeLayout(page, 'Back to center');
|
|
182
177
|
await animationFrame(page);
|
|
183
178
|
|
|
184
179
|
const doc = await page.$eval(editable, getDocFromElement);
|
|
@@ -41,8 +41,6 @@ import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
|
41
41
|
import { replaceSelectedTable } from '../../plugins/table/transforms';
|
|
42
42
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
43
43
|
import tablePlugin from '../../plugins/table-plugin';
|
|
44
|
-
import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
|
|
45
|
-
import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
|
|
46
44
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
47
45
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
48
46
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
@@ -97,9 +95,7 @@ describe('Table analytic events', () => {
|
|
|
97
95
|
analyticsPluginFake as unknown as typeof analyticsPlugin,
|
|
98
96
|
{ createAnalyticsEvent: jest.fn() },
|
|
99
97
|
])
|
|
100
|
-
.add(typeAheadPlugin)
|
|
101
98
|
.add(contentInsertionPlugin)
|
|
102
|
-
.add(quickInsertPlugin)
|
|
103
99
|
.add(widthPlugin)
|
|
104
100
|
.add([tablePlugin, { tableOptions }]),
|
|
105
101
|
pluginKey,
|
|
@@ -108,23 +104,6 @@ describe('Table analytic events', () => {
|
|
|
108
104
|
return _editor;
|
|
109
105
|
};
|
|
110
106
|
|
|
111
|
-
describe('table inserted via quickInsert', () => {
|
|
112
|
-
beforeEach(async () => {
|
|
113
|
-
const { typeAheadTool } = editor(doc(p('{<>}')));
|
|
114
|
-
typeAheadTool.searchQuickInsert('Table').insert({ index: 0 });
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should fire v3 analytics', () => {
|
|
118
|
-
expect(mockAttachPayload).toBeCalledWith({
|
|
119
|
-
action: 'inserted',
|
|
120
|
-
actionSubject: 'document',
|
|
121
|
-
actionSubjectId: 'table',
|
|
122
|
-
attributes: expect.objectContaining({ inputMethod: 'quickInsert' }),
|
|
123
|
-
eventType: 'track',
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
107
|
describe('table deleted', () => {
|
|
129
108
|
beforeEach(() => {
|
|
130
109
|
const { editorView } = editor(defaultTableDoc);
|
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
LightEditorPlugin,
|
|
15
15
|
createProsemirrorEditorFactory,
|
|
16
16
|
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
17
|
-
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
18
17
|
import {
|
|
19
18
|
selectColumn,
|
|
20
19
|
moveCursorBackward,
|
|
@@ -39,7 +38,6 @@ describe('table plugin: commands', () => {
|
|
|
39
38
|
.add([featureFlagsPlugin, {}])
|
|
40
39
|
.add([analyticsPlugin, {}])
|
|
41
40
|
.add(decorationsPlugin)
|
|
42
|
-
.add(panelPlugin)
|
|
43
41
|
.add(contentInsertionPlugin)
|
|
44
42
|
.add(widthPlugin)
|
|
45
43
|
.add([
|
|
@@ -10,21 +10,11 @@ import {
|
|
|
10
10
|
td,
|
|
11
11
|
th,
|
|
12
12
|
tr,
|
|
13
|
-
mention,
|
|
14
|
-
date,
|
|
15
|
-
a,
|
|
16
|
-
status,
|
|
17
13
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
18
|
-
import { EditorView } from 'prosemirror-view';
|
|
19
14
|
import { sortByColumn } from '../../../plugins/table/commands/sort';
|
|
20
15
|
import { uuid } from '@atlaskit/adf-schema';
|
|
21
16
|
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
22
17
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
23
|
-
import statusPlugin from '@atlaskit/editor-core/src/plugins/status';
|
|
24
|
-
import mentionsPlugin from '@atlaskit/editor-core/src/plugins/mentions';
|
|
25
|
-
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
26
|
-
import hyperlinkPlugin from '@atlaskit/editor-core/src/plugins/hyperlink';
|
|
27
|
-
import datePlugin from '@atlaskit/editor-core/src/plugins/date';
|
|
28
18
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
29
19
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
30
20
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
@@ -122,125 +112,4 @@ describe('Sort Table', () => {
|
|
|
122
112
|
),
|
|
123
113
|
);
|
|
124
114
|
});
|
|
125
|
-
|
|
126
|
-
describe('mixed content ordering', () => {
|
|
127
|
-
let editorView: EditorView;
|
|
128
|
-
|
|
129
|
-
beforeEach(() => {
|
|
130
|
-
({ editorView } = createEditor({
|
|
131
|
-
preset: new Preset<LightEditorPlugin>()
|
|
132
|
-
.add([featureFlagsPlugin, {}])
|
|
133
|
-
.add([analyticsPlugin, {}])
|
|
134
|
-
.add(contentInsertionPlugin)
|
|
135
|
-
.add(editorDisabledPlugin)
|
|
136
|
-
.add(widthPlugin)
|
|
137
|
-
.add([tablePlugin, { tableOptions: { allowHeaderRow: true } }])
|
|
138
|
-
.add([statusPlugin, { menuDisabled: false }])
|
|
139
|
-
.add(mentionsPlugin)
|
|
140
|
-
.add(hyperlinkPlugin)
|
|
141
|
-
.add(datePlugin),
|
|
142
|
-
doc: doc(
|
|
143
|
-
table()(
|
|
144
|
-
tr(th({})(p('Mixed{<>}'))),
|
|
145
|
-
tr(td({})(p(a({ href: '' })('LinkB')))),
|
|
146
|
-
tr(td({})(p('a1'))),
|
|
147
|
-
tr(
|
|
148
|
-
td({})(
|
|
149
|
-
p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
|
|
150
|
-
),
|
|
151
|
-
),
|
|
152
|
-
tr(td({})(p('10'))),
|
|
153
|
-
tr(td({})(p('b1'))),
|
|
154
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
|
|
155
|
-
tr(td({})(p('20'))),
|
|
156
|
-
tr(
|
|
157
|
-
td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
|
|
158
|
-
),
|
|
159
|
-
tr(td({})(p(a({ href: '' })('LinkA')))),
|
|
160
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
|
|
161
|
-
tr(
|
|
162
|
-
td({})(
|
|
163
|
-
p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
|
|
164
|
-
),
|
|
165
|
-
),
|
|
166
|
-
tr(
|
|
167
|
-
td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
|
|
168
|
-
),
|
|
169
|
-
),
|
|
170
|
-
),
|
|
171
|
-
}));
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should test a basic table ascending', () => {
|
|
175
|
-
sortByColumn(0, SortOrder.ASC)(editorView.state, editorView.dispatch);
|
|
176
|
-
|
|
177
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
178
|
-
doc(
|
|
179
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
180
|
-
tr(th({})(p('Mixed{<>}'))),
|
|
181
|
-
tr(td({})(p('10'))),
|
|
182
|
-
tr(td({})(p('20'))),
|
|
183
|
-
tr(td({})(p('a1'))),
|
|
184
|
-
tr(td({})(p('b1'))),
|
|
185
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
|
|
186
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
|
|
187
|
-
tr(
|
|
188
|
-
td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
|
|
189
|
-
),
|
|
190
|
-
tr(
|
|
191
|
-
td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
|
|
192
|
-
),
|
|
193
|
-
tr(
|
|
194
|
-
td({})(
|
|
195
|
-
p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
|
|
196
|
-
),
|
|
197
|
-
),
|
|
198
|
-
tr(
|
|
199
|
-
td({})(
|
|
200
|
-
p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
|
|
201
|
-
),
|
|
202
|
-
),
|
|
203
|
-
tr(td({})(p(a({ href: '' })('LinkA')))),
|
|
204
|
-
tr(td({})(p(a({ href: '' })('LinkB')))),
|
|
205
|
-
),
|
|
206
|
-
),
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
it('should test a basic table descending', () => {
|
|
211
|
-
sortByColumn(0, SortOrder.DESC)(editorView.state, editorView.dispatch);
|
|
212
|
-
|
|
213
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
214
|
-
doc(
|
|
215
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
216
|
-
tr(th({})(p('Mixed{<>}'))),
|
|
217
|
-
tr(td({})(p(a({ href: '' })('LinkB')))),
|
|
218
|
-
tr(td({})(p(a({ href: '' })('LinkA')))),
|
|
219
|
-
tr(
|
|
220
|
-
td({})(
|
|
221
|
-
p(status({ text: 'statusB', color: '#FFF', localId: 'a' })),
|
|
222
|
-
),
|
|
223
|
-
),
|
|
224
|
-
tr(
|
|
225
|
-
td({})(
|
|
226
|
-
p(status({ text: 'statusA', color: '#FFF', localId: 'a' })),
|
|
227
|
-
),
|
|
228
|
-
),
|
|
229
|
-
tr(
|
|
230
|
-
td({})(p(date({ timestamp: new Date('2020-01-01').getTime() }))),
|
|
231
|
-
),
|
|
232
|
-
tr(
|
|
233
|
-
td({})(p(date({ timestamp: new Date('2019-01-01').getTime() }))),
|
|
234
|
-
),
|
|
235
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionB' })()))),
|
|
236
|
-
tr(td({})(p(mention({ id: 'a', text: 'MentionA' })()))),
|
|
237
|
-
tr(td({})(p('b1'))),
|
|
238
|
-
tr(td({})(p('a1'))),
|
|
239
|
-
tr(td({})(p('20'))),
|
|
240
|
-
tr(td({})(p('10'))),
|
|
241
|
-
),
|
|
242
|
-
),
|
|
243
|
-
);
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
115
|
});
|
|
@@ -21,24 +21,14 @@ import {
|
|
|
21
21
|
tdCursor,
|
|
22
22
|
tdEmpty,
|
|
23
23
|
thCursor,
|
|
24
|
-
thEmpty,
|
|
25
24
|
th,
|
|
26
25
|
tr,
|
|
27
|
-
expand,
|
|
28
|
-
bodiedExtension,
|
|
29
26
|
DocBuilder,
|
|
30
27
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
31
28
|
|
|
32
29
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
33
|
-
import {
|
|
34
|
-
getFreshMediaProvider,
|
|
35
|
-
temporaryMediaGroup,
|
|
36
|
-
} from '@atlaskit/editor-test-helpers/media-provider';
|
|
37
|
-
|
|
38
|
-
import type { EditorProps } from '@atlaskit/editor-core';
|
|
39
30
|
import {
|
|
40
31
|
addBoldInEmptyHeaderCells,
|
|
41
|
-
clearMultipleCells,
|
|
42
32
|
selectColumn,
|
|
43
33
|
selectRow,
|
|
44
34
|
setEditorFocus,
|
|
@@ -50,21 +40,13 @@ import {
|
|
|
50
40
|
transformSliceToAddTableHeaders,
|
|
51
41
|
} from '../../plugins/table/commands';
|
|
52
42
|
import { splitCell } from '../../plugins/table/commands/split-cell';
|
|
53
|
-
import { wrapTableInExpand } from '../../plugins/table/commands/collapse';
|
|
54
43
|
import { handleCut } from '../../plugins/table/event-handlers';
|
|
55
44
|
import { getPluginState } from '../../plugins/table/pm-plugins/plugin-factory';
|
|
56
45
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
57
46
|
import tablePlugin from '../../plugins/table';
|
|
58
|
-
import editorDisabledPlugin from '@atlaskit/editor-core/src/plugins/editor-disabled';
|
|
59
|
-
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
60
|
-
import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
61
|
-
import extensionPlugin from '@atlaskit/editor-core/src/plugins/extension';
|
|
62
|
-
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
63
|
-
import floatingToolbarPlugin from '@atlaskit/editor-core/src/plugins/floating-toolbar';
|
|
64
47
|
|
|
65
48
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
66
49
|
import { gridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
67
|
-
import textFormattingPlugin from '@atlaskit/editor-core/src/plugins/text-formatting';
|
|
68
50
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
69
51
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
70
52
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
@@ -82,25 +64,18 @@ describe('table plugin: actions', () => {
|
|
|
82
64
|
});
|
|
83
65
|
|
|
84
66
|
const createEditor = createProsemirrorEditorFactory();
|
|
85
|
-
const editor = (doc: DocBuilder
|
|
67
|
+
const editor = (doc: DocBuilder) =>
|
|
86
68
|
createEditor({
|
|
87
69
|
doc,
|
|
88
70
|
attachTo: document.body,
|
|
89
71
|
preset: new Preset<LightEditorPlugin>()
|
|
90
72
|
.add([featureFlagsPlugin, {}])
|
|
91
|
-
.add(editorDisabledPlugin)
|
|
92
73
|
.add([analyticsPlugin, {}])
|
|
93
74
|
.add(contentInsertionPlugin)
|
|
94
75
|
.add(decorationsPlugin)
|
|
95
76
|
.add(widthPlugin)
|
|
96
77
|
.add(gridPlugin)
|
|
97
|
-
.add(tablePlugin)
|
|
98
|
-
.add(panelPlugin)
|
|
99
|
-
.add(textFormattingPlugin)
|
|
100
|
-
.add(extensionPlugin)
|
|
101
|
-
.add(floatingToolbarPlugin)
|
|
102
|
-
.add([mediaPlugin, { allowMediaSingle: true }])
|
|
103
|
-
.add(expandPlugin),
|
|
78
|
+
.add(tablePlugin),
|
|
104
79
|
pluginKey,
|
|
105
80
|
});
|
|
106
81
|
|
|
@@ -264,56 +239,6 @@ describe('table plugin: actions', () => {
|
|
|
264
239
|
});
|
|
265
240
|
});
|
|
266
241
|
|
|
267
|
-
describe('#clearMultipleCells', () => {
|
|
268
|
-
it('should empty selected cells', () => {
|
|
269
|
-
const { editorView } = editor(
|
|
270
|
-
doc(
|
|
271
|
-
p('text'),
|
|
272
|
-
table()(
|
|
273
|
-
tr(td()(p('c1')), tdEmpty),
|
|
274
|
-
tr(td()(panelNote(p('text'))), tdEmpty),
|
|
275
|
-
),
|
|
276
|
-
),
|
|
277
|
-
);
|
|
278
|
-
const { state, dispatch } = editorView;
|
|
279
|
-
selectColumn(0)(state, dispatch);
|
|
280
|
-
clearMultipleCells()(editorView.state, dispatch);
|
|
281
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
282
|
-
doc(
|
|
283
|
-
p('text'),
|
|
284
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
285
|
-
tr(tdEmpty, tdEmpty),
|
|
286
|
-
tr(tdEmpty, tdEmpty),
|
|
287
|
-
),
|
|
288
|
-
),
|
|
289
|
-
);
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it('should empty cell with the cursor', () => {
|
|
293
|
-
const { editorView } = editor(
|
|
294
|
-
doc(
|
|
295
|
-
p('text'),
|
|
296
|
-
table()(
|
|
297
|
-
tr(td()(p('c1')), tdEmpty),
|
|
298
|
-
tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
|
|
299
|
-
),
|
|
300
|
-
),
|
|
301
|
-
);
|
|
302
|
-
const { state, dispatch } = editorView;
|
|
303
|
-
clearMultipleCells(state.selection.$from.pos)(editorView.state, dispatch);
|
|
304
|
-
|
|
305
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
306
|
-
doc(
|
|
307
|
-
p('text'),
|
|
308
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
309
|
-
tr(td()(p('c1')), tdEmpty),
|
|
310
|
-
tr(tdEmpty, tdEmpty),
|
|
311
|
-
),
|
|
312
|
-
),
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
});
|
|
316
|
-
|
|
317
242
|
describe('#setMultipleCellAttrs', () => {
|
|
318
243
|
it('should set selected cell attributes', () => {
|
|
319
244
|
const { editorView } = editor(
|
|
@@ -341,31 +266,6 @@ describe('table plugin: actions', () => {
|
|
|
341
266
|
),
|
|
342
267
|
);
|
|
343
268
|
});
|
|
344
|
-
it('should set cell attributes if the cell has cursor', () => {
|
|
345
|
-
const { editorView } = editor(
|
|
346
|
-
doc(
|
|
347
|
-
p('text'),
|
|
348
|
-
table()(
|
|
349
|
-
tr(tdEmpty, tdEmpty),
|
|
350
|
-
tr(td()(panelNote(p('te{<>}xt'))), tdEmpty),
|
|
351
|
-
),
|
|
352
|
-
),
|
|
353
|
-
);
|
|
354
|
-
const { state, dispatch } = editorView;
|
|
355
|
-
setMultipleCellAttrs({ colspan: 2 }, state.selection.$from.pos)(
|
|
356
|
-
editorView.state,
|
|
357
|
-
dispatch,
|
|
358
|
-
);
|
|
359
|
-
expect(editorView.state).toEqualDocumentAndSelection(
|
|
360
|
-
doc(
|
|
361
|
-
p('text'),
|
|
362
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
363
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
364
|
-
tr(td({ colspan: 2 })(panelNote(p('te{<>}xt'))), tdEmpty),
|
|
365
|
-
),
|
|
366
|
-
),
|
|
367
|
-
);
|
|
368
|
-
});
|
|
369
269
|
});
|
|
370
270
|
|
|
371
271
|
describe('#toggleContextualMenu', () => {
|
|
@@ -729,22 +629,6 @@ describe('table plugin: actions', () => {
|
|
|
729
629
|
});
|
|
730
630
|
describe('when the cursor is on table header cell', () => {
|
|
731
631
|
describe('and the cell is empty', () => {
|
|
732
|
-
it('should add strong mark on storedMarks', () => {
|
|
733
|
-
const { editorView } = editor(
|
|
734
|
-
doc(table()(tr(thCursor), tr(td()(p(''))))),
|
|
735
|
-
);
|
|
736
|
-
const { state, dispatch } = editorView;
|
|
737
|
-
|
|
738
|
-
const tableCellHeader = findParentNodeOfType(
|
|
739
|
-
state.schema.nodes.tableHeader,
|
|
740
|
-
)(state.selection);
|
|
741
|
-
|
|
742
|
-
addBoldInEmptyHeaderCells(tableCellHeader!)(state, dispatch);
|
|
743
|
-
const result = editorView.state.storedMarks || [];
|
|
744
|
-
expect(result.length).toBeGreaterThan(0);
|
|
745
|
-
expect(result[0].type).toEqual(state.schema.marks.strong);
|
|
746
|
-
});
|
|
747
|
-
|
|
748
632
|
describe('and the user removed the strong mark', () => {
|
|
749
633
|
it('should not add strong mark on storedMarks', () => {
|
|
750
634
|
const { editorView } = editor(
|
|
@@ -849,151 +733,5 @@ describe('table plugin: actions', () => {
|
|
|
849
733
|
),
|
|
850
734
|
);
|
|
851
735
|
});
|
|
852
|
-
|
|
853
|
-
it('should split cell with media selected', () => {
|
|
854
|
-
const { editorView } = editor(
|
|
855
|
-
doc(
|
|
856
|
-
table()(
|
|
857
|
-
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
858
|
-
tr(
|
|
859
|
-
td({ colspan: 2 })('{<node>}', temporaryMediaGroup),
|
|
860
|
-
td()(p('')),
|
|
861
|
-
),
|
|
862
|
-
),
|
|
863
|
-
),
|
|
864
|
-
{
|
|
865
|
-
media: {
|
|
866
|
-
allowMediaSingle: true,
|
|
867
|
-
provider: getFreshMediaProvider(),
|
|
868
|
-
},
|
|
869
|
-
},
|
|
870
|
-
);
|
|
871
|
-
|
|
872
|
-
splitCell(editorView.state, editorView.dispatch);
|
|
873
|
-
|
|
874
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
875
|
-
doc(
|
|
876
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
877
|
-
tr(th()(p('')), th()(p('')), th()(p(''))),
|
|
878
|
-
tr(td()(temporaryMediaGroup), td()(p('')), td()(p(''))),
|
|
879
|
-
),
|
|
880
|
-
),
|
|
881
|
-
);
|
|
882
|
-
});
|
|
883
|
-
});
|
|
884
|
-
|
|
885
|
-
describe('#wrapTableInExpand', () => {
|
|
886
|
-
it('should not wrap if selection is not on a table', () => {
|
|
887
|
-
const { editorView } = editor(
|
|
888
|
-
doc(
|
|
889
|
-
p('Cursor here{<>}'),
|
|
890
|
-
table()(tr(thEmpty, thEmpty, thEmpty), tr(tdEmpty, tdEmpty, tdEmpty)),
|
|
891
|
-
),
|
|
892
|
-
{ allowExpand: true, allowTables: { allowCollapse: true } },
|
|
893
|
-
);
|
|
894
|
-
|
|
895
|
-
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
896
|
-
|
|
897
|
-
expect(result).toBeFalsy();
|
|
898
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
899
|
-
doc(
|
|
900
|
-
p('Cursor {<>}here'),
|
|
901
|
-
table({ localId: 'test-table-local-id' })(
|
|
902
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
903
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
904
|
-
),
|
|
905
|
-
),
|
|
906
|
-
);
|
|
907
|
-
});
|
|
908
|
-
|
|
909
|
-
it('should be able to wrap a root level table', () => {
|
|
910
|
-
const { editorView } = editor(
|
|
911
|
-
doc(
|
|
912
|
-
table()(
|
|
913
|
-
tr(thCursor, thEmpty, thEmpty),
|
|
914
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
915
|
-
),
|
|
916
|
-
),
|
|
917
|
-
{ allowExpand: true },
|
|
918
|
-
);
|
|
919
|
-
|
|
920
|
-
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
921
|
-
|
|
922
|
-
expect(result).toBeTruthy();
|
|
923
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
924
|
-
doc(
|
|
925
|
-
expand()(
|
|
926
|
-
table({ localId: 'test-table-local-id' })(
|
|
927
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
928
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
929
|
-
),
|
|
930
|
-
),
|
|
931
|
-
),
|
|
932
|
-
);
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
it('should not wrap a table under an expand', () => {
|
|
936
|
-
const { editorView } = editor(
|
|
937
|
-
doc(
|
|
938
|
-
expand()(
|
|
939
|
-
table()(
|
|
940
|
-
tr(thCursor, thEmpty, thEmpty),
|
|
941
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
942
|
-
),
|
|
943
|
-
),
|
|
944
|
-
),
|
|
945
|
-
{ allowExpand: true },
|
|
946
|
-
);
|
|
947
|
-
|
|
948
|
-
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
949
|
-
|
|
950
|
-
expect(result).toBeFalsy();
|
|
951
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
952
|
-
doc(
|
|
953
|
-
expand()(
|
|
954
|
-
table({ localId: 'test-table-local-id' })(
|
|
955
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
956
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
957
|
-
),
|
|
958
|
-
),
|
|
959
|
-
),
|
|
960
|
-
);
|
|
961
|
-
});
|
|
962
|
-
|
|
963
|
-
it('should not wrap a table inside a bodiedExtension', () => {
|
|
964
|
-
const { editorView } = editor(
|
|
965
|
-
doc(
|
|
966
|
-
bodiedExtension({
|
|
967
|
-
extensionKey: 'key',
|
|
968
|
-
extensionType: 'type',
|
|
969
|
-
localId: 'localId',
|
|
970
|
-
})(
|
|
971
|
-
table()(
|
|
972
|
-
tr(thCursor, thEmpty, thEmpty),
|
|
973
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
974
|
-
),
|
|
975
|
-
),
|
|
976
|
-
),
|
|
977
|
-
{ allowExpand: true, allowExtension: true },
|
|
978
|
-
);
|
|
979
|
-
|
|
980
|
-
const result = wrapTableInExpand(editorView.state, editorView.dispatch);
|
|
981
|
-
|
|
982
|
-
expect(result).toBeFalsy();
|
|
983
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
984
|
-
doc(
|
|
985
|
-
bodiedExtension({
|
|
986
|
-
extensionKey: 'key',
|
|
987
|
-
extensionType: 'type',
|
|
988
|
-
localId: 'localId',
|
|
989
|
-
})(
|
|
990
|
-
table({ localId: 'test-table-local-id' })(
|
|
991
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
992
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
993
|
-
),
|
|
994
|
-
),
|
|
995
|
-
),
|
|
996
|
-
);
|
|
997
|
-
});
|
|
998
736
|
});
|
|
999
737
|
});
|