@atlaskit/editor-plugin-table 0.0.7 → 0.0.9
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 +12 -0
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/cjs/plugins/table/nodeviews/table.js +4 -2
- package/dist/cjs/plugins/table/toolbar.js +0 -1
- package/dist/cjs/plugins/table/ui/TableFloatingControls/CornerControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/RowControls/index.js +23 -10
- package/dist/cjs/plugins/table/ui/TableFloatingControls/index.js +4 -4
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/es2019/plugins/table/nodeviews/table.js +4 -2
- package/dist/es2019/plugins/table/toolbar.js +1 -2
- package/dist/es2019/plugins/table/ui/TableFloatingControls/CornerControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/RowControls/index.js +18 -3
- package/dist/es2019/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +4 -2
- package/dist/esm/plugins/table/nodeviews/table.js +4 -2
- package/dist/esm/plugins/table/toolbar.js +1 -2
- package/dist/esm/plugins/table/ui/TableFloatingControls/CornerControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/RowControls/index.js +19 -9
- package/dist/esm/plugins/table/ui/TableFloatingControls/index.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +1 -0
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +5 -8
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +5 -5
- package/package.json +7 -2
- package/src/__tests__/unit/hover-selection.ts +1 -1
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +22 -22
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +3 -3
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +15 -15
- package/src/__tests__/unit/ui/RowControls.tsx +1 -1
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +2 -2
- package/src/plugins/table/__tests__/unit/commands/insert.ts +2 -2
- package/src/plugins/table/__tests__/unit/commands.ts +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/TableComponent.tsx +2 -2
- package/src/plugins/table/__tests__/unit/nodeviews/table.ts +1 -0
- package/src/plugins/table/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +25 -47
- package/src/plugins/table/nodeviews/TableComponent.tsx +8 -2
- package/src/plugins/table/nodeviews/table.tsx +7 -0
- package/src/plugins/table/nodeviews/types.ts +1 -0
- package/src/plugins/table/toolbar.ts +0 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +1 -1
- package/src/plugins/table/ui/TableFloatingControls/CornerControls/index.tsx +19 -1
- package/src/plugins/table/ui/TableFloatingControls/RowControls/index.tsx +16 -1
- package/src/plugins/table/ui/TableFloatingControls/index.tsx +2 -2
|
@@ -11,20 +11,28 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
11
11
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
12
|
|
|
13
13
|
import React, { Component } from 'react';
|
|
14
|
+
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
14
15
|
import { clearHoverSelection } from '../../../commands';
|
|
15
16
|
import { TableCssClassName as ClassName } from '../../../types';
|
|
16
17
|
import { getRowClassNames, getRowHeights, getRowsParams } from '../../../utils';
|
|
17
18
|
import { tableControlsSpacing, tableToolbarSize } from '../../consts';
|
|
19
|
+
var messages = defineMessages({
|
|
20
|
+
rowControl: {
|
|
21
|
+
id: 'fabric.editor.rowControl',
|
|
22
|
+
defaultMessage: 'Highlight row',
|
|
23
|
+
description: 'A button on the left of each row that shows up when the table is in focus. Clicking on it will select the entire row.'
|
|
24
|
+
}
|
|
25
|
+
});
|
|
18
26
|
|
|
19
|
-
var
|
|
20
|
-
_inherits(
|
|
27
|
+
var RowControlsComponent = /*#__PURE__*/function (_Component) {
|
|
28
|
+
_inherits(RowControlsComponent, _Component);
|
|
21
29
|
|
|
22
|
-
var _super = _createSuper(
|
|
30
|
+
var _super = _createSuper(RowControlsComponent);
|
|
23
31
|
|
|
24
|
-
function
|
|
32
|
+
function RowControlsComponent() {
|
|
25
33
|
var _this;
|
|
26
34
|
|
|
27
|
-
_classCallCheck(this,
|
|
35
|
+
_classCallCheck(this, RowControlsComponent);
|
|
28
36
|
|
|
29
37
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
30
38
|
args[_key] = arguments[_key];
|
|
@@ -42,7 +50,7 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
42
50
|
return _this;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
_createClass(
|
|
53
|
+
_createClass(RowControlsComponent, [{
|
|
46
54
|
key: "render",
|
|
47
55
|
value: function render() {
|
|
48
56
|
var _this2 = this;
|
|
@@ -52,7 +60,8 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
52
60
|
tableRef = _this$props.tableRef,
|
|
53
61
|
hoveredRows = _this$props.hoveredRows,
|
|
54
62
|
isInDanger = _this$props.isInDanger,
|
|
55
|
-
isResizing = _this$props.isResizing
|
|
63
|
+
isResizing = _this$props.isResizing,
|
|
64
|
+
formatMessage = _this$props.intl.formatMessage;
|
|
56
65
|
|
|
57
66
|
if (!tableRef) {
|
|
58
67
|
return null;
|
|
@@ -89,6 +98,7 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
89
98
|
paddingTop: thisRowSticky ? "".concat(tableControlsSpacing, "px") : undefined
|
|
90
99
|
}
|
|
91
100
|
}, /*#__PURE__*/React.createElement("button", {
|
|
101
|
+
"aria-label": formatMessage(messages.rowControl),
|
|
92
102
|
type: "button",
|
|
93
103
|
className: "".concat(ClassName.ROW_CONTROLS_BUTTON, "\n ").concat(ClassName.CONTROLS_BUTTON, "\n "),
|
|
94
104
|
onClick: function onClick(event) {
|
|
@@ -107,7 +117,7 @@ var RowControls = /*#__PURE__*/function (_Component) {
|
|
|
107
117
|
}
|
|
108
118
|
}]);
|
|
109
119
|
|
|
110
|
-
return
|
|
120
|
+
return RowControlsComponent;
|
|
111
121
|
}(Component);
|
|
112
122
|
|
|
113
|
-
export
|
|
123
|
+
export var RowControls = injectIntl(RowControlsComponent);
|
|
@@ -20,9 +20,9 @@ import React, { Component } from 'react';
|
|
|
20
20
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
21
21
|
import { hoverRows, selectRow } from '../../commands';
|
|
22
22
|
import { isSelectionUpdated } from '../../utils';
|
|
23
|
-
import CornerControls from './CornerControls';
|
|
23
|
+
import { CornerControls } from './CornerControls';
|
|
24
24
|
import NumberColumn from './NumberColumn';
|
|
25
|
-
import RowControls from './RowControls';
|
|
25
|
+
import { RowControls } from './RowControls';
|
|
26
26
|
|
|
27
27
|
var TableFloatingControls = /*#__PURE__*/function (_Component) {
|
|
28
28
|
_inherits(TableFloatingControls, _Component);
|
package/dist/esm/version.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
2
3
|
import { EditorView } from 'prosemirror-view';
|
|
3
4
|
export interface Props {
|
|
4
5
|
editorView: EditorView;
|
|
@@ -10,10 +11,6 @@ export interface Props {
|
|
|
10
11
|
isHeaderRowEnabled?: boolean;
|
|
11
12
|
stickyTop?: number;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private clearHoverSelection;
|
|
17
|
-
private selectTable;
|
|
18
|
-
private hoverTable;
|
|
19
|
-
}
|
|
14
|
+
export declare const CornerControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
15
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
16
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
4
|
export interface Props {
|
|
4
5
|
editorView: EditorView;
|
|
5
6
|
tableRef: HTMLTableElement;
|
|
@@ -11,7 +12,6 @@ export interface Props {
|
|
|
11
12
|
insertRowButtonIndex?: number;
|
|
12
13
|
stickyTop?: number;
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
17
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
2
3
|
import { EditorView } from 'prosemirror-view';
|
|
3
4
|
export interface Props {
|
|
4
5
|
editorView: EditorView;
|
|
@@ -10,10 +11,6 @@ export interface Props {
|
|
|
10
11
|
isHeaderRowEnabled?: boolean;
|
|
11
12
|
stickyTop?: number;
|
|
12
13
|
}
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private clearHoverSelection;
|
|
17
|
-
private selectTable;
|
|
18
|
-
private hoverTable;
|
|
19
|
-
}
|
|
14
|
+
export declare const CornerControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
15
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
16
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { EditorView } from 'prosemirror-view';
|
|
3
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
3
4
|
export interface Props {
|
|
4
5
|
editorView: EditorView;
|
|
5
6
|
tableRef: HTMLTableElement;
|
|
@@ -11,7 +12,6 @@ export interface Props {
|
|
|
11
12
|
insertRowButtonIndex?: number;
|
|
12
13
|
stickyTop?: number;
|
|
13
14
|
}
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
15
|
+
export declare const RowControls: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
16
|
+
WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -68,6 +68,7 @@
|
|
|
68
68
|
"@atlaskit/visual-regression": "*",
|
|
69
69
|
"@atlaskit/webdriver-runner": "*",
|
|
70
70
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
71
|
+
"@testing-library/react": "^12.1.5",
|
|
71
72
|
"@types/prosemirror-history": "^1.0.1",
|
|
72
73
|
"enzyme": "^3.10.0",
|
|
73
74
|
"prosemirror-history": "^1.1.3",
|
|
@@ -81,7 +82,11 @@
|
|
|
81
82
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
|
|
82
83
|
"techstack": {
|
|
83
84
|
"@repo/internal": {
|
|
84
|
-
"theming": "tokens"
|
|
85
|
+
"theming": "tokens",
|
|
86
|
+
"deprecation": "no-deprecated-imports",
|
|
87
|
+
"styling": [
|
|
88
|
+
"emotion"
|
|
89
|
+
]
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
}
|
|
@@ -87,7 +87,7 @@ describe('table hover selection plugin', () => {
|
|
|
87
87
|
selectColumns([column])(editorView.state, editorView.dispatch);
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
|
|
90
|
+
it('should add decoration', () => {
|
|
91
91
|
const cells = getCellsInColumn(column)(editorView.state.selection)!;
|
|
92
92
|
|
|
93
93
|
const decor = getTableDecorations(
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import { IntlProvider } from 'react-intl-next';
|
|
2
4
|
import { isTableSelected } from '@atlaskit/editor-tables/utils';
|
|
3
5
|
import { createEditorFactory } from '@atlaskit/editor-test-helpers/create-editor';
|
|
4
|
-
import { mountWithIntl } from '@atlaskit/editor-test-helpers/enzyme';
|
|
5
6
|
import {
|
|
6
7
|
doc,
|
|
7
8
|
table,
|
|
@@ -10,17 +11,12 @@ import {
|
|
|
10
11
|
DocBuilder,
|
|
11
12
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
12
13
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
TableCssClassName as ClassName,
|
|
16
|
-
} from '../../../plugins/table/types';
|
|
17
|
-
import CornerControls from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
|
|
14
|
+
import { TablePluginState } from '../../../plugins/table/types';
|
|
15
|
+
import { CornerControls } from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
|
|
18
16
|
import { getPluginState } from '../../../plugins/table/pm-plugins/plugin-factory';
|
|
19
17
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
20
18
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
21
19
|
|
|
22
|
-
const CornerButton = `.${ClassName.CONTROLS_CORNER_BUTTON}`;
|
|
23
|
-
|
|
24
20
|
describe('CornerControls', () => {
|
|
25
21
|
const createEditor = createEditorFactory<TablePluginState>();
|
|
26
22
|
|
|
@@ -40,17 +36,19 @@ describe('CornerControls', () => {
|
|
|
40
36
|
doc(table()(tr(thEmpty, thEmpty, thEmpty))),
|
|
41
37
|
);
|
|
42
38
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
const ref = editorView.dom.querySelector('table') || undefined;
|
|
40
|
+
|
|
41
|
+
render(
|
|
42
|
+
<IntlProvider locale="en">
|
|
43
|
+
<CornerControls tableRef={ref} editorView={editorView} />
|
|
44
|
+
</IntlProvider>,
|
|
48
45
|
);
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
const cornerControl = screen.getByLabelText('Highlight table');
|
|
48
|
+
|
|
49
|
+
fireEvent.click(cornerControl);
|
|
51
50
|
|
|
52
51
|
expect(isTableSelected(editorView.state.selection)).toBe(true);
|
|
53
|
-
controls.unmount();
|
|
54
52
|
});
|
|
55
53
|
});
|
|
56
54
|
|
|
@@ -62,19 +60,21 @@ describe('CornerControls', () => {
|
|
|
62
60
|
),
|
|
63
61
|
);
|
|
64
62
|
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
63
|
+
const ref = editorView.dom.querySelector('table') || undefined;
|
|
64
|
+
|
|
65
|
+
render(
|
|
66
|
+
<IntlProvider locale="en">
|
|
67
|
+
<CornerControls tableRef={ref} editorView={editorView} />
|
|
68
|
+
</IntlProvider>,
|
|
70
69
|
);
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
const cornerControl = screen.getByLabelText('Highlight table');
|
|
72
|
+
|
|
73
|
+
fireEvent.mouseOver(cornerControl);
|
|
73
74
|
|
|
74
75
|
const { hoveredColumns, hoveredRows } = getPluginState(editorView.state);
|
|
75
76
|
expect(hoveredColumns).toEqual([0, 1, 2]);
|
|
76
77
|
expect(hoveredRows).toEqual([0, 1]);
|
|
77
|
-
controls.unmount();
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
});
|
|
@@ -69,11 +69,11 @@ describe('Floating Delete Button', () => {
|
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
it('should not render a delete button with no selection', () => {
|
|
73
73
|
expect(wrapper.find(DeleteButton).length).toBe(0);
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
it('should not render a delete button with whole table selected', () => {
|
|
77
77
|
// select the whole table
|
|
78
78
|
editorView.dispatch(selectTable(editorView.state.tr));
|
|
79
79
|
|
|
@@ -112,7 +112,7 @@ describe('Floating Delete Button', () => {
|
|
|
112
112
|
},
|
|
113
113
|
);
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
it('should render a single delete button over multiple column selections', () => {
|
|
116
116
|
selectColumns([0, 1])(editorView.state, editorView.dispatch);
|
|
117
117
|
|
|
118
118
|
// We need to force renderer
|
|
@@ -94,8 +94,8 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
|
|
|
94
94
|
jest.restoreAllMocks();
|
|
95
95
|
});
|
|
96
96
|
|
|
97
|
-
|
|
98
|
-
// We need to set the props here, as by default insertColumnButtonIndex
|
|
97
|
+
it('sends error analytics event after attempting to render for second column', () => {
|
|
98
|
+
// We need to set the props here, as by default insertColumnButtonIndex is undefined (in
|
|
99
99
|
// mountWithIntl()) and rendering halts when it's undefined
|
|
100
100
|
wrapper.setProps({
|
|
101
101
|
insertColumnButtonIndex: 1,
|
|
@@ -115,11 +115,11 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
|
|
|
115
115
|
});
|
|
116
116
|
});
|
|
117
117
|
|
|
118
|
-
|
|
118
|
+
it('should not render insert button by default', () => {
|
|
119
119
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
120
120
|
});
|
|
121
121
|
|
|
122
|
-
|
|
122
|
+
it("shouldn't render insert button for second column", () => {
|
|
123
123
|
wrapper.setProps({
|
|
124
124
|
insertColumnButtonIndex: 1,
|
|
125
125
|
});
|
|
@@ -127,7 +127,7 @@ describe('Floating Insert Button when findDomRefAtPos fails', () => {
|
|
|
127
127
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
128
128
|
});
|
|
129
129
|
|
|
130
|
-
|
|
130
|
+
it("shouldn't render insert button for second row", () => {
|
|
131
131
|
wrapper.setProps({
|
|
132
132
|
insertRowButtonIndex: 1,
|
|
133
133
|
});
|
|
@@ -181,21 +181,21 @@ describe('Floating Insert Button', () => {
|
|
|
181
181
|
wrapper.unmount();
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
it('should not render insert button by default', () => {
|
|
185
185
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
it('should render insert button for second column', () => {
|
|
189
189
|
wrapper.setProps({ insertColumnButtonIndex: 1 });
|
|
190
190
|
expect(wrapper.find(InsertButton).length).toBe(1);
|
|
191
191
|
});
|
|
192
192
|
|
|
193
|
-
|
|
193
|
+
it('should render insert button for second row', () => {
|
|
194
194
|
wrapper.setProps({ insertRowButtonIndex: 1 });
|
|
195
195
|
expect(wrapper.find(InsertButton).length).toBe(1);
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
|
|
198
|
+
it('should not render insert button for first row when row header is enabled', () => {
|
|
199
199
|
wrapper.setProps({
|
|
200
200
|
insertRowButtonIndex: 0,
|
|
201
201
|
isHeaderRowEnabled: true,
|
|
@@ -204,7 +204,7 @@ describe('Floating Insert Button', () => {
|
|
|
204
204
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
205
205
|
});
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
it('should render insert button for first row when row header is disabled', () => {
|
|
208
208
|
wrapper.setProps({
|
|
209
209
|
insertRowButtonIndex: 0,
|
|
210
210
|
isHeaderRowEnabled: false,
|
|
@@ -213,7 +213,7 @@ describe('Floating Insert Button', () => {
|
|
|
213
213
|
expect(wrapper.find(InsertButton).length).toBe(1);
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
-
|
|
216
|
+
it('should not render insert button for first col when column header is enabled', () => {
|
|
217
217
|
wrapper.setProps({
|
|
218
218
|
insertColumnButtonIndex: 0,
|
|
219
219
|
isHeaderColumnEnabled: true,
|
|
@@ -222,7 +222,7 @@ describe('Floating Insert Button', () => {
|
|
|
222
222
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
223
223
|
});
|
|
224
224
|
|
|
225
|
-
|
|
225
|
+
it('should render insert button for first col when column header is disabled', () => {
|
|
226
226
|
wrapper.setProps({
|
|
227
227
|
insertColumnButtonIndex: 0,
|
|
228
228
|
isHeaderColumnEnabled: false,
|
|
@@ -231,7 +231,7 @@ describe('Floating Insert Button', () => {
|
|
|
231
231
|
expect(wrapper.find(InsertButton).length).toBe(1);
|
|
232
232
|
});
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
it('should render insert button when a single cell is selected', () => {
|
|
235
235
|
selectCell(1, 1)(editorView.state, editorView.dispatch);
|
|
236
236
|
|
|
237
237
|
wrapper.setProps({
|
|
@@ -242,7 +242,7 @@ describe('Floating Insert Button', () => {
|
|
|
242
242
|
expect(wrapper.find(InsertButton).length).toBe(1);
|
|
243
243
|
});
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
it('should not render insert button when a whole column is selected', () => {
|
|
246
246
|
selectColumns([1])(editorView.state, editorView.dispatch);
|
|
247
247
|
|
|
248
248
|
wrapper.setProps({
|
|
@@ -253,7 +253,7 @@ describe('Floating Insert Button', () => {
|
|
|
253
253
|
expect(wrapper.find(InsertButton).length).toBe(0);
|
|
254
254
|
});
|
|
255
255
|
|
|
256
|
-
|
|
256
|
+
it('should no render insert button when a whole row is selected', () => {
|
|
257
257
|
selectRows([1])(editorView.state, editorView.dispatch);
|
|
258
258
|
|
|
259
259
|
wrapper.setProps({
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
TablePluginState,
|
|
23
23
|
} from '../../../plugins/table/types';
|
|
24
24
|
import TableFloatingControls from '../../../plugins/table/ui/TableFloatingControls';
|
|
25
|
-
import RowControls from '../../../plugins/table/ui/TableFloatingControls/RowControls';
|
|
25
|
+
import { RowControls } from '../../../plugins/table/ui/TableFloatingControls/RowControls';
|
|
26
26
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
27
27
|
import { ReactWrapper } from 'enzyme';
|
|
28
28
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
import { TablePluginState } from '../../../plugins/table/types';
|
|
20
20
|
import { hoverTable } from '../../../plugins/table/commands';
|
|
21
21
|
import TableFloatingControls from '../../../plugins/table/ui/TableFloatingControls';
|
|
22
|
-
import CornerControls from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
|
|
23
|
-
import RowControls from '../../../plugins/table/ui/TableFloatingControls/RowControls';
|
|
22
|
+
import { CornerControls } from '../../../plugins/table/ui/TableFloatingControls/CornerControls';
|
|
23
|
+
import { RowControls } from '../../../plugins/table/ui/TableFloatingControls/RowControls';
|
|
24
24
|
import { pluginKey } from '../../../plugins/table/pm-plugins/plugin-key';
|
|
25
25
|
import { getDecorations } from '../../../plugins/table/pm-plugins/decorations/plugin';
|
|
26
26
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
@@ -53,7 +53,7 @@ describe('table plugin: insert', () => {
|
|
|
53
53
|
pluginKey,
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
it('does scale cells in tables which are not overflowing', () => {
|
|
57
57
|
const { editorView } = editor(
|
|
58
58
|
doc(
|
|
59
59
|
table({ localId: TABLE_LOCAL_ID })(
|
|
@@ -84,7 +84,7 @@ describe('table plugin: insert', () => {
|
|
|
84
84
|
);
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
it('does not scale cells in tables which are overflowing', () => {
|
|
88
88
|
const { editorView } = editor(
|
|
89
89
|
doc(
|
|
90
90
|
table({ localId: TABLE_LOCAL_ID })(
|
|
@@ -810,7 +810,7 @@ describe('table plugin: actions', () => {
|
|
|
810
810
|
* | th | th | th |
|
|
811
811
|
* | th | td | td |
|
|
812
812
|
*/
|
|
813
|
-
|
|
813
|
+
it('should keep right row header and cells after split', () => {
|
|
814
814
|
const { editorView } = editor(
|
|
815
815
|
doc(
|
|
816
816
|
table()(
|
|
@@ -833,7 +833,7 @@ describe('table plugin: actions', () => {
|
|
|
833
833
|
);
|
|
834
834
|
});
|
|
835
835
|
|
|
836
|
-
|
|
836
|
+
it('should split cell with media selected', () => {
|
|
837
837
|
const { editorView } = editor(
|
|
838
838
|
doc(
|
|
839
839
|
table()(
|
|
@@ -259,7 +259,7 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
259
259
|
return { wrapper, view };
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
describe('with
|
|
262
|
+
describe('with optimization on', () => {
|
|
263
263
|
let wrapper: ReactWrapper;
|
|
264
264
|
beforeEach(() => {
|
|
265
265
|
wrapper = setupTable(true).wrapper;
|
|
@@ -306,7 +306,7 @@ describe('table -> nodeviews -> TableComponent.tsx', () => {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
-
describe('with
|
|
309
|
+
describe('with optimization off', () => {
|
|
310
310
|
let wrapper: ReactWrapper;
|
|
311
311
|
beforeEach(() => {
|
|
312
312
|
wrapper = setupTable(false).wrapper;
|
|
@@ -73,6 +73,7 @@ describe('table -> nodeviews -> table.tsx', () => {
|
|
|
73
73
|
tableRenderOptimization: true,
|
|
74
74
|
getEditorContainerWidth: () => ({ width: 500 }),
|
|
75
75
|
getEditorFeatureFlags: () => ({}),
|
|
76
|
+
hasIntlContext: true,
|
|
76
77
|
}).init();
|
|
77
78
|
|
|
78
79
|
renderSpy = jest.spyOn(tableNodeView, 'render');
|