@atlaskit/editor-plugin-undo-redo 2.0.9 → 2.0.10
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 +9 -0
- package/dist/cjs/pm-plugins/attach-input-meta.js +30 -1
- package/dist/cjs/pm-plugins/commands.js +9 -2
- package/dist/cjs/ui/ToolbarUndoRedo/index.js +12 -2
- package/dist/cjs/undoRedoPlugin.js +6 -2
- package/dist/es2019/pm-plugins/attach-input-meta.js +24 -1
- package/dist/es2019/pm-plugins/commands.js +5 -2
- package/dist/es2019/ui/ToolbarUndoRedo/index.js +13 -3
- package/dist/es2019/undoRedoPlugin.js +7 -3
- package/dist/esm/pm-plugins/attach-input-meta.js +29 -0
- package/dist/esm/pm-plugins/commands.js +9 -2
- package/dist/esm/ui/ToolbarUndoRedo/index.js +13 -3
- package/dist/esm/undoRedoPlugin.js +7 -3
- package/dist/types/pm-plugins/attach-input-meta.d.ts +5 -2
- package/dist/types/pm-plugins/commands.d.ts +3 -0
- package/dist/types/undoRedoPluginType.d.ts +7 -1
- package/dist/types-ts4.5/pm-plugins/attach-input-meta.d.ts +5 -2
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +3 -0
- package/dist/types-ts4.5/undoRedoPluginType.d.ts +3 -1
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-undo-redo
|
|
2
2
|
|
|
3
|
+
## 2.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#149192](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/149192)
|
|
8
|
+
[`7dd3315f8b3a2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7dd3315f8b3a2) -
|
|
9
|
+
Added undo/redo analytics
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
3
12
|
## 2.0.9
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.attachInputMeta = void 0;
|
|
6
|
+
exports.attachInputMetaWithAnalytics = exports.attachInputMeta = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
9
|
+
var _enums = require("./enums");
|
|
7
10
|
var _pluginKey = require("./plugin-key");
|
|
8
11
|
var attachInputMeta = exports.attachInputMeta = function attachInputMeta(inputSource) {
|
|
9
12
|
return function (command) {
|
|
@@ -23,4 +26,30 @@ var attachInputMeta = exports.attachInputMeta = function attachInputMeta(inputSo
|
|
|
23
26
|
return true;
|
|
24
27
|
};
|
|
25
28
|
};
|
|
29
|
+
};
|
|
30
|
+
var inputSourceToInputMethod = function inputSourceToInputMethod(inputSource) {
|
|
31
|
+
switch (inputSource) {
|
|
32
|
+
case _enums.InputSource.EXTERNAL:
|
|
33
|
+
return _analytics.INPUT_METHOD.EXTERNAL;
|
|
34
|
+
case _enums.InputSource.KEYBOARD:
|
|
35
|
+
return _analytics.INPUT_METHOD.KEYBOARD;
|
|
36
|
+
case _enums.InputSource.TOOLBAR:
|
|
37
|
+
return _analytics.INPUT_METHOD.TOOLBAR;
|
|
38
|
+
default:
|
|
39
|
+
return _analytics.INPUT_METHOD.EXTERNAL;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var attachInputMetaWithAnalytics = exports.attachInputMetaWithAnalytics = function attachInputMetaWithAnalytics(editorAnalyticsAPI) {
|
|
43
|
+
return function (inputSource, action) {
|
|
44
|
+
return function (command) {
|
|
45
|
+
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsAPI, {
|
|
46
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
47
|
+
action: action,
|
|
48
|
+
actionSubject: _analytics.ACTION_SUBJECT.EDITOR,
|
|
49
|
+
attributes: {
|
|
50
|
+
inputMethod: inputSourceToInputMethod(inputSource)
|
|
51
|
+
}
|
|
52
|
+
})(attachInputMeta(inputSource)(command));
|
|
53
|
+
};
|
|
54
|
+
};
|
|
26
55
|
};
|
|
@@ -3,11 +3,18 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.undoFromToolbar = exports.undoFromKeyboard = exports.redoFromToolbar = exports.redoFromKeyboard = void 0;
|
|
6
|
+
exports.undoFromToolbarWithAnalytics = exports.undoFromToolbar = exports.undoFromKeyboard = exports.redoFromToolbarWithAnalytics = exports.redoFromToolbar = exports.redoFromKeyboard = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
7
8
|
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
8
9
|
var _attachInputMeta = require("./attach-input-meta");
|
|
9
10
|
var _enums = require("./enums");
|
|
10
11
|
var undoFromKeyboard = exports.undoFromKeyboard = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.KEYBOARD)(_history.undo);
|
|
11
12
|
var redoFromKeyboard = exports.redoFromKeyboard = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.KEYBOARD)(_history.redo);
|
|
12
13
|
var undoFromToolbar = exports.undoFromToolbar = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.TOOLBAR)(_history.undo);
|
|
13
|
-
var redoFromToolbar = exports.redoFromToolbar = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.TOOLBAR)(_history.redo);
|
|
14
|
+
var redoFromToolbar = exports.redoFromToolbar = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.TOOLBAR)(_history.redo);
|
|
15
|
+
var undoFromToolbarWithAnalytics = exports.undoFromToolbarWithAnalytics = function undoFromToolbarWithAnalytics(editorAnalyticsAPI) {
|
|
16
|
+
return (0, _attachInputMeta.attachInputMetaWithAnalytics)(editorAnalyticsAPI)(_enums.InputSource.TOOLBAR, _analytics.ACTION.UNDO_PERFORMED)(_history.undo);
|
|
17
|
+
};
|
|
18
|
+
var redoFromToolbarWithAnalytics = exports.redoFromToolbarWithAnalytics = function redoFromToolbarWithAnalytics(editorAnalyticsAPI) {
|
|
19
|
+
return (0, _attachInputMeta.attachInputMetaWithAnalytics)(editorAnalyticsAPI)(_enums.InputSource.TOOLBAR, _analytics.ACTION.REDO_PERFORMED)(_history.redo);
|
|
20
|
+
};
|
|
@@ -32,10 +32,20 @@ var ToolbarUndoRedo = exports.ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
|
32
32
|
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['history']),
|
|
33
33
|
historyState = _useSharedPluginState.historyState;
|
|
34
34
|
var handleUndo = function handleUndo() {
|
|
35
|
-
(0,
|
|
35
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics')) {
|
|
36
|
+
var _api$analytics;
|
|
37
|
+
(0, _utils.forceFocus)(editorView, api)((0, _commands.undoFromToolbarWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions));
|
|
38
|
+
} else {
|
|
39
|
+
(0, _utils.forceFocus)(editorView, api)(_commands.undoFromToolbar);
|
|
40
|
+
}
|
|
36
41
|
};
|
|
37
42
|
var handleRedo = function handleRedo() {
|
|
38
|
-
(0,
|
|
43
|
+
if ((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics')) {
|
|
44
|
+
var _api$analytics2;
|
|
45
|
+
(0, _utils.forceFocus)(editorView, api)((0, _commands.redoFromToolbarWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions));
|
|
46
|
+
} else {
|
|
47
|
+
(0, _utils.forceFocus)(editorView, api)(_commands.redoFromToolbar);
|
|
48
|
+
}
|
|
39
49
|
};
|
|
40
50
|
var labelUndo = formatMessage(_messages.undoRedoMessages.undo);
|
|
41
51
|
var labelRedo = formatMessage(_messages.undoRedoMessages.redo);
|
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.undoRedoPlugin = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
10
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
10
11
|
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
13
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
12
14
|
var _attachInputMeta = require("./pm-plugins/attach-input-meta");
|
|
13
15
|
var _enums = require("./pm-plugins/enums");
|
|
@@ -40,16 +42,18 @@ var undoRedoPlugin = exports.undoRedoPlugin = function undoRedoPlugin(_ref) {
|
|
|
40
42
|
component: primaryToolbarComponent
|
|
41
43
|
});
|
|
42
44
|
var handleUndo = function handleUndo(inputSource) {
|
|
45
|
+
var _api$analytics;
|
|
43
46
|
if (!editorViewRef.current) {
|
|
44
47
|
return false;
|
|
45
48
|
}
|
|
46
|
-
return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.undo));
|
|
49
|
+
return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? (0, _attachInputMeta.attachInputMetaWithAnalytics)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(inputSource || _enums.InputSource.EXTERNAL, _analytics.ACTION.UNDO_PERFORMED)(_history.undo) : (0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.undo));
|
|
47
50
|
};
|
|
48
51
|
var handleRedo = function handleRedo(inputSource) {
|
|
52
|
+
var _api$analytics2;
|
|
49
53
|
if (!editorViewRef.current) {
|
|
50
54
|
return false;
|
|
51
55
|
}
|
|
52
|
-
return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.redo));
|
|
56
|
+
return (0, _utils.forceFocus)(editorViewRef.current, api)((0, _platformFeatureFlags.fg)('platform_editor_controls_patch_analytics') ? (0, _attachInputMeta.attachInputMetaWithAnalytics)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(inputSource || _enums.InputSource.EXTERNAL, _analytics.ACTION.REDO_PERFORMED)(_history.redo) : (0, _attachInputMeta.attachInputMeta)(inputSource || _enums.InputSource.EXTERNAL)(_history.redo));
|
|
53
57
|
};
|
|
54
58
|
return {
|
|
55
59
|
name: 'undoRedoPlugin',
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
|
+
import { InputSource } from './enums';
|
|
1
4
|
import { pluginKey as undoPluginKey } from './plugin-key';
|
|
2
5
|
export const attachInputMeta = inputSource => command => (state, dispatch) => {
|
|
3
6
|
let customTr = state.tr;
|
|
@@ -13,4 +16,24 @@ export const attachInputMeta = inputSource => command => (state, dispatch) => {
|
|
|
13
16
|
dispatch(customTr);
|
|
14
17
|
}
|
|
15
18
|
return true;
|
|
16
|
-
};
|
|
19
|
+
};
|
|
20
|
+
const inputSourceToInputMethod = inputSource => {
|
|
21
|
+
switch (inputSource) {
|
|
22
|
+
case InputSource.EXTERNAL:
|
|
23
|
+
return INPUT_METHOD.EXTERNAL;
|
|
24
|
+
case InputSource.KEYBOARD:
|
|
25
|
+
return INPUT_METHOD.KEYBOARD;
|
|
26
|
+
case InputSource.TOOLBAR:
|
|
27
|
+
return INPUT_METHOD.TOOLBAR;
|
|
28
|
+
default:
|
|
29
|
+
return INPUT_METHOD.EXTERNAL;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export const attachInputMetaWithAnalytics = editorAnalyticsAPI => (inputSource, action) => command => withAnalytics(editorAnalyticsAPI, {
|
|
33
|
+
eventType: EVENT_TYPE.TRACK,
|
|
34
|
+
action,
|
|
35
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
36
|
+
attributes: {
|
|
37
|
+
inputMethod: inputSourceToInputMethod(inputSource)
|
|
38
|
+
}
|
|
39
|
+
})(attachInputMeta(inputSource)(command));
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
-
import { attachInputMeta } from './attach-input-meta';
|
|
3
|
+
import { attachInputMeta, attachInputMetaWithAnalytics } from './attach-input-meta';
|
|
3
4
|
import { InputSource } from './enums';
|
|
4
5
|
export const undoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(undo);
|
|
5
6
|
export const redoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(redo);
|
|
6
7
|
export const undoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(undo);
|
|
7
|
-
export const redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
8
|
+
export const redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
9
|
+
export const undoFromToolbarWithAnalytics = editorAnalyticsAPI => attachInputMetaWithAnalytics(editorAnalyticsAPI)(InputSource.TOOLBAR, ACTION.UNDO_PERFORMED)(undo);
|
|
10
|
+
export const redoFromToolbarWithAnalytics = editorAnalyticsAPI => attachInputMetaWithAnalytics(editorAnalyticsAPI)(InputSource.TOOLBAR, ACTION.REDO_PERFORMED)(redo);
|
|
@@ -13,7 +13,7 @@ import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
|
13
13
|
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
|
-
import { redoFromToolbar, undoFromToolbar } from '../../pm-plugins/commands';
|
|
16
|
+
import { redoFromToolbar, redoFromToolbarWithAnalytics, undoFromToolbar, undoFromToolbarWithAnalytics } from '../../pm-plugins/commands';
|
|
17
17
|
import { forceFocus } from '../../pm-plugins/utils';
|
|
18
18
|
export const ToolbarUndoRedo = ({
|
|
19
19
|
disabled,
|
|
@@ -28,10 +28,20 @@ export const ToolbarUndoRedo = ({
|
|
|
28
28
|
historyState
|
|
29
29
|
} = useSharedPluginState(api, ['history']);
|
|
30
30
|
const handleUndo = () => {
|
|
31
|
-
|
|
31
|
+
if (fg('platform_editor_controls_patch_analytics')) {
|
|
32
|
+
var _api$analytics;
|
|
33
|
+
forceFocus(editorView, api)(undoFromToolbarWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions));
|
|
34
|
+
} else {
|
|
35
|
+
forceFocus(editorView, api)(undoFromToolbar);
|
|
36
|
+
}
|
|
32
37
|
};
|
|
33
38
|
const handleRedo = () => {
|
|
34
|
-
|
|
39
|
+
if (fg('platform_editor_controls_patch_analytics')) {
|
|
40
|
+
var _api$analytics2;
|
|
41
|
+
forceFocus(editorView, api)(redoFromToolbarWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions));
|
|
42
|
+
} else {
|
|
43
|
+
forceFocus(editorView, api)(redoFromToolbar);
|
|
44
|
+
}
|
|
35
45
|
};
|
|
36
46
|
const labelUndo = formatMessage(undoRedoMessages.undo);
|
|
37
47
|
const labelRedo = formatMessage(undoRedoMessages.redo);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
4
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
-
import { attachInputMeta } from './pm-plugins/attach-input-meta';
|
|
7
|
+
import { attachInputMeta, attachInputMetaWithAnalytics } from './pm-plugins/attach-input-meta';
|
|
6
8
|
import { InputSource } from './pm-plugins/enums';
|
|
7
9
|
import { keymapPlugin } from './pm-plugins/keymaps';
|
|
8
10
|
import { createPlugin } from './pm-plugins/main';
|
|
@@ -34,16 +36,18 @@ export const undoRedoPlugin = ({
|
|
|
34
36
|
component: primaryToolbarComponent
|
|
35
37
|
});
|
|
36
38
|
const handleUndo = inputSource => {
|
|
39
|
+
var _api$analytics;
|
|
37
40
|
if (!editorViewRef.current) {
|
|
38
41
|
return false;
|
|
39
42
|
}
|
|
40
|
-
return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
|
|
43
|
+
return forceFocus(editorViewRef.current, api)(fg('platform_editor_controls_patch_analytics') ? attachInputMetaWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(inputSource || InputSource.EXTERNAL, ACTION.UNDO_PERFORMED)(undo) : attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
|
|
41
44
|
};
|
|
42
45
|
const handleRedo = inputSource => {
|
|
46
|
+
var _api$analytics2;
|
|
43
47
|
if (!editorViewRef.current) {
|
|
44
48
|
return false;
|
|
45
49
|
}
|
|
46
|
-
return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
|
|
50
|
+
return forceFocus(editorViewRef.current, api)(fg('platform_editor_controls_patch_analytics') ? attachInputMetaWithAnalytics(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(inputSource || InputSource.EXTERNAL, ACTION.REDO_PERFORMED)(redo) : attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
|
|
47
51
|
};
|
|
48
52
|
return {
|
|
49
53
|
name: 'undoRedoPlugin',
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ACTION_SUBJECT, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
3
|
+
import { InputSource } from './enums';
|
|
1
4
|
import { pluginKey as undoPluginKey } from './plugin-key';
|
|
2
5
|
export var attachInputMeta = function attachInputMeta(inputSource) {
|
|
3
6
|
return function (command) {
|
|
@@ -17,4 +20,30 @@ export var attachInputMeta = function attachInputMeta(inputSource) {
|
|
|
17
20
|
return true;
|
|
18
21
|
};
|
|
19
22
|
};
|
|
23
|
+
};
|
|
24
|
+
var inputSourceToInputMethod = function inputSourceToInputMethod(inputSource) {
|
|
25
|
+
switch (inputSource) {
|
|
26
|
+
case InputSource.EXTERNAL:
|
|
27
|
+
return INPUT_METHOD.EXTERNAL;
|
|
28
|
+
case InputSource.KEYBOARD:
|
|
29
|
+
return INPUT_METHOD.KEYBOARD;
|
|
30
|
+
case InputSource.TOOLBAR:
|
|
31
|
+
return INPUT_METHOD.TOOLBAR;
|
|
32
|
+
default:
|
|
33
|
+
return INPUT_METHOD.EXTERNAL;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
export var attachInputMetaWithAnalytics = function attachInputMetaWithAnalytics(editorAnalyticsAPI) {
|
|
37
|
+
return function (inputSource, action) {
|
|
38
|
+
return function (command) {
|
|
39
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
40
|
+
eventType: EVENT_TYPE.TRACK,
|
|
41
|
+
action: action,
|
|
42
|
+
actionSubject: ACTION_SUBJECT.EDITOR,
|
|
43
|
+
attributes: {
|
|
44
|
+
inputMethod: inputSourceToInputMethod(inputSource)
|
|
45
|
+
}
|
|
46
|
+
})(attachInputMeta(inputSource)(command));
|
|
47
|
+
};
|
|
48
|
+
};
|
|
20
49
|
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
-
import { attachInputMeta } from './attach-input-meta';
|
|
3
|
+
import { attachInputMeta, attachInputMetaWithAnalytics } from './attach-input-meta';
|
|
3
4
|
import { InputSource } from './enums';
|
|
4
5
|
export var undoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(undo);
|
|
5
6
|
export var redoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(redo);
|
|
6
7
|
export var undoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(undo);
|
|
7
|
-
export var redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
8
|
+
export var redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
9
|
+
export var undoFromToolbarWithAnalytics = function undoFromToolbarWithAnalytics(editorAnalyticsAPI) {
|
|
10
|
+
return attachInputMetaWithAnalytics(editorAnalyticsAPI)(InputSource.TOOLBAR, ACTION.UNDO_PERFORMED)(undo);
|
|
11
|
+
};
|
|
12
|
+
export var redoFromToolbarWithAnalytics = function redoFromToolbarWithAnalytics(editorAnalyticsAPI) {
|
|
13
|
+
return attachInputMetaWithAnalytics(editorAnalyticsAPI)(InputSource.TOOLBAR, ACTION.REDO_PERFORMED)(redo);
|
|
14
|
+
};
|
|
@@ -13,7 +13,7 @@ import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
|
13
13
|
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
|
-
import { redoFromToolbar, undoFromToolbar } from '../../pm-plugins/commands';
|
|
16
|
+
import { redoFromToolbar, redoFromToolbarWithAnalytics, undoFromToolbar, undoFromToolbarWithAnalytics } from '../../pm-plugins/commands';
|
|
17
17
|
import { forceFocus } from '../../pm-plugins/utils';
|
|
18
18
|
export var ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
19
19
|
var disabled = _ref.disabled,
|
|
@@ -24,10 +24,20 @@ export var ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
|
24
24
|
var _useSharedPluginState = useSharedPluginState(api, ['history']),
|
|
25
25
|
historyState = _useSharedPluginState.historyState;
|
|
26
26
|
var handleUndo = function handleUndo() {
|
|
27
|
-
|
|
27
|
+
if (fg('platform_editor_controls_patch_analytics')) {
|
|
28
|
+
var _api$analytics;
|
|
29
|
+
forceFocus(editorView, api)(undoFromToolbarWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions));
|
|
30
|
+
} else {
|
|
31
|
+
forceFocus(editorView, api)(undoFromToolbar);
|
|
32
|
+
}
|
|
28
33
|
};
|
|
29
34
|
var handleRedo = function handleRedo() {
|
|
30
|
-
|
|
35
|
+
if (fg('platform_editor_controls_patch_analytics')) {
|
|
36
|
+
var _api$analytics2;
|
|
37
|
+
forceFocus(editorView, api)(redoFromToolbarWithAnalytics(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions));
|
|
38
|
+
} else {
|
|
39
|
+
forceFocus(editorView, api)(redoFromToolbar);
|
|
40
|
+
}
|
|
31
41
|
};
|
|
32
42
|
var labelUndo = formatMessage(undoRedoMessages.undo);
|
|
33
43
|
var labelRedo = formatMessage(undoRedoMessages.redo);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
4
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
6
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
|
-
import { attachInputMeta } from './pm-plugins/attach-input-meta';
|
|
7
|
+
import { attachInputMeta, attachInputMetaWithAnalytics } from './pm-plugins/attach-input-meta';
|
|
6
8
|
import { InputSource } from './pm-plugins/enums';
|
|
7
9
|
import { keymapPlugin } from './pm-plugins/keymaps';
|
|
8
10
|
import { createPlugin } from './pm-plugins/main';
|
|
@@ -32,16 +34,18 @@ export var undoRedoPlugin = function undoRedoPlugin(_ref) {
|
|
|
32
34
|
component: primaryToolbarComponent
|
|
33
35
|
});
|
|
34
36
|
var handleUndo = function handleUndo(inputSource) {
|
|
37
|
+
var _api$analytics;
|
|
35
38
|
if (!editorViewRef.current) {
|
|
36
39
|
return false;
|
|
37
40
|
}
|
|
38
|
-
return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
|
|
41
|
+
return forceFocus(editorViewRef.current, api)(fg('platform_editor_controls_patch_analytics') ? attachInputMetaWithAnalytics(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions)(inputSource || InputSource.EXTERNAL, ACTION.UNDO_PERFORMED)(undo) : attachInputMeta(inputSource || InputSource.EXTERNAL)(undo));
|
|
39
42
|
};
|
|
40
43
|
var handleRedo = function handleRedo(inputSource) {
|
|
44
|
+
var _api$analytics2;
|
|
41
45
|
if (!editorViewRef.current) {
|
|
42
46
|
return false;
|
|
43
47
|
}
|
|
44
|
-
return forceFocus(editorViewRef.current, api)(attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
|
|
48
|
+
return forceFocus(editorViewRef.current, api)(fg('platform_editor_controls_patch_analytics') ? attachInputMetaWithAnalytics(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions)(inputSource || InputSource.EXTERNAL, ACTION.REDO_PERFORMED)(redo) : attachInputMeta(inputSource || InputSource.EXTERNAL)(redo));
|
|
45
49
|
};
|
|
46
50
|
return {
|
|
47
51
|
name: 'undoRedoPlugin',
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { HigherOrderCommand, Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
import { InputSource } from './enums';
|
|
3
5
|
type AttachInputMeta = (inputSource: InputSource) => HigherOrderCommand;
|
|
4
6
|
export declare const attachInputMeta: AttachInputMeta;
|
|
7
|
+
export declare const attachInputMetaWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputSource: InputSource, action: ACTION.UNDO_PERFORMED | ACTION.REDO_PERFORMED) => (command: Command) => Command;
|
|
5
8
|
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
export declare const undoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
2
3
|
export declare const redoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
3
4
|
export declare const undoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
4
5
|
export declare const redoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
6
|
+
export declare const undoFromToolbarWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
7
|
+
export declare const redoFromToolbarWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
2
3
|
import type { HistoryPlugin } from '@atlaskit/editor-plugin-history';
|
|
3
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
5
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
5
6
|
import { InputSource } from './pm-plugins/enums';
|
|
6
7
|
export type UndoRedoAction = (inputSource?: InputSource) => boolean;
|
|
7
8
|
export type UndoRedoPlugin = NextEditorPlugin<'undoRedoPlugin', {
|
|
8
|
-
dependencies: [
|
|
9
|
+
dependencies: [
|
|
10
|
+
TypeAheadPlugin,
|
|
11
|
+
HistoryPlugin,
|
|
12
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
13
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
14
|
+
];
|
|
9
15
|
actions: {
|
|
10
16
|
undo: UndoRedoAction;
|
|
11
17
|
redo: UndoRedoAction;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { ACTION } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { HigherOrderCommand, Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
import { InputSource } from './enums';
|
|
3
5
|
type AttachInputMeta = (inputSource: InputSource) => HigherOrderCommand;
|
|
4
6
|
export declare const attachInputMeta: AttachInputMeta;
|
|
7
|
+
export declare const attachInputMetaWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (inputSource: InputSource, action: ACTION.UNDO_PERFORMED | ACTION.REDO_PERFORMED) => (command: Command) => Command;
|
|
5
8
|
export {};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
export declare const undoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
2
3
|
export declare const redoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
3
4
|
export declare const undoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
4
5
|
export declare const redoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
6
|
+
export declare const undoFromToolbarWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
7
|
+
export declare const redoFromToolbarWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
2
3
|
import type { HistoryPlugin } from '@atlaskit/editor-plugin-history';
|
|
3
4
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
4
5
|
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
@@ -8,7 +9,8 @@ export type UndoRedoPlugin = NextEditorPlugin<'undoRedoPlugin', {
|
|
|
8
9
|
dependencies: [
|
|
9
10
|
TypeAheadPlugin,
|
|
10
11
|
HistoryPlugin,
|
|
11
|
-
OptionalPlugin<PrimaryToolbarPlugin
|
|
12
|
+
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
13
|
+
OptionalPlugin<AnalyticsPlugin>
|
|
12
14
|
];
|
|
13
15
|
actions: {
|
|
14
16
|
undo: UndoRedoAction;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-undo-redo",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.10",
|
|
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": "^103.
|
|
36
|
+
"@atlaskit/editor-common": "^103.21.0",
|
|
37
37
|
"@atlaskit/editor-plugin-history": "^2.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-primary-toolbar": "^3.
|
|
39
|
-
"@atlaskit/editor-plugin-type-ahead": "^2.
|
|
38
|
+
"@atlaskit/editor-plugin-primary-toolbar": "^3.2.0",
|
|
39
|
+
"@atlaskit/editor-plugin-type-ahead": "^2.5.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
41
|
-
"@atlaskit/icon": "^25.
|
|
41
|
+
"@atlaskit/icon": "^25.6.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
43
|
-
"@atlaskit/tmp-editor-statsig": "^4.
|
|
43
|
+
"@atlaskit/tmp-editor-statsig": "^4.15.0",
|
|
44
44
|
"@babel/runtime": "^7.0.0",
|
|
45
45
|
"@emotion/react": "^11.7.1"
|
|
46
46
|
},
|
|
@@ -95,6 +95,9 @@
|
|
|
95
95
|
"platform-feature-flags": {
|
|
96
96
|
"platform_editor_cmd_y_mac_redo_shortcut": {
|
|
97
97
|
"type": "boolean"
|
|
98
|
+
},
|
|
99
|
+
"platform_editor_controls_patch_analytics": {
|
|
100
|
+
"type": "boolean"
|
|
98
101
|
}
|
|
99
102
|
}
|
|
100
103
|
}
|