@atlaskit/editor-plugin-undo-redo 2.0.6 → 2.0.8

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/editor-plugin-undo-redo
2
2
 
3
+ ## 2.0.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#130818](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130818)
8
+ [`0e42cb4df2b7f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0e42cb4df2b7f) -
9
+ Changed undo/redo commands to use EXTRENAL input type when no inputSource is provided. Ensure type
10
+ ahead is closed before undo/redo and that editor is re-focused after undo/redo.
11
+
12
+ ## 2.0.7
13
+
14
+ ### Patch Changes
15
+
16
+ - [#130044](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/130044)
17
+ [`cad348d512cdf`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/cad348d512cdf) -
18
+ [ux] ED-26802 contextual formatting configuration
19
+ - Updated dependencies
20
+
3
21
  ## 2.0.6
4
22
 
5
23
  ### Patch Changes
@@ -8,6 +8,6 @@ var _analytics = require("@atlaskit/editor-common/analytics");
8
8
  var InputSource = exports.InputSource = function (InputSource) {
9
9
  InputSource[InputSource["TOOLBAR"] = _analytics.INPUT_METHOD.TOOLBAR] = "TOOLBAR";
10
10
  InputSource[InputSource["KEYBOARD"] = _analytics.INPUT_METHOD.KEYBOARD] = "KEYBOARD";
11
- InputSource[InputSource["PAGE_OVERFLOW_MENU"] = _analytics.INPUT_METHOD.PAGE_OVERFLOW_MENU] = "PAGE_OVERFLOW_MENU";
11
+ InputSource[InputSource["EXTERNAL"] = _analytics.INPUT_METHOD.EXTERNAL] = "EXTERNAL";
12
12
  return InputSource;
13
13
  }({});
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.forceFocus = exports.closeTypeAheadAndRunCommand = void 0;
7
+ var closeTypeAheadAndRunCommand = exports.closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
8
+ return function (command) {
9
+ var _api$typeAhead;
10
+ if (!editorView) {
11
+ return false;
12
+ }
13
+ if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead = _api$typeAhead.actions) !== null && _api$typeAhead !== void 0 && _api$typeAhead.isOpen(editorView.state)) {
14
+ var _api$typeAhead2;
15
+ api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || _api$typeAhead2.close({
16
+ attachCommand: command,
17
+ insertCurrentQueryAsRawText: false
18
+ });
19
+ } else {
20
+ command(editorView.state, editorView.dispatch);
21
+ }
22
+ return true;
23
+ };
24
+ };
25
+ var forceFocus = exports.forceFocus = function forceFocus(editorView, api) {
26
+ return function (command) {
27
+ var result = closeTypeAheadAndRunCommand(editorView, api)(command);
28
+ if (result && !editorView.hasFocus()) {
29
+ editorView.focus();
30
+ }
31
+ return result;
32
+ };
33
+ };
@@ -16,37 +16,13 @@ var _redo = _interopRequireDefault(require("@atlaskit/icon/core/migration/redo")
16
16
  var _undo = _interopRequireDefault(require("@atlaskit/icon/core/migration/undo"));
17
17
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
18
18
  var _commands = require("../../pm-plugins/commands");
19
+ var _utils = require("../../pm-plugins/utils");
19
20
  /**
20
21
  * @jsxRuntime classic
21
22
  * @jsx jsx
22
23
  */
23
24
  // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
24
25
 
25
- var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
26
- return function (command) {
27
- var _api$typeAhead;
28
- if (!editorView) {
29
- return;
30
- }
31
- if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead = _api$typeAhead.actions) !== null && _api$typeAhead !== void 0 && _api$typeAhead.isOpen(editorView.state)) {
32
- var _api$typeAhead2;
33
- api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || _api$typeAhead2.close({
34
- attachCommand: command,
35
- insertCurrentQueryAsRawText: false
36
- });
37
- } else {
38
- command(editorView.state, editorView.dispatch);
39
- }
40
- };
41
- };
42
- var forceFocus = function forceFocus(editorView, api) {
43
- return function (command) {
44
- closeTypeAheadAndRunCommand(editorView, api)(command);
45
- if (!editorView.hasFocus()) {
46
- editorView.focus();
47
- }
48
- };
49
- };
50
26
  var ToolbarUndoRedo = exports.ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
51
27
  var disabled = _ref.disabled,
52
28
  isReducedSpacing = _ref.isReducedSpacing,
@@ -56,10 +32,10 @@ var ToolbarUndoRedo = exports.ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
56
32
  var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['history']),
57
33
  historyState = _useSharedPluginState.historyState;
58
34
  var handleUndo = function handleUndo() {
59
- forceFocus(editorView, api)(_commands.undoFromToolbar);
35
+ (0, _utils.forceFocus)(editorView, api)(_commands.undoFromToolbar);
60
36
  };
61
37
  var handleRedo = function handleRedo() {
62
- forceFocus(editorView, api)(_commands.redoFromToolbar);
38
+ (0, _utils.forceFocus)(editorView, api)(_commands.redoFromToolbar);
63
39
  };
64
40
  var labelUndo = formatMessage(_messages.undoRedoMessages.undo);
65
41
  var labelRedo = formatMessage(_messages.undoRedoMessages.redo);
@@ -10,14 +10,16 @@ var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
10
10
  var _history = require("@atlaskit/editor-prosemirror/history");
11
11
  var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
12
12
  var _attachInputMeta = require("./pm-plugins/attach-input-meta");
13
+ var _enums = require("./pm-plugins/enums");
13
14
  var _keymaps = require("./pm-plugins/keymaps");
14
15
  var _main = require("./pm-plugins/main");
16
+ var _utils = require("./pm-plugins/utils");
15
17
  var _ToolbarUndoRedo = _interopRequireDefault(require("./ui/ToolbarUndoRedo"));
16
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
17
18
  // Ignored via go/ees005
18
19
  // eslint-disable-next-line import/no-named-as-default
19
20
 
20
21
  var undoRedoPlugin = exports.undoRedoPlugin = function undoRedoPlugin(_ref) {
22
+ var _api$primaryToolbar;
21
23
  var api = _ref.api;
22
24
  var editorViewRef = {
23
25
  current: null
@@ -33,42 +35,27 @@ var undoRedoPlugin = exports.undoRedoPlugin = function undoRedoPlugin(_ref) {
33
35
  api: api
34
36
  });
35
37
  };
36
- if ((0, _experiments.editorExperiment)('platform_editor_controls', 'control', {
37
- exposure: true
38
- })) {
39
- var _api$primaryToolbar;
40
- api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
41
- name: 'undoRedoPlugin',
42
- component: primaryToolbarComponent
43
- });
44
- }
38
+ api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
39
+ name: 'undoRedoPlugin',
40
+ component: primaryToolbarComponent
41
+ });
42
+ var handleUndo = function handleUndo(inputSource) {
43
+ if (!editorViewRef.current) {
44
+ return false;
45
+ }
46
+ return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.undo));
47
+ };
48
+ var handleRedo = function handleRedo(inputSource) {
49
+ if (!editorViewRef.current) {
50
+ return false;
51
+ }
52
+ return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.redo));
53
+ };
45
54
  return {
46
55
  name: 'undoRedoPlugin',
47
56
  actions: {
48
- undo: function undo(inputSource) {
49
- if (!editorViewRef.current) {
50
- return false;
51
- }
52
- var _editorViewRef$curren = editorViewRef.current,
53
- state = _editorViewRef$curren.state,
54
- dispatch = _editorViewRef$curren.dispatch;
55
- if (!inputSource) {
56
- return (0, _history.undo)(state, dispatch);
57
- }
58
- return (0, _attachInputMeta.attachInputMeta)(inputSource)(_history.undo)(state, dispatch);
59
- },
60
- redo: function redo(inputSource) {
61
- if (!editorViewRef.current) {
62
- return false;
63
- }
64
- var _editorViewRef$curren2 = editorViewRef.current,
65
- state = _editorViewRef$curren2.state,
66
- dispatch = _editorViewRef$curren2.dispatch;
67
- if (!inputSource) {
68
- return (0, _history.redo)(state, dispatch);
69
- }
70
- return (0, _attachInputMeta.attachInputMeta)(inputSource)(_history.redo)(state, dispatch);
71
- }
57
+ undo: handleUndo,
58
+ redo: handleRedo
72
59
  },
73
60
  pmPlugins: function pmPlugins() {
74
61
  var plugins = [{
@@ -103,8 +90,6 @@ var undoRedoPlugin = exports.undoRedoPlugin = function undoRedoPlugin(_ref) {
103
90
  }
104
91
  return plugins;
105
92
  },
106
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _experiments.editorExperiment)('platform_editor_controls', 'control', {
107
- exposure: true
108
- }) ? primaryToolbarComponent : undefined
93
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
109
94
  };
110
95
  };
@@ -2,6 +2,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  export let InputSource = function (InputSource) {
3
3
  InputSource[InputSource["TOOLBAR"] = INPUT_METHOD.TOOLBAR] = "TOOLBAR";
4
4
  InputSource[InputSource["KEYBOARD"] = INPUT_METHOD.KEYBOARD] = "KEYBOARD";
5
- InputSource[InputSource["PAGE_OVERFLOW_MENU"] = INPUT_METHOD.PAGE_OVERFLOW_MENU] = "PAGE_OVERFLOW_MENU";
5
+ InputSource[InputSource["EXTERNAL"] = INPUT_METHOD.EXTERNAL] = "EXTERNAL";
6
6
  return InputSource;
7
7
  }({});
@@ -0,0 +1,23 @@
1
+ export const closeTypeAheadAndRunCommand = (editorView, api) => command => {
2
+ var _api$typeAhead, _api$typeAhead$action;
3
+ if (!editorView) {
4
+ return false;
5
+ }
6
+ if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead$action = _api$typeAhead.actions) !== null && _api$typeAhead$action !== void 0 && _api$typeAhead$action.isOpen(editorView.state)) {
7
+ var _api$typeAhead2, _api$typeAhead2$actio;
8
+ api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.close({
9
+ attachCommand: command,
10
+ insertCurrentQueryAsRawText: false
11
+ });
12
+ } else {
13
+ command(editorView.state, editorView.dispatch);
14
+ }
15
+ return true;
16
+ };
17
+ export const forceFocus = (editorView, api) => command => {
18
+ const result = closeTypeAheadAndRunCommand(editorView, api)(command);
19
+ if (result && !editorView.hasFocus()) {
20
+ editorView.focus();
21
+ }
22
+ return result;
23
+ };
@@ -14,27 +14,7 @@ import RedoIcon from '@atlaskit/icon/core/migration/redo';
14
14
  import UndoIcon from '@atlaskit/icon/core/migration/undo';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { redoFromToolbar, undoFromToolbar } from '../../pm-plugins/commands';
17
- const closeTypeAheadAndRunCommand = (editorView, api) => command => {
18
- var _api$typeAhead, _api$typeAhead$action;
19
- if (!editorView) {
20
- return;
21
- }
22
- if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead$action = _api$typeAhead.actions) !== null && _api$typeAhead$action !== void 0 && _api$typeAhead$action.isOpen(editorView.state)) {
23
- var _api$typeAhead2, _api$typeAhead2$actio;
24
- api === null || api === void 0 ? void 0 : (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 ? void 0 : (_api$typeAhead2$actio = _api$typeAhead2.actions) === null || _api$typeAhead2$actio === void 0 ? void 0 : _api$typeAhead2$actio.close({
25
- attachCommand: command,
26
- insertCurrentQueryAsRawText: false
27
- });
28
- } else {
29
- command(editorView.state, editorView.dispatch);
30
- }
31
- };
32
- const forceFocus = (editorView, api) => command => {
33
- closeTypeAheadAndRunCommand(editorView, api)(command);
34
- if (!editorView.hasFocus()) {
35
- editorView.focus();
36
- }
37
- };
17
+ import { forceFocus } from '../../pm-plugins/utils';
38
18
  export const ToolbarUndoRedo = ({
39
19
  disabled,
40
20
  isReducedSpacing,
@@ -3,15 +3,17 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import { redo, undo } from '@atlaskit/editor-prosemirror/history';
4
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
5
  import { attachInputMeta } from './pm-plugins/attach-input-meta';
6
+ import { InputSource } from './pm-plugins/enums';
6
7
  import { keymapPlugin } from './pm-plugins/keymaps';
7
8
  import { createPlugin } from './pm-plugins/main';
8
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
9
+ import { forceFocus } from './pm-plugins/utils';
9
10
  // Ignored via go/ees005
10
11
  // eslint-disable-next-line import/no-named-as-default
11
12
  import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
12
13
  export const undoRedoPlugin = ({
13
14
  api
14
15
  }) => {
16
+ var _api$primaryToolbar;
15
17
  const editorViewRef = {
16
18
  current: null
17
19
  };
@@ -27,44 +29,27 @@ export const undoRedoPlugin = ({
27
29
  api: api
28
30
  });
29
31
  };
30
- if (editorExperiment('platform_editor_controls', 'control', {
31
- exposure: true
32
- })) {
33
- var _api$primaryToolbar;
34
- api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
35
- name: 'undoRedoPlugin',
36
- component: primaryToolbarComponent
37
- });
38
- }
32
+ api === null || api === void 0 ? void 0 : (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 ? void 0 : _api$primaryToolbar.actions.registerComponent({
33
+ name: 'undoRedoPlugin',
34
+ component: primaryToolbarComponent
35
+ });
36
+ const handleUndo = inputSource => {
37
+ if (!editorViewRef.current) {
38
+ return false;
39
+ }
40
+ return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
41
+ };
42
+ const handleRedo = inputSource => {
43
+ if (!editorViewRef.current) {
44
+ return false;
45
+ }
46
+ return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
47
+ };
39
48
  return {
40
49
  name: 'undoRedoPlugin',
41
50
  actions: {
42
- undo: inputSource => {
43
- if (!editorViewRef.current) {
44
- return false;
45
- }
46
- const {
47
- state,
48
- dispatch
49
- } = editorViewRef.current;
50
- if (!inputSource) {
51
- return undo(state, dispatch);
52
- }
53
- return attachInputMeta(inputSource)(undo)(state, dispatch);
54
- },
55
- redo: inputSource => {
56
- if (!editorViewRef.current) {
57
- return false;
58
- }
59
- const {
60
- state,
61
- dispatch
62
- } = editorViewRef.current;
63
- if (!inputSource) {
64
- return redo(state, dispatch);
65
- }
66
- return attachInputMeta(inputSource)(redo)(state, dispatch);
67
- }
51
+ undo: handleUndo,
52
+ redo: handleRedo
68
53
  },
69
54
  pmPlugins() {
70
55
  const plugins = [{
@@ -95,8 +80,6 @@ export const undoRedoPlugin = ({
95
80
  }
96
81
  return plugins;
97
82
  },
98
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'control', {
99
- exposure: true
100
- }) ? primaryToolbarComponent : undefined
83
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
101
84
  };
102
85
  };
@@ -2,6 +2,6 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  export var InputSource = function (InputSource) {
3
3
  InputSource[InputSource["TOOLBAR"] = INPUT_METHOD.TOOLBAR] = "TOOLBAR";
4
4
  InputSource[InputSource["KEYBOARD"] = INPUT_METHOD.KEYBOARD] = "KEYBOARD";
5
- InputSource[InputSource["PAGE_OVERFLOW_MENU"] = INPUT_METHOD.PAGE_OVERFLOW_MENU] = "PAGE_OVERFLOW_MENU";
5
+ InputSource[InputSource["EXTERNAL"] = INPUT_METHOD.EXTERNAL] = "EXTERNAL";
6
6
  return InputSource;
7
7
  }({});
@@ -0,0 +1,27 @@
1
+ export var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
2
+ return function (command) {
3
+ var _api$typeAhead;
4
+ if (!editorView) {
5
+ return false;
6
+ }
7
+ if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead = _api$typeAhead.actions) !== null && _api$typeAhead !== void 0 && _api$typeAhead.isOpen(editorView.state)) {
8
+ var _api$typeAhead2;
9
+ api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || _api$typeAhead2.close({
10
+ attachCommand: command,
11
+ insertCurrentQueryAsRawText: false
12
+ });
13
+ } else {
14
+ command(editorView.state, editorView.dispatch);
15
+ }
16
+ return true;
17
+ };
18
+ };
19
+ export var forceFocus = function forceFocus(editorView, api) {
20
+ return function (command) {
21
+ var result = closeTypeAheadAndRunCommand(editorView, api)(command);
22
+ if (result && !editorView.hasFocus()) {
23
+ editorView.focus();
24
+ }
25
+ return result;
26
+ };
27
+ };
@@ -14,31 +14,7 @@ import RedoIcon from '@atlaskit/icon/core/migration/redo';
14
14
  import UndoIcon from '@atlaskit/icon/core/migration/undo';
15
15
  import { fg } from '@atlaskit/platform-feature-flags';
16
16
  import { redoFromToolbar, undoFromToolbar } from '../../pm-plugins/commands';
17
- var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
18
- return function (command) {
19
- var _api$typeAhead;
20
- if (!editorView) {
21
- return;
22
- }
23
- if (api !== null && api !== void 0 && (_api$typeAhead = api.typeAhead) !== null && _api$typeAhead !== void 0 && (_api$typeAhead = _api$typeAhead.actions) !== null && _api$typeAhead !== void 0 && _api$typeAhead.isOpen(editorView.state)) {
24
- var _api$typeAhead2;
25
- api === null || api === void 0 || (_api$typeAhead2 = api.typeAhead) === null || _api$typeAhead2 === void 0 || (_api$typeAhead2 = _api$typeAhead2.actions) === null || _api$typeAhead2 === void 0 || _api$typeAhead2.close({
26
- attachCommand: command,
27
- insertCurrentQueryAsRawText: false
28
- });
29
- } else {
30
- command(editorView.state, editorView.dispatch);
31
- }
32
- };
33
- };
34
- var forceFocus = function forceFocus(editorView, api) {
35
- return function (command) {
36
- closeTypeAheadAndRunCommand(editorView, api)(command);
37
- if (!editorView.hasFocus()) {
38
- editorView.focus();
39
- }
40
- };
41
- };
17
+ import { forceFocus } from '../../pm-plugins/utils';
42
18
  export var ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
43
19
  var disabled = _ref.disabled,
44
20
  isReducedSpacing = _ref.isReducedSpacing,
@@ -1,15 +1,17 @@
1
1
  import React from 'react';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- import { redo as _redo, undo as _undo } from '@atlaskit/editor-prosemirror/history';
3
+ import { redo, undo } from '@atlaskit/editor-prosemirror/history';
4
4
  import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
5
  import { attachInputMeta } from './pm-plugins/attach-input-meta';
6
+ import { InputSource } from './pm-plugins/enums';
6
7
  import { keymapPlugin } from './pm-plugins/keymaps';
7
8
  import { createPlugin } from './pm-plugins/main';
8
- // eslint-disable-next-line @atlassian/tangerine/import/entry-points
9
+ import { forceFocus } from './pm-plugins/utils';
9
10
  // Ignored via go/ees005
10
11
  // eslint-disable-next-line import/no-named-as-default
11
12
  import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
12
13
  export var undoRedoPlugin = function undoRedoPlugin(_ref) {
14
+ var _api$primaryToolbar;
13
15
  var api = _ref.api;
14
16
  var editorViewRef = {
15
17
  current: null
@@ -25,42 +27,27 @@ export var undoRedoPlugin = function undoRedoPlugin(_ref) {
25
27
  api: api
26
28
  });
27
29
  };
28
- if (editorExperiment('platform_editor_controls', 'control', {
29
- exposure: true
30
- })) {
31
- var _api$primaryToolbar;
32
- api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
33
- name: 'undoRedoPlugin',
34
- component: primaryToolbarComponent
35
- });
36
- }
30
+ api === null || api === void 0 || (_api$primaryToolbar = api.primaryToolbar) === null || _api$primaryToolbar === void 0 || _api$primaryToolbar.actions.registerComponent({
31
+ name: 'undoRedoPlugin',
32
+ component: primaryToolbarComponent
33
+ });
34
+ var handleUndo = function handleUndo(inputSource) {
35
+ if (!editorViewRef.current) {
36
+ return false;
37
+ }
38
+ return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
39
+ };
40
+ var handleRedo = function handleRedo(inputSource) {
41
+ if (!editorViewRef.current) {
42
+ return false;
43
+ }
44
+ return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
45
+ };
37
46
  return {
38
47
  name: 'undoRedoPlugin',
39
48
  actions: {
40
- undo: function undo(inputSource) {
41
- if (!editorViewRef.current) {
42
- return false;
43
- }
44
- var _editorViewRef$curren = editorViewRef.current,
45
- state = _editorViewRef$curren.state,
46
- dispatch = _editorViewRef$curren.dispatch;
47
- if (!inputSource) {
48
- return _undo(state, dispatch);
49
- }
50
- return attachInputMeta(inputSource)(_undo)(state, dispatch);
51
- },
52
- redo: function redo(inputSource) {
53
- if (!editorViewRef.current) {
54
- return false;
55
- }
56
- var _editorViewRef$curren2 = editorViewRef.current,
57
- state = _editorViewRef$curren2.state,
58
- dispatch = _editorViewRef$curren2.dispatch;
59
- if (!inputSource) {
60
- return _redo(state, dispatch);
61
- }
62
- return attachInputMeta(inputSource)(_redo)(state, dispatch);
63
- }
49
+ undo: handleUndo,
50
+ redo: handleRedo
64
51
  },
65
52
  pmPlugins: function pmPlugins() {
66
53
  var plugins = [{
@@ -95,8 +82,6 @@ export var undoRedoPlugin = function undoRedoPlugin(_ref) {
95
82
  }
96
83
  return plugins;
97
84
  },
98
- primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'control', {
99
- exposure: true
100
- }) ? primaryToolbarComponent : undefined
85
+ primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) ? primaryToolbarComponent : undefined
101
86
  };
102
87
  };
@@ -1,5 +1,5 @@
1
1
  export declare enum InputSource {
2
2
  TOOLBAR = "toolbar",
3
3
  KEYBOARD = "keyboard",
4
- PAGE_OVERFLOW_MENU = "confluencePageOverflowMenu"
4
+ EXTERNAL = "external"
5
5
  }
@@ -0,0 +1,5 @@
1
+ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { UndoRedoPlugin } from '../undoRedoPluginType';
4
+ export declare const closeTypeAheadAndRunCommand: (editorView: EditorView, api: ExtractInjectionAPI<UndoRedoPlugin> | undefined) => (command: Command) => boolean;
5
+ export declare const forceFocus: (editorView: EditorView, api: ExtractInjectionAPI<UndoRedoPlugin> | undefined) => (command: Command) => boolean;
@@ -1,5 +1,5 @@
1
1
  export declare enum InputSource {
2
2
  TOOLBAR = "toolbar",
3
3
  KEYBOARD = "keyboard",
4
- PAGE_OVERFLOW_MENU = "confluencePageOverflowMenu"
4
+ EXTERNAL = "external"
5
5
  }
@@ -0,0 +1,5 @@
1
+ import type { Command, ExtractInjectionAPI } from '@atlaskit/editor-common/types';
2
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
3
+ import { UndoRedoPlugin } from '../undoRedoPluginType';
4
+ export declare const closeTypeAheadAndRunCommand: (editorView: EditorView, api: ExtractInjectionAPI<UndoRedoPlugin> | undefined) => (command: Command) => boolean;
5
+ export declare const forceFocus: (editorView: EditorView, api: ExtractInjectionAPI<UndoRedoPlugin> | undefined) => (command: Command) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-undo-redo",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "Undo redo plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,14 +33,14 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^102.8.0",
36
+ "@atlaskit/editor-common": "^102.13.0",
37
37
  "@atlaskit/editor-plugin-history": "^2.0.0",
38
- "@atlaskit/editor-plugin-primary-toolbar": "^3.0.0",
39
- "@atlaskit/editor-plugin-type-ahead": "^2.1.0",
38
+ "@atlaskit/editor-plugin-primary-toolbar": "^3.1.0",
39
+ "@atlaskit/editor-plugin-type-ahead": "^2.2.0",
40
40
  "@atlaskit/editor-prosemirror": "7.0.0",
41
41
  "@atlaskit/icon": "^25.0.0",
42
42
  "@atlaskit/platform-feature-flags": "^1.1.0",
43
- "@atlaskit/tmp-editor-statsig": "^4.0.0",
43
+ "@atlaskit/tmp-editor-statsig": "^4.2.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@emotion/react": "^11.7.1"
46
46
  },