@atlaskit/editor-plugin-table 1.3.1 → 1.4.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 +22 -0
- package/dist/cjs/plugins/table/commands/misc.js +1 -2
- package/dist/cjs/plugins/table/index.js +25 -34
- package/dist/cjs/plugins/table/transforms/column-width.js +0 -17
- package/dist/cjs/plugins/table/transforms/delete-columns.js +4 -13
- package/dist/cjs/plugins/table/transforms/delete-rows.js +4 -13
- package/dist/cjs/plugins/table/transforms/fix-tables.js +6 -24
- package/dist/cjs/plugins/table/transforms/index.js +0 -13
- package/dist/cjs/plugins/table/transforms/merge.js +5 -20
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/table/commands/misc.js +2 -3
- package/dist/es2019/plugins/table/index.js +21 -33
- package/dist/es2019/plugins/table/transforms/column-width.js +0 -17
- package/dist/es2019/plugins/table/transforms/delete-columns.js +4 -13
- package/dist/es2019/plugins/table/transforms/delete-rows.js +4 -13
- package/dist/es2019/plugins/table/transforms/fix-tables.js +0 -14
- package/dist/es2019/plugins/table/transforms/index.js +1 -2
- package/dist/es2019/plugins/table/transforms/merge.js +5 -21
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/table/commands/misc.js +2 -3
- package/dist/esm/plugins/table/index.js +25 -34
- package/dist/esm/plugins/table/transforms/column-width.js +0 -17
- package/dist/esm/plugins/table/transforms/delete-columns.js +4 -13
- package/dist/esm/plugins/table/transforms/delete-rows.js +4 -13
- package/dist/esm/plugins/table/transforms/fix-tables.js +0 -17
- package/dist/esm/plugins/table/transforms/index.js +1 -2
- package/dist/esm/plugins/table/transforms/merge.js +5 -21
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/table/index.d.ts +9 -0
- package/dist/types/plugins/table/transforms/fix-tables.d.ts +0 -1
- package/dist/types/plugins/table/transforms/index.d.ts +1 -2
- package/dist/types-ts4.5/i18n/cs.d.ts +35 -0
- package/dist/types-ts4.5/i18n/da.d.ts +33 -0
- package/dist/types-ts4.5/i18n/de.d.ts +33 -0
- package/dist/types-ts4.5/i18n/en.d.ts +35 -0
- package/dist/types-ts4.5/i18n/en_GB.d.ts +35 -0
- package/dist/types-ts4.5/i18n/es.d.ts +33 -0
- package/dist/types-ts4.5/i18n/fi.d.ts +33 -0
- package/dist/types-ts4.5/i18n/fr.d.ts +35 -0
- package/dist/types-ts4.5/i18n/hu.d.ts +35 -0
- package/dist/types-ts4.5/i18n/it.d.ts +35 -0
- package/dist/types-ts4.5/i18n/ja.d.ts +35 -0
- package/dist/types-ts4.5/i18n/ko.d.ts +33 -0
- package/dist/types-ts4.5/i18n/nb.d.ts +33 -0
- package/dist/types-ts4.5/i18n/nl.d.ts +35 -0
- package/dist/types-ts4.5/i18n/pl.d.ts +35 -0
- package/dist/types-ts4.5/i18n/pt_BR.d.ts +35 -0
- package/dist/types-ts4.5/i18n/ru.d.ts +35 -0
- package/dist/types-ts4.5/i18n/sv.d.ts +33 -0
- package/dist/types-ts4.5/i18n/th.d.ts +33 -0
- package/dist/types-ts4.5/i18n/tr.d.ts +35 -0
- package/dist/types-ts4.5/i18n/uk.d.ts +35 -0
- package/dist/types-ts4.5/i18n/vi.d.ts +33 -0
- package/dist/types-ts4.5/i18n/zh.d.ts +35 -0
- package/dist/types-ts4.5/i18n/zh_TW.d.ts +35 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/commands/clear.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/commands/collapse.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/commands/go-to-next-cell.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/commands/hover.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/index.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/insert.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/commands/misc.d.ts +27 -0
- package/dist/types-ts4.5/plugins/table/commands/referentiality.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/commands/selection.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/commands/sort.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/commands/split-cell.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/commands/toggle.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/commands-with-analytics.d.ts +26 -0
- package/dist/types-ts4.5/plugins/table/create-plugin-config.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/event-handlers.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/handlers.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/index.d.ts +30 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/OverflowShadowsObserver.d.ts +25 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/TableComponent.d.ts +73 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverflowShadowsObserver.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/__mocks__/OverridableMock.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/table.d.ts +34 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/tableCell.d.ts +19 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/types.d.ts +24 -0
- package/dist/types-ts4.5/plugins/table/nodeviews/update-overflow-shadows.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/plugin.d.ts +7 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-controls.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/column-resizing.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/compose-decorations.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/index.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/decorations/utils/types.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/default-table-selection.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/keymap.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/main.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-factory.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/safari-delete-composition-text-issue-workaround.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/commands.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/dom.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.d.ts +72 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin-state.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/plugin.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/types.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/sticky-headers/util.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-local-id.d.ts +22 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/commands.d.ts +25 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/event-handlers.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/index.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-factory.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin-key.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/plugin.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/colgroup.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/column-state.d.ts +14 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/content-width.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/dom.d.ts +13 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/index.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/misc.d.ts +22 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-column.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-logic.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/types.d.ts +22 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-resizing/utils/unit-to-number.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/pm-plugins/table-selection-keymap.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/reducer.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/toolbar.d.ts +37 -0
- package/dist/types-ts4.5/plugins/table/transforms/column-width.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/transforms/delete-columns.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/transforms/delete-rows.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/transforms/fix-tables.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/transforms/index.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/transforms/merge.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/transforms/replace-table.d.ts +5 -0
- package/dist/types-ts4.5/plugins/table/transforms/split.d.ts +9 -0
- package/dist/types-ts4.5/plugins/table/types.d.ts +332 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/index.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualButton/styles.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/ContextualMenu.d.ts +88 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/index.d.ts +23 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingContextualMenu/styles.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/DeleteButton.d.ts +14 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/getPopUpOptions.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/index.d.ts +54 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingDeleteButton/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/InsertButton.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/getPopupOptions.d.ts +3 -0
- package/dist/types-ts4.5/plugins/table/ui/FloatingInsertButton/index.d.ts +35 -0
- package/dist/types-ts4.5/plugins/table/ui/LayoutButton/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/CornerControls/index.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/NumberColumn/index.d.ts +21 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/RowControls/index.d.ts +17 -0
- package/dist/types-ts4.5/plugins/table/ui/TableFloatingControls/index.d.ts +40 -0
- package/dist/types-ts4.5/plugins/table/ui/common-styles.d.ts +8 -0
- package/dist/types-ts4.5/plugins/table/ui/consts.d.ts +39 -0
- package/dist/types-ts4.5/plugins/table/ui/messages.d.ts +58 -0
- package/dist/types-ts4.5/plugins/table/ui/ui-styles.d.ts +15 -0
- package/dist/types-ts4.5/plugins/table/utils/analytics.d.ts +18 -0
- package/dist/types-ts4.5/plugins/table/utils/collapse.d.ts +29 -0
- package/dist/types-ts4.5/plugins/table/utils/column-controls.d.ts +10 -0
- package/dist/types-ts4.5/plugins/table/utils/decoration.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/utils/dom.d.ts +20 -0
- package/dist/types-ts4.5/plugins/table/utils/get-allow-add-column-custom-step.d.ts +2 -0
- package/dist/types-ts4.5/plugins/table/utils/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/table/utils/nodes.d.ts +12 -0
- package/dist/types-ts4.5/plugins/table/utils/paste.d.ts +14 -0
- package/dist/types-ts4.5/plugins/table/utils/row-controls.d.ts +16 -0
- package/dist/types-ts4.5/plugins/table/utils/selection.d.ts +6 -0
- package/dist/types-ts4.5/plugins/table/utils/table.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table/utils/update-plugin-state-decorations.d.ts +4 -0
- package/dist/types-ts4.5/plugins/table-plugin.d.ts +2 -0
- package/dist/types-ts4.5/types/i18n.d.ts +5 -0
- package/examples/99-testing.tsx +4 -94
- package/package.json +8 -6
- package/report.api.md +11 -0
- package/src/__tests__/unit/analytics.ts +6 -0
- package/src/__tests__/unit/collab.ts +6 -0
- package/src/__tests__/unit/color-picker.ts +4 -0
- package/src/__tests__/unit/commands/go-to-next-cell.ts +8 -1
- package/src/__tests__/unit/commands/insert.ts +6 -0
- package/src/__tests__/unit/commands/misc.ts +14 -6
- package/src/__tests__/unit/commands/sort.ts +19 -12
- package/src/__tests__/unit/commands.ts +10 -2
- package/src/__tests__/unit/copy-paste.ts +6 -0
- package/src/__tests__/unit/event-handlers/index.ts +13 -8
- package/src/__tests__/unit/event-handlers.ts +13 -1
- package/src/__tests__/unit/fix-tables.ts +8 -4
- package/src/__tests__/unit/get-toolbar-config.ts +4 -0
- package/src/__tests__/unit/handlers.ts +8 -1
- package/src/__tests__/unit/hover-selection.ts +8 -1
- package/src/__tests__/unit/index.ts +10 -2
- package/src/__tests__/unit/keymap.ts +10 -4
- package/src/__tests__/unit/layout.ts +4 -0
- package/src/__tests__/unit/nodeviews/cell.ts +6 -0
- package/src/__tests__/unit/nodeviews/table.ts +16 -9
- package/src/__tests__/unit/pm-plugins/decorations/column-resizing.ts +14 -4
- package/src/__tests__/unit/pm-plugins/decorations/plugin.ts +8 -1
- package/src/__tests__/unit/pm-plugins/main-with-allow-collapse.ts +4 -0
- package/src/__tests__/unit/pm-plugins/main.ts +6 -0
- package/src/__tests__/unit/pm-plugins/safari-delete-composition-text-issue-workaround.ts +8 -4
- package/src/__tests__/unit/pm-plugins/sticky-headers/tableRow.tsx +13 -4
- package/src/__tests__/unit/pm-plugins/table-resizing/event-handlers.ts +6 -0
- package/src/__tests__/unit/pm-plugins/table-selection-keymap.ts +6 -0
- package/src/__tests__/unit/sort-column.ts +6 -0
- package/src/__tests__/unit/toolbar.ts +16 -9
- package/src/__tests__/unit/transforms/delete-columns.ts +8 -1
- package/src/__tests__/unit/transforms/delete-rows.ts +8 -1
- package/src/__tests__/unit/transforms/merging.ts +8 -1
- package/src/__tests__/unit/ui/ContextualMenu.tsx +8 -4
- package/src/__tests__/unit/ui/CornerControls.tsx +8 -1
- package/src/__tests__/unit/ui/FloatingContextualButton.tsx +8 -1
- package/src/__tests__/unit/ui/FloatingContextualMenu.tsx +8 -1
- package/src/__tests__/unit/ui/RowControls.tsx +8 -1
- package/src/__tests__/unit/ui/TableFloatingControls.tsx +8 -1
- package/src/__tests__/unit/undo-redo.ts +6 -0
- package/src/__tests__/unit/utils/collapse.ts +4 -0
- package/src/__tests__/unit/utils/nodes.ts +8 -1
- package/src/__tests__/unit/utils/row-controls.ts +8 -1
- package/src/__tests__/unit/utils.ts +8 -1
- package/src/plugins/table/commands/misc.ts +2 -4
- package/src/plugins/table/index.tsx +39 -40
- package/src/plugins/table/transforms/column-width.ts +0 -11
- package/src/plugins/table/transforms/delete-columns.ts +4 -5
- package/src/plugins/table/transforms/delete-rows.ts +4 -7
- package/src/plugins/table/transforms/fix-tables.ts +0 -17
- package/src/plugins/table/transforms/index.ts +1 -2
- package/src/plugins/table/transforms/merge.ts +9 -20
- package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -79
- package/dist/cjs/plugins/table/transforms/metadata.js +0 -20
- package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -71
- package/dist/es2019/plugins/table/transforms/metadata.js +0 -12
- package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js +0 -71
- package/dist/esm/plugins/table/transforms/metadata.js +0 -14
- package/dist/types/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts +0 -4
- package/dist/types/plugins/table/transforms/metadata.d.ts +0 -21
- package/src/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.ts +0 -78
- package/src/plugins/table/transforms/metadata.ts +0 -35
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import type { Schema } from 'prosemirror-model';
|
|
4
3
|
import type { EditorView } from 'prosemirror-view';
|
|
5
4
|
|
|
6
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -12,12 +11,13 @@ import { table, tableCell, tableHeader, tableRow } from '@atlaskit/adf-schema';
|
|
|
12
11
|
|
|
13
12
|
import { toggleTable, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
14
13
|
|
|
15
|
-
import type { EditorPlugin } from '@atlaskit/editor-common/types';
|
|
14
|
+
import type { EditorPlugin, Command } from '@atlaskit/editor-common/types';
|
|
16
15
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
17
16
|
import {
|
|
18
17
|
ACTION,
|
|
19
18
|
ACTION_SUBJECT,
|
|
20
19
|
ACTION_SUBJECT_ID,
|
|
20
|
+
AnalyticsEventPayload,
|
|
21
21
|
EVENT_TYPE,
|
|
22
22
|
INPUT_METHOD,
|
|
23
23
|
TABLE_ACTION,
|
|
@@ -31,7 +31,6 @@ import type { EditorSelectionAPI } from '@atlaskit/editor-common/selection';
|
|
|
31
31
|
|
|
32
32
|
import { pluginConfig } from './create-plugin-config';
|
|
33
33
|
import { createPlugin as createTableLocalIdPlugin } from './pm-plugins/table-local-id';
|
|
34
|
-
import { createPlugin as createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin } from './pm-plugins/safari-delayed-dom-selection-syncing-workaround';
|
|
35
34
|
import { createPlugin as createTableSafariDeleteCompositionTextIssueWorkaroundPlugin } from './pm-plugins/safari-delete-composition-text-issue-workaround';
|
|
36
35
|
import { createPlugin as createDecorationsPlugin } from './pm-plugins/decorations/plugin';
|
|
37
36
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
@@ -62,6 +61,8 @@ import type {
|
|
|
62
61
|
NextEditorPlugin,
|
|
63
62
|
} from '@atlaskit/editor-common/types';
|
|
64
63
|
import { EditorState, Transaction } from 'prosemirror-state';
|
|
64
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
65
|
+
import type { contentInsertionPlugin } from '@atlaskit/editor-plugin-content-insertion';
|
|
65
66
|
|
|
66
67
|
interface TablePluginOptions {
|
|
67
68
|
tableOptions: PluginConfig;
|
|
@@ -75,14 +76,20 @@ interface TablePluginOptions {
|
|
|
75
76
|
getEditorFeatureFlags?: GetEditorFeatureFlags;
|
|
76
77
|
}
|
|
77
78
|
|
|
79
|
+
type InsertTableAction = (analyticsPayload: AnalyticsEventPayload) => Command;
|
|
80
|
+
|
|
78
81
|
const defaultGetEditorFeatureFlags = () => ({});
|
|
79
82
|
|
|
80
83
|
const tablesPlugin: NextEditorPlugin<
|
|
81
84
|
'table',
|
|
82
85
|
{
|
|
83
86
|
pluginConfiguration: TablePluginOptions | undefined;
|
|
87
|
+
actions: {
|
|
88
|
+
insertTable: InsertTableAction;
|
|
89
|
+
};
|
|
90
|
+
dependencies: [typeof analyticsPlugin, typeof contentInsertionPlugin];
|
|
84
91
|
}
|
|
85
|
-
> = (options?: TablePluginOptions) => {
|
|
92
|
+
> = (options?: TablePluginOptions, api?) => {
|
|
86
93
|
const editorViewRef: Record<'current', EditorView | null> = { current: null };
|
|
87
94
|
const defaultGetEditorContainerWidth: GetEditorContainerWidth = () => {
|
|
88
95
|
if (!editorViewRef.current) {
|
|
@@ -104,6 +111,29 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
104
111
|
return {
|
|
105
112
|
name: 'table',
|
|
106
113
|
|
|
114
|
+
actions: {
|
|
115
|
+
insertTable:
|
|
116
|
+
(analyticsPayload): Command =>
|
|
117
|
+
(state, dispatch) => {
|
|
118
|
+
const node = createTable({
|
|
119
|
+
schema: state.schema,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
api?.dependencies?.contentInsertion?.actions?.insert({
|
|
124
|
+
state,
|
|
125
|
+
dispatch,
|
|
126
|
+
node,
|
|
127
|
+
|
|
128
|
+
options: {
|
|
129
|
+
selectNodeInserted: false,
|
|
130
|
+
analyticsPayload,
|
|
131
|
+
},
|
|
132
|
+
}) ?? false
|
|
133
|
+
);
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
|
|
107
137
|
nodes() {
|
|
108
138
|
return [
|
|
109
139
|
{ name: 'table', node: table },
|
|
@@ -130,7 +160,11 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
130
160
|
tableOptions,
|
|
131
161
|
editorAnalyticsAPI,
|
|
132
162
|
getEditorFeatureFlags,
|
|
133
|
-
} =
|
|
163
|
+
} =
|
|
164
|
+
options ||
|
|
165
|
+
({
|
|
166
|
+
editorAnalyticsAPI: api?.dependencies.analytics.actions,
|
|
167
|
+
} as TablePluginOptions);
|
|
134
168
|
return createPlugin(
|
|
135
169
|
dispatchAnalyticsEvent,
|
|
136
170
|
dispatch,
|
|
@@ -246,21 +280,6 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
246
280
|
},
|
|
247
281
|
];
|
|
248
282
|
|
|
249
|
-
// workaround for prosemirrors delayed dom selection syncing during pointer drag
|
|
250
|
-
// causing issues with table selections in Safari
|
|
251
|
-
// https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
|
|
252
|
-
|
|
253
|
-
// NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
|
|
254
|
-
// https://github.com/ProseMirror/prosemirror-view/pull/116
|
|
255
|
-
if (browser.safari) {
|
|
256
|
-
plugins.push({
|
|
257
|
-
name: 'tableSafariDelayedDomSelectionSyncingWorkaround',
|
|
258
|
-
plugin: () => {
|
|
259
|
-
return createTableSafariDelayedDomSelectionSyncingWorkaroundPlugin();
|
|
260
|
-
},
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
283
|
// Workaround for table element breaking issue caused by composition event with an inputType of deleteCompositionText.
|
|
265
284
|
// https://github.com/ProseMirror/prosemirror/issues/934
|
|
266
285
|
if (browser.safari) {
|
|
@@ -418,26 +437,6 @@ const tablesPlugin: NextEditorPlugin<
|
|
|
418
437
|
},
|
|
419
438
|
|
|
420
439
|
pluginsOptions: {
|
|
421
|
-
// TODO: ED-14676 This is not the final API design
|
|
422
|
-
// For now, we are using this on (insert-api/api.ts) but we may create a proper place for it
|
|
423
|
-
createNodeHandler: ({
|
|
424
|
-
nodeName,
|
|
425
|
-
schema,
|
|
426
|
-
}: {
|
|
427
|
-
nodeName: string;
|
|
428
|
-
schema: Schema;
|
|
429
|
-
}) => {
|
|
430
|
-
// An EditorPlugin may manage more than one node.
|
|
431
|
-
if (nodeName !== 'table') {
|
|
432
|
-
return null;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
const table = createTable({
|
|
436
|
-
schema,
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
return table;
|
|
440
|
-
},
|
|
441
440
|
quickInsert: ({ formatMessage }) => [
|
|
442
441
|
{
|
|
443
442
|
id: 'table',
|
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
ResizeState,
|
|
12
12
|
} from '../pm-plugins/table-resizing/utils';
|
|
13
13
|
|
|
14
|
-
import { setMeta } from './metadata';
|
|
15
14
|
import { ContentNodeWithPos } from 'prosemirror-utils';
|
|
16
15
|
import { EditorView } from 'prosemirror-view';
|
|
17
16
|
import {
|
|
@@ -43,11 +42,6 @@ export const updateColumnWidths =
|
|
|
43
42
|
const colspan = attrs.colspan || 1;
|
|
44
43
|
|
|
45
44
|
if (attrs.colwidth && attrs.colwidth.length > colspan) {
|
|
46
|
-
tr = setMeta({
|
|
47
|
-
type: 'UPDATE_COLUMN_WIDTHS',
|
|
48
|
-
problem: 'COLWIDTHS_BEFORE_UPDATE',
|
|
49
|
-
data: { colwidths: attrs.colwidth, colspan },
|
|
50
|
-
})(tr);
|
|
51
45
|
attrs.colwidth = attrs.colwidth.slice(0, colspan);
|
|
52
46
|
}
|
|
53
47
|
|
|
@@ -67,11 +61,6 @@ export const updateColumnWidths =
|
|
|
67
61
|
|
|
68
62
|
colwidths[colspanIndex] = width;
|
|
69
63
|
if (colwidths.length > colspan) {
|
|
70
|
-
tr = setMeta({
|
|
71
|
-
type: 'UPDATE_COLUMN_WIDTHS',
|
|
72
|
-
problem: 'COLWIDTHS_AFTER_UPDATE',
|
|
73
|
-
data: { colwidths, colspan },
|
|
74
|
-
})(tr);
|
|
75
64
|
colwidths = colwidths.slice(0, colspan);
|
|
76
65
|
}
|
|
77
66
|
updatedCellsAttrs[cellPos] = {
|
|
@@ -6,7 +6,6 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
6
6
|
import { CellAttributes } from '@atlaskit/adf-schema';
|
|
7
7
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
8
8
|
|
|
9
|
-
import { setMeta } from './metadata';
|
|
10
9
|
import { splitCellsInColumns } from './split';
|
|
11
10
|
|
|
12
11
|
const deleteColumnsCustomStep =
|
|
@@ -155,7 +154,7 @@ const deleteColumnsLegacy =
|
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
if (!rows.length) {
|
|
158
|
-
return
|
|
157
|
+
return tr;
|
|
159
158
|
}
|
|
160
159
|
|
|
161
160
|
const newTable = table.node.type.createChecked(
|
|
@@ -166,16 +165,16 @@ const deleteColumnsLegacy =
|
|
|
166
165
|
|
|
167
166
|
const fixedTable = fixRowSpans(newTable);
|
|
168
167
|
if (fixedTable === null) {
|
|
169
|
-
return
|
|
168
|
+
return tr;
|
|
170
169
|
}
|
|
171
170
|
|
|
172
171
|
const cursorPos = getNextCursorPos(newTable, columnsToDelete);
|
|
173
172
|
|
|
174
|
-
return
|
|
173
|
+
return (
|
|
175
174
|
tr
|
|
176
175
|
.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
177
176
|
// move cursor to the left of the deleted columns if possible, otherwise - to the first column
|
|
178
|
-
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)))
|
|
177
|
+
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)))
|
|
179
178
|
);
|
|
180
179
|
};
|
|
181
180
|
|
|
@@ -6,7 +6,6 @@ import { findTable } from '@atlaskit/editor-tables/utils';
|
|
|
6
6
|
import { CellAttributes } from '@atlaskit/adf-schema';
|
|
7
7
|
|
|
8
8
|
import { mergeEmptyColumns } from './merge';
|
|
9
|
-
import { setMeta } from './metadata';
|
|
10
9
|
|
|
11
10
|
export const deleteRows =
|
|
12
11
|
(rect: Rect, isHeaderRowRequired: boolean = false) =>
|
|
@@ -117,7 +116,7 @@ export const deleteRows =
|
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
if (!rows.length) {
|
|
120
|
-
return
|
|
119
|
+
return tr;
|
|
121
120
|
}
|
|
122
121
|
|
|
123
122
|
const newTable = table.node.type.createChecked(
|
|
@@ -127,17 +126,15 @@ export const deleteRows =
|
|
|
127
126
|
);
|
|
128
127
|
const fixedTable = mergeEmptyColumns(newTable);
|
|
129
128
|
if (fixedTable === null) {
|
|
130
|
-
return
|
|
131
|
-
tr,
|
|
132
|
-
);
|
|
129
|
+
return tr;
|
|
133
130
|
}
|
|
134
131
|
const cursorPos = getNextCursorPos(newTable, rowsToDelete);
|
|
135
132
|
|
|
136
|
-
return
|
|
133
|
+
return (
|
|
137
134
|
tr
|
|
138
135
|
.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
139
136
|
// move cursor before the deleted rows if possible, otherwise - to the first row
|
|
140
|
-
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)))
|
|
137
|
+
.setSelection(Selection.near(tr.doc.resolve(table.pos + cursorPos)))
|
|
141
138
|
);
|
|
142
139
|
};
|
|
143
140
|
|
|
@@ -9,8 +9,6 @@ import {
|
|
|
9
9
|
akEditorWideLayoutWidth,
|
|
10
10
|
} from '@atlaskit/editor-shared-styles';
|
|
11
11
|
|
|
12
|
-
import { sendLogs } from '@atlaskit/editor-common/utils';
|
|
13
|
-
|
|
14
12
|
import {
|
|
15
13
|
calculateColumnWidth,
|
|
16
14
|
contentWidth,
|
|
@@ -19,20 +17,6 @@ import {
|
|
|
19
17
|
} from '../pm-plugins/table-resizing/utils';
|
|
20
18
|
import { ReportInvalidNodeAttrs } from '../types';
|
|
21
19
|
|
|
22
|
-
export const fireAnalytics = (properties = {}) =>
|
|
23
|
-
sendLogs({
|
|
24
|
-
events: [
|
|
25
|
-
{
|
|
26
|
-
name: 'atlaskit.fabric.editor.fixtable',
|
|
27
|
-
product: 'atlaskit',
|
|
28
|
-
properties,
|
|
29
|
-
serverTime: new Date().getTime(),
|
|
30
|
-
server: 'local',
|
|
31
|
-
user: '-',
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
});
|
|
35
|
-
|
|
36
20
|
const validateTableCellNodeAttrs = (
|
|
37
21
|
{
|
|
38
22
|
colspan,
|
|
@@ -104,7 +88,6 @@ export const removeExtraneousColumnWidths = (
|
|
|
104
88
|
});
|
|
105
89
|
|
|
106
90
|
if (hasProblems) {
|
|
107
|
-
fireAnalytics({ message: 'removeExtraneousColumnWidths' });
|
|
108
91
|
return true;
|
|
109
92
|
}
|
|
110
93
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { fixTables, fixAutoSizedTable } from './fix-tables';
|
|
2
2
|
export { mergeCells, canMergeCells, mergeEmptyColumns } from './merge';
|
|
3
3
|
export { deleteColumns } from './delete-columns';
|
|
4
4
|
export { deleteRows } from './delete-rows';
|
|
5
5
|
export { updateColumnWidths } from './column-width';
|
|
6
|
-
export { setMeta } from './metadata';
|
|
7
6
|
export { replaceSelectedTable } from './replace-table';
|
|
@@ -6,8 +6,6 @@ import { findTable, getSelectionRect } from '@atlaskit/editor-tables/utils';
|
|
|
6
6
|
|
|
7
7
|
import { CellAttributes } from '@atlaskit/adf-schema';
|
|
8
8
|
|
|
9
|
-
import { setMeta } from './metadata';
|
|
10
|
-
|
|
11
9
|
// re-creates table node with merged cells
|
|
12
10
|
export function mergeCells(tr: Transaction): Transaction {
|
|
13
11
|
const { selection } = tr;
|
|
@@ -55,9 +53,7 @@ export function mergeCells(tr: Transaction): Transaction {
|
|
|
55
53
|
}
|
|
56
54
|
const rowspan = rect.bottom - rect.top;
|
|
57
55
|
if (rowspan < 1) {
|
|
58
|
-
return
|
|
59
|
-
tr,
|
|
60
|
-
);
|
|
56
|
+
return tr;
|
|
61
57
|
}
|
|
62
58
|
// update colspan and rowspan of the merged cell to span the selection
|
|
63
59
|
const attrs = addColSpan(
|
|
@@ -95,10 +91,7 @@ export function mergeCells(tr: Transaction): Transaction {
|
|
|
95
91
|
if (rowspan && rowspan + i - 1 >= rows.length) {
|
|
96
92
|
rowChanged = true;
|
|
97
93
|
if (rowspan < 2) {
|
|
98
|
-
return
|
|
99
|
-
type: 'MERGE_CELLS',
|
|
100
|
-
problem: 'NEGATIVE_ROWSPAN',
|
|
101
|
-
})(tr);
|
|
94
|
+
return tr;
|
|
102
95
|
}
|
|
103
96
|
cells.push(
|
|
104
97
|
cell.type.createChecked(
|
|
@@ -123,7 +116,7 @@ export function mergeCells(tr: Transaction): Transaction {
|
|
|
123
116
|
|
|
124
117
|
// empty tables? cancel merging like nothing happened
|
|
125
118
|
if (!rows.length) {
|
|
126
|
-
return
|
|
119
|
+
return tr;
|
|
127
120
|
}
|
|
128
121
|
|
|
129
122
|
const newTable = table.node.type.createChecked(
|
|
@@ -134,18 +127,14 @@ export function mergeCells(tr: Transaction): Transaction {
|
|
|
134
127
|
|
|
135
128
|
const fixedTable = mergeEmptyColumns(newTable);
|
|
136
129
|
if (fixedTable === null) {
|
|
137
|
-
return
|
|
138
|
-
tr,
|
|
139
|
-
);
|
|
130
|
+
return tr;
|
|
140
131
|
}
|
|
141
132
|
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
),
|
|
148
|
-
);
|
|
133
|
+
return tr
|
|
134
|
+
.replaceWith(table.pos, table.pos + table.node.nodeSize, fixedTable)
|
|
135
|
+
.setSelection(
|
|
136
|
+
Selection.near(tr.doc.resolve((mergedCellPos || 0) + table.start)),
|
|
137
|
+
);
|
|
149
138
|
}
|
|
150
139
|
|
|
151
140
|
export function canMergeCells(tr: Transaction): boolean {
|
package/dist/cjs/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.tableSafariDelayedDomSelectionSyncingWorkaroundKey = exports.createPlugin = void 0;
|
|
7
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
8
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var tableSafariDelayedDomSelectionSyncingWorkaroundKey = new _prosemirrorState.PluginKey('tableSafariDelayedDomSelectionSyncingWorkaround');
|
|
10
|
-
exports.tableSafariDelayedDomSelectionSyncingWorkaroundKey = tableSafariDelayedDomSelectionSyncingWorkaroundKey;
|
|
11
|
-
var createPlugin = function createPlugin() {
|
|
12
|
-
// From a review of the prosemirror-view source code,
|
|
13
|
-
// the only places where a view relies on the presence
|
|
14
|
-
// of view.mouseDown are;
|
|
15
|
-
// - when checking it's presence in selectionToDOM
|
|
16
|
-
// to delay drag selections
|
|
17
|
-
// - to ensure it is cleaned up when the mouseup
|
|
18
|
-
// event is not fired in a previous mousedown event
|
|
19
|
-
|
|
20
|
-
// Because we are manually wiping the view.mouseDown,
|
|
21
|
-
// we manage this custom cleanup ourselves
|
|
22
|
-
var prevMouseDownDone = null;
|
|
23
|
-
return new _safePlugin.SafePlugin({
|
|
24
|
-
key: tableSafariDelayedDomSelectionSyncingWorkaroundKey,
|
|
25
|
-
props: {
|
|
26
|
-
handleDOMEvents: {
|
|
27
|
-
mousedown: function mousedown(view) {
|
|
28
|
-
// Workaround issue in safari where table selections
|
|
29
|
-
// do not work correctly since prosemirror delayed
|
|
30
|
-
// DOM selection syncing during pointer drag.
|
|
31
|
-
//
|
|
32
|
-
// https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
|
|
33
|
-
|
|
34
|
-
// NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
|
|
35
|
-
// https://github.com/ProseMirror/prosemirror-view/pull/116
|
|
36
|
-
|
|
37
|
-
// This fix removes the selectionToDOM from the view
|
|
38
|
-
// prior to selectionToDOM being called.
|
|
39
|
-
// selectionToDOM checks if there is an "active"
|
|
40
|
-
// mouseDown, and if so, it delays running logic
|
|
41
|
-
// which causes the table selections issue.
|
|
42
|
-
|
|
43
|
-
// The handleDOMEvents are called before ProseMirror
|
|
44
|
-
// events fired on the editable DOM element.
|
|
45
|
-
// This means the view.mouseView will not yet be
|
|
46
|
-
// created when the mousedown event starts.
|
|
47
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents
|
|
48
|
-
//
|
|
49
|
-
// Because selectionToDOM is only added to the script
|
|
50
|
-
// tasks queue following the mousedown event, we can
|
|
51
|
-
// prepend a task which will clear the mouseDown from
|
|
52
|
-
// the view. We do this using a setTimout with no
|
|
53
|
-
// interval.
|
|
54
|
-
|
|
55
|
-
if (prevMouseDownDone) {
|
|
56
|
-
// avoid memory leaks when the mouseup event is not fired
|
|
57
|
-
// in a previous mousedown event
|
|
58
|
-
prevMouseDownDone();
|
|
59
|
-
}
|
|
60
|
-
setTimeout(function () {
|
|
61
|
-
// the ts-ignores here are required due to the
|
|
62
|
-
// view.mouseDown being an internal which is
|
|
63
|
-
// not part of the views type signature
|
|
64
|
-
|
|
65
|
-
// @ts-ignore
|
|
66
|
-
if (view.mouseDown) {
|
|
67
|
-
// @ts-ignore
|
|
68
|
-
prevMouseDownDone = view.mouseDown.done.bind(view.mouseDown);
|
|
69
|
-
// @ts-ignore
|
|
70
|
-
view.mouseDown = null;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
exports.createPlugin = createPlugin;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.setMeta = void 0;
|
|
7
|
-
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
8
|
-
var _fixTables = require("./fix-tables");
|
|
9
|
-
// Set metadata on a ProseMirror transaction for debugging purposes in Synchrony
|
|
10
|
-
|
|
11
|
-
var setMeta = function setMeta(meta) {
|
|
12
|
-
return function (tr) {
|
|
13
|
-
if ('problem' in meta) {
|
|
14
|
-
// Send analytics event whenever we encounter with a problem
|
|
15
|
-
(0, _fixTables.fireAnalytics)(meta);
|
|
16
|
-
}
|
|
17
|
-
return tr.setMeta(_pluginKey.pluginKey, meta);
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exports.setMeta = setMeta;
|
package/dist/es2019/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
export const tableSafariDelayedDomSelectionSyncingWorkaroundKey = new PluginKey('tableSafariDelayedDomSelectionSyncingWorkaround');
|
|
4
|
-
export const createPlugin = () => {
|
|
5
|
-
// From a review of the prosemirror-view source code,
|
|
6
|
-
// the only places where a view relies on the presence
|
|
7
|
-
// of view.mouseDown are;
|
|
8
|
-
// - when checking it's presence in selectionToDOM
|
|
9
|
-
// to delay drag selections
|
|
10
|
-
// - to ensure it is cleaned up when the mouseup
|
|
11
|
-
// event is not fired in a previous mousedown event
|
|
12
|
-
|
|
13
|
-
// Because we are manually wiping the view.mouseDown,
|
|
14
|
-
// we manage this custom cleanup ourselves
|
|
15
|
-
let prevMouseDownDone = null;
|
|
16
|
-
return new SafePlugin({
|
|
17
|
-
key: tableSafariDelayedDomSelectionSyncingWorkaroundKey,
|
|
18
|
-
props: {
|
|
19
|
-
handleDOMEvents: {
|
|
20
|
-
mousedown: view => {
|
|
21
|
-
// Workaround issue in safari where table selections
|
|
22
|
-
// do not work correctly since prosemirror delayed
|
|
23
|
-
// DOM selection syncing during pointer drag.
|
|
24
|
-
//
|
|
25
|
-
// https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
|
|
26
|
-
|
|
27
|
-
// NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
|
|
28
|
-
// https://github.com/ProseMirror/prosemirror-view/pull/116
|
|
29
|
-
|
|
30
|
-
// This fix removes the selectionToDOM from the view
|
|
31
|
-
// prior to selectionToDOM being called.
|
|
32
|
-
// selectionToDOM checks if there is an "active"
|
|
33
|
-
// mouseDown, and if so, it delays running logic
|
|
34
|
-
// which causes the table selections issue.
|
|
35
|
-
|
|
36
|
-
// The handleDOMEvents are called before ProseMirror
|
|
37
|
-
// events fired on the editable DOM element.
|
|
38
|
-
// This means the view.mouseView will not yet be
|
|
39
|
-
// created when the mousedown event starts.
|
|
40
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents
|
|
41
|
-
//
|
|
42
|
-
// Because selectionToDOM is only added to the script
|
|
43
|
-
// tasks queue following the mousedown event, we can
|
|
44
|
-
// prepend a task which will clear the mouseDown from
|
|
45
|
-
// the view. We do this using a setTimout with no
|
|
46
|
-
// interval.
|
|
47
|
-
|
|
48
|
-
if (prevMouseDownDone) {
|
|
49
|
-
// avoid memory leaks when the mouseup event is not fired
|
|
50
|
-
// in a previous mousedown event
|
|
51
|
-
prevMouseDownDone();
|
|
52
|
-
}
|
|
53
|
-
setTimeout(() => {
|
|
54
|
-
// the ts-ignores here are required due to the
|
|
55
|
-
// view.mouseDown being an internal which is
|
|
56
|
-
// not part of the views type signature
|
|
57
|
-
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
if (view.mouseDown) {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
prevMouseDownDone = view.mouseDown.done.bind(view.mouseDown);
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
view.mouseDown = null;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
2
|
-
import { fireAnalytics } from './fix-tables';
|
|
3
|
-
|
|
4
|
-
// Set metadata on a ProseMirror transaction for debugging purposes in Synchrony
|
|
5
|
-
|
|
6
|
-
export const setMeta = meta => tr => {
|
|
7
|
-
if ('problem' in meta) {
|
|
8
|
-
// Send analytics event whenever we encounter with a problem
|
|
9
|
-
fireAnalytics(meta);
|
|
10
|
-
}
|
|
11
|
-
return tr.setMeta(pluginKey, meta);
|
|
12
|
-
};
|
package/dist/esm/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
export var tableSafariDelayedDomSelectionSyncingWorkaroundKey = new PluginKey('tableSafariDelayedDomSelectionSyncingWorkaround');
|
|
4
|
-
export var createPlugin = function createPlugin() {
|
|
5
|
-
// From a review of the prosemirror-view source code,
|
|
6
|
-
// the only places where a view relies on the presence
|
|
7
|
-
// of view.mouseDown are;
|
|
8
|
-
// - when checking it's presence in selectionToDOM
|
|
9
|
-
// to delay drag selections
|
|
10
|
-
// - to ensure it is cleaned up when the mouseup
|
|
11
|
-
// event is not fired in a previous mousedown event
|
|
12
|
-
|
|
13
|
-
// Because we are manually wiping the view.mouseDown,
|
|
14
|
-
// we manage this custom cleanup ourselves
|
|
15
|
-
var prevMouseDownDone = null;
|
|
16
|
-
return new SafePlugin({
|
|
17
|
-
key: tableSafariDelayedDomSelectionSyncingWorkaroundKey,
|
|
18
|
-
props: {
|
|
19
|
-
handleDOMEvents: {
|
|
20
|
-
mousedown: function mousedown(view) {
|
|
21
|
-
// Workaround issue in safari where table selections
|
|
22
|
-
// do not work correctly since prosemirror delayed
|
|
23
|
-
// DOM selection syncing during pointer drag.
|
|
24
|
-
//
|
|
25
|
-
// https://github.com/ProseMirror/prosemirror-view/commit/885258b80551ac87b81601d3ed25f552aeb22293
|
|
26
|
-
|
|
27
|
-
// NOTE: this workaround can be removed when next upgrading prosemirror as the issue will be fixed
|
|
28
|
-
// https://github.com/ProseMirror/prosemirror-view/pull/116
|
|
29
|
-
|
|
30
|
-
// This fix removes the selectionToDOM from the view
|
|
31
|
-
// prior to selectionToDOM being called.
|
|
32
|
-
// selectionToDOM checks if there is an "active"
|
|
33
|
-
// mouseDown, and if so, it delays running logic
|
|
34
|
-
// which causes the table selections issue.
|
|
35
|
-
|
|
36
|
-
// The handleDOMEvents are called before ProseMirror
|
|
37
|
-
// events fired on the editable DOM element.
|
|
38
|
-
// This means the view.mouseView will not yet be
|
|
39
|
-
// created when the mousedown event starts.
|
|
40
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.handleDOMEvents
|
|
41
|
-
//
|
|
42
|
-
// Because selectionToDOM is only added to the script
|
|
43
|
-
// tasks queue following the mousedown event, we can
|
|
44
|
-
// prepend a task which will clear the mouseDown from
|
|
45
|
-
// the view. We do this using a setTimout with no
|
|
46
|
-
// interval.
|
|
47
|
-
|
|
48
|
-
if (prevMouseDownDone) {
|
|
49
|
-
// avoid memory leaks when the mouseup event is not fired
|
|
50
|
-
// in a previous mousedown event
|
|
51
|
-
prevMouseDownDone();
|
|
52
|
-
}
|
|
53
|
-
setTimeout(function () {
|
|
54
|
-
// the ts-ignores here are required due to the
|
|
55
|
-
// view.mouseDown being an internal which is
|
|
56
|
-
// not part of the views type signature
|
|
57
|
-
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
if (view.mouseDown) {
|
|
60
|
-
// @ts-ignore
|
|
61
|
-
prevMouseDownDone = view.mouseDown.done.bind(view.mouseDown);
|
|
62
|
-
// @ts-ignore
|
|
63
|
-
view.mouseDown = null;
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
return false;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { pluginKey } from '../pm-plugins/plugin-key';
|
|
2
|
-
import { fireAnalytics } from './fix-tables';
|
|
3
|
-
|
|
4
|
-
// Set metadata on a ProseMirror transaction for debugging purposes in Synchrony
|
|
5
|
-
|
|
6
|
-
export var setMeta = function setMeta(meta) {
|
|
7
|
-
return function (tr) {
|
|
8
|
-
if ('problem' in meta) {
|
|
9
|
-
// Send analytics event whenever we encounter with a problem
|
|
10
|
-
fireAnalytics(meta);
|
|
11
|
-
}
|
|
12
|
-
return tr.setMeta(pluginKey, meta);
|
|
13
|
-
};
|
|
14
|
-
};
|
package/dist/types/plugins/table/pm-plugins/safari-delayed-dom-selection-syncing-workaround.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror-state';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
-
export declare const tableSafariDelayedDomSelectionSyncingWorkaroundKey: PluginKey<any, any>;
|
|
4
|
-
export declare const createPlugin: () => SafePlugin<any, any>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Transaction } from 'prosemirror-state';
|
|
2
|
-
type TableProblems = 'NEGATIVE_ROWSPAN' | 'REMOVE_EMPTY_ROWS' | 'REMOVE_EMPTY_COLUMNS' | 'EMPTY_TABLE' | 'FIX_ROWSPANS' | 'COLWIDTHS_BEFORE_UPDATE' | 'COLWIDTHS_AFTER_UPDATE';
|
|
3
|
-
export type TableMetaData = {
|
|
4
|
-
type: 'MERGE_CELLS';
|
|
5
|
-
problem?: TableProblems;
|
|
6
|
-
} | {
|
|
7
|
-
type: 'DELETE_ROWS';
|
|
8
|
-
problem?: TableProblems;
|
|
9
|
-
} | {
|
|
10
|
-
type: 'DELETE_COLUMNS';
|
|
11
|
-
problem?: TableProblems;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'UPDATE_COLUMN_WIDTHS';
|
|
14
|
-
data: {
|
|
15
|
-
colwidths: number[];
|
|
16
|
-
colspan: number;
|
|
17
|
-
};
|
|
18
|
-
problem?: TableProblems;
|
|
19
|
-
};
|
|
20
|
-
export declare const setMeta: (meta: TableMetaData) => (tr: Transaction) => Transaction;
|
|
21
|
-
export {};
|