@atlaskit/editor-plugin-table 9.2.0 → 9.3.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/CHANGELOG.md +18 -0
- package/dist/cjs/nodeviews/TableCell.js +0 -2
- package/dist/cjs/nodeviews/TableContainer.js +13 -2
- package/dist/cjs/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/cjs/nodeviews/TableResizer.js +5 -10
- package/dist/cjs/nodeviews/TableRow.js +0 -2
- package/dist/cjs/nodeviews/lazy-node-views.js +4 -16
- package/dist/cjs/nodeviews/table.js +2 -8
- package/dist/cjs/pm-plugins/commands/column-resize.js +1 -4
- package/dist/cjs/pm-plugins/commands/commands-with-analytics.js +4 -16
- package/dist/cjs/pm-plugins/commands/insert.js +4 -19
- package/dist/cjs/pm-plugins/commands/misc.js +3 -12
- package/dist/cjs/pm-plugins/decorations/plugin.js +1 -6
- package/dist/cjs/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/cjs/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/cjs/pm-plugins/drag-and-drop/commands.js +3 -12
- package/dist/cjs/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/cjs/pm-plugins/keymap.js +0 -2
- package/dist/cjs/pm-plugins/main.js +1 -6
- package/dist/cjs/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/cjs/pm-plugins/table-resizing/plugin.js +0 -2
- package/dist/cjs/pm-plugins/table-resizing/utils/colgroup.js +1 -7
- package/dist/cjs/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/cjs/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/cjs/pm-plugins/table-resizing/utils/resize-state.js +1 -4
- package/dist/cjs/pm-plugins/table-width.js +1 -6
- package/dist/cjs/pm-plugins/transforms/column-width.js +1 -4
- package/dist/cjs/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/cjs/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/cjs/pm-plugins/transforms/split.js +0 -2
- package/dist/cjs/pm-plugins/utils/alignment.js +1 -4
- package/dist/cjs/pm-plugins/utils/decoration.js +4 -16
- package/dist/cjs/pm-plugins/utils/drag-menu.js +1 -4
- package/dist/cjs/pm-plugins/utils/nodes.js +0 -3
- package/dist/cjs/pm-plugins/utils/paste.js +4 -0
- package/dist/cjs/pm-plugins/utils/row-controls.js +1 -4
- package/dist/cjs/tablePlugin.js +12 -10
- package/dist/cjs/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/cjs/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -4
- package/dist/cjs/ui/TableFloatingControls/RowControls/DragControls.js +1 -4
- package/dist/cjs/ui/TableFloatingControls/index.js +1 -4
- package/dist/cjs/ui/toolbar.js +3 -12
- package/dist/es2019/nodeviews/TableCell.js +0 -2
- package/dist/es2019/nodeviews/TableContainer.js +13 -2
- package/dist/es2019/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/es2019/nodeviews/TableResizer.js +5 -10
- package/dist/es2019/nodeviews/TableRow.js +0 -2
- package/dist/es2019/nodeviews/lazy-node-views.js +4 -16
- package/dist/es2019/nodeviews/table.js +2 -8
- package/dist/es2019/pm-plugins/commands/column-resize.js +1 -4
- package/dist/es2019/pm-plugins/commands/commands-with-analytics.js +6 -24
- package/dist/es2019/pm-plugins/commands/delete.js +1 -4
- package/dist/es2019/pm-plugins/commands/insert.js +5 -23
- package/dist/es2019/pm-plugins/commands/misc.js +3 -12
- package/dist/es2019/pm-plugins/decorations/plugin.js +1 -6
- package/dist/es2019/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/es2019/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/es2019/pm-plugins/drag-and-drop/commands.js +4 -16
- package/dist/es2019/pm-plugins/drag-and-drop/plugin.js +2 -8
- package/dist/es2019/pm-plugins/keymap.js +0 -3
- package/dist/es2019/pm-plugins/main.js +1 -6
- package/dist/es2019/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/plugin.js +0 -3
- package/dist/es2019/pm-plugins/table-resizing/utils/colgroup.js +2 -11
- package/dist/es2019/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-column.js +1 -4
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/es2019/pm-plugins/table-resizing/utils/resize-state.js +2 -8
- package/dist/es2019/pm-plugins/table-resizing/utils/scale-table.js +4 -16
- package/dist/es2019/pm-plugins/table-width.js +1 -6
- package/dist/es2019/pm-plugins/transforms/column-width.js +2 -8
- package/dist/es2019/pm-plugins/transforms/delete-columns.js +1 -4
- package/dist/es2019/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/es2019/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/es2019/pm-plugins/transforms/split.js +0 -2
- package/dist/es2019/pm-plugins/utils/alignment.js +1 -4
- package/dist/es2019/pm-plugins/utils/decoration.js +4 -16
- package/dist/es2019/pm-plugins/utils/drag-menu.js +2 -8
- package/dist/es2019/pm-plugins/utils/nodes.js +0 -3
- package/dist/es2019/pm-plugins/utils/paste.js +5 -4
- package/dist/es2019/pm-plugins/utils/row-controls.js +1 -4
- package/dist/es2019/pm-plugins/utils/snapping.js +1 -4
- package/dist/es2019/tablePlugin.js +12 -10
- package/dist/es2019/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/es2019/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -4
- package/dist/es2019/ui/TableFloatingControls/RowControls/DragControls.js +1 -4
- package/dist/es2019/ui/TableFloatingControls/index.js +1 -5
- package/dist/es2019/ui/event-handlers.js +1 -4
- package/dist/es2019/ui/toolbar.js +9 -36
- package/dist/esm/nodeviews/TableCell.js +0 -2
- package/dist/esm/nodeviews/TableContainer.js +13 -2
- package/dist/esm/nodeviews/TableNodeViewBase.js +0 -2
- package/dist/esm/nodeviews/TableResizer.js +5 -10
- package/dist/esm/nodeviews/TableRow.js +0 -2
- package/dist/esm/nodeviews/lazy-node-views.js +4 -16
- package/dist/esm/nodeviews/table.js +2 -8
- package/dist/esm/pm-plugins/commands/column-resize.js +1 -4
- package/dist/esm/pm-plugins/commands/commands-with-analytics.js +4 -16
- package/dist/esm/pm-plugins/commands/insert.js +4 -19
- package/dist/esm/pm-plugins/commands/misc.js +3 -12
- package/dist/esm/pm-plugins/decorations/plugin.js +1 -6
- package/dist/esm/pm-plugins/decorations/utils/column-resizing.js +1 -4
- package/dist/esm/pm-plugins/drag-and-drop/commands-with-analytics.js +3 -12
- package/dist/esm/pm-plugins/drag-and-drop/commands.js +3 -12
- package/dist/esm/pm-plugins/drag-and-drop/plugin.js +1 -4
- package/dist/esm/pm-plugins/keymap.js +0 -3
- package/dist/esm/pm-plugins/main.js +1 -6
- package/dist/esm/pm-plugins/table-resizing/event-handlers.js +1 -4
- package/dist/esm/pm-plugins/table-resizing/plugin.js +0 -3
- package/dist/esm/pm-plugins/table-resizing/utils/colgroup.js +1 -7
- package/dist/esm/pm-plugins/table-resizing/utils/column-state.js +1 -4
- package/dist/esm/pm-plugins/table-resizing/utils/content-width.js +0 -8
- package/dist/esm/pm-plugins/table-resizing/utils/resize-logic.js +2 -10
- package/dist/esm/pm-plugins/table-resizing/utils/resize-state.js +1 -4
- package/dist/esm/pm-plugins/table-width.js +1 -6
- package/dist/esm/pm-plugins/transforms/column-width.js +1 -4
- package/dist/esm/pm-plugins/transforms/fix-tables.js +3 -15
- package/dist/esm/pm-plugins/transforms/replace-table.js +1 -4
- package/dist/esm/pm-plugins/transforms/split.js +0 -2
- package/dist/esm/pm-plugins/utils/alignment.js +1 -4
- package/dist/esm/pm-plugins/utils/decoration.js +4 -16
- package/dist/esm/pm-plugins/utils/drag-menu.js +1 -4
- package/dist/esm/pm-plugins/utils/nodes.js +0 -3
- package/dist/esm/pm-plugins/utils/paste.js +4 -0
- package/dist/esm/pm-plugins/utils/row-controls.js +1 -4
- package/dist/esm/tablePlugin.js +12 -10
- package/dist/esm/ui/FloatingInsertButton/getPopupOptions.js +0 -6
- package/dist/esm/ui/TableFloatingColumnControls/ColumnControls/index.js +1 -4
- package/dist/esm/ui/TableFloatingControls/RowControls/DragControls.js +1 -4
- package/dist/esm/ui/TableFloatingControls/index.js +1 -4
- package/dist/esm/ui/toolbar.js +3 -12
- package/dist/types/nodeviews/TableResizer.d.ts +2 -1
- package/dist/types-ts4.5/nodeviews/TableResizer.d.ts +2 -1
- package/package.json +11 -5
- package/src/nodeviews/TableCell.ts +0 -2
- package/src/nodeviews/TableComponent.tsx +1 -1
- package/src/nodeviews/TableContainer.tsx +12 -1
- package/src/nodeviews/TableNodeViewBase.ts +0 -2
- package/src/nodeviews/TableResizer.tsx +9 -5
- package/src/nodeviews/TableRow.ts +0 -2
- package/src/nodeviews/lazy-node-views.ts +0 -8
- package/src/nodeviews/table.tsx +0 -4
- package/src/pm-plugins/commands/column-resize.ts +0 -2
- package/src/pm-plugins/commands/commands-with-analytics.ts +0 -12
- package/src/pm-plugins/commands/delete.ts +0 -2
- package/src/pm-plugins/commands/insert.ts +0 -12
- package/src/pm-plugins/commands/misc.ts +0 -6
- package/src/pm-plugins/decorations/plugin.ts +0 -4
- package/src/pm-plugins/decorations/utils/column-resizing.ts +0 -2
- package/src/pm-plugins/drag-and-drop/commands-with-analytics.ts +0 -6
- package/src/pm-plugins/drag-and-drop/commands.ts +0 -8
- package/src/pm-plugins/drag-and-drop/plugin.ts +0 -4
- package/src/pm-plugins/keymap.ts +0 -2
- package/src/pm-plugins/main.ts +0 -4
- package/src/pm-plugins/table-resizing/event-handlers.ts +0 -2
- package/src/pm-plugins/table-resizing/plugin.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/colgroup.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/column-state.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/content-width.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/resize-column.ts +0 -2
- package/src/pm-plugins/table-resizing/utils/resize-logic.ts +0 -6
- package/src/pm-plugins/table-resizing/utils/resize-state.ts +0 -4
- package/src/pm-plugins/table-resizing/utils/scale-table.ts +0 -8
- package/src/pm-plugins/table-width.ts +0 -4
- package/src/pm-plugins/transforms/column-width.ts +0 -4
- package/src/pm-plugins/transforms/delete-columns.ts +0 -2
- package/src/pm-plugins/transforms/fix-tables.ts +0 -8
- package/src/pm-plugins/transforms/replace-table.ts +0 -2
- package/src/pm-plugins/transforms/split.ts +0 -2
- package/src/pm-plugins/utils/alignment.ts +0 -2
- package/src/pm-plugins/utils/decoration.ts +0 -8
- package/src/pm-plugins/utils/drag-menu.ts +0 -4
- package/src/pm-plugins/utils/nodes.ts +0 -2
- package/src/pm-plugins/utils/paste.ts +4 -2
- package/src/pm-plugins/utils/row-controls.ts +0 -2
- package/src/pm-plugins/utils/snapping.ts +0 -2
- package/src/tablePlugin.tsx +7 -2
- package/src/ui/FloatingInsertButton/getPopupOptions.ts +0 -4
- package/src/ui/TableFloatingColumnControls/ColumnControls/index.tsx +1 -3
- package/src/ui/TableFloatingColumnControls/index.tsx +1 -1
- package/src/ui/TableFloatingControls/RowControls/DragControls.tsx +0 -2
- package/src/ui/TableFloatingControls/index.tsx +1 -5
- package/src/ui/event-handlers.ts +0 -2
- package/src/ui/toolbar.tsx +0 -18
|
@@ -12,10 +12,7 @@ import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorWideL
|
|
|
12
12
|
import { TABLE_MAX_WIDTH } from './table-resizing/utils/consts';
|
|
13
13
|
import { ALIGN_START } from './utils/alignment';
|
|
14
14
|
export const pluginKey = new PluginKey('tableWidthPlugin');
|
|
15
|
-
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor
|
|
16
|
-
// Ignored via go/ees005
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
18
|
-
) => {
|
|
15
|
+
const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTableScalingEnabled, isTableAlignmentEnabled, isCommentEditor) => {
|
|
19
16
|
return new SafePlugin({
|
|
20
17
|
key: pluginKey,
|
|
21
18
|
state: {
|
|
@@ -117,8 +114,6 @@ const createPlugin = (dispatch, dispatchAnalyticsEvent, fullWidthEnabled, isTabl
|
|
|
117
114
|
}
|
|
118
115
|
if (referentialityTr) {
|
|
119
116
|
referentialityTr.steps.forEach(step => {
|
|
120
|
-
// Ignored via go/ees005
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
122
117
|
step.getMap().forEach((_, __, newStart, newEnd) => {
|
|
123
118
|
newState.doc.nodesBetween(newStart, newEnd, (node, pos) => {
|
|
124
119
|
if (node.type === table) {
|
|
@@ -13,10 +13,7 @@ import { scaleTableTo } from '../table-resizing/utils/scale-table';
|
|
|
13
13
|
* @param start
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
export const updateColumnWidths = (resizeState, table, start, api
|
|
17
|
-
// Ignored via go/ees005
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
19
|
-
) => tr => {
|
|
16
|
+
export const updateColumnWidths = (resizeState, table, start, api) => tr => {
|
|
20
17
|
const map = TableMap.get(table);
|
|
21
18
|
const updatedCellsAttrs = {};
|
|
22
19
|
const steps = [];
|
|
@@ -104,10 +101,7 @@ export const updateColumnWidths = (resizeState, table, start, api
|
|
|
104
101
|
* @param view
|
|
105
102
|
* @returns Updated transaction with rescaled columns for a given table
|
|
106
103
|
*/
|
|
107
|
-
export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, api, isCommentEditor = false
|
|
108
|
-
// Ignored via go/ees005
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
110
|
-
) => (table, view) => tr => {
|
|
104
|
+
export const rescaleColumns = (isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, api, isCommentEditor = false) => (table, view) => tr => {
|
|
111
105
|
if (!view) {
|
|
112
106
|
return tr;
|
|
113
107
|
}
|
|
@@ -194,10 +194,7 @@ function fixRowSpans(table) {
|
|
|
194
194
|
}
|
|
195
195
|
return table.type.createChecked(table.attrs, rows, table.marks);
|
|
196
196
|
}
|
|
197
|
-
export const deleteColumns = (rect, allowCustomStep, api, view, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false
|
|
198
|
-
// Ignored via go/ees005
|
|
199
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
200
|
-
) => tr => {
|
|
197
|
+
export const deleteColumns = (rect, allowCustomStep, api, view, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => tr => {
|
|
201
198
|
let updatedTr = tr;
|
|
202
199
|
updatedTr.setMeta(META_KEYS.OVERFLOW_TRIGGER, {
|
|
203
200
|
name: TABLE_OVERFLOW_CHANGE_TRIGGER.DELETED_COLUMN
|
|
@@ -36,10 +36,7 @@ const validateTableCellNodeAttrs = ({
|
|
|
36
36
|
//
|
|
37
37
|
// This row only spans two columns, yet it contains widths for 3.
|
|
38
38
|
// We remove the third width here, assumed duplicate content.
|
|
39
|
-
export const removeExtraneousColumnWidths = (node, basePos, tr, reportInvalidTableCellSpanAttrs
|
|
40
|
-
// Ignored via go/ees005
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
42
|
-
) => {
|
|
39
|
+
export const removeExtraneousColumnWidths = (node, basePos, tr, reportInvalidTableCellSpanAttrs) => {
|
|
43
40
|
let hasProblems = false;
|
|
44
41
|
tr = replaceCells(tr, node, basePos, cell => {
|
|
45
42
|
const {
|
|
@@ -92,10 +89,7 @@ export const fixTables = (tr, reportInvalidTableCellSpanAttrs) => {
|
|
|
92
89
|
//
|
|
93
90
|
// We use this when migrating TinyMCE tables for Confluence, for example:
|
|
94
91
|
// https://pug.jira-dev.com/wiki/spaces/AEC/pages/3362882215/How+do+we+map+TinyMCE+tables+to+Fabric+tables
|
|
95
|
-
export const fixAutoSizedTable = (view, tableNode, tableRef, tablePos, opts
|
|
96
|
-
// Ignored via go/ees005
|
|
97
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
98
|
-
) => {
|
|
92
|
+
export const fixAutoSizedTable = (view, tableNode, tableRef, tablePos, opts) => {
|
|
99
93
|
let {
|
|
100
94
|
tr
|
|
101
95
|
} = view.state;
|
|
@@ -138,9 +132,6 @@ const getLayoutBasedOnWidth = totalWidth => {
|
|
|
138
132
|
return 'default';
|
|
139
133
|
}
|
|
140
134
|
};
|
|
141
|
-
|
|
142
|
-
// Ignored via go/ees005
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
144
135
|
function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
|
|
145
136
|
const row = tableRef.querySelector('tr');
|
|
146
137
|
if (!row) {
|
|
@@ -165,10 +156,7 @@ function parseDOMColumnWidths(domAtPos, tableNode, tableStart, tableRef) {
|
|
|
165
156
|
}
|
|
166
157
|
|
|
167
158
|
// TODO: move to prosemirror-utils
|
|
168
|
-
const replaceCells = (tr, table, tablePos, modifyCell
|
|
169
|
-
// Ignored via go/ees005
|
|
170
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
171
|
-
) => {
|
|
159
|
+
const replaceCells = (tr, table, tablePos, modifyCell) => {
|
|
172
160
|
const rows = [];
|
|
173
161
|
let modifiedCells = 0;
|
|
174
162
|
for (let rowIndex = 0; rowIndex < table.childCount; rowIndex++) {
|
|
@@ -3,10 +3,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { findTable, isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
5
5
|
import { getSelectedTableInfo } from '../utils/analytics';
|
|
6
|
-
export const replaceSelectedTable = (state, content, inputMethod, editorAnalyticsAPI
|
|
7
|
-
// Ignored via go/ees005
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
9
|
-
) => {
|
|
6
|
+
export const replaceSelectedTable = (state, content, inputMethod, editorAnalyticsAPI) => {
|
|
10
7
|
if (isTableSelected(state.selection)) {
|
|
11
8
|
const table = findTable(state.selection);
|
|
12
9
|
if (table) {
|
|
@@ -7,8 +7,6 @@ import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
|
7
7
|
* @param columnStart - Start of the rect included (rect.left)
|
|
8
8
|
* @param columnEnd - End of the rect not included (rect.right)
|
|
9
9
|
*/
|
|
10
|
-
// Ignored via go/ees005
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
12
10
|
export function splitCellsInColumns(tr, tablePos, columnStart, columnEnd) {
|
|
13
11
|
const mapStart = tr.mapping.maps.length;
|
|
14
12
|
const table = tr.doc.nodeAt(tablePos);
|
|
@@ -11,7 +11,4 @@ export const normaliseAlignment = layout => layout === ALIGN_CENTER || layout ==
|
|
|
11
11
|
/**
|
|
12
12
|
* We don't want to switch alignment in Full-width editor
|
|
13
13
|
*/
|
|
14
|
-
export const shouldChangeAlignmentToCenterResized = (isTableAlignmentEnabled, tableNode, lineLength, updatedTableWidth
|
|
15
|
-
// Ignored via go/ees005
|
|
16
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
17
|
-
) => Boolean(isTableAlignmentEnabled && tableNode && tableNode.attrs.layout === ALIGN_START && lineLength && updatedTableWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH);
|
|
14
|
+
export const shouldChangeAlignmentToCenterResized = (isTableAlignmentEnabled, tableNode, lineLength, updatedTableWidth) => Boolean(isTableAlignmentEnabled && tableNode && tableNode.attrs.layout === ALIGN_START && lineLength && updatedTableWidth > lineLength && lineLength < FULL_WIDTH_EDITOR_CONTENT_WIDTH);
|
|
@@ -20,10 +20,7 @@ export const createCellHoverDecoration = cells => cells.map(cell => Decoration.n
|
|
|
20
20
|
}, {
|
|
21
21
|
key: TableDecorations.CELL_CONTROLS_HOVER
|
|
22
22
|
}));
|
|
23
|
-
export const createControlsHoverDecoration = (cells, type, tr, isDragAndDropEnable, hoveredIndexes, danger, selected
|
|
24
|
-
// Ignored via go/ees005
|
|
25
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
26
|
-
) => {
|
|
23
|
+
export const createControlsHoverDecoration = (cells, type, tr, isDragAndDropEnable, hoveredIndexes, danger, selected) => {
|
|
27
24
|
const table = findTable(tr.selection);
|
|
28
25
|
if (!table) {
|
|
29
26
|
return [];
|
|
@@ -146,10 +143,7 @@ export const createColumnControlsDecoration = selection => {
|
|
|
146
143
|
});
|
|
147
144
|
});
|
|
148
145
|
};
|
|
149
|
-
export const updateDecorations = (node, decorationSet, decorations, key
|
|
150
|
-
// Ignored via go/ees005
|
|
151
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
152
|
-
) => {
|
|
146
|
+
export const updateDecorations = (node, decorationSet, decorations, key) => {
|
|
153
147
|
const filteredDecorations = filterDecorationByKey(key, decorationSet);
|
|
154
148
|
const decorationSetFiltered = decorationSet.remove(filteredDecorations);
|
|
155
149
|
return decorationSetFiltered.add(node, decorations);
|
|
@@ -235,10 +229,7 @@ const makeArray = n => Array.from(Array(n).keys());
|
|
|
235
229
|
* we will add a new class on the last item for each cell,
|
|
236
230
|
* hence the second media will receive this class `ClassName.LAST_ITEM_IN_CELL`
|
|
237
231
|
*/
|
|
238
|
-
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl, nodeViewPortalProviderAPI
|
|
239
|
-
// Ignored via go/ees005
|
|
240
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
241
|
-
) => {
|
|
232
|
+
export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexTarget, includeTooltip = false, getIntl, nodeViewPortalProviderAPI) => {
|
|
242
233
|
const emptyResult = [[], []];
|
|
243
234
|
const table = findTable(tr.selection);
|
|
244
235
|
if (!table || !table.node) {
|
|
@@ -248,10 +239,7 @@ export const createResizeHandleDecoration = (tr, rowIndexTarget, columnEndIndexT
|
|
|
248
239
|
if (!map.width) {
|
|
249
240
|
return emptyResult;
|
|
250
241
|
}
|
|
251
|
-
const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode
|
|
252
|
-
// Ignored via go/ees005
|
|
253
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
254
|
-
) => {
|
|
242
|
+
const createResizerHandleDecoration = (cellColumnPositioning, columnIndex, rowIndex, cellPos, cellNode) => {
|
|
255
243
|
const decorationRenderKey = uuid();
|
|
256
244
|
const position = cellPos + cellNode.nodeSize - 1;
|
|
257
245
|
return Decoration.widget(position, () => {
|
|
@@ -36,10 +36,7 @@ import { getNewResizeStateFromSelectedColumns } from '../table-resizing/utils/re
|
|
|
36
36
|
import { hasMergedCellsInSelection, hasMergedCellsWithColumnNextToColumnIndex, hasMergedCellsWithRowNextToRowIndex } from './merged-cells';
|
|
37
37
|
import { getSelectedColumnIndexes, getSelectedRowIndexes } from './selection';
|
|
38
38
|
export const getTargetIndex = (selectedIndexes, direction) => Math[direction < 0 ? 'min' : 'max'](...selectedIndexes) + direction;
|
|
39
|
-
export const canMove = (sourceType, direction, totalItemsOfSourceTypeCount, selection, selectionRect
|
|
40
|
-
// Ignored via go/ees005
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
42
|
-
) => {
|
|
39
|
+
export const canMove = (sourceType, direction, totalItemsOfSourceTypeCount, selection, selectionRect) => {
|
|
43
40
|
if (!selectionRect) {
|
|
44
41
|
return false;
|
|
45
42
|
}
|
|
@@ -78,10 +75,7 @@ const defaultSelectionRect = {
|
|
|
78
75
|
right: 0,
|
|
79
76
|
bottom: 0
|
|
80
77
|
};
|
|
81
|
-
export const getDragMenuConfig = (direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, ariaNotifyPlugin, isCommentEditor = false
|
|
82
|
-
// Ignored via go/ees005
|
|
83
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
84
|
-
) => {
|
|
78
|
+
export const getDragMenuConfig = (direction, getEditorContainerWidth, hasMergedCellsInTable, editorView, api, tableMap, index, targetCellPosition, selectionRect, editorAnalyticsAPI, isHeaderRowRequired, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, ariaNotifyPlugin, isCommentEditor = false) => {
|
|
85
79
|
var _tableMap$height, _tableMap$height2, _tableMap$width, _tableMap$width2;
|
|
86
80
|
const {
|
|
87
81
|
selection
|
|
@@ -62,9 +62,6 @@ export const tablesHaveDifferentNoOfRows = (currentTable, previousTable) => {
|
|
|
62
62
|
const currentMap = TableMap.get(currentTable);
|
|
63
63
|
return prevMap.height !== currentMap.height;
|
|
64
64
|
};
|
|
65
|
-
|
|
66
|
-
// Ignored via go/ees005
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
68
65
|
function filterNearSelection(selection, findNode, predicate, defaultValue) {
|
|
69
66
|
const found = findNode(selection);
|
|
70
67
|
if (!found) {
|
|
@@ -2,6 +2,7 @@ import { getParentOfTypeCount } from '@atlaskit/editor-common/nesting';
|
|
|
2
2
|
import { flatmap, mapChildren, mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { Slice, Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
4
|
import { flatten, hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
6
7
|
import { getPluginState } from '../plugin-factory';
|
|
7
8
|
|
|
@@ -19,6 +20,9 @@ export const unwrapContentFromTable = maybeTable => {
|
|
|
19
20
|
maybeTable.descendants(maybeCell => {
|
|
20
21
|
if (maybeCell.type === tableCell || maybeCell.type === tableHeader) {
|
|
21
22
|
content.push(...flatten(maybeCell, false).map(child => child.node));
|
|
23
|
+
if (fg('platform_editor_nested_tables_paste_dupe_fix')) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
22
26
|
}
|
|
23
27
|
return true;
|
|
24
28
|
});
|
|
@@ -30,10 +34,7 @@ export const unwrapContentFromTable = maybeTable => {
|
|
|
30
34
|
// Flattens nested tables after a given nesting depth
|
|
31
35
|
// If this looks familiar, it's a heavily modified version of `mapFragment` which has been
|
|
32
36
|
// adjusted to support tracking nesting depth. This wasn't possible by using `mapFragment` directly
|
|
33
|
-
const unwrapNestedTables = (content, schema, unwrapNestDepth, currentNestDepth = 0
|
|
34
|
-
// Ignored via go/ees005
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
36
|
-
) => {
|
|
37
|
+
const unwrapNestedTables = (content, schema, unwrapNestDepth, currentNestDepth = 0) => {
|
|
37
38
|
const flattenNested = (node, tableDepth) => {
|
|
38
39
|
if (node.type === schema.nodes.table) {
|
|
39
40
|
if (tableDepth >= unwrapNestDepth) {
|
|
@@ -74,10 +74,7 @@ export const getRowsParams = rowsHeights => {
|
|
|
74
74
|
}
|
|
75
75
|
return rows;
|
|
76
76
|
};
|
|
77
|
-
export const getRowClassNames = (index, selection, hoveredRows = [], isInDanger, isResizing
|
|
78
|
-
// Ignored via go/ees005
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
80
|
-
) => {
|
|
77
|
+
export const getRowClassNames = (index, selection, hoveredRows = [], isInDanger, isResizing) => {
|
|
81
78
|
const classNames = [];
|
|
82
79
|
if (isRowSelected(index)(selection) || hoveredRows.indexOf(index) > -1 && !isResizing) {
|
|
83
80
|
classNames.push(ClassName.HOVERED_CELL_ACTIVE);
|
|
@@ -31,10 +31,7 @@ export const defaultTablePreserveSnappingWidths = (lengthOffset, editorContainer
|
|
|
31
31
|
/**
|
|
32
32
|
* Returns keys of guidelines that are closest to the table and within the snapGap
|
|
33
33
|
*/
|
|
34
|
-
export const findClosestSnap = (currentWidth, snapWidths, guidelines, snapGap = 0, tolerance = 0
|
|
35
|
-
// Ignored via go/ees005
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
37
|
-
) => {
|
|
34
|
+
export const findClosestSnap = (currentWidth, snapWidths, guidelines, snapGap = 0, tolerance = 0) => {
|
|
38
35
|
const closestGapIndex = snapWidths.reduce((prev, curr, index) => Math.abs(curr - currentWidth) < Math.abs(snapWidths[prev] - currentWidth) ? index : prev, 0);
|
|
39
36
|
const gap = Math.abs(snapWidths[closestGapIndex] - currentWidth);
|
|
40
37
|
if (gap < snapGap) {
|
|
@@ -110,7 +110,8 @@ const tablesPlugin = ({
|
|
|
110
110
|
},
|
|
111
111
|
actions: {
|
|
112
112
|
insertTable: analyticsPayload => (state, dispatch) => {
|
|
113
|
-
|
|
113
|
+
var _options$tableOptions;
|
|
114
|
+
if (options !== null && options !== void 0 && (_options$tableOptions = options.tableOptions) !== null && _options$tableOptions !== void 0 && _options$tableOptions.allowNestedTables && fg('platform_editor_use_nested_table_pm_nodes')) {
|
|
114
115
|
return editorCommandToPMCommand(insertTableWithNestingSupport({
|
|
115
116
|
isTableScalingEnabled: options === null || options === void 0 ? void 0 : options.isTableScalingEnabled,
|
|
116
117
|
isTableAlignmentEnabled: options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment,
|
|
@@ -172,11 +173,12 @@ const tablesPlugin = ({
|
|
|
172
173
|
}) : insertTableWithSize(options === null || options === void 0 ? void 0 : options.fullWidthEnabled, options === null || options === void 0 ? void 0 : options.isTableScalingEnabled, options === null || options === void 0 ? void 0 : options.tableOptions.allowTableAlignment, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, options === null || options === void 0 ? void 0 : options.isCommentEditor)
|
|
173
174
|
},
|
|
174
175
|
nodes() {
|
|
176
|
+
var _options$tableOptions2;
|
|
175
177
|
const {
|
|
176
178
|
allowColumnResizing
|
|
177
179
|
} = pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions);
|
|
178
180
|
// TODO: ED-25901 - We need to move this into a plugin config option so we don't accidentally enable nested nodes in Jira
|
|
179
|
-
const isNestingSupported = fg('platform_editor_use_nested_table_pm_nodes');
|
|
181
|
+
const isNestingSupported = (options === null || options === void 0 ? void 0 : (_options$tableOptions2 = options.tableOptions) === null || _options$tableOptions2 === void 0 ? void 0 : _options$tableOptions2.allowNestedTables) && fg('platform_editor_use_nested_table_pm_nodes');
|
|
180
182
|
return isNestingSupported ? [{
|
|
181
183
|
name: 'table',
|
|
182
184
|
node: tableNodeSpecWithFixedToDOM({
|
|
@@ -337,16 +339,16 @@ const tablesPlugin = ({
|
|
|
337
339
|
dispatchAnalyticsEvent,
|
|
338
340
|
dispatch
|
|
339
341
|
}) => {
|
|
340
|
-
var _options$fullWidthEna, _options$isTableScali, _options$
|
|
341
|
-
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$
|
|
342
|
+
var _options$fullWidthEna, _options$isTableScali, _options$tableOptions3, _options$isCommentEdi;
|
|
343
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing ? createTableWidthPlugin(dispatch, dispatchAnalyticsEvent, (_options$fullWidthEna = options.fullWidthEnabled) !== null && _options$fullWidthEna !== void 0 ? _options$fullWidthEna : false, (_options$isTableScali = options.isTableScalingEnabled) !== null && _options$isTableScali !== void 0 ? _options$isTableScali : false, (_options$tableOptions3 = options.tableOptions.allowTableResizing) !== null && _options$tableOptions3 !== void 0 ? _options$tableOptions3 : false, (_options$isCommentEdi = options.isCommentEditor) !== null && _options$isCommentEdi !== void 0 ? _options$isCommentEdi : false) : undefined;
|
|
342
344
|
}
|
|
343
345
|
}, {
|
|
344
346
|
name: 'tableWidthInCommentFix',
|
|
345
347
|
plugin: ({
|
|
346
348
|
dispatch
|
|
347
349
|
}) => {
|
|
348
|
-
var _options$
|
|
349
|
-
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing && options !== null && options !== void 0 && options.isCommentEditor ? createTableWidthInCommentFixPlugin(dispatch, (_options$
|
|
350
|
+
var _options$tableOptions4;
|
|
351
|
+
return options !== null && options !== void 0 && options.tableOptions.allowTableResizing && options !== null && options !== void 0 && options.isCommentEditor ? createTableWidthInCommentFixPlugin(dispatch, (_options$tableOptions4 = options.tableOptions.allowTableAlignment) !== null && _options$tableOptions4 !== void 0 ? _options$tableOptions4 : false) : undefined;
|
|
350
352
|
}
|
|
351
353
|
},
|
|
352
354
|
// TODO: should be deprecated and eventually replaced with 'tableAnalyticsPlugin'
|
|
@@ -356,8 +358,8 @@ const tablesPlugin = ({
|
|
|
356
358
|
dispatch,
|
|
357
359
|
dispatchAnalyticsEvent
|
|
358
360
|
}) => {
|
|
359
|
-
var _options$
|
|
360
|
-
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$
|
|
361
|
+
var _options$tableOptions5;
|
|
362
|
+
return createTableOverflowAnalyticsPlugin(dispatch, dispatchAnalyticsEvent, (_options$tableOptions5 = options === null || options === void 0 ? void 0 : options.tableOptions.allowTableResizing) !== null && _options$tableOptions5 !== void 0 ? _options$tableOptions5 : false);
|
|
361
363
|
}
|
|
362
364
|
}, {
|
|
363
365
|
name: 'tableAnalyticsPlugin',
|
|
@@ -551,7 +553,7 @@ const tablesPlugin = ({
|
|
|
551
553
|
keyshortcut: tooltip(toggleTable),
|
|
552
554
|
icon: () => /*#__PURE__*/React.createElement(IconTable, null),
|
|
553
555
|
action(insert, state) {
|
|
554
|
-
var _api$table;
|
|
556
|
+
var _api$table, _options$tableOptions6;
|
|
555
557
|
// see comment on tablesPlugin.getSharedState on usage
|
|
556
558
|
const tableState = api === null || api === void 0 ? void 0 : (_api$table = api.table) === null || _api$table === void 0 ? void 0 : _api$table.sharedState.currentState();
|
|
557
559
|
const tableNodeProps = {
|
|
@@ -567,7 +569,7 @@ const tablesPlugin = ({
|
|
|
567
569
|
tr
|
|
568
570
|
} = state;
|
|
569
571
|
// If the cursor is inside a table
|
|
570
|
-
if (hasParentNodeOfType(state.schema.nodes.table)(state.selection) && fg('platform_editor_use_nested_table_pm_nodes')) {
|
|
572
|
+
if (hasParentNodeOfType(state.schema.nodes.table)(state.selection) && options !== null && options !== void 0 && (_options$tableOptions6 = options.tableOptions) !== null && _options$tableOptions6 !== void 0 && _options$tableOptions6.allowNestedTables && fg('platform_editor_use_nested_table_pm_nodes')) {
|
|
571
573
|
// If the experiment is disabled, or we're trying to nest deeper than one level, we insert the table after the top table
|
|
572
574
|
if (editorExperiment('nested-tables-in-tables', false, {
|
|
573
575
|
exposure: true
|
|
@@ -32,9 +32,6 @@ function getRowOptions(index, isDragAndDropEnabled) {
|
|
|
32
32
|
}
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
-
|
|
36
|
-
// Ignored via go/ees005
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
38
35
|
function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDropEnabled) {
|
|
39
36
|
const options = {
|
|
40
37
|
alignX: 'end',
|
|
@@ -80,9 +77,6 @@ function getColumnOptions(index, tableContainer, hasNumberedColumns, isDragAndDr
|
|
|
80
77
|
}
|
|
81
78
|
return options;
|
|
82
79
|
}
|
|
83
|
-
|
|
84
|
-
// Ignored via go/ees005
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
86
80
|
function getPopupOptions(direction, index, hasNumberedColumns, isDragAndDropEnabled, tableContainer) {
|
|
87
81
|
switch (direction) {
|
|
88
82
|
case 'column':
|
|
@@ -137,10 +137,7 @@ export const ColumnControls = ({
|
|
|
137
137
|
var _getScrollOffset;
|
|
138
138
|
columnControlsRef.current.scrollLeft = (_getScrollOffset = getScrollOffset === null || getScrollOffset === void 0 ? void 0 : getScrollOffset()) !== null && _getScrollOffset !== void 0 ? _getScrollOffset : 0;
|
|
139
139
|
}
|
|
140
|
-
const generateHandleByType = (type, appearance, gridColumn, indexes
|
|
141
|
-
// Ignored via go/ees005
|
|
142
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
143
|
-
) => {
|
|
140
|
+
const generateHandleByType = (type, appearance, gridColumn, indexes) => {
|
|
144
141
|
var _rowHeights$reduce, _colWidths$reduce;
|
|
145
142
|
const isHover = type === 'hover';
|
|
146
143
|
const isPlaceholder = appearance === 'placeholder';
|
|
@@ -131,10 +131,7 @@ export const DragControls = ({
|
|
|
131
131
|
selectRows(selectedRowIndexes);
|
|
132
132
|
}
|
|
133
133
|
}, [rowIndex, selectRow, selectRows, selectedRowIndexes]);
|
|
134
|
-
const generateHandleByType = (type, appearance, gridRow, indexes
|
|
135
|
-
// Ignored via go/ees005
|
|
136
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
137
|
-
) => {
|
|
134
|
+
const generateHandleByType = (type, appearance, gridRow, indexes) => {
|
|
138
135
|
const isHover = type === 'hover';
|
|
139
136
|
const previewHeight = rowHeights.reduce((sum, v, i) => sum + v * (indexes.includes(i) ? 1 : 0), 0);
|
|
140
137
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useCallback } from 'react';
|
|
2
2
|
import { browser } from '@atlaskit/editor-common/browser';
|
|
3
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
4
3
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
5
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
5
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -83,9 +82,6 @@ export const TableFloatingControls = ({
|
|
|
83
82
|
hoverCell(rowIndex, 0)(state, dispatch);
|
|
84
83
|
}
|
|
85
84
|
}, [editorView, tableActive]);
|
|
86
|
-
const {
|
|
87
|
-
featureFlagsState
|
|
88
|
-
} = useSharedPluginState(api, ['featureFlags']);
|
|
89
85
|
if (!tableRef) {
|
|
90
86
|
return null;
|
|
91
87
|
}
|
|
@@ -95,7 +91,7 @@ export const TableFloatingControls = ({
|
|
|
95
91
|
// Ignored via go/ees005
|
|
96
92
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
97
93
|
const isNested = tablePos !== undefined && isTableNested(editorView.state, tablePos);
|
|
98
|
-
const shouldShowCornerControls =
|
|
94
|
+
const shouldShowCornerControls = isNested && !editorExperiment('nested-dnd', true);
|
|
99
95
|
return (
|
|
100
96
|
/*#__PURE__*/
|
|
101
97
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
@@ -384,10 +384,7 @@ export function handleTripleClick(view, pos) {
|
|
|
384
384
|
}
|
|
385
385
|
return false;
|
|
386
386
|
}
|
|
387
|
-
export const handleCut = (oldTr, oldState, newState, api, editorAnalyticsAPI, editorView, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false
|
|
388
|
-
// Ignored via go/ees005
|
|
389
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
390
|
-
) => {
|
|
387
|
+
export const handleCut = (oldTr, oldState, newState, api, editorAnalyticsAPI, editorView, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => {
|
|
391
388
|
const oldSelection = oldState.tr.selection;
|
|
392
389
|
let {
|
|
393
390
|
tr
|
|
@@ -44,10 +44,7 @@ import { TableCssClassName } from '../types';
|
|
|
44
44
|
import { FloatingAlignmentButtons } from './FloatingAlignmentButtons/FloatingAlignmentButtons';
|
|
45
45
|
export const getToolbarMenuConfig = (config, state, {
|
|
46
46
|
formatMessage
|
|
47
|
-
}, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown = false, areTableColumnWidthsFixed = false
|
|
48
|
-
// Ignored via go/ees005
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
50
|
-
) => {
|
|
47
|
+
}, editorAnalyticsAPI, isTableScalingWithFixedColumnWidthsOptionShown = false, areTableColumnWidthsFixed = false) => {
|
|
51
48
|
const optionItem = 'item-checkbox';
|
|
52
49
|
const options = [{
|
|
53
50
|
id: 'editor.table.lockColumnWidths',
|
|
@@ -129,10 +126,7 @@ export const getToolbarMenuConfig = (config, state, {
|
|
|
129
126
|
// with native widgets. It's enabled via a plugin config.
|
|
130
127
|
export const getToolbarCellOptionsConfig = (editorState, editorView, initialSelectionRect, {
|
|
131
128
|
formatMessage
|
|
132
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false
|
|
133
|
-
// Ignored via go/ees005
|
|
134
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
135
|
-
) => {
|
|
129
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
136
130
|
var _pluginState$pluginCo, _pluginState$pluginCo2;
|
|
137
131
|
const {
|
|
138
132
|
top,
|
|
@@ -349,10 +343,7 @@ const getClosestSelectionOrTableRect = state => {
|
|
|
349
343
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
350
344
|
return isSelectionType(selection, 'cell') ? getSelectionRect(selection) : tableRect;
|
|
351
345
|
};
|
|
352
|
-
export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false
|
|
353
|
-
// Ignored via go/ees005
|
|
354
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
355
|
-
) => config => (state, intl) => {
|
|
346
|
+
export const getToolbarConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, getEditorFeatureFlags, getEditorView, options, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false) => config => (state, intl) => {
|
|
356
347
|
const tableObject = findTable(state.selection);
|
|
357
348
|
const pluginState = getPluginState(state);
|
|
358
349
|
const resizeState = tableResizingPluginKey.getState(state);
|
|
@@ -461,10 +452,7 @@ const separator = hidden => {
|
|
|
461
452
|
};
|
|
462
453
|
const getCellItems = (state, view, {
|
|
463
454
|
formatMessage
|
|
464
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false
|
|
465
|
-
// Ignored via go/ees005
|
|
466
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
467
|
-
) => {
|
|
455
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, shouldUseIncreasedScalingPercent = false, isCommentEditor = false) => {
|
|
468
456
|
const initialSelectionRect = getClosestSelectionRect(state);
|
|
469
457
|
if (initialSelectionRect) {
|
|
470
458
|
const cellOptions = getToolbarCellOptionsConfig(state, view, initialSelectionRect, {
|
|
@@ -476,10 +464,7 @@ const getCellItems = (state, view, {
|
|
|
476
464
|
}
|
|
477
465
|
return [];
|
|
478
466
|
};
|
|
479
|
-
const getDistributeConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false
|
|
480
|
-
// Ignored via go/ees005
|
|
481
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
482
|
-
) => (state, dispatch, editorView) => {
|
|
467
|
+
const getDistributeConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => (state, dispatch, editorView) => {
|
|
483
468
|
const selectionOrTableRect = getClosestSelectionOrTableRect(state);
|
|
484
469
|
if (!editorView || !selectionOrTableRect) {
|
|
485
470
|
return false;
|
|
@@ -496,10 +481,7 @@ const getDistributeConfig = (getEditorContainerWidth, api, editorAnalyticsAPI, i
|
|
|
496
481
|
// fixed column button should be in this function call in the future
|
|
497
482
|
const getColumnSettingItems = (editorState, editorView, {
|
|
498
483
|
formatMessage
|
|
499
|
-
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false
|
|
500
|
-
// Ignored via go/ees005
|
|
501
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
502
|
-
) => {
|
|
484
|
+
}, getEditorContainerWidth, api, editorAnalyticsAPI, isTableScalingEnabled = false, isTableFixedColumnWidthsOptionEnabled = false, isCommentEditor = false) => {
|
|
503
485
|
var _newResizeStateWithAn2, _pluginState$pluginCo3;
|
|
504
486
|
const pluginState = getPluginState(editorState);
|
|
505
487
|
const selectionOrTableRect = getClosestSelectionOrTableRect(editorState);
|
|
@@ -529,10 +511,7 @@ const getColumnSettingItems = (editorState, editorView, {
|
|
|
529
511
|
};
|
|
530
512
|
const getColorPicker = (state, menu, {
|
|
531
513
|
formatMessage
|
|
532
|
-
}, editorAnalyticsAPI, getEditorView
|
|
533
|
-
// Ignored via go/ees005
|
|
534
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
535
|
-
) => {
|
|
514
|
+
}, editorAnalyticsAPI, getEditorView) => {
|
|
536
515
|
var _node$attrs;
|
|
537
516
|
const {
|
|
538
517
|
targetCellPosition,
|
|
@@ -591,10 +570,7 @@ const highlightColumnsHandler = (state, dispatch) => {
|
|
|
591
570
|
};
|
|
592
571
|
const getAlignmentOptionsConfig = (editorState, {
|
|
593
572
|
formatMessage
|
|
594
|
-
}, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor, isCommentEditor
|
|
595
|
-
// Ignored via go/ees005
|
|
596
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
597
|
-
) => {
|
|
573
|
+
}, editorAnalyticsAPI, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor, isCommentEditor) => {
|
|
598
574
|
const tableObject = findTable(editorState.selection);
|
|
599
575
|
if (!tableObject) {
|
|
600
576
|
return [];
|
|
@@ -669,10 +645,7 @@ const getSelectedAlignmentIcon = (alignmentIcons, selectedNode) => {
|
|
|
669
645
|
const selectedAlignment = selectedNode.attrs.layout;
|
|
670
646
|
return alignmentIcons.find(icon => icon.value === normaliseAlignment(selectedAlignment));
|
|
671
647
|
};
|
|
672
|
-
const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor
|
|
673
|
-
// Ignored via go/ees005
|
|
674
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
675
|
-
) => {
|
|
648
|
+
const isLayoutOptionDisabled = (selectedNode, getEditorContainerWidth, getDomRef, editorView, shouldUseIncreasedScalingPercent, isFullWidthEditor) => {
|
|
676
649
|
const {
|
|
677
650
|
lineLength
|
|
678
651
|
} = getEditorContainerWidth();
|
|
@@ -38,8 +38,6 @@ function delayUntilIdle(cb) {
|
|
|
38
38
|
// eslint-disable-next-line require-unicode-regexp
|
|
39
39
|
var cssVariablePattern = /^VAR\(--.*\)$/;
|
|
40
40
|
var TableCell = /*#__PURE__*/function (_TableNodeView) {
|
|
41
|
-
// Ignored via go/ees005
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
43
41
|
function TableCell(node, view, getPos, eventDispatcher, editorAnalyticsAPI) {
|
|
44
42
|
var _this;
|
|
45
43
|
_classCallCheck(this, TableCell);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import React, { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
3
4
|
import classNames from 'classnames';
|
|
@@ -5,6 +6,7 @@ import { CHANGE_ALIGNMENT_REASON, INPUT_METHOD } from '@atlaskit/editor-common/a
|
|
|
5
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
7
|
import { getTableContainerWidth } from '@atlaskit/editor-common/node-width';
|
|
7
8
|
import { akEditorDefaultLayoutWidth, akEditorGutterPaddingDynamic, akEditorMobileBreakoutPoint } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
10
|
import { setTableAlignmentWithTableContentWithPosWithAnalytics } from '../pm-plugins/commands/commands-with-analytics';
|
|
9
11
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
10
12
|
import { TABLE_MAX_WIDTH, TABLE_OFFSET_IN_COMMENT_EDITOR } from '../pm-plugins/table-resizing/utils/consts';
|
|
@@ -246,7 +248,7 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
246
248
|
,
|
|
247
249
|
className: ClassName.TABLE_RESIZER_CONTAINER,
|
|
248
250
|
ref: containerRef
|
|
249
|
-
}, isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer
|
|
251
|
+
}, fg('platform_editor_live_page_prevent_table_recreation') ? null : isLivePageViewMode ? /*#__PURE__*/React.createElement(InnerContainer
|
|
250
252
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
|
|
251
253
|
, {
|
|
252
254
|
className: className,
|
|
@@ -263,7 +265,16 @@ export var ResizableTableContainer = /*#__PURE__*/React.memo(function (_ref4) {
|
|
|
263
265
|
React.createElement(TableResizer, tableResizerProps, /*#__PURE__*/React.createElement(InnerContainer, {
|
|
264
266
|
className: className,
|
|
265
267
|
node: node
|
|
266
|
-
}, children)))
|
|
268
|
+
}, children)), fg('platform_editor_live_page_prevent_table_recreation') ?
|
|
269
|
+
/*#__PURE__*/
|
|
270
|
+
// Ignored via go/ees005
|
|
271
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
272
|
+
React.createElement(TableResizer, _extends({}, tableResizerProps, {
|
|
273
|
+
disabled: isLivePageViewMode
|
|
274
|
+
}), /*#__PURE__*/React.createElement(InnerContainer, {
|
|
275
|
+
className: className,
|
|
276
|
+
node: node
|
|
277
|
+
}, children)) : null));
|
|
267
278
|
});
|
|
268
279
|
export var TableContainer = function TableContainer(_ref6) {
|
|
269
280
|
var children = _ref6.children,
|
|
@@ -5,8 +5,6 @@ var TableNodeView = /*#__PURE__*/_createClass(
|
|
|
5
5
|
/**
|
|
6
6
|
* @constructor
|
|
7
7
|
*/
|
|
8
|
-
// Ignored via go/ees005
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
10
8
|
function TableNodeView(node, view, getPos, eventDispatcher) {
|
|
11
9
|
_classCallCheck(this, TableNodeView);
|
|
12
10
|
this.node = node;
|