@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
|
@@ -46,13 +46,13 @@ export var hoverMergedCells = function hoverMergedCells() {
|
|
|
46
46
|
};
|
|
47
47
|
export var hoverColumns = function hoverColumns(hoveredColumns, isInDanger) {
|
|
48
48
|
return createCommand(function (state) {
|
|
49
|
-
var cells = getCellsInColumn(hoveredColumns)(state.selection);
|
|
49
|
+
var cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
50
50
|
|
|
51
51
|
if (!cells) {
|
|
52
52
|
return false;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
var decorations = createControlsHoverDecoration(cells, 'column', isInDanger);
|
|
55
|
+
var decorations = createControlsHoverDecoration(cells, 'column', state.tr, isInDanger);
|
|
56
56
|
return {
|
|
57
57
|
type: 'HOVER_COLUMNS',
|
|
58
58
|
data: {
|
|
@@ -73,7 +73,7 @@ export var hoverRows = function hoverRows(hoveredRows, isInDanger) {
|
|
|
73
73
|
return false;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
var decorations = createControlsHoverDecoration(cells, 'row', isInDanger);
|
|
76
|
+
var decorations = createControlsHoverDecoration(cells, 'row', state.tr, isInDanger);
|
|
77
77
|
return {
|
|
78
78
|
type: 'HOVER_ROWS',
|
|
79
79
|
data: {
|
|
@@ -103,7 +103,7 @@ export var hoverTable = function hoverTable(isInDanger, isSelected) {
|
|
|
103
103
|
return false;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
var decorations = createControlsHoverDecoration(cells, 'table', isInDanger, isSelected);
|
|
106
|
+
var decorations = createControlsHoverDecoration(cells, 'table', state.tr, isInDanger, isSelected);
|
|
107
107
|
return {
|
|
108
108
|
type: 'HOVER_TABLE',
|
|
109
109
|
data: {
|
|
@@ -55,75 +55,77 @@ export var emptyMultipleCellsWithAnalytics = function emptyMultipleCellsWithAnal
|
|
|
55
55
|
};
|
|
56
56
|
};
|
|
57
57
|
export var mergeCellsWithAnalytics = function mergeCellsWithAnalytics(editorAnalyticsAPI) {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
|
|
62
|
-
horizontalCells = _getSelectedCellInfo2.horizontalCells,
|
|
63
|
-
verticalCells = _getSelectedCellInfo2.verticalCells,
|
|
64
|
-
totalCells = _getSelectedCellInfo2.totalCells,
|
|
65
|
-
totalRowCount = _getSelectedCellInfo2.totalRowCount,
|
|
66
|
-
totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
|
|
67
|
-
|
|
68
|
-
return {
|
|
69
|
-
action: TABLE_ACTION.MERGED,
|
|
70
|
-
actionSubject: ACTION_SUBJECT.TABLE,
|
|
71
|
-
actionSubjectId: null,
|
|
72
|
-
attributes: {
|
|
73
|
-
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
74
|
-
// TODO: merge with floating toolbar once command is updated
|
|
75
|
-
horizontalCells: horizontalCells,
|
|
76
|
-
verticalCells: verticalCells,
|
|
77
|
-
totalCells: totalCells,
|
|
78
|
-
totalRowCount: totalRowCount,
|
|
79
|
-
totalColumnCount: totalColumnCount
|
|
80
|
-
},
|
|
81
|
-
eventType: EVENT_TYPE.TRACK
|
|
82
|
-
};
|
|
83
|
-
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
84
|
-
if (dispatch) {
|
|
85
|
-
dispatch(mergeCells(state.tr));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return true;
|
|
89
|
-
});
|
|
90
|
-
};
|
|
91
|
-
export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
|
|
92
|
-
return withEditorAnalyticsAPI(function (_ref3) {
|
|
93
|
-
var selection = _ref3.selection;
|
|
94
|
-
|
|
95
|
-
var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
|
|
96
|
-
totalRowCount = _getSelectedCellInfo3.totalRowCount,
|
|
97
|
-
totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
|
|
58
|
+
return function (inputMethod) {
|
|
59
|
+
return withEditorAnalyticsAPI(function (_ref2) {
|
|
60
|
+
var selection = _ref2.selection;
|
|
98
61
|
|
|
99
|
-
|
|
62
|
+
var _getSelectedCellInfo2 = getSelectedCellInfo(selection),
|
|
63
|
+
horizontalCells = _getSelectedCellInfo2.horizontalCells,
|
|
64
|
+
verticalCells = _getSelectedCellInfo2.verticalCells,
|
|
65
|
+
totalCells = _getSelectedCellInfo2.totalCells,
|
|
66
|
+
totalRowCount = _getSelectedCellInfo2.totalRowCount,
|
|
67
|
+
totalColumnCount = _getSelectedCellInfo2.totalColumnCount;
|
|
100
68
|
|
|
101
|
-
if (cell) {
|
|
102
|
-
var _cell$node$attrs = cell.node.attrs,
|
|
103
|
-
verticalCells = _cell$node$attrs.rowspan,
|
|
104
|
-
horizontalCells = _cell$node$attrs.colspan;
|
|
105
69
|
return {
|
|
106
|
-
action: TABLE_ACTION.
|
|
70
|
+
action: TABLE_ACTION.MERGED,
|
|
107
71
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
108
72
|
actionSubjectId: null,
|
|
109
73
|
attributes: {
|
|
110
|
-
inputMethod:
|
|
111
|
-
// TODO: merge with floating toolbar once command is updated
|
|
74
|
+
inputMethod: inputMethod,
|
|
112
75
|
horizontalCells: horizontalCells,
|
|
113
76
|
verticalCells: verticalCells,
|
|
114
|
-
totalCells:
|
|
77
|
+
totalCells: totalCells,
|
|
115
78
|
totalRowCount: totalRowCount,
|
|
116
79
|
totalColumnCount: totalColumnCount
|
|
117
80
|
},
|
|
118
81
|
eventType: EVENT_TYPE.TRACK
|
|
119
82
|
};
|
|
120
|
-
}
|
|
83
|
+
})(editorAnalyticsAPI)(function (state, dispatch) {
|
|
84
|
+
if (dispatch) {
|
|
85
|
+
dispatch(mergeCells(state.tr));
|
|
86
|
+
}
|
|
121
87
|
|
|
122
|
-
|
|
123
|
-
|
|
88
|
+
return true;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
export var splitCellWithAnalytics = function splitCellWithAnalytics(editorAnalyticsAPI) {
|
|
93
|
+
return function (inputMethod) {
|
|
94
|
+
return withEditorAnalyticsAPI(function (_ref3) {
|
|
95
|
+
var selection = _ref3.selection;
|
|
96
|
+
|
|
97
|
+
var _getSelectedCellInfo3 = getSelectedCellInfo(selection),
|
|
98
|
+
totalRowCount = _getSelectedCellInfo3.totalRowCount,
|
|
99
|
+
totalColumnCount = _getSelectedCellInfo3.totalColumnCount;
|
|
100
|
+
|
|
101
|
+
var cell = findCellClosestToPos(selection.$anchor);
|
|
102
|
+
|
|
103
|
+
if (cell) {
|
|
104
|
+
var _cell$node$attrs = cell.node.attrs,
|
|
105
|
+
verticalCells = _cell$node$attrs.rowspan,
|
|
106
|
+
horizontalCells = _cell$node$attrs.colspan;
|
|
107
|
+
return {
|
|
108
|
+
action: TABLE_ACTION.SPLIT,
|
|
109
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
110
|
+
actionSubjectId: null,
|
|
111
|
+
attributes: {
|
|
112
|
+
inputMethod: inputMethod,
|
|
113
|
+
horizontalCells: horizontalCells,
|
|
114
|
+
verticalCells: verticalCells,
|
|
115
|
+
totalCells: horizontalCells * verticalCells,
|
|
116
|
+
totalRowCount: totalRowCount,
|
|
117
|
+
totalColumnCount: totalColumnCount
|
|
118
|
+
},
|
|
119
|
+
eventType: EVENT_TYPE.TRACK
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return;
|
|
124
|
+
})(editorAnalyticsAPI)(splitCell);
|
|
125
|
+
};
|
|
124
126
|
};
|
|
125
127
|
export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalyticsAPI) {
|
|
126
|
-
return function (cellColor, targetCellPosition) {
|
|
128
|
+
return function (inputMethod, cellColor, targetCellPosition) {
|
|
127
129
|
return withEditorAnalyticsAPI(function (_ref4) {
|
|
128
130
|
var selection = _ref4.selection;
|
|
129
131
|
|
|
@@ -139,8 +141,7 @@ export var setColorWithAnalytics = function setColorWithAnalytics(editorAnalytic
|
|
|
139
141
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
140
142
|
actionSubjectId: null,
|
|
141
143
|
attributes: {
|
|
142
|
-
inputMethod:
|
|
143
|
-
// TODO: merge with floating toolbar once command is updated
|
|
144
|
+
inputMethod: inputMethod,
|
|
144
145
|
cellColor: (tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor).toLowerCase(),
|
|
145
146
|
horizontalCells: horizontalCells,
|
|
146
147
|
verticalCells: verticalCells,
|
|
@@ -4,8 +4,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
4
4
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
5
5
|
import { cellAround, findCellRectClosestToPos, findTable, getSelectionRect, removeTable } from '@atlaskit/editor-tables/utils';
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
|
-
import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
8
|
-
|
|
7
|
+
import { isElementInTableCell, isLastItemMediaGroup, setNodeSelection } from '@atlaskit/editor-common/utils';
|
|
9
8
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
10
9
|
import { ACTION_SUBJECT, EVENT_TYPE, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { addResizeHandleDecorations, clearHoverSelection, hideInsertColumnOrRowButton, hideResizeHandleLine, hoverColumns, selectColumn, setEditorFocus, showInsertColumnButton, showInsertRowButton, showResizeHandleLine } from './commands';
|
|
@@ -6,8 +6,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
6
6
|
|
|
7
7
|
// #region Imports
|
|
8
8
|
import { findParentNodeOfType } from 'prosemirror-utils';
|
|
9
|
-
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
10
|
-
|
|
9
|
+
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
11
10
|
import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
12
11
|
import { isTableCollapsible } from './utils/collapse';
|
|
13
12
|
import { defaultTableSelection } from './pm-plugins/default-table-selection';
|
|
@@ -6,7 +6,7 @@ import { createTable } from '@atlaskit/editor-tables/utils';
|
|
|
6
6
|
import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
7
7
|
import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
8
8
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
9
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
9
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD, TABLE_ACTION } from '@atlaskit/editor-common/analytics';
|
|
10
10
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
11
|
import { IconTable } from '@atlaskit/editor-common/icons';
|
|
12
12
|
import { pluginConfig } from './create-plugin-config';
|
|
@@ -128,21 +128,38 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
128
128
|
}, {
|
|
129
129
|
name: 'tableEditing',
|
|
130
130
|
plugin: function plugin() {
|
|
131
|
-
return tableEditing(
|
|
131
|
+
return tableEditing({
|
|
132
|
+
reportFixedTable: function reportFixedTable(_ref5) {
|
|
133
|
+
var _options$editorAnalyt;
|
|
134
|
+
|
|
135
|
+
var state = _ref5.state,
|
|
136
|
+
tr = _ref5.tr,
|
|
137
|
+
reason = _ref5.reason;
|
|
138
|
+
options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
|
|
139
|
+
action: TABLE_ACTION.FIXED,
|
|
140
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
141
|
+
actionSubjectId: null,
|
|
142
|
+
attributes: {
|
|
143
|
+
reason: reason
|
|
144
|
+
},
|
|
145
|
+
eventType: EVENT_TYPE.TRACK
|
|
146
|
+
})(tr);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
132
149
|
}
|
|
133
150
|
}, {
|
|
134
151
|
name: 'tableStickyHeaders',
|
|
135
|
-
plugin: function plugin(
|
|
136
|
-
var dispatch =
|
|
137
|
-
eventDispatcher =
|
|
152
|
+
plugin: function plugin(_ref6) {
|
|
153
|
+
var dispatch = _ref6.dispatch,
|
|
154
|
+
eventDispatcher = _ref6.eventDispatcher;
|
|
138
155
|
return options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, function () {
|
|
139
156
|
return [];
|
|
140
157
|
}, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined;
|
|
141
158
|
}
|
|
142
159
|
}, {
|
|
143
160
|
name: 'tableLocalId',
|
|
144
|
-
plugin: function plugin(
|
|
145
|
-
var dispatch =
|
|
161
|
+
plugin: function plugin(_ref7) {
|
|
162
|
+
var dispatch = _ref7.dispatch;
|
|
146
163
|
return createTableLocalIdPlugin(dispatch);
|
|
147
164
|
}
|
|
148
165
|
}, {
|
|
@@ -187,12 +204,12 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
187
204
|
|
|
188
205
|
return plugins;
|
|
189
206
|
},
|
|
190
|
-
contentComponent: function contentComponent(
|
|
191
|
-
var editorView =
|
|
192
|
-
popupsMountPoint =
|
|
193
|
-
popupsBoundariesElement =
|
|
194
|
-
popupsScrollableElement =
|
|
195
|
-
dispatchAnalyticsEvent =
|
|
207
|
+
contentComponent: function contentComponent(_ref8) {
|
|
208
|
+
var editorView = _ref8.editorView,
|
|
209
|
+
popupsMountPoint = _ref8.popupsMountPoint,
|
|
210
|
+
popupsBoundariesElement = _ref8.popupsBoundariesElement,
|
|
211
|
+
popupsScrollableElement = _ref8.popupsScrollableElement,
|
|
212
|
+
dispatchAnalyticsEvent = _ref8.dispatchAnalyticsEvent;
|
|
196
213
|
return /*#__PURE__*/React.createElement(ErrorBoundary, {
|
|
197
214
|
component: ACTION_SUBJECT.TABLES_PLUGIN,
|
|
198
215
|
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
@@ -203,25 +220,25 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
203
220
|
tableResizingPluginState: tableResizingPluginKey,
|
|
204
221
|
stickyHeadersState: stickyHeadersPluginKey
|
|
205
222
|
},
|
|
206
|
-
render: function render(
|
|
207
|
-
var resizingPluginState =
|
|
208
|
-
stickyHeadersState =
|
|
209
|
-
tablePluginState =
|
|
223
|
+
render: function render(_ref9) {
|
|
224
|
+
var resizingPluginState = _ref9.tableResizingPluginState,
|
|
225
|
+
stickyHeadersState = _ref9.stickyHeadersState,
|
|
226
|
+
tablePluginState = _ref9.tablePluginState;
|
|
210
227
|
var state = editorView.state;
|
|
211
228
|
var isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
|
|
212
|
-
var
|
|
213
|
-
tableNode =
|
|
214
|
-
tablePos =
|
|
215
|
-
targetCellPosition =
|
|
216
|
-
isContextualMenuOpen =
|
|
217
|
-
layout =
|
|
218
|
-
tableRef =
|
|
219
|
-
pluginConfig =
|
|
220
|
-
insertColumnButtonIndex =
|
|
221
|
-
insertRowButtonIndex =
|
|
222
|
-
isHeaderColumnEnabled =
|
|
223
|
-
isHeaderRowEnabled =
|
|
224
|
-
tableWrapperTarget =
|
|
229
|
+
var _ref10 = tablePluginState,
|
|
230
|
+
tableNode = _ref10.tableNode,
|
|
231
|
+
tablePos = _ref10.tablePos,
|
|
232
|
+
targetCellPosition = _ref10.targetCellPosition,
|
|
233
|
+
isContextualMenuOpen = _ref10.isContextualMenuOpen,
|
|
234
|
+
layout = _ref10.layout,
|
|
235
|
+
tableRef = _ref10.tableRef,
|
|
236
|
+
pluginConfig = _ref10.pluginConfig,
|
|
237
|
+
insertColumnButtonIndex = _ref10.insertColumnButtonIndex,
|
|
238
|
+
insertRowButtonIndex = _ref10.insertRowButtonIndex,
|
|
239
|
+
isHeaderColumnEnabled = _ref10.isHeaderColumnEnabled,
|
|
240
|
+
isHeaderRowEnabled = _ref10.isHeaderRowEnabled,
|
|
241
|
+
tableWrapperTarget = _ref10.tableWrapperTarget;
|
|
225
242
|
var allowControls = pluginConfig.allowControls;
|
|
226
243
|
var stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
|
|
227
244
|
return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
|
|
@@ -286,9 +303,9 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
286
303
|
pluginsOptions: {
|
|
287
304
|
// TODO: ED-14676 This is not the final API design
|
|
288
305
|
// For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
|
|
289
|
-
createNodeHandler: function createNodeHandler(
|
|
290
|
-
var nodeName =
|
|
291
|
-
schema =
|
|
306
|
+
createNodeHandler: function createNodeHandler(_ref11) {
|
|
307
|
+
var nodeName = _ref11.nodeName,
|
|
308
|
+
schema = _ref11.schema;
|
|
292
309
|
|
|
293
310
|
// An EditorPlugin may manage more than one node.
|
|
294
311
|
if (nodeName !== 'table') {
|
|
@@ -300,8 +317,8 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
300
317
|
});
|
|
301
318
|
return table;
|
|
302
319
|
},
|
|
303
|
-
quickInsert: function quickInsert(
|
|
304
|
-
var formatMessage =
|
|
320
|
+
quickInsert: function quickInsert(_ref12) {
|
|
321
|
+
var formatMessage = _ref12.formatMessage;
|
|
305
322
|
return [{
|
|
306
323
|
id: 'table',
|
|
307
324
|
title: formatMessage(messages.table),
|
|
@@ -313,12 +330,12 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
313
330
|
return /*#__PURE__*/React.createElement(IconTable, null);
|
|
314
331
|
},
|
|
315
332
|
action: function action(insert, state) {
|
|
316
|
-
var _options$
|
|
333
|
+
var _options$editorAnalyt2;
|
|
317
334
|
|
|
318
335
|
var tr = insert(createTable({
|
|
319
336
|
schema: state.schema
|
|
320
337
|
}));
|
|
321
|
-
options === null || options === void 0 ? void 0 : (_options$
|
|
338
|
+
options === null || options === void 0 ? void 0 : (_options$editorAnalyt2 = options.editorAnalyticsAPI) === null || _options$editorAnalyt2 === void 0 ? void 0 : _options$editorAnalyt2.attachAnalyticsEvent({
|
|
322
339
|
action: ACTION.INSERTED,
|
|
323
340
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
324
341
|
actionSubjectId: ACTION_SUBJECT_ID.TABLE,
|
|
@@ -331,7 +348,7 @@ var tablesPlugin = function tablesPlugin(options) {
|
|
|
331
348
|
}
|
|
332
349
|
}];
|
|
333
350
|
},
|
|
334
|
-
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
351
|
+
floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI, (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
|
|
335
352
|
}
|
|
336
353
|
};
|
|
337
354
|
};
|
|
@@ -2,7 +2,7 @@ import { keymap } from 'prosemirror-keymap';
|
|
|
2
2
|
import { chainCommands } from 'prosemirror-commands';
|
|
3
3
|
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { createTable, goToNextCell, moveCursorBackward
|
|
5
|
+
import { triggerUnlessTableHeader, createTable, goToNextCell, moveCursorBackward } from '../commands';
|
|
6
6
|
import { addRowAroundSelection, emptyMultipleCellsWithAnalytics, deleteTableIfSelectedWithAnalytics } from '../commands-with-analytics';
|
|
7
7
|
import { addColumnAfter, addColumnBefore } from '../commands/insert';
|
|
8
8
|
import { withEditorAnalyticsAPI } from '../utils/analytics';
|
|
@@ -16,12 +16,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
16
|
* TODO: https://product-fabric.atlassian.net/browse/ED-12714
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
|
-
// import { Dispatch } from '../../../event-dispatcher';
|
|
20
19
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
21
20
|
import { PluginKey } from 'prosemirror-state';
|
|
22
21
|
import rafSchedule from 'raf-schd';
|
|
23
|
-
import { uuid } from '@atlaskit/adf-schema';
|
|
24
|
-
|
|
22
|
+
import { uuid } from '@atlaskit/adf-schema';
|
|
25
23
|
import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
|
|
26
24
|
var pluginKey = new PluginKey('tableLocalIdPlugin');
|
|
27
25
|
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
|
|
3
|
+
/** @jsx jsx */
|
|
4
|
+
import { jsx } from '@emotion/react';
|
|
2
5
|
import { defineMessages } from 'react-intl-next';
|
|
3
6
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
4
7
|
import commonMessages from '@atlaskit/editor-common/messages';
|
|
5
8
|
import { clearHoverSelection, hoverTable } from './commands';
|
|
6
|
-
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics } from './commands-with-analytics';
|
|
9
|
+
import { deleteTableWithAnalytics, toggleHeaderColumnWithAnalytics, toggleHeaderRowWithAnalytics, toggleNumberColumnWithAnalytics, insertRowWithAnalytics, deleteRowsWithAnalytics, mergeCellsWithAnalytics, splitCellWithAnalytics, deleteColumnsWithAnalytics, emptyMultipleCellsWithAnalytics, insertColumnWithAnalytics, wrapTableInExpandWithAnalytics, sortColumnWithAnalytics, setColorWithAnalytics, distributeColumnsWidthsWithAnalytics } from './commands-with-analytics';
|
|
7
10
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
8
11
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
9
12
|
import { TableCssClassName } from './types';
|
|
13
|
+
import { getMergedCellsPositions } from './utils';
|
|
10
14
|
import { isReferencedSource } from './utils/referentiality';
|
|
11
15
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
12
16
|
import { findCellRectClosestToPos, findTable, getSelectionRect, isSelectionType } from '@atlaskit/editor-tables/utils';
|
|
@@ -16,6 +20,11 @@ import tableMessages from './ui/messages';
|
|
|
16
20
|
import { messages as ContextualMenuMessages } from './ui/FloatingContextualMenu/ContextualMenu';
|
|
17
21
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
18
22
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
23
|
+
import { addColumnAfter, addRowAfter, tooltip, backspace } from '@atlaskit/editor-common/keymaps';
|
|
24
|
+
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
25
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
26
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
27
|
+
import { cellBackgroundColorPalette, DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
19
28
|
export var messages = defineMessages({
|
|
20
29
|
tableOptions: {
|
|
21
30
|
id: 'fabric.editor.tableOptions',
|
|
@@ -85,6 +94,8 @@ export var getToolbarMenuConfig = function getToolbarMenuConfig(config, state, _
|
|
|
85
94
|
// with native widgets. It's enabled via a plugin config.
|
|
86
95
|
|
|
87
96
|
export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(editorState, initialSelectionRect, _ref2, getEditorContainerWidth, editorAnalyticsAPI) {
|
|
97
|
+
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
98
|
+
|
|
88
99
|
var formatMessage = _ref2.formatMessage;
|
|
89
100
|
var top = initialSelectionRect.top,
|
|
90
101
|
bottom = initialSelectionRect.bottom,
|
|
@@ -92,6 +103,7 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
92
103
|
left = initialSelectionRect.left;
|
|
93
104
|
var numberOfColumns = right - left;
|
|
94
105
|
var numberOfRows = bottom - top;
|
|
106
|
+
var pluginState = getPluginState(editorState);
|
|
95
107
|
var options = [{
|
|
96
108
|
id: 'editor.table.insertColumn',
|
|
97
109
|
title: formatMessage(tableMessages.insertColumn),
|
|
@@ -106,7 +118,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
106
118
|
return true;
|
|
107
119
|
},
|
|
108
120
|
selected: false,
|
|
109
|
-
disabled: false
|
|
121
|
+
disabled: false,
|
|
122
|
+
elemAfter: jsx("div", {
|
|
123
|
+
css: shortcutStyle
|
|
124
|
+
}, tooltip(addColumnAfter))
|
|
110
125
|
}, {
|
|
111
126
|
id: 'editor.table.insertRow',
|
|
112
127
|
title: formatMessage(tableMessages.insertRow),
|
|
@@ -124,7 +139,10 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
124
139
|
return true;
|
|
125
140
|
},
|
|
126
141
|
selected: false,
|
|
127
|
-
disabled: false
|
|
142
|
+
disabled: false,
|
|
143
|
+
elemAfter: jsx("div", {
|
|
144
|
+
css: shortcutStyle
|
|
145
|
+
}, tooltip(addRowAfter))
|
|
128
146
|
}, {
|
|
129
147
|
id: 'editor.table.removeColumns',
|
|
130
148
|
title: formatMessage(tableMessages.removeColumns, {
|
|
@@ -160,16 +178,63 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
160
178
|
}, {
|
|
161
179
|
id: 'editor.table.mergeCells',
|
|
162
180
|
title: formatMessage(ContextualMenuMessages.mergeCells),
|
|
163
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI),
|
|
181
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
164
182
|
selected: false,
|
|
165
183
|
disabled: !canMergeCells(editorState.tr)
|
|
166
184
|
}, {
|
|
167
185
|
id: 'editor.table.splitCell',
|
|
168
186
|
title: formatMessage(ContextualMenuMessages.splitCell),
|
|
169
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI),
|
|
187
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB),
|
|
170
188
|
selected: false,
|
|
171
189
|
disabled: !splitCell(editorState)
|
|
172
|
-
}
|
|
190
|
+
}];
|
|
191
|
+
|
|
192
|
+
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo = pluginState.pluginConfig) !== null && _pluginState$pluginCo !== void 0 && _pluginState$pluginCo.allowDistributeColumns) {
|
|
193
|
+
var distributeColumnWidths = function distributeColumnWidths(state, dispatch, view) {
|
|
194
|
+
var newResizeStateWithAnalytics = view ? getNewResizeStateFromSelectedColumns(initialSelectionRect, editorState, view.domAtPos.bind(view), getEditorContainerWidth) : undefined;
|
|
195
|
+
|
|
196
|
+
if (newResizeStateWithAnalytics) {
|
|
197
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, newResizeStateWithAnalytics)(state, dispatch);
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return false;
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
options.push({
|
|
205
|
+
id: 'editor.table.distributeColumns',
|
|
206
|
+
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
207
|
+
onClick: distributeColumnWidths,
|
|
208
|
+
selected: false,
|
|
209
|
+
disabled: numberOfColumns <= 1
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (pluginState !== null && pluginState !== void 0 && (_pluginState$pluginCo2 = pluginState.pluginConfig) !== null && _pluginState$pluginCo2 !== void 0 && _pluginState$pluginCo2.allowColumnSorting) {
|
|
214
|
+
var hasMergedCellsInTable = getMergedCellsPositions(editorState.tr).length > 0;
|
|
215
|
+
options.push({
|
|
216
|
+
id: 'editor.table.sortColumnAsc',
|
|
217
|
+
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
218
|
+
onClick: function onClick(state, dispatch) {
|
|
219
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.ASC)(state, dispatch);
|
|
220
|
+
return true;
|
|
221
|
+
},
|
|
222
|
+
selected: false,
|
|
223
|
+
disabled: hasMergedCellsInTable
|
|
224
|
+
});
|
|
225
|
+
options.push({
|
|
226
|
+
id: 'editor.table.sortColumnDesc',
|
|
227
|
+
title: formatMessage(ContextualMenuMessages.sortColumnDESC),
|
|
228
|
+
onClick: function onClick(state, dispatch) {
|
|
229
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, initialSelectionRect.left, SortOrder.DESC)(state, dispatch);
|
|
230
|
+
return true;
|
|
231
|
+
},
|
|
232
|
+
selected: false,
|
|
233
|
+
disabled: hasMergedCellsInTable
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
options.push({
|
|
173
238
|
id: 'editor.table.clearCells',
|
|
174
239
|
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
175
240
|
0: Math.max(numberOfColumns, numberOfRows)
|
|
@@ -182,14 +247,19 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
182
247
|
return true;
|
|
183
248
|
},
|
|
184
249
|
selected: false,
|
|
185
|
-
disabled: false
|
|
186
|
-
|
|
250
|
+
disabled: false,
|
|
251
|
+
elemAfter: jsx("div", {
|
|
252
|
+
css: shortcutStyle
|
|
253
|
+
}, tooltip(backspace))
|
|
254
|
+
});
|
|
187
255
|
return {
|
|
188
256
|
id: 'editor.table.cellOptions',
|
|
189
257
|
type: 'dropdown',
|
|
190
258
|
title: formatMessage(tableMessages.cellOptions),
|
|
191
|
-
|
|
192
|
-
|
|
259
|
+
options: options,
|
|
260
|
+
// Increased dropdown item width to prevent labels from being truncated
|
|
261
|
+
dropdownWidth: 230,
|
|
262
|
+
showSelected: false
|
|
193
263
|
};
|
|
194
264
|
};
|
|
195
265
|
|
|
@@ -198,7 +268,7 @@ var getClosestSelectionRect = function getClosestSelectionRect(state) {
|
|
|
198
268
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : findCellRectClosestToPos(selection.$from);
|
|
199
269
|
};
|
|
200
270
|
|
|
201
|
-
export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI) {
|
|
271
|
+
export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth, editorAnalyticsAPI, getEditorFeatureFlags) {
|
|
202
272
|
return function (config) {
|
|
203
273
|
return function (state, intl) {
|
|
204
274
|
var tableObject = findTable(state.selection);
|
|
@@ -208,7 +278,12 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
208
278
|
if (tableObject && pluginState.editorHasFocus) {
|
|
209
279
|
var nodeType = state.schema.nodes.table;
|
|
210
280
|
var menu = getToolbarMenuConfig(config, pluginState, intl, editorAnalyticsAPI);
|
|
211
|
-
|
|
281
|
+
|
|
282
|
+
var _ref3 = getEditorFeatureFlags() || {},
|
|
283
|
+
tableCellOptionsInFloatingToolbar = _ref3.tableCellOptionsInFloatingToolbar;
|
|
284
|
+
|
|
285
|
+
var cellItems = getCellItems(config, state, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar);
|
|
286
|
+
var colorPicker = getColorPicker(state, menu, intl, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar); // Check if we need to show confirm dialog for delete button
|
|
212
287
|
|
|
213
288
|
var confirmDialog;
|
|
214
289
|
var localId = tableObject.node.attrs.localId;
|
|
@@ -241,9 +316,20 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
241
316
|
getDomRef: getDomRef,
|
|
242
317
|
nodeType: nodeType,
|
|
243
318
|
offset: [0, 3],
|
|
244
|
-
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), [{
|
|
319
|
+
items: [menu, separator(menu.hidden)].concat(_toConsumableArray(cellItems), _toConsumableArray(colorPicker), [{
|
|
245
320
|
type: 'extensions-placeholder',
|
|
246
321
|
separator: 'end'
|
|
322
|
+
}, {
|
|
323
|
+
type: 'copy-button',
|
|
324
|
+
items: [{
|
|
325
|
+
state: state,
|
|
326
|
+
formatMessage: intl.formatMessage,
|
|
327
|
+
nodeType: nodeType,
|
|
328
|
+
onMouseEnter: hoverTable(false, true),
|
|
329
|
+
onMouseLeave: clearHoverSelection()
|
|
330
|
+
}, {
|
|
331
|
+
type: 'separator'
|
|
332
|
+
}]
|
|
247
333
|
}, {
|
|
248
334
|
id: 'editor.table.delete',
|
|
249
335
|
type: 'button',
|
|
@@ -255,7 +341,8 @@ export var getToolbarConfig = function getToolbarConfig(getEditorContainerWidth,
|
|
|
255
341
|
onMouseLeave: clearHoverSelection(),
|
|
256
342
|
title: intl.formatMessage(commonMessages.remove),
|
|
257
343
|
confirmDialog: confirmDialog
|
|
258
|
-
}])
|
|
344
|
+
}]),
|
|
345
|
+
scrollable: true
|
|
259
346
|
};
|
|
260
347
|
}
|
|
261
348
|
|
|
@@ -271,10 +358,10 @@ var separator = function separator(hidden) {
|
|
|
271
358
|
};
|
|
272
359
|
};
|
|
273
360
|
|
|
274
|
-
var getCellItems = function getCellItems(pluginConfig, state,
|
|
275
|
-
var formatMessage =
|
|
361
|
+
var getCellItems = function getCellItems(pluginConfig, state, _ref4, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
362
|
+
var formatMessage = _ref4.formatMessage;
|
|
276
363
|
|
|
277
|
-
if (pluginConfig.allowCellOptionsInFloatingToolbar) {
|
|
364
|
+
if (pluginConfig.allowCellOptionsInFloatingToolbar || tableCellOptionsInFloatingToolbar) {
|
|
278
365
|
var initialSelectionRect = getClosestSelectionRect(state);
|
|
279
366
|
|
|
280
367
|
if (initialSelectionRect) {
|
|
@@ -286,4 +373,39 @@ var getCellItems = function getCellItems(pluginConfig, state, _ref3, getEditorCo
|
|
|
286
373
|
}
|
|
287
374
|
|
|
288
375
|
return [];
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
var getColorPicker = function getColorPicker(state, menu, _ref5, getEditorContainerWidth, editorAnalyticsAPI, tableCellOptionsInFloatingToolbar) {
|
|
379
|
+
var _node$attrs;
|
|
380
|
+
|
|
381
|
+
var formatMessage = _ref5.formatMessage;
|
|
382
|
+
|
|
383
|
+
var _getPluginState2 = getPluginState(state),
|
|
384
|
+
targetCellPosition = _getPluginState2.targetCellPosition,
|
|
385
|
+
pluginConfig = _getPluginState2.pluginConfig;
|
|
386
|
+
|
|
387
|
+
if (!pluginConfig.allowBackgroundColor || !tableCellOptionsInFloatingToolbar) {
|
|
388
|
+
return [];
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
var node = targetCellPosition ? state.doc.nodeAt(targetCellPosition) : undefined;
|
|
392
|
+
var currentBackground = (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.background) || '#ffffff';
|
|
393
|
+
var defaultPalette = cellBackgroundColorPalette.find(function (item) {
|
|
394
|
+
return item.value === currentBackground;
|
|
395
|
+
}) || {
|
|
396
|
+
label: 'Custom',
|
|
397
|
+
value: currentBackground,
|
|
398
|
+
border: DEFAULT_BORDER_COLOR
|
|
399
|
+
};
|
|
400
|
+
return [{
|
|
401
|
+
id: 'editor.panel.colorPicker',
|
|
402
|
+
title: formatMessage(ContextualMenuMessages.cellBackground),
|
|
403
|
+
type: 'select',
|
|
404
|
+
selectType: 'color',
|
|
405
|
+
defaultValue: defaultPalette,
|
|
406
|
+
options: cellBackgroundColorPalette,
|
|
407
|
+
onChange: function onChange(option) {
|
|
408
|
+
return setColorWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.FLOATING_TB, option.value, targetCellPosition);
|
|
409
|
+
}
|
|
410
|
+
}, separator(menu.hidden)];
|
|
289
411
|
};
|