@atlaskit/editor-plugin-table 0.1.0 → 0.1.2
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/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/esm/version.json +1 -1
- package/examples/99-testing.tsx +35 -30
- package/package.json +3 -12
- package/src/__tests__/integration/__fixtures__/auto-size-documents.ts +5 -10
- package/src/__tests__/integration/__fixtures__/layout-documents.ts +1 -2
- package/src/__tests__/integration/__fixtures__/resize-documents.ts +5 -10
- package/src/__tests__/integration/resize.ts +1 -2
- package/src/__tests__/unit/analytics.ts +33 -32
- package/src/__tests__/unit/collab.ts +12 -9
- package/src/__tests__/unit/commands/sort.ts +28 -28
- package/src/__tests__/unit/copy-paste.ts +6 -8
- package/src/__tests__/unit/event-handlers.ts +7 -10
- package/src/__tests__/unit/fix-tables.ts +17 -23
- package/src/__tests__/unit/get-toolbar-config.ts +0 -5
- package/src/__tests__/unit/hover-selection.ts +1 -66
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -1
- package/src/__tests__/unit/index.ts +5 -5
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +11 -218
- package/src/__tests__/unit/nodeviews/cell.ts +12 -10
- package/src/__tests__/unit/nodeviews/table.ts +25 -26
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +11 -8
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +11 -12
- package/src/__tests__/unit/toolbar.ts +18 -5
- package/src/__tests__/unit/ui/ContextualMenu.tsx +55 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +7 -7
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +45 -49
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +49 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +30 -2
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +143 -111
- package/src/__tests__/unit/ui/RowControls.tsx +112 -141
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +18 -15
- package/src/__tests__/unit/undo-redo.ts +10 -9
- package/src/__tests__/unit/utils/nodes.ts +8 -4
- package/src/__tests__/unit/utils/row-controls.ts +8 -4
- package/src/plugins/table/commands/clear.ts +30 -29
- package/src/plugins/table/commands/go-to-next-cell.ts +41 -38
- package/src/plugins/table/commands/insert.ts +91 -91
- package/src/plugins/table/commands/misc.ts +123 -125
- package/src/plugins/table/commands/selection.ts +329 -319
- package/src/plugins/table/commands-with-analytics.ts +299 -294
- package/src/plugins/table/event-handlers.ts +111 -111
- package/src/plugins/table/handlers.ts +95 -94
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +4 -3
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -9
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +39 -39
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +7 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +30 -30
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +7 -7
- package/src/plugins/table/pm-plugins/plugin-factory.ts +33 -33
- package/src/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.ts +6 -9
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +3 -2
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +98 -90
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +46 -47
- package/src/plugins/table/toolbar.tsx +116 -113
- package/src/plugins/table/transforms/column-width.ts +143 -146
- package/src/plugins/table/transforms/delete-columns.ts +144 -142
- package/src/plugins/table/transforms/delete-rows.ts +110 -111
- package/src/plugins/table/transforms/metadata.ts +9 -9
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +7 -6
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +3 -2
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +2 -5
- package/src/plugins/table/ui/LayoutButton/index.tsx +2 -6
- package/src/plugins/table/ui/common-styles.ts +1 -3
- package/src/plugins/table/utils/analytics.ts +24 -25
- package/src/plugins/table/utils/dom.ts +3 -3
- package/src/plugins/table/utils/row-controls.ts +92 -93
- package/dist/types-ts4.0/index.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/commands/clear.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/collapse.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/commands/go-to-next-cell.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/commands/hover.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/commands/insert.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/commands/misc.d.ts +0 -27
- package/dist/types-ts4.0/plugins/table/commands/selection.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/sort.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/split-cell.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/commands/toggle.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/create-plugin-config.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/event-handlers.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/handlers.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/nodeviews/TableComponent.d.ts +0 -72
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/table.d.ts +0 -31
- package/dist/types-ts4.0/plugins/table/nodeviews/tableCell.d.ts +0 -19
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +0 -24
- package/dist/types-ts4.0/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/plugin.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/index.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/types.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/default-table-selection.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/keymap.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-factory.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/commands.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -65
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/types.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/util.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-local-id.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/commands.d.ts +0 -25
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +0 -13
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-selection-keymap.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/toolbar.d.ts +0 -36
- package/dist/types-ts4.0/plugins/table/transforms/column-width.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/transforms/delete-columns.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/delete-rows.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/transforms/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/transforms/merge.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/metadata.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/transforms/replace-table.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/split.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/types.d.ts +0 -328
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/index.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/styles.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +0 -87
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/index.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/styles.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/index.d.ts +0 -54
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/types.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/index.d.ts +0 -35
- package/dist/types-ts4.0/plugins/table/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/index.d.ts +0 -40
- package/dist/types-ts4.0/plugins/table/ui/common-styles.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/ui/consts.d.ts +0 -39
- package/dist/types-ts4.0/plugins/table/ui/messages.d.ts +0 -38
- package/dist/types-ts4.0/plugins/table/ui/ui-styles.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/utils/analytics.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/utils/collapse.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/utils/column-controls.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/dom.d.ts +0 -20
- package/dist/types-ts4.0/plugins/table/utils/get-allow-add-column-custom-step.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/index.d.ts +0 -11
- package/dist/types-ts4.0/plugins/table/utils/nodes.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/utils/paste.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/utils/referentiality.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/row-controls.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/selection.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/utils/table.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/utils/update-plugin-state-decorations.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table-plugin.d.ts +0 -2
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +0 -56
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +0 -50
|
@@ -49,14 +49,12 @@ const array = (...args: any): Node[] => args.map((i: any) => i(defaultSchema));
|
|
|
49
49
|
const fragment = (...args: any) =>
|
|
50
50
|
Fragment.from(args.map((i: any) => i(defaultSchema)));
|
|
51
51
|
|
|
52
|
-
const selectCell =
|
|
53
|
-
pos: number;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return tr.setSelection(new CellSelection($anchor, $anchor) as any);
|
|
59
|
-
};
|
|
52
|
+
const selectCell =
|
|
53
|
+
(cell: { pos: number; start: number; node: ProsemirrorNode }) =>
|
|
54
|
+
(tr: Transaction) => {
|
|
55
|
+
const $anchor = tr.doc.resolve(cell.pos);
|
|
56
|
+
return tr.setSelection(new CellSelection($anchor, $anchor) as any);
|
|
57
|
+
};
|
|
60
58
|
|
|
61
59
|
const copySelectionAndPasteAtPos = ({
|
|
62
60
|
editorView,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MediaAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import { TextSelection } from 'prosemirror-state';
|
|
3
|
-
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
4
3
|
import {
|
|
5
4
|
createProsemirrorEditorFactory,
|
|
6
5
|
LightEditorPlugin,
|
|
@@ -19,7 +18,6 @@ import {
|
|
|
19
18
|
mediaGroup,
|
|
20
19
|
p,
|
|
21
20
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
22
|
-
import { TablePluginState } from '../../plugins/table/types';
|
|
23
21
|
import {
|
|
24
22
|
handleMouseOver,
|
|
25
23
|
handleMouseMove,
|
|
@@ -36,6 +34,7 @@ import {
|
|
|
36
34
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
37
35
|
import { TableCssClassName as ClassName } from '../../plugins/table/types';
|
|
38
36
|
import tablePlugin from '../../plugins/table-plugin';
|
|
37
|
+
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
39
38
|
|
|
40
39
|
describe('table plugin: decorations', () => {
|
|
41
40
|
const createEditor = createProsemirrorEditorFactory();
|
|
@@ -148,21 +147,19 @@ describe('table plugin: decorations', () => {
|
|
|
148
147
|
});
|
|
149
148
|
|
|
150
149
|
describe('table event handlers', () => {
|
|
151
|
-
const createEditor =
|
|
150
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
152
151
|
const fakeGetEditorFeatureFlags = () => ({});
|
|
153
152
|
const editor = (doc: DocBuilder) =>
|
|
154
153
|
createEditor({
|
|
155
154
|
doc,
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
155
|
+
attachTo: document.body,
|
|
156
|
+
preset: new Preset<LightEditorPlugin>().add(tablePlugin).add([
|
|
157
|
+
mediaPlugin,
|
|
158
|
+
{
|
|
159
159
|
allowMediaSingle: true,
|
|
160
160
|
allowMediaGroup: true,
|
|
161
161
|
},
|
|
162
|
-
|
|
163
|
-
__plugins: [tablePlugin()],
|
|
164
|
-
},
|
|
165
|
-
},
|
|
162
|
+
]),
|
|
166
163
|
pluginKey,
|
|
167
164
|
});
|
|
168
165
|
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createProsemirrorEditorFactory,
|
|
3
|
+
LightEditorPlugin,
|
|
4
|
+
Preset,
|
|
5
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
2
6
|
import {
|
|
3
7
|
doc,
|
|
4
8
|
p,
|
|
@@ -8,21 +12,17 @@ import {
|
|
|
8
12
|
th,
|
|
9
13
|
DocBuilder,
|
|
10
14
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
11
|
-
import {
|
|
15
|
+
import { PluginConfig } from '../../plugins/table/types';
|
|
12
16
|
|
|
13
17
|
import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
14
18
|
import tablePlugin from '../../plugins/table-plugin';
|
|
19
|
+
|
|
15
20
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
16
21
|
|
|
17
22
|
describe('fix tables', () => {
|
|
18
|
-
const createEditor =
|
|
23
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
19
24
|
// @ts-ignore
|
|
20
25
|
global['fetch'] = jest.fn();
|
|
21
|
-
const createAnalyticsEvent = jest.fn();
|
|
22
|
-
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
createAnalyticsEvent.mockReset();
|
|
25
|
-
});
|
|
26
26
|
|
|
27
27
|
const editor = (doc: DocBuilder) => {
|
|
28
28
|
const tableOptions = {
|
|
@@ -35,18 +35,12 @@ describe('fix tables', () => {
|
|
|
35
35
|
|
|
36
36
|
return createEditor({
|
|
37
37
|
doc,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}),
|
|
44
|
-
],
|
|
45
|
-
},
|
|
46
|
-
allowAnalyticsGASV3: true,
|
|
47
|
-
},
|
|
38
|
+
attachTo: document.body,
|
|
39
|
+
preset: new Preset<LightEditorPlugin>().add([
|
|
40
|
+
tablePlugin,
|
|
41
|
+
{ tableOptions },
|
|
42
|
+
]),
|
|
48
43
|
pluginKey: tablePluginKey,
|
|
49
|
-
createAnalyticsEvent,
|
|
50
44
|
});
|
|
51
45
|
};
|
|
52
46
|
|
|
@@ -92,7 +86,7 @@ describe('fix tables', () => {
|
|
|
92
86
|
const TABLE_LOCAL_ID = 'test-table-2';
|
|
93
87
|
const SPAN_VALUE = -2;
|
|
94
88
|
it('should fire v3 analytics', () => {
|
|
95
|
-
editor(
|
|
89
|
+
const { dispatchAnalyticsEvent } = editor(
|
|
96
90
|
doc(
|
|
97
91
|
table({ localId: TABLE_LOCAL_ID })(
|
|
98
92
|
tr(
|
|
@@ -105,7 +99,7 @@ describe('fix tables', () => {
|
|
|
105
99
|
),
|
|
106
100
|
);
|
|
107
101
|
|
|
108
|
-
expect(
|
|
102
|
+
expect(dispatchAnalyticsEvent).toHaveBeenCalledWith(
|
|
109
103
|
expect.objectContaining({
|
|
110
104
|
action: 'invalidDocumentEncountered',
|
|
111
105
|
actionSubject: 'editor',
|
|
@@ -125,7 +119,7 @@ describe('fix tables', () => {
|
|
|
125
119
|
const TABLE_LOCAL_ID = 'test-table-3';
|
|
126
120
|
const SPAN_VALUE = -2;
|
|
127
121
|
it('should fire v3 analytics', () => {
|
|
128
|
-
editor(
|
|
122
|
+
const { dispatchAnalyticsEvent } = editor(
|
|
129
123
|
doc(
|
|
130
124
|
table({ localId: TABLE_LOCAL_ID })(
|
|
131
125
|
tr(
|
|
@@ -138,7 +132,7 @@ describe('fix tables', () => {
|
|
|
138
132
|
),
|
|
139
133
|
);
|
|
140
134
|
|
|
141
|
-
expect(
|
|
135
|
+
expect(dispatchAnalyticsEvent).toHaveBeenCalledWith(
|
|
142
136
|
expect.objectContaining({
|
|
143
137
|
action: 'invalidDocumentEncountered',
|
|
144
138
|
actionSubject: 'editor',
|
|
@@ -65,11 +65,6 @@ describe('getToolbarConfig', () => {
|
|
|
65
65
|
return button;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
-
/**
|
|
69
|
-
* Use `createEditorFactory` here to enable referentiality as
|
|
70
|
-
* `createProsemirrorEditorFactory` has some issues with correctly mimicking
|
|
71
|
-
* old state for the unique localId plugin
|
|
72
|
-
*/
|
|
73
68
|
const createEditorFn = createProsemirrorEditorFactory();
|
|
74
69
|
const createEditor = (doc: DocBuilder) => {
|
|
75
70
|
const output = createEditorFn({
|
|
@@ -26,11 +26,7 @@ import {
|
|
|
26
26
|
hoverRows,
|
|
27
27
|
hoverTable,
|
|
28
28
|
} from '../../plugins/table/commands';
|
|
29
|
-
import {
|
|
30
|
-
TableDecorations,
|
|
31
|
-
TableCssClassName as ClassName,
|
|
32
|
-
TablePluginState,
|
|
33
|
-
} from '../../plugins/table/types';
|
|
29
|
+
import { TableDecorations, TablePluginState } from '../../plugins/table/types';
|
|
34
30
|
import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
35
31
|
import { getDecorations } from '../../plugins/table/pm-plugins/decorations/plugin';
|
|
36
32
|
import tablePlugin from '../../plugins/table-plugin';
|
|
@@ -130,51 +126,6 @@ describe('table hover selection plugin', () => {
|
|
|
130
126
|
// selection spans 2 cells in the selected column (because we have 2 rows in the table)
|
|
131
127
|
expect(decos).toHaveLength(2);
|
|
132
128
|
});
|
|
133
|
-
|
|
134
|
-
it('should apply the hovered column class', () => {
|
|
135
|
-
hoverColumns([column])(editorView.state, editorView.dispatch);
|
|
136
|
-
|
|
137
|
-
const decos = getTableDecorations(
|
|
138
|
-
editorView,
|
|
139
|
-
getCellsInColumn(column)(editorView.state.selection)!,
|
|
140
|
-
TableDecorations.ALL_CONTROLS_HOVER,
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
decos.forEach((deco) => {
|
|
144
|
-
expect(deco).toEqual(
|
|
145
|
-
expect.objectContaining({
|
|
146
|
-
type: expect.objectContaining({
|
|
147
|
-
attrs: expect.objectContaining({
|
|
148
|
-
class: expect.stringContaining(ClassName.HOVERED_COLUMN),
|
|
149
|
-
}),
|
|
150
|
-
}),
|
|
151
|
-
}),
|
|
152
|
-
);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it('can apply the danger class to the decoration', () => {
|
|
157
|
-
hoverColumns([column], true)(editorView.state, editorView.dispatch);
|
|
158
|
-
|
|
159
|
-
const decos = getTableDecorations(
|
|
160
|
-
editorView,
|
|
161
|
-
getCellsInColumn(column)(editorView.state.selection)!,
|
|
162
|
-
TableDecorations.ALL_CONTROLS_HOVER,
|
|
163
|
-
);
|
|
164
|
-
|
|
165
|
-
expect(decos).toHaveLength(2);
|
|
166
|
-
const expected = [
|
|
167
|
-
ClassName.HOVERED_CELL_IN_DANGER,
|
|
168
|
-
ClassName.HOVERED_COLUMN,
|
|
169
|
-
];
|
|
170
|
-
|
|
171
|
-
decos.forEach((deco) => {
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
expect(deco.type.attrs.class.split(' ')).toEqual(
|
|
174
|
-
expect.arrayContaining(expected),
|
|
175
|
-
);
|
|
176
|
-
});
|
|
177
|
-
});
|
|
178
129
|
},
|
|
179
130
|
);
|
|
180
131
|
});
|
|
@@ -224,22 +175,6 @@ describe('table hover selection plugin', () => {
|
|
|
224
175
|
),
|
|
225
176
|
).toHaveLength(2);
|
|
226
177
|
});
|
|
227
|
-
|
|
228
|
-
it('can apply the danger class to the decoration', () => {
|
|
229
|
-
hoverRows([row], true)(editorView.state, editorView.dispatch);
|
|
230
|
-
const cells = getCellsInRow(row)(editorView.state.selection)!;
|
|
231
|
-
const decos = getTableDecorations(
|
|
232
|
-
editorView,
|
|
233
|
-
cells,
|
|
234
|
-
TableDecorations.ALL_CONTROLS_HOVER,
|
|
235
|
-
);
|
|
236
|
-
|
|
237
|
-
expect(decos).toHaveLength(2);
|
|
238
|
-
decos.forEach((deco) => {
|
|
239
|
-
// @ts-ignore
|
|
240
|
-
expect(deco.type.attrs.class.split(' ')).toContain('danger');
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
178
|
});
|
|
244
179
|
});
|
|
245
180
|
});
|
|
@@ -72,7 +72,7 @@ describe.skip('TableView', () => {
|
|
|
72
72
|
// create the NodeView
|
|
73
73
|
const node = table()(tr(tdCursor, tdEmpty, tdEmpty))(defaultSchema);
|
|
74
74
|
const { editorView, portalProviderAPI } = editor(doc(p()));
|
|
75
|
-
const eventDispatcher =
|
|
75
|
+
const eventDispatcher = { on: () => {} } as unknown as EventDispatcher;
|
|
76
76
|
const tableView = new TableView({
|
|
77
77
|
node,
|
|
78
78
|
allowColumnResizing: false,
|
|
@@ -450,8 +450,8 @@ describe('table plugin', () => {
|
|
|
450
450
|
);
|
|
451
451
|
|
|
452
452
|
editorView.dispatch(selectColumn(column)(editorView.state.tr));
|
|
453
|
-
const selection =
|
|
454
|
-
.selection as any
|
|
453
|
+
const selection = editorView.state
|
|
454
|
+
.selection as any as CellSelection;
|
|
455
455
|
const tableNode = selection.$anchorCell.node(-1);
|
|
456
456
|
const map = TableMap.get(tableNode);
|
|
457
457
|
const start = selection.$anchorCell.start(-1);
|
|
@@ -476,8 +476,8 @@ describe('table plugin', () => {
|
|
|
476
476
|
);
|
|
477
477
|
|
|
478
478
|
editorView.dispatch(selectRow(row)(editorView.state.tr));
|
|
479
|
-
const selection =
|
|
480
|
-
.selection as any
|
|
479
|
+
const selection = editorView.state
|
|
480
|
+
.selection as any as CellSelection;
|
|
481
481
|
const anchor = selection.$anchorCell.index(-1);
|
|
482
482
|
const head = selection.$headCell.index(-1);
|
|
483
483
|
expect(anchor).toEqual(row);
|
|
@@ -496,7 +496,7 @@ describe('table plugin', () => {
|
|
|
496
496
|
);
|
|
497
497
|
|
|
498
498
|
editorView.dispatch(selectTable(editorView.state.tr));
|
|
499
|
-
const selection =
|
|
499
|
+
const selection = editorView.state.selection as any as CellSelection;
|
|
500
500
|
expect(selection.isRowSelection()).toEqual(true);
|
|
501
501
|
expect(selection.isColSelection()).toEqual(true);
|
|
502
502
|
});
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { mount, ReactWrapper, shallow } from 'enzyme';
|
|
3
2
|
import { replaceRaf } from 'raf-stub';
|
|
4
|
-
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
5
4
|
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
6
5
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
7
6
|
import {
|
|
@@ -13,7 +12,6 @@ import {
|
|
|
13
12
|
tdEmpty,
|
|
14
13
|
tdCursor,
|
|
15
14
|
DocBuilder,
|
|
16
|
-
thEmpty,
|
|
17
15
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
18
16
|
import { findTable, selectTable } from '@atlaskit/editor-tables/utils';
|
|
19
17
|
import {
|
|
@@ -21,15 +19,10 @@ import {
|
|
|
21
19
|
TablePluginState,
|
|
22
20
|
} from '../../../plugins/table/types';
|
|
23
21
|
import TableComponent from '../../../plugins/table/nodeviews/TableComponent';
|
|
24
|
-
|
|
22
|
+
|
|
25
23
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
26
24
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
27
25
|
import { toggleNumberColumn } from '../../../plugins/table/commands';
|
|
28
|
-
import {
|
|
29
|
-
pluginKey as stickyHeadersPluginKey,
|
|
30
|
-
StickyPluginState,
|
|
31
|
-
} from '../../../plugins/table/pm-plugins/sticky-headers';
|
|
32
|
-
import { tablesHaveDifferentColumnWidths } from '../../../plugins/table/utils/nodes';
|
|
33
26
|
|
|
34
27
|
jest.mock('../../../plugins/table/utils/nodes', () =>
|
|
35
28
|
Object.assign({}, jest.requireActual('../../../plugins/table/utils/nodes'), {
|
|
@@ -37,17 +30,12 @@ jest.mock('../../../plugins/table/utils/nodes', () =>
|
|
|
37
30
|
}),
|
|
38
31
|
);
|
|
39
32
|
|
|
40
|
-
// with this jest will load mocked class from the relative __mocks__ folder
|
|
41
|
-
jest.mock('../../../plugins/table/nodeviews/OverflowShadowsObserver');
|
|
42
|
-
|
|
43
33
|
replaceRaf();
|
|
44
34
|
const requestAnimationFrame = window.requestAnimationFrame as any;
|
|
45
35
|
|
|
46
36
|
describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
47
37
|
const createEditor = createEditorFactory<TablePluginState>();
|
|
48
|
-
//
|
|
49
38
|
const getEditorFeatureFlags = jest.fn();
|
|
50
|
-
//
|
|
51
39
|
const editor = (
|
|
52
40
|
doc: DocBuilder,
|
|
53
41
|
featureFlags?: { [featureFlag: string]: string | boolean },
|
|
@@ -65,7 +53,6 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
65
53
|
pluginKey,
|
|
66
54
|
});
|
|
67
55
|
};
|
|
68
|
-
//
|
|
69
56
|
afterEach(() => {
|
|
70
57
|
jest.clearAllMocks();
|
|
71
58
|
});
|
|
@@ -165,224 +152,30 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
165
152
|
|
|
166
153
|
const tableF = findTable(view.state.selection);
|
|
167
154
|
const getNode = () => tableF!.node;
|
|
168
|
-
const
|
|
169
|
-
<TableComponent
|
|
170
|
-
view={view}
|
|
171
|
-
eventDispatcher={({ on: () => {} } as any) as EventDispatcher}
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
containerWidth={{}}
|
|
174
|
-
// @ts-ignore
|
|
175
|
-
getNode={getNode}
|
|
176
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
177
|
-
{...props}
|
|
178
|
-
/>,
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
expect(wrapper.hasClass(ClassName.WITH_CONTROLS)).toBe(expected);
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
describe('overflowShadowOptimization', () => {
|
|
186
|
-
let overflowShadowsConstructorSpy = jest.fn();
|
|
187
|
-
let updateStickyShadowsSpy = jest.fn();
|
|
188
|
-
let observeCellsSpy = jest.fn();
|
|
189
|
-
let disposeSpy = jest.fn();
|
|
190
|
-
beforeAll(() => {
|
|
191
|
-
(OverflowShadowsObserver as any).setMock('observeCells', observeCellsSpy);
|
|
192
|
-
(OverflowShadowsObserver as any).setMock('dispose', disposeSpy);
|
|
193
|
-
(OverflowShadowsObserver as any).setMock(
|
|
194
|
-
'updateStickyShadows',
|
|
195
|
-
updateStickyShadowsSpy,
|
|
196
|
-
);
|
|
197
|
-
(OverflowShadowsObserver as any).setMock(
|
|
198
|
-
'constructor',
|
|
199
|
-
overflowShadowsConstructorSpy,
|
|
200
|
-
);
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
afterAll(() => {
|
|
204
|
-
(OverflowShadowsObserver as any).resetMocks();
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
let triggerDispatcherEvent: { [key: string]: any } = {};
|
|
208
|
-
const tablePos = 0;
|
|
209
|
-
|
|
210
|
-
function setupTable(tableOverflowShadowsOptimization: boolean = false) {
|
|
211
|
-
const editorData = editor(
|
|
212
|
-
doc(
|
|
213
|
-
table()(
|
|
214
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
215
|
-
tr(td()(p('{<>}text')), tdEmpty, tdEmpty),
|
|
216
|
-
),
|
|
217
|
-
),
|
|
218
|
-
{
|
|
219
|
-
tableOverflowShadowsOptimization,
|
|
220
|
-
},
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
const view = editorData.editorView;
|
|
224
|
-
const tableF = findTable(view.state.selection);
|
|
225
|
-
|
|
226
|
-
const getNode = () => view.state.doc.firstChild!;
|
|
227
|
-
const wrapper = mount(
|
|
155
|
+
const { container } = render(
|
|
228
156
|
<TableComponent
|
|
229
157
|
view={view}
|
|
230
158
|
eventDispatcher={
|
|
231
|
-
(
|
|
232
|
-
on: (key: string, action: Function) => {
|
|
233
|
-
triggerDispatcherEvent[key] = action;
|
|
234
|
-
},
|
|
235
|
-
off: jest.fn(),
|
|
236
|
-
} as any) as EventDispatcher
|
|
159
|
+
{ on: jest.fn(), off: jest.fn() } as unknown as EventDispatcher
|
|
237
160
|
}
|
|
238
161
|
// @ts-ignore
|
|
239
162
|
containerWidth={{}}
|
|
240
|
-
pluginState={{
|
|
241
|
-
pluginConfig: {
|
|
242
|
-
allowControls: false,
|
|
243
|
-
},
|
|
244
|
-
}}
|
|
245
|
-
getPos={() => tablePos}
|
|
246
163
|
getNode={getNode}
|
|
247
|
-
|
|
248
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
164
|
+
contentDOM={(contentElement: HTMLElement | null) => {
|
|
249
165
|
const node = view.dom.getElementsByTagName('table')[0];
|
|
250
166
|
|
|
251
|
-
if (!
|
|
252
|
-
|
|
167
|
+
if (!contentElement?.firstChild) {
|
|
168
|
+
contentElement?.appendChild(node);
|
|
253
169
|
}
|
|
254
170
|
}}
|
|
255
171
|
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
172
|
+
{...props}
|
|
256
173
|
/>,
|
|
257
174
|
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
describe('with optimization on', () => {
|
|
263
|
-
let wrapper: ReactWrapper;
|
|
264
|
-
beforeEach(() => {
|
|
265
|
-
wrapper = setupTable(true).wrapper;
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('inits overflow shadows observer', () => {
|
|
269
|
-
const tableWrapperNode = wrapper
|
|
270
|
-
.find(`.${ClassName.TABLE_NODE_WRAPPER}`)
|
|
271
|
-
.getDOMNode();
|
|
272
|
-
const tableNode = tableWrapperNode.querySelector('table');
|
|
273
|
-
wrapper.setProps({});
|
|
274
|
-
expect(overflowShadowsConstructorSpy).toHaveBeenCalledWith(
|
|
275
|
-
expect.any(Function),
|
|
276
|
-
tableNode,
|
|
277
|
-
tableWrapperNode,
|
|
278
|
-
);
|
|
279
|
-
});
|
|
280
|
-
|
|
281
|
-
it('observes table cells on component update', () => {
|
|
282
|
-
expect(observeCellsSpy).not.toHaveBeenCalled();
|
|
283
|
-
wrapper.setProps({});
|
|
284
|
-
expect(observeCellsSpy).toHaveBeenCalledTimes(1);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
it('updates sticky shadows on sticky state changed', () => {
|
|
288
|
-
const newStickyState: StickyPluginState = [
|
|
289
|
-
{
|
|
290
|
-
pos: tablePos + 1,
|
|
291
|
-
top: 0,
|
|
292
|
-
padding: 10,
|
|
293
|
-
sticky: true,
|
|
294
|
-
},
|
|
295
|
-
];
|
|
296
|
-
triggerDispatcherEvent[(stickyHeadersPluginKey as any).key](
|
|
297
|
-
newStickyState,
|
|
298
|
-
);
|
|
299
|
-
expect(updateStickyShadowsSpy).toHaveBeenCalled();
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
it('disposes shadows observer on unmount', () => {
|
|
303
|
-
wrapper.setProps({});
|
|
304
|
-
wrapper.unmount();
|
|
305
|
-
expect(disposeSpy).toHaveBeenCalled();
|
|
306
|
-
});
|
|
307
|
-
});
|
|
308
|
-
|
|
309
|
-
describe('with optimization off', () => {
|
|
310
|
-
let wrapper: ReactWrapper;
|
|
311
|
-
beforeEach(() => {
|
|
312
|
-
wrapper = setupTable(false).wrapper;
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
it('does not init overflow shadows observer', () => {
|
|
316
|
-
wrapper.setProps({});
|
|
317
|
-
expect(overflowShadowsConstructorSpy).not.toHaveBeenCalled();
|
|
318
|
-
});
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('when media fullscreen is changed', () => {
|
|
323
|
-
function setupTable(isMediaFullscreen: boolean) {
|
|
324
|
-
const editorData = editor(
|
|
325
|
-
doc(
|
|
326
|
-
table()(
|
|
327
|
-
tr(thEmpty, thEmpty, thEmpty),
|
|
328
|
-
tr(td()(p('{<>}text')), tdEmpty, tdEmpty),
|
|
329
|
-
),
|
|
330
|
-
),
|
|
331
|
-
);
|
|
332
|
-
|
|
333
|
-
const view = editorData.editorView;
|
|
334
|
-
const tableF = findTable(view.state.selection);
|
|
335
|
-
let triggerDispatcherEvent: { [key: string]: any } = {};
|
|
336
|
-
const getNode = () => view.state.doc.firstChild!;
|
|
337
|
-
const tablePos = 0;
|
|
338
|
-
|
|
339
|
-
const wrapper = mount(
|
|
340
|
-
<TableComponent
|
|
341
|
-
view={view}
|
|
342
|
-
eventDispatcher={
|
|
343
|
-
({
|
|
344
|
-
on: (key: string, action: Function) => {
|
|
345
|
-
triggerDispatcherEvent[key] = action;
|
|
346
|
-
},
|
|
347
|
-
off: jest.fn(),
|
|
348
|
-
} as any) as EventDispatcher
|
|
349
|
-
}
|
|
350
|
-
// @ts-ignore
|
|
351
|
-
containerWidth={{}}
|
|
352
|
-
pluginState={{
|
|
353
|
-
pluginConfig: {
|
|
354
|
-
allowControls: false,
|
|
355
|
-
},
|
|
356
|
-
}}
|
|
357
|
-
getPos={() => tablePos}
|
|
358
|
-
getNode={getNode}
|
|
359
|
-
node={tableF!.node}
|
|
360
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
361
|
-
const node = view.dom.getElementsByTagName('table')[0];
|
|
362
|
-
if (!wrapper?.firstChild) {
|
|
363
|
-
wrapper?.appendChild(node);
|
|
364
|
-
}
|
|
365
|
-
}}
|
|
366
|
-
isMediaFullscreen={isMediaFullscreen}
|
|
367
|
-
allowColumnResizing={true}
|
|
368
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
369
|
-
/>,
|
|
175
|
+
const controlsContainer = container.querySelector(
|
|
176
|
+
`.${ClassName.WITH_CONTROLS}`,
|
|
370
177
|
);
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
it('when media is not fullscreen', () => {
|
|
375
|
-
const wrapper = setupTable(false).wrapper;
|
|
376
|
-
wrapper.setProps({});
|
|
377
|
-
|
|
378
|
-
expect(tablesHaveDifferentColumnWidths).toHaveBeenCalled();
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('when media is fullscreen', () => {
|
|
382
|
-
const wrapper = setupTable(true).wrapper;
|
|
383
|
-
wrapper.setProps({});
|
|
384
|
-
|
|
385
|
-
expect(tablesHaveDifferentColumnWidths).not.toHaveBeenCalled();
|
|
178
|
+
expect(!!controlsContainer).toBe(expected);
|
|
386
179
|
});
|
|
387
180
|
});
|
|
388
181
|
});
|
|
@@ -2,7 +2,11 @@ import {
|
|
|
2
2
|
setCellAttrs,
|
|
3
3
|
findCellClosestToPos,
|
|
4
4
|
} from '@atlaskit/editor-tables/utils';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
createProsemirrorEditorFactory,
|
|
7
|
+
LightEditorPlugin,
|
|
8
|
+
Preset,
|
|
9
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
10
|
import {
|
|
7
11
|
doc,
|
|
8
12
|
p,
|
|
@@ -19,13 +23,14 @@ import {
|
|
|
19
23
|
rgbToHex,
|
|
20
24
|
uuid,
|
|
21
25
|
} from '@atlaskit/adf-schema';
|
|
22
|
-
import {
|
|
26
|
+
import { PluginConfig } from '../../../plugins/table/types';
|
|
23
27
|
import { mergeCells } from '../../../plugins/table/transforms';
|
|
24
28
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
25
29
|
import TableCellViews from '../../../plugins/table/nodeviews/tableCell';
|
|
26
30
|
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
27
31
|
import * as domHelpers from '../../../plugins/table/pm-plugins/sticky-headers/nodeviews/dom';
|
|
28
32
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
33
|
+
import undoRedoPlugin from '@atlaskit/editor-core/src/plugins/undo-redo';
|
|
29
34
|
|
|
30
35
|
jest.mock('@atlaskit/editor-common/utils', () => ({
|
|
31
36
|
...jest.requireActual<Object>('@atlaskit/editor-common/utils'),
|
|
@@ -36,18 +41,15 @@ jest.mock('@atlaskit/editor-common/utils', () => ({
|
|
|
36
41
|
|
|
37
42
|
describe('table -> nodeviews -> tableCell.tsx', () => {
|
|
38
43
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
39
|
-
const createEditor =
|
|
44
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
40
45
|
|
|
41
46
|
const editor = (doc: DocBuilder, props?: PluginConfig) =>
|
|
42
47
|
createEditor({
|
|
43
48
|
doc,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
},
|
|
49
|
+
attachTo: document.body,
|
|
50
|
+
preset: new Preset<LightEditorPlugin>()
|
|
51
|
+
.add([tablePlugin, { tableOptions: { advanced: true, ...props } }])
|
|
52
|
+
.add(undoRedoPlugin),
|
|
51
53
|
pluginKey,
|
|
52
54
|
});
|
|
53
55
|
|