@atlaskit/editor-plugin-table 1.0.3 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/plugins/table/ui/FloatingContextualButton/index.js +3 -1
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +3 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +2 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/ui/FloatingContextualButton/index.js +3 -1
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +3 -1
- package/dist/es2019/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/ui/FloatingContextualButton/index.js +3 -1
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +3 -1
- package/dist/esm/plugins/table/ui/TableFloatingControls/NumberColumn/index.js +2 -1
- package/dist/esm/version.json +1 -1
- package/package.json +3 -3
- package/src/__tests__/integration/__fixtures__/paragraph-and-table-adf.ts +132 -0
- package/src/__tests__/integration/arrow-down-into-table.ts +24 -15
- package/src/__tests__/integration/deleting-empty-paragraph-under-table.ts +3 -3
- package/src/__tests__/integration/meta-arrowup-cursor-in-first-row.ts +1 -1
- package/src/__tests__/unit/copy-paste.ts +1 -1
- package/src/__tests__/unit/toolbar.ts +86 -2
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +7 -1
- package/src/__tests__/visual-regression/cell-options-menu.ts +1 -12
- package/src/plugins/table/ui/FloatingContextualButton/index.tsx +2 -0
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +2 -0
- package/src/plugins/table/ui/TableFloatingControls/NumberColumn/index.tsx +1 -0
- package/src/__tests__/integration/__fixtures__/paragraph-and-table-adf.json +0 -130
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4ee60bafc6d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ee60bafc6d) - ED-16603: Remove tooltips from VR tests and make them opt in. To opt-in, add `allowedSideEffects` when loading the page.
|
|
8
|
+
|
|
9
|
+
## 1.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`a0a35fe7fb1`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a0a35fe7fb1) - Renaming contentComponent event subject to contentComponentv2. Move errorStack attribute to nonPrivacySafeAttributes
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [`cb6dc027c6d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cb6dc027c6d) - [ux] Disable content editable on a table number column to prevent selection on the number column.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 1.0.3
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -118,7 +118,9 @@ var FloatingContextualButtonInner = /*#__PURE__*/function (_React$Component) {
|
|
|
118
118
|
selection: editorView.state.selection.toJSON(),
|
|
119
119
|
position: targetCellPosition,
|
|
120
120
|
docSize: editorView.state.doc.nodeSize,
|
|
121
|
-
error: error instanceof Error ? error.message : String(error)
|
|
121
|
+
error: error instanceof Error ? error.message : String(error)
|
|
122
|
+
},
|
|
123
|
+
nonPrivacySafeAttributes: {
|
|
122
124
|
errorStack: error instanceof Error ? error.stack : undefined
|
|
123
125
|
}
|
|
124
126
|
};
|
|
@@ -134,7 +134,9 @@ var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
134
134
|
selection: editorView.state.selection.toJSON(),
|
|
135
135
|
position: pos,
|
|
136
136
|
docSize: editorView.state.doc.nodeSize,
|
|
137
|
-
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
137
|
+
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
138
|
+
},
|
|
139
|
+
nonPrivacySafeAttributes: {
|
|
138
140
|
errorStack: error.stack || undefined
|
|
139
141
|
}
|
|
140
142
|
};
|
|
@@ -119,7 +119,8 @@ var NumberColumn = /*#__PURE__*/function (_Component) {
|
|
|
119
119
|
className: _types.TableCssClassName.NUMBERED_COLUMN,
|
|
120
120
|
style: {
|
|
121
121
|
marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined
|
|
122
|
-
}
|
|
122
|
+
},
|
|
123
|
+
contentEditable: false
|
|
123
124
|
}, rowHeights.map(function (rowHeight, index) {
|
|
124
125
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
125
126
|
key: "wrapper-".concat(index),
|
package/dist/cjs/version.json
CHANGED
|
@@ -69,7 +69,9 @@ export class FloatingContextualButtonInner extends React.Component {
|
|
|
69
69
|
selection: editorView.state.selection.toJSON(),
|
|
70
70
|
position: targetCellPosition,
|
|
71
71
|
docSize: editorView.state.doc.nodeSize,
|
|
72
|
-
error: error instanceof Error ? error.message : String(error)
|
|
72
|
+
error: error instanceof Error ? error.message : String(error)
|
|
73
|
+
},
|
|
74
|
+
nonPrivacySafeAttributes: {
|
|
73
75
|
errorStack: error instanceof Error ? error.stack : undefined
|
|
74
76
|
}
|
|
75
77
|
};
|
|
@@ -89,7 +89,9 @@ export class FloatingInsertButton extends React.Component {
|
|
|
89
89
|
selection: editorView.state.selection.toJSON(),
|
|
90
90
|
position: pos,
|
|
91
91
|
docSize: editorView.state.doc.nodeSize,
|
|
92
|
-
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
92
|
+
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
93
|
+
},
|
|
94
|
+
nonPrivacySafeAttributes: {
|
|
93
95
|
errorStack: error.stack || undefined
|
|
94
96
|
}
|
|
95
97
|
};
|
|
@@ -73,7 +73,8 @@ export default class NumberColumn extends Component {
|
|
|
73
73
|
className: ClassName.NUMBERED_COLUMN,
|
|
74
74
|
style: {
|
|
75
75
|
marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined
|
|
76
|
-
}
|
|
76
|
+
},
|
|
77
|
+
contentEditable: false
|
|
77
78
|
}, rowHeights.map((rowHeight, index) => /*#__PURE__*/React.createElement("div", {
|
|
78
79
|
key: `wrapper-${index}`,
|
|
79
80
|
className: this.getClassNames(index),
|
package/dist/es2019/version.json
CHANGED
|
@@ -91,7 +91,9 @@ export var FloatingContextualButtonInner = /*#__PURE__*/function (_React$Compone
|
|
|
91
91
|
selection: editorView.state.selection.toJSON(),
|
|
92
92
|
position: targetCellPosition,
|
|
93
93
|
docSize: editorView.state.doc.nodeSize,
|
|
94
|
-
error: error instanceof Error ? error.message : String(error)
|
|
94
|
+
error: error instanceof Error ? error.message : String(error)
|
|
95
|
+
},
|
|
96
|
+
nonPrivacySafeAttributes: {
|
|
95
97
|
errorStack: error instanceof Error ? error.stack : undefined
|
|
96
98
|
}
|
|
97
99
|
};
|
|
@@ -106,7 +106,9 @@ export var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
106
106
|
selection: editorView.state.selection.toJSON(),
|
|
107
107
|
position: pos,
|
|
108
108
|
docSize: editorView.state.doc.nodeSize,
|
|
109
|
-
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
109
|
+
error: error === null || error === void 0 ? void 0 : error.toString()
|
|
110
|
+
},
|
|
111
|
+
nonPrivacySafeAttributes: {
|
|
110
112
|
errorStack: error.stack || undefined
|
|
111
113
|
}
|
|
112
114
|
};
|
|
@@ -98,7 +98,8 @@ var NumberColumn = /*#__PURE__*/function (_Component) {
|
|
|
98
98
|
className: ClassName.NUMBERED_COLUMN,
|
|
99
99
|
style: {
|
|
100
100
|
marginTop: hasHeaderRow && this.props.stickyTop !== undefined ? rowHeights[0] : undefined
|
|
101
|
-
}
|
|
101
|
+
},
|
|
102
|
+
contentEditable: false
|
|
102
103
|
}, rowHeights.map(function (rowHeight, index) {
|
|
103
104
|
return /*#__PURE__*/React.createElement("div", {
|
|
104
105
|
key: "wrapper-".concat(index),
|
package/dist/esm/version.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@atlaskit/adf-schema": "^25.1.0",
|
|
22
|
-
"@atlaskit/editor-common": "^72.
|
|
22
|
+
"@atlaskit/editor-common": "^72.2.0",
|
|
23
23
|
"@atlaskit/editor-shared-styles": "^2.3.0",
|
|
24
24
|
"@atlaskit/editor-tables": "^2.2.0",
|
|
25
25
|
"@atlaskit/icon": "^21.11.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@atlaskit/analytics-next": "^8.3.3",
|
|
53
53
|
"@atlaskit/button": "^16.5.0",
|
|
54
|
-
"@atlaskit/editor-core": "^178.
|
|
54
|
+
"@atlaskit/editor-core": "^178.1.0",
|
|
55
55
|
"@atlaskit/editor-test-helpers": "^18.0.0",
|
|
56
56
|
"@atlaskit/link-provider": "^1.3.0",
|
|
57
57
|
"@atlaskit/logo": "^13.10.0",
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export const documentWithParagraphAndTable = (
|
|
2
|
+
isNumberColumnEnabled: boolean,
|
|
3
|
+
) => ({
|
|
4
|
+
version: 1,
|
|
5
|
+
type: 'doc',
|
|
6
|
+
content: [
|
|
7
|
+
{
|
|
8
|
+
type: 'paragraph',
|
|
9
|
+
content: [
|
|
10
|
+
{
|
|
11
|
+
type: 'text',
|
|
12
|
+
text: 'text',
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'table',
|
|
18
|
+
attrs: {
|
|
19
|
+
isNumberColumnEnabled,
|
|
20
|
+
layout: 'default',
|
|
21
|
+
localId: 'e1365400-6226-4bb9-b3f1-b80fd3ae640a',
|
|
22
|
+
},
|
|
23
|
+
content: [
|
|
24
|
+
{
|
|
25
|
+
type: 'tableRow',
|
|
26
|
+
content: [
|
|
27
|
+
{
|
|
28
|
+
type: 'tableHeader',
|
|
29
|
+
attrs: {},
|
|
30
|
+
content: [
|
|
31
|
+
{
|
|
32
|
+
type: 'paragraph',
|
|
33
|
+
content: [],
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'tableHeader',
|
|
39
|
+
attrs: {},
|
|
40
|
+
content: [
|
|
41
|
+
{
|
|
42
|
+
type: 'paragraph',
|
|
43
|
+
content: [],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'tableHeader',
|
|
49
|
+
attrs: {},
|
|
50
|
+
content: [
|
|
51
|
+
{
|
|
52
|
+
type: 'paragraph',
|
|
53
|
+
content: [],
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'tableRow',
|
|
61
|
+
content: [
|
|
62
|
+
{
|
|
63
|
+
type: 'tableCell',
|
|
64
|
+
attrs: {},
|
|
65
|
+
content: [
|
|
66
|
+
{
|
|
67
|
+
type: 'paragraph',
|
|
68
|
+
content: [],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'tableCell',
|
|
74
|
+
attrs: {},
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: 'paragraph',
|
|
78
|
+
content: [],
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'tableCell',
|
|
84
|
+
attrs: {},
|
|
85
|
+
content: [
|
|
86
|
+
{
|
|
87
|
+
type: 'paragraph',
|
|
88
|
+
content: [],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
type: 'tableRow',
|
|
96
|
+
content: [
|
|
97
|
+
{
|
|
98
|
+
type: 'tableCell',
|
|
99
|
+
attrs: {},
|
|
100
|
+
content: [
|
|
101
|
+
{
|
|
102
|
+
type: 'paragraph',
|
|
103
|
+
content: [],
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
type: 'tableCell',
|
|
109
|
+
attrs: {},
|
|
110
|
+
content: [
|
|
111
|
+
{
|
|
112
|
+
type: 'paragraph',
|
|
113
|
+
content: [],
|
|
114
|
+
},
|
|
115
|
+
],
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
type: 'tableCell',
|
|
119
|
+
attrs: {},
|
|
120
|
+
content: [
|
|
121
|
+
{
|
|
122
|
+
type: 'paragraph',
|
|
123
|
+
content: [],
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
});
|
|
@@ -8,19 +8,10 @@ import {
|
|
|
8
8
|
goToEditorTestingWDExample,
|
|
9
9
|
mountEditor,
|
|
10
10
|
} from '@atlaskit/editor-test-helpers/testing-example-page';
|
|
11
|
-
import
|
|
11
|
+
import { documentWithParagraphAndTable } from './__fixtures__/paragraph-and-table-adf';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
// cursor would go behind the table when pressing arrow down
|
|
16
|
-
// https://product-fabric.atlassian.net/browse/ED-14046
|
|
17
|
-
//
|
|
18
|
-
// Skipping in firefox as there is a known bug
|
|
19
|
-
// Needs to be fixed in https://product-fabric.atlassian.net/servicedesk/customer/portal/99/DTR-155?created=true
|
|
20
|
-
BrowserTestCase(
|
|
21
|
-
'arrow-down-into-table.ts: pressing arrow down above table should move cursor into first row',
|
|
22
|
-
{ skip: ['firefox'] },
|
|
23
|
-
async (client: any) => {
|
|
13
|
+
const testArrowDown =
|
|
14
|
+
(isNumberedColumnEnabled: boolean) => async (client: any) => {
|
|
24
15
|
const page = await goToEditorTestingWDExample(
|
|
25
16
|
client,
|
|
26
17
|
'editor-plugin-table',
|
|
@@ -28,11 +19,29 @@ BrowserTestCase(
|
|
|
28
19
|
await mountEditor(page, {
|
|
29
20
|
appearance: fullpage.appearance,
|
|
30
21
|
allowTables: {},
|
|
31
|
-
defaultValue:
|
|
22
|
+
defaultValue: documentWithParagraphAndTable(isNumberedColumnEnabled),
|
|
32
23
|
});
|
|
33
24
|
|
|
34
25
|
await setProseMirrorTextSelection(page, { anchor: 5 });
|
|
35
26
|
await page.keys('ArrowDown');
|
|
36
|
-
await expectToMatchSelection(page, { type: 'text',
|
|
37
|
-
}
|
|
27
|
+
await expectToMatchSelection(page, { type: 'text', anchor: 10, head: 10 });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// This keyboard navigation is actually browser functionality
|
|
31
|
+
// But there was a div on our end that caused a bug where the
|
|
32
|
+
// cursor would go behind the table when pressing arrow down
|
|
33
|
+
// https://product-fabric.atlassian.net/browse/ED-14046
|
|
34
|
+
//
|
|
35
|
+
// Skipping in firefox as there is a known bug
|
|
36
|
+
// Needs to be fixed in https://product-fabric.atlassian.net/servicedesk/customer/portal/99/DTR-155?created=true
|
|
37
|
+
BrowserTestCase(
|
|
38
|
+
'arrow-down-into-table.ts: pressing arrow down above table should move cursor into first row',
|
|
39
|
+
{ skip: ['firefox'] },
|
|
40
|
+
testArrowDown(false),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
BrowserTestCase(
|
|
44
|
+
'arrow-down-into-table.ts: pressing arrow down above table should move cursor into first row for a numbered table',
|
|
45
|
+
{ skip: ['firefox'] },
|
|
46
|
+
testArrowDown(true),
|
|
38
47
|
);
|
|
@@ -33,7 +33,7 @@ BrowserTestCase(
|
|
|
33
33
|
|
|
34
34
|
await setProseMirrorTextSelection(page, { anchor: 45 });
|
|
35
35
|
await page.keys('Backspace');
|
|
36
|
-
await expectToMatchSelection(page, { type: 'text',
|
|
36
|
+
await expectToMatchSelection(page, { type: 'text', anchor: 40, head: 40 });
|
|
37
37
|
const doc = await page.$eval(editable, getDocFromElement);
|
|
38
38
|
expect(doc).toMatchCustomDocSnapshot(testName);
|
|
39
39
|
},
|
|
@@ -56,7 +56,7 @@ BrowserTestCase(
|
|
|
56
56
|
|
|
57
57
|
await setProseMirrorTextSelection(page, { anchor: 45 });
|
|
58
58
|
await page.keys('Backspace');
|
|
59
|
-
await expectToMatchSelection(page, { type: 'text',
|
|
59
|
+
await expectToMatchSelection(page, { type: 'text', anchor: 40, head: 40 });
|
|
60
60
|
const doc = await page.$eval(editable, getDocFromElement);
|
|
61
61
|
expect(doc).toMatchCustomDocSnapshot(testName);
|
|
62
62
|
},
|
|
@@ -79,7 +79,7 @@ BrowserTestCase(
|
|
|
79
79
|
|
|
80
80
|
await setProseMirrorTextSelection(page, { anchor: 45 });
|
|
81
81
|
await page.keys('Backspace');
|
|
82
|
-
await expectToMatchSelection(page, { type: 'text',
|
|
82
|
+
await expectToMatchSelection(page, { type: 'text', anchor: 40, head: 40 });
|
|
83
83
|
const doc = await page.$eval(editable, getDocFromElement);
|
|
84
84
|
expect(doc).toMatchCustomDocSnapshot(testName);
|
|
85
85
|
},
|
|
@@ -154,7 +154,7 @@ describe('table plugin', () => {
|
|
|
154
154
|
table({ localId: TABLE_LOCAL_ID })(
|
|
155
155
|
tr(th()(p('1')), th()(p('2')), th()(p('3'))),
|
|
156
156
|
tr(td()(p('4')), td()(p('5')), td()(p('6'))),
|
|
157
|
-
tr(td()(p('7')),
|
|
157
|
+
tr(td()(p('7')), td()(p('1')), td()(p('9'))),
|
|
158
158
|
),
|
|
159
159
|
),
|
|
160
160
|
);
|
|
@@ -14,6 +14,10 @@ import {
|
|
|
14
14
|
tr as row,
|
|
15
15
|
table,
|
|
16
16
|
td,
|
|
17
|
+
tr,
|
|
18
|
+
tdEmpty,
|
|
19
|
+
thEmpty,
|
|
20
|
+
th,
|
|
17
21
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
18
22
|
import type {
|
|
19
23
|
Command,
|
|
@@ -146,8 +150,7 @@ describe('getToolbarMenuConfig', () => {
|
|
|
146
150
|
|
|
147
151
|
describe('getToolbarCellOptionsConfig', () => {
|
|
148
152
|
const createEditor = createProsemirrorEditorFactory();
|
|
149
|
-
const
|
|
150
|
-
doc: doc(table()(row(td()(p('1{cursor}'))))),
|
|
153
|
+
const props = {
|
|
151
154
|
preset: new Preset<LightEditorPlugin>().add([
|
|
152
155
|
tablePlugin,
|
|
153
156
|
{
|
|
@@ -159,6 +162,10 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
159
162
|
},
|
|
160
163
|
]),
|
|
161
164
|
pluginKey,
|
|
165
|
+
};
|
|
166
|
+
const { editorView } = createEditor({
|
|
167
|
+
doc: doc(table()(row(td()(p('1{cursor}'))))),
|
|
168
|
+
...props,
|
|
162
169
|
});
|
|
163
170
|
const { state } = editorView;
|
|
164
171
|
const getEditorContainerWidth = () => ({ width: 500 });
|
|
@@ -177,6 +184,13 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
177
184
|
undefined,
|
|
178
185
|
);
|
|
179
186
|
|
|
187
|
+
beforeEach(() => {
|
|
188
|
+
jest.resetAllMocks();
|
|
189
|
+
(getMergedCellsPositions as Function as jest.Mock<{}>).mockImplementation(
|
|
190
|
+
() => () => [],
|
|
191
|
+
);
|
|
192
|
+
});
|
|
193
|
+
|
|
180
194
|
it('is a dropdown with the following dropdown items with the given order', () => {
|
|
181
195
|
const items = cellOptionsMenu.options as Array<DropdownOptionT<Command>>;
|
|
182
196
|
expect(items[0]).toMatchObject({
|
|
@@ -407,4 +421,74 @@ describe('getToolbarCellOptionsConfig', () => {
|
|
|
407
421
|
const isDisabled = distributeColumns.every((item) => item.disabled);
|
|
408
422
|
expect(isDisabled).toBeTruthy();
|
|
409
423
|
});
|
|
424
|
+
|
|
425
|
+
it('should disable distribute columns if selected cells are without colwidths', () => {
|
|
426
|
+
const { editorView } = createEditor({
|
|
427
|
+
doc: doc(
|
|
428
|
+
table()(
|
|
429
|
+
tr(th({})(p('{<cell}')), thEmpty, thEmpty),
|
|
430
|
+
tr(tdEmpty, td({})(p('{cell>}')), tdEmpty),
|
|
431
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
432
|
+
),
|
|
433
|
+
),
|
|
434
|
+
...props,
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
const { state } = editorView;
|
|
438
|
+
const rect = new Rect(1, 1, 2, 2);
|
|
439
|
+
|
|
440
|
+
const cellOptionsMenu = getToolbarCellOptionsConfig(
|
|
441
|
+
state,
|
|
442
|
+
editorView,
|
|
443
|
+
rect,
|
|
444
|
+
{
|
|
445
|
+
formatMessage,
|
|
446
|
+
},
|
|
447
|
+
getEditorContainerWidth,
|
|
448
|
+
undefined,
|
|
449
|
+
);
|
|
450
|
+
|
|
451
|
+
const items = cellOptionsMenu.options as Array<DropdownOptionT<Command>>;
|
|
452
|
+
const distributeColumns = items.filter((item) =>
|
|
453
|
+
item.id?.startsWith('editor.table.distributeColumns'),
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
const isDisabled = distributeColumns.every((item) => item.disabled);
|
|
457
|
+
expect(isDisabled).toBeTruthy();
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
it('should disable distribute columns if selection is on a single column', () => {
|
|
461
|
+
const { editorView } = createEditor({
|
|
462
|
+
doc: doc(
|
|
463
|
+
table()(
|
|
464
|
+
tr(th({})(p('{<cell}')), thEmpty, thEmpty),
|
|
465
|
+
tr(td({})(p('{cell>}')), tdEmpty, tdEmpty),
|
|
466
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
467
|
+
),
|
|
468
|
+
),
|
|
469
|
+
...props,
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
const { state } = editorView;
|
|
473
|
+
const rect = new Rect(1, 1, 1, 2);
|
|
474
|
+
|
|
475
|
+
const cellOptionsMenu = getToolbarCellOptionsConfig(
|
|
476
|
+
state,
|
|
477
|
+
editorView,
|
|
478
|
+
rect,
|
|
479
|
+
{
|
|
480
|
+
formatMessage,
|
|
481
|
+
},
|
|
482
|
+
getEditorContainerWidth,
|
|
483
|
+
undefined,
|
|
484
|
+
);
|
|
485
|
+
|
|
486
|
+
const items = cellOptionsMenu.options as Array<DropdownOptionT<Command>>;
|
|
487
|
+
const distributeColumns = items.filter((item) =>
|
|
488
|
+
item.id?.startsWith('editor.table.distributeColumns'),
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
const isDisabled = distributeColumns.every((item) => item.disabled);
|
|
492
|
+
expect(isDisabled).toBeTruthy();
|
|
493
|
+
});
|
|
410
494
|
});
|
|
@@ -81,7 +81,10 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
|
|
|
81
81
|
|
|
82
82
|
const mock = jest.spyOn(prosemirrorUtils, 'findDomRefAtPos');
|
|
83
83
|
mock.mockImplementation(() => {
|
|
84
|
-
|
|
84
|
+
const error = new Error('Error message from mock');
|
|
85
|
+
error.stack = 'stack trace';
|
|
86
|
+
|
|
87
|
+
throw error;
|
|
85
88
|
});
|
|
86
89
|
});
|
|
87
90
|
|
|
@@ -123,6 +126,9 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
|
|
|
123
126
|
docSize: 46,
|
|
124
127
|
error: 'Error: Error message from mock',
|
|
125
128
|
}),
|
|
129
|
+
nonPrivacySafeAttributes: expect.objectContaining({
|
|
130
|
+
errorStack: 'stack trace',
|
|
131
|
+
}),
|
|
126
132
|
});
|
|
127
133
|
});
|
|
128
134
|
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PuppeteerPage,
|
|
3
|
-
waitForNoTooltip,
|
|
4
|
-
} from '@atlaskit/visual-regression/helper';
|
|
1
|
+
import { PuppeteerPage } from '@atlaskit/visual-regression/helper';
|
|
5
2
|
import { insertTable } from '@atlaskit/editor-test-helpers/page-objects/table';
|
|
6
3
|
import {
|
|
7
4
|
snapshot,
|
|
@@ -58,8 +55,6 @@ describe('Table cell options menu', () => {
|
|
|
58
55
|
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
59
56
|
await page.hover(deleteColumnCellOptionSelector);
|
|
60
57
|
|
|
61
|
-
await waitForNoTooltip(page);
|
|
62
|
-
|
|
63
58
|
await snapshot(page);
|
|
64
59
|
});
|
|
65
60
|
|
|
@@ -72,8 +67,6 @@ describe('Table cell options menu', () => {
|
|
|
72
67
|
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
73
68
|
await page.click(deleteColumnCellOptionSelector);
|
|
74
69
|
|
|
75
|
-
await waitForNoTooltip(page);
|
|
76
|
-
|
|
77
70
|
await snapshot(page);
|
|
78
71
|
});
|
|
79
72
|
});
|
|
@@ -88,8 +81,6 @@ describe('Table cell options menu', () => {
|
|
|
88
81
|
await page.waitForSelector(deleteRowCellOptionSelector);
|
|
89
82
|
await page.hover(deleteRowCellOptionSelector);
|
|
90
83
|
|
|
91
|
-
await waitForNoTooltip(page);
|
|
92
|
-
|
|
93
84
|
await snapshot(page);
|
|
94
85
|
});
|
|
95
86
|
|
|
@@ -102,8 +93,6 @@ describe('Table cell options menu', () => {
|
|
|
102
93
|
await page.waitForSelector(deleteColumnCellOptionSelector);
|
|
103
94
|
await page.click(deleteRowCellOptionSelector);
|
|
104
95
|
|
|
105
|
-
await waitForNoTooltip(page);
|
|
106
|
-
|
|
107
96
|
await snapshot(page);
|
|
108
97
|
});
|
|
109
98
|
});
|
|
@@ -88,6 +88,8 @@ export class FloatingContextualButtonInner extends React.Component<
|
|
|
88
88
|
position: targetCellPosition,
|
|
89
89
|
docSize: editorView.state.doc.nodeSize,
|
|
90
90
|
error: error instanceof Error ? error.message : String(error),
|
|
91
|
+
},
|
|
92
|
+
nonPrivacySafeAttributes: {
|
|
91
93
|
errorStack: error instanceof Error ? error.stack : undefined,
|
|
92
94
|
},
|
|
93
95
|
};
|
|
@@ -140,6 +140,8 @@ export class FloatingInsertButton extends React.Component<
|
|
|
140
140
|
position: pos,
|
|
141
141
|
docSize: editorView.state.doc.nodeSize,
|
|
142
142
|
error: (error as any)?.toString(),
|
|
143
|
+
},
|
|
144
|
+
nonPrivacySafeAttributes: {
|
|
143
145
|
errorStack: (error as any).stack || undefined,
|
|
144
146
|
},
|
|
145
147
|
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 1,
|
|
3
|
-
"type": "doc",
|
|
4
|
-
"content": [
|
|
5
|
-
{
|
|
6
|
-
"type": "paragraph",
|
|
7
|
-
"content": [
|
|
8
|
-
{
|
|
9
|
-
"type": "text",
|
|
10
|
-
"text": "text"
|
|
11
|
-
}
|
|
12
|
-
]
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
"type": "table",
|
|
16
|
-
"attrs": {
|
|
17
|
-
"isNumberColumnEnabled": false,
|
|
18
|
-
"layout": "default",
|
|
19
|
-
"localId": "e1365400-6226-4bb9-b3f1-b80fd3ae640a"
|
|
20
|
-
},
|
|
21
|
-
"content": [
|
|
22
|
-
{
|
|
23
|
-
"type": "tableRow",
|
|
24
|
-
"content": [
|
|
25
|
-
{
|
|
26
|
-
"type": "tableHeader",
|
|
27
|
-
"attrs": {},
|
|
28
|
-
"content": [
|
|
29
|
-
{
|
|
30
|
-
"type": "paragraph",
|
|
31
|
-
"content": []
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
"type": "tableHeader",
|
|
37
|
-
"attrs": {},
|
|
38
|
-
"content": [
|
|
39
|
-
{
|
|
40
|
-
"type": "paragraph",
|
|
41
|
-
"content": []
|
|
42
|
-
}
|
|
43
|
-
]
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
"type": "tableHeader",
|
|
47
|
-
"attrs": {},
|
|
48
|
-
"content": [
|
|
49
|
-
{
|
|
50
|
-
"type": "paragraph",
|
|
51
|
-
"content": []
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
}
|
|
55
|
-
]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"type": "tableRow",
|
|
59
|
-
"content": [
|
|
60
|
-
{
|
|
61
|
-
"type": "tableCell",
|
|
62
|
-
"attrs": {},
|
|
63
|
-
"content": [
|
|
64
|
-
{
|
|
65
|
-
"type": "paragraph",
|
|
66
|
-
"content": []
|
|
67
|
-
}
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
"type": "tableCell",
|
|
72
|
-
"attrs": {},
|
|
73
|
-
"content": [
|
|
74
|
-
{
|
|
75
|
-
"type": "paragraph",
|
|
76
|
-
"content": []
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"type": "tableCell",
|
|
82
|
-
"attrs": {},
|
|
83
|
-
"content": [
|
|
84
|
-
{
|
|
85
|
-
"type": "paragraph",
|
|
86
|
-
"content": []
|
|
87
|
-
}
|
|
88
|
-
]
|
|
89
|
-
}
|
|
90
|
-
]
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
"type": "tableRow",
|
|
94
|
-
"content": [
|
|
95
|
-
{
|
|
96
|
-
"type": "tableCell",
|
|
97
|
-
"attrs": {},
|
|
98
|
-
"content": [
|
|
99
|
-
{
|
|
100
|
-
"type": "paragraph",
|
|
101
|
-
"content": []
|
|
102
|
-
}
|
|
103
|
-
]
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
"type": "tableCell",
|
|
107
|
-
"attrs": {},
|
|
108
|
-
"content": [
|
|
109
|
-
{
|
|
110
|
-
"type": "paragraph",
|
|
111
|
-
"content": []
|
|
112
|
-
}
|
|
113
|
-
]
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
"type": "tableCell",
|
|
117
|
-
"attrs": {},
|
|
118
|
-
"content": [
|
|
119
|
-
{
|
|
120
|
-
"type": "paragraph",
|
|
121
|
-
"content": []
|
|
122
|
-
}
|
|
123
|
-
]
|
|
124
|
-
}
|
|
125
|
-
]
|
|
126
|
-
}
|
|
127
|
-
]
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
}
|