@atlaskit/editor-plugin-table 3.0.0 → 3.0.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
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@atlaskit/adf-schema": "^29.1.0",
|
|
31
|
-
"@atlaskit/editor-common": "^
|
|
31
|
+
"@atlaskit/editor-common": "^75.0.0",
|
|
32
32
|
"@atlaskit/editor-palette": "1.5.1",
|
|
33
33
|
"@atlaskit/editor-plugin-analytics": "^0.2.0",
|
|
34
34
|
"@atlaskit/editor-plugin-content-insertion": "^0.1.0",
|
|
@@ -338,4 +338,73 @@ describe('table -> nodeviews -> TableContainer.tsx', () => {
|
|
|
338
338
|
expect(selectionActionMock).toHaveBeenNthCalledWith(2, true);
|
|
339
339
|
});
|
|
340
340
|
});
|
|
341
|
+
|
|
342
|
+
describe('deletion', () => {
|
|
343
|
+
const selectionActionMock = jest.fn().mockReturnValue(() => {});
|
|
344
|
+
const actualGuidelineMock = jest.fn();
|
|
345
|
+
const guidelineActionMock = jest.fn().mockReturnValue(actualGuidelineMock);
|
|
346
|
+
const buildContainer = (attrs: TableAttributes) => {
|
|
347
|
+
const { table, editorView } = createNode(attrs);
|
|
348
|
+
|
|
349
|
+
const { container, unmount } = render(
|
|
350
|
+
<ResizableTableContainer
|
|
351
|
+
containerWidth={1800}
|
|
352
|
+
lineLength={720}
|
|
353
|
+
node={table}
|
|
354
|
+
className={''}
|
|
355
|
+
editorView={editorView}
|
|
356
|
+
getPos={() => 0}
|
|
357
|
+
tableRef={
|
|
358
|
+
{
|
|
359
|
+
querySelector: () => null,
|
|
360
|
+
insertBefore: () => {},
|
|
361
|
+
style: {},
|
|
362
|
+
} as any
|
|
363
|
+
}
|
|
364
|
+
pluginInjectionApi={
|
|
365
|
+
{
|
|
366
|
+
selection: {
|
|
367
|
+
commands: { displayGapCursor: selectionActionMock },
|
|
368
|
+
},
|
|
369
|
+
guideline: {
|
|
370
|
+
actions: { displayGuideline: guidelineActionMock },
|
|
371
|
+
},
|
|
372
|
+
// mock core so the selection command will execute
|
|
373
|
+
core: { actions: { execute: jest.fn() } },
|
|
374
|
+
} as any
|
|
375
|
+
}
|
|
376
|
+
/>,
|
|
377
|
+
);
|
|
378
|
+
|
|
379
|
+
return { container, unmount, selectionActionMock, actualGuidelineMock };
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
afterEach(() => {
|
|
383
|
+
selectionActionMock.mockClear();
|
|
384
|
+
actualGuidelineMock.mockClear();
|
|
385
|
+
guidelineActionMock.mockClear();
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
// this is testing logic inside TableResizer, targeting the clean up in the useEffect
|
|
389
|
+
it('should call selection plugin action to display gapcursor when removed', () => {
|
|
390
|
+
const { container, unmount, selectionActionMock } = buildContainer({});
|
|
391
|
+
|
|
392
|
+
fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
|
|
393
|
+
fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
|
|
394
|
+
|
|
395
|
+
unmount();
|
|
396
|
+
expect(selectionActionMock).toHaveBeenCalledWith(true);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// this is testing logic inside TableResizer, targeting the clean up in the useEffect
|
|
400
|
+
it('should call guideline plugin action to remove guidelines when removed', () => {
|
|
401
|
+
const { container, unmount, actualGuidelineMock } = buildContainer({});
|
|
402
|
+
|
|
403
|
+
fireEvent.mouseDown(container.querySelector('.resizer-handle.right')!);
|
|
404
|
+
fireEvent.mouseMove(container.querySelector('.resizer-handle.right')!);
|
|
405
|
+
|
|
406
|
+
unmount();
|
|
407
|
+
expect(actualGuidelineMock).toHaveBeenCalledWith({ guidelines: [] });
|
|
408
|
+
});
|
|
409
|
+
});
|
|
341
410
|
});
|