@atlaskit/editor-plugin-table 0.0.9 → 0.1.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/.eslintrc.js +35 -0
- package/CHANGELOG.md +29 -0
- package/commands/package.json +14 -0
- package/dist/cjs/plugins/table/commands/hover.js +4 -4
- package/dist/cjs/plugins/table/commands-with-analytics.js +59 -58
- package/dist/cjs/plugins/table/event-handlers.js +0 -1
- package/dist/cjs/plugins/table/index.js +54 -37
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/index.js +9 -1
- package/dist/cjs/plugins/table/toolbar.js +150 -22
- package/dist/cjs/plugins/table/transforms/fix-tables.js +7 -7
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +1 -1
- package/dist/cjs/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/cjs/plugins/table/utils/column-controls.js +0 -1
- package/dist/cjs/plugins/table/utils/decoration.js +53 -4
- package/dist/cjs/plugins/table/utils/dom.js +0 -2
- package/dist/cjs/plugins/table/utils/paste.js +0 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/hover.js +4 -4
- package/dist/es2019/plugins/table/commands-with-analytics.js +6 -9
- package/dist/es2019/plugins/table/event-handlers.js +1 -2
- package/dist/es2019/plugins/table/handlers.js +1 -2
- package/dist/es2019/plugins/table/index.js +23 -5
- package/dist/es2019/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/table/pm-plugins/table-local-id.js +1 -3
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/index.js +2 -1
- package/dist/es2019/plugins/table/toolbar.js +133 -16
- package/dist/es2019/plugins/table/transforms/fix-tables.js +2 -4
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +2 -3
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -2
- package/dist/es2019/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/es2019/plugins/table/utils/column-controls.js +0 -1
- package/dist/es2019/plugins/table/utils/decoration.js +60 -25
- package/dist/es2019/plugins/table/utils/dom.js +0 -2
- package/dist/es2019/plugins/table/utils/paste.js +1 -2
- package/dist/es2019/plugins/table/utils/row-controls.js +1 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/hover.js +4 -4
- package/dist/esm/plugins/table/commands-with-analytics.js +56 -55
- package/dist/esm/plugins/table/event-handlers.js +1 -2
- package/dist/esm/plugins/table/handlers.js +1 -2
- package/dist/esm/plugins/table/index.js +55 -38
- package/dist/esm/plugins/table/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/table-local-id.js +1 -3
- package/dist/esm/plugins/table/pm-plugins/table-resizing/index.js +2 -1
- package/dist/esm/plugins/table/toolbar.js +139 -17
- package/dist/esm/plugins/table/transforms/fix-tables.js +2 -4
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +4 -6
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/DeleteButton.js +2 -3
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -2
- package/dist/esm/plugins/table/ui/LayoutButton/index.js +3 -5
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +2 -1
- package/dist/esm/plugins/table/utils/column-controls.js +0 -1
- package/dist/esm/plugins/table/utils/decoration.js +50 -4
- package/dist/esm/plugins/table/utils/dom.js +0 -2
- package/dist/esm/plugins/table/utils/paste.js +1 -2
- package/dist/esm/plugins/table/utils/row-controls.js +1 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/commands-with-analytics.d.ts +5 -5
- package/dist/types/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
- package/dist/types/plugins/table/toolbar.d.ts +2 -2
- package/dist/types/plugins/table/transforms/fix-tables.d.ts +1 -1
- package/dist/types/plugins/table/utils/decoration.d.ts +1 -1
- package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +5 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +1 -0
- package/dist/types-ts4.0/plugins/table/toolbar.d.ts +2 -2
- package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +1 -1
- package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +1 -1
- package/examples/config.jsonc +14 -0
- package/package.json +15 -11
- package/plugin-key/package.json +14 -0
- package/report.api.md +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/auto-size-documents.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/basic-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/empty-paragraph-underneath-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/even-columns.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/layout-documents.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/merged-rows-and-cols-document.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/nested-in-extension.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/paragraph-and-table-adf.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/resize-documents.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/scale.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-inside-layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-min-width-columns-document.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-multiline-date.adf.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__fixtures__/table-with-text-and-empty-row.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/auto-size.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/change-date-inside-table.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/copy-button.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-columns.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-in-full-width.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-column-with-empty-action.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-last-row-with-empty-action.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-rows.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/delete-table-when-selected.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/deleting-empty-paragraph-under-table.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/even-columns.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-cell-header-with-strong-mark.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/insert-row-inside-layout.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/layout.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/resize.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/__snapshots__/scale.ts.snap +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/arrow-down-into-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/auto-size.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/block-node-selection.ts +1 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/cell-selection.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/change-date-inside-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/copy-button.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-columns.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-in-full-width.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-column-with-empty-action.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-last-row-with-empty-action.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-rows.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/integration/delete-table-when-selected.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/deleting-empty-paragraph-under-table.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/even-columns.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-cell-header-with-strong-mark.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-long-smart-link.ts +1 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/insert-row-inside-layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/layout.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/resize-handler.ts +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/integration/resize.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/integration/scale.ts +0 -0
- package/src/__tests__/integration/table-controls-selection.ts +71 -0
- package/src/__tests__/unit/analytics.ts +8 -9
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/go-to-next-cell.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/insert.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands/misc.ts +12 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/commands.ts +7 -7
- package/src/__tests__/unit/copy-button.ts +22 -0
- package/src/__tests__/unit/event-handlers.ts +120 -1
- package/src/{plugins/table/__tests__ → __tests__}/unit/get-toolbar-config.ts +8 -3
- package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/OverflowShadowsObserver.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/TableComponent.tsx +11 -11
- package/src/{plugins/table/__tests__ → __tests__}/unit/nodeviews/table.ts +5 -5
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-controls.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/column-resizing.ts +9 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/decorations/plugin.ts +5 -5
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main-with-allow-collapse.ts +4 -4
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/main.ts +6 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/sticky-headers/tableRow.tsx +16 -13
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-local-id.ts +3 -6
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/colgroup.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-resizing/event-handlers.ts +3 -3
- package/src/{plugins/table/__tests__ → __tests__}/unit/pm-plugins/table-selection-keymap.ts +3 -3
- package/src/{plugins/table/__tests__ → __tests__}/unit/toolbar.ts +5 -9
- package/src/__tests__/unit/ui/DeleteButton.tsx +35 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +26 -64
- package/src/{plugins/table/__tests__ → __tests__}/unit/utils/collapse.ts +2 -2
- package/src/{plugins/table/__tests__ → __tests__}/unit/utils/column-controls.ts +1 -1
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__fixtures__/table-with-100-numbered-list-items.json +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-should-remove-the-table-column-on-click-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-column-menu-item-visual-hints-should-be-added-to-the-table-column-on-hover-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-should-remove-the-table-row-on-click-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/cell-options-menu-ts-table-cell-options-menu-delete-row-menu-item-visual-hints-should-be-added-to-the-table-row-on-hover-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/copy-button-ts-floating-toolbar-copy-button-table-target-node-displays-blue-border-when-copy-button-is-hovered-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-1-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-2-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/__image_snapshots__/index-ts-snapshot-test-table-numbered-list-should-not-overflow-table-cell-when-there-are-more-than-100-ordered-list-items-3-snap.png +0 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/cell-options-menu.ts +2 -0
- package/src/__tests__/visual-regression/copy-button.ts +181 -0
- package/src/{plugins/table/__tests__ → __tests__}/visual-regression/index.ts +3 -1
- package/src/plugins/table/commands/hover.ts +4 -1
- package/src/plugins/table/commands-with-analytics.ts +12 -8
- package/src/plugins/table/event-handlers.ts +0 -1
- package/src/plugins/table/handlers.ts +0 -1
- package/src/plugins/table/index.tsx +28 -2
- package/src/plugins/table/pm-plugins/keymap.ts +1 -1
- package/src/plugins/table/pm-plugins/table-local-id.ts +0 -2
- package/src/plugins/table/pm-plugins/table-resizing/index.ts +1 -0
- package/src/plugins/table/{toolbar.ts → toolbar.tsx} +186 -14
- package/src/plugins/table/transforms/fix-tables.ts +2 -3
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +13 -10
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -0
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -0
- package/src/plugins/table/ui/FloatingDeleteButton/DeleteButton.tsx +1 -2
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +0 -1
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +0 -1
- package/src/plugins/table/ui/LayoutButton/index.tsx +2 -4
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +1 -0
- package/src/plugins/table/utils/column-controls.ts +0 -1
- package/src/plugins/table/utils/decoration.ts +44 -5
- package/src/plugins/table/utils/dom.ts +0 -2
- package/src/plugins/table/utils/paste.ts +0 -1
- package/src/plugins/table/utils/row-controls.ts +0 -1
- package/types/package.json +5 -5
- package/ui/common-styles/package.json +14 -0
- package/ui/consts/package.json +14 -0
- package/dist/cjs/plugins/plugin-key.js +0 -17
- package/dist/cjs/plugins/table/todo-stubs.js +0 -10
- package/dist/cjs/types.js +0 -5
- package/dist/es2019/plugins/plugin-key.js +0 -3
- package/dist/es2019/plugins/table/todo-stubs.js +0 -1
- package/dist/es2019/types.js +0 -1
- package/dist/esm/plugins/plugin-key.js +0 -5
- package/dist/esm/plugins/table/todo-stubs.js +0 -1
- package/dist/esm/types.js +0 -1
- package/dist/types/plugins/plugin-key.d.ts +0 -4
- package/dist/types/plugins/table/todo-stubs.d.ts +0 -1
- package/dist/types/types.d.ts +0 -3
- package/dist/types-ts4.0/plugins/plugin-key.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/todo-stubs.d.ts +0 -1
- package/dist/types-ts4.0/types.d.ts +0 -3
- package/src/plugins/plugin-key.ts +0 -7
- package/src/plugins/table/__tests__/integration/table-controls-selection.ts +0 -70
- package/src/plugins/table/__tests__/unit/event-handlers.ts +0 -130
- package/src/plugins/table/todo-stubs.ts +0 -1
- package/src/types.ts +0 -3
- package/tmp/api-report-tmp.d.ts +0 -91
|
@@ -12,7 +12,6 @@ import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
|
12
12
|
|
|
13
13
|
import { CellAttributes } from '@atlaskit/adf-schema';
|
|
14
14
|
|
|
15
|
-
// import { nonNullable } from '@atlaskit/editor-core/src/utils';
|
|
16
15
|
import { nonNullable } from '@atlaskit/editor-common/utils';
|
|
17
16
|
import {
|
|
18
17
|
Cell,
|
|
@@ -61,10 +60,49 @@ export const createCellHoverDecoration = (
|
|
|
61
60
|
export const createControlsHoverDecoration = (
|
|
62
61
|
cells: Cell[],
|
|
63
62
|
type: 'row' | 'column' | 'table',
|
|
63
|
+
tr: Transaction | ReadonlyTransaction,
|
|
64
64
|
danger?: boolean,
|
|
65
65
|
selected?: boolean,
|
|
66
|
-
): Decoration[] =>
|
|
67
|
-
|
|
66
|
+
): Decoration[] => {
|
|
67
|
+
const table = findTable(tr.selection);
|
|
68
|
+
if (!table) {
|
|
69
|
+
return [];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const map = TableMap.get(table.node);
|
|
73
|
+
const [min, max] = cells.reduce<[number | null, number | null]>(
|
|
74
|
+
([min, max], cell) => {
|
|
75
|
+
if (min === null || cell.pos < min) {
|
|
76
|
+
min = cell.pos;
|
|
77
|
+
}
|
|
78
|
+
if (max === null || cell.pos > max) {
|
|
79
|
+
max = cell.pos;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return [min, max];
|
|
83
|
+
},
|
|
84
|
+
[null, null],
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
if (min === null || max === null) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let updatedCells: number[] = cells.map((x) => x.pos);
|
|
92
|
+
|
|
93
|
+
// ED-15246 fixed trello card table overflow issue
|
|
94
|
+
// If columns / rows have been merged the hovered selection is different to the actual selection
|
|
95
|
+
// So If the table cells are in danger we want to create a "rectangle" selection
|
|
96
|
+
// to match the "clicked" selection
|
|
97
|
+
|
|
98
|
+
if (danger) {
|
|
99
|
+
const rect = map.rectBetween(min - table.start, max - table.start);
|
|
100
|
+
updatedCells = map.cellsInRect(rect).map((x) => x + table.start);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return updatedCells.map((pos) => {
|
|
104
|
+
const cell = tr.doc.nodeAt(pos);
|
|
105
|
+
|
|
68
106
|
const classes = [ClassName.HOVERED_CELL];
|
|
69
107
|
if (danger) {
|
|
70
108
|
classes.push(ClassName.HOVERED_CELL_IN_DANGER);
|
|
@@ -97,14 +135,15 @@ export const createControlsHoverDecoration = (
|
|
|
97
135
|
}
|
|
98
136
|
|
|
99
137
|
return Decoration.node(
|
|
100
|
-
|
|
101
|
-
|
|
138
|
+
pos,
|
|
139
|
+
pos + cell!.nodeSize,
|
|
102
140
|
{
|
|
103
141
|
class: classes.join(' '),
|
|
104
142
|
},
|
|
105
143
|
{ key },
|
|
106
144
|
);
|
|
107
145
|
});
|
|
146
|
+
};
|
|
108
147
|
|
|
109
148
|
export const createColumnSelectedDecoration = (
|
|
110
149
|
tr: Transaction | ReadonlyTransaction,
|
|
@@ -2,7 +2,6 @@ import { Fragment, Node as PMNode, Schema, Slice } from 'prosemirror-model';
|
|
|
2
2
|
import { EditorState } from 'prosemirror-state';
|
|
3
3
|
import { flatten } from 'prosemirror-utils';
|
|
4
4
|
|
|
5
|
-
// import { flatmap, mapSlice } from '@atlaskit/editor-core/src/utils/slice';
|
|
6
5
|
import { flatmap, mapSlice } from '@atlaskit/editor-common/utils';
|
|
7
6
|
|
|
8
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
isTableSelected,
|
|
11
11
|
} from '@atlaskit/editor-tables/utils';
|
|
12
12
|
|
|
13
|
-
// import { parsePx } from '@atlaskit/editor-core/src/utils/dom';
|
|
14
13
|
import { parsePx } from '@atlaskit/editor-common/utils';
|
|
15
14
|
import { TableCssClassName as ClassName } from '../types';
|
|
16
15
|
import { tableDeleteButtonSize } from '../ui/consts';
|
package/types/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table/types",
|
|
3
|
-
"main": "../dist/cjs/types.js",
|
|
4
|
-
"module": "../dist/esm/types.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/types.js",
|
|
6
|
-
"types": "../dist/types/types.d.ts",
|
|
3
|
+
"main": "../dist/cjs/plugins/table/types.js",
|
|
4
|
+
"module": "../dist/esm/plugins/table/types.js",
|
|
5
|
+
"module:es2019": "../dist/es2019/plugins/table/types.js",
|
|
6
|
+
"types": "../dist/types/plugins/table/types.d.ts",
|
|
7
7
|
"typesVersions": {
|
|
8
8
|
">=4.0 <4.5": {
|
|
9
9
|
"*": [
|
|
10
|
-
"../dist/types-ts4.0/types.d.ts"
|
|
10
|
+
"../dist/types-ts4.0/plugins/table/types.d.ts"
|
|
11
11
|
]
|
|
12
12
|
}
|
|
13
13
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-table/ui/common-styles",
|
|
3
|
+
"main": "../../dist/cjs/plugins/table/ui/common-styles.js",
|
|
4
|
+
"module": "../../dist/esm/plugins/table/ui/common-styles.js",
|
|
5
|
+
"module:es2019": "../../dist/es2019/plugins/table/ui/common-styles.js",
|
|
6
|
+
"types": "../../dist/types/plugins/table/ui/common-styles.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
">=4.0 <4.5": {
|
|
9
|
+
"*": [
|
|
10
|
+
"../../dist/types-ts4.0/plugins/table/ui/common-styles.d.ts"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-table/ui/consts",
|
|
3
|
+
"main": "../../dist/cjs/plugins/table/ui/consts.js",
|
|
4
|
+
"module": "../../dist/esm/plugins/table/ui/consts.js",
|
|
5
|
+
"module:es2019": "../../dist/es2019/plugins/table/ui/consts.js",
|
|
6
|
+
"types": "../../dist/types/plugins/table/ui/consts.d.ts",
|
|
7
|
+
"typesVersions": {
|
|
8
|
+
">=4.0 <4.5": {
|
|
9
|
+
"*": [
|
|
10
|
+
"../../dist/types-ts4.0/plugins/table/ui/consts.d.ts"
|
|
11
|
+
]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pluginKey = exports.getPluginState = void 0;
|
|
7
|
-
|
|
8
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
9
|
-
|
|
10
|
-
var pluginKey = new _prosemirrorState.PluginKey('nextTablePlugin');
|
|
11
|
-
exports.pluginKey = pluginKey;
|
|
12
|
-
|
|
13
|
-
var getPluginState = function getPluginState(state) {
|
|
14
|
-
return state && pluginKey.getState(state);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
exports.getPluginState = getPluginState;
|
package/dist/cjs/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const sendLogs = _a => {};
|
package/dist/es2019/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var sendLogs = function sendLogs(_a) {};
|
package/dist/esm/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { EditorState, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { TablePluginState } from '../types';
|
|
3
|
-
export declare const pluginKey: PluginKey<TablePluginState, any>;
|
|
4
|
-
export declare const getPluginState: (state: EditorState) => TablePluginState | undefined | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const sendLogs: (_a?: any) => void;
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { EditorState, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { TablePluginState } from '../types';
|
|
3
|
-
export declare const pluginKey: PluginKey<TablePluginState, any>;
|
|
4
|
-
export declare const getPluginState: (state: EditorState) => TablePluginState | undefined | null;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const sendLogs: (_a?: any) => void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EditorState, PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { TablePluginState } from '../types';
|
|
3
|
-
|
|
4
|
-
export const pluginKey = new PluginKey<TablePluginState>('nextTablePlugin');
|
|
5
|
-
export const getPluginState = (
|
|
6
|
-
state: EditorState,
|
|
7
|
-
): TablePluginState | undefined | null => state && pluginKey.getState(state);
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
//TODO: [ED-15027] remove and relocate this test once the behaviour has been corrected.\
|
|
2
|
-
import { BrowserTestCase } from '@atlaskit/webdriver-runner/runner';
|
|
3
|
-
import { BrowserObject } from '@atlaskit/webdriver-runner/wd-wrapper';
|
|
4
|
-
import {
|
|
5
|
-
goToEditorTestingWDExample,
|
|
6
|
-
mountEditor,
|
|
7
|
-
} from '@atlaskit/editor-test-helpers/testing-example-page';
|
|
8
|
-
import {
|
|
9
|
-
fullpage,
|
|
10
|
-
expectToMatchSelection,
|
|
11
|
-
setProseMirrorTextSelection,
|
|
12
|
-
} from '@atlaskit/editor-test-helpers/integration/helpers';
|
|
13
|
-
import type { WebDriverPage } from '@atlaskit/editor-test-helpers/integration/types';
|
|
14
|
-
import adf from './__fixtures__/table-with-multiline-date.adf.json';
|
|
15
|
-
|
|
16
|
-
describe('table with multiline date', () => {
|
|
17
|
-
const initEditor = async ({
|
|
18
|
-
client,
|
|
19
|
-
selection,
|
|
20
|
-
adf,
|
|
21
|
-
}: {
|
|
22
|
-
client: BrowserObject;
|
|
23
|
-
selection: { anchor: number; head: number };
|
|
24
|
-
adf: string;
|
|
25
|
-
}): Promise<WebDriverPage> => {
|
|
26
|
-
const page = await goToEditorTestingWDExample(
|
|
27
|
-
client,
|
|
28
|
-
'editor-plugin-table',
|
|
29
|
-
);
|
|
30
|
-
const props = {
|
|
31
|
-
appearance: fullpage.appearance,
|
|
32
|
-
defaultValue: adf,
|
|
33
|
-
allowTextAlignment: true,
|
|
34
|
-
allowTables: {
|
|
35
|
-
advanced: true,
|
|
36
|
-
allowColumnResizing: true,
|
|
37
|
-
},
|
|
38
|
-
allowDate: true,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
await mountEditor(page, props, undefined, { clickInEditor: false });
|
|
42
|
-
|
|
43
|
-
await page.waitForSelector('.inlineNodeView');
|
|
44
|
-
|
|
45
|
-
await setProseMirrorTextSelection(page, selection);
|
|
46
|
-
|
|
47
|
-
return page;
|
|
48
|
-
};
|
|
49
|
-
BrowserTestCase(
|
|
50
|
-
'Does not select table corner controls when navigating up from a multiline node inside a table',
|
|
51
|
-
{
|
|
52
|
-
skip: ['firefox', 'safari'],
|
|
53
|
-
},
|
|
54
|
-
async (client: BrowserObject) => {
|
|
55
|
-
const page = await initEditor({
|
|
56
|
-
client,
|
|
57
|
-
selection: { anchor: 27, head: 27 },
|
|
58
|
-
adf,
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
await page.keys('ArrowUp');
|
|
62
|
-
|
|
63
|
-
await expectToMatchSelection(page, {
|
|
64
|
-
type: 'text',
|
|
65
|
-
anchor: 27,
|
|
66
|
-
head: 27,
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
);
|
|
70
|
-
});
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createProsemirrorEditorFactory,
|
|
3
|
-
LightEditorPlugin,
|
|
4
|
-
Preset,
|
|
5
|
-
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
6
|
-
import {
|
|
7
|
-
doc,
|
|
8
|
-
p,
|
|
9
|
-
table,
|
|
10
|
-
td,
|
|
11
|
-
tdCursor,
|
|
12
|
-
tdEmpty,
|
|
13
|
-
tr,
|
|
14
|
-
DocBuilder,
|
|
15
|
-
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
16
|
-
|
|
17
|
-
import tablePlugin from '../../../table';
|
|
18
|
-
import { handleMouseOut, handleMouseDown } from '../../event-handlers';
|
|
19
|
-
import { pluginKey } from '../../pm-plugins/plugin-key';
|
|
20
|
-
import { TableCssClassName as ClassName } from '../../types';
|
|
21
|
-
|
|
22
|
-
describe('table plugin: decorations', () => {
|
|
23
|
-
const createEditor = createProsemirrorEditorFactory();
|
|
24
|
-
const editor = (doc: DocBuilder) =>
|
|
25
|
-
createEditor({
|
|
26
|
-
doc,
|
|
27
|
-
preset: new Preset<LightEditorPlugin>().add(tablePlugin),
|
|
28
|
-
pluginKey,
|
|
29
|
-
});
|
|
30
|
-
describe('#handleMouseDown', () => {
|
|
31
|
-
beforeEach(() => {
|
|
32
|
-
jest.resetAllMocks();
|
|
33
|
-
});
|
|
34
|
-
it('should return true & prevent default behaviour for table wrappers: pm-table-contianer', () => {
|
|
35
|
-
const { editorView } = editor(
|
|
36
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
37
|
-
);
|
|
38
|
-
const tableContainer = document.createElement('div');
|
|
39
|
-
tableContainer.className = 'pm-table-container';
|
|
40
|
-
const event = new MouseEvent('mousedown');
|
|
41
|
-
Object.defineProperty(event, 'target', { value: tableContainer });
|
|
42
|
-
const preventDefaultSpy = jest.spyOn(
|
|
43
|
-
MouseEvent.prototype,
|
|
44
|
-
'preventDefault',
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
expect(handleMouseDown(editorView, event)).toEqual(true);
|
|
48
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should return true & prevent default behaviour for table wrappers: pm-table-wrapper', () => {
|
|
52
|
-
const { editorView } = editor(
|
|
53
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
54
|
-
);
|
|
55
|
-
const tableContainer = document.createElement('div');
|
|
56
|
-
tableContainer.className = 'pm-table-wrapper';
|
|
57
|
-
const event = new MouseEvent('mousedown');
|
|
58
|
-
Object.defineProperty(event, 'target', { value: tableContainer });
|
|
59
|
-
const preventDefaultSpy = jest.spyOn(
|
|
60
|
-
MouseEvent.prototype,
|
|
61
|
-
'preventDefault',
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
expect(handleMouseDown(editorView, event)).toEqual(true);
|
|
65
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(1);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('should return false & not prevent default behaviour for editor content area: ak-editor-content-area', () => {
|
|
69
|
-
const { editorView } = editor(
|
|
70
|
-
doc(table()(tr(td({})(p())), tr(td({})(p())), tr(td({})(p())))),
|
|
71
|
-
);
|
|
72
|
-
const editorContentArea = document.createElement('div');
|
|
73
|
-
editorContentArea.className = 'ak-editor-content-area';
|
|
74
|
-
const event = new MouseEvent('mousedown');
|
|
75
|
-
Object.defineProperty(event, 'target', { value: editorContentArea });
|
|
76
|
-
const preventDefaultSpy = jest.spyOn(
|
|
77
|
-
MouseEvent.prototype,
|
|
78
|
-
'preventDefault',
|
|
79
|
-
);
|
|
80
|
-
|
|
81
|
-
expect(handleMouseDown(editorView, event)).toEqual(false);
|
|
82
|
-
expect(preventDefaultSpy).toHaveBeenCalledTimes(0);
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
describe('#handleMouseOut', () => {
|
|
86
|
-
describe('when the target is a resize handle column', () => {
|
|
87
|
-
it('should return true', () => {
|
|
88
|
-
const { editorView } = editor(
|
|
89
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(td()(p('{o}')), tdEmpty))),
|
|
90
|
-
);
|
|
91
|
-
const firstCell = document.createElement('div');
|
|
92
|
-
firstCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
93
|
-
|
|
94
|
-
// event.target = secondCell.node;
|
|
95
|
-
const spy = jest
|
|
96
|
-
.spyOn(MouseEvent.prototype, 'target', 'get')
|
|
97
|
-
.mockReturnValue(firstCell);
|
|
98
|
-
|
|
99
|
-
const event = new MouseEvent('opa');
|
|
100
|
-
|
|
101
|
-
expect(handleMouseOut(editorView, event)).toEqual(true);
|
|
102
|
-
spy.mockRestore();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('when the relatedTarget is a resize handle column too', () => {
|
|
107
|
-
it('should return false', () => {
|
|
108
|
-
const { editorView } = editor(
|
|
109
|
-
doc(table()(tr(tdCursor, tdEmpty), tr(td()(p('{o}')), tdEmpty))),
|
|
110
|
-
);
|
|
111
|
-
const firstCell = document.createElement('div');
|
|
112
|
-
firstCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
113
|
-
const secondCell = document.createElement('div');
|
|
114
|
-
secondCell.classList.add(ClassName.RESIZE_HANDLE_DECORATION);
|
|
115
|
-
|
|
116
|
-
// event.target = secondCell.node;
|
|
117
|
-
const spy = jest
|
|
118
|
-
.spyOn(MouseEvent.prototype, 'target', 'get')
|
|
119
|
-
.mockReturnValue(secondCell);
|
|
120
|
-
|
|
121
|
-
const event = new MouseEvent('opa', {
|
|
122
|
-
relatedTarget: firstCell,
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
expect(handleMouseOut(editorView, event)).toEqual(false);
|
|
126
|
-
spy.mockRestore();
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const sendLogs = (_a?: any) => {};
|
package/src/types.ts
DELETED
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
## API Report File for "@atlaskit/editor-plugin-table"
|
|
2
|
-
|
|
3
|
-
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
-
|
|
5
|
-
```ts
|
|
6
|
-
|
|
7
|
-
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import type { EditorPlugin } from '@atlaskit/editor-common/types';
|
|
9
|
-
import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
10
|
-
import type { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
|
|
11
|
-
import { TableLayout } from '@atlaskit/adf-schema';
|
|
12
|
-
|
|
13
|
-
// @public (undocumented)
|
|
14
|
-
type PermittedLayoutsDescriptor = 'all' | TableLayout[];
|
|
15
|
-
|
|
16
|
-
// @public (undocumented)
|
|
17
|
-
interface PluginConfig {
|
|
18
|
-
// (undocumented)
|
|
19
|
-
advanced?: boolean;
|
|
20
|
-
// (undocumented)
|
|
21
|
-
allowAddColumnWithCustomStep?: boolean;
|
|
22
|
-
// (undocumented)
|
|
23
|
-
allowBackgroundColor?: boolean;
|
|
24
|
-
// (undocumented)
|
|
25
|
-
allowCellOptionsInFloatingToolbar?: boolean;
|
|
26
|
-
// (undocumented)
|
|
27
|
-
allowCollapse?: boolean;
|
|
28
|
-
// (undocumented)
|
|
29
|
-
allowColumnResizing?: boolean;
|
|
30
|
-
// (undocumented)
|
|
31
|
-
allowColumnSorting?: boolean;
|
|
32
|
-
// (undocumented)
|
|
33
|
-
allowControls?: boolean;
|
|
34
|
-
// (undocumented)
|
|
35
|
-
allowDistributeColumns?: boolean;
|
|
36
|
-
// (undocumented)
|
|
37
|
-
allowHeaderColumn?: boolean;
|
|
38
|
-
// (undocumented)
|
|
39
|
-
allowHeaderRow?: boolean;
|
|
40
|
-
// (undocumented)
|
|
41
|
-
allowMergeCells?: boolean;
|
|
42
|
-
// (undocumented)
|
|
43
|
-
allowNumberColumn?: boolean;
|
|
44
|
-
// (undocumented)
|
|
45
|
-
initialRenderOptimization?: boolean;
|
|
46
|
-
// (undocumented)
|
|
47
|
-
isHeaderRowRequired?: boolean;
|
|
48
|
-
// (undocumented)
|
|
49
|
-
mouseMoveOptimization?: boolean;
|
|
50
|
-
// (undocumented)
|
|
51
|
-
permittedLayouts?: PermittedLayoutsDescriptor;
|
|
52
|
-
// (undocumented)
|
|
53
|
-
stickToolbarToBottom?: boolean;
|
|
54
|
-
// (undocumented)
|
|
55
|
-
stickyHeaders?: boolean;
|
|
56
|
-
// (undocumented)
|
|
57
|
-
stickyHeadersOptimization?: boolean;
|
|
58
|
-
// (undocumented)
|
|
59
|
-
tableCellOptimization?: boolean;
|
|
60
|
-
// (undocumented)
|
|
61
|
-
tableOverflowShadowsOptimization?: boolean;
|
|
62
|
-
// (undocumented)
|
|
63
|
-
tableRenderOptimization?: boolean;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// @public (undocumented)
|
|
67
|
-
interface TablePluginOptions {
|
|
68
|
-
// (undocumented)
|
|
69
|
-
allowContextualMenu?: boolean;
|
|
70
|
-
// (undocumented)
|
|
71
|
-
breakoutEnabled?: boolean;
|
|
72
|
-
// (undocumented)
|
|
73
|
-
editorAnalyticsAPI?: EditorAnalyticsAPI;
|
|
74
|
-
// (undocumented)
|
|
75
|
-
editorSelectionAPI?: EditorSelectionAPI;
|
|
76
|
-
// (undocumented)
|
|
77
|
-
fullWidthEnabled?: boolean;
|
|
78
|
-
// (undocumented)
|
|
79
|
-
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
80
|
-
// (undocumented)
|
|
81
|
-
tableOptions: PluginConfig;
|
|
82
|
-
// (undocumented)
|
|
83
|
-
wasFullWidthEnabled?: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// @public (undocumented)
|
|
87
|
-
export const tablesPlugin: (options?: TablePluginOptions | undefined) => EditorPlugin;
|
|
88
|
-
|
|
89
|
-
// (No @packageDocumentation comment for this package)
|
|
90
|
-
|
|
91
|
-
```
|