@atlaskit/editor-core 149.0.1 → 150.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.
- package/CHANGELOG.md +41 -0
- package/dist/cjs/create-editor/create-plugins-list.js +2 -1
- 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/plugins/analytics/types/enums.js +0 -1
- package/dist/cjs/plugins/analytics/types/node-events.js +1 -0
- package/dist/cjs/plugins/collab-edit/ui/to-avatar.js +4 -8
- 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/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/table/commands/insert.js +25 -10
- package/dist/cjs/plugins/table/commands/misc.js +3 -3
- 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 +3 -1
- 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/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/cjs/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/cjs/plugins/type-ahead/ui/TypeAheadPopup.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/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/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/plugins/analytics/types/enums.js +0 -1
- package/dist/es2019/plugins/analytics/types/node-events.js +1 -0
- package/dist/es2019/plugins/collab-edit/ui/to-avatar.js +2 -6
- 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/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/table/commands/insert.js +27 -12
- package/dist/es2019/plugins/table/commands/misc.js +3 -3
- 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 +1 -2
- 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/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/es2019/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/es2019/plugins/type-ahead/ui/TypeAheadPopup.js +1 -2
- 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/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/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/plugins/analytics/types/enums.js +0 -1
- package/dist/esm/plugins/analytics/types/node-events.js +1 -0
- package/dist/esm/plugins/collab-edit/ui/to-avatar.js +4 -8
- 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/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/table/commands/insert.js +26 -11
- package/dist/esm/plugins/table/commands/misc.js +3 -3
- 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 +1 -2
- 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/text-color/ui/ToolbarTextColor/index.js +3 -7
- package/dist/esm/plugins/type-ahead/transforms/open-typeahead-at-cursor.js +20 -3
- package/dist/esm/plugins/type-ahead/ui/TypeAheadPopup.js +1 -2
- 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/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/editor.d.ts +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/analytics-queue.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/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -2
- package/dist/types/plugins/floating-toolbar/ui/EditorRemoveEmojiIcon.d.ts +1 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- 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/quick-insert/index.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
|
|
|
@@ -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",
|
|
@@ -249,7 +249,7 @@ export var areColumnsEven = function areColumnsEven(resizeState) {
|
|
|
249
249
|
});
|
|
250
250
|
}; // Get the layout
|
|
251
251
|
|
|
252
|
-
var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
252
|
+
export var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
253
253
|
switch (input) {
|
|
254
254
|
case 'wide':
|
|
255
255
|
return input;
|
|
@@ -261,7 +261,6 @@ var normaliseTableLayout = function normaliseTableLayout(input) {
|
|
|
261
261
|
return 'default';
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
|
-
|
|
265
264
|
export var getNewResizeStateFromSelectedColumns = function getNewResizeStateFromSelectedColumns(rect, state, domAtPos, dynamicTextSizing) {
|
|
266
265
|
var _getSelectedTableInfo = getSelectedTableInfo(state.selection),
|
|
267
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
|
};
|
|
@@ -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, {
|
|
@@ -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
|
};
|
|
@@ -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,
|
|
@@ -5,7 +5,7 @@ var _templateObject, _templateObject2;
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
|
-
import { Popup } from '@atlaskit/editor-common';
|
|
8
|
+
import { Popup, withOuterListeners } from '@atlaskit/editor-common';
|
|
9
9
|
import Button from '@atlaskit/button';
|
|
10
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
11
11
|
import { N60A } from '@atlaskit/theme/colors';
|
|
@@ -34,6 +34,8 @@ var ColorPickerButton = function ColorPickerButton(props) {
|
|
|
34
34
|
setIsPopupOpen(!isPopupOpen);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
var ColorPaletteWithListeners = withOuterListeners(ColorPalette);
|
|
38
|
+
|
|
37
39
|
var onColorSelected = function onColorSelected(color, label) {
|
|
38
40
|
setIsPopupOpen(false);
|
|
39
41
|
|
|
@@ -72,11 +74,12 @@ var ColorPickerButton = function ColorPickerButton(props) {
|
|
|
72
74
|
fitWidth: 350,
|
|
73
75
|
offset: [0, 10],
|
|
74
76
|
alignX: props.alignX
|
|
75
|
-
}, /*#__PURE__*/React.createElement(ColorPickerWrapper, null, /*#__PURE__*/React.createElement(
|
|
77
|
+
}, /*#__PURE__*/React.createElement(ColorPickerWrapper, null, /*#__PURE__*/React.createElement(ColorPaletteWithListeners, {
|
|
76
78
|
palette: props.colorPalette,
|
|
77
79
|
cols: props.cols,
|
|
78
80
|
selectedColor: props.currentColor || null,
|
|
79
|
-
onClick: onColorSelected
|
|
81
|
+
onClick: onColorSelected,
|
|
82
|
+
handleClickOutside: togglePopup
|
|
80
83
|
})));
|
|
81
84
|
};
|
|
82
85
|
|
|
@@ -11,6 +11,7 @@ import { mockCreateAnalyticsEvent, mockFire } from '@atlaskit/editor-test-helper
|
|
|
11
11
|
import ColorPickerButton from './index';
|
|
12
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '../../plugins/analytics/types';
|
|
13
13
|
import { editorAnalyticsChannel } from '../../plugins/analytics/consts';
|
|
14
|
+
import { act } from 'react-dom/test-utils';
|
|
14
15
|
describe('color-picker-button', function () {
|
|
15
16
|
var onChangeMock = jest.fn();
|
|
16
17
|
|
|
@@ -49,6 +50,20 @@ describe('color-picker-button', function () {
|
|
|
49
50
|
expect(wrapper.find('ColorPalette')).toHaveLength(1);
|
|
50
51
|
expect(wrapper.find('Color')).toHaveLength(21);
|
|
51
52
|
});
|
|
53
|
+
it('should close ColorPalette popup after clicking outside', function () {
|
|
54
|
+
var wrapper = getWrapper(); // show the popup
|
|
55
|
+
|
|
56
|
+
wrapper.find('button').simulate('click'); // make sure the popup and picker are shown
|
|
57
|
+
|
|
58
|
+
expect(wrapper.find('Popup')).toHaveLength(1);
|
|
59
|
+
var colorPalette = wrapper.find('InjectIntl(ColorPalette)').instance();
|
|
60
|
+
act(function () {
|
|
61
|
+
colorPalette.props.handleClickOutside();
|
|
62
|
+
});
|
|
63
|
+
wrapper.update(); // make sure popup is hidden
|
|
64
|
+
|
|
65
|
+
expect(wrapper.find('Popup')).toHaveLength(0);
|
|
66
|
+
});
|
|
52
67
|
it('should hide popup and call onChange after selecting a color', function () {
|
|
53
68
|
var wrapper = getWrapper();
|
|
54
69
|
selectColor(wrapper, 'Mintie'); // ensure popup is hidden
|
|
@@ -12,10 +12,9 @@ import ChevronRightIcon from '@atlaskit/icon/glyph/chevron-right';
|
|
|
12
12
|
import Button from '@atlaskit/button';
|
|
13
13
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
14
14
|
import { messages } from '../messages';
|
|
15
|
-
import { multiply } from '@atlaskit/theme/math';
|
|
16
15
|
export var ExpandContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-bottom: 1px solid ", ";\n"])), N40);
|
|
17
|
-
export var ExpandControl = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n height: ", "px;\n justify-content: center;\n padding-right: ", "px;\n"])),
|
|
18
|
-
var ChevronContainer = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n\n & > button {\n width: ", "px;\n height: ", "px;\n }\n"])),
|
|
16
|
+
export var ExpandControl = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n height: ", "px;\n justify-content: center;\n padding-right: ", "px;\n"])), gridSize() * 6, gridSize());
|
|
17
|
+
var ChevronContainer = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n\n & > button {\n width: ", "px;\n height: ", "px;\n }\n"])), gridSize() * 3, gridSize() * 3);
|
|
19
18
|
var LabelContainer = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n width: 100%;\n align-items: center;\n display: flex;\n font-weight: 500;\n"])));
|
|
20
19
|
var ExpandContentContainer = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: ", ";\n margin-top: -", "px;\n"])), function (_ref) {
|
|
21
20
|
var isHidden = _ref.isHidden;
|
|
@@ -31,9 +31,8 @@ import { messages } from '../messages'; // eslint-disable-next-line import/no-cy
|
|
|
31
31
|
import FormContent from '../FormContent';
|
|
32
32
|
import { getNameFromDuplicateField, isDuplicateField } from '../utils';
|
|
33
33
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
34
|
-
import { multiply } from '@atlaskit/theme/math';
|
|
35
34
|
import { N40A } from '@atlaskit/theme/colors';
|
|
36
|
-
var ActionsWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-top: 1px solid ", ";\n margin-top: ", "px;\n padding-top: ", "px;\n"])), N40A,
|
|
35
|
+
var ActionsWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n border-top: 1px solid ", ";\n margin-top: ", "px;\n padding-top: ", "px;\n"])), N40A, gridSize() * 2, gridSize() * 2);
|
|
37
36
|
|
|
38
37
|
var populateFromParameters = function populateFromParameters(parameters, fields) {
|
|
39
38
|
if (Object.keys(parameters).length) {
|
|
@@ -6,13 +6,12 @@ import React from 'react';
|
|
|
6
6
|
import { injectIntl } from 'react-intl';
|
|
7
7
|
import styled from 'styled-components';
|
|
8
8
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
9
|
-
import { multiply } from '@atlaskit/theme/math';
|
|
10
9
|
import CrossCircleIcon from '@atlaskit/icon/glyph/cross-circle';
|
|
11
10
|
import Tooltip from '@atlaskit/tooltip';
|
|
12
11
|
import * as colors from '@atlaskit/theme/colors';
|
|
13
12
|
import { messages } from '../messages';
|
|
14
13
|
var RemovableFieldWrapper = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n margin-bottom: ", "px;\n"])), function (props) {
|
|
15
|
-
return props.hasMarginBottom ?
|
|
14
|
+
return props.hasMarginBottom ? gridSize() * 2 : 0;
|
|
16
15
|
});
|
|
17
16
|
var RemoveButtonWrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n right: 0;\n top: 0;\n cursor: pointer;\n\n color: ", ";\n\n &:hover {\n color: ", ";\n }\n"])), colors.N80, colors.R300);
|
|
18
17
|
|
package/dist/esm/version.json
CHANGED
package/dist/types/editor.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ export default class Editor extends React.Component<EditorProps, State> {
|
|
|
48
48
|
};
|
|
49
49
|
} | undefined;
|
|
50
50
|
};
|
|
51
|
-
prepareExtensionProvider: (extensionProviders?: (ExtensionProvider<any> | Promise<ExtensionProvider<any>>)[] | ((editorActions?: EditorActions<any> | undefined) => (ExtensionProvider<any> | Promise<ExtensionProvider<any>>)[]) | undefined) => ExtensionProvider<any> | undefined
|
|
51
|
+
prepareExtensionProvider: import("memoize-one").MemoizedFn<(extensionProviders?: (ExtensionProvider<any> | Promise<ExtensionProvider<any>>)[] | ((editorActions?: EditorActions<any> | undefined) => (ExtensionProvider<any> | Promise<ExtensionProvider<any>>)[]) | undefined) => ExtensionProvider<any> | undefined>;
|
|
52
52
|
prepareQuickInsertProvider: (extensionProvider?: ExtensionProvider<any> | undefined, quickInsert?: boolean | {
|
|
53
53
|
provider: Promise<QuickInsertProvider>;
|
|
54
54
|
} | undefined) => Promise<QuickInsertProvider> | undefined;
|