@atlaskit/editor-plugin-table 7.1.4 → 7.2.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/nodeviews/TableComponent.js +0 -3
- package/dist/cjs/nodeviews/table.js +1 -4
- package/dist/cjs/plugin.js +0 -1
- package/dist/cjs/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/cjs/pm-plugins/drag-and-drop/consts.js +2 -3
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +14 -39
- package/dist/cjs/pm-plugins/drag-and-drop/reducer.js +0 -2
- package/dist/cjs/pm-plugins/main.js +3 -0
- package/dist/cjs/ui/DragHandle/index.js +3 -5
- package/dist/cjs/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/cjs/ui/FloatingDragMenu/index.js +0 -2
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/cjs/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/cjs/ui/TableFloatingControls/index.js +4 -7
- package/dist/es2019/nodeviews/TableComponent.js +0 -3
- package/dist/es2019/nodeviews/table.js +1 -5
- package/dist/es2019/plugin.js +0 -1
- package/dist/es2019/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/es2019/pm-plugins/drag-and-drop/consts.js +1 -2
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +15 -39
- package/dist/es2019/pm-plugins/drag-and-drop/reducer.js +0 -5
- package/dist/es2019/pm-plugins/main.js +4 -1
- package/dist/es2019/ui/DragHandle/index.js +3 -4
- package/dist/es2019/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/es2019/ui/FloatingDragMenu/index.js +0 -2
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/es2019/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/es2019/ui/TableFloatingControls/index.js +4 -7
- package/dist/esm/nodeviews/TableComponent.js +0 -3
- package/dist/esm/nodeviews/table.js +1 -4
- package/dist/esm/plugin.js +0 -1
- package/dist/esm/pm-plugins/drag-and-drop/actions.js +1 -2
- package/dist/esm/pm-plugins/drag-and-drop/consts.js +1 -2
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +15 -39
- package/dist/esm/pm-plugins/drag-and-drop/reducer.js +0 -2
- package/dist/esm/pm-plugins/main.js +4 -1
- package/dist/esm/ui/DragHandle/index.js +3 -5
- package/dist/esm/ui/FloatingDragMenu/DragMenu.js +1 -2
- package/dist/esm/ui/FloatingDragMenu/index.js +0 -2
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -3
- package/dist/esm/ui/TableFloatingColumnControls/index.js +0 -2
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +1 -3
- package/dist/esm/ui/TableFloatingControls/index.js +4 -7
- package/dist/types/nodeviews/TableComponent.d.ts +0 -1
- package/dist/types/pm-plugins/drag-and-drop/actions.d.ts +1 -4
- package/dist/types/pm-plugins/drag-and-drop/consts.d.ts +0 -1
- package/dist/types/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types/pm-plugins/drag-and-drop/types.d.ts +0 -1
- package/dist/types/ui/DragHandle/index.d.ts +0 -1
- package/dist/types/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types/ui/FloatingDragMenu/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types/ui/TableFloatingColumnControls/index.d.ts +0 -1
- package/dist/types/ui/TableFloatingControls/RowControls/DragControls.d.ts +0 -1
- package/dist/types/ui/TableFloatingControls/index.d.ts +0 -1
- package/dist/types-ts4.5/nodeviews/TableComponent.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/actions.d.ts +1 -4
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/consts.d.ts +0 -1
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/plugin.d.ts +1 -2
- package/dist/types-ts4.5/pm-plugins/drag-and-drop/types.d.ts +0 -1
- package/dist/types-ts4.5/ui/DragHandle/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/FloatingDragMenu/DragMenu.d.ts +1 -2
- package/dist/types-ts4.5/ui/FloatingDragMenu/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/ColumnControls/index.d.ts +1 -2
- package/dist/types-ts4.5/ui/TableFloatingColumnControls/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/RowControls/DragControls.d.ts +0 -1
- package/dist/types-ts4.5/ui/TableFloatingControls/index.d.ts +0 -1
- package/package.json +5 -5
- package/src/nodeviews/TableComponent.tsx +0 -4
- package/src/nodeviews/table.tsx +0 -3
- package/src/plugin.tsx +0 -1
- package/src/pm-plugins/drag-and-drop/actions.ts +1 -9
- package/src/pm-plugins/drag-and-drop/consts.ts +0 -2
- package/src/pm-plugins/drag-and-drop/plugin.ts +17 -49
- package/src/pm-plugins/drag-and-drop/reducer.ts +0 -5
- package/src/pm-plugins/drag-and-drop/types.ts +0 -1
- package/src/pm-plugins/main.ts +4 -0
- package/src/ui/DragHandle/index.tsx +2 -5
- package/src/ui/FloatingDragMenu/DragMenu.tsx +1 -3
- package/src/ui/FloatingDragMenu/index.tsx +0 -3
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +0 -3
- package/src/ui/TableFloatingColumnControls/index.tsx +0 -3
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -3
- package/src/ui/TableFloatingControls/index.tsx +1 -6
- package/src/__tests__/unit/pm-plugins/drag-and-drop/plugin.ts +0 -112
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import type { DocBuilder } from '@atlaskit/editor-common/types';
|
|
2
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
3
|
-
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
|
-
import { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
|
-
import { featureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
6
|
-
import { guidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
7
|
-
import { selectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
8
|
-
import { widthPlugin } from '@atlaskit/editor-plugin-width';
|
|
9
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
10
|
-
import type { LightEditorPlugin } from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
11
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
12
|
-
import {
|
|
13
|
-
createProsemirrorEditorFactory,
|
|
14
|
-
Preset,
|
|
15
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
16
|
-
// eslint-disable-next-line import/no-extraneous-dependencies -- Removed import for fixing circular dependencies
|
|
17
|
-
import {
|
|
18
|
-
doc,
|
|
19
|
-
p,
|
|
20
|
-
table,
|
|
21
|
-
td,
|
|
22
|
-
tdCursor,
|
|
23
|
-
tdEmpty,
|
|
24
|
-
tr,
|
|
25
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
26
|
-
|
|
27
|
-
import tablePlugin from '../../../../plugin';
|
|
28
|
-
import { DRAGGABLE_TABLE_NODE_SIZE_LIMIT } from '../../../../pm-plugins/drag-and-drop/consts';
|
|
29
|
-
import { getPluginState } from '../../../../pm-plugins/drag-and-drop/plugin-factory';
|
|
30
|
-
import { pluginKey } from '../../../../pm-plugins/plugin-key';
|
|
31
|
-
import type { PluginConfig } from '../../../../types';
|
|
32
|
-
|
|
33
|
-
const tableOptions = {
|
|
34
|
-
allowNumberColumn: true,
|
|
35
|
-
allowHeaderRow: true,
|
|
36
|
-
allowHeaderColumn: true,
|
|
37
|
-
permittedLayouts: 'all',
|
|
38
|
-
allowColumnResizing: true,
|
|
39
|
-
stickyHeaders: true,
|
|
40
|
-
} as PluginConfig;
|
|
41
|
-
|
|
42
|
-
describe('drag and drop plugin', () => {
|
|
43
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
44
|
-
const editor = (doc: DocBuilder) =>
|
|
45
|
-
createEditor({
|
|
46
|
-
doc,
|
|
47
|
-
attachTo: document.body,
|
|
48
|
-
preset: new Preset<LightEditorPlugin>()
|
|
49
|
-
.add([featureFlagsPlugin, {}])
|
|
50
|
-
.add([analyticsPlugin, {}])
|
|
51
|
-
.add(contentInsertionPlugin)
|
|
52
|
-
.add(widthPlugin)
|
|
53
|
-
.add(guidelinePlugin)
|
|
54
|
-
.add(selectionPlugin)
|
|
55
|
-
.add([
|
|
56
|
-
tablePlugin,
|
|
57
|
-
{
|
|
58
|
-
tableOptions,
|
|
59
|
-
dragAndDropEnabled: true,
|
|
60
|
-
},
|
|
61
|
-
]),
|
|
62
|
-
pluginKey,
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('when table is not selected', () => {
|
|
66
|
-
it('should reset table canDrag so by default tables are draggable', () => {
|
|
67
|
-
const { editorView } = editor(
|
|
68
|
-
doc(
|
|
69
|
-
p('{<>}Hello World'),
|
|
70
|
-
table()(tr(tdEmpty, tdEmpty), tr(tdEmpty, tdEmpty)),
|
|
71
|
-
),
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
const { canDrag } = getPluginState(editorView.state);
|
|
75
|
-
expect(canDrag).toBe(true);
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
describe('when table is selected', () => {
|
|
80
|
-
it('should allow items to be draggable if table is within nodeSize limit', () => {
|
|
81
|
-
const { editorView } = editor(
|
|
82
|
-
// The nodeSize of an empty 2x2 is 22 so if i adjust the limit to be 1 under the max (ie. 23), then canDrag should be enabled.
|
|
83
|
-
doc(
|
|
84
|
-
table()(
|
|
85
|
-
tr(tdCursor, tdEmpty),
|
|
86
|
-
tr(
|
|
87
|
-
tdEmpty,
|
|
88
|
-
td()(p('-'.repeat(DRAGGABLE_TABLE_NODE_SIZE_LIMIT - 23))),
|
|
89
|
-
),
|
|
90
|
-
),
|
|
91
|
-
),
|
|
92
|
-
);
|
|
93
|
-
|
|
94
|
-
const { canDrag } = getPluginState(editorView.state);
|
|
95
|
-
expect(canDrag).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it('should not allow items to be draggable if table is above nodeSize limit', () => {
|
|
99
|
-
const { editorView } = editor(
|
|
100
|
-
doc(
|
|
101
|
-
table()(
|
|
102
|
-
tr(tdCursor, tdEmpty),
|
|
103
|
-
tr(tdEmpty, td()(p('-'.repeat(DRAGGABLE_TABLE_NODE_SIZE_LIMIT)))),
|
|
104
|
-
),
|
|
105
|
-
),
|
|
106
|
-
);
|
|
107
|
-
|
|
108
|
-
const { canDrag } = getPluginState(editorView.state);
|
|
109
|
-
expect(canDrag).toBe(false);
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
});
|