@atlaskit/editor-plugin-table 1.7.2 → 2.0.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 +15 -0
- package/dist/cjs/plugins/table/index.js +11 -16
- package/dist/cjs/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +2 -1
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/index.js +12 -12
- package/dist/cjs/plugins/table/utils/nodes.js +4 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/index.js +11 -16
- package/dist/es2019/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +4 -1
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/index.js +1 -1
- package/dist/es2019/plugins/table/utils/nodes.js +3 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/index.js +11 -16
- package/dist/esm/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.js +2 -1
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/index.js +12 -12
- package/dist/esm/plugins/table/utils/nodes.js +4 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands/insert.d.ts +1 -1
- package/dist/types/plugins/table/index.d.ts +0 -2
- package/dist/types/plugins/table/nodeviews/table.d.ts +3 -3
- package/dist/types/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/plugin-factory.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/plugin-key.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +2 -2
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -1
- package/dist/types/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-add-width.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-local-id.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +5 -3
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
- package/dist/types/plugins/table/utils/collapse.d.ts +3 -3
- package/dist/types/plugins/table/utils/row-controls.d.ts +1 -1
- package/dist/types/plugins/table/utils/update-plugin-state-decorations.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-add-width.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +5 -3
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +3 -3
- package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +1 -1
- package/package.json +7 -14
- package/report.api.md +0 -3
- package/src/__tests__/integration/sticky-header.ts +0 -94
- package/src/__tests__/unit/analytics.ts +20 -10
- package/src/__tests__/unit/keymap.ts +14 -21
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +12 -7
- 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 +2 -2
- 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 +2 -2
- package/src/__tests__/visual-regression/sticky-header.ts +3 -2
- package/src/plugins/table/index.tsx +12 -25
- package/src/plugins/table/nodeviews/table.tsx +5 -2
- package/src/plugins/table/pm-plugins/main.ts +1 -1
- package/src/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/misc.ts +1 -1
- package/src/plugins/table/toolbar.tsx +1 -3
- package/src/plugins/table/ui/FloatingContextualMenu/index.tsx +1 -1
- package/src/plugins/table/utils/collapse.ts +3 -3
- package/src/plugins/table/utils/nodes.ts +3 -3
- package/src/plugins/table/utils/update-plugin-state-decorations.ts +1 -1
- package/tmp/api-report-tmp.d.ts +0 -3
|
@@ -44,9 +44,9 @@ import tablePlugin from '../../plugins/table-plugin';
|
|
|
44
44
|
import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
|
|
45
45
|
import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
|
|
46
46
|
import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
47
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
48
47
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
49
48
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
49
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
50
50
|
|
|
51
51
|
const defaultTableDoc = doc(
|
|
52
52
|
table()(
|
|
@@ -59,6 +59,16 @@ const defaultTableDoc = doc(
|
|
|
59
59
|
const secondRow: Rect = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
60
60
|
const secondColumn: Rect = { left: 1, top: 0, bottom: 3, right: 2 };
|
|
61
61
|
|
|
62
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
63
|
+
// We just want to know if the action is called.
|
|
64
|
+
const mockAttachPayload = jest.fn();
|
|
65
|
+
const analyticsPluginFake = () => ({
|
|
66
|
+
name: 'analytics',
|
|
67
|
+
actions: {
|
|
68
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
|
|
62
72
|
describe('Table analytic events', () => {
|
|
63
73
|
let editorAnalyticsAPIFake: EditorAnalyticsAPI;
|
|
64
74
|
const analyticFireMock = jest.fn().mockReturnValue(jest.fn());
|
|
@@ -83,15 +93,15 @@ describe('Table analytic events', () => {
|
|
|
83
93
|
doc,
|
|
84
94
|
preset: new Preset<LightEditorPlugin>()
|
|
85
95
|
.add([featureFlagsPlugin, {}])
|
|
86
|
-
.add([
|
|
96
|
+
.add([
|
|
97
|
+
analyticsPluginFake as unknown as typeof analyticsPlugin,
|
|
98
|
+
{ createAnalyticsEvent: jest.fn() },
|
|
99
|
+
])
|
|
87
100
|
.add(typeAheadPlugin)
|
|
88
101
|
.add(contentInsertionPlugin)
|
|
89
102
|
.add(quickInsertPlugin)
|
|
90
103
|
.add(widthPlugin)
|
|
91
|
-
.add([
|
|
92
|
-
tablePlugin,
|
|
93
|
-
{ tableOptions, editorAnalyticsAPI: editorAnalyticsAPIFake },
|
|
94
|
-
]),
|
|
104
|
+
.add([tablePlugin, { tableOptions }]),
|
|
95
105
|
pluginKey,
|
|
96
106
|
});
|
|
97
107
|
|
|
@@ -105,7 +115,7 @@ describe('Table analytic events', () => {
|
|
|
105
115
|
});
|
|
106
116
|
|
|
107
117
|
it('should fire v3 analytics', () => {
|
|
108
|
-
expect(
|
|
118
|
+
expect(mockAttachPayload).toBeCalledWith({
|
|
109
119
|
action: 'inserted',
|
|
110
120
|
actionSubject: 'document',
|
|
111
121
|
actionSubjectId: 'table',
|
|
@@ -218,7 +228,7 @@ describe('Table analytic events', () => {
|
|
|
218
228
|
});
|
|
219
229
|
|
|
220
230
|
it('should fire v3 analytics', () => {
|
|
221
|
-
expect(
|
|
231
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
222
232
|
action: 'cleared',
|
|
223
233
|
actionSubject: 'table',
|
|
224
234
|
actionSubjectId: null,
|
|
@@ -578,7 +588,7 @@ describe('Table analytic events', () => {
|
|
|
578
588
|
});
|
|
579
589
|
|
|
580
590
|
it('should fire v3 analytics', () => {
|
|
581
|
-
expect(
|
|
591
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
582
592
|
action: 'addedRow',
|
|
583
593
|
actionSubject: 'table',
|
|
584
594
|
actionSubjectId: null,
|
|
@@ -608,7 +618,7 @@ describe('Table analytic events', () => {
|
|
|
608
618
|
});
|
|
609
619
|
|
|
610
620
|
it('should fire v3 analytics', () => {
|
|
611
|
-
expect(
|
|
621
|
+
expect(mockAttachPayload).toHaveBeenCalledWith({
|
|
612
622
|
action: 'addedRow',
|
|
613
623
|
actionSubject: 'table',
|
|
614
624
|
actionSubjectId: null,
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from '@atlaskit/editor-tables/utils';
|
|
9
9
|
import { PluginKey } from 'prosemirror-state';
|
|
10
10
|
|
|
11
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
12
11
|
import {
|
|
13
12
|
createProsemirrorEditorFactory,
|
|
14
13
|
LightEditorPlugin,
|
|
@@ -29,10 +28,6 @@ import {
|
|
|
29
28
|
import { pmNodeBuilder } from '@atlaskit/editor-test-helpers/schema-element-builder';
|
|
30
29
|
import defaultSchema from '@atlaskit/editor-test-helpers/schema';
|
|
31
30
|
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
32
|
-
import {
|
|
33
|
-
CreateUIAnalyticsEvent,
|
|
34
|
-
UIAnalyticsEvent,
|
|
35
|
-
} from '@atlaskit/analytics-next';
|
|
36
31
|
import { uuid } from '@atlaskit/adf-schema';
|
|
37
32
|
import { uuid as tablesUuid } from '@atlaskit/editor-tables';
|
|
38
33
|
|
|
@@ -42,8 +37,7 @@ import expandPlugin from '@atlaskit/editor-core/src/plugins/expand';
|
|
|
42
37
|
import tasksDecisionsPlugin from '@atlaskit/editor-core/src/plugins/tasks-and-decisions';
|
|
43
38
|
import selectionPlugin from '@atlaskit/editor-core/src/plugins/selection';
|
|
44
39
|
import mediaPlugin from '@atlaskit/editor-core/src/plugins/media';
|
|
45
|
-
import
|
|
46
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
40
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
47
41
|
import listPlugin from '@atlaskit/editor-core/src/plugins/list';
|
|
48
42
|
import blockTypePlugin from '@atlaskit/editor-core/src/plugins/block-type';
|
|
49
43
|
import codeBlockPlugin from '@atlaskit/editor-core/src/plugins/code-block';
|
|
@@ -67,6 +61,16 @@ import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
|
67
61
|
|
|
68
62
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
69
63
|
|
|
64
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
65
|
+
// We just want to know if the action is called.
|
|
66
|
+
const mockAttachPayload = jest.fn();
|
|
67
|
+
const analyticsPluginFake = () => ({
|
|
68
|
+
name: 'analytics',
|
|
69
|
+
actions: {
|
|
70
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
|
|
70
74
|
describe('table keymap', () => {
|
|
71
75
|
beforeAll(() => {
|
|
72
76
|
uuid.setStatic(TABLE_LOCAL_ID);
|
|
@@ -78,27 +82,16 @@ describe('table keymap', () => {
|
|
|
78
82
|
tablesUuid.setStatic(false);
|
|
79
83
|
});
|
|
80
84
|
|
|
81
|
-
let editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
82
|
-
attachAnalyticsEvent: jest.fn().mockReturnValue(jest.fn()),
|
|
83
|
-
};
|
|
84
|
-
const createAnalyticsEvent: CreateUIAnalyticsEvent = jest.fn(
|
|
85
|
-
() => ({ fire() {} } as UIAnalyticsEvent),
|
|
86
|
-
);
|
|
87
|
-
|
|
88
85
|
const createEditor = createProsemirrorEditorFactory();
|
|
89
86
|
const preset = new Preset<LightEditorPlugin>()
|
|
90
87
|
.add([featureFlagsPlugin, {}])
|
|
91
|
-
.add([analyticsPlugin, {
|
|
92
|
-
.add([deprecatedAnalyticsPlugin, { createAnalyticsEvent }])
|
|
88
|
+
.add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
|
|
93
89
|
.add(contentInsertionPlugin)
|
|
94
90
|
.add(decorationsPlugin)
|
|
95
91
|
.add(widthPlugin)
|
|
96
92
|
.add(gridPlugin)
|
|
97
93
|
.add(selectionPlugin)
|
|
98
|
-
.add([
|
|
99
|
-
tablePlugin,
|
|
100
|
-
{ tableOptions: {}, editorAnalyticsAPI: editorAnalyticsAPIFake },
|
|
101
|
-
])
|
|
94
|
+
.add([tablePlugin, { tableOptions: {} }])
|
|
102
95
|
.add(expandPlugin)
|
|
103
96
|
.add(tasksDecisionsPlugin)
|
|
104
97
|
.add(panelPlugin)
|
|
@@ -604,7 +597,7 @@ describe('table keymap', () => {
|
|
|
604
597
|
});
|
|
605
598
|
|
|
606
599
|
it('should dispatch analytics event', () => {
|
|
607
|
-
expect(
|
|
600
|
+
expect(mockAttachPayload).toBeCalledWith({
|
|
608
601
|
action: 'inserted',
|
|
609
602
|
actionSubject: 'document',
|
|
610
603
|
actionSubjectId: 'table',
|
|
@@ -25,7 +25,6 @@ import { TextSelection, NodeSelection, EditorState } from 'prosemirror-state';
|
|
|
25
25
|
import { EditorView } from 'prosemirror-view';
|
|
26
26
|
import panelPlugin from '@atlaskit/editor-core/src/plugins/panel';
|
|
27
27
|
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
28
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
29
28
|
import {
|
|
30
29
|
akEditorFullPageMaxWidth,
|
|
31
30
|
akEditorDefaultLayoutWidth,
|
|
@@ -35,10 +34,17 @@ import featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
|
35
34
|
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
36
35
|
import { decorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
37
36
|
|
|
37
|
+
// We don't need to test if the analytics implementation works (tested elsewhere)
|
|
38
|
+
// We just want to know if the action is called.
|
|
39
|
+
const mockAttachPayload = jest.fn();
|
|
40
|
+
const analyticsPluginFake = () => ({
|
|
41
|
+
name: 'analytics',
|
|
42
|
+
actions: {
|
|
43
|
+
attachAnalyticsEvent: mockAttachPayload.mockImplementation(() => () => {}),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
38
47
|
describe('table-resizing/event-handlers', () => {
|
|
39
|
-
const editorAnalyticsAPIFake: EditorAnalyticsAPI = {
|
|
40
|
-
attachAnalyticsEvent: jest.fn().mockReturnValue(() => jest.fn()),
|
|
41
|
-
};
|
|
42
48
|
let editor: any;
|
|
43
49
|
beforeEach(() => {
|
|
44
50
|
const createEditor = createProsemirrorEditorFactory();
|
|
@@ -48,7 +54,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
48
54
|
attachTo: document.body,
|
|
49
55
|
preset: new Preset<LightEditorPlugin>()
|
|
50
56
|
.add([featureFlagsPlugin, {}])
|
|
51
|
-
.add([analyticsPlugin, {}])
|
|
57
|
+
.add([analyticsPluginFake as unknown as typeof analyticsPlugin, {}])
|
|
52
58
|
.add(contentInsertionPlugin)
|
|
53
59
|
.add(decorationsPlugin)
|
|
54
60
|
.add(widthPlugin)
|
|
@@ -56,7 +62,6 @@ describe('table-resizing/event-handlers', () => {
|
|
|
56
62
|
tablePlugin,
|
|
57
63
|
{
|
|
58
64
|
tableOptions: { allowColumnResizing: true },
|
|
59
|
-
editorAnalyticsAPI: editorAnalyticsAPIFake,
|
|
60
65
|
},
|
|
61
66
|
])
|
|
62
67
|
.add(panelPlugin),
|
|
@@ -72,7 +77,7 @@ describe('table-resizing/event-handlers', () => {
|
|
|
72
77
|
|
|
73
78
|
resizeColumn(view, 12, 150, 250);
|
|
74
79
|
|
|
75
|
-
expect(
|
|
80
|
+
expect(mockAttachPayload).toHaveBeenCalledWith(
|
|
76
81
|
expect.objectContaining({
|
|
77
82
|
action: TABLE_ACTION.ATTEMPTED_TABLE_WIDTH_CHANGE,
|
|
78
83
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:ebb86471508f57976e27a1c2d32d7ef690f19699443550444ba6fabbb30b1d7c
|
|
3
|
+
size 20020
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
version https://git-lfs.github.com/spec/v1
|
|
2
|
-
oid sha256:
|
|
3
|
-
size
|
|
2
|
+
oid sha256:f24f89698026674f09e57abf0de63a7cba9490251e8238d670653d8ddc6bb077
|
|
3
|
+
size 19266
|
|
@@ -38,11 +38,12 @@ describe('Snapshot Test: Table', () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
describe('sticky header', () => {
|
|
41
|
-
|
|
42
|
-
it.skip('should align with table cell when active', async () => {
|
|
41
|
+
it('should align with table cell when active', async () => {
|
|
43
42
|
await initEditor(page, stickyHeaderWithHorizontalScroll);
|
|
44
43
|
|
|
45
44
|
await clickFirstCell(page, true);
|
|
45
|
+
// Mouse was inside the table and would cause the column resizer to trigger occasionally
|
|
46
|
+
await page.mouse.move(0, 0);
|
|
46
47
|
|
|
47
48
|
// scroll to bottom center to see scroll shadows
|
|
48
49
|
await scrollToElement(page, 'ol > li');
|
|
@@ -32,7 +32,6 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
32
32
|
|
|
33
33
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
34
34
|
|
|
35
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
36
35
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
37
36
|
|
|
38
37
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -80,7 +79,6 @@ interface TablePluginOptions {
|
|
|
80
79
|
// TODO these two need to be rethought
|
|
81
80
|
fullWidthEnabled?: boolean;
|
|
82
81
|
wasFullWidthEnabled?: boolean;
|
|
83
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
84
82
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
85
83
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
86
84
|
}
|
|
@@ -110,6 +108,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
110
108
|
};
|
|
111
109
|
return api?.dependencies.width.sharedState.currentState() ?? defaultState;
|
|
112
110
|
};
|
|
111
|
+
const editorAnalyticsAPI = api?.dependencies.analytics?.actions;
|
|
113
112
|
|
|
114
113
|
return {
|
|
115
114
|
name: 'table',
|
|
@@ -165,13 +164,8 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
165
164
|
wasFullWidthEnabled,
|
|
166
165
|
breakoutEnabled,
|
|
167
166
|
tableOptions,
|
|
168
|
-
editorAnalyticsAPI,
|
|
169
167
|
getEditorFeatureFlags,
|
|
170
|
-
} =
|
|
171
|
-
options ||
|
|
172
|
-
({
|
|
173
|
-
editorAnalyticsAPI: api?.dependencies.analytics?.actions,
|
|
174
|
-
} as TablePluginOptions);
|
|
168
|
+
} = options || ({} as TablePluginOptions);
|
|
175
169
|
return createPlugin(
|
|
176
170
|
dispatchAnalyticsEvent,
|
|
177
171
|
dispatch,
|
|
@@ -191,12 +185,8 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
191
185
|
{
|
|
192
186
|
name: 'tablePMColResizing',
|
|
193
187
|
plugin: ({ dispatch }) => {
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
tableOptions,
|
|
197
|
-
editorAnalyticsAPI,
|
|
198
|
-
getEditorFeatureFlags,
|
|
199
|
-
} = options || ({} as TablePluginOptions);
|
|
188
|
+
const { fullWidthEnabled, tableOptions, getEditorFeatureFlags } =
|
|
189
|
+
options || ({} as TablePluginOptions);
|
|
200
190
|
const { allowColumnResizing } = pluginConfig(tableOptions);
|
|
201
191
|
return allowColumnResizing
|
|
202
192
|
? createFlexiResizingPlugin(
|
|
@@ -217,10 +207,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
217
207
|
{
|
|
218
208
|
name: 'tableKeymap',
|
|
219
209
|
plugin: () =>
|
|
220
|
-
keymapPlugin(
|
|
221
|
-
defaultGetEditorContainerWidth,
|
|
222
|
-
options?.editorAnalyticsAPI,
|
|
223
|
-
),
|
|
210
|
+
keymapPlugin(defaultGetEditorContainerWidth, editorAnalyticsAPI),
|
|
224
211
|
},
|
|
225
212
|
{
|
|
226
213
|
name: 'tableSelectionKeymap',
|
|
@@ -239,7 +226,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
239
226
|
tr: Transaction;
|
|
240
227
|
reason: string;
|
|
241
228
|
}) => {
|
|
242
|
-
|
|
229
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
243
230
|
action: TABLE_ACTION.FIXED,
|
|
244
231
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
245
232
|
actionSubjectId: null,
|
|
@@ -374,7 +361,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
374
361
|
!!resizingPluginState && !!resizingPluginState.dragging
|
|
375
362
|
}
|
|
376
363
|
stickyHeader={stickyHeader}
|
|
377
|
-
editorAnalyticsAPI={
|
|
364
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
378
365
|
/>
|
|
379
366
|
) : null;
|
|
380
367
|
|
|
@@ -415,7 +402,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
415
402
|
scrollableElement={popupsScrollableElement}
|
|
416
403
|
hasStickyHeaders={stickyHeader && stickyHeader.sticky}
|
|
417
404
|
dispatchAnalyticsEvent={dispatchAnalyticsEvent}
|
|
418
|
-
editorAnalyticsAPI={
|
|
405
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
419
406
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
420
407
|
/>
|
|
421
408
|
)}
|
|
@@ -426,7 +413,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
426
413
|
targetCellPosition={targetCellPosition}
|
|
427
414
|
isOpen={Boolean(isContextualMenuOpen)}
|
|
428
415
|
pluginConfig={pluginConfig}
|
|
429
|
-
editorAnalyticsAPI={
|
|
416
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
430
417
|
getEditorContainerWidth={defaultGetEditorContainerWidth}
|
|
431
418
|
getEditorFeatureFlags={
|
|
432
419
|
options?.getEditorFeatureFlags ||
|
|
@@ -445,7 +432,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
445
432
|
isNumberColumnEnabled={
|
|
446
433
|
tableNode && tableNode.attrs.isNumberColumnEnabled
|
|
447
434
|
}
|
|
448
|
-
editorAnalyticsAPI={
|
|
435
|
+
editorAnalyticsAPI={editorAnalyticsAPI}
|
|
449
436
|
/>
|
|
450
437
|
)}
|
|
451
438
|
{LayoutContent}
|
|
@@ -473,7 +460,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
473
460
|
schema: state.schema,
|
|
474
461
|
}),
|
|
475
462
|
);
|
|
476
|
-
|
|
463
|
+
editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
477
464
|
action: ACTION.INSERTED,
|
|
478
465
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
479
466
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -486,7 +473,7 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
486
473
|
],
|
|
487
474
|
floatingToolbar: getToolbarConfig(
|
|
488
475
|
defaultGetEditorContainerWidth,
|
|
489
|
-
|
|
476
|
+
editorAnalyticsAPI,
|
|
490
477
|
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
491
478
|
() => editorViewRef.current,
|
|
492
479
|
)(pluginConfig(options?.tableOptions)),
|
|
@@ -87,10 +87,13 @@ export default class TableView extends ReactNodeView<Props> {
|
|
|
87
87
|
const rendered = DOMSerializer.renderSpec(
|
|
88
88
|
document,
|
|
89
89
|
toDOM(this.node, this.reactComponentProps as Props),
|
|
90
|
-
)
|
|
90
|
+
) as {
|
|
91
|
+
dom: HTMLElement;
|
|
92
|
+
contentDOM?: HTMLElement;
|
|
93
|
+
};
|
|
91
94
|
|
|
92
95
|
if (rendered.dom) {
|
|
93
|
-
this.table = rendered.dom
|
|
96
|
+
this.table = rendered.dom;
|
|
94
97
|
}
|
|
95
98
|
|
|
96
99
|
return rendered;
|
|
@@ -59,7 +59,7 @@ export const createPlugin = () => {
|
|
|
59
59
|
props: {
|
|
60
60
|
decorations: (state) =>
|
|
61
61
|
tableSafariDeleteCompositionTextIssueWorkaroundKey.getState(state)
|
|
62
|
-
|
|
62
|
+
?.decorations,
|
|
63
63
|
handleDOMEvents: {
|
|
64
64
|
beforeinput: (view: EditorView, event: Event): boolean => {
|
|
65
65
|
if ((event as InputEvent)?.inputType !== 'deleteCompositionText') {
|
|
@@ -57,7 +57,7 @@ export function getDefaultLayoutMaxWidth(containerWidth?: number): number {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// Does the current position point at a cell.
|
|
60
|
-
export function pointsAtCell($pos: ResolvedPos
|
|
60
|
+
export function pointsAtCell($pos: ResolvedPos) {
|
|
61
61
|
return (
|
|
62
62
|
($pos.parent.type.spec as NodeSpec & { tableRole: string }).tableRole ===
|
|
63
63
|
'row' && $pos.nodeAfter
|
|
@@ -45,7 +45,6 @@ import {
|
|
|
45
45
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
46
46
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
47
47
|
import {
|
|
48
|
-
ColumnResizingPluginState,
|
|
49
48
|
ToolbarMenuConfig,
|
|
50
49
|
ToolbarMenuState,
|
|
51
50
|
ToolbarMenuContext,
|
|
@@ -440,8 +439,7 @@ export const getToolbarConfig =
|
|
|
440
439
|
(state, intl) => {
|
|
441
440
|
const tableObject = findTable(state.selection);
|
|
442
441
|
const pluginState = getPluginState(state);
|
|
443
|
-
const resizeState
|
|
444
|
-
tableResizingPluginKey.getState(state);
|
|
442
|
+
const resizeState = tableResizingPluginKey.getState(state);
|
|
445
443
|
if (tableObject && pluginState.editorHasFocus) {
|
|
446
444
|
const nodeType = state.schema.nodes.table;
|
|
447
445
|
const menu = getToolbarMenuConfig(
|
|
@@ -31,7 +31,7 @@ import ContextualMenu from './ContextualMenu';
|
|
|
31
31
|
|
|
32
32
|
// offset of the contextual menu dropdown
|
|
33
33
|
const calculateOffset = (targetCellRef: HTMLElement, state: EditorState) => {
|
|
34
|
-
const { tableRef } = pluginKey.getState(state);
|
|
34
|
+
const { tableRef } = pluginKey.getState(state) || {};
|
|
35
35
|
let top = -contextualMenuTriggerSize;
|
|
36
36
|
|
|
37
37
|
if (tableRef && targetCellRef) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { NodeType, NodeRange
|
|
1
|
+
import { NodeType, NodeRange } from 'prosemirror-model';
|
|
2
2
|
import { Transaction, ReadonlyTransaction } from 'prosemirror-state';
|
|
3
3
|
import { findWrapping } from 'prosemirror-transform';
|
|
4
4
|
|
|
5
5
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
|
|
7
|
-
interface IsTableCollapsibleResult
|
|
7
|
+
interface IsTableCollapsibleResult {
|
|
8
8
|
tableIsCollapsible: boolean;
|
|
9
9
|
range?: NodeRange;
|
|
10
10
|
findWrappingRes?:
|
|
11
|
-
| Array<{ type: NodeType
|
|
11
|
+
| Array<{ type: NodeType; attrs?: { [key: string]: any } | null }>
|
|
12
12
|
| null
|
|
13
13
|
| undefined;
|
|
14
14
|
}
|
|
@@ -60,18 +60,18 @@ export const checkIfNumberColumnEnabled = (selection: Selection): boolean =>
|
|
|
60
60
|
);
|
|
61
61
|
|
|
62
62
|
export const isLayoutSupported = (state: EditorState): boolean => {
|
|
63
|
-
const { permittedLayouts } = pluginKey.getState(state)
|
|
63
|
+
const { permittedLayouts } = pluginKey.getState(state)?.pluginConfig || {};
|
|
64
64
|
const { bodiedExtension, layoutSection, expand } = state.schema.nodes;
|
|
65
65
|
|
|
66
66
|
return (
|
|
67
67
|
!hasParentNodeOfType([expand, layoutSection, bodiedExtension])(
|
|
68
68
|
state.selection,
|
|
69
69
|
) &&
|
|
70
|
-
permittedLayouts &&
|
|
70
|
+
!!permittedLayouts &&
|
|
71
71
|
(permittedLayouts === 'all' ||
|
|
72
72
|
(permittedLayouts.indexOf('default') > -1 &&
|
|
73
73
|
permittedLayouts.indexOf('wide') > -1 &&
|
|
74
|
-
permittedLayouts.indexOf('full-
|
|
74
|
+
permittedLayouts.indexOf('full-width') > -1))
|
|
75
75
|
);
|
|
76
76
|
};
|
|
77
77
|
|
|
@@ -7,7 +7,7 @@ import { TableDecorations } from '../types';
|
|
|
7
7
|
import { updateDecorations } from './decoration';
|
|
8
8
|
|
|
9
9
|
export const updatePluginStateDecorations = (
|
|
10
|
-
state: EditorState
|
|
10
|
+
state: EditorState,
|
|
11
11
|
decorations: Decoration[],
|
|
12
12
|
key: TableDecorations,
|
|
13
13
|
): DecorationSet =>
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ import { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
|
8
8
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
9
9
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
10
10
|
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
11
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
12
11
|
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
13
12
|
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
14
13
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
@@ -76,8 +75,6 @@ interface TablePluginOptions {
|
|
|
76
75
|
// (undocumented)
|
|
77
76
|
breakoutEnabled?: boolean;
|
|
78
77
|
// (undocumented)
|
|
79
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
80
|
-
// (undocumented)
|
|
81
78
|
editorSelectionAPI?: EditorSelectionAPI;
|
|
82
79
|
// (undocumented)
|
|
83
80
|
fullWidthEnabled?: boolean;
|