@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
|
@@ -59,13 +59,14 @@ export const hoverMergedCells = () =>
|
|
|
59
59
|
export const hoverColumns = (hoveredColumns: number[], isInDanger?: boolean) =>
|
|
60
60
|
createCommand(
|
|
61
61
|
(state) => {
|
|
62
|
-
const cells = getCellsInColumn(hoveredColumns)(state.selection);
|
|
62
|
+
const cells = getCellsInColumn(hoveredColumns)(state.tr.selection);
|
|
63
63
|
if (!cells) {
|
|
64
64
|
return false;
|
|
65
65
|
}
|
|
66
66
|
const decorations = createControlsHoverDecoration(
|
|
67
67
|
cells,
|
|
68
68
|
'column',
|
|
69
|
+
state.tr,
|
|
69
70
|
isInDanger,
|
|
70
71
|
);
|
|
71
72
|
|
|
@@ -95,6 +96,7 @@ export const hoverRows = (hoveredRows: number[], isInDanger?: boolean) =>
|
|
|
95
96
|
const decorations = createControlsHoverDecoration(
|
|
96
97
|
cells,
|
|
97
98
|
'row',
|
|
99
|
+
state.tr,
|
|
98
100
|
isInDanger,
|
|
99
101
|
);
|
|
100
102
|
|
|
@@ -131,6 +133,7 @@ export const hoverTable = (isInDanger?: boolean, isSelected?: boolean) =>
|
|
|
131
133
|
const decorations = createControlsHoverDecoration(
|
|
132
134
|
cells,
|
|
133
135
|
'table',
|
|
136
|
+
state.tr,
|
|
134
137
|
isInDanger,
|
|
135
138
|
isSelected,
|
|
136
139
|
);
|
|
@@ -96,7 +96,7 @@ export const emptyMultipleCellsWithAnalytics = (
|
|
|
96
96
|
|
|
97
97
|
export const mergeCellsWithAnalytics = (
|
|
98
98
|
editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined,
|
|
99
|
-
) =>
|
|
99
|
+
) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) =>
|
|
100
100
|
withEditorAnalyticsAPI(({ selection }) => {
|
|
101
101
|
const {
|
|
102
102
|
horizontalCells,
|
|
@@ -111,7 +111,7 @@ export const mergeCellsWithAnalytics = (
|
|
|
111
111
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
112
112
|
actionSubjectId: null,
|
|
113
113
|
attributes: {
|
|
114
|
-
inputMethod
|
|
114
|
+
inputMethod,
|
|
115
115
|
horizontalCells,
|
|
116
116
|
verticalCells,
|
|
117
117
|
totalCells,
|
|
@@ -129,7 +129,7 @@ export const mergeCellsWithAnalytics = (
|
|
|
129
129
|
|
|
130
130
|
export const splitCellWithAnalytics = (
|
|
131
131
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
132
|
-
) =>
|
|
132
|
+
) => (inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB) =>
|
|
133
133
|
withEditorAnalyticsAPI(({ selection }) => {
|
|
134
134
|
const { totalRowCount, totalColumnCount } = getSelectedCellInfo(selection);
|
|
135
135
|
const cell = findCellClosestToPos(selection.$anchor);
|
|
@@ -144,7 +144,7 @@ export const splitCellWithAnalytics = (
|
|
|
144
144
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
145
145
|
actionSubjectId: null,
|
|
146
146
|
attributes: {
|
|
147
|
-
inputMethod
|
|
147
|
+
inputMethod,
|
|
148
148
|
horizontalCells,
|
|
149
149
|
verticalCells,
|
|
150
150
|
totalCells: horizontalCells * verticalCells,
|
|
@@ -159,7 +159,11 @@ export const splitCellWithAnalytics = (
|
|
|
159
159
|
|
|
160
160
|
export const setColorWithAnalytics = (
|
|
161
161
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
162
|
-
) => (
|
|
162
|
+
) => (
|
|
163
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB,
|
|
164
|
+
cellColor: string,
|
|
165
|
+
targetCellPosition?: number,
|
|
166
|
+
) =>
|
|
163
167
|
withEditorAnalyticsAPI(({ selection }) => {
|
|
164
168
|
const {
|
|
165
169
|
horizontalCells,
|
|
@@ -174,7 +178,7 @@ export const setColorWithAnalytics = (
|
|
|
174
178
|
actionSubject: ACTION_SUBJECT.TABLE,
|
|
175
179
|
actionSubjectId: null,
|
|
176
180
|
attributes: {
|
|
177
|
-
inputMethod
|
|
181
|
+
inputMethod,
|
|
178
182
|
cellColor: (
|
|
179
183
|
tableBackgroundColorPalette.get(cellColor.toLowerCase()) || cellColor
|
|
180
184
|
).toLowerCase(),
|
|
@@ -457,7 +461,7 @@ export const toggleTableLayoutWithAnalytics = (
|
|
|
457
461
|
export const sortColumnWithAnalytics = (
|
|
458
462
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
459
463
|
) => (
|
|
460
|
-
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
464
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB,
|
|
461
465
|
columnIndex: number,
|
|
462
466
|
sortOrder: SortOrder,
|
|
463
467
|
) =>
|
|
@@ -483,7 +487,7 @@ export const sortColumnWithAnalytics = (
|
|
|
483
487
|
export const distributeColumnsWidthsWithAnalytics = (
|
|
484
488
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
485
489
|
) => (
|
|
486
|
-
inputMethod: INPUT_METHOD.CONTEXT_MENU,
|
|
490
|
+
inputMethod: INPUT_METHOD.CONTEXT_MENU | INPUT_METHOD.FLOATING_TB,
|
|
487
491
|
{ resizeState, table, attributes }: ResizeStateWithAnalytics,
|
|
488
492
|
) => {
|
|
489
493
|
return withEditorAnalyticsAPI(() => {
|
|
@@ -23,7 +23,6 @@ import {
|
|
|
23
23
|
isLastItemMediaGroup,
|
|
24
24
|
setNodeSelection,
|
|
25
25
|
} from '@atlaskit/editor-common/utils';
|
|
26
|
-
// import { closestElement } from '@atlaskit/editor-core/src/utils/dom';
|
|
27
26
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
28
27
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
29
28
|
import {
|
|
@@ -3,7 +3,6 @@ import { Transaction, ReadonlyTransaction } from 'prosemirror-state';
|
|
|
3
3
|
import { ContentNodeWithPos, findParentNodeOfType } from 'prosemirror-utils';
|
|
4
4
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
|
|
6
|
-
// import { isTextInput } from '../../utils/is-text-input';
|
|
7
6
|
import { isTextInput } from '@atlaskit/editor-common/utils';
|
|
8
7
|
import { isTableCollapsible } from './utils/collapse';
|
|
9
8
|
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
ACTION_SUBJECT_ID,
|
|
21
21
|
EVENT_TYPE,
|
|
22
22
|
INPUT_METHOD,
|
|
23
|
+
TABLE_ACTION,
|
|
23
24
|
} from '@atlaskit/editor-common/analytics';
|
|
24
25
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
25
26
|
|
|
@@ -59,6 +60,7 @@ import type {
|
|
|
59
60
|
GetEditorContainerWidth,
|
|
60
61
|
GetEditorFeatureFlags,
|
|
61
62
|
} from '@atlaskit/editor-common/types';
|
|
63
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
62
64
|
|
|
63
65
|
interface TablePluginOptions {
|
|
64
66
|
tableOptions: PluginConfig;
|
|
@@ -177,8 +179,31 @@ const tablesPlugin = (options?: TablePluginOptions): EditorPlugin => {
|
|
|
177
179
|
name: 'tableSelectionKeymap',
|
|
178
180
|
plugin: () => tableSelectionKeymapPlugin(options?.editorSelectionAPI),
|
|
179
181
|
},
|
|
180
|
-
{
|
|
181
|
-
|
|
182
|
+
{
|
|
183
|
+
name: 'tableEditing',
|
|
184
|
+
plugin: () =>
|
|
185
|
+
tableEditing({
|
|
186
|
+
reportFixedTable: ({
|
|
187
|
+
state,
|
|
188
|
+
tr,
|
|
189
|
+
reason,
|
|
190
|
+
}: {
|
|
191
|
+
state: EditorState;
|
|
192
|
+
tr: Transaction;
|
|
193
|
+
reason: string;
|
|
194
|
+
}) => {
|
|
195
|
+
options?.editorAnalyticsAPI?.attachAnalyticsEvent({
|
|
196
|
+
action: TABLE_ACTION.FIXED,
|
|
197
|
+
actionSubject: ACTION_SUBJECT.TABLE,
|
|
198
|
+
actionSubjectId: null,
|
|
199
|
+
attributes: {
|
|
200
|
+
reason,
|
|
201
|
+
},
|
|
202
|
+
eventType: EVENT_TYPE.TRACK,
|
|
203
|
+
})(tr);
|
|
204
|
+
},
|
|
205
|
+
}) as SafePlugin,
|
|
206
|
+
},
|
|
182
207
|
{
|
|
183
208
|
name: 'tableStickyHeaders',
|
|
184
209
|
plugin: ({ dispatch, eventDispatcher }) =>
|
|
@@ -432,6 +457,7 @@ const tablesPlugin = (options?: TablePluginOptions): EditorPlugin => {
|
|
|
432
457
|
floatingToolbar: getToolbarConfig(
|
|
433
458
|
defaultGetEditorContainerWidth,
|
|
434
459
|
options?.editorAnalyticsAPI,
|
|
460
|
+
options?.getEditorFeatureFlags || defaultGetEditorFeatureFlags,
|
|
435
461
|
)(pluginConfig(options?.tableOptions)),
|
|
436
462
|
},
|
|
437
463
|
};
|
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
INPUT_METHOD,
|
|
12
12
|
} from '@atlaskit/editor-common/analytics';
|
|
13
13
|
import {
|
|
14
|
+
triggerUnlessTableHeader,
|
|
14
15
|
createTable,
|
|
15
16
|
goToNextCell,
|
|
16
17
|
moveCursorBackward,
|
|
17
|
-
triggerUnlessTableHeader,
|
|
18
18
|
} from '../commands';
|
|
19
19
|
import {
|
|
20
20
|
addRowAroundSelection,
|
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* TODO: https://product-fabric.atlassian.net/browse/ED-12714
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
|
-
// import { Dispatch } from '../../../event-dispatcher';
|
|
14
13
|
import { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
15
14
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
16
15
|
import { EditorState, PluginKey, Transaction } from 'prosemirror-state';
|
|
@@ -19,7 +18,6 @@ import rafSchedule from 'raf-schd';
|
|
|
19
18
|
|
|
20
19
|
import { uuid } from '@atlaskit/adf-schema';
|
|
21
20
|
|
|
22
|
-
// import { stepAddsOneOf } from '../../../utils/step';
|
|
23
21
|
import { stepAddsOneOf } from '@atlaskit/editor-common/utils';
|
|
24
22
|
|
|
25
23
|
interface TableLocalIdPluginState {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import { defineMessages } from 'react-intl-next';
|
|
2
4
|
|
|
3
5
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
@@ -8,6 +10,7 @@ import type {
|
|
|
8
10
|
FloatingToolbarDropdown,
|
|
9
11
|
FloatingToolbarHandler,
|
|
10
12
|
FloatingToolbarItem,
|
|
13
|
+
GetEditorFeatureFlags,
|
|
11
14
|
} from '@atlaskit/editor-common/types';
|
|
12
15
|
|
|
13
16
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
@@ -26,6 +29,9 @@ import {
|
|
|
26
29
|
emptyMultipleCellsWithAnalytics,
|
|
27
30
|
insertColumnWithAnalytics,
|
|
28
31
|
wrapTableInExpandWithAnalytics,
|
|
32
|
+
sortColumnWithAnalytics,
|
|
33
|
+
setColorWithAnalytics,
|
|
34
|
+
distributeColumnsWidthsWithAnalytics,
|
|
29
35
|
} from './commands-with-analytics';
|
|
30
36
|
import { getPluginState } from './pm-plugins/plugin-factory';
|
|
31
37
|
import { pluginKey as tableResizingPluginKey } from './pm-plugins/table-resizing';
|
|
@@ -37,6 +43,7 @@ import {
|
|
|
37
43
|
PluginConfig,
|
|
38
44
|
TableCssClassName,
|
|
39
45
|
} from './types';
|
|
46
|
+
import { getMergedCellsPositions } from './utils';
|
|
40
47
|
import { isReferencedSource } from './utils/referentiality';
|
|
41
48
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
42
49
|
import {
|
|
@@ -56,6 +63,19 @@ import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
|
56
63
|
import { findParentDomRefOfType } from 'prosemirror-utils';
|
|
57
64
|
import { EditorView } from 'prosemirror-view';
|
|
58
65
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
66
|
+
import {
|
|
67
|
+
addColumnAfter,
|
|
68
|
+
addRowAfter,
|
|
69
|
+
tooltip,
|
|
70
|
+
backspace,
|
|
71
|
+
} from '@atlaskit/editor-common/keymaps';
|
|
72
|
+
import { getNewResizeStateFromSelectedColumns } from './pm-plugins/table-resizing/utils/resize-state';
|
|
73
|
+
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
74
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
75
|
+
import {
|
|
76
|
+
cellBackgroundColorPalette,
|
|
77
|
+
DEFAULT_BORDER_COLOR,
|
|
78
|
+
} from '@atlaskit/editor-common/ui-color';
|
|
59
79
|
|
|
60
80
|
export const messages = defineMessages({
|
|
61
81
|
tableOptions: {
|
|
@@ -145,6 +165,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
145
165
|
const { top, bottom, right, left } = initialSelectionRect;
|
|
146
166
|
const numberOfColumns = right - left;
|
|
147
167
|
const numberOfRows = bottom - top;
|
|
168
|
+
const pluginState = getPluginState(editorState);
|
|
148
169
|
|
|
149
170
|
const options = [
|
|
150
171
|
{
|
|
@@ -167,6 +188,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
167
188
|
},
|
|
168
189
|
selected: false,
|
|
169
190
|
disabled: false,
|
|
191
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(addColumnAfter)}</div>,
|
|
170
192
|
},
|
|
171
193
|
{
|
|
172
194
|
id: 'editor.table.insertRow',
|
|
@@ -184,6 +206,7 @@ export const getToolbarCellOptionsConfig = (
|
|
|
184
206
|
},
|
|
185
207
|
selected: false,
|
|
186
208
|
disabled: false,
|
|
209
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(addRowAfter)}</div>,
|
|
187
210
|
},
|
|
188
211
|
{
|
|
189
212
|
id: 'editor.table.removeColumns',
|
|
@@ -229,41 +252,114 @@ export const getToolbarCellOptionsConfig = (
|
|
|
229
252
|
{
|
|
230
253
|
id: 'editor.table.mergeCells',
|
|
231
254
|
title: formatMessage(ContextualMenuMessages.mergeCells),
|
|
232
|
-
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)
|
|
255
|
+
onClick: mergeCellsWithAnalytics(editorAnalyticsAPI)(
|
|
256
|
+
INPUT_METHOD.FLOATING_TB,
|
|
257
|
+
),
|
|
233
258
|
selected: false,
|
|
234
259
|
disabled: !canMergeCells(editorState.tr),
|
|
235
260
|
},
|
|
236
261
|
{
|
|
237
262
|
id: 'editor.table.splitCell',
|
|
238
263
|
title: formatMessage(ContextualMenuMessages.splitCell),
|
|
239
|
-
onClick: splitCellWithAnalytics(editorAnalyticsAPI)
|
|
264
|
+
onClick: splitCellWithAnalytics(editorAnalyticsAPI)(
|
|
265
|
+
INPUT_METHOD.FLOATING_TB,
|
|
266
|
+
),
|
|
240
267
|
selected: false,
|
|
241
268
|
disabled: !splitCell(editorState),
|
|
242
269
|
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
270
|
+
];
|
|
271
|
+
|
|
272
|
+
if (pluginState?.pluginConfig?.allowDistributeColumns) {
|
|
273
|
+
const distributeColumnWidths: Command = (state, dispatch, view) => {
|
|
274
|
+
const newResizeStateWithAnalytics = view
|
|
275
|
+
? getNewResizeStateFromSelectedColumns(
|
|
276
|
+
initialSelectionRect,
|
|
277
|
+
editorState,
|
|
278
|
+
view.domAtPos.bind(view),
|
|
279
|
+
getEditorContainerWidth,
|
|
280
|
+
)
|
|
281
|
+
: undefined;
|
|
282
|
+
|
|
283
|
+
if (newResizeStateWithAnalytics) {
|
|
284
|
+
distributeColumnsWidthsWithAnalytics(editorAnalyticsAPI)(
|
|
285
|
+
INPUT_METHOD.FLOATING_TB,
|
|
286
|
+
newResizeStateWithAnalytics,
|
|
287
|
+
)(state, dispatch);
|
|
288
|
+
return true;
|
|
289
|
+
}
|
|
290
|
+
return false;
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
options.push({
|
|
294
|
+
id: 'editor.table.distributeColumns',
|
|
295
|
+
title: formatMessage(ContextualMenuMessages.distributeColumns),
|
|
296
|
+
onClick: distributeColumnWidths,
|
|
297
|
+
selected: false,
|
|
298
|
+
disabled: numberOfColumns <= 1,
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (pluginState?.pluginConfig?.allowColumnSorting) {
|
|
303
|
+
const hasMergedCellsInTable =
|
|
304
|
+
getMergedCellsPositions(editorState.tr).length > 0;
|
|
305
|
+
|
|
306
|
+
options.push({
|
|
307
|
+
id: 'editor.table.sortColumnAsc',
|
|
308
|
+
title: formatMessage(ContextualMenuMessages.sortColumnASC),
|
|
248
309
|
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
249
|
-
|
|
250
|
-
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
|
|
310
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
251
311
|
INPUT_METHOD.FLOATING_TB,
|
|
252
|
-
|
|
312
|
+
initialSelectionRect.left,
|
|
313
|
+
SortOrder.ASC,
|
|
253
314
|
)(state, dispatch);
|
|
254
315
|
return true;
|
|
255
316
|
},
|
|
256
317
|
selected: false,
|
|
257
|
-
disabled:
|
|
318
|
+
disabled: hasMergedCellsInTable,
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
options.push({
|
|
322
|
+
id: 'editor.table.sortColumnDesc',
|
|
323
|
+
title: formatMessage(ContextualMenuMessages.sortColumnDESC),
|
|
324
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
325
|
+
sortColumnWithAnalytics(editorAnalyticsAPI)(
|
|
326
|
+
INPUT_METHOD.FLOATING_TB,
|
|
327
|
+
initialSelectionRect.left,
|
|
328
|
+
SortOrder.DESC,
|
|
329
|
+
)(state, dispatch);
|
|
330
|
+
return true;
|
|
331
|
+
},
|
|
332
|
+
selected: false,
|
|
333
|
+
disabled: hasMergedCellsInTable,
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
options.push({
|
|
338
|
+
id: 'editor.table.clearCells',
|
|
339
|
+
title: formatMessage(ContextualMenuMessages.clearCells, {
|
|
340
|
+
0: Math.max(numberOfColumns, numberOfRows),
|
|
341
|
+
}),
|
|
342
|
+
onClick: (state: EditorState, dispatch?: CommandDispatch) => {
|
|
343
|
+
const { targetCellPosition } = getPluginState(state);
|
|
344
|
+
emptyMultipleCellsWithAnalytics(editorAnalyticsAPI)(
|
|
345
|
+
INPUT_METHOD.FLOATING_TB,
|
|
346
|
+
targetCellPosition,
|
|
347
|
+
)(state, dispatch);
|
|
348
|
+
return true;
|
|
258
349
|
},
|
|
259
|
-
|
|
350
|
+
selected: false,
|
|
351
|
+
disabled: false,
|
|
352
|
+
elemAfter: <div css={shortcutStyle}>{tooltip(backspace)}</div>,
|
|
353
|
+
});
|
|
260
354
|
|
|
261
355
|
return {
|
|
262
356
|
id: 'editor.table.cellOptions',
|
|
263
357
|
type: 'dropdown',
|
|
264
358
|
title: formatMessage(tableMessages.cellOptions),
|
|
265
|
-
hidden: true,
|
|
266
359
|
options,
|
|
360
|
+
// Increased dropdown item width to prevent labels from being truncated
|
|
361
|
+
dropdownWidth: 230,
|
|
362
|
+
showSelected: false,
|
|
267
363
|
};
|
|
268
364
|
};
|
|
269
365
|
|
|
@@ -277,6 +373,7 @@ const getClosestSelectionRect = (state: EditorState): Rect | undefined => {
|
|
|
277
373
|
export const getToolbarConfig = (
|
|
278
374
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
279
375
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
376
|
+
getEditorFeatureFlags: GetEditorFeatureFlags,
|
|
280
377
|
) => (config: PluginConfig): FloatingToolbarHandler => (state, intl) => {
|
|
281
378
|
const tableObject = findTable(state.selection);
|
|
282
379
|
const pluginState = getPluginState(state);
|
|
@@ -292,12 +389,22 @@ export const getToolbarConfig = (
|
|
|
292
389
|
editorAnalyticsAPI,
|
|
293
390
|
);
|
|
294
391
|
|
|
392
|
+
const { tableCellOptionsInFloatingToolbar } = getEditorFeatureFlags() || {};
|
|
295
393
|
const cellItems = getCellItems(
|
|
296
394
|
config,
|
|
297
395
|
state,
|
|
298
396
|
intl,
|
|
299
397
|
getEditorContainerWidth,
|
|
300
398
|
editorAnalyticsAPI,
|
|
399
|
+
tableCellOptionsInFloatingToolbar,
|
|
400
|
+
);
|
|
401
|
+
const colorPicker = getColorPicker(
|
|
402
|
+
state,
|
|
403
|
+
menu,
|
|
404
|
+
intl,
|
|
405
|
+
getEditorContainerWidth,
|
|
406
|
+
editorAnalyticsAPI,
|
|
407
|
+
tableCellOptionsInFloatingToolbar,
|
|
301
408
|
);
|
|
302
409
|
|
|
303
410
|
// Check if we need to show confirm dialog for delete button
|
|
@@ -347,10 +454,24 @@ export const getToolbarConfig = (
|
|
|
347
454
|
menu,
|
|
348
455
|
separator(menu.hidden),
|
|
349
456
|
...cellItems,
|
|
457
|
+
...colorPicker,
|
|
350
458
|
{
|
|
351
459
|
type: 'extensions-placeholder',
|
|
352
460
|
separator: 'end',
|
|
353
461
|
},
|
|
462
|
+
{
|
|
463
|
+
type: 'copy-button',
|
|
464
|
+
items: [
|
|
465
|
+
{
|
|
466
|
+
state,
|
|
467
|
+
formatMessage: intl.formatMessage,
|
|
468
|
+
nodeType,
|
|
469
|
+
onMouseEnter: hoverTable(false, true),
|
|
470
|
+
onMouseLeave: clearHoverSelection(),
|
|
471
|
+
},
|
|
472
|
+
{ type: 'separator' },
|
|
473
|
+
],
|
|
474
|
+
},
|
|
354
475
|
{
|
|
355
476
|
id: 'editor.table.delete',
|
|
356
477
|
type: 'button',
|
|
@@ -364,6 +485,7 @@ export const getToolbarConfig = (
|
|
|
364
485
|
confirmDialog,
|
|
365
486
|
},
|
|
366
487
|
],
|
|
488
|
+
scrollable: true,
|
|
367
489
|
};
|
|
368
490
|
}
|
|
369
491
|
return;
|
|
@@ -382,8 +504,12 @@ const getCellItems = (
|
|
|
382
504
|
{ formatMessage }: ToolbarMenuContext,
|
|
383
505
|
getEditorContainerWidth: GetEditorContainerWidth,
|
|
384
506
|
editorAnalyticsAPI: EditorAnalyticsAPI | undefined | null,
|
|
507
|
+
tableCellOptionsInFloatingToolbar?: boolean,
|
|
385
508
|
): Array<FloatingToolbarItem<Command>> => {
|
|
386
|
-
if (
|
|
509
|
+
if (
|
|
510
|
+
pluginConfig.allowCellOptionsInFloatingToolbar ||
|
|
511
|
+
tableCellOptionsInFloatingToolbar
|
|
512
|
+
) {
|
|
387
513
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
388
514
|
if (initialSelectionRect) {
|
|
389
515
|
const cellOptions = getToolbarCellOptionsConfig(
|
|
@@ -398,3 +524,49 @@ const getCellItems = (
|
|
|
398
524
|
}
|
|
399
525
|
return [];
|
|
400
526
|
};
|
|
527
|
+
|
|
528
|
+
const getColorPicker = (
|
|
529
|
+
state: EditorState,
|
|
530
|
+
menu: FloatingToolbarItem<Command>,
|
|
531
|
+
{ formatMessage }: ToolbarMenuContext,
|
|
532
|
+
getEditorContainerWidth: GetEditorContainerWidth,
|
|
533
|
+
editorAnalyticsAPI: EditorAnalyticsAPI | null | undefined,
|
|
534
|
+
tableCellOptionsInFloatingToolbar?: boolean,
|
|
535
|
+
): Array<FloatingToolbarItem<Command>> => {
|
|
536
|
+
const { targetCellPosition, pluginConfig } = getPluginState(state);
|
|
537
|
+
if (
|
|
538
|
+
!pluginConfig.allowBackgroundColor ||
|
|
539
|
+
!tableCellOptionsInFloatingToolbar
|
|
540
|
+
) {
|
|
541
|
+
return [];
|
|
542
|
+
}
|
|
543
|
+
const node = targetCellPosition
|
|
544
|
+
? state.doc.nodeAt(targetCellPosition)
|
|
545
|
+
: undefined;
|
|
546
|
+
const currentBackground = node?.attrs?.background || '#ffffff';
|
|
547
|
+
const defaultPalette = cellBackgroundColorPalette.find(
|
|
548
|
+
(item) => item.value === currentBackground,
|
|
549
|
+
) || {
|
|
550
|
+
label: 'Custom',
|
|
551
|
+
value: currentBackground,
|
|
552
|
+
border: DEFAULT_BORDER_COLOR,
|
|
553
|
+
};
|
|
554
|
+
|
|
555
|
+
return [
|
|
556
|
+
{
|
|
557
|
+
id: 'editor.panel.colorPicker',
|
|
558
|
+
title: formatMessage(ContextualMenuMessages.cellBackground),
|
|
559
|
+
type: 'select',
|
|
560
|
+
selectType: 'color',
|
|
561
|
+
defaultValue: defaultPalette,
|
|
562
|
+
options: cellBackgroundColorPalette,
|
|
563
|
+
onChange: (option: any) =>
|
|
564
|
+
setColorWithAnalytics(editorAnalyticsAPI)(
|
|
565
|
+
INPUT_METHOD.FLOATING_TB,
|
|
566
|
+
option.value,
|
|
567
|
+
targetCellPosition,
|
|
568
|
+
),
|
|
569
|
+
},
|
|
570
|
+
separator(menu.hidden),
|
|
571
|
+
];
|
|
572
|
+
};
|
|
@@ -9,9 +9,8 @@ import {
|
|
|
9
9
|
akEditorWideLayoutWidth,
|
|
10
10
|
} from '@atlaskit/editor-shared-styles';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import { sendLogs } from '../todo-stubs';
|
|
12
|
+
import { sendLogs } from '@atlaskit/editor-common/utils';
|
|
13
|
+
|
|
15
14
|
import {
|
|
16
15
|
calculateColumnWidth,
|
|
17
16
|
contentWidth,
|
|
@@ -167,7 +167,6 @@ export class FloatingContextualButtonInner extends React.Component<
|
|
|
167
167
|
this.props.stickyHeader !== nextProps.stickyHeader
|
|
168
168
|
);
|
|
169
169
|
}
|
|
170
|
-
// TODO: restore
|
|
171
170
|
private handleClick = () => {
|
|
172
171
|
const { state, dispatch } = this.props.editorView;
|
|
173
172
|
// Clicking outside the dropdown handles toggling the menu closed
|
|
@@ -29,9 +29,7 @@ import { closestElement } from '@atlaskit/editor-common/utils';
|
|
|
29
29
|
|
|
30
30
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
31
31
|
import type { GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
32
|
-
// import { DropdownItem } from '../../../block-type/ui/ToolbarBlockType';
|
|
33
32
|
|
|
34
|
-
// TODO ED-15449 - unstub type?
|
|
35
33
|
import type { MenuItem } from '@atlaskit/editor-common/ui-menu';
|
|
36
34
|
type DropdownItem = MenuItem & {
|
|
37
35
|
value: {
|
|
@@ -365,11 +363,17 @@ export class ContextualMenu extends Component<
|
|
|
365
363
|
this.toggleOpen();
|
|
366
364
|
break;
|
|
367
365
|
case 'merge':
|
|
368
|
-
mergeCellsWithAnalytics(editorAnalyticsAPI)(
|
|
366
|
+
mergeCellsWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(
|
|
367
|
+
state,
|
|
368
|
+
dispatch,
|
|
369
|
+
);
|
|
369
370
|
this.toggleOpen();
|
|
370
371
|
break;
|
|
371
372
|
case 'split':
|
|
372
|
-
splitCellWithAnalytics(editorAnalyticsAPI)(
|
|
373
|
+
splitCellWithAnalytics(editorAnalyticsAPI)(INPUT_METHOD.CONTEXT_MENU)(
|
|
374
|
+
state,
|
|
375
|
+
dispatch,
|
|
376
|
+
);
|
|
373
377
|
this.toggleOpen();
|
|
374
378
|
break;
|
|
375
379
|
case 'distribute_columns':
|
|
@@ -511,12 +515,11 @@ export class ContextualMenu extends Component<
|
|
|
511
515
|
// TargetCellPosition could be outdated: https://product-fabric.atlassian.net/browse/ED-8129
|
|
512
516
|
const { targetCellPosition } = getPluginState(editorView.state);
|
|
513
517
|
const { state, dispatch } = editorView;
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
);
|
|
518
|
+
setColorWithAnalytics(editorAnalyticsAPI)(
|
|
519
|
+
INPUT_METHOD.CONTEXT_MENU,
|
|
520
|
+
color,
|
|
521
|
+
targetCellPosition,
|
|
522
|
+
)(state, dispatch);
|
|
520
523
|
this.toggleOpen();
|
|
521
524
|
};
|
|
522
525
|
}
|
|
@@ -2,7 +2,6 @@ import React, { SyntheticEvent } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { WrappedComponentProps, injectIntl } from 'react-intl-next';
|
|
4
4
|
|
|
5
|
-
// import { MessageDescriptor } from '../../../../types/i18n';
|
|
6
5
|
import { MessageDescriptor } from 'react-intl-next';
|
|
7
6
|
import { TableCssClassName as ClassName } from '../../types';
|
|
8
7
|
|
|
@@ -30,7 +29,7 @@ const DeleteButton = ({
|
|
|
30
29
|
>
|
|
31
30
|
<button
|
|
32
31
|
type="button"
|
|
33
|
-
|
|
32
|
+
aria-label={formatMessage(removeLabel, { 0: 1 })}
|
|
34
33
|
className={ClassName.CONTROLS_DELETE_BUTTON}
|
|
35
34
|
onMouseDown={onClick}
|
|
36
35
|
onMouseMove={(e) => e.preventDefault()}
|
|
@@ -12,7 +12,6 @@ import { createPortal } from 'react-dom';
|
|
|
12
12
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
13
13
|
import { akEditorTableNumberColumnWidth } from '@atlaskit/editor-shared-styles';
|
|
14
14
|
|
|
15
|
-
// import { closestElement } from '../../../../utils/dom';
|
|
16
15
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
17
16
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
18
17
|
import { clearHoverSelection, hoverColumns, hoverRows } from '../../commands';
|
|
@@ -10,7 +10,6 @@ import { WrappedComponentProps, injectIntl } from 'react-intl-next';
|
|
|
10
10
|
|
|
11
11
|
import { Popup } from '@atlaskit/editor-common/ui';
|
|
12
12
|
|
|
13
|
-
// import { closestElement } from '../../../../utils/dom';
|
|
14
13
|
import { closestElement } from '@atlaskit/editor-common/utils';
|
|
15
14
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
15
|
import {
|
|
@@ -107,8 +107,7 @@ class LayoutButton extends React.Component<Props & WrappedComponentProps, any> {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
renderSticky(button: JSX.Element, targetRef: Node, tableRef: Node) {
|
|
110
|
-
|
|
111
|
-
const title = 'TODO MISSING TITLE';
|
|
110
|
+
const title = this.getTitle();
|
|
112
111
|
|
|
113
112
|
if (
|
|
114
113
|
!(targetRef instanceof HTMLElement) ||
|
|
@@ -146,8 +145,7 @@ class LayoutButton extends React.Component<Props & WrappedComponentProps, any> {
|
|
|
146
145
|
return null;
|
|
147
146
|
}
|
|
148
147
|
|
|
149
|
-
|
|
150
|
-
const title = 'TODO MISSING TITLE';
|
|
148
|
+
const title = this.getTitle();
|
|
151
149
|
|
|
152
150
|
return (
|
|
153
151
|
<Popup
|