@atlaskit/editor-plugin-table 2.9.1 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/plugins/table/event-handlers.js +52 -56
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +19 -69
- package/dist/cjs/plugins/table/nodeviews/TableResizer.js +5 -1
- package/dist/cjs/plugins/table/nodeviews/table.js +23 -30
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +3 -6
- package/dist/cjs/plugins/table/nodeviews/update-overflow-shadows.js +2 -40
- package/dist/cjs/plugins/table/pm-plugins/main.js +3 -3
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +3 -7
- package/dist/cjs/plugins/table/ui/common-styles.js +2 -2
- package/dist/cjs/plugins/table/utils/dom.js +5 -12
- package/dist/es2019/plugins/table/event-handlers.js +3 -6
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +18 -69
- package/dist/es2019/plugins/table/nodeviews/TableResizer.js +6 -1
- package/dist/es2019/plugins/table/nodeviews/table.js +24 -32
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +3 -7
- package/dist/es2019/plugins/table/nodeviews/update-overflow-shadows.js +0 -35
- package/dist/es2019/plugins/table/pm-plugins/main.js +3 -4
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -77
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +3 -9
- package/dist/es2019/plugins/table/ui/common-styles.js +3 -3
- package/dist/es2019/plugins/table/utils/dom.js +5 -12
- package/dist/esm/plugins/table/event-handlers.js +52 -56
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +19 -69
- package/dist/esm/plugins/table/nodeviews/TableResizer.js +5 -1
- package/dist/esm/plugins/table/nodeviews/table.js +23 -30
- package/dist/esm/plugins/table/nodeviews/tableCell.js +3 -6
- package/dist/esm/plugins/table/nodeviews/update-overflow-shadows.js +0 -37
- package/dist/esm/plugins/table/pm-plugins/main.js +3 -3
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +2 -73
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/plugin.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/event-handlers.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/dom.js +1 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +3 -7
- package/dist/esm/plugins/table/ui/common-styles.js +2 -2
- package/dist/esm/plugins/table/utils/dom.js +5 -12
- package/dist/types/plugins/table/event-handlers.d.ts +1 -2
- package/dist/types/plugins/table/nodeviews/TableComponent.d.ts +0 -2
- package/dist/types/plugins/table/nodeviews/table.d.ts +0 -1
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +2 -3
- package/dist/types/plugins/table/nodeviews/types.d.ts +0 -1
- package/dist/types/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
- package/dist/types/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
- package/dist/types/plugins/table/types.d.ts +2 -2
- package/dist/types/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types/plugins/table/utils/dom.d.ts +1 -1
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +0 -2
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +2 -3
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +1 -6
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +1 -2
- package/dist/types-ts4.5/plugins/table/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +1 -1
- package/package.json +2 -2
- package/report.api.md +2 -0
- package/src/__tests__/integration/horizontal-scroll-shadows.ts +6 -9
- package/src/__tests__/integration/resize.ts +6 -16
- package/src/__tests__/unit/event-handlers.ts +1 -4
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +48 -92
- package/src/__tests__/unit/nodeviews/cell.ts +1 -3
- package/src/__tests__/unit/nodeviews/table.ts +71 -83
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +5 -9
- package/src/__tests__/unit/ui/RowControls.tsx +1 -0
- package/src/__tests__/unit/utils/dom.ts +6 -112
- package/src/plugins/table/event-handlers.ts +72 -79
- package/src/plugins/table/nodeviews/TableComponent.tsx +37 -114
- package/src/plugins/table/nodeviews/TableResizer.tsx +3 -0
- package/src/plugins/table/nodeviews/table.tsx +22 -30
- package/src/plugins/table/nodeviews/tableCell.tsx +3 -11
- package/src/plugins/table/nodeviews/types.ts +0 -1
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +0 -54
- package/src/plugins/table/pm-plugins/main.ts +4 -22
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +1 -83
- package/src/plugins/table/pm-plugins/sticky-headers/plugin.ts +1 -7
- package/src/plugins/table/pm-plugins/table-resizing/event-handlers.ts +1 -1
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +30 -48
- package/src/plugins/table/types.ts +3 -2
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +3 -15
- package/src/plugins/table/ui/common-styles.ts +1 -1
- package/src/plugins/table/utils/dom.ts +3 -11
- package/tmp/api-report-tmp.d.ts +2 -0
|
@@ -6,6 +6,7 @@ import { replaceRaf } from 'raf-stub';
|
|
|
6
6
|
import type { EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
|
|
7
7
|
import { Command } from '@atlaskit/editor-common/types';
|
|
8
8
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
|
+
import { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
9
10
|
import { selectTableClosestToPos } from '@atlaskit/editor-tables/src/utils/select-nodes';
|
|
10
11
|
import {
|
|
11
12
|
findTable,
|
|
@@ -73,6 +74,33 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
73
74
|
pluginKey,
|
|
74
75
|
});
|
|
75
76
|
};
|
|
77
|
+
const getTableComponent = (editorView: EditorView, props: any = {}) => {
|
|
78
|
+
const tableF = findTable(editorView.state.selection);
|
|
79
|
+
const getNode = () => tableF!.node;
|
|
80
|
+
return (
|
|
81
|
+
<TableComponent
|
|
82
|
+
view={editorView}
|
|
83
|
+
eventDispatcher={
|
|
84
|
+
{ on: () => {}, off: () => {} } as any as EventDispatcher
|
|
85
|
+
}
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
containerWidth={{}}
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
getNode={getNode}
|
|
90
|
+
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
91
|
+
allowControls
|
|
92
|
+
contentDOM={(wrapper: HTMLElement | null) => {
|
|
93
|
+
const node = editorView.dom.getElementsByTagName('table')[0];
|
|
94
|
+
if (!wrapper?.firstChild) {
|
|
95
|
+
wrapper?.appendChild(node);
|
|
96
|
+
}
|
|
97
|
+
}}
|
|
98
|
+
getPos={jest.fn()}
|
|
99
|
+
{...props}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
76
104
|
afterEach(() => {
|
|
77
105
|
jest.clearAllMocks();
|
|
78
106
|
});
|
|
@@ -81,17 +109,11 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
81
109
|
it('should add table selected css class to the selected table', () => {
|
|
82
110
|
const { editorView } = editor(
|
|
83
111
|
doc(p('text'), table()(tr(tdEmpty, tdEmpty, tdCursor))),
|
|
84
|
-
{
|
|
85
|
-
tableCellOptimization: true,
|
|
86
|
-
tableRenderOptimization: true,
|
|
87
|
-
stickyHeadersOptimization: true,
|
|
88
|
-
initialRenderOptimization: true,
|
|
89
|
-
},
|
|
90
112
|
);
|
|
91
113
|
const { state, dispatch } = editorView;
|
|
92
114
|
dispatch(selectTable(state.tr));
|
|
93
|
-
|
|
94
|
-
const tableContainer =
|
|
115
|
+
const { container } = render(getTableComponent(editorView));
|
|
116
|
+
const tableContainer = container.querySelector(
|
|
95
117
|
`.${ClassName.TABLE_CONTAINER}`,
|
|
96
118
|
);
|
|
97
119
|
expect(
|
|
@@ -135,45 +157,12 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
135
157
|
|
|
136
158
|
render(
|
|
137
159
|
<div>
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
containerWidth={{}}
|
|
145
|
-
// @ts-ignore
|
|
146
|
-
getNode={getTableNode(1)}
|
|
147
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
148
|
-
allowControls
|
|
149
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
150
|
-
const node = editorView.dom.getElementsByTagName('table')[0];
|
|
151
|
-
if (!wrapper?.firstChild) {
|
|
152
|
-
wrapper?.appendChild(node);
|
|
153
|
-
}
|
|
154
|
-
}}
|
|
155
|
-
getPos={jest.fn()}
|
|
156
|
-
/>
|
|
157
|
-
<TableComponent
|
|
158
|
-
view={editorView}
|
|
159
|
-
eventDispatcher={
|
|
160
|
-
{ on: () => {}, off: () => {} } as any as EventDispatcher
|
|
161
|
-
}
|
|
162
|
-
// @ts-ignore
|
|
163
|
-
containerWidth={{}}
|
|
164
|
-
// @ts-ignore
|
|
165
|
-
getNode={getTableNode(2)}
|
|
166
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
167
|
-
allowControls
|
|
168
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
169
|
-
const node = editorView.dom.getElementsByTagName('table')[0];
|
|
170
|
-
if (!wrapper?.firstChild) {
|
|
171
|
-
wrapper?.appendChild(node);
|
|
172
|
-
}
|
|
173
|
-
}}
|
|
174
|
-
getPos={jest.fn()}
|
|
175
|
-
/>
|
|
176
|
-
,
|
|
160
|
+
{getTableComponent(editorView, {
|
|
161
|
+
getNode: getTableNode(1),
|
|
162
|
+
})}
|
|
163
|
+
{getTableComponent(editorView, {
|
|
164
|
+
getNode: getTableNode(2),
|
|
165
|
+
})}
|
|
177
166
|
</div>,
|
|
178
167
|
);
|
|
179
168
|
expect(clearHoverSelectionSpy).not.toBeCalled();
|
|
@@ -189,8 +178,8 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
189
178
|
const { editorView } = editor(
|
|
190
179
|
doc(p('text'), table()(tr(thEmpty, thEmpty, thEmpty))),
|
|
191
180
|
);
|
|
192
|
-
const { state, dispatch } = editorView;
|
|
193
181
|
|
|
182
|
+
const { state, dispatch } = editorView;
|
|
194
183
|
const isInDanger = true;
|
|
195
184
|
hoverTable(isInDanger)(state, dispatch);
|
|
196
185
|
dispatch(selectTable(state.tr));
|
|
@@ -198,29 +187,19 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
198
187
|
const tableF = findTable(state.selection);
|
|
199
188
|
const getNode = () => tableF!.node;
|
|
200
189
|
|
|
190
|
+
const { rerender } = render(
|
|
191
|
+
getTableComponent(editorView, {
|
|
192
|
+
getNode,
|
|
193
|
+
}),
|
|
194
|
+
);
|
|
195
|
+
|
|
201
196
|
const newTr = state.tr.setSelection(TextSelection.create(state.doc, 0));
|
|
202
197
|
dispatch(newTr);
|
|
203
198
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
{ on: () => {}, off: () => {} } as any as EventDispatcher
|
|
209
|
-
}
|
|
210
|
-
// @ts-ignore
|
|
211
|
-
containerWidth={{}}
|
|
212
|
-
// @ts-ignore
|
|
213
|
-
getNode={getNode}
|
|
214
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
215
|
-
allowControls
|
|
216
|
-
contentDOM={(wrapper: HTMLElement | null) => {
|
|
217
|
-
const node = editorView.dom.getElementsByTagName('table')[0];
|
|
218
|
-
if (!wrapper?.firstChild) {
|
|
219
|
-
wrapper?.appendChild(node);
|
|
220
|
-
}
|
|
221
|
-
}}
|
|
222
|
-
getPos={jest.fn()}
|
|
223
|
-
/>,
|
|
199
|
+
rerender(
|
|
200
|
+
getTableComponent(editorView, {
|
|
201
|
+
getNode,
|
|
202
|
+
}),
|
|
224
203
|
);
|
|
225
204
|
expect(clearHoverSelectionSpy).toBeCalledTimes(1);
|
|
226
205
|
});
|
|
@@ -295,30 +274,7 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
295
274
|
const { editorView: view } = editor(
|
|
296
275
|
doc(p('text'), table()(tr(td()(p('{<>}text')), tdEmpty, tdEmpty))),
|
|
297
276
|
);
|
|
298
|
-
|
|
299
|
-
const tableF = findTable(view.state.selection);
|
|
300
|
-
const getNode = () => tableF!.node;
|
|
301
|
-
const { container } = render(
|
|
302
|
-
<TableComponent
|
|
303
|
-
view={view}
|
|
304
|
-
eventDispatcher={
|
|
305
|
-
{ on: jest.fn(), off: jest.fn() } as unknown as EventDispatcher
|
|
306
|
-
}
|
|
307
|
-
// @ts-ignore
|
|
308
|
-
containerWidth={{}}
|
|
309
|
-
getNode={getNode}
|
|
310
|
-
contentDOM={(contentElement: HTMLElement | null) => {
|
|
311
|
-
const node = view.dom.getElementsByTagName('table')[0];
|
|
312
|
-
|
|
313
|
-
if (!contentElement?.firstChild) {
|
|
314
|
-
contentElement?.appendChild(node);
|
|
315
|
-
}
|
|
316
|
-
}}
|
|
317
|
-
getEditorFeatureFlags={getEditorFeatureFlags}
|
|
318
|
-
getPos={jest.fn()}
|
|
319
|
-
{...props}
|
|
320
|
-
/>,
|
|
321
|
-
);
|
|
277
|
+
const { container } = render(getTableComponent(view, props));
|
|
322
278
|
const controlsContainer = container.querySelector(
|
|
323
279
|
`.${ClassName.WITH_CONTROLS}`,
|
|
324
280
|
);
|
|
@@ -111,9 +111,7 @@ describe('table -> nodeviews -> tableCell.tsx', () => {
|
|
|
111
111
|
refs: { pos },
|
|
112
112
|
} = editor(
|
|
113
113
|
doc(p('text'), table()(tr(td()(p('{pos}text')), tdEmpty, tdEmpty))),
|
|
114
|
-
{
|
|
115
|
-
tableCellOptimization: true,
|
|
116
|
-
},
|
|
114
|
+
{},
|
|
117
115
|
);
|
|
118
116
|
const { state, dispatch } = editorView;
|
|
119
117
|
const cell = findCellClosestToPos(state.doc.resolve(pos))!;
|
|
@@ -36,97 +36,85 @@ describe('table -> nodeviews -> table.tsx', () => {
|
|
|
36
36
|
table(attrs)(...args)(defaultSchema);
|
|
37
37
|
|
|
38
38
|
describe('TableView', () => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
]),
|
|
58
|
-
pluginKey,
|
|
59
|
-
});
|
|
39
|
+
const editor = (doc: DocBuilder) =>
|
|
40
|
+
createEditor({
|
|
41
|
+
doc,
|
|
42
|
+
preset: new Preset<LightEditorPlugin>()
|
|
43
|
+
.add([featureFlagsPlugin, {}])
|
|
44
|
+
.add([analyticsPlugin, {}])
|
|
45
|
+
.add(contentInsertionPlugin)
|
|
46
|
+
.add(widthPlugin)
|
|
47
|
+
.add(guidelinePlugin)
|
|
48
|
+
.add([
|
|
49
|
+
tablePlugin,
|
|
50
|
+
{
|
|
51
|
+
tableOptions: {},
|
|
52
|
+
},
|
|
53
|
+
]),
|
|
54
|
+
pluginKey,
|
|
55
|
+
});
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
getEditorContainerWidth: () => ({ width: 500 }),
|
|
86
|
-
getEditorFeatureFlags: () => ({}),
|
|
87
|
-
hasIntlContext: true,
|
|
88
|
-
}).init();
|
|
57
|
+
describe('on view update', () => {
|
|
58
|
+
let tableNode: PMNode,
|
|
59
|
+
tableNodeView: TableView,
|
|
60
|
+
renderSpy: jest.SpyInstance,
|
|
61
|
+
view: EditorView;
|
|
62
|
+
beforeEach(() => {
|
|
63
|
+
tableNode = createTableNode({
|
|
64
|
+
isNumberColumnEnabled: true,
|
|
65
|
+
})(tr(td()(p('{<>}text')), tdEmpty, tdEmpty));
|
|
66
|
+
const { editorView, portalProviderAPI, eventDispatcher } = editor(
|
|
67
|
+
doc(p('text'), table()(tr(tdCursor, tdEmpty), tr(tdEmpty, tdEmpty))),
|
|
68
|
+
);
|
|
69
|
+
view = editorView;
|
|
70
|
+
tableNodeView = new TableView({
|
|
71
|
+
node: tableNode,
|
|
72
|
+
allowColumnResizing: false,
|
|
73
|
+
view: editorView,
|
|
74
|
+
portalProviderAPI,
|
|
75
|
+
eventDispatcher,
|
|
76
|
+
getPos: () => 1,
|
|
77
|
+
getEditorContainerWidth: () => ({ width: 500 }),
|
|
78
|
+
getEditorFeatureFlags: () => ({}),
|
|
79
|
+
hasIntlContext: true,
|
|
80
|
+
}).init();
|
|
89
81
|
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
renderSpy = jest.spyOn(tableNodeView, 'render');
|
|
83
|
+
});
|
|
92
84
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
85
|
+
it('does not rerender if attributes or table width did not change', () => {
|
|
86
|
+
const newNodeWithUnchangedAttributesOrWidth = createTableNode({
|
|
87
|
+
isNumberColumnEnabled: true,
|
|
88
|
+
})(tr(td()(p('{<>}text1')), tdEmpty, tdEmpty));
|
|
89
|
+
tableNodeView.update(newNodeWithUnchangedAttributesOrWidth, []);
|
|
90
|
+
expect(renderSpy).not.toHaveBeenCalled();
|
|
91
|
+
});
|
|
100
92
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
);
|
|
109
|
-
expect(renderSpy).toHaveBeenCalled();
|
|
110
|
-
});
|
|
93
|
+
it('rerenders when table width changes', () => {
|
|
94
|
+
const newNodeWithUnchangedAttributesAndExtraColumn = createTableNode({
|
|
95
|
+
isNumberColumnEnabled: true,
|
|
96
|
+
})(tr(td()(p('{<>}text1')), tdEmpty, tdEmpty, tdEmpty));
|
|
97
|
+
tableNodeView.update(newNodeWithUnchangedAttributesAndExtraColumn, []);
|
|
98
|
+
expect(renderSpy).toHaveBeenCalled();
|
|
99
|
+
});
|
|
111
100
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
101
|
+
it('rerenders when attributes change', () => {
|
|
102
|
+
const newNodeWithChangedAttributes = createTableNode({
|
|
103
|
+
isNumberColumnEnabled: false,
|
|
104
|
+
})(tr(td()(p('{<>}text1')), tdEmpty));
|
|
116
105
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
106
|
+
tableNodeView.update(newNodeWithChangedAttributes, []);
|
|
107
|
+
expect(renderSpy).toHaveBeenCalled();
|
|
108
|
+
});
|
|
120
109
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
it('rerenders when hovered rows change but attributes dont change', () => {
|
|
111
|
+
const newNodeWithUnchangedAttributes = createTableNode({
|
|
112
|
+
isNumberColumnEnabled: true,
|
|
113
|
+
})(tr(td()(p('{<>}text1')), tdEmpty));
|
|
125
114
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
});
|
|
115
|
+
hoverRows([1])(view.state, view.dispatch);
|
|
116
|
+
tableNodeView.update(newNodeWithUnchangedAttributes, []);
|
|
117
|
+
expect(renderSpy).toHaveBeenCalled();
|
|
130
118
|
});
|
|
131
119
|
});
|
|
132
120
|
});
|
|
@@ -55,8 +55,8 @@ describe('TableRowNodeView', () => {
|
|
|
55
55
|
let tableRowNodeView: TableRowNodeView;
|
|
56
56
|
const fakeGetEditorFeatureFlags = jest.fn(() => ({}));
|
|
57
57
|
const createEditor = createProsemirrorEditorFactory();
|
|
58
|
-
const editor = (doc: DocBuilder
|
|
59
|
-
const featureFlags = {
|
|
58
|
+
const editor = (doc: DocBuilder) => {
|
|
59
|
+
const featureFlags = {};
|
|
60
60
|
fakeGetEditorFeatureFlags.mockReturnValue(featureFlags);
|
|
61
61
|
return createEditor({
|
|
62
62
|
doc,
|
|
@@ -114,7 +114,6 @@ describe('TableRowNodeView', () => {
|
|
|
114
114
|
editorView,
|
|
115
115
|
jest.fn(),
|
|
116
116
|
eventDispatcher,
|
|
117
|
-
fakeGetEditorFeatureFlags,
|
|
118
117
|
);
|
|
119
118
|
});
|
|
120
119
|
afterEach(() => {
|
|
@@ -216,7 +215,6 @@ describe('TableRowNodeView', () => {
|
|
|
216
215
|
editorView,
|
|
217
216
|
jest.fn(),
|
|
218
217
|
eventDispatcher,
|
|
219
|
-
fakeGetEditorFeatureFlags,
|
|
220
218
|
);
|
|
221
219
|
tableRowDom = editorView.dom.getElementsByTagName('tr')[0];
|
|
222
220
|
});
|
|
@@ -258,7 +256,7 @@ describe('TableRowNodeView', () => {
|
|
|
258
256
|
});
|
|
259
257
|
});
|
|
260
258
|
|
|
261
|
-
describe('
|
|
259
|
+
describe('sticky headers', () => {
|
|
262
260
|
let rafStub: Stub;
|
|
263
261
|
let originalIntersectionObserver: object;
|
|
264
262
|
let originalResizeObserver: object;
|
|
@@ -323,6 +321,7 @@ describe('TableRowNodeView', () => {
|
|
|
323
321
|
) {
|
|
324
322
|
this.disconnect = jest.fn();
|
|
325
323
|
this.observe = jest.fn();
|
|
324
|
+
this.unobserve = jest.fn();
|
|
326
325
|
intersectCallback = callback;
|
|
327
326
|
};
|
|
328
327
|
|
|
@@ -332,6 +331,7 @@ describe('TableRowNodeView', () => {
|
|
|
332
331
|
) {
|
|
333
332
|
this.disconnect = jest.fn();
|
|
334
333
|
this.observe = jest.fn();
|
|
334
|
+
this.unobserve = jest.fn();
|
|
335
335
|
resizeCallback = callback;
|
|
336
336
|
};
|
|
337
337
|
});
|
|
@@ -349,7 +349,6 @@ describe('TableRowNodeView', () => {
|
|
|
349
349
|
|
|
350
350
|
const editorData = editor(
|
|
351
351
|
doc(table()(tr(thEmpty, thEmpty), tr(tdEmpty, tdEmpty))),
|
|
352
|
-
true, // toggle to enable optimization
|
|
353
352
|
);
|
|
354
353
|
editorView = editorData.editorView;
|
|
355
354
|
eventDispatcher = editorData.eventDispatcher;
|
|
@@ -362,7 +361,6 @@ describe('TableRowNodeView', () => {
|
|
|
362
361
|
editorView,
|
|
363
362
|
jest.fn(),
|
|
364
363
|
eventDispatcher,
|
|
365
|
-
fakeGetEditorFeatureFlags,
|
|
366
364
|
);
|
|
367
365
|
tableRowNodeView.dom = tableRowDom;
|
|
368
366
|
});
|
|
@@ -604,7 +602,6 @@ describe('TableRowNodeView', () => {
|
|
|
604
602
|
beforeEach(() => {
|
|
605
603
|
const editorData = editor(
|
|
606
604
|
doc(table()(tr(thEmpty, thEmpty), tr(tdEmpty, tdEmpty))),
|
|
607
|
-
true, // toggle to enable optimization
|
|
608
605
|
);
|
|
609
606
|
editorView = editorData.editorView;
|
|
610
607
|
eventDispatcher = editorData.eventDispatcher;
|
|
@@ -616,7 +613,6 @@ describe('TableRowNodeView', () => {
|
|
|
616
613
|
editorView,
|
|
617
614
|
jest.fn(),
|
|
618
615
|
eventDispatcher,
|
|
619
|
-
fakeGetEditorFeatureFlags,
|
|
620
616
|
);
|
|
621
617
|
tableRowNodeView.dom = tableRowDom;
|
|
622
618
|
|