@atlaskit/editor-plugin-table 5.5.11 → 5.5.12
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 +6 -0
- package/dist/cjs/plugins/table/commands/insert.js +17 -2
- package/dist/cjs/plugins/table/index.js +5 -1
- package/dist/es2019/plugins/table/commands/insert.js +15 -1
- package/dist/es2019/plugins/table/index.js +5 -1
- package/dist/esm/plugins/table/commands/insert.js +16 -1
- package/dist/esm/plugins/table/index.js +5 -1
- package/dist/types/plugins/table/commands/insert.d.ts +3 -1
- package/dist/types/plugins/table/index.d.ts +5 -1
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +3 -1
- package/dist/types-ts4.5/plugins/table/index.d.ts +5 -1
- package/package.json +1 -1
- package/src/plugins/table/commands/insert.ts +26 -0
- package/src/plugins/table/index.tsx +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-table
|
|
2
2
|
|
|
3
|
+
## 5.5.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60612](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60612) [`7edc766361a2`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7edc766361a2) - Created an EditorCommad on table plugin to insert a table of custom size
|
|
8
|
+
|
|
3
9
|
## 5.5.11
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.addColumnAfter = void 0;
|
|
7
7
|
exports.addColumnAt = addColumnAt;
|
|
8
|
-
exports.insertRow = exports.insertColumn = exports.createTable = exports.addColumnBefore = void 0;
|
|
8
|
+
exports.insertTableWithSize = exports.insertRow = exports.insertColumn = exports.createTable = exports.addColumnBefore = void 0;
|
|
9
9
|
var _customSteps = require("@atlaskit/custom-steps");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -154,4 +154,19 @@ var createTable = exports.createTable = function createTable() {
|
|
|
154
154
|
return true;
|
|
155
155
|
};
|
|
156
156
|
};
|
|
157
|
-
// #endregion
|
|
157
|
+
// #endregion
|
|
158
|
+
|
|
159
|
+
var insertTableWithSize = exports.insertTableWithSize = function insertTableWithSize(editorAnalyticsAPI) {
|
|
160
|
+
return function (rowsCount, colsCount, inputMethod) {
|
|
161
|
+
return function (_ref) {
|
|
162
|
+
var tr = _ref.tr;
|
|
163
|
+
var tableNode = (0, _utils2.createTable)({
|
|
164
|
+
schema: tr.doc.type.schema,
|
|
165
|
+
rowsCount: rowsCount,
|
|
166
|
+
colsCount: colsCount
|
|
167
|
+
});
|
|
168
|
+
var newTr = (0, _utils.safeInsert)(tableNode)(tr).scrollIntoView();
|
|
169
|
+
return newTr;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
};
|
|
@@ -18,6 +18,7 @@ var _withPluginState = require("@atlaskit/editor-common/with-plugin-state");
|
|
|
18
18
|
var _pmPlugins = require("@atlaskit/editor-tables/pm-plugins");
|
|
19
19
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
20
20
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
21
|
+
var _insert = require("./commands/insert");
|
|
21
22
|
var _createPluginConfig = require("./create-plugin-config");
|
|
22
23
|
var _plugin = require("./pm-plugins/analytics/plugin");
|
|
23
24
|
var _pluginKey = require("./pm-plugins/analytics/plugin-key");
|
|
@@ -49,7 +50,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
49
50
|
* from `@atlaskit/editor-core`.
|
|
50
51
|
*/
|
|
51
52
|
var tablesPlugin = function tablesPlugin(_ref) {
|
|
52
|
-
var _api$analytics;
|
|
53
|
+
var _api$analytics, _api$analytics2;
|
|
53
54
|
var options = _ref.config,
|
|
54
55
|
api = _ref.api;
|
|
55
56
|
var editorViewRef = {
|
|
@@ -84,6 +85,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
84
85
|
};
|
|
85
86
|
}
|
|
86
87
|
},
|
|
88
|
+
commands: {
|
|
89
|
+
insertTableWithSize: (0, _insert.insertTableWithSize)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
90
|
+
},
|
|
87
91
|
nodes: function nodes() {
|
|
88
92
|
var tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? _adfSchema.tableWithCustomWidth : _adfSchema.table;
|
|
89
93
|
return [{
|
|
@@ -133,4 +133,18 @@ export const createTable = () => (state, dispatch) => {
|
|
|
133
133
|
}
|
|
134
134
|
return true;
|
|
135
135
|
};
|
|
136
|
-
// #endregion
|
|
136
|
+
// #endregion
|
|
137
|
+
|
|
138
|
+
export const insertTableWithSize = editorAnalyticsAPI => (rowsCount, colsCount, inputMethod) => {
|
|
139
|
+
return ({
|
|
140
|
+
tr
|
|
141
|
+
}) => {
|
|
142
|
+
const tableNode = createTableNode({
|
|
143
|
+
schema: tr.doc.type.schema,
|
|
144
|
+
rowsCount: rowsCount,
|
|
145
|
+
colsCount: colsCount
|
|
146
|
+
});
|
|
147
|
+
const newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
148
|
+
return newTr;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
@@ -11,6 +11,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
11
11
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
12
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { insertTableWithSize } from './commands/insert';
|
|
14
15
|
import { pluginConfig } from './create-plugin-config';
|
|
15
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
16
17
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -43,7 +44,7 @@ const tablesPlugin = ({
|
|
|
43
44
|
config: options,
|
|
44
45
|
api
|
|
45
46
|
}) => {
|
|
46
|
-
var _api$analytics;
|
|
47
|
+
var _api$analytics, _api$analytics2;
|
|
47
48
|
const editorViewRef = {
|
|
48
49
|
current: null
|
|
49
50
|
};
|
|
@@ -74,6 +75,9 @@ const tablesPlugin = ({
|
|
|
74
75
|
})) !== null && _api$contentInsertion !== void 0 ? _api$contentInsertion : false;
|
|
75
76
|
}
|
|
76
77
|
},
|
|
78
|
+
commands: {
|
|
79
|
+
insertTableWithSize: insertTableWithSize(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
80
|
+
},
|
|
77
81
|
nodes() {
|
|
78
82
|
const tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
79
83
|
return [{
|
|
@@ -145,4 +145,19 @@ export var createTable = function createTable() {
|
|
|
145
145
|
return true;
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
// #endregion
|
|
148
|
+
// #endregion
|
|
149
|
+
|
|
150
|
+
export var insertTableWithSize = function insertTableWithSize(editorAnalyticsAPI) {
|
|
151
|
+
return function (rowsCount, colsCount, inputMethod) {
|
|
152
|
+
return function (_ref) {
|
|
153
|
+
var tr = _ref.tr;
|
|
154
|
+
var tableNode = createTableNode({
|
|
155
|
+
schema: tr.doc.type.schema,
|
|
156
|
+
rowsCount: rowsCount,
|
|
157
|
+
colsCount: colsCount
|
|
158
|
+
});
|
|
159
|
+
var newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
160
|
+
return newTr;
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
@@ -11,6 +11,7 @@ import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
|
11
11
|
import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
12
12
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
13
13
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
14
|
+
import { insertTableWithSize } from './commands/insert';
|
|
14
15
|
import { pluginConfig } from './create-plugin-config';
|
|
15
16
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
16
17
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -42,7 +43,7 @@ var defaultGetEditorFeatureFlags = function defaultGetEditorFeatureFlags() {
|
|
|
42
43
|
* from `@atlaskit/editor-core`.
|
|
43
44
|
*/
|
|
44
45
|
var tablesPlugin = function tablesPlugin(_ref) {
|
|
45
|
-
var _api$analytics;
|
|
46
|
+
var _api$analytics, _api$analytics2;
|
|
46
47
|
var options = _ref.config,
|
|
47
48
|
api = _ref.api;
|
|
48
49
|
var editorViewRef = {
|
|
@@ -77,6 +78,9 @@ var tablesPlugin = function tablesPlugin(_ref) {
|
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
},
|
|
81
|
+
commands: {
|
|
82
|
+
insertTableWithSize: insertTableWithSize(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)
|
|
83
|
+
},
|
|
80
84
|
nodes: function nodes() {
|
|
81
85
|
var tableNode = options !== null && options !== void 0 && options.tableResizingEnabled ? tableWithCustomWidth : table;
|
|
82
86
|
return [{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, EditorCommand, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -7,3 +8,4 @@ export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContaine
|
|
|
7
8
|
export declare const insertColumn: (getEditorContainerWidth: GetEditorContainerWidth) => (column: number) => Command;
|
|
8
9
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean) => Command;
|
|
9
10
|
export declare const createTable: () => Command;
|
|
11
|
+
export declare const insertTableWithSize: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
6
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
@@ -22,6 +23,9 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
22
23
|
actions: {
|
|
23
24
|
insertTable: InsertTableAction;
|
|
24
25
|
};
|
|
26
|
+
commands: {
|
|
27
|
+
insertTableWithSize: (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
28
|
+
};
|
|
25
29
|
dependencies: [
|
|
26
30
|
AnalyticsPlugin,
|
|
27
31
|
ContentInsertionPlugin,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { Command, EditorCommand, GetEditorContainerWidth } from '@atlaskit/editor-common/types';
|
|
2
3
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
4
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
4
5
|
export declare function addColumnAt(getEditorContainerWidth: GetEditorContainerWidth): (column: number, allowAddColumnCustomStep: boolean | undefined, view: EditorView | undefined) => (tr: Transaction) => Transaction;
|
|
@@ -7,3 +8,4 @@ export declare const addColumnAfter: (getEditorContainerWidth: GetEditorContaine
|
|
|
7
8
|
export declare const insertColumn: (getEditorContainerWidth: GetEditorContainerWidth) => (column: number) => Command;
|
|
8
9
|
export declare const insertRow: (row: number, moveCursorToTheNewRow: boolean) => Command;
|
|
9
10
|
export declare const createTable: () => Command;
|
|
11
|
+
export declare const insertTableWithSize: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AnalyticsEventPayload } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, EditorCommand, GetEditorFeatureFlags, NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
5
|
import type { ContentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
5
6
|
import type { GuidelinePlugin } from '@atlaskit/editor-plugin-guideline';
|
|
@@ -22,6 +23,9 @@ export type TablePlugin = NextEditorPlugin<'table', {
|
|
|
22
23
|
actions: {
|
|
23
24
|
insertTable: InsertTableAction;
|
|
24
25
|
};
|
|
26
|
+
commands: {
|
|
27
|
+
insertTableWithSize: (rowsCount: number, colsCount: number, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
|
|
28
|
+
};
|
|
25
29
|
dependencies: [
|
|
26
30
|
AnalyticsPlugin,
|
|
27
31
|
ContentInsertionPlugin,
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
// #region Imports
|
|
2
2
|
import { AddColumnStep } from '@atlaskit/custom-steps';
|
|
3
|
+
import type {
|
|
4
|
+
EditorAnalyticsAPI,
|
|
5
|
+
INPUT_METHOD,
|
|
6
|
+
} from '@atlaskit/editor-common/analytics';
|
|
3
7
|
import { TABLE_OVERFLOW_CHANGE_TRIGGER } from '@atlaskit/editor-common/analytics';
|
|
4
8
|
import type {
|
|
5
9
|
Command,
|
|
10
|
+
EditorCommand,
|
|
6
11
|
GetEditorContainerWidth,
|
|
7
12
|
} from '@atlaskit/editor-common/types';
|
|
8
13
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -201,3 +206,24 @@ export const createTable = (): Command => (state, dispatch) => {
|
|
|
201
206
|
return true;
|
|
202
207
|
};
|
|
203
208
|
// #endregion
|
|
209
|
+
|
|
210
|
+
export const insertTableWithSize =
|
|
211
|
+
(editorAnalyticsAPI: EditorAnalyticsAPI | undefined) =>
|
|
212
|
+
(
|
|
213
|
+
rowsCount: number,
|
|
214
|
+
colsCount: number,
|
|
215
|
+
inputMethod?:
|
|
216
|
+
| INPUT_METHOD.PICKER
|
|
217
|
+
| INPUT_METHOD.ASCII
|
|
218
|
+
| INPUT_METHOD.TYPEAHEAD,
|
|
219
|
+
): EditorCommand => {
|
|
220
|
+
return ({ tr }) => {
|
|
221
|
+
const tableNode = createTableNode({
|
|
222
|
+
schema: tr.doc.type.schema,
|
|
223
|
+
rowsCount: rowsCount,
|
|
224
|
+
colsCount: colsCount,
|
|
225
|
+
});
|
|
226
|
+
const newTr = safeInsert(tableNode)(tr).scrollIntoView();
|
|
227
|
+
return newTr;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
@@ -23,6 +23,7 @@ import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/
|
|
|
23
23
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
24
24
|
import type {
|
|
25
25
|
Command,
|
|
26
|
+
EditorCommand,
|
|
26
27
|
EditorPlugin,
|
|
27
28
|
GetEditorContainerWidth,
|
|
28
29
|
GetEditorFeatureFlags,
|
|
@@ -41,6 +42,7 @@ import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
|
|
|
41
42
|
import { createTable } from '@atlaskit/editor-tables/utils';
|
|
42
43
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
43
44
|
|
|
45
|
+
import { insertTableWithSize } from './commands/insert';
|
|
44
46
|
import { pluginConfig } from './create-plugin-config';
|
|
45
47
|
import { createPlugin as createTableAnalyticsPlugin } from './pm-plugins/analytics/plugin';
|
|
46
48
|
import { pluginKey as tableAnalyticsPluginKey } from './pm-plugins/analytics/plugin-key';
|
|
@@ -78,6 +80,7 @@ import FloatingDragMenu from './ui/FloatingDragMenu';
|
|
|
78
80
|
import FloatingInsertButton from './ui/FloatingInsertButton';
|
|
79
81
|
import LayoutButton from './ui/LayoutButton';
|
|
80
82
|
import { isLayoutSupported } from './utils';
|
|
83
|
+
|
|
81
84
|
export interface TablePluginOptions {
|
|
82
85
|
tableOptions: PluginConfig;
|
|
83
86
|
// experimental custom table resizing experience, set inside editor-core behind a feature flag
|
|
@@ -103,6 +106,16 @@ export type TablePlugin = NextEditorPlugin<
|
|
|
103
106
|
actions: {
|
|
104
107
|
insertTable: InsertTableAction;
|
|
105
108
|
};
|
|
109
|
+
commands: {
|
|
110
|
+
insertTableWithSize: (
|
|
111
|
+
rowsCount: number,
|
|
112
|
+
colsCount: number,
|
|
113
|
+
inputMethod?:
|
|
114
|
+
| INPUT_METHOD.PICKER
|
|
115
|
+
| INPUT_METHOD.ASCII
|
|
116
|
+
| INPUT_METHOD.TYPEAHEAD,
|
|
117
|
+
) => EditorCommand;
|
|
118
|
+
};
|
|
106
119
|
dependencies: [
|
|
107
120
|
AnalyticsPlugin,
|
|
108
121
|
ContentInsertionPlugin,
|
|
@@ -152,6 +165,9 @@ const tablesPlugin: TablePlugin = ({ config: options, api }) => {
|
|
|
152
165
|
);
|
|
153
166
|
},
|
|
154
167
|
},
|
|
168
|
+
commands: {
|
|
169
|
+
insertTableWithSize: insertTableWithSize(api?.analytics?.actions),
|
|
170
|
+
},
|
|
155
171
|
|
|
156
172
|
nodes() {
|
|
157
173
|
const tableNode = options?.tableResizingEnabled
|