@atlaskit/editor-core 149.0.0 → 150.0.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 +41 -0
- package/dist/cjs/create-editor/create-plugins-list.js +2 -1
- package/dist/cjs/editor.js +1 -4
- package/dist/cjs/i18n/cs.js +18 -2
- package/dist/cjs/i18n/da.js +18 -2
- package/dist/cjs/i18n/de.js +18 -2
- package/dist/cjs/i18n/es.js +13 -2
- package/dist/cjs/i18n/et.js +0 -1
- package/dist/cjs/i18n/fi.js +13 -2
- package/dist/cjs/i18n/fr.js +13 -2
- package/dist/cjs/i18n/hu.js +14 -3
- package/dist/cjs/i18n/it.js +18 -2
- package/dist/cjs/i18n/ja.js +13 -2
- package/dist/cjs/i18n/ko.js +13 -2
- package/dist/cjs/i18n/nb.js +13 -2
- package/dist/cjs/i18n/nl.js +18 -2
- package/dist/cjs/i18n/pl.js +16 -2
- package/dist/cjs/i18n/pt_BR.js +14 -3
- package/dist/cjs/i18n/pt_PT.js +0 -1
- package/dist/cjs/i18n/ru.js +13 -2
- package/dist/cjs/i18n/sk.js +0 -1
- package/dist/cjs/i18n/sv.js +18 -2
- package/dist/cjs/i18n/th.js +18 -2
- package/dist/cjs/i18n/tr.js +16 -2
- package/dist/cjs/i18n/uk.js +18 -2
- package/dist/cjs/i18n/vi.js +13 -2
- package/dist/cjs/i18n/zh.js +18 -2
- package/dist/cjs/i18n/zh_TW.js +18 -2
- package/dist/cjs/messages.js +4 -4
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/cjs/plugins/analytics/types/enums.js +0 -1
- package/dist/cjs/plugins/analytics/types/node-events.js +1 -0
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/cjs/plugins/expand/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/extension/actions.js +16 -16
- package/dist/cjs/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/floating-toolbar/ui/{EditorHideEmojiIcon.js → EditorRemoveEmojiIcon.js} +2 -2
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.js +5 -2
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +14 -0
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +19 -22
- package/dist/cjs/plugins/layout/actions.js +70 -16
- package/dist/cjs/plugins/layout/index.js +3 -2
- package/dist/cjs/plugins/layout/pm-plugins/main.js +3 -1
- package/dist/cjs/plugins/layout/toolbar-messages.js +5 -0
- package/dist/cjs/plugins/layout/toolbar.js +11 -2
- package/dist/cjs/plugins/list/pm-plugins/main.js +0 -38
- package/dist/cjs/plugins/macro/actions.js +14 -14
- package/dist/cjs/plugins/mentions/analytics.js +2 -3
- package/dist/cjs/plugins/mentions/type-ahead/index.js +7 -12
- package/dist/cjs/plugins/panel/nodeviews/panel.js +7 -3
- package/dist/cjs/plugins/panel/toolbar.js +8 -6
- package/dist/cjs/plugins/panel/toolbar.test.js +25 -11
- package/dist/cjs/plugins/paste/handlers.js +2 -2
- package/dist/cjs/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/cjs/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/cjs/plugins/table/commands/insert.js +25 -10
- package/dist/cjs/plugins/table/commands/misc.js +3 -3
- package/dist/cjs/plugins/table/commands/selection.js +24 -24
- package/dist/cjs/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/cjs/plugins/table/nodeviews/tableCell.js +20 -6
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +17 -16
- package/dist/cjs/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +1 -0
- package/dist/cjs/plugins/table/toolbar.js +4 -4
- package/dist/cjs/plugins/table/transforms/column-width.js +72 -12
- package/dist/cjs/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/cjs/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/cjs/plugins/table/utils/table.js +17 -2
- package/dist/cjs/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/cjs/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/cjs/plugins/type-ahead/ui/InputQuery.js +5 -3
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.js +1 -3
- package/dist/cjs/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +1 -3
- package/dist/cjs/ui/ColorPickerButton/index.js +5 -2
- package/dist/cjs/ui/ColorPickerButton/index.test.js +16 -0
- package/dist/cjs/ui/ConfigPanel/Fields/Expand.js +2 -4
- package/dist/cjs/ui/ConfigPanel/Fields/Fieldset.js +1 -3
- package/dist/cjs/ui/ConfigPanel/NestedForms/RemovableField.js +1 -3
- package/dist/cjs/ui/PanelTextInput/index.js +1 -3
- package/dist/cjs/utils/compare.js +7 -7
- package/dist/cjs/utils/index.js +7 -8
- package/dist/cjs/utils/rich-media-utils.js +2 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/create-editor/create-plugins-list.js +2 -1
- package/dist/es2019/editor.js +1 -4
- package/dist/es2019/i18n/cs.js +18 -2
- package/dist/es2019/i18n/da.js +18 -2
- package/dist/es2019/i18n/de.js +18 -2
- package/dist/es2019/i18n/es.js +13 -2
- package/dist/es2019/i18n/et.js +0 -1
- package/dist/es2019/i18n/fi.js +13 -2
- package/dist/es2019/i18n/fr.js +13 -2
- package/dist/es2019/i18n/hu.js +14 -3
- package/dist/es2019/i18n/it.js +18 -2
- package/dist/es2019/i18n/ja.js +13 -2
- package/dist/es2019/i18n/ko.js +13 -2
- package/dist/es2019/i18n/nb.js +13 -2
- package/dist/es2019/i18n/nl.js +18 -2
- package/dist/es2019/i18n/pl.js +16 -2
- package/dist/es2019/i18n/pt_BR.js +14 -3
- package/dist/es2019/i18n/pt_PT.js +0 -1
- package/dist/es2019/i18n/ru.js +13 -2
- package/dist/es2019/i18n/sk.js +0 -1
- package/dist/es2019/i18n/sv.js +18 -2
- package/dist/es2019/i18n/th.js +18 -2
- package/dist/es2019/i18n/tr.js +16 -2
- package/dist/es2019/i18n/uk.js +18 -2
- package/dist/es2019/i18n/vi.js +13 -2
- package/dist/es2019/i18n/zh.js +18 -2
- package/dist/es2019/i18n/zh_TW.js +18 -2
- package/dist/es2019/messages.js +4 -4
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/es2019/plugins/analytics/types/enums.js +0 -1
- package/dist/es2019/plugins/analytics/types/node-events.js +1 -0
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/es2019/plugins/expand/pm-plugins/keymap.js +2 -2
- package/dist/es2019/plugins/extension/actions.js +16 -16
- package/dist/es2019/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/floating-toolbar/ui/{EditorHideEmojiIcon.js → EditorRemoveEmojiIcon.js} +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.js +5 -3
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +14 -0
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +20 -23
- package/dist/es2019/plugins/layout/actions.js +64 -13
- package/dist/es2019/plugins/layout/index.js +3 -2
- package/dist/es2019/plugins/layout/pm-plugins/main.js +3 -1
- package/dist/es2019/plugins/layout/toolbar-messages.js +5 -0
- package/dist/es2019/plugins/layout/toolbar.js +10 -2
- package/dist/es2019/plugins/list/pm-plugins/main.js +1 -41
- package/dist/es2019/plugins/macro/actions.js +14 -14
- package/dist/es2019/plugins/mentions/analytics.js +2 -3
- package/dist/es2019/plugins/mentions/type-ahead/index.js +9 -15
- package/dist/es2019/plugins/panel/nodeviews/panel.js +5 -3
- package/dist/es2019/plugins/panel/toolbar.js +8 -6
- package/dist/es2019/plugins/panel/toolbar.test.js +18 -8
- package/dist/es2019/plugins/paste/handlers.js +2 -2
- package/dist/es2019/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/es2019/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/es2019/plugins/table/commands/insert.js +27 -12
- package/dist/es2019/plugins/table/commands/misc.js +3 -3
- package/dist/es2019/plugins/table/commands/selection.js +25 -25
- package/dist/es2019/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/es2019/plugins/table/nodeviews/tableCell.js +19 -6
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +14 -16
- package/dist/es2019/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +1 -1
- package/dist/es2019/plugins/table/toolbar.js +4 -4
- package/dist/es2019/plugins/table/transforms/column-width.js +62 -11
- package/dist/es2019/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/es2019/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/es2019/plugins/table/utils/table.js +7 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/es2019/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/es2019/plugins/type-ahead/ui/InputQuery.js +5 -3
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +1 -2
- package/dist/es2019/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +1 -3
- package/dist/es2019/ui/ColorPickerButton/index.js +6 -3
- package/dist/es2019/ui/ColorPickerButton/index.test.js +15 -0
- package/dist/es2019/ui/ConfigPanel/Fields/Expand.js +3 -4
- package/dist/es2019/ui/ConfigPanel/Fields/Fieldset.js +2 -3
- package/dist/es2019/ui/ConfigPanel/NestedForms/RemovableField.js +1 -2
- package/dist/es2019/ui/ConfigPanel/transformers.js +9 -9
- package/dist/es2019/ui/PanelTextInput/index.js +1 -3
- package/dist/es2019/utils/compare.js +7 -7
- package/dist/es2019/utils/index.js +7 -8
- package/dist/es2019/utils/rich-media-utils.js +2 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/create-editor/create-plugins-list.js +2 -1
- package/dist/esm/editor.js +1 -4
- package/dist/esm/i18n/cs.js +18 -2
- package/dist/esm/i18n/da.js +18 -2
- package/dist/esm/i18n/de.js +18 -2
- package/dist/esm/i18n/es.js +13 -2
- package/dist/esm/i18n/et.js +0 -1
- package/dist/esm/i18n/fi.js +13 -2
- package/dist/esm/i18n/fr.js +13 -2
- package/dist/esm/i18n/hu.js +14 -3
- package/dist/esm/i18n/it.js +18 -2
- package/dist/esm/i18n/ja.js +13 -2
- package/dist/esm/i18n/ko.js +13 -2
- package/dist/esm/i18n/nb.js +13 -2
- package/dist/esm/i18n/nl.js +18 -2
- package/dist/esm/i18n/pl.js +16 -2
- package/dist/esm/i18n/pt_BR.js +14 -3
- package/dist/esm/i18n/pt_PT.js +0 -1
- package/dist/esm/i18n/ru.js +13 -2
- package/dist/esm/i18n/sk.js +0 -1
- package/dist/esm/i18n/sv.js +18 -2
- package/dist/esm/i18n/th.js +18 -2
- package/dist/esm/i18n/tr.js +16 -2
- package/dist/esm/i18n/uk.js +18 -2
- package/dist/esm/i18n/vi.js +13 -2
- package/dist/esm/i18n/zh.js +18 -2
- package/dist/esm/i18n/zh_TW.js +18 -2
- package/dist/esm/messages.js +4 -4
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +1 -2
- package/dist/esm/plugins/analytics/types/enums.js +0 -1
- package/dist/esm/plugins/analytics/types/node-events.js +1 -0
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -3
- package/dist/esm/plugins/expand/pm-plugins/keymap.js +2 -2
- package/dist/esm/plugins/extension/actions.js +16 -16
- package/dist/esm/plugins/extension/pm-plugins/main.js +4 -4
- package/dist/esm/plugins/floating-toolbar/ui/{EditorHideEmojiIcon.js → EditorRemoveEmojiIcon.js} +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.js +6 -3
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +14 -0
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +20 -23
- package/dist/esm/plugins/layout/actions.js +66 -13
- package/dist/esm/plugins/layout/index.js +3 -2
- package/dist/esm/plugins/layout/pm-plugins/main.js +3 -1
- package/dist/esm/plugins/layout/toolbar-messages.js +5 -0
- package/dist/esm/plugins/layout/toolbar.js +10 -2
- package/dist/esm/plugins/list/pm-plugins/main.js +1 -37
- package/dist/esm/plugins/macro/actions.js +14 -14
- package/dist/esm/plugins/mentions/analytics.js +2 -3
- package/dist/esm/plugins/mentions/type-ahead/index.js +7 -12
- package/dist/esm/plugins/panel/nodeviews/panel.js +5 -3
- package/dist/esm/plugins/panel/toolbar.js +8 -6
- package/dist/esm/plugins/panel/toolbar.test.js +25 -11
- package/dist/esm/plugins/paste/handlers.js +2 -2
- package/dist/esm/plugins/selection/gap-cursor/actions.js +5 -6
- package/dist/esm/plugins/selection/pm-plugins/selection-main.js +1 -3
- package/dist/esm/plugins/table/commands/insert.js +26 -11
- package/dist/esm/plugins/table/commands/misc.js +3 -3
- package/dist/esm/plugins/table/commands/selection.js +24 -24
- package/dist/esm/plugins/table/nodeviews/TableComponent.js +5 -4
- package/dist/esm/plugins/table/nodeviews/tableCell.js +21 -7
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/resize-state.js +15 -17
- package/dist/esm/plugins/table/pm-plugins/table-resizing/utils/scale-table.js +1 -1
- package/dist/esm/plugins/table/toolbar.js +4 -4
- package/dist/esm/plugins/table/transforms/column-width.js +62 -10
- package/dist/esm/plugins/table/ui/FloatingContextualMenu/ContextualMenu.js +1 -1
- package/dist/esm/plugins/table/ui/FloatingInsertButton/index.js +1 -1
- package/dist/esm/plugins/table/utils/table.js +9 -0
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -2
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/esm/plugins/text-formatting/pm-plugins/cursor.js +1 -4
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/esm/plugins/type-ahead/ui/InputQuery.js +5 -3
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +1 -2
- package/dist/esm/plugins/view-update-subscription/subscribe/toolbarAndPickerUpdates.js +1 -3
- package/dist/esm/ui/ColorPickerButton/index.js +6 -3
- package/dist/esm/ui/ColorPickerButton/index.test.js +15 -0
- package/dist/esm/ui/ConfigPanel/Fields/Expand.js +2 -3
- package/dist/esm/ui/ConfigPanel/Fields/Fieldset.js +1 -2
- package/dist/esm/ui/ConfigPanel/NestedForms/RemovableField.js +1 -2
- package/dist/esm/ui/PanelTextInput/index.js +1 -3
- package/dist/esm/utils/compare.js +7 -7
- package/dist/esm/utils/index.js +7 -8
- package/dist/esm/utils/rich-media-utils.js +2 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/i18n/cs.d.ts +16 -0
- package/dist/types/i18n/da.d.ts +16 -0
- package/dist/types/i18n/de.d.ts +16 -0
- package/dist/types/i18n/es.d.ts +11 -0
- package/dist/types/i18n/et.d.ts +0 -1
- package/dist/types/i18n/fi.d.ts +11 -0
- package/dist/types/i18n/fr.d.ts +11 -0
- package/dist/types/i18n/hu.d.ts +11 -0
- package/dist/types/i18n/it.d.ts +16 -0
- package/dist/types/i18n/ja.d.ts +11 -0
- package/dist/types/i18n/ko.d.ts +11 -0
- package/dist/types/i18n/nb.d.ts +11 -0
- package/dist/types/i18n/nl.d.ts +16 -0
- package/dist/types/i18n/pl.d.ts +14 -0
- package/dist/types/i18n/pt_BR.d.ts +11 -0
- package/dist/types/i18n/pt_PT.d.ts +0 -1
- package/dist/types/i18n/ru.d.ts +11 -0
- package/dist/types/i18n/sk.d.ts +0 -1
- package/dist/types/i18n/sv.d.ts +16 -0
- package/dist/types/i18n/th.d.ts +16 -0
- package/dist/types/i18n/tr.d.ts +14 -0
- package/dist/types/i18n/uk.d.ts +16 -0
- package/dist/types/i18n/vi.d.ts +11 -0
- package/dist/types/i18n/zh.d.ts +16 -0
- package/dist/types/i18n/zh_TW.d.ts +16 -0
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +0 -1
- package/dist/types/plugins/analytics/types/general-events.d.ts +1 -1
- package/dist/types/plugins/analytics/types/list-events.d.ts +1 -5
- package/dist/types/plugins/analytics/types/node-events.d.ts +1 -0
- package/dist/types/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.d.ts +1 -0
- package/dist/types/plugins/layout/actions.d.ts +1 -0
- package/dist/types/plugins/layout/pm-plugins/types.d.ts +1 -0
- package/dist/types/plugins/layout/toolbar-messages.d.ts +5 -0
- package/dist/types/plugins/layout/toolbar.d.ts +1 -1
- package/dist/types/plugins/layout/types.d.ts +2 -1
- package/dist/types/plugins/mentions/analytics.d.ts +1 -1
- package/dist/types/plugins/table/nodeviews/tableCell.d.ts +1 -1
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/resize-state.d.ts +2 -0
- package/dist/types/plugins/table/pm-plugins/table-resizing/utils/scale-table.d.ts +1 -0
- package/dist/types/plugins/table/transforms/column-width.d.ts +10 -0
- package/dist/types/plugins/table/utils/table.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/Fields/Expand.d.ts +1 -1
- package/package.json +22 -22
- package/dist/types/plugins/floating-toolbar/ui/EditorHideEmojiIcon.d.ts +0 -1
|
@@ -6,8 +6,10 @@ import { safeInsert } from 'prosemirror-utils';
|
|
|
6
6
|
import { AddColumnStep } from '@atlaskit/adf-schema/steps';
|
|
7
7
|
import { getPluginState } from '../pm-plugins/plugin-factory';
|
|
8
8
|
import { checkIfHeaderRowEnabled, copyPreviousRow } from '../utils';
|
|
9
|
-
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
9
|
+
import { getAllowAddColumnCustomStep } from '../utils/get-allow-add-column-custom-step';
|
|
10
|
+
import { rescaleColumns } from '../transforms/column-width';
|
|
10
11
|
|
|
12
|
+
// #endregion
|
|
11
13
|
function addColumnAtCustomStep(column) {
|
|
12
14
|
return function (tr) {
|
|
13
15
|
var table = findTable(tr.selection);
|
|
@@ -22,17 +24,30 @@ function addColumnAtCustomStep(column) {
|
|
|
22
24
|
|
|
23
25
|
function addColumnAt(column) {
|
|
24
26
|
var allowAddColumnCustomStep = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
27
|
+
var view = arguments.length > 2 ? arguments[2] : undefined;
|
|
28
|
+
return function (tr) {
|
|
29
|
+
var updatedTr = tr;
|
|
25
30
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
if (allowAddColumnCustomStep) {
|
|
32
|
+
updatedTr = addColumnAtCustomStep(column)(updatedTr);
|
|
33
|
+
} else {
|
|
34
|
+
updatedTr = addColumnAtPMUtils(column)(updatedTr);
|
|
35
|
+
}
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
var table = findTable(updatedTr.selection);
|
|
38
|
+
|
|
39
|
+
if (table) {
|
|
40
|
+
// [ED-8288] Update colwidths manually to avoid multiple dispatch in TableComponent
|
|
41
|
+
updatedTr = rescaleColumns(table, view)(updatedTr);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return updatedTr;
|
|
45
|
+
};
|
|
31
46
|
} // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
32
47
|
// Command to add a column before the column with the selection.
|
|
33
48
|
|
|
34
49
|
|
|
35
|
-
export var addColumnBefore = function addColumnBefore(state, dispatch) {
|
|
50
|
+
export var addColumnBefore = function addColumnBefore(state, dispatch, view) {
|
|
36
51
|
var table = findTable(state.selection);
|
|
37
52
|
|
|
38
53
|
if (!table) {
|
|
@@ -41,14 +56,14 @@ export var addColumnBefore = function addColumnBefore(state, dispatch) {
|
|
|
41
56
|
|
|
42
57
|
if (dispatch) {
|
|
43
58
|
var rect = selectedRect(state);
|
|
44
|
-
dispatch(addColumnAt(rect.left, getAllowAddColumnCustomStep(state))(state.tr));
|
|
59
|
+
dispatch(addColumnAt(rect.left, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
45
60
|
}
|
|
46
61
|
|
|
47
62
|
return true;
|
|
48
63
|
}; // :: (EditorState, dispatch: ?(tr: Transaction)) → bool
|
|
49
64
|
// Command to add a column after the column with the selection.
|
|
50
65
|
|
|
51
|
-
export var addColumnAfter = function addColumnAfter(state, dispatch) {
|
|
66
|
+
export var addColumnAfter = function addColumnAfter(state, dispatch, view) {
|
|
52
67
|
var table = findTable(state.selection);
|
|
53
68
|
|
|
54
69
|
if (!table) {
|
|
@@ -57,15 +72,15 @@ export var addColumnAfter = function addColumnAfter(state, dispatch) {
|
|
|
57
72
|
|
|
58
73
|
if (dispatch) {
|
|
59
74
|
var rect = selectedRect(state);
|
|
60
|
-
dispatch(addColumnAt(rect.right, getAllowAddColumnCustomStep(state))(state.tr));
|
|
75
|
+
dispatch(addColumnAt(rect.right, getAllowAddColumnCustomStep(state), view)(state.tr));
|
|
61
76
|
}
|
|
62
77
|
|
|
63
78
|
return true;
|
|
64
79
|
}; // #region Commands
|
|
65
80
|
|
|
66
81
|
export var insertColumn = function insertColumn(column) {
|
|
67
|
-
return function (state, dispatch) {
|
|
68
|
-
var tr = addColumnAt(column, getAllowAddColumnCustomStep(state))(state.tr);
|
|
82
|
+
return function (state, dispatch, view) {
|
|
83
|
+
var tr = addColumnAt(column, getAllowAddColumnCustomStep(state), view)(state.tr);
|
|
69
84
|
var table = findTable(tr.selection);
|
|
70
85
|
|
|
71
86
|
if (!table) {
|
|
@@ -98,7 +98,7 @@ export var setCellAttr = function setCellAttr(name, value) {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
export var triggerUnlessTableHeader = function triggerUnlessTableHeader(command) {
|
|
101
|
-
return function (state, dispatch) {
|
|
101
|
+
return function (state, dispatch, view) {
|
|
102
102
|
var selection = state.selection,
|
|
103
103
|
tableHeader = state.schema.nodes.tableHeader;
|
|
104
104
|
|
|
@@ -106,7 +106,7 @@ export var triggerUnlessTableHeader = function triggerUnlessTableHeader(command)
|
|
|
106
106
|
var cell = findCellClosestToPos(selection.$from);
|
|
107
107
|
|
|
108
108
|
if (cell && cell.node.type !== tableHeader) {
|
|
109
|
-
return command(state, dispatch);
|
|
109
|
+
return command(state, dispatch, view);
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -114,7 +114,7 @@ export var triggerUnlessTableHeader = function triggerUnlessTableHeader(command)
|
|
|
114
114
|
var rect = getSelectionRect(selection);
|
|
115
115
|
|
|
116
116
|
if (!checkIfHeaderRowEnabled(state) || rect && rect.top > 0) {
|
|
117
|
-
return command(state, dispatch);
|
|
117
|
+
return command(state, dispatch, view);
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -165,23 +165,23 @@ var arrowLeftFromText = function arrowLeftFromText(selection) {
|
|
|
165
165
|
|
|
166
166
|
if (isSelectionAtStartOfTable($from, selection) && $from.parent.type.name === 'paragraph' && $from.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
167
167
|
) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
168
|
+
var _getSelectionPluginSt4 = getSelectionPluginState(state),
|
|
169
|
+
selectionRelativeToNode = _getSelectionPluginSt4.selectionRelativeToNode;
|
|
170
|
+
|
|
171
|
+
if (selectionRelativeToNode === RelativeSelectionPos.Before) {
|
|
172
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
173
|
+
// and want to set gap cursor selection before table
|
|
174
|
+
return setGapCursorBeforeTable()(state, dispatch);
|
|
175
|
+
} else {
|
|
176
|
+
// we have a text selection at start of first table cell, directly inside a top level paragraph,
|
|
177
|
+
// and want to set a full table cell selection
|
|
178
|
+
return selectFullTable({
|
|
179
|
+
node: table.node,
|
|
180
|
+
startPos: table.start,
|
|
181
|
+
dir: TableSelectionDirection.BottomToTop
|
|
182
|
+
})(state, dispatch);
|
|
184
183
|
}
|
|
184
|
+
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
return false;
|
|
@@ -197,14 +197,14 @@ var arrowRightFromText = function arrowRightFromText(selection) {
|
|
|
197
197
|
|
|
198
198
|
if (isSelectionAtEndOfTable($to, selection) && $to.parent.type.name === 'paragraph' && $to.depth === table.depth + 3 // + 3 for: row, cell & paragraph nodes
|
|
199
199
|
) {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
200
|
+
// we have a text selection at end of last table cell, directly inside a top level paragraph,
|
|
201
|
+
// and want to set a full table cell selection
|
|
202
|
+
return selectFullTable({
|
|
203
|
+
node: table.node,
|
|
204
|
+
startPos: table.start,
|
|
205
|
+
dir: TableSelectionDirection.TopToBottom
|
|
206
|
+
})(state, dispatch);
|
|
207
|
+
}
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
return false;
|
|
@@ -177,16 +177,17 @@ var TableComponent = /*#__PURE__*/function (_React$Component) {
|
|
|
177
177
|
var layoutSize = _this.tableNodeLayoutSize(node, containerWidth.width, options);
|
|
178
178
|
|
|
179
179
|
var hasNumberedColumnChanged = prevAttrs.isNumberColumnEnabled !== node.attrs.isNumberColumnEnabled;
|
|
180
|
+
var noOfColumnsChanged = tablesHaveDifferentNoOfColumns(node, prevNode);
|
|
180
181
|
|
|
181
182
|
if ( // Breakout mode/layout changed
|
|
182
183
|
layoutChanged || // We need to react if our parent changes
|
|
183
184
|
// Scales the cols widths relative to the new parent width.
|
|
184
185
|
parentWidthChanged || // Enabling / disabling this feature reduces or adds size to the table.
|
|
185
|
-
hasNumberedColumnChanged || //
|
|
186
|
-
tablesHaveDifferentNoOfColumns(node, prevNode) || // This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
186
|
+
hasNumberedColumnChanged || // This last check is also to cater for dynamic text sizing changing the 'default' layout width
|
|
187
187
|
// Usually happens on window resize.
|
|
188
|
-
layoutSize !== _this.layoutSize) {
|
|
189
|
-
|
|
188
|
+
layoutSize !== _this.layoutSize || noOfColumnsChanged) {
|
|
189
|
+
// If column has been inserted/deleted avoid multi dispatch
|
|
190
|
+
if (!hasNumberedColumnChanged && !noOfColumnsChanged) {
|
|
190
191
|
_this.scaleTable({
|
|
191
192
|
parentWidth: parentWidth,
|
|
192
193
|
layoutChanged: layoutChanged
|
|
@@ -3,7 +3,7 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
3
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
4
4
|
import uuid from 'uuid';
|
|
5
5
|
import { DOMSerializer } from 'prosemirror-model';
|
|
6
|
-
import {
|
|
6
|
+
import { getCellDomAttrs, getCellAttrs } from '@atlaskit/adf-schema';
|
|
7
7
|
import { getFeatureFlags } from '../../feature-flags-context';
|
|
8
8
|
|
|
9
9
|
var TableCellNodeView = /*#__PURE__*/function () {
|
|
@@ -33,16 +33,30 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
_createClass(TableCellNodeView, [{
|
|
36
|
-
key: "
|
|
37
|
-
value: function
|
|
36
|
+
key: "updateNodeView",
|
|
37
|
+
value: function updateNodeView(node) {
|
|
38
38
|
var _this = this;
|
|
39
39
|
|
|
40
40
|
if (this.node.type !== node.type) {
|
|
41
41
|
return false;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
var attrs =
|
|
45
|
-
var nextAttrs =
|
|
44
|
+
var attrs = getCellDomAttrs(this.node);
|
|
45
|
+
var nextAttrs = getCellDomAttrs(node);
|
|
46
|
+
|
|
47
|
+
var _getCellAttrs = getCellAttrs(this.dom),
|
|
48
|
+
colspan = _getCellAttrs.colspan,
|
|
49
|
+
rowspan = _getCellAttrs.rowspan; // need to rerender when colspan/rowspan in dom are different from the node attrs
|
|
50
|
+
// this can happen when undoing merge cells
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
var defaultColspan = 1,
|
|
54
|
+
defaultRowspan = 1;
|
|
55
|
+
|
|
56
|
+
if (colspan !== (node.attrs.colspan || defaultColspan) || rowspan !== (node.attrs.rowspan || defaultRowspan)) {
|
|
57
|
+
return false;
|
|
58
|
+
} // added + changed attributes
|
|
59
|
+
|
|
46
60
|
|
|
47
61
|
var addedAttrs = Object.entries(nextAttrs).filter(function (_ref2) {
|
|
48
62
|
var _ref3 = _slicedToArray(_ref2, 2),
|
|
@@ -79,9 +93,9 @@ var TableCellNodeView = /*#__PURE__*/function () {
|
|
|
79
93
|
}, {
|
|
80
94
|
key: "update",
|
|
81
95
|
value: function update(node) {
|
|
82
|
-
var
|
|
96
|
+
var didUpdate = this.updateNodeView(node);
|
|
83
97
|
this.node = node;
|
|
84
|
-
return
|
|
98
|
+
return didUpdate;
|
|
85
99
|
}
|
|
86
100
|
}, {
|
|
87
101
|
key: "destroy",
|
|
@@ -186,8 +186,7 @@ export var bulkColumnsResize = function bulkColumnsResize(resizeState, columnsIn
|
|
|
186
186
|
|
|
187
187
|
var newState = _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
188
188
|
cols: cols.map(function (col) {
|
|
189
|
-
if (columnsIndexes.indexOf(col.index) > -1 ||
|
|
190
|
-
columnsIndexes.indexOf(sourceColumnIndex) > -1 && col.index < colIndex) {
|
|
189
|
+
if (columnsIndexes.indexOf(col.index) > -1 || columnsIndexes.indexOf(sourceColumnIndex) > -1 && col.index < colIndex) {
|
|
191
190
|
return col;
|
|
192
191
|
}
|
|
193
192
|
|
|
@@ -225,19 +224,19 @@ export var bulkColumnsResize = function bulkColumnsResize(resizeState, columnsIn
|
|
|
225
224
|
} // table is in overflow: keep the dragged column at its widths and evenly distribute columns
|
|
226
225
|
// to recover from overflow state
|
|
227
226
|
else {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
227
|
+
var columnWidth = Math.floor((minTableWidth - sourceCol.width) / (newState.cols.length - 1));
|
|
228
|
+
newState = _objectSpread(_objectSpread({}, resizeState), {}, {
|
|
229
|
+
cols: newState.cols.map(function (col) {
|
|
230
|
+
if (col.index === sourceCol.index) {
|
|
231
|
+
return col;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return _objectSpread(_objectSpread({}, col), {}, {
|
|
235
|
+
width: columnWidth
|
|
236
|
+
});
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
}
|
|
241
240
|
} // fix total table widths by adding missing pixels to columns widths here and there
|
|
242
241
|
|
|
243
242
|
|
|
@@ -250,7 +249,7 @@ export var areColumnsEven = function areColumnsEven(resizeState) {
|
|
|
250
249
|
});
|
|
251
250
|
}; // Get the layout
|
|
252
251
|
|
|
253
|
-
var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
252
|
+
export var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
254
253
|
switch (input) {
|
|
255
254
|
case 'wide':
|
|
256
255
|
return input;
|
|
@@ -262,7 +261,6 @@ var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
|
262
261
|
return 'default';
|
|
263
262
|
}
|
|
264
263
|
};
|
|
265
|
-
|
|
266
264
|
export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFromSelectedColumns(rect, state, domAtPos, dynamicTextSizing) {
|
|
267
265
|
var _getSelectedTableInfo = getSelectedTableInfo(state.selection),
|
|
268
266
|
totalRowCount = _getSelectedTableInfo.totalRowCount,
|
|
@@ -82,7 +82,7 @@ export var scaleWithParent = function scaleWithParent(tableRef, parentWidth, tab
|
|
|
82
82
|
return scaleTableTo(resizeState, Math.floor(parentWidth));
|
|
83
83
|
}; // Scales the table to a given size and updates its colgroup DOM node
|
|
84
84
|
|
|
85
|
-
function scaleTableTo(state, maxSize) {
|
|
85
|
+
export function scaleTableTo(state, maxSize) {
|
|
86
86
|
var scaleFactor = maxSize / getTotalWidth(state);
|
|
87
87
|
|
|
88
88
|
var newState = _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -102,12 +102,12 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
102
102
|
var options = [{
|
|
103
103
|
id: 'editor.table.insertColumn',
|
|
104
104
|
title: formatMessage(tableMessages.insertColumn),
|
|
105
|
-
onClick: function onClick(state, dispatch) {
|
|
105
|
+
onClick: function onClick(state, dispatch, view) {
|
|
106
106
|
var selectionRect = getClosestSelectionRect(state);
|
|
107
107
|
var index = selectionRect === null || selectionRect === void 0 ? void 0 : selectionRect.right;
|
|
108
108
|
|
|
109
109
|
if (index) {
|
|
110
|
-
insertColumnWithAnalytics(INPUT_METHOD.FLOATING_TB, index)(state, dispatch);
|
|
110
|
+
insertColumnWithAnalytics(INPUT_METHOD.FLOATING_TB, index)(state, dispatch, view);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
return true;
|
|
@@ -137,11 +137,11 @@ export var getToolbarCellOptionsConfig = function getToolbarCellOptionsConfig(ed
|
|
|
137
137
|
title: formatMessage(tableMessages.removeColumns, {
|
|
138
138
|
0: numberOfColumns
|
|
139
139
|
}),
|
|
140
|
-
onClick: function onClick(state, dispatch) {
|
|
140
|
+
onClick: function onClick(state, dispatch, view) {
|
|
141
141
|
var selectionRect = getClosestSelectionRect(state);
|
|
142
142
|
|
|
143
143
|
if (selectionRect) {
|
|
144
|
-
deleteColumnsWithAnalytics(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch);
|
|
144
|
+
deleteColumnsWithAnalytics(INPUT_METHOD.FLOATING_TB, selectionRect)(state, dispatch, view);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
return true;
|
|
@@ -5,7 +5,12 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
6
6
|
|
|
7
7
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
8
|
+
import { hasTableBeenResized } from '../pm-plugins/table-resizing/utils';
|
|
8
9
|
import { setMeta } from './metadata';
|
|
10
|
+
import { getResizeState, normaliseTableLayout } from '../pm-plugins/table-resizing/utils/resize-state';
|
|
11
|
+
import { getTableMaxWidth } from '../pm-plugins/table-resizing/utils/misc';
|
|
12
|
+
import { tableCellMinWidth } from '@atlaskit/editor-common';
|
|
13
|
+
import { scaleTableTo } from '../pm-plugins/table-resizing/utils/scale-table';
|
|
9
14
|
export var updateColumnWidths = function updateColumnWidths(resizeState, table, start) {
|
|
10
15
|
return function (tr) {
|
|
11
16
|
var map = TableMap.get(table);
|
|
@@ -93,19 +98,66 @@ export var updateColumnWidths = function updateColumnWidths(resizeState, table,
|
|
|
93
98
|
}
|
|
94
99
|
|
|
95
100
|
var tablePos = start - 1;
|
|
96
|
-
var
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*
|
|
101
|
+
var selectionBookmark = tr.selection.getBookmark();
|
|
102
|
+
tr.replaceWith(tablePos, tablePos + table.nodeSize, table.type.createChecked(table.attrs, rows, table.marks));
|
|
103
|
+
/**
|
|
104
|
+
* We want to restore to the original selection but w/o applying the mapping. Function
|
|
105
|
+
* tr.replaceWith puts the selection after the inserted content. We need to manually
|
|
106
|
+
* set the selection back to original state. Mapping in this case doesn't quite work
|
|
107
|
+
* e.g. if we change the content before a selection. This is because mapping
|
|
108
|
+
* means moving it if the content in front of it changed. Instead we can get
|
|
109
|
+
* bookmark of selection.
|
|
100
110
|
*
|
|
101
|
-
*
|
|
102
|
-
* will map the selection to after the table as it thinks the original table
|
|
103
|
-
* node has been deleted.
|
|
111
|
+
* @see https://github.com/ProseMirror/prosemirror/issues/645
|
|
104
112
|
*/
|
|
105
113
|
|
|
106
|
-
|
|
107
|
-
|
|
114
|
+
return tr.setSelection(selectionBookmark.resolve(tr.doc));
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* This function is called when user inserts/deletes a column in a table to rescale all columns.
|
|
119
|
+
* This is done manually to avoid a multi-dispatch in TableComponent. See [ED-8288].
|
|
120
|
+
* @param table
|
|
121
|
+
* @param view
|
|
122
|
+
* @returns Updated transaction with rescaled columns for a given table
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
export var rescaleColumns = function rescaleColumns(table, view) {
|
|
126
|
+
return function (tr) {
|
|
127
|
+
if (!view || !hasTableBeenResized(table.node)) {
|
|
128
|
+
return tr;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var state = view.state;
|
|
132
|
+
var domAtPos = view.domAtPos.bind(view);
|
|
133
|
+
var maybeTable = domAtPos(table.start).node;
|
|
134
|
+
var tableRef = maybeTable.closest('table');
|
|
135
|
+
|
|
136
|
+
if (!tableRef) {
|
|
137
|
+
return tr;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
var layout = normaliseTableLayout(tableRef === null || tableRef === void 0 ? void 0 : tableRef.dataset.layout);
|
|
141
|
+
var maxSize = getTableMaxWidth({
|
|
142
|
+
table: table.node,
|
|
143
|
+
tableStart: table.start,
|
|
144
|
+
state: state,
|
|
145
|
+
layout: layout,
|
|
146
|
+
dynamicTextSizing: true
|
|
147
|
+
});
|
|
148
|
+
var resizeState = getResizeState({
|
|
149
|
+
minWidth: tableCellMinWidth,
|
|
150
|
+
table: table.node,
|
|
151
|
+
start: table.start,
|
|
152
|
+
tableRef: tableRef,
|
|
153
|
+
domAtPos: domAtPos,
|
|
154
|
+
maxSize: maxSize
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (resizeState.overflow) {
|
|
158
|
+
resizeState = scaleTableTo(resizeState, maxSize);
|
|
159
|
+
}
|
|
108
160
|
|
|
109
|
-
return
|
|
161
|
+
return updateColumnWidths(resizeState, table.node, table.start)(tr);
|
|
110
162
|
};
|
|
111
163
|
};
|
|
@@ -316,7 +316,7 @@ var ContextualMenu = /*#__PURE__*/function (_Component) {
|
|
|
316
316
|
break;
|
|
317
317
|
|
|
318
318
|
case 'insert_column':
|
|
319
|
-
insertColumnWithAnalytics(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch);
|
|
319
|
+
insertColumnWithAnalytics(INPUT_METHOD.CONTEXT_MENU, selectionRect.right)(state, dispatch, editorView);
|
|
320
320
|
|
|
321
321
|
_this.toggleOpen();
|
|
322
322
|
|
|
@@ -198,7 +198,7 @@ var FloatingInsertButton = /*#__PURE__*/function (_React$Component) {
|
|
|
198
198
|
event.preventDefault();
|
|
199
199
|
var state = editorView.state,
|
|
200
200
|
dispatch = editorView.dispatch;
|
|
201
|
-
insertColumnWithAnalytics(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch);
|
|
201
|
+
insertColumnWithAnalytics(INPUT_METHOD.BUTTON, insertColumnButtonIndex)(state, dispatch, editorView);
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
204
|
}]);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { TableMap } from '@atlaskit/editor-tables/table-map';
|
|
2
3
|
import { findTable } from '@atlaskit/editor-tables/utils';
|
|
3
4
|
export var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
@@ -18,4 +19,12 @@ export var getMergedCellsPositions = function getMergedCellsPositions(tr) {
|
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
return mergedCells;
|
|
22
|
+
};
|
|
23
|
+
export var colsToRect = function colsToRect(cols, noOfRows) {
|
|
24
|
+
return {
|
|
25
|
+
left: Math.min.apply(Math, _toConsumableArray(cols)),
|
|
26
|
+
right: Math.max.apply(Math, _toConsumableArray(cols)) + 1,
|
|
27
|
+
top: 0,
|
|
28
|
+
bottom: noOfRows
|
|
29
|
+
};
|
|
21
30
|
};
|
|
@@ -184,8 +184,7 @@ var deleteHandler = filter([isInsideTaskOrDecisionItem, isEmptySelectionAtEnd],
|
|
|
184
184
|
} // if nested, just unindent
|
|
185
185
|
|
|
186
186
|
|
|
187
|
-
if ($next.node($next.depth - 2).type === taskList ||
|
|
188
|
-
$next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
187
|
+
if ($next.node($next.depth - 2).type === taskList || $next.node($next.depth - 1).type === taskList && $next.parent.type === taskList) {
|
|
189
188
|
var tr = liftBlock(state.tr, $next, $next);
|
|
190
189
|
|
|
191
190
|
if (dispatch && tr) {
|
|
@@ -144,12 +144,6 @@ var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
144
144
|
isOpen = _this$state.isOpen,
|
|
145
145
|
isShowingMoreColors = _this$state.isShowingMoreColors;
|
|
146
146
|
|
|
147
|
-
if (e.defaultPrevented) {
|
|
148
|
-
// This should be handled by stopping propogation, but as an additional safety net
|
|
149
|
-
// we ignore handled events for the purpose of hiding the popup.
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
147
|
if (isOpen === true) {
|
|
154
148
|
_this.dispatchAnalyticsEvent(_this.buildAnalyticsPalette(ACTION.CLOSED, {
|
|
155
149
|
isShowingMoreColors: isShowingMoreColors,
|
|
@@ -237,13 +231,15 @@ var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
|
237
231
|
label: ""
|
|
238
232
|
})))
|
|
239
233
|
})
|
|
234
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
235
|
+
"data-testid": "text-color-palette"
|
|
240
236
|
}, /*#__PURE__*/React.createElement(ColorPalette, {
|
|
241
237
|
palette: palette,
|
|
242
238
|
onClick: function onClick(color) {
|
|
243
239
|
return _this2.changeTextColor(color, pluginState.disabled);
|
|
244
240
|
},
|
|
245
241
|
selectedColor: pluginState.color
|
|
246
|
-
}), showMoreColorsToggle && /*#__PURE__*/React.createElement(ShowMoreWrapper, null, /*#__PURE__*/React.createElement(Button, {
|
|
242
|
+
})), showMoreColorsToggle && /*#__PURE__*/React.createElement(ShowMoreWrapper, null, /*#__PURE__*/React.createElement(Button, {
|
|
247
243
|
appearance: "subtle",
|
|
248
244
|
onClick: this.handleShowMoreToggle,
|
|
249
245
|
iconBefore: /*#__PURE__*/React.createElement(EditorBackgroundColorIcon, {
|
|
@@ -24,10 +24,7 @@ export default new Plugin({
|
|
|
24
24
|
var clickWasAtTextNode = !!(clickNode && clickNode.isText);
|
|
25
25
|
var clickWasAtEndOfAParagraphNode = $click.parent.type === paragraph && $click.textOffset === 0 && $click.nodeAfter === null;
|
|
26
26
|
|
|
27
|
-
if (clickWasAtEdgeOfATextNode && clickWasNearACodeMark && clickedDOMElementPosition && (
|
|
28
|
-
// it was at a directly adjacent non-text node, so we skip this manual
|
|
29
|
-
// text selection logic to preserve that non-text node's selection
|
|
30
|
-
clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
27
|
+
if (clickWasAtEdgeOfATextNode && clickWasNearACodeMark && clickedDOMElementPosition && (clickWasAtTextNode || clickWasAtEndOfAParagraphNode)) {
|
|
31
28
|
var clickWasInsideNodeDOM = event.target.parentNode === view.domAtPos(clickedDOMElementPosition).node && code.isInSet(view.state.doc.resolve(clickedDOMElementPosition).nodeAfter.marks);
|
|
32
29
|
var nodeNextToClick = $click.nodeBefore && code.isInSet($click.nodeBefore.marks) ? $click.nodeAfter : $click.nodeBefore; // Need to set the selection here to allow clicking between [code('text'),{<>},emoji()]
|
|
33
30
|
|
|
@@ -15,8 +15,25 @@ export var openTypeAheadAtCursor = function openTypeAheadAtCursor(_ref) {
|
|
|
15
15
|
}
|
|
16
16
|
});
|
|
17
17
|
var selection = tr.selection;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
|
|
19
|
+
if (!(selection instanceof TextSelection)) {
|
|
20
|
+
return tr;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!selection.$cursor) {
|
|
24
|
+
tr.deleteSelection();
|
|
25
|
+
return tr;
|
|
26
|
+
} // Search & Destroy placeholder
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
var cursorPos = selection.$cursor.pos;
|
|
30
|
+
var nodeAtCursor = tr.doc.nodeAt(cursorPos);
|
|
31
|
+
var isPlaceholderAtCursorPosition = nodeAtCursor && nodeAtCursor.type.name === 'placeholder';
|
|
32
|
+
|
|
33
|
+
if (nodeAtCursor && isPlaceholderAtCursorPosition) {
|
|
34
|
+
tr.delete(cursorPos, cursorPos + nodeAtCursor.nodeSize);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return tr;
|
|
21
38
|
};
|
|
22
39
|
};
|
|
@@ -52,7 +52,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
52
52
|
var text = cleanedInputContent();
|
|
53
53
|
onQueryChange(text);
|
|
54
54
|
}, [onQueryChange, cleanedInputContent]);
|
|
55
|
-
var
|
|
55
|
+
var checkKeyEvent = useCallback(function (event) {
|
|
56
56
|
var key = keyNameNormalized(event);
|
|
57
57
|
var sel = document.getSelection();
|
|
58
58
|
var raw = ref.current.textContent || '';
|
|
@@ -165,7 +165,10 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
165
165
|
});
|
|
166
166
|
event.preventDefault();
|
|
167
167
|
event.stopPropagation();
|
|
168
|
+
return;
|
|
168
169
|
}
|
|
170
|
+
|
|
171
|
+
checkKeyEvent(event);
|
|
169
172
|
};
|
|
170
173
|
|
|
171
174
|
var onFocusOut = function onFocusOut(event) {
|
|
@@ -260,7 +263,7 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
260
263
|
element.removeEventListener('input', onInput);
|
|
261
264
|
}
|
|
262
265
|
};
|
|
263
|
-
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel]);
|
|
266
|
+
}, [triggerQueryPrefix, cleanedInputContent, onQueryFocus, cancel, checkKeyEvent]);
|
|
264
267
|
useEffect(function () {
|
|
265
268
|
var hasReopenQuery = typeof reopenQuery === 'string' && reopenQuery.trim().length > 0;
|
|
266
269
|
|
|
@@ -290,7 +293,6 @@ export var InputQuery = /*#__PURE__*/React.memo(function (_ref) {
|
|
|
290
293
|
contentEditable: true,
|
|
291
294
|
innerRef: ref,
|
|
292
295
|
onKeyUp: onKeyUp,
|
|
293
|
-
onKeyDown: onKeyDown,
|
|
294
296
|
onClick: onClick,
|
|
295
297
|
role: "textbox",
|
|
296
298
|
suppressContentEditableWarning: true,
|
|
@@ -8,10 +8,9 @@ import { akEditorFloatingDialogZIndex } from '@atlaskit/editor-shared-styles';
|
|
|
8
8
|
import { Popup } from '@atlaskit/editor-common';
|
|
9
9
|
import { borderRadius, gridSize } from '@atlaskit/theme/constants';
|
|
10
10
|
import { N0, N60A, N50A } from '@atlaskit/theme/colors';
|
|
11
|
-
import { divide } from '@atlaskit/theme/math';
|
|
12
11
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../../analytics';
|
|
13
12
|
import { TypeAheadList } from './TypeAheadList';
|
|
14
|
-
var TypeAheadContent = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n box-shadow: 0 0 1px ", ", 0 4px 8px -2px ", ";\n padding: ", "px 0;\n width: 320px;\n max-height: 380px; /* ~5.5 visibile items */\n overflow-y: auto;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n position: relative;\n"])), N0, borderRadius(), N60A, N50A,
|
|
13
|
+
var TypeAheadContent = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n box-shadow: 0 0 1px ", ", 0 4px 8px -2px ", ";\n padding: ", "px 0;\n width: 320px;\n max-height: 380px; /* ~5.5 visibile items */\n overflow-y: auto;\n -ms-overflow-style: -ms-autohiding-scrollbar;\n position: relative;\n"])), N0, borderRadius(), N60A, N50A, gridSize() / 2);
|
|
15
14
|
|
|
16
15
|
var Highlight = function Highlight(_ref) {
|
|
17
16
|
var state = _ref.state,
|
|
@@ -62,9 +62,7 @@ export var subscribeToToolbarAndPickerUpdates = function subscribeToToolbarAndPi
|
|
|
62
62
|
var oldToolbarConfig = getOldConfigWithNodeInfo(lastUpdatedState);
|
|
63
63
|
var isToolbarEqual = areToolbarsSame(toolbarConfig, oldToolbarConfig);
|
|
64
64
|
|
|
65
|
-
if (dateState !== oldDateState || statusState !== oldStatusState ||
|
|
66
|
-
// EG A nested status or date node in a table
|
|
67
|
-
!isToolbarEqual && !statusState.showStatusPickerAt && !dateState.showDatePickerAt) {
|
|
65
|
+
if (dateState !== oldDateState || statusState !== oldStatusState || !isToolbarEqual && !statusState.showStatusPickerAt && !dateState.showDatePickerAt) {
|
|
68
66
|
shouldCallback = true;
|
|
69
67
|
}
|
|
70
68
|
} else {
|