@atlaskit/editor-plugin-table 0.0.1 → 0.0.2

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.
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
3
  import { browser } from '@atlaskit/editor-common/utils';
3
4
  import { tableEditing } from '@atlaskit/editor-tables/pm-plugins';
4
5
  import { createTable } from '@atlaskit/editor-tables/utils';
@@ -29,280 +30,311 @@ import LayoutButton from './ui/LayoutButton';
29
30
  import { isLayoutSupported } from './utils';
30
31
  import { ErrorBoundary } from '@atlaskit/editor-common/error-boundary';
31
32
 
32
- const defaultGetEditorContainerWidth = () => {
33
- var _document, _document$body;
33
+ const defaultGetEditorFeatureFlags = () => ({});
34
34
 
35
- return {
36
- width: ((_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) || 500
35
+ const tablesPlugin = options => {
36
+ const editorViewRef = {
37
+ current: null
37
38
  };
38
- };
39
-
40
- const defaultGetEditorFeatureFlags = () => ({});
41
39
 
42
- const tablesPlugin = options => ({
43
- name: 'table',
40
+ const defaultGetEditorContainerWidth = () => {
41
+ if (!editorViewRef.current) {
42
+ var _document, _document$body;
44
43
 
45
- nodes() {
46
- return [{
47
- name: 'table',
48
- node: table
49
- }, {
50
- name: 'tableHeader',
51
- node: tableHeader
52
- }, {
53
- name: 'tableRow',
54
- node: tableRow
55
- }, {
56
- name: 'tableCell',
57
- node: tableCell
58
- }];
59
- },
44
+ return {
45
+ width: ((_document = document) === null || _document === void 0 ? void 0 : (_document$body = _document.body) === null || _document$body === void 0 ? void 0 : _document$body.offsetWidth) || 500
46
+ };
47
+ }
60
48
 
61
- pmPlugins() {
62
- const plugins = [{
63
- name: 'table',
64
- plugin: ({
65
- dispatchAnalyticsEvent,
66
- dispatch,
67
- portalProviderAPI,
68
- eventDispatcher
69
- }) => {
70
- const {
71
- fullWidthEnabled,
72
- wasFullWidthEnabled,
73
- breakoutEnabled,
74
- tableOptions,
75
- editorAnalyticsAPI,
76
- getEditorFeatureFlags
77
- } = options || {};
78
- return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), (options === null || options === void 0 ? void 0 : options.getEditorContainerWidth) || defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
79
- }
80
- }, {
81
- name: 'tablePMColResizing',
82
- plugin: ({
83
- dispatch
84
- }) => {
85
- const {
86
- fullWidthEnabled,
87
- tableOptions,
88
- editorAnalyticsAPI,
89
- getEditorContainerWidth,
90
- getEditorFeatureFlags
91
- } = options || {};
92
- const {
93
- allowColumnResizing
94
- } = pluginConfig(tableOptions);
95
- return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
96
- lastColumnResizable: !fullWidthEnabled
97
- }, getEditorContainerWidth || defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI) : undefined;
49
+ const {
50
+ current: {
51
+ state
98
52
  }
99
- }, {
100
- name: 'tableEditing',
101
- plugin: () => createDecorationsPlugin()
102
- }, // Needs to be lower priority than editor-tables.tableEditing
103
- // plugin as it is currently swallowing backspace events inside tables
104
- {
105
- name: 'tableKeymap',
106
- plugin: () => keymapPlugin((options === null || options === void 0 ? void 0 : options.getEditorContainerWidth) || defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)
107
- }, {
108
- name: 'tableSelectionKeymap',
109
- plugin: () => tableSelectionKeymapPlugin(options === null || options === void 0 ? void 0 : options.editorSelectionAPI)
110
- }, {
111
- name: 'tableEditing',
112
- plugin: () => tableEditing()
113
- }, {
114
- name: 'tableStickyHeaders',
115
- plugin: ({
116
- dispatch,
117
- eventDispatcher
118
- }) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, () => [], (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined
119
- }, {
120
- name: 'tableLocalId',
121
- plugin: ({
122
- dispatch
123
- }) => createTableLocalIdPlugin(dispatch)
124
- }]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
125
- // causing issues with table selections in Safari
126
- // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
127
- // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
128
- // https://github.com/ProseMirror/prosemirror-view/pull/116
53
+ } = editorViewRef; // TODO: ED-15663
54
+ // Please, do not copy or use this kind of code below
55
+ // @ts-ignore
129
56
 
130
- if (browser.safari) {
131
- plugins.push({
132
- name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
133
- plugin: () => {
134
- return createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin();
135
- }
136
- });
137
- } // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
138
- // https://github.com/ProseMirror/prosemirror/issues/934
57
+ return state['widthPlugin$'];
58
+ };
139
59
 
60
+ return {
61
+ name: 'table',
140
62
 
141
- if (browser.safari) {
142
- plugins.push({
143
- name: 'tableSafariDeleteCompositionTextIssueWorkaround',
63
+ nodes() {
64
+ return [{
65
+ name: 'table',
66
+ node: table
67
+ }, {
68
+ name: 'tableHeader',
69
+ node: tableHeader
70
+ }, {
71
+ name: 'tableRow',
72
+ node: tableRow
73
+ }, {
74
+ name: 'tableCell',
75
+ node: tableCell
76
+ }];
77
+ },
78
+
79
+ pmPlugins() {
80
+ const plugins = [{
81
+ name: 'table',
82
+ plugin: ({
83
+ dispatchAnalyticsEvent,
84
+ dispatch,
85
+ portalProviderAPI,
86
+ eventDispatcher
87
+ }) => {
88
+ const {
89
+ fullWidthEnabled,
90
+ wasFullWidthEnabled,
91
+ breakoutEnabled,
92
+ tableOptions,
93
+ editorAnalyticsAPI,
94
+ getEditorFeatureFlags
95
+ } = options || {};
96
+ return createPlugin(dispatchAnalyticsEvent, dispatch, portalProviderAPI, eventDispatcher, pluginConfig(tableOptions), defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, breakoutEnabled, fullWidthEnabled, wasFullWidthEnabled, editorAnalyticsAPI);
97
+ }
98
+ }, {
99
+ name: 'tablePMColResizing',
100
+ plugin: ({
101
+ dispatch
102
+ }) => {
103
+ const {
104
+ fullWidthEnabled,
105
+ tableOptions,
106
+ editorAnalyticsAPI,
107
+ getEditorFeatureFlags
108
+ } = options || {};
109
+ const {
110
+ allowColumnResizing
111
+ } = pluginConfig(tableOptions);
112
+ return allowColumnResizing ? createFlexiResizingPlugin(dispatch, {
113
+ lastColumnResizable: !fullWidthEnabled
114
+ }, defaultGetEditorContainerWidth, getEditorFeatureFlags || defaultGetEditorFeatureFlags, editorAnalyticsAPI) : undefined;
115
+ }
116
+ }, {
117
+ name: 'tableEditing',
118
+ plugin: () => createDecorationsPlugin()
119
+ }, // Needs to be lower priority than editor-tables.tableEditing
120
+ // plugin as it is currently swallowing backspace events inside tables
121
+ {
122
+ name: 'tableKeymap',
123
+ plugin: () => keymapPlugin(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)
124
+ }, {
125
+ name: 'tableSelectionKeymap',
126
+ plugin: () => tableSelectionKeymapPlugin(options === null || options === void 0 ? void 0 : options.editorSelectionAPI)
127
+ }, {
128
+ name: 'tableEditing',
129
+ plugin: () => tableEditing()
130
+ }, {
131
+ name: 'tableStickyHeaders',
132
+ plugin: ({
133
+ dispatch,
134
+ eventDispatcher
135
+ }) => options && options.tableOptions.stickyHeaders ? createStickyHeadersPlugin(dispatch, eventDispatcher, () => [], (options === null || options === void 0 ? void 0 : options.getEditorFeatureFlags) || defaultGetEditorFeatureFlags) : undefined
136
+ }, {
137
+ name: 'tableLocalId',
138
+ plugin: ({
139
+ dispatch
140
+ }) => createTableLocalIdPlugin(dispatch)
141
+ }, {
142
+ name: 'tableGetEditorViewReferencePlugin',
144
143
  plugin: () => {
145
- return createTableSafariDeleteCompositionTextIssueWorkaroundPlugin();
144
+ return new SafePlugin({
145
+ view: editorView => {
146
+ editorViewRef.current = editorView;
147
+ return {
148
+ destroy: () => {
149
+ editorViewRef.current = null;
150
+ }
151
+ };
152
+ }
153
+ });
146
154
  }
147
- });
148
- }
155
+ }]; // workaround for prosemirrors delayed dom selection syncing during pointer drag
156
+ // causing issues with table selections in Safari
157
+ // https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
158
+ // NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
159
+ // https://github.com/ProseMirror/prosemirror-view/pull/116
149
160
 
150
- return plugins;
151
- },
161
+ if (browser.safari) {
162
+ plugins.push({
163
+ name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
164
+ plugin: () => {
165
+ return createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin();
166
+ }
167
+ });
168
+ } // Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
169
+ // https://github.com/ProseMirror/prosemirror/issues/934
152
170
 
153
- contentComponent({
154
- editorView,
155
- popupsMountPoint,
156
- popupsBoundariesElement,
157
- popupsScrollableElement,
158
- dispatchAnalyticsEvent
159
- }) {
160
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
161
- component: ACTION_SUBJECT.TABLES_PLUGIN,
162
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
163
- fallbackComponent: null
164
- }, /*#__PURE__*/React.createElement(WithPluginState, {
165
- plugins: {
166
- tablePluginState: pluginKey,
167
- tableResizingPluginState: tableResizingPluginKey,
168
- stickyHeadersState: stickyHeadersPluginKey
169
- },
170
- render: ({
171
- tableResizingPluginState: resizingPluginState,
172
- stickyHeadersState,
173
- tablePluginState
174
- }) => {
175
- const {
176
- state
177
- } = editorView;
178
- const isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
179
- const {
180
- tableNode,
181
- tablePos,
182
- targetCellPosition,
183
- isContextualMenuOpen,
184
- layout,
185
- tableRef,
186
- pluginConfig,
187
- insertColumnButtonIndex,
188
- insertRowButtonIndex,
189
- isHeaderColumnEnabled,
190
- isHeaderRowEnabled,
191
- tableWrapperTarget
192
- } = tablePluginState;
193
- const {
194
- allowControls
195
- } = pluginConfig;
196
- const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
197
- return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
198
- isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
199
- editorView: editorView,
200
- tableNode: tableNode,
201
- mountPoint: popupsMountPoint,
202
- targetCellPosition: targetCellPosition,
203
- scrollableElement: popupsScrollableElement,
204
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
205
- isContextualMenuOpen: isContextualMenuOpen,
206
- layout: layout,
207
- stickyHeader: stickyHeader
208
- }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
209
- tableNode: tableNode,
210
- tableRef: tableRef,
211
- insertColumnButtonIndex: insertColumnButtonIndex,
212
- insertRowButtonIndex: insertRowButtonIndex,
213
- isHeaderColumnEnabled: isHeaderColumnEnabled,
214
- isHeaderRowEnabled: isHeaderRowEnabled,
215
- editorView: editorView,
216
- mountPoint: popupsMountPoint,
217
- boundariesElement: popupsBoundariesElement,
218
- scrollableElement: popupsScrollableElement,
219
- hasStickyHeaders: stickyHeader && stickyHeader.sticky,
220
- dispatchAnalyticsEvent: dispatchAnalyticsEvent,
221
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
222
- getEditorContainerWidth: (options === null || options === void 0 ? void 0 : options.getEditorContainerWidth) || defaultGetEditorContainerWidth
223
- }), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
224
- editorView: editorView,
225
- mountPoint: popupsMountPoint,
226
- boundariesElement: popupsBoundariesElement,
227
- targetCellPosition: targetCellPosition,
228
- isOpen: Boolean(isContextualMenuOpen),
229
- pluginConfig: pluginConfig,
230
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
231
- getEditorContainerWidth: (options === null || options === void 0 ? void 0 : options.getEditorContainerWidth) || defaultGetEditorContainerWidth
232
- }), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
233
- editorView: editorView,
234
- selection: editorView.state.selection,
235
- tableRef: tableRef,
236
- mountPoint: popupsMountPoint,
237
- boundariesElement: popupsBoundariesElement,
238
- scrollableElement: popupsScrollableElement,
239
- stickyHeaders: stickyHeader,
240
- isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
241
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
242
- }), isLayoutSupported(state) && options && options.breakoutEnabled && /*#__PURE__*/React.createElement(LayoutButton, {
243
- editorView: editorView,
244
- mountPoint: popupsMountPoint,
245
- boundariesElement: popupsBoundariesElement,
246
- scrollableElement: popupsScrollableElement,
247
- targetRef: tableWrapperTarget,
248
- layout: layout,
249
- isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
250
- stickyHeader: stickyHeader,
251
- editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
252
- }));
253
- }
254
- }));
255
- },
256
171
 
257
- pluginsOptions: {
258
- // TODO: ED-14676 This is not the final API design
259
- // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
260
- createNodeHandler: ({
261
- nodeName,
262
- schema
263
- }) => {
264
- // An EditorPlugin may manage more than one node.
265
- if (nodeName !== 'table') {
266
- return null;
172
+ if (browser.safari) {
173
+ plugins.push({
174
+ name: 'tableSafariDeleteCompositionTextIssueWorkaround',
175
+ plugin: () => {
176
+ return createTableSafariDeleteCompositionTextIssueWorkaroundPlugin();
177
+ }
178
+ });
267
179
  }
268
180
 
269
- const table = createTable({
270
- schema
271
- });
272
- return table;
181
+ return plugins;
273
182
  },
274
- quickInsert: ({
275
- formatMessage
276
- }) => [{
277
- id: 'table',
278
- title: formatMessage(messages.table),
279
- description: formatMessage(messages.tableDescription),
280
- keywords: ['cell', 'table'],
281
- priority: 600,
282
- keyshortcut: tooltip(toggleTable),
283
183
 
284
- // icon: () => <IconTable />,
285
- action(insert, state) {
286
- var _options$editorAnalyt;
184
+ contentComponent({
185
+ editorView,
186
+ popupsMountPoint,
187
+ popupsBoundariesElement,
188
+ popupsScrollableElement,
189
+ dispatchAnalyticsEvent
190
+ }) {
191
+ return /*#__PURE__*/React.createElement(ErrorBoundary, {
192
+ component: ACTION_SUBJECT.TABLES_PLUGIN,
193
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
194
+ fallbackComponent: null
195
+ }, /*#__PURE__*/React.createElement(WithPluginState, {
196
+ plugins: {
197
+ tablePluginState: pluginKey,
198
+ tableResizingPluginState: tableResizingPluginKey,
199
+ stickyHeadersState: stickyHeadersPluginKey
200
+ },
201
+ render: ({
202
+ tableResizingPluginState: resizingPluginState,
203
+ stickyHeadersState,
204
+ tablePluginState
205
+ }) => {
206
+ const {
207
+ state
208
+ } = editorView;
209
+ const isDragging = resizingPluginState === null || resizingPluginState === void 0 ? void 0 : resizingPluginState.dragging;
210
+ const {
211
+ tableNode,
212
+ tablePos,
213
+ targetCellPosition,
214
+ isContextualMenuOpen,
215
+ layout,
216
+ tableRef,
217
+ pluginConfig,
218
+ insertColumnButtonIndex,
219
+ insertRowButtonIndex,
220
+ isHeaderColumnEnabled,
221
+ isHeaderRowEnabled,
222
+ tableWrapperTarget
223
+ } = tablePluginState;
224
+ const {
225
+ allowControls
226
+ } = pluginConfig;
227
+ const stickyHeader = stickyHeadersState ? findStickyHeaderForTable(stickyHeadersState, tablePos) : undefined;
228
+ return /*#__PURE__*/React.createElement(React.Fragment, null, targetCellPosition && tableRef && !isDragging && options && options.allowContextualMenu && /*#__PURE__*/React.createElement(FloatingContextualButton, {
229
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
230
+ editorView: editorView,
231
+ tableNode: tableNode,
232
+ mountPoint: popupsMountPoint,
233
+ targetCellPosition: targetCellPosition,
234
+ scrollableElement: popupsScrollableElement,
235
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
236
+ isContextualMenuOpen: isContextualMenuOpen,
237
+ layout: layout,
238
+ stickyHeader: stickyHeader
239
+ }), allowControls && /*#__PURE__*/React.createElement(FloatingInsertButton, {
240
+ tableNode: tableNode,
241
+ tableRef: tableRef,
242
+ insertColumnButtonIndex: insertColumnButtonIndex,
243
+ insertRowButtonIndex: insertRowButtonIndex,
244
+ isHeaderColumnEnabled: isHeaderColumnEnabled,
245
+ isHeaderRowEnabled: isHeaderRowEnabled,
246
+ editorView: editorView,
247
+ mountPoint: popupsMountPoint,
248
+ boundariesElement: popupsBoundariesElement,
249
+ scrollableElement: popupsScrollableElement,
250
+ hasStickyHeaders: stickyHeader && stickyHeader.sticky,
251
+ dispatchAnalyticsEvent: dispatchAnalyticsEvent,
252
+ editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
253
+ getEditorContainerWidth: defaultGetEditorContainerWidth
254
+ }), /*#__PURE__*/React.createElement(FloatingContextualMenu, {
255
+ editorView: editorView,
256
+ mountPoint: popupsMountPoint,
257
+ boundariesElement: popupsBoundariesElement,
258
+ targetCellPosition: targetCellPosition,
259
+ isOpen: Boolean(isContextualMenuOpen),
260
+ pluginConfig: pluginConfig,
261
+ editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI,
262
+ getEditorContainerWidth: defaultGetEditorContainerWidth
263
+ }), allowControls && /*#__PURE__*/React.createElement(FloatingDeleteButton, {
264
+ editorView: editorView,
265
+ selection: editorView.state.selection,
266
+ tableRef: tableRef,
267
+ mountPoint: popupsMountPoint,
268
+ boundariesElement: popupsBoundariesElement,
269
+ scrollableElement: popupsScrollableElement,
270
+ stickyHeaders: stickyHeader,
271
+ isNumberColumnEnabled: tableNode && tableNode.attrs.isNumberColumnEnabled,
272
+ editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
273
+ }), isLayoutSupported(state) && options && options.breakoutEnabled && /*#__PURE__*/React.createElement(LayoutButton, {
274
+ editorView: editorView,
275
+ mountPoint: popupsMountPoint,
276
+ boundariesElement: popupsBoundariesElement,
277
+ scrollableElement: popupsScrollableElement,
278
+ targetRef: tableWrapperTarget,
279
+ layout: layout,
280
+ isResizing: !!resizingPluginState && !!resizingPluginState.dragging,
281
+ stickyHeader: stickyHeader,
282
+ editorAnalyticsAPI: options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI
283
+ }));
284
+ }
285
+ }));
286
+ },
287
287
 
288
- const tr = insert(createTable({
289
- schema: state.schema
290
- }));
291
- options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
292
- action: ACTION.INSERTED,
293
- actionSubject: ACTION_SUBJECT.DOCUMENT,
294
- actionSubjectId: ACTION_SUBJECT_ID.TABLE,
295
- attributes: {
296
- inputMethod: INPUT_METHOD.QUICK_INSERT
297
- },
298
- eventType: EVENT_TYPE.TRACK
299
- })(tr);
300
- return tr;
301
- }
288
+ pluginsOptions: {
289
+ // TODO: ED-14676 This is not the final API design
290
+ // For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
291
+ createNodeHandler: ({
292
+ nodeName,
293
+ schema
294
+ }) => {
295
+ // An EditorPlugin may manage more than one node.
296
+ if (nodeName !== 'table') {
297
+ return null;
298
+ }
299
+
300
+ const table = createTable({
301
+ schema
302
+ });
303
+ return table;
304
+ },
305
+ quickInsert: ({
306
+ formatMessage
307
+ }) => [{
308
+ id: 'table',
309
+ title: formatMessage(messages.table),
310
+ description: formatMessage(messages.tableDescription),
311
+ keywords: ['cell', 'table'],
312
+ priority: 600,
313
+ keyshortcut: tooltip(toggleTable),
302
314
 
303
- }],
304
- floatingToolbar: getToolbarConfig((options === null || options === void 0 ? void 0 : options.getEditorContainerWidth) || defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
305
- }
306
- });
315
+ // icon: () => <IconTable />,
316
+ action(insert, state) {
317
+ var _options$editorAnalyt;
318
+
319
+ const tr = insert(createTable({
320
+ schema: state.schema
321
+ }));
322
+ options === null || options === void 0 ? void 0 : (_options$editorAnalyt = options.editorAnalyticsAPI) === null || _options$editorAnalyt === void 0 ? void 0 : _options$editorAnalyt.attachAnalyticsEvent({
323
+ action: ACTION.INSERTED,
324
+ actionSubject: ACTION_SUBJECT.DOCUMENT,
325
+ actionSubjectId: ACTION_SUBJECT_ID.TABLE,
326
+ attributes: {
327
+ inputMethod: INPUT_METHOD.QUICK_INSERT
328
+ },
329
+ eventType: EVENT_TYPE.TRACK
330
+ })(tr);
331
+ return tr;
332
+ }
333
+
334
+ }],
335
+ floatingToolbar: getToolbarConfig(defaultGetEditorContainerWidth, options === null || options === void 0 ? void 0 : options.editorAnalyticsAPI)(pluginConfig(options === null || options === void 0 ? void 0 : options.tableOptions))
336
+ }
337
+ };
338
+ };
307
339
 
308
340
  export default tablesPlugin;
@@ -1,4 +1,4 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-table",
3
- "version": "0.0.1"
3
+ "version": "0.0.2"
4
4
  }