@atlaskit/editor-plugin-undo-redo 0.1.0
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 +1 -0
- package/LICENSE.md +13 -0
- package/README.md +9 -0
- package/dist/cjs/attach-input-meta.js +26 -0
- package/dist/cjs/commands.js +13 -0
- package/dist/cjs/enums.js +12 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/plugin.js +43 -0
- package/dist/cjs/pm-plugins/keymaps.js +23 -0
- package/dist/cjs/pm-plugins/main.js +14 -0
- package/dist/cjs/pm-plugins/plugin-key.js +8 -0
- package/dist/cjs/types.js +5 -0
- package/dist/cjs/ui/ToolbarUndoRedo/index.js +103 -0
- package/dist/es2019/attach-input-meta.js +16 -0
- package/dist/es2019/commands.js +7 -0
- package/dist/es2019/enums.js +6 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/plugin.js +32 -0
- package/dist/es2019/pm-plugins/keymaps.js +17 -0
- package/dist/es2019/pm-plugins/main.js +9 -0
- package/dist/es2019/pm-plugins/plugin-key.js +2 -0
- package/dist/es2019/types.js +1 -0
- package/dist/es2019/ui/ToolbarUndoRedo/index.js +96 -0
- package/dist/esm/attach-input-meta.js +20 -0
- package/dist/esm/commands.js +7 -0
- package/dist/esm/enums.js +6 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/plugin.js +36 -0
- package/dist/esm/pm-plugins/keymaps.js +17 -0
- package/dist/esm/pm-plugins/main.js +8 -0
- package/dist/esm/pm-plugins/plugin-key.js +2 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/ui/ToolbarUndoRedo/index.js +95 -0
- package/dist/types/attach-input-meta.d.ts +5 -0
- package/dist/types/commands.d.ts +4 -0
- package/dist/types/enums.d.ts +4 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/plugin.d.ts +2 -0
- package/dist/types/pm-plugins/keymaps.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +2 -0
- package/dist/types/pm-plugins/plugin-key.d.ts +2 -0
- package/dist/types/types.d.ts +6 -0
- package/dist/types/ui/ToolbarUndoRedo/index.d.ts +20 -0
- package/dist/types-ts4.5/attach-input-meta.d.ts +5 -0
- package/dist/types-ts4.5/commands.d.ts +4 -0
- package/dist/types-ts4.5/enums.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +2 -0
- package/dist/types-ts4.5/plugin.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/keymaps.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/plugin-key.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +9 -0
- package/dist/types-ts4.5/ui/ToolbarUndoRedo/index.d.ts +20 -0
- package/package.json +98 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @atlaskit/editor-plugin-undo-redo
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Atlassian Pty Ltd
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# EditorPluginUndoRedo
|
|
2
|
+
|
|
3
|
+
Undo redo plugin for @atlaskit/editor-core
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
`import EditorPluginUndoRedo from '@atlaskit/editor-plugin-undo-redo';`
|
|
8
|
+
|
|
9
|
+
Detailed docs and example usage can be found [here](https://atlaskit.atlassian.com/packages/editor/editor-plugin-undo-redo).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.attachInputMeta = void 0;
|
|
7
|
+
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
8
|
+
var attachInputMeta = exports.attachInputMeta = function attachInputMeta(inputSource) {
|
|
9
|
+
return function (command) {
|
|
10
|
+
return function (state, dispatch) {
|
|
11
|
+
var customTr = state.tr;
|
|
12
|
+
var fakeDispatch = function fakeDispatch(tr) {
|
|
13
|
+
customTr = tr;
|
|
14
|
+
};
|
|
15
|
+
command(state, fakeDispatch);
|
|
16
|
+
if (!customTr || !customTr.docChanged) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
customTr.setMeta(_pluginKey.pluginKey, inputSource);
|
|
20
|
+
if (dispatch) {
|
|
21
|
+
dispatch(customTr);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.undoFromToolbar = exports.undoFromKeyboard = exports.redoFromToolbar = exports.redoFromKeyboard = void 0;
|
|
7
|
+
var _history = require("@atlaskit/editor-prosemirror/history");
|
|
8
|
+
var _attachInputMeta = require("./attach-input-meta");
|
|
9
|
+
var _enums = require("./enums");
|
|
10
|
+
var undoFromKeyboard = exports.undoFromKeyboard = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.KEYBOARD)(_history.undo);
|
|
11
|
+
var redoFromKeyboard = exports.redoFromKeyboard = (0, _attachInputMeta.attachInputMeta)(_enums.InputSource.KEYBOARD)(_history.redo);
|
|
12
|
+
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);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.InputSource = void 0;
|
|
7
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var InputSource = exports.InputSource = function (InputSource) {
|
|
9
|
+
InputSource[InputSource["TOOLBAR"] = _analytics.INPUT_METHOD.TOOLBAR] = "TOOLBAR";
|
|
10
|
+
InputSource[InputSource["KEYBOARD"] = _analytics.INPUT_METHOD.KEYBOARD] = "KEYBOARD";
|
|
11
|
+
return InputSource;
|
|
12
|
+
}({});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "undoRedoPlugin", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _plugin.undoRedoPlugin;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _plugin = require("./plugin");
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.undoRedoPlugin = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _keymaps = require("./pm-plugins/keymaps");
|
|
10
|
+
var _main = require("./pm-plugins/main");
|
|
11
|
+
var _ToolbarUndoRedo = _interopRequireDefault(require("./ui/ToolbarUndoRedo"));
|
|
12
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
13
|
+
|
|
14
|
+
var undoRedoPlugin = exports.undoRedoPlugin = function undoRedoPlugin(_ref) {
|
|
15
|
+
var api = _ref.api;
|
|
16
|
+
return {
|
|
17
|
+
name: 'undoRedoPlugin',
|
|
18
|
+
pmPlugins: function pmPlugins() {
|
|
19
|
+
return [{
|
|
20
|
+
name: 'undoRedoKeyMap',
|
|
21
|
+
plugin: function plugin() {
|
|
22
|
+
return (0, _keymaps.keymapPlugin)();
|
|
23
|
+
}
|
|
24
|
+
}, {
|
|
25
|
+
name: 'undoRedoPlugin',
|
|
26
|
+
plugin: function plugin(options) {
|
|
27
|
+
return (0, _main.createPlugin)(options);
|
|
28
|
+
}
|
|
29
|
+
}];
|
|
30
|
+
},
|
|
31
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
|
|
32
|
+
var editorView = _ref2.editorView,
|
|
33
|
+
disabled = _ref2.disabled,
|
|
34
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_ToolbarUndoRedo.default, {
|
|
36
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
37
|
+
disabled: disabled,
|
|
38
|
+
editorView: editorView,
|
|
39
|
+
api: api
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.keymapPlugin = keymapPlugin;
|
|
7
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
8
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
+
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
10
|
+
var _commands = require("../commands");
|
|
11
|
+
function keymapPlugin() {
|
|
12
|
+
var list = {};
|
|
13
|
+
(0, _keymaps.bindKeymapWithCommand)((0, _keymaps.findKeyMapForBrowser)(_keymaps.redo), _commands.redoFromKeyboard, list);
|
|
14
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.undo.common, _commands.undoFromKeyboard, list);
|
|
15
|
+
return new _safePlugin.SafePlugin({
|
|
16
|
+
props: {
|
|
17
|
+
handleKeyDown: function handleKeyDown(view, event) {
|
|
18
|
+
var keyboardEvent = (0, _keymaps.isCapsLockOnAndModifyKeyboardEvent)(event);
|
|
19
|
+
return (0, _keymap.keydownHandler)(list)(view, keyboardEvent);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createPlugin = void 0;
|
|
7
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
+
var _pluginKey = require("./plugin-key");
|
|
9
|
+
var createPlugin = exports.createPlugin = function createPlugin(_ref) {
|
|
10
|
+
var dispatch = _ref.dispatch;
|
|
11
|
+
return new _safePlugin.SafePlugin({
|
|
12
|
+
key: _pluginKey.pluginKey
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.ToolbarUndoRedo = void 0;
|
|
8
|
+
var _react = require("@emotion/react");
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
|
+
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
|
+
var _styles = require("@atlaskit/editor-common/styles");
|
|
14
|
+
var _uiMenu = require("@atlaskit/editor-common/ui-menu");
|
|
15
|
+
var _redo = _interopRequireDefault(require("@atlaskit/icon/glyph/redo"));
|
|
16
|
+
var _undo = _interopRequireDefault(require("@atlaskit/icon/glyph/undo"));
|
|
17
|
+
var _commands = require("../../commands");
|
|
18
|
+
/** @jsx jsx */
|
|
19
|
+
|
|
20
|
+
var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
|
|
21
|
+
return function (command) {
|
|
22
|
+
var _api$typeAhead;
|
|
23
|
+
if (!editorView) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
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)) {
|
|
27
|
+
var _api$typeAhead2;
|
|
28
|
+
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({
|
|
29
|
+
attachCommand: command,
|
|
30
|
+
insertCurrentQueryAsRawText: false
|
|
31
|
+
});
|
|
32
|
+
} else {
|
|
33
|
+
command(editorView.state, editorView.dispatch);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
var forceFocus = function forceFocus(editorView, api) {
|
|
38
|
+
return function (command) {
|
|
39
|
+
closeTypeAheadAndRunCommand(editorView, api)(command);
|
|
40
|
+
if (!editorView.hasFocus()) {
|
|
41
|
+
editorView.focus();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
var ToolbarUndoRedo = exports.ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
46
|
+
var disabled = _ref.disabled,
|
|
47
|
+
isReducedSpacing = _ref.isReducedSpacing,
|
|
48
|
+
editorView = _ref.editorView,
|
|
49
|
+
api = _ref.api,
|
|
50
|
+
formatMessage = _ref.intl.formatMessage;
|
|
51
|
+
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['history']),
|
|
52
|
+
historyState = _useSharedPluginState.historyState;
|
|
53
|
+
var handleUndo = function handleUndo() {
|
|
54
|
+
forceFocus(editorView, api)(_commands.undoFromToolbar);
|
|
55
|
+
};
|
|
56
|
+
var handleRedo = function handleRedo() {
|
|
57
|
+
forceFocus(editorView, api)(_commands.redoFromToolbar);
|
|
58
|
+
};
|
|
59
|
+
var labelUndo = formatMessage(_messages.undoRedoMessages.undo);
|
|
60
|
+
var labelRedo = formatMessage(_messages.undoRedoMessages.redo);
|
|
61
|
+
var _ref2 = historyState !== null && historyState !== void 0 ? historyState : {},
|
|
62
|
+
canUndo = _ref2.canUndo,
|
|
63
|
+
canRedo = _ref2.canRedo;
|
|
64
|
+
return (
|
|
65
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
66
|
+
(0, _react.jsx)("span", {
|
|
67
|
+
css: _styles.buttonGroupStyle
|
|
68
|
+
}, (0, _react.jsx)(_uiMenu.ToolbarButton, {
|
|
69
|
+
buttonId: _uiMenu.TOOLBAR_BUTTON.UNDO,
|
|
70
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
71
|
+
onClick: handleUndo,
|
|
72
|
+
disabled: !canUndo || disabled,
|
|
73
|
+
"aria-label": (0, _keymaps.tooltip)(_keymaps.undo, labelUndo),
|
|
74
|
+
"aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(_keymaps.undo),
|
|
75
|
+
title: (0, _react.jsx)(_keymaps.ToolTipContent, {
|
|
76
|
+
description: labelUndo,
|
|
77
|
+
keymap: _keymaps.undo
|
|
78
|
+
}),
|
|
79
|
+
iconBefore: (0, _react.jsx)(_undo.default, {
|
|
80
|
+
label: ""
|
|
81
|
+
}),
|
|
82
|
+
testId: "ak-editor-toolbar-button-undo"
|
|
83
|
+
}), (0, _react.jsx)(_uiMenu.ToolbarButton, {
|
|
84
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
85
|
+
buttonId: _uiMenu.TOOLBAR_BUTTON.REDO,
|
|
86
|
+
onClick: handleRedo,
|
|
87
|
+
disabled: !canRedo || disabled,
|
|
88
|
+
title: (0, _react.jsx)(_keymaps.ToolTipContent, {
|
|
89
|
+
description: labelRedo,
|
|
90
|
+
keymap: _keymaps.redo
|
|
91
|
+
}),
|
|
92
|
+
iconBefore: (0, _react.jsx)(_redo.default, {
|
|
93
|
+
label: ""
|
|
94
|
+
}),
|
|
95
|
+
testId: "ak-editor-toolbar-button-redo",
|
|
96
|
+
"aria-label": (0, _keymaps.tooltip)(_keymaps.redo, labelRedo),
|
|
97
|
+
"aria-keyshortcuts": (0, _keymaps.getAriaKeyshortcuts)(_keymaps.redo)
|
|
98
|
+
}), (0, _react.jsx)("span", {
|
|
99
|
+
css: _styles.separatorStyles
|
|
100
|
+
}))
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
var _default = exports.default = (0, _reactIntlNext.injectIntl)(ToolbarUndoRedo);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { pluginKey as undoPluginKey } from './pm-plugins/plugin-key';
|
|
2
|
+
export const attachInputMeta = inputSource => command => (state, dispatch) => {
|
|
3
|
+
let customTr = state.tr;
|
|
4
|
+
const fakeDispatch = tr => {
|
|
5
|
+
customTr = tr;
|
|
6
|
+
};
|
|
7
|
+
command(state, fakeDispatch);
|
|
8
|
+
if (!customTr || !customTr.docChanged) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
customTr.setMeta(undoPluginKey, inputSource);
|
|
12
|
+
if (dispatch) {
|
|
13
|
+
dispatch(customTr);
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
+
import { attachInputMeta } from './attach-input-meta';
|
|
3
|
+
import { InputSource } from './enums';
|
|
4
|
+
export const undoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(undo);
|
|
5
|
+
export const redoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(redo);
|
|
6
|
+
export const undoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(undo);
|
|
7
|
+
export const redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
export let InputSource = function (InputSource) {
|
|
3
|
+
InputSource[InputSource["TOOLBAR"] = INPUT_METHOD.TOOLBAR] = "TOOLBAR";
|
|
4
|
+
InputSource[InputSource["KEYBOARD"] = INPUT_METHOD.KEYBOARD] = "KEYBOARD";
|
|
5
|
+
return InputSource;
|
|
6
|
+
}({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { undoRedoPlugin } from './plugin';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { keymapPlugin } from './pm-plugins/keymaps';
|
|
3
|
+
import { createPlugin } from './pm-plugins/main';
|
|
4
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
+
|
|
6
|
+
import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
|
|
7
|
+
export const undoRedoPlugin = ({
|
|
8
|
+
api
|
|
9
|
+
}) => ({
|
|
10
|
+
name: 'undoRedoPlugin',
|
|
11
|
+
pmPlugins() {
|
|
12
|
+
return [{
|
|
13
|
+
name: 'undoRedoKeyMap',
|
|
14
|
+
plugin: () => keymapPlugin()
|
|
15
|
+
}, {
|
|
16
|
+
name: 'undoRedoPlugin',
|
|
17
|
+
plugin: options => createPlugin(options)
|
|
18
|
+
}];
|
|
19
|
+
},
|
|
20
|
+
primaryToolbarComponent({
|
|
21
|
+
editorView,
|
|
22
|
+
disabled,
|
|
23
|
+
isToolbarReducedSpacing
|
|
24
|
+
}) {
|
|
25
|
+
return /*#__PURE__*/React.createElement(ToolbarUndoRedo, {
|
|
26
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
27
|
+
disabled: disabled,
|
|
28
|
+
editorView: editorView,
|
|
29
|
+
api: api
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bindKeymapWithCommand, findKeyMapForBrowser, isCapsLockOnAndModifyKeyboardEvent, redo, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
+
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
5
|
+
export function keymapPlugin() {
|
|
6
|
+
const list = {};
|
|
7
|
+
bindKeymapWithCommand(findKeyMapForBrowser(redo), redoFromKeyboard, list);
|
|
8
|
+
bindKeymapWithCommand(undo.common, undoFromKeyboard, list);
|
|
9
|
+
return new SafePlugin({
|
|
10
|
+
props: {
|
|
11
|
+
handleKeyDown(view, event) {
|
|
12
|
+
let keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
|
|
13
|
+
return keydownHandler(list)(view, keyboardEvent);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { getAriaKeyshortcuts, redo as redoKeymap, tooltip, ToolTipContent, undo as undoKeymap } from '@atlaskit/editor-common/keymaps';
|
|
6
|
+
import { undoRedoMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { buttonGroupStyle, separatorStyles } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
9
|
+
import RedoIcon from '@atlaskit/icon/glyph/redo';
|
|
10
|
+
import UndoIcon from '@atlaskit/icon/glyph/undo';
|
|
11
|
+
import { redoFromToolbar, undoFromToolbar } from '../../commands';
|
|
12
|
+
const closeTypeAheadAndRunCommand = (editorView, api) => command => {
|
|
13
|
+
var _api$typeAhead, _api$typeAhead$action;
|
|
14
|
+
if (!editorView) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
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)) {
|
|
18
|
+
var _api$typeAhead2, _api$typeAhead2$actio;
|
|
19
|
+
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({
|
|
20
|
+
attachCommand: command,
|
|
21
|
+
insertCurrentQueryAsRawText: false
|
|
22
|
+
});
|
|
23
|
+
} else {
|
|
24
|
+
command(editorView.state, editorView.dispatch);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const forceFocus = (editorView, api) => command => {
|
|
28
|
+
closeTypeAheadAndRunCommand(editorView, api)(command);
|
|
29
|
+
if (!editorView.hasFocus()) {
|
|
30
|
+
editorView.focus();
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const ToolbarUndoRedo = ({
|
|
34
|
+
disabled,
|
|
35
|
+
isReducedSpacing,
|
|
36
|
+
editorView,
|
|
37
|
+
api,
|
|
38
|
+
intl: {
|
|
39
|
+
formatMessage
|
|
40
|
+
}
|
|
41
|
+
}) => {
|
|
42
|
+
const {
|
|
43
|
+
historyState
|
|
44
|
+
} = useSharedPluginState(api, ['history']);
|
|
45
|
+
const handleUndo = () => {
|
|
46
|
+
forceFocus(editorView, api)(undoFromToolbar);
|
|
47
|
+
};
|
|
48
|
+
const handleRedo = () => {
|
|
49
|
+
forceFocus(editorView, api)(redoFromToolbar);
|
|
50
|
+
};
|
|
51
|
+
const labelUndo = formatMessage(undoRedoMessages.undo);
|
|
52
|
+
const labelRedo = formatMessage(undoRedoMessages.redo);
|
|
53
|
+
const {
|
|
54
|
+
canUndo,
|
|
55
|
+
canRedo
|
|
56
|
+
} = historyState !== null && historyState !== void 0 ? historyState : {};
|
|
57
|
+
return (
|
|
58
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
59
|
+
jsx("span", {
|
|
60
|
+
css: buttonGroupStyle
|
|
61
|
+
}, jsx(ToolbarButton, {
|
|
62
|
+
buttonId: TOOLBAR_BUTTON.UNDO,
|
|
63
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
64
|
+
onClick: handleUndo,
|
|
65
|
+
disabled: !canUndo || disabled,
|
|
66
|
+
"aria-label": tooltip(undoKeymap, labelUndo),
|
|
67
|
+
"aria-keyshortcuts": getAriaKeyshortcuts(undoKeymap),
|
|
68
|
+
title: jsx(ToolTipContent, {
|
|
69
|
+
description: labelUndo,
|
|
70
|
+
keymap: undoKeymap
|
|
71
|
+
}),
|
|
72
|
+
iconBefore: jsx(UndoIcon, {
|
|
73
|
+
label: ""
|
|
74
|
+
}),
|
|
75
|
+
testId: "ak-editor-toolbar-button-undo"
|
|
76
|
+
}), jsx(ToolbarButton, {
|
|
77
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
78
|
+
buttonId: TOOLBAR_BUTTON.REDO,
|
|
79
|
+
onClick: handleRedo,
|
|
80
|
+
disabled: !canRedo || disabled,
|
|
81
|
+
title: jsx(ToolTipContent, {
|
|
82
|
+
description: labelRedo,
|
|
83
|
+
keymap: redoKeymap
|
|
84
|
+
}),
|
|
85
|
+
iconBefore: jsx(RedoIcon, {
|
|
86
|
+
label: ""
|
|
87
|
+
}),
|
|
88
|
+
testId: "ak-editor-toolbar-button-redo",
|
|
89
|
+
"aria-label": tooltip(redoKeymap, labelRedo),
|
|
90
|
+
"aria-keyshortcuts": getAriaKeyshortcuts(redoKeymap)
|
|
91
|
+
}), jsx("span", {
|
|
92
|
+
css: separatorStyles
|
|
93
|
+
}))
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
export default injectIntl(ToolbarUndoRedo);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { pluginKey as undoPluginKey } from './pm-plugins/plugin-key';
|
|
2
|
+
export var attachInputMeta = function attachInputMeta(inputSource) {
|
|
3
|
+
return function (command) {
|
|
4
|
+
return function (state, dispatch) {
|
|
5
|
+
var customTr = state.tr;
|
|
6
|
+
var fakeDispatch = function fakeDispatch(tr) {
|
|
7
|
+
customTr = tr;
|
|
8
|
+
};
|
|
9
|
+
command(state, fakeDispatch);
|
|
10
|
+
if (!customTr || !customTr.docChanged) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
customTr.setMeta(undoPluginKey, inputSource);
|
|
14
|
+
if (dispatch) {
|
|
15
|
+
dispatch(customTr);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
|
+
import { attachInputMeta } from './attach-input-meta';
|
|
3
|
+
import { InputSource } from './enums';
|
|
4
|
+
export var undoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(undo);
|
|
5
|
+
export var redoFromKeyboard = attachInputMeta(InputSource.KEYBOARD)(redo);
|
|
6
|
+
export var undoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(undo);
|
|
7
|
+
export var redoFromToolbar = attachInputMeta(InputSource.TOOLBAR)(redo);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
export var InputSource = function (InputSource) {
|
|
3
|
+
InputSource[InputSource["TOOLBAR"] = INPUT_METHOD.TOOLBAR] = "TOOLBAR";
|
|
4
|
+
InputSource[InputSource["KEYBOARD"] = INPUT_METHOD.KEYBOARD] = "KEYBOARD";
|
|
5
|
+
return InputSource;
|
|
6
|
+
}({});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { undoRedoPlugin } from './plugin';
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { keymapPlugin } from './pm-plugins/keymaps';
|
|
3
|
+
import { createPlugin } from './pm-plugins/main';
|
|
4
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
+
|
|
6
|
+
import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
|
|
7
|
+
export var undoRedoPlugin = function undoRedoPlugin(_ref) {
|
|
8
|
+
var api = _ref.api;
|
|
9
|
+
return {
|
|
10
|
+
name: 'undoRedoPlugin',
|
|
11
|
+
pmPlugins: function pmPlugins() {
|
|
12
|
+
return [{
|
|
13
|
+
name: 'undoRedoKeyMap',
|
|
14
|
+
plugin: function plugin() {
|
|
15
|
+
return keymapPlugin();
|
|
16
|
+
}
|
|
17
|
+
}, {
|
|
18
|
+
name: 'undoRedoPlugin',
|
|
19
|
+
plugin: function plugin(options) {
|
|
20
|
+
return createPlugin(options);
|
|
21
|
+
}
|
|
22
|
+
}];
|
|
23
|
+
},
|
|
24
|
+
primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
|
|
25
|
+
var editorView = _ref2.editorView,
|
|
26
|
+
disabled = _ref2.disabled,
|
|
27
|
+
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
|
|
28
|
+
return /*#__PURE__*/React.createElement(ToolbarUndoRedo, {
|
|
29
|
+
isReducedSpacing: isToolbarReducedSpacing,
|
|
30
|
+
disabled: disabled,
|
|
31
|
+
editorView: editorView,
|
|
32
|
+
api: api
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bindKeymapWithCommand, findKeyMapForBrowser, isCapsLockOnAndModifyKeyboardEvent, redo, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
|
+
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
5
|
+
export function keymapPlugin() {
|
|
6
|
+
var list = {};
|
|
7
|
+
bindKeymapWithCommand(findKeyMapForBrowser(redo), redoFromKeyboard, list);
|
|
8
|
+
bindKeymapWithCommand(undo.common, undoFromKeyboard, list);
|
|
9
|
+
return new SafePlugin({
|
|
10
|
+
props: {
|
|
11
|
+
handleKeyDown: function handleKeyDown(view, event) {
|
|
12
|
+
var keyboardEvent = isCapsLockOnAndModifyKeyboardEvent(event);
|
|
13
|
+
return keydownHandler(list)(view, keyboardEvent);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
3
|
+
import { injectIntl } from 'react-intl-next';
|
|
4
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
5
|
+
import { getAriaKeyshortcuts, redo as redoKeymap, tooltip, ToolTipContent, undo as undoKeymap } from '@atlaskit/editor-common/keymaps';
|
|
6
|
+
import { undoRedoMessages } from '@atlaskit/editor-common/messages';
|
|
7
|
+
import { buttonGroupStyle, separatorStyles } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { TOOLBAR_BUTTON, ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
9
|
+
import RedoIcon from '@atlaskit/icon/glyph/redo';
|
|
10
|
+
import UndoIcon from '@atlaskit/icon/glyph/undo';
|
|
11
|
+
import { redoFromToolbar, undoFromToolbar } from '../../commands';
|
|
12
|
+
var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
|
|
13
|
+
return function (command) {
|
|
14
|
+
var _api$typeAhead;
|
|
15
|
+
if (!editorView) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
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)) {
|
|
19
|
+
var _api$typeAhead2;
|
|
20
|
+
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({
|
|
21
|
+
attachCommand: command,
|
|
22
|
+
insertCurrentQueryAsRawText: false
|
|
23
|
+
});
|
|
24
|
+
} else {
|
|
25
|
+
command(editorView.state, editorView.dispatch);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var forceFocus = function forceFocus(editorView, api) {
|
|
30
|
+
return function (command) {
|
|
31
|
+
closeTypeAheadAndRunCommand(editorView, api)(command);
|
|
32
|
+
if (!editorView.hasFocus()) {
|
|
33
|
+
editorView.focus();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export var ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
38
|
+
var disabled = _ref.disabled,
|
|
39
|
+
isReducedSpacing = _ref.isReducedSpacing,
|
|
40
|
+
editorView = _ref.editorView,
|
|
41
|
+
api = _ref.api,
|
|
42
|
+
formatMessage = _ref.intl.formatMessage;
|
|
43
|
+
var _useSharedPluginState = useSharedPluginState(api, ['history']),
|
|
44
|
+
historyState = _useSharedPluginState.historyState;
|
|
45
|
+
var handleUndo = function handleUndo() {
|
|
46
|
+
forceFocus(editorView, api)(undoFromToolbar);
|
|
47
|
+
};
|
|
48
|
+
var handleRedo = function handleRedo() {
|
|
49
|
+
forceFocus(editorView, api)(redoFromToolbar);
|
|
50
|
+
};
|
|
51
|
+
var labelUndo = formatMessage(undoRedoMessages.undo);
|
|
52
|
+
var labelRedo = formatMessage(undoRedoMessages.redo);
|
|
53
|
+
var _ref2 = historyState !== null && historyState !== void 0 ? historyState : {},
|
|
54
|
+
canUndo = _ref2.canUndo,
|
|
55
|
+
canRedo = _ref2.canRedo;
|
|
56
|
+
return (
|
|
57
|
+
// eslint-disable-next-line @atlaskit/design-system/consistent-css-prop-usage
|
|
58
|
+
jsx("span", {
|
|
59
|
+
css: buttonGroupStyle
|
|
60
|
+
}, jsx(ToolbarButton, {
|
|
61
|
+
buttonId: TOOLBAR_BUTTON.UNDO,
|
|
62
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
63
|
+
onClick: handleUndo,
|
|
64
|
+
disabled: !canUndo || disabled,
|
|
65
|
+
"aria-label": tooltip(undoKeymap, labelUndo),
|
|
66
|
+
"aria-keyshortcuts": getAriaKeyshortcuts(undoKeymap),
|
|
67
|
+
title: jsx(ToolTipContent, {
|
|
68
|
+
description: labelUndo,
|
|
69
|
+
keymap: undoKeymap
|
|
70
|
+
}),
|
|
71
|
+
iconBefore: jsx(UndoIcon, {
|
|
72
|
+
label: ""
|
|
73
|
+
}),
|
|
74
|
+
testId: "ak-editor-toolbar-button-undo"
|
|
75
|
+
}), jsx(ToolbarButton, {
|
|
76
|
+
spacing: isReducedSpacing ? 'none' : 'default',
|
|
77
|
+
buttonId: TOOLBAR_BUTTON.REDO,
|
|
78
|
+
onClick: handleRedo,
|
|
79
|
+
disabled: !canRedo || disabled,
|
|
80
|
+
title: jsx(ToolTipContent, {
|
|
81
|
+
description: labelRedo,
|
|
82
|
+
keymap: redoKeymap
|
|
83
|
+
}),
|
|
84
|
+
iconBefore: jsx(RedoIcon, {
|
|
85
|
+
label: ""
|
|
86
|
+
}),
|
|
87
|
+
testId: "ak-editor-toolbar-button-redo",
|
|
88
|
+
"aria-label": tooltip(redoKeymap, labelRedo),
|
|
89
|
+
"aria-keyshortcuts": getAriaKeyshortcuts(redoKeymap)
|
|
90
|
+
}), jsx("span", {
|
|
91
|
+
css: separatorStyles
|
|
92
|
+
}))
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
export default injectIntl(ToolbarUndoRedo);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const undoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
2
|
+
export declare const redoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
3
|
+
export declare const undoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const redoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { HistoryPlugin } from '@atlaskit/editor-plugin-history';
|
|
3
|
+
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
4
|
+
export type UndoRedoPlugin = NextEditorPlugin<'undoRedoPlugin', {
|
|
5
|
+
dependencies: [TypeAheadPlugin, HistoryPlugin];
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { UndoRedoPlugin } from '../../types';
|
|
8
|
+
export interface Props {
|
|
9
|
+
undoDisabled?: boolean;
|
|
10
|
+
redoDisabled?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
isReducedSpacing?: boolean;
|
|
13
|
+
editorView: EditorView;
|
|
14
|
+
api: ExtractInjectionAPI<UndoRedoPlugin> | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare const ToolbarUndoRedo: ({ disabled, isReducedSpacing, editorView, api, intl: { formatMessage }, }: Props & WrappedComponentProps) => jsx.JSX.Element;
|
|
17
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
18
|
+
WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const undoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
2
|
+
export declare const redoFromKeyboard: import("@atlaskit/editor-common/types").Command;
|
|
3
|
+
export declare const undoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const redoFromToolbar: import("@atlaskit/editor-common/types").Command;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { HistoryPlugin } from '@atlaskit/editor-plugin-history';
|
|
3
|
+
import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
|
|
4
|
+
export type UndoRedoPlugin = NextEditorPlugin<'undoRedoPlugin', {
|
|
5
|
+
dependencies: [
|
|
6
|
+
TypeAheadPlugin,
|
|
7
|
+
HistoryPlugin
|
|
8
|
+
];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/** @jsx jsx */
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import type { WrappedComponentProps } from 'react-intl-next';
|
|
5
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import type { UndoRedoPlugin } from '../../types';
|
|
8
|
+
export interface Props {
|
|
9
|
+
undoDisabled?: boolean;
|
|
10
|
+
redoDisabled?: boolean;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
isReducedSpacing?: boolean;
|
|
13
|
+
editorView: EditorView;
|
|
14
|
+
api: ExtractInjectionAPI<UndoRedoPlugin> | undefined;
|
|
15
|
+
}
|
|
16
|
+
export declare const ToolbarUndoRedo: ({ disabled, isReducedSpacing, editorView, api, intl: { formatMessage }, }: Props & WrappedComponentProps) => jsx.JSX.Element;
|
|
17
|
+
declare const _default: import("react").FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
|
|
18
|
+
WrappedComponent: import("react").ComponentType<Props & WrappedComponentProps<"intl">>;
|
|
19
|
+
};
|
|
20
|
+
export default _default;
|
package/package.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlaskit/editor-plugin-undo-redo",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Undo redo plugin for @atlaskit/editor-core",
|
|
5
|
+
"author": "Atlassian Pty Ltd",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
},
|
|
10
|
+
"atlassian": {
|
|
11
|
+
"team": "Editor: Lego",
|
|
12
|
+
"singleton": true,
|
|
13
|
+
"releaseModel": "continuous"
|
|
14
|
+
},
|
|
15
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
16
|
+
"main": "dist/cjs/index.js",
|
|
17
|
+
"module": "dist/esm/index.js",
|
|
18
|
+
"module:es2019": "dist/es2019/index.js",
|
|
19
|
+
"types": "dist/types/index.d.ts",
|
|
20
|
+
"typesVersions": {
|
|
21
|
+
">=4.5 <4.9": {
|
|
22
|
+
"*": [
|
|
23
|
+
"dist/types-ts4.5/*",
|
|
24
|
+
"dist/types-ts4.5/index.d.ts"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"sideEffects": false,
|
|
29
|
+
"atlaskit:src": "src/index.ts",
|
|
30
|
+
"af:exports": {
|
|
31
|
+
".": "./src/index.ts"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@atlaskit/editor-common": "^76.27.0",
|
|
35
|
+
"@atlaskit/editor-plugin-history": "^0.1.0",
|
|
36
|
+
"@atlaskit/editor-plugin-type-ahead": "^0.8.0",
|
|
37
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
38
|
+
"@atlaskit/icon": "^22.0.0",
|
|
39
|
+
"@babel/runtime": "^7.0.0",
|
|
40
|
+
"@emotion/react": "^11.7.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react": "^16.8.0",
|
|
44
|
+
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@af/integration-testing": "*",
|
|
48
|
+
"@af/visual-regression": "*",
|
|
49
|
+
"@atlaskit/analytics-listeners": "^8.7.0",
|
|
50
|
+
"@atlaskit/analytics-next": "^9.1.0",
|
|
51
|
+
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
52
|
+
"@atlaskit/editor-plugin-list": "^3.0.0",
|
|
53
|
+
"@atlaskit/ssr": "*",
|
|
54
|
+
"@atlaskit/visual-regression": "*",
|
|
55
|
+
"@atlaskit/webdriver-runner": "*",
|
|
56
|
+
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
57
|
+
"@testing-library/react": "^12.1.5",
|
|
58
|
+
"react-dom": "^16.8.0",
|
|
59
|
+
"typescript": "~4.9.5",
|
|
60
|
+
"wait-for-expect": "^1.2.0"
|
|
61
|
+
},
|
|
62
|
+
"techstack": {
|
|
63
|
+
"@atlassian/frontend": {
|
|
64
|
+
"import-structure": [
|
|
65
|
+
"atlassian-conventions"
|
|
66
|
+
],
|
|
67
|
+
"circular-dependencies": [
|
|
68
|
+
"file-and-folder-level"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"@repo/internal": {
|
|
72
|
+
"dom-events": "use-bind-event-listener",
|
|
73
|
+
"analytics": [
|
|
74
|
+
"analytics-next"
|
|
75
|
+
],
|
|
76
|
+
"design-tokens": [
|
|
77
|
+
"color"
|
|
78
|
+
],
|
|
79
|
+
"theming": [
|
|
80
|
+
"react-context"
|
|
81
|
+
],
|
|
82
|
+
"ui-components": [
|
|
83
|
+
"lite-mode"
|
|
84
|
+
],
|
|
85
|
+
"deprecation": [
|
|
86
|
+
"no-deprecated-imports"
|
|
87
|
+
],
|
|
88
|
+
"styling": [
|
|
89
|
+
"static",
|
|
90
|
+
"emotion"
|
|
91
|
+
],
|
|
92
|
+
"imports": [
|
|
93
|
+
"import-no-extraneous-disable-for-examples-and-docs"
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
98
|
+
}
|