@atlaskit/editor-plugin-table 0.1.0 → 0.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 +8 -0
- package/dist/cjs/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/ui/FloatingDeleteButton/index.js +2 -1
- package/dist/esm/version.json +1 -1
- package/examples/99-testing.tsx +35 -30
- package/package.json +2 -11
- package/src/__tests__/integration/__fixtures__/auto-size-documents.ts +5 -10
- package/src/__tests__/integration/__fixtures__/layout-documents.ts +1 -2
- package/src/__tests__/integration/__fixtures__/resize-documents.ts +5 -10
- package/src/__tests__/integration/resize.ts +1 -2
- package/src/__tests__/unit/analytics.ts +33 -32
- package/src/__tests__/unit/collab.ts +12 -9
- package/src/__tests__/unit/commands/sort.ts +28 -28
- package/src/__tests__/unit/copy-paste.ts +6 -8
- package/src/__tests__/unit/event-handlers.ts +7 -10
- package/src/__tests__/unit/fix-tables.ts +17 -23
- package/src/__tests__/unit/get-toolbar-config.ts +0 -5
- package/src/__tests__/unit/hover-selection.ts +1 -66
- package/src/__tests__/unit/index-with-fake-timers.ts +1 -1
- package/src/__tests__/unit/index.ts +5 -5
- package/src/__tests__/unit/nodeviews/TableComponent.tsx +11 -218
- package/src/__tests__/unit/nodeviews/cell.ts +12 -10
- package/src/__tests__/unit/nodeviews/table.ts +25 -26
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +11 -8
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +11 -12
- package/src/__tests__/unit/toolbar.ts +18 -5
- package/src/__tests__/unit/ui/ContextualMenu.tsx +55 -0
- package/src/__tests__/unit/ui/CornerControls.tsx +7 -7
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +45 -49
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +49 -0
- package/src/__tests__/unit/ui/FloatingDeleteButton.tsx +30 -2
- package/src/__tests__/unit/ui/FloatingInsertButton.tsx +143 -111
- package/src/__tests__/unit/ui/RowControls.tsx +112 -141
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +18 -15
- package/src/__tests__/unit/undo-redo.ts +10 -9
- package/src/__tests__/unit/utils/nodes.ts +8 -4
- package/src/__tests__/unit/utils/row-controls.ts +8 -4
- package/src/plugins/table/commands/clear.ts +30 -29
- package/src/plugins/table/commands/go-to-next-cell.ts +41 -38
- package/src/plugins/table/commands/insert.ts +91 -91
- package/src/plugins/table/commands/misc.ts +123 -125
- package/src/plugins/table/commands/selection.ts +329 -319
- package/src/plugins/table/commands-with-analytics.ts +299 -294
- package/src/plugins/table/event-handlers.ts +111 -111
- package/src/plugins/table/handlers.ts +95 -94
- package/src/plugins/table/nodeviews/OverflowShadowsObserver.ts +4 -3
- package/src/plugins/table/nodeviews/TableComponent.tsx +6 -9
- package/src/plugins/table/nodeviews/update-overflow-shadows.ts +39 -39
- package/src/plugins/table/pm-plugins/decorations/utils/column-controls.ts +7 -9
- package/src/plugins/table/pm-plugins/decorations/utils/column-resizing.ts +30 -30
- package/src/plugins/table/pm-plugins/decorations/utils/compose-decorations.ts +7 -7
- package/src/plugins/table/pm-plugins/plugin-factory.ts +33 -33
- package/src/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.ts +6 -9
- package/src/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.ts +3 -2
- package/src/plugins/table/pm-plugins/table-resizing/commands.ts +98 -90
- package/src/plugins/table/pm-plugins/table-resizing/utils/dom.ts +46 -47
- package/src/plugins/table/toolbar.tsx +116 -113
- package/src/plugins/table/transforms/column-width.ts +143 -146
- package/src/plugins/table/transforms/delete-columns.ts +144 -142
- package/src/plugins/table/transforms/delete-rows.ts +110 -111
- package/src/plugins/table/transforms/metadata.ts +9 -9
- package/src/plugins/table/ui/FloatingContextualMenu/ContextualMenu.tsx +7 -6
- package/src/plugins/table/ui/FloatingDeleteButton/index.tsx +3 -2
- package/src/plugins/table/ui/FloatingInsertButton/index.tsx +2 -5
- package/src/plugins/table/ui/LayoutButton/index.tsx +2 -6
- package/src/plugins/table/ui/common-styles.ts +1 -3
- package/src/plugins/table/utils/analytics.ts +24 -25
- package/src/plugins/table/utils/dom.ts +3 -3
- package/src/plugins/table/utils/row-controls.ts +92 -93
- package/dist/types-ts4.0/index.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/commands/clear.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/collapse.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/commands/go-to-next-cell.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/commands/hover.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/commands/insert.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/commands/misc.d.ts +0 -27
- package/dist/types-ts4.0/plugins/table/commands/selection.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/commands/sort.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/commands/split-cell.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/commands/toggle.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/commands-with-analytics.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/create-plugin-config.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/event-handlers.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/handlers.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +0 -26
- package/dist/types-ts4.0/plugins/table/nodeviews/TableComponent.d.ts +0 -72
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/nodeviews/table.d.ts +0 -31
- package/dist/types-ts4.0/plugins/table/nodeviews/tableCell.d.ts +0 -19
- package/dist/types-ts4.0/plugins/table/nodeviews/types.d.ts +0 -24
- package/dist/types-ts4.0/plugins/table/nodeviews/update-overflow-shadows.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/plugin.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/index.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/decorations/utils/types.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/default-table-selection.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/keymap.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/pm-plugins/main.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-factory.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/commands.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/index.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +0 -65
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/types.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/pm-plugins/sticky-headers/util.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-local-id.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/commands.d.ts +0 -25
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/index.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/plugin.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +0 -8
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +0 -13
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/pm-plugins/table-selection-keymap.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/reducer.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/toolbar.d.ts +0 -36
- package/dist/types-ts4.0/plugins/table/transforms/column-width.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/transforms/delete-columns.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/delete-rows.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/transforms/fix-tables.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/transforms/index.d.ts +0 -7
- package/dist/types-ts4.0/plugins/table/transforms/merge.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/metadata.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/transforms/replace-table.d.ts +0 -5
- package/dist/types-ts4.0/plugins/table/transforms/split.d.ts +0 -9
- package/dist/types-ts4.0/plugins/table/types.d.ts +0 -328
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/index.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualButton/styles.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +0 -87
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/index.d.ts +0 -22
- package/dist/types-ts4.0/plugins/table/ui/FloatingContextualMenu/styles.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/index.d.ts +0 -54
- package/dist/types-ts4.0/plugins/table/ui/FloatingDeleteButton/types.d.ts +0 -1
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +0 -3
- package/dist/types-ts4.0/plugins/table/ui/FloatingInsertButton/index.d.ts +0 -35
- package/dist/types-ts4.0/plugins/table/ui/LayoutButton/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +0 -21
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +0 -17
- package/dist/types-ts4.0/plugins/table/ui/TableFloatingControls/index.d.ts +0 -40
- package/dist/types-ts4.0/plugins/table/ui/common-styles.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/ui/consts.d.ts +0 -39
- package/dist/types-ts4.0/plugins/table/ui/messages.d.ts +0 -38
- package/dist/types-ts4.0/plugins/table/ui/ui-styles.d.ts +0 -15
- package/dist/types-ts4.0/plugins/table/utils/analytics.d.ts +0 -18
- package/dist/types-ts4.0/plugins/table/utils/collapse.d.ts +0 -29
- package/dist/types-ts4.0/plugins/table/utils/column-controls.d.ts +0 -10
- package/dist/types-ts4.0/plugins/table/utils/decoration.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/dom.d.ts +0 -20
- package/dist/types-ts4.0/plugins/table/utils/get-allow-add-column-custom-step.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/index.d.ts +0 -11
- package/dist/types-ts4.0/plugins/table/utils/nodes.d.ts +0 -12
- package/dist/types-ts4.0/plugins/table/utils/paste.d.ts +0 -14
- package/dist/types-ts4.0/plugins/table/utils/referentiality.d.ts +0 -2
- package/dist/types-ts4.0/plugins/table/utils/row-controls.d.ts +0 -16
- package/dist/types-ts4.0/plugins/table/utils/selection.d.ts +0 -6
- package/dist/types-ts4.0/plugins/table/utils/table.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table/utils/update-plugin-state-decorations.d.ts +0 -4
- package/dist/types-ts4.0/plugins/table-plugin.d.ts +0 -2
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/ContextualMenu.tsx +0 -56
- package/src/plugins/table/ui/FloatingContextualMenu/__tests__/FloatingContextualMenu.tsx +0 -50
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 0.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`2ce5df13885`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2ce5df13885) - [ux] Prevent cursor selection from being reset when delete button is clicked
|
|
8
|
+
The fix ensures that when removing a row or column via the delete button, the cursor will stay within the table.
|
|
9
|
+
Reference https://discuss.prosemirror.net/t/setting-selection-to-newly-inserted-text-node/3615/6
|
|
10
|
+
|
|
3
11
|
## 0.1.0
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -154,7 +154,8 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
154
154
|
dispatch = _this$props$editorVie2.dispatch;
|
|
155
155
|
return (0, _commands.clearHoverSelection)()(state, dispatch);
|
|
156
156
|
});
|
|
157
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function () {
|
|
157
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function (event) {
|
|
158
|
+
event.preventDefault();
|
|
158
159
|
var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
|
|
159
160
|
var _this$props$editorVie3 = _this.props.editorView,
|
|
160
161
|
state = _this$props$editorVie3.state,
|
package/dist/cjs/version.json
CHANGED
|
@@ -96,7 +96,8 @@ class FloatingDeleteButton extends Component {
|
|
|
96
96
|
return clearHoverSelection()(state, dispatch);
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
_defineProperty(this, "handleClick",
|
|
99
|
+
_defineProperty(this, "handleClick", event => {
|
|
100
|
+
event.preventDefault();
|
|
100
101
|
const {
|
|
101
102
|
editorAnalyticsAPI
|
|
102
103
|
} = this.props;
|
package/dist/es2019/version.json
CHANGED
|
@@ -121,7 +121,8 @@ var FloatingDeleteButton = /*#__PURE__*/function (_Component) {
|
|
|
121
121
|
return clearHoverSelection()(state, dispatch);
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
_defineProperty(_assertThisInitialized(_this), "handleClick", function () {
|
|
124
|
+
_defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
|
|
125
|
+
event.preventDefault();
|
|
125
126
|
var editorAnalyticsAPI = _this.props.editorAnalyticsAPI;
|
|
126
127
|
var _this$props$editorVie3 = _this.props.editorView,
|
|
127
128
|
state = _this$props$editorVie3.state,
|
package/dist/esm/version.json
CHANGED
package/examples/99-testing.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { IntlProvider } from 'react-intl-next';
|
|
2
3
|
import Button from '@atlaskit/button/standard-button';
|
|
3
4
|
import { customInsertMenuItems } from '@atlaskit/editor-test-helpers/mock-insert-menu';
|
|
4
5
|
import { AtlassianIcon } from '@atlaskit/logo/atlassian-icon';
|
|
@@ -52,28 +53,30 @@ const editorSelectionAPI = {
|
|
|
52
53
|
// IT IS DANGEROUS AND YOU WILL BREAK SOMETHING
|
|
53
54
|
return (state as any)['selection$'];
|
|
54
55
|
},
|
|
55
|
-
setSelectionRelativeToNode:
|
|
56
|
-
|
|
57
|
-
selection,
|
|
58
|
-
}: {
|
|
59
|
-
selectionRelativeToNode?: RelativeSelectionPos;
|
|
60
|
-
selection?: Selection | null;
|
|
61
|
-
}) => (state: EditorState) => {
|
|
62
|
-
const tr = state.tr;
|
|
63
|
-
|
|
64
|
-
// THE CODE BELOW IS REALLY WRONG
|
|
65
|
-
// DO NOT EVEN THINK TO USE THIS ANYWHERE ELSE
|
|
66
|
-
tr.setMeta('selection$', {
|
|
67
|
-
type: 'SET_RELATIVE_SELECTION',
|
|
56
|
+
setSelectionRelativeToNode:
|
|
57
|
+
({
|
|
68
58
|
selectionRelativeToNode,
|
|
69
|
-
|
|
59
|
+
selection,
|
|
60
|
+
}: {
|
|
61
|
+
selectionRelativeToNode?: RelativeSelectionPos;
|
|
62
|
+
selection?: Selection | null;
|
|
63
|
+
}) =>
|
|
64
|
+
(state: EditorState) => {
|
|
65
|
+
const tr = state.tr;
|
|
66
|
+
|
|
67
|
+
// THE CODE BELOW IS REALLY WRONG
|
|
68
|
+
// DO NOT EVEN THINK TO USE THIS ANYWHERE ELSE
|
|
69
|
+
tr.setMeta('selection$', {
|
|
70
|
+
type: 'SET_RELATIVE_SELECTION',
|
|
71
|
+
selectionRelativeToNode,
|
|
72
|
+
});
|
|
70
73
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
if (selection) {
|
|
75
|
+
tr.setSelection(selection);
|
|
76
|
+
}
|
|
74
77
|
|
|
75
|
-
|
|
76
|
-
|
|
78
|
+
return tr;
|
|
79
|
+
},
|
|
77
80
|
};
|
|
78
81
|
|
|
79
82
|
export default function EditorExampleForIntegrationTests({ clipboard = true }) {
|
|
@@ -189,17 +192,19 @@ export default function EditorExampleForIntegrationTests({ clipboard = true }) {
|
|
|
189
192
|
const collabEdit = sessionId ? createCollabEdit(sessionId) : undefined;
|
|
190
193
|
|
|
191
194
|
return (
|
|
192
|
-
<
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
195
|
+
<IntlProvider locale="en">
|
|
196
|
+
<Editor
|
|
197
|
+
{...mapProvidersToProps(nonSerializableProps.providers, props)}
|
|
198
|
+
{...nonSerializableProps.providers}
|
|
199
|
+
insertMenuItems={customInsertMenuItems}
|
|
200
|
+
extensionHandlers={nonSerializableProps.extensionHandlers}
|
|
201
|
+
onEditorReady={onMount}
|
|
202
|
+
onChange={onChange}
|
|
203
|
+
onDestroy={onDestroy}
|
|
204
|
+
collabEdit={collabEdit}
|
|
205
|
+
dangerouslyAppendPlugins={dangerouslyAppendPlugins}
|
|
206
|
+
/>
|
|
207
|
+
</IntlProvider>
|
|
203
208
|
);
|
|
204
209
|
};
|
|
205
210
|
const editorContent = withCollab ? (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-table",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Table plugin for the @atlaskit/editor",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -11,14 +11,6 @@
|
|
|
11
11
|
"module": "dist/esm/index.js",
|
|
12
12
|
"module:es2019": "dist/es2019/index.js",
|
|
13
13
|
"types": "dist/types/index.d.ts",
|
|
14
|
-
"typesVersions": {
|
|
15
|
-
">=4.0 <4.5": {
|
|
16
|
-
"*": [
|
|
17
|
-
"dist/types-ts4.0/*",
|
|
18
|
-
"dist/types-ts4.0/index.d.ts"
|
|
19
|
-
]
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
14
|
"atlaskit:src": "src/index.ts",
|
|
23
15
|
"atlassian": {
|
|
24
16
|
"team": "Editor",
|
|
@@ -64,13 +56,12 @@
|
|
|
64
56
|
"@atlaskit/logo": "^13.10.0",
|
|
65
57
|
"@atlaskit/media-integration-test-helpers": "^2.6.0",
|
|
66
58
|
"@atlaskit/synchrony-test-helpers": "^2.3.0",
|
|
67
|
-
"@atlaskit/util-data-test": "^17.
|
|
59
|
+
"@atlaskit/util-data-test": "^17.6.0",
|
|
68
60
|
"@atlaskit/visual-regression": "*",
|
|
69
61
|
"@atlaskit/webdriver-runner": "*",
|
|
70
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
71
63
|
"@testing-library/react": "^12.1.5",
|
|
72
64
|
"@types/prosemirror-history": "^1.0.1",
|
|
73
|
-
"enzyme": "^3.10.0",
|
|
74
65
|
"prosemirror-history": "^1.1.3",
|
|
75
66
|
"raf-stub": "^2.0.1",
|
|
76
67
|
"typescript": "4.5.5"
|
|
@@ -169,8 +169,7 @@ const autoSizeToWideLayout = {
|
|
|
169
169
|
content: [
|
|
170
170
|
{
|
|
171
171
|
type: 'text',
|
|
172
|
-
text:
|
|
173
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
|
172
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
|
174
173
|
},
|
|
175
174
|
],
|
|
176
175
|
},
|
|
@@ -195,8 +194,7 @@ const autoSizeToWideLayout = {
|
|
|
195
194
|
content: [
|
|
196
195
|
{
|
|
197
196
|
type: 'text',
|
|
198
|
-
text:
|
|
199
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
|
197
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
|
|
200
198
|
},
|
|
201
199
|
],
|
|
202
200
|
},
|
|
@@ -316,8 +314,7 @@ const autoSizeToFullWidthLayout = {
|
|
|
316
314
|
content: [
|
|
317
315
|
{
|
|
318
316
|
type: 'text',
|
|
319
|
-
text:
|
|
320
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
317
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
321
318
|
},
|
|
322
319
|
],
|
|
323
320
|
},
|
|
@@ -367,8 +364,7 @@ const autoSizeToFullWidthLayout = {
|
|
|
367
364
|
content: [
|
|
368
365
|
{
|
|
369
366
|
type: 'text',
|
|
370
|
-
text:
|
|
371
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
367
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
372
368
|
},
|
|
373
369
|
],
|
|
374
370
|
},
|
|
@@ -418,8 +414,7 @@ const autoSizeToFullWidthLayout = {
|
|
|
418
414
|
content: [
|
|
419
415
|
{
|
|
420
416
|
type: 'text',
|
|
421
|
-
text:
|
|
422
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
417
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
423
418
|
},
|
|
424
419
|
],
|
|
425
420
|
},
|
|
@@ -271,8 +271,7 @@ const nestedTables = {
|
|
|
271
271
|
content: [
|
|
272
272
|
{
|
|
273
273
|
type: 'text',
|
|
274
|
-
text:
|
|
275
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
274
|
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean mi nisl, venenatis eget auctor vitae, venenatis quis lorem. Suspendisse maximus tortor vel dui tincidunt cursus. Vestibulum magna nibh, auctor non auctor id, finibus vitae orci. Nulla viverra ipsum et nunc fringilla ultricies. Pellentesque vitae felis molestie justo finibus accumsan. Suspendisse potenti. Nulla facilisi. Integer dignissim quis velit quis elementum. Sed sit amet varius ante. Duis vestibulum porta augue eu laoreet. Morbi id risus et augue sollicitudin aliquam. In et ligula dolor. Nam ac aliquet diam.',
|
|
276
275
|
},
|
|
277
276
|
],
|
|
278
277
|
},
|
|
@@ -212,8 +212,7 @@ export const twoColFullWidthTableWithContent = {
|
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
214
|
type: 'text',
|
|
215
|
-
text:
|
|
216
|
-
'2. Paste a jira link in for the href and immediately close the bracket to complete the markdown',
|
|
215
|
+
text: '2. Paste a jira link in for the href and immediately close the bracket to complete the markdown',
|
|
217
216
|
},
|
|
218
217
|
],
|
|
219
218
|
},
|
|
@@ -229,8 +228,7 @@ export const twoColFullWidthTableWithContent = {
|
|
|
229
228
|
},
|
|
230
229
|
{
|
|
231
230
|
type: 'text',
|
|
232
|
-
text:
|
|
233
|
-
'markdown for URL works correctly? or smartcard overrides it?',
|
|
231
|
+
text: 'markdown for URL works correctly? or smartcard overrides it?',
|
|
234
232
|
},
|
|
235
233
|
],
|
|
236
234
|
},
|
|
@@ -246,8 +244,7 @@ export const twoColFullWidthTableWithContent = {
|
|
|
246
244
|
},
|
|
247
245
|
{
|
|
248
246
|
type: 'text',
|
|
249
|
-
text:
|
|
250
|
-
'Smartcard link for Jira is still being processed and is entered as the value for the markdown for the URL ',
|
|
247
|
+
text: 'Smartcard link for Jira is still being processed and is entered as the value for the markdown for the URL ',
|
|
251
248
|
},
|
|
252
249
|
{
|
|
253
250
|
type: 'emoji',
|
|
@@ -262,8 +259,7 @@ export const twoColFullWidthTableWithContent = {
|
|
|
262
259
|
},
|
|
263
260
|
{
|
|
264
261
|
type: 'text',
|
|
265
|
-
text:
|
|
266
|
-
'URL ends up pointing to the confluence edit link but without a page ID so 404s',
|
|
262
|
+
text: 'URL ends up pointing to the confluence edit link but without a page ID so 404s',
|
|
267
263
|
},
|
|
268
264
|
],
|
|
269
265
|
},
|
|
@@ -302,8 +298,7 @@ export const twoColFullWidthTableWithContent = {
|
|
|
302
298
|
content: [
|
|
303
299
|
{
|
|
304
300
|
type: 'text',
|
|
305
|
-
text:
|
|
306
|
-
"Publishing somewhat big pages doesn't really provide any indication to the user that their page is actually being published and they're going to be navigated away",
|
|
301
|
+
text: "Publishing somewhat big pages doesn't really provide any indication to the user that their page is actually being published and they're going to be navigated away",
|
|
307
302
|
},
|
|
308
303
|
],
|
|
309
304
|
},
|
|
@@ -185,8 +185,7 @@ BrowserTestCase(
|
|
|
185
185
|
featureFlags: {},
|
|
186
186
|
},
|
|
187
187
|
{
|
|
188
|
-
test:
|
|
189
|
-
'Should stack columns to the right and go to overflow with overflowShadowsOptimisation',
|
|
188
|
+
test: 'Should stack columns to the right and go to overflow with overflowShadowsOptimisation',
|
|
190
189
|
featureFlags: {
|
|
191
190
|
tableOverflowShadowsOptimization: true,
|
|
192
191
|
},
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { Rect } from '@atlaskit/editor-tables/table-map';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createProsemirrorEditorFactory,
|
|
4
|
+
LightEditorPlugin,
|
|
5
|
+
Preset,
|
|
6
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
3
7
|
import {
|
|
4
8
|
doc,
|
|
5
9
|
p,
|
|
@@ -14,7 +18,7 @@ import {
|
|
|
14
18
|
import sendKeyToPm from '@atlaskit/editor-test-helpers/send-key-to-pm';
|
|
15
19
|
import { B50 } from '@atlaskit/theme/colors';
|
|
16
20
|
|
|
17
|
-
import {
|
|
21
|
+
import { PluginConfig } from '../../plugins/table/types';
|
|
18
22
|
import {
|
|
19
23
|
deleteTableWithAnalytics,
|
|
20
24
|
emptyMultipleCellsWithAnalytics,
|
|
@@ -37,11 +41,15 @@ import { pluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
|
37
41
|
import { replaceSelectedTable } from '../../plugins/table/transforms';
|
|
38
42
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
39
43
|
import tablePlugin from '../../plugins/table-plugin';
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
import typeAheadPlugin from '@atlaskit/editor-core/src/plugins/type-ahead';
|
|
45
|
+
import quickInsertPlugin from '@atlaskit/editor-core/src/plugins/quick-insert';
|
|
46
|
+
|
|
47
|
+
const defaultTableDoc = doc(
|
|
48
|
+
table()(
|
|
49
|
+
tr(thEmpty, thEmpty, thEmpty),
|
|
50
|
+
tr(tdEmpty, tdEmpty, tdEmpty),
|
|
51
|
+
tr(tdEmpty, tdEmpty, tdCursor),
|
|
52
|
+
),
|
|
45
53
|
);
|
|
46
54
|
|
|
47
55
|
const secondRow: Rect = { left: 0, top: 1, bottom: 2, right: 3 };
|
|
@@ -57,7 +65,7 @@ describe('Table analytic events', () => {
|
|
|
57
65
|
};
|
|
58
66
|
});
|
|
59
67
|
|
|
60
|
-
const createEditor =
|
|
68
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
61
69
|
|
|
62
70
|
const editor = (doc: DocBuilder) => {
|
|
63
71
|
const tableOptions = {
|
|
@@ -69,20 +77,13 @@ describe('Table analytic events', () => {
|
|
|
69
77
|
|
|
70
78
|
const _editor = createEditor({
|
|
71
79
|
doc,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
tablePlugin({
|
|
80
|
-
tableOptions,
|
|
81
|
-
editorAnalyticsAPI: editorAnalyticsAPIFake,
|
|
82
|
-
}),
|
|
83
|
-
],
|
|
84
|
-
},
|
|
85
|
-
},
|
|
80
|
+
preset: new Preset<LightEditorPlugin>()
|
|
81
|
+
.add(typeAheadPlugin)
|
|
82
|
+
.add(quickInsertPlugin)
|
|
83
|
+
.add([
|
|
84
|
+
tablePlugin,
|
|
85
|
+
{ tableOptions, editorAnalyticsAPI: editorAnalyticsAPIFake },
|
|
86
|
+
]),
|
|
86
87
|
pluginKey,
|
|
87
88
|
});
|
|
88
89
|
|
|
@@ -108,7 +109,7 @@ describe('Table analytic events', () => {
|
|
|
108
109
|
|
|
109
110
|
describe('table deleted', () => {
|
|
110
111
|
beforeEach(() => {
|
|
111
|
-
const { editorView } = editor(
|
|
112
|
+
const { editorView } = editor(defaultTableDoc);
|
|
112
113
|
deleteTableWithAnalytics(editorAnalyticsAPIFake)(
|
|
113
114
|
editorView.state,
|
|
114
115
|
editorView.dispatch,
|
|
@@ -334,7 +335,7 @@ describe('Table analytic events', () => {
|
|
|
334
335
|
|
|
335
336
|
describe('header row toggled', () => {
|
|
336
337
|
beforeEach(() => {
|
|
337
|
-
const { editorView } = editor(
|
|
338
|
+
const { editorView } = editor(defaultTableDoc);
|
|
338
339
|
toggleHeaderRowWithAnalytics(editorAnalyticsAPIFake)(
|
|
339
340
|
editorView.state,
|
|
340
341
|
editorView.dispatch,
|
|
@@ -358,7 +359,7 @@ describe('Table analytic events', () => {
|
|
|
358
359
|
|
|
359
360
|
describe('header column toggled', () => {
|
|
360
361
|
beforeEach(() => {
|
|
361
|
-
const { editorView } = editor(
|
|
362
|
+
const { editorView } = editor(defaultTableDoc);
|
|
362
363
|
toggleHeaderColumnWithAnalytics(editorAnalyticsAPIFake)(
|
|
363
364
|
editorView.state,
|
|
364
365
|
editorView.dispatch,
|
|
@@ -382,7 +383,7 @@ describe('Table analytic events', () => {
|
|
|
382
383
|
|
|
383
384
|
describe('number column toggled', () => {
|
|
384
385
|
beforeEach(() => {
|
|
385
|
-
const { editorView } = editor(
|
|
386
|
+
const { editorView } = editor(defaultTableDoc);
|
|
386
387
|
toggleNumberColumnWithAnalytics(editorAnalyticsAPIFake)(
|
|
387
388
|
editorView.state,
|
|
388
389
|
editorView.dispatch,
|
|
@@ -407,7 +408,7 @@ describe('Table analytic events', () => {
|
|
|
407
408
|
describe('layout changed', () => {
|
|
408
409
|
describe('normal', () => {
|
|
409
410
|
it('should fire v3 analytics', () => {
|
|
410
|
-
const { editorView } = editor(
|
|
411
|
+
const { editorView } = editor(defaultTableDoc);
|
|
411
412
|
toggleTableLayoutWithAnalytics(editorAnalyticsAPIFake)(
|
|
412
413
|
editorView.state,
|
|
413
414
|
editorView.dispatch,
|
|
@@ -536,7 +537,7 @@ describe('Table analytic events', () => {
|
|
|
536
537
|
describe('row added', () => {
|
|
537
538
|
describe('context menu', () => {
|
|
538
539
|
beforeEach(() => {
|
|
539
|
-
const { editorView } = editor(
|
|
540
|
+
const { editorView } = editor(defaultTableDoc);
|
|
540
541
|
insertRowWithAnalytics(editorAnalyticsAPIFake)(
|
|
541
542
|
INPUT_METHOD.CONTEXT_MENU,
|
|
542
543
|
{
|
|
@@ -565,7 +566,7 @@ describe('Table analytic events', () => {
|
|
|
565
566
|
describe('keyboard', () => {
|
|
566
567
|
describe('Tab', () => {
|
|
567
568
|
beforeEach(() => {
|
|
568
|
-
const { editorView } = editor(
|
|
569
|
+
const { editorView } = editor(defaultTableDoc);
|
|
569
570
|
sendKeyToPm(editorView, 'Tab');
|
|
570
571
|
});
|
|
571
572
|
|
|
@@ -622,7 +623,7 @@ describe('Table analytic events', () => {
|
|
|
622
623
|
return { width: 500 };
|
|
623
624
|
};
|
|
624
625
|
beforeEach(() => {
|
|
625
|
-
const { editorView } = editor(
|
|
626
|
+
const { editorView } = editor(defaultTableDoc);
|
|
626
627
|
insertColumnWithAnalytics(
|
|
627
628
|
getEditorContainerWidth,
|
|
628
629
|
editorAnalyticsAPIFake,
|
|
@@ -651,7 +652,7 @@ describe('Table analytic events', () => {
|
|
|
651
652
|
|
|
652
653
|
describe('row deleted', () => {
|
|
653
654
|
beforeEach(() => {
|
|
654
|
-
const { editorView } = editor(
|
|
655
|
+
const { editorView } = editor(defaultTableDoc);
|
|
655
656
|
deleteRowsWithAnalytics(editorAnalyticsAPIFake)(
|
|
656
657
|
INPUT_METHOD.CONTEXT_MENU,
|
|
657
658
|
secondRow,
|
|
@@ -678,7 +679,7 @@ describe('Table analytic events', () => {
|
|
|
678
679
|
|
|
679
680
|
describe('column deleted', () => {
|
|
680
681
|
beforeEach(() => {
|
|
681
|
-
const { editorView } = editor(
|
|
682
|
+
const { editorView } = editor(defaultTableDoc);
|
|
682
683
|
deleteColumnsWithAnalytics(editorAnalyticsAPIFake)(
|
|
683
684
|
INPUT_METHOD.CONTEXT_MENU,
|
|
684
685
|
secondColumn,
|
|
@@ -8,16 +8,22 @@ import {
|
|
|
8
8
|
DocBuilder,
|
|
9
9
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
10
10
|
import { removeColumnAt } from '@atlaskit/editor-tables/utils';
|
|
11
|
-
import {
|
|
11
|
+
import { PluginConfig } from '../../plugins/table/types';
|
|
12
12
|
|
|
13
13
|
import { setResizeHandlePos } from '../../plugins/table/pm-plugins/table-resizing/commands';
|
|
14
14
|
import { pluginKey as tablePluginKey } from '../../plugins/table/pm-plugins/plugin-key';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
createProsemirrorEditorFactory,
|
|
17
|
+
LightEditorPlugin,
|
|
18
|
+
Preset,
|
|
19
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
16
20
|
import tablePlugin from '../../plugins/table-plugin';
|
|
21
|
+
import widthPlugin from '@atlaskit/editor-core/src/plugins/width';
|
|
22
|
+
|
|
17
23
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
18
24
|
|
|
19
25
|
describe('Tables with Collab editing', () => {
|
|
20
|
-
const createEditor =
|
|
26
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
21
27
|
const tableOptions = {
|
|
22
28
|
allowNumberColumn: true,
|
|
23
29
|
allowHeaderRow: true,
|
|
@@ -29,12 +35,9 @@ describe('Tables with Collab editing', () => {
|
|
|
29
35
|
const editor = (doc: DocBuilder) => {
|
|
30
36
|
return createEditor({
|
|
31
37
|
doc,
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
__plugins: [tablePlugin({ tableOptions })],
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
+
preset: new Preset<LightEditorPlugin>()
|
|
39
|
+
.add([tablePlugin, { tableOptions }])
|
|
40
|
+
.add(widthPlugin),
|
|
38
41
|
pluginKey: tablePluginKey,
|
|
39
42
|
});
|
|
40
43
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createProsemirrorEditorFactory,
|
|
3
|
+
LightEditorPlugin,
|
|
4
|
+
Preset,
|
|
5
|
+
} from '@atlaskit/editor-test-helpers/create-prosemirror-editor';
|
|
2
6
|
import {
|
|
3
7
|
doc,
|
|
4
8
|
p,
|
|
@@ -12,11 +16,14 @@ import {
|
|
|
12
16
|
status,
|
|
13
17
|
} from '@atlaskit/editor-test-helpers/doc-builder';
|
|
14
18
|
import { EditorView } from 'prosemirror-view';
|
|
15
|
-
import { mentionResourceProvider } from '@atlaskit/util-data-test/mention-story-data';
|
|
16
19
|
import { sortByColumn } from '../../../plugins/table/commands/sort';
|
|
17
20
|
import { uuid } from '@atlaskit/adf-schema';
|
|
18
21
|
import { TableSortOrder as SortOrder } from '@atlaskit/adf-schema/steps';
|
|
19
22
|
import tablePlugin from '../../../plugins/table-plugin';
|
|
23
|
+
import statusPlugin from '@atlaskit/editor-core/src/plugins/status';
|
|
24
|
+
import mentionsPlugin from '@atlaskit/editor-core/src/plugins/mentions';
|
|
25
|
+
import hyperlinkPlugin from '@atlaskit/editor-core/src/plugins/hyperlink';
|
|
26
|
+
import datePlugin from '@atlaskit/editor-core/src/plugins/date';
|
|
20
27
|
|
|
21
28
|
const TABLE_LOCAL_ID = 'test-table-local-id';
|
|
22
29
|
|
|
@@ -29,14 +36,13 @@ describe('Sort Table', () => {
|
|
|
29
36
|
uuid.setStatic(false);
|
|
30
37
|
});
|
|
31
38
|
|
|
32
|
-
const createEditor =
|
|
39
|
+
const createEditor = createProsemirrorEditorFactory();
|
|
33
40
|
it('should test a basic table with heading', () => {
|
|
34
41
|
const { editorView } = createEditor({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
42
|
+
preset: new Preset<LightEditorPlugin>().add([
|
|
43
|
+
tablePlugin,
|
|
44
|
+
{ tableOptions: { allowHeaderRow: true } },
|
|
45
|
+
]),
|
|
40
46
|
doc: doc(
|
|
41
47
|
table()(
|
|
42
48
|
tr(th({})(p('Number{<>}'))),
|
|
@@ -62,11 +68,10 @@ describe('Sort Table', () => {
|
|
|
62
68
|
|
|
63
69
|
it('should test a basic table descending', () => {
|
|
64
70
|
const { editorView } = createEditor({
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
71
|
+
preset: new Preset<LightEditorPlugin>().add([
|
|
72
|
+
tablePlugin,
|
|
73
|
+
{ tableOptions: { allowHeaderRow: true } },
|
|
74
|
+
]),
|
|
70
75
|
doc: doc(
|
|
71
76
|
table()(tr(td({})(p('2{<>}'))), tr(td({})(p('5'))), tr(td({})(p('4')))),
|
|
72
77
|
),
|
|
@@ -86,11 +91,10 @@ describe('Sort Table', () => {
|
|
|
86
91
|
|
|
87
92
|
it('should test a basic table ascending', () => {
|
|
88
93
|
const { editorView } = createEditor({
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
},
|
|
94
|
+
preset: new Preset<LightEditorPlugin>().add([
|
|
95
|
+
tablePlugin,
|
|
96
|
+
{ tableOptions: { allowHeaderRow: true } },
|
|
97
|
+
]),
|
|
94
98
|
doc: doc(
|
|
95
99
|
table()(tr(td({})(p('2{<>}'))), tr(td({})(p('5'))), tr(td({})(p('4')))),
|
|
96
100
|
),
|
|
@@ -113,16 +117,12 @@ describe('Sort Table', () => {
|
|
|
113
117
|
|
|
114
118
|
beforeEach(() => {
|
|
115
119
|
({ editorView } = createEditor({
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
],
|
|
123
|
-
},
|
|
124
|
-
mentionProvider: Promise.resolve(mentionResourceProvider),
|
|
125
|
-
},
|
|
120
|
+
preset: new Preset<LightEditorPlugin>()
|
|
121
|
+
.add([tablePlugin, { tableOptions: { allowHeaderRow: true } }])
|
|
122
|
+
.add([statusPlugin, { menuDisabled: false }])
|
|
123
|
+
.add(mentionsPlugin)
|
|
124
|
+
.add(hyperlinkPlugin)
|
|
125
|
+
.add(datePlugin),
|
|
126
126
|
doc: doc(
|
|
127
127
|
table()(
|
|
128
128
|
tr(th({})(p('Mixed{<>}'))),
|
|
@@ -49,14 +49,12 @@ const array = (...args: any): Node[] => args.map((i: any) => i(defaultSchema));
|
|
|
49
49
|
const fragment = (...args: any) =>
|
|
50
50
|
Fragment.from(args.map((i: any) => i(defaultSchema)));
|
|
51
51
|
|
|
52
|
-
const selectCell =
|
|
53
|
-
pos: number;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return tr.setSelection(new CellSelection($anchor, $anchor) as any);
|
|
59
|
-
};
|
|
52
|
+
const selectCell =
|
|
53
|
+
(cell: { pos: number; start: number; node: ProsemirrorNode }) =>
|
|
54
|
+
(tr: Transaction) => {
|
|
55
|
+
const $anchor = tr.doc.resolve(cell.pos);
|
|
56
|
+
return tr.setSelection(new CellSelection($anchor, $anchor) as any);
|
|
57
|
+
};
|
|
60
58
|
|
|
61
59
|
const copySelectionAndPasteAtPos = ({
|
|
62
60
|
editorView,
|