@atlaskit/editor-plugin-table 7.2.2 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/cjs/commands/column-resize.js +115 -45
- package/dist/cjs/commands/go-to-next-cell.js +7 -11
- package/dist/cjs/commands/misc.js +3 -2
- package/dist/cjs/commands/selection.js +3 -3
- package/dist/cjs/event-handlers.js +38 -25
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -19
- package/dist/cjs/pm-plugins/keymap.js +1 -0
- package/dist/cjs/pm-plugins/main.js +43 -9
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +37 -7
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +20 -6
- package/dist/cjs/reducer.js +5 -2
- package/dist/cjs/utils/drag-menu.js +37 -23
- package/dist/cjs/utils/merged-cells.js +66 -1
- package/dist/es2019/commands/column-resize.js +100 -35
- package/dist/es2019/commands/go-to-next-cell.js +7 -9
- package/dist/es2019/commands/misc.js +3 -2
- package/dist/es2019/commands/selection.js +5 -5
- package/dist/es2019/event-handlers.js +17 -3
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/es2019/pm-plugins/keymap.js +3 -2
- package/dist/es2019/pm-plugins/main.js +41 -5
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +37 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +16 -1
- package/dist/es2019/reducer.js +5 -2
- package/dist/es2019/utils/drag-menu.js +38 -14
- package/dist/es2019/utils/merged-cells.js +73 -0
- package/dist/esm/commands/column-resize.js +105 -35
- package/dist/esm/commands/go-to-next-cell.js +7 -11
- package/dist/esm/commands/misc.js +3 -2
- package/dist/esm/commands/selection.js +5 -5
- package/dist/esm/event-handlers.js +38 -25
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +4 -20
- package/dist/esm/pm-plugins/keymap.js +3 -2
- package/dist/esm/pm-plugins/main.js +38 -4
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +34 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +15 -1
- package/dist/esm/reducer.js +5 -2
- package/dist/esm/utils/drag-menu.js +36 -22
- package/dist/esm/utils/merged-cells.js +65 -0
- package/dist/types/commands/column-resize.d.ts +2 -0
- package/dist/types/commands/misc.d.ts +1 -1
- package/dist/types/types.d.ts +16 -0
- package/dist/types/utils/drag-menu.d.ts +4 -1
- package/dist/types/utils/merged-cells.d.ts +2 -0
- package/dist/types-ts4.5/commands/column-resize.d.ts +2 -0
- package/dist/types-ts4.5/commands/misc.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +16 -0
- package/dist/types-ts4.5/utils/drag-menu.d.ts +4 -1
- package/dist/types-ts4.5/utils/merged-cells.d.ts +2 -0
- package/package.json +10 -17
- package/src/commands/column-resize.ts +155 -40
- package/src/commands/go-to-next-cell.ts +6 -15
- package/src/commands/misc.ts +2 -0
- package/src/commands/selection.ts +5 -5
- package/src/event-handlers.ts +21 -4
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +11 -32
- package/src/pm-plugins/keymap.ts +3 -0
- package/src/pm-plugins/main.ts +47 -2
- package/src/pm-plugins/table-resizing/event-handlers.ts +33 -5
- package/src/pm-plugins/table-resizing/plugin.ts +18 -1
- package/src/reducer.ts +5 -2
- package/src/types.ts +16 -0
- package/src/utils/drag-menu.ts +94 -20
- package/src/utils/merged-cells.ts +78 -0
- package/tsconfig.dev.json +0 -69
- package/tsconfig.json +2 -877
- package/examples/99-testing.tsx +0 -140
- package/examples/config.jsonc +0 -14
- package/src/__tests__/unit/analytics.ts +0 -888
- package/src/__tests__/unit/collab.ts +0 -93
- package/src/__tests__/unit/commands/go-to-next-cell.ts +0 -173
- package/src/__tests__/unit/commands/insert.ts +0 -137
- package/src/__tests__/unit/commands/misc.ts +0 -185
- package/src/__tests__/unit/commands/sort.ts +0 -128
- package/src/__tests__/unit/commands.ts +0 -745
- package/src/__tests__/unit/copy-button.ts +0 -22
- package/src/__tests__/unit/copy-paste.ts +0 -677
- package/src/__tests__/unit/event-handlers/index.ts +0 -125
- package/src/__tests__/unit/event-handlers.ts +0 -296
- package/src/__tests__/unit/fix-tables.ts +0 -164
- package/src/__tests__/unit/get-toolbar-config.ts +0 -127
- package/src/__tests__/unit/handlers.ts +0 -98
- package/src/__tests__/unit/hover-selection.ts +0 -230
- package/src/__tests__/unit/index-with-fake-timers.ts +0 -111
- package/src/__tests__/unit/index.ts +0 -912
- package/src/__tests__/unit/layout.ts +0 -146
- package/src/__tests__/unit/nodeviews/OverflowShadowsObserver.ts +0 -162
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +0 -280
- package/src/__tests__/unit/nodeviews/TableContainer.tsx +0 -525
- package/src/__tests__/unit/nodeviews/cell.ts +0 -132
- package/src/__tests__/unit/nodeviews/table.ts +0 -129
- package/src/__tests__/unit/pm-plugins/analytics.ts +0 -327
- package/src/__tests__/unit/pm-plugins/decorations/column-controls.ts +0 -94
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +0 -176
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +0 -211
- package/src/__tests__/unit/pm-plugins/main.ts +0 -214
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +0 -101
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +0 -562
- package/src/__tests__/unit/pm-plugins/table-local-id.ts +0 -507
- package/src/__tests__/unit/pm-plugins/table-resizing/colgroup.ts +0 -269
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +0 -192
- package/src/__tests__/unit/pm-plugins/table-resizing/utils/resize-state.ts +0 -33
- package/src/__tests__/unit/pm-plugins/table-width.ts +0 -292
- package/src/__tests__/unit/sort-column.ts +0 -399
- package/src/__tests__/unit/toolbar.ts +0 -512
- package/src/__tests__/unit/transforms/delete-columns.ts +0 -597
- package/src/__tests__/unit/transforms/delete-rows.ts +0 -620
- package/src/__tests__/unit/transforms/merging.ts +0 -392
- package/src/__tests__/unit/ui/ContextualMenu.tsx +0 -71
- package/src/__tests__/unit/ui/CornerControls.tsx +0 -99
- package/src/__tests__/unit/ui/DeleteButton.tsx +0 -38
- package/src/__tests__/unit/ui/FixedButton.tsx +0 -217
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +0 -123
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +0 -68
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +0 -178
- package/src/__tests__/unit/ui/FloatingDragMenu.tsx +0 -511
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +0 -322
- package/src/__tests__/unit/ui/NumberColumn.tsx +0 -146
- package/src/__tests__/unit/ui/RowControls.tsx +0 -294
- package/src/__tests__/unit/ui/RowDragControls.tsx +0 -129
- package/src/__tests__/unit/ui/TableFloatingColumnControls.tsx +0 -189
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +0 -118
- package/src/__tests__/unit/undo-redo.ts +0 -220
- package/src/__tests__/unit/utils/analytics.ts +0 -98
- package/src/__tests__/unit/utils/collapse.ts +0 -57
- package/src/__tests__/unit/utils/column-controls.ts +0 -205
- package/src/__tests__/unit/utils/dom.ts +0 -180
- package/src/__tests__/unit/utils/merged-cells.ts +0 -156
- package/src/__tests__/unit/utils/nodes.ts +0 -79
- package/src/__tests__/unit/utils/row-controls.ts +0 -195
- package/src/__tests__/unit/utils/table.ts +0 -96
- package/src/__tests__/unit/utils.ts +0 -670
- package/src/__tests__/visual-regression/__fixtures__/sticky-header-with-horizontal-scroll.json +0 -5228
- package/src/__tests__/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -20272
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-1-snap.png +0 -3
- package/src/__tests__/visual-regression/__image_snapshots__/sticky-header-ts-snapshot-test-table-sticky-header-should-align-with-table-cell-when-active-2-snap.png +0 -3
- package/src/__tests__/visual-regression/cell-options-menu.ts +0 -101
- package/src/__tests__/visual-regression/copy-button.ts +0 -181
- package/src/__tests__/visual-regression/index.ts +0 -62
- package/src/__tests__/visual-regression/sticky-header.ts +0 -61
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
import type { DocBuilder } from '@atlaskit/editor-common/types';
|
|
2
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
3
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
-
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
|
-
import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
6
|
-
import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
7
|
-
import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
8
|
-
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
|
-
import { undo } from '@atlaskit/editor-prosemirror/history';
|
|
10
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
12
|
-
import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
13
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
14
|
-
import {
|
|
15
|
-
createProsemirrorEditorFactory,
|
|
16
|
-
Preset,
|
|
17
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
18
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
19
|
-
import {
|
|
20
|
-
doc,
|
|
21
|
-
p,
|
|
22
|
-
table,
|
|
23
|
-
td,
|
|
24
|
-
tdEmpty,
|
|
25
|
-
tr,
|
|
26
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
27
|
-
|
|
28
|
-
import tablePlugin from '../../../plugin';
|
|
29
|
-
import { pluginKey as tablePluginKey } from '../../../pm-plugins/plugin-key';
|
|
30
|
-
|
|
31
|
-
const createDoc = (attrs: any) =>
|
|
32
|
-
doc(
|
|
33
|
-
table(attrs)(
|
|
34
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
35
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
36
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
37
|
-
),
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const expectedDocuments = {
|
|
41
|
-
fullWidthAppearanceLayoutDefault: createDoc({
|
|
42
|
-
localId: 'localId',
|
|
43
|
-
isNumberColumnEnabled: false,
|
|
44
|
-
layout: 'default',
|
|
45
|
-
width: 1800,
|
|
46
|
-
}),
|
|
47
|
-
fixedWidthAppearanceLayoutDefault: createDoc({
|
|
48
|
-
localId: 'localId',
|
|
49
|
-
isNumberColumnEnabled: false,
|
|
50
|
-
layout: 'default',
|
|
51
|
-
width: 760,
|
|
52
|
-
}),
|
|
53
|
-
fixedWidthAppearanceLayoutWide: createDoc({
|
|
54
|
-
localId: 'localId',
|
|
55
|
-
isNumberColumnEnabled: false,
|
|
56
|
-
layout: 'wide',
|
|
57
|
-
width: 960,
|
|
58
|
-
}),
|
|
59
|
-
fixedWidthAppearanceLayoutFullWidth: createDoc({
|
|
60
|
-
localId: 'localId',
|
|
61
|
-
isNumberColumnEnabled: false,
|
|
62
|
-
layout: 'full-width',
|
|
63
|
-
width: 1800,
|
|
64
|
-
}),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
describe('table width', () => {
|
|
68
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
69
|
-
|
|
70
|
-
beforeAll(() => {
|
|
71
|
-
// @ts-ignore
|
|
72
|
-
global['fetch'] = jest.fn();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const editor = (doc: DocBuilder, isFullWidthEnabled = false) => {
|
|
76
|
-
return createEditor({
|
|
77
|
-
doc,
|
|
78
|
-
attachTo: document.body,
|
|
79
|
-
preset: new Preset<LightEditorPlugin>()
|
|
80
|
-
.add([featureFlagsPlugin, {}])
|
|
81
|
-
.add([analyticsPlugin, {}])
|
|
82
|
-
.add(contentInsertionPlugin)
|
|
83
|
-
.add(widthPlugin)
|
|
84
|
-
.add(guidelinePlugin)
|
|
85
|
-
.add(selectionPlugin)
|
|
86
|
-
.add([
|
|
87
|
-
tablePlugin,
|
|
88
|
-
{
|
|
89
|
-
fullWidthEnabled: isFullWidthEnabled,
|
|
90
|
-
tableResizingEnabled: true, // so table-width plugin is enabled
|
|
91
|
-
tableOptions: {
|
|
92
|
-
advanced: true,
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
]),
|
|
96
|
-
pluginKey: tablePluginKey,
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
describe('move selection from outside table to inside table should fire analytics', () => {
|
|
101
|
-
const TABLE_LOCAL_ID = 'test-table-1';
|
|
102
|
-
it('should fire v3 analytics', () => {
|
|
103
|
-
// create editor with a table and a paragraph below
|
|
104
|
-
// mouse cursor is at the end of the parapgraph
|
|
105
|
-
const {
|
|
106
|
-
dispatchAnalyticsEvent,
|
|
107
|
-
editorView,
|
|
108
|
-
refs: { inTablePos },
|
|
109
|
-
} = editor(
|
|
110
|
-
doc(
|
|
111
|
-
table({ localId: TABLE_LOCAL_ID })(
|
|
112
|
-
tr(td({})(p('{inTablePos}in cell')), tdEmpty, tdEmpty),
|
|
113
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
114
|
-
),
|
|
115
|
-
p('hello cursor is here initially{<>}'),
|
|
116
|
-
),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
// move cursor to where ths inTablePos is
|
|
120
|
-
const $inTablePos = editorView.state.doc.resolve(inTablePos);
|
|
121
|
-
editorView.dispatch(
|
|
122
|
-
editorView.state.tr.setSelection(
|
|
123
|
-
new TextSelection($inTablePos, $inTablePos),
|
|
124
|
-
),
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
// analytics event should be fired
|
|
128
|
-
expect(dispatchAnalyticsEvent).toHaveBeenCalledWith(
|
|
129
|
-
expect.objectContaining({
|
|
130
|
-
action: 'selected',
|
|
131
|
-
actionSubject: 'document',
|
|
132
|
-
actionSubjectId: 'table',
|
|
133
|
-
attributes: expect.objectContaining({
|
|
134
|
-
localId: TABLE_LOCAL_ID,
|
|
135
|
-
}),
|
|
136
|
-
eventType: 'track',
|
|
137
|
-
}),
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
describe('Load an existing table with width attr equal null', () => {
|
|
143
|
-
describe('full-width editor appearance', () => {
|
|
144
|
-
it('should translate table width attr to 1800', () => {
|
|
145
|
-
const { editorView } = editor(
|
|
146
|
-
doc(
|
|
147
|
-
// @ts-ignore
|
|
148
|
-
table({ localId: 'localId', layout: 'default', width: null })(
|
|
149
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
150
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
151
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
152
|
-
),
|
|
153
|
-
),
|
|
154
|
-
true,
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
// create `replaceDocument` step
|
|
158
|
-
editorView.dispatch(
|
|
159
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
160
|
-
);
|
|
161
|
-
|
|
162
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
163
|
-
expectedDocuments.fullWidthAppearanceLayoutDefault,
|
|
164
|
-
);
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it('should not remove width when undo is sent', () => {
|
|
168
|
-
const { editorView } = editor(
|
|
169
|
-
doc(
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
table({ localId: 'localId', layout: 'default', width: null })(
|
|
172
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
173
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
174
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
175
|
-
),
|
|
176
|
-
),
|
|
177
|
-
true,
|
|
178
|
-
);
|
|
179
|
-
|
|
180
|
-
// create `replaceDocument` step
|
|
181
|
-
editorView.dispatch(
|
|
182
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
183
|
-
);
|
|
184
|
-
|
|
185
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
186
|
-
expectedDocuments.fullWidthAppearanceLayoutDefault,
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
undo(editorView.state, editorView.dispatch);
|
|
190
|
-
|
|
191
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
192
|
-
expectedDocuments.fullWidthAppearanceLayoutDefault,
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
describe('fixed-width editor appearance', () => {
|
|
197
|
-
it('should translate table width attr to 760 for default layout', () => {
|
|
198
|
-
const { editorView } = editor(
|
|
199
|
-
doc(
|
|
200
|
-
// @ts-ignore
|
|
201
|
-
table({ localId: 'localId', layout: 'default', width: null })(
|
|
202
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
203
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
204
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
205
|
-
),
|
|
206
|
-
),
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
// create `replaceDocument` step
|
|
210
|
-
editorView.dispatch(
|
|
211
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
212
|
-
);
|
|
213
|
-
|
|
214
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
215
|
-
expectedDocuments.fixedWidthAppearanceLayoutDefault,
|
|
216
|
-
);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should not remove width when undo is sent', () => {
|
|
220
|
-
const { editorView } = editor(
|
|
221
|
-
doc(
|
|
222
|
-
// @ts-ignore
|
|
223
|
-
table({ localId: 'localId', layout: 'default', width: null })(
|
|
224
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
225
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
226
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
227
|
-
),
|
|
228
|
-
),
|
|
229
|
-
);
|
|
230
|
-
|
|
231
|
-
// create `replaceDocument` step
|
|
232
|
-
editorView.dispatch(
|
|
233
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
234
|
-
);
|
|
235
|
-
|
|
236
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
237
|
-
expectedDocuments.fixedWidthAppearanceLayoutDefault,
|
|
238
|
-
);
|
|
239
|
-
|
|
240
|
-
undo(editorView.state, editorView.dispatch);
|
|
241
|
-
|
|
242
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
243
|
-
expectedDocuments.fixedWidthAppearanceLayoutDefault,
|
|
244
|
-
);
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('should translate table width attr to 960 for wide layout', () => {
|
|
248
|
-
const { editorView } = editor(
|
|
249
|
-
doc(
|
|
250
|
-
// @ts-ignore
|
|
251
|
-
table({ localId: 'localId', layout: 'wide', width: null })(
|
|
252
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
253
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
254
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
255
|
-
),
|
|
256
|
-
),
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
// create `replaceDocument` step
|
|
260
|
-
editorView.dispatch(
|
|
261
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
262
|
-
);
|
|
263
|
-
|
|
264
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
265
|
-
expectedDocuments.fixedWidthAppearanceLayoutWide,
|
|
266
|
-
);
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it('should translate table width attr to 1800 for full-width layout', () => {
|
|
270
|
-
const { editorView } = editor(
|
|
271
|
-
doc(
|
|
272
|
-
// @ts-ignore
|
|
273
|
-
table({ localId: 'localId', layout: 'full-width', width: null })(
|
|
274
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
275
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
276
|
-
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
277
|
-
),
|
|
278
|
-
),
|
|
279
|
-
);
|
|
280
|
-
|
|
281
|
-
// create `replaceDocument` step
|
|
282
|
-
editorView.dispatch(
|
|
283
|
-
editorView.state.tr.setMeta('replaceDocument', true),
|
|
284
|
-
);
|
|
285
|
-
|
|
286
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
287
|
-
expectedDocuments.fixedWidthAppearanceLayoutFullWidth,
|
|
288
|
-
);
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
});
|
|
@@ -1,399 +0,0 @@
|
|
|
1
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
2
|
-
import { TableSortOrder as SortOrder } from '@atlaskit/custom-steps';
|
|
3
|
-
import type { DocBuilder } from '@atlaskit/editor-common/types';
|
|
4
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
5
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
6
|
-
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
7
|
-
import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
8
|
-
import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
9
|
-
import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
10
|
-
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
11
|
-
import type { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
13
|
-
import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
14
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
15
|
-
import {
|
|
16
|
-
createProsemirrorEditorFactory,
|
|
17
|
-
Preset,
|
|
18
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
19
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
20
|
-
import {
|
|
21
|
-
doc,
|
|
22
|
-
p,
|
|
23
|
-
table,
|
|
24
|
-
td,
|
|
25
|
-
th,
|
|
26
|
-
tr,
|
|
27
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
28
|
-
|
|
29
|
-
import { sortByColumn } from '../../commands';
|
|
30
|
-
import tablePlugin from '../../plugin';
|
|
31
|
-
import { pluginKey as tablePluginKey } from '../../pm-plugins/plugin-key';
|
|
32
|
-
import type { PermittedLayoutsDescriptor, TablePluginState } from '../../types';
|
|
33
|
-
|
|
34
|
-
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
35
|
-
|
|
36
|
-
describe('table plugin', () => {
|
|
37
|
-
beforeEach(() => {
|
|
38
|
-
uuid.setStatic(TABLE_LOCAL_ID);
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
afterEach(() => {
|
|
42
|
-
uuid.setStatic(false);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
46
|
-
const tableOptions = {
|
|
47
|
-
allowNumberColumn: true,
|
|
48
|
-
allowHeaderRow: true,
|
|
49
|
-
allowHeaderColumn: true,
|
|
50
|
-
allowBackgroundColor: true,
|
|
51
|
-
permittedLayouts: 'all' as PermittedLayoutsDescriptor,
|
|
52
|
-
allowColumnSorting: true,
|
|
53
|
-
};
|
|
54
|
-
const preset = new Preset<LightEditorPlugin>()
|
|
55
|
-
.add([featureFlagsPlugin, {}])
|
|
56
|
-
.add([analyticsPlugin, {}])
|
|
57
|
-
.add(contentInsertionPlugin)
|
|
58
|
-
.add(widthPlugin)
|
|
59
|
-
.add(guidelinePlugin)
|
|
60
|
-
.add(selectionPlugin)
|
|
61
|
-
.add([tablePlugin, { tableOptions }]);
|
|
62
|
-
|
|
63
|
-
const editor = (doc: DocBuilder) => {
|
|
64
|
-
return createEditor<TablePluginState, PluginKey, typeof preset>({
|
|
65
|
-
doc,
|
|
66
|
-
preset,
|
|
67
|
-
pluginKey: tablePluginKey,
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
describe('TableView', () => {
|
|
72
|
-
describe('Sort Columns in given order', () => {
|
|
73
|
-
it('sorts the given column in ascending order', () => {
|
|
74
|
-
const { editorView } = editor(
|
|
75
|
-
doc(
|
|
76
|
-
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
77
|
-
tr(
|
|
78
|
-
th({})(p('1')),
|
|
79
|
-
th({})(p('2')),
|
|
80
|
-
th({})(p('3')),
|
|
81
|
-
th({})(p('4')),
|
|
82
|
-
th({})(p('5')),
|
|
83
|
-
),
|
|
84
|
-
tr(
|
|
85
|
-
td({})(p('c')),
|
|
86
|
-
td({})(p('c')),
|
|
87
|
-
td({})(p()),
|
|
88
|
-
td({})(p('c')),
|
|
89
|
-
td({})(p()),
|
|
90
|
-
),
|
|
91
|
-
tr(
|
|
92
|
-
td({})(p('b')),
|
|
93
|
-
td({})(p()),
|
|
94
|
-
td({})(p('d')),
|
|
95
|
-
td({})(p()),
|
|
96
|
-
td({})(p('c')),
|
|
97
|
-
),
|
|
98
|
-
tr(
|
|
99
|
-
td({})(p()),
|
|
100
|
-
td({})(p('z')),
|
|
101
|
-
td({})(p()),
|
|
102
|
-
td({})(p()),
|
|
103
|
-
td({})(p('f')),
|
|
104
|
-
),
|
|
105
|
-
tr(
|
|
106
|
-
td({})(p('2')),
|
|
107
|
-
td({})(p()),
|
|
108
|
-
td({})(p()),
|
|
109
|
-
td({})(p()),
|
|
110
|
-
td({})(p()),
|
|
111
|
-
),
|
|
112
|
-
tr(
|
|
113
|
-
td({})(p('1')),
|
|
114
|
-
td({})(p()),
|
|
115
|
-
td({})(p('c')),
|
|
116
|
-
td({})(p()),
|
|
117
|
-
td({})(p()),
|
|
118
|
-
),
|
|
119
|
-
tr(
|
|
120
|
-
td({})(p('a')),
|
|
121
|
-
td({})(p()),
|
|
122
|
-
td({})(p()),
|
|
123
|
-
td({})(p()),
|
|
124
|
-
td({})(p()),
|
|
125
|
-
),
|
|
126
|
-
),
|
|
127
|
-
),
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
const sortByColumnCommand = sortByColumn(0, SortOrder.ASC);
|
|
131
|
-
|
|
132
|
-
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
133
|
-
|
|
134
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
135
|
-
doc(
|
|
136
|
-
table({
|
|
137
|
-
isNumberColumnEnabled: false,
|
|
138
|
-
layout: 'default',
|
|
139
|
-
localId: TABLE_LOCAL_ID,
|
|
140
|
-
})(
|
|
141
|
-
tr(
|
|
142
|
-
th({})(p('1')),
|
|
143
|
-
th({})(p('2')),
|
|
144
|
-
th({})(p('3')),
|
|
145
|
-
th({})(p('4')),
|
|
146
|
-
th({})(p('5')),
|
|
147
|
-
),
|
|
148
|
-
tr(
|
|
149
|
-
td({})(p('1')),
|
|
150
|
-
td({})(p()),
|
|
151
|
-
td({})(p('c')),
|
|
152
|
-
td({})(p()),
|
|
153
|
-
td({})(p()),
|
|
154
|
-
),
|
|
155
|
-
tr(
|
|
156
|
-
td({})(p('2')),
|
|
157
|
-
td({})(p()),
|
|
158
|
-
td({})(p()),
|
|
159
|
-
td({})(p()),
|
|
160
|
-
td({})(p()),
|
|
161
|
-
),
|
|
162
|
-
tr(
|
|
163
|
-
td({})(p('a')),
|
|
164
|
-
td({})(p()),
|
|
165
|
-
td({})(p()),
|
|
166
|
-
td({})(p()),
|
|
167
|
-
td({})(p()),
|
|
168
|
-
),
|
|
169
|
-
tr(
|
|
170
|
-
td({})(p('b')),
|
|
171
|
-
td({})(p()),
|
|
172
|
-
td({})(p('d')),
|
|
173
|
-
td({})(p()),
|
|
174
|
-
td({})(p('c')),
|
|
175
|
-
),
|
|
176
|
-
tr(
|
|
177
|
-
td({})(p('c')),
|
|
178
|
-
td({})(p('c')),
|
|
179
|
-
td({})(p()),
|
|
180
|
-
td({})(p('c')),
|
|
181
|
-
td({})(p()),
|
|
182
|
-
),
|
|
183
|
-
tr(
|
|
184
|
-
td({})(p()),
|
|
185
|
-
td({})(p('z')),
|
|
186
|
-
td({})(p()),
|
|
187
|
-
td({})(p()),
|
|
188
|
-
td({})(p('f')),
|
|
189
|
-
),
|
|
190
|
-
),
|
|
191
|
-
),
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
it('sorts the given column in descending order', () => {
|
|
195
|
-
const { editorView } = editor(
|
|
196
|
-
doc(
|
|
197
|
-
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
198
|
-
tr(
|
|
199
|
-
th({})(p('1')),
|
|
200
|
-
th({})(p('2')),
|
|
201
|
-
th({})(p('3')),
|
|
202
|
-
th({})(p('4')),
|
|
203
|
-
th({})(p('5')),
|
|
204
|
-
),
|
|
205
|
-
tr(
|
|
206
|
-
td({})(p('c')),
|
|
207
|
-
td({})(p('c')),
|
|
208
|
-
td({})(p()),
|
|
209
|
-
td({})(p('c')),
|
|
210
|
-
td({})(p()),
|
|
211
|
-
),
|
|
212
|
-
tr(
|
|
213
|
-
td({})(p('b')),
|
|
214
|
-
td({})(p()),
|
|
215
|
-
td({})(p('d')),
|
|
216
|
-
td({})(p()),
|
|
217
|
-
td({})(p('c')),
|
|
218
|
-
),
|
|
219
|
-
tr(
|
|
220
|
-
td({})(p()),
|
|
221
|
-
td({})(p('z')),
|
|
222
|
-
td({})(p()),
|
|
223
|
-
td({})(p()),
|
|
224
|
-
td({})(p('f')),
|
|
225
|
-
),
|
|
226
|
-
tr(
|
|
227
|
-
td({})(p('2')),
|
|
228
|
-
td({})(p()),
|
|
229
|
-
td({})(p()),
|
|
230
|
-
td({})(p()),
|
|
231
|
-
td({})(p()),
|
|
232
|
-
),
|
|
233
|
-
tr(
|
|
234
|
-
td({})(p('1')),
|
|
235
|
-
td({})(p()),
|
|
236
|
-
td({})(p('c')),
|
|
237
|
-
td({})(p()),
|
|
238
|
-
td({})(p()),
|
|
239
|
-
),
|
|
240
|
-
tr(
|
|
241
|
-
td({})(p('a')),
|
|
242
|
-
td({})(p()),
|
|
243
|
-
td({})(p()),
|
|
244
|
-
td({})(p()),
|
|
245
|
-
td({})(p()),
|
|
246
|
-
),
|
|
247
|
-
),
|
|
248
|
-
),
|
|
249
|
-
);
|
|
250
|
-
|
|
251
|
-
const sortByColumnCommand = sortByColumn(0, SortOrder.DESC);
|
|
252
|
-
|
|
253
|
-
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
254
|
-
|
|
255
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
256
|
-
doc(
|
|
257
|
-
table({
|
|
258
|
-
isNumberColumnEnabled: false,
|
|
259
|
-
layout: 'default',
|
|
260
|
-
localId: TABLE_LOCAL_ID,
|
|
261
|
-
})(
|
|
262
|
-
tr(
|
|
263
|
-
th({})(p('1')),
|
|
264
|
-
th({})(p('2')),
|
|
265
|
-
th({})(p('3')),
|
|
266
|
-
th({})(p('4')),
|
|
267
|
-
th({})(p('5')),
|
|
268
|
-
),
|
|
269
|
-
tr(
|
|
270
|
-
td({})(p('c')),
|
|
271
|
-
td({})(p('c')),
|
|
272
|
-
td({})(p()),
|
|
273
|
-
td({})(p('c')),
|
|
274
|
-
td({})(p()),
|
|
275
|
-
),
|
|
276
|
-
tr(
|
|
277
|
-
td({})(p('b')),
|
|
278
|
-
td({})(p()),
|
|
279
|
-
td({})(p('d')),
|
|
280
|
-
td({})(p()),
|
|
281
|
-
td({})(p('c')),
|
|
282
|
-
),
|
|
283
|
-
tr(
|
|
284
|
-
td({})(p('a')),
|
|
285
|
-
td({})(p()),
|
|
286
|
-
td({})(p()),
|
|
287
|
-
td({})(p()),
|
|
288
|
-
td({})(p()),
|
|
289
|
-
),
|
|
290
|
-
tr(
|
|
291
|
-
td({})(p('2')),
|
|
292
|
-
td({})(p()),
|
|
293
|
-
td({})(p()),
|
|
294
|
-
td({})(p()),
|
|
295
|
-
td({})(p()),
|
|
296
|
-
),
|
|
297
|
-
tr(
|
|
298
|
-
td({})(p('1')),
|
|
299
|
-
td({})(p()),
|
|
300
|
-
td({})(p('c')),
|
|
301
|
-
td({})(p()),
|
|
302
|
-
td({})(p()),
|
|
303
|
-
),
|
|
304
|
-
tr(
|
|
305
|
-
td({})(p()),
|
|
306
|
-
td({})(p('z')),
|
|
307
|
-
td({})(p()),
|
|
308
|
-
td({})(p()),
|
|
309
|
-
td({})(p('f')),
|
|
310
|
-
),
|
|
311
|
-
),
|
|
312
|
-
),
|
|
313
|
-
);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
describe('case sensitivity', () => {
|
|
317
|
-
describe('ascending order', () => {
|
|
318
|
-
it('sorts the given column', () => {
|
|
319
|
-
const { editorView } = editor(
|
|
320
|
-
doc(
|
|
321
|
-
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
322
|
-
tr(th({})(p()), th({})(p())),
|
|
323
|
-
tr(td({})(p('A')), td({})(p('1'))),
|
|
324
|
-
tr(td({})(p('a')), td({})(p('2'))),
|
|
325
|
-
tr(td({})(p('b')), td({})(p('3'))),
|
|
326
|
-
tr(td({})(p('B')), td({})(p('4'))),
|
|
327
|
-
tr(td({})(p('bb')), td({})(p('5'))),
|
|
328
|
-
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
329
|
-
),
|
|
330
|
-
),
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
const sortByColumnCommand = sortByColumn(0, SortOrder.ASC);
|
|
334
|
-
|
|
335
|
-
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
336
|
-
|
|
337
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
338
|
-
doc(
|
|
339
|
-
table({
|
|
340
|
-
isNumberColumnEnabled: false,
|
|
341
|
-
layout: 'default',
|
|
342
|
-
localId: TABLE_LOCAL_ID,
|
|
343
|
-
})(
|
|
344
|
-
tr(th({})(p()), th({})(p())),
|
|
345
|
-
tr(td({})(p('A')), td({})(p('1'))),
|
|
346
|
-
tr(td({})(p('a')), td({})(p('2'))),
|
|
347
|
-
tr(td({})(p('B')), td({})(p('4'))),
|
|
348
|
-
tr(td({})(p('b')), td({})(p('3'))),
|
|
349
|
-
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
350
|
-
tr(td({})(p('bb')), td({})(p('5'))),
|
|
351
|
-
),
|
|
352
|
-
),
|
|
353
|
-
);
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
|
|
357
|
-
describe('descending order', () => {
|
|
358
|
-
it('sorts the given column', () => {
|
|
359
|
-
const { editorView } = editor(
|
|
360
|
-
doc(
|
|
361
|
-
table({ isNumberColumnEnabled: false, layout: 'default' })(
|
|
362
|
-
tr(th({})(p()), th({})(p())),
|
|
363
|
-
tr(td({})(p('A')), td({})(p('1'))),
|
|
364
|
-
tr(td({})(p('a')), td({})(p('2'))),
|
|
365
|
-
tr(td({})(p('b')), td({})(p('3'))),
|
|
366
|
-
tr(td({})(p('B')), td({})(p('4'))),
|
|
367
|
-
tr(td({})(p('bb')), td({})(p('5'))),
|
|
368
|
-
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
369
|
-
),
|
|
370
|
-
),
|
|
371
|
-
);
|
|
372
|
-
|
|
373
|
-
const sortByColumnCommand = sortByColumn(0, SortOrder.DESC);
|
|
374
|
-
|
|
375
|
-
sortByColumnCommand(editorView.state, editorView.dispatch);
|
|
376
|
-
|
|
377
|
-
expect(editorView.state.doc).toEqualDocument(
|
|
378
|
-
doc(
|
|
379
|
-
table({
|
|
380
|
-
isNumberColumnEnabled: false,
|
|
381
|
-
layout: 'default',
|
|
382
|
-
localId: TABLE_LOCAL_ID,
|
|
383
|
-
})(
|
|
384
|
-
tr(th({})(p()), th({})(p())),
|
|
385
|
-
tr(td({})(p('bb')), td({})(p('5'))),
|
|
386
|
-
tr(td({})(p('Bb')), td({})(p('6'))),
|
|
387
|
-
tr(td({})(p('b')), td({})(p('3'))),
|
|
388
|
-
tr(td({})(p('B')), td({})(p('4'))),
|
|
389
|
-
tr(td({})(p('a')), td({})(p('2'))),
|
|
390
|
-
tr(td({})(p('A')), td({})(p('1'))),
|
|
391
|
-
),
|
|
392
|
-
),
|
|
393
|
-
);
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
});
|
|
397
|
-
});
|
|
398
|
-
});
|
|
399
|
-
});
|