@atlaskit/editor-core 190.1.14 → 190.1.15
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 +8 -0
- package/afm-cc/tsconfig.json +3 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/presets/default.js +2 -2
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/presets/default.js +1 -1
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/presets/default.js +1 -1
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
- package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +3 -2
- package/tsconfig.json +1 -1
- package/dist/cjs/plugins/undo-redo/attach-input-meta.js +0 -26
- package/dist/cjs/plugins/undo-redo/commands.js +0 -13
- package/dist/cjs/plugins/undo-redo/enums.js +0 -12
- package/dist/cjs/plugins/undo-redo/index.js +0 -44
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +0 -23
- package/dist/cjs/plugins/undo-redo/pm-plugins/main.js +0 -14
- package/dist/cjs/plugins/undo-redo/pm-plugins/plugin-key.js +0 -8
- package/dist/cjs/plugins/undo-redo/types.js +0 -5
- package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -104
- package/dist/es2019/plugins/undo-redo/attach-input-meta.js +0 -16
- package/dist/es2019/plugins/undo-redo/commands.js +0 -7
- package/dist/es2019/plugins/undo-redo/enums.js +0 -6
- package/dist/es2019/plugins/undo-redo/index.js +0 -32
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +0 -17
- package/dist/es2019/plugins/undo-redo/pm-plugins/main.js +0 -9
- package/dist/es2019/plugins/undo-redo/pm-plugins/plugin-key.js +0 -2
- package/dist/es2019/plugins/undo-redo/types.js +0 -1
- package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -94
- package/dist/esm/plugins/undo-redo/attach-input-meta.js +0 -20
- package/dist/esm/plugins/undo-redo/commands.js +0 -7
- package/dist/esm/plugins/undo-redo/enums.js +0 -6
- package/dist/esm/plugins/undo-redo/index.js +0 -36
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +0 -17
- package/dist/esm/plugins/undo-redo/pm-plugins/main.js +0 -8
- package/dist/esm/plugins/undo-redo/pm-plugins/plugin-key.js +0 -2
- package/dist/esm/plugins/undo-redo/types.js +0 -1
- package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -93
- package/dist/types/plugins/undo-redo/attach-input-meta.d.ts +0 -5
- package/dist/types/plugins/undo-redo/commands.d.ts +0 -4
- package/dist/types/plugins/undo-redo/enums.d.ts +0 -4
- package/dist/types/plugins/undo-redo/index.d.ts +0 -3
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +0 -2
- package/dist/types/plugins/undo-redo/pm-plugins/main.d.ts +0 -2
- package/dist/types/plugins/undo-redo/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types/plugins/undo-redo/types.d.ts +0 -6
- package/dist/types/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +0 -20
- package/dist/types-ts4.5/plugins/undo-redo/attach-input-meta.d.ts +0 -5
- package/dist/types-ts4.5/plugins/undo-redo/commands.d.ts +0 -4
- package/dist/types-ts4.5/plugins/undo-redo/enums.d.ts +0 -4
- package/dist/types-ts4.5/plugins/undo-redo/index.d.ts +0 -3
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +0 -2
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/main.d.ts +0 -2
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/plugin-key.d.ts +0 -2
- package/dist/types-ts4.5/plugins/undo-redo/types.d.ts +0 -9
- package/dist/types-ts4.5/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +0 -20
package/tsconfig.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"./example-helpers/**/*.ts",
|
|
11
11
|
"./example-helpers/**/*.tsx",
|
|
12
12
|
"./playwright/**/*.ts"
|
|
13
|
-
, "../editor-plugin-data-consumer/src/index.tsx" ],
|
|
13
|
+
, "../editor-plugin-data-consumer/src/index.tsx", "../editor-plugin-undo-redo/src/types.ts", "../editor-plugin-undo-redo/src/attach-input-meta.ts", "../editor-plugin-undo-redo/src/commands.ts", "../editor-plugin-undo-redo/src/enums.ts", "../editor-plugin-undo-redo/src/index.tsx" ],
|
|
14
14
|
"compilerOptions": {
|
|
15
15
|
"baseUrl": "./"
|
|
16
16
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
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);
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}({});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = 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 = 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
|
-
};
|
|
44
|
-
var _default = exports.default = undoRedoPlugin;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.keymapPlugin = keymapPlugin;
|
|
7
|
-
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
|
-
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
|
-
var _commands = require("../commands");
|
|
10
|
-
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = exports.ToolbarUndoRedo = void 0;
|
|
9
|
-
var _react = require("@emotion/react");
|
|
10
|
-
var _reactIntlNext = require("react-intl-next");
|
|
11
|
-
var _undo = _interopRequireDefault(require("@atlaskit/icon/glyph/undo"));
|
|
12
|
-
var _redo = _interopRequireDefault(require("@atlaskit/icon/glyph/redo"));
|
|
13
|
-
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
14
|
-
var _keymaps = require("../../../../keymaps");
|
|
15
|
-
var _styles = require("@atlaskit/editor-common/styles");
|
|
16
|
-
var _ToolbarButton = _interopRequireWildcard(require("../../../../ui/ToolbarButton"));
|
|
17
|
-
var _messages = require("@atlaskit/editor-common/messages");
|
|
18
|
-
var _commands = require("../../commands");
|
|
19
|
-
var _keymaps2 = require("@atlaskit/editor-common/keymaps");
|
|
20
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
-
/** @jsx jsx */
|
|
23
|
-
|
|
24
|
-
var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
|
|
25
|
-
return function (command) {
|
|
26
|
-
var _api$typeAhead;
|
|
27
|
-
if (!editorView) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
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)) {
|
|
31
|
-
var _api$typeAhead2;
|
|
32
|
-
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({
|
|
33
|
-
attachCommand: command,
|
|
34
|
-
insertCurrentQueryAsRawText: false
|
|
35
|
-
});
|
|
36
|
-
} else {
|
|
37
|
-
command(editorView.state, editorView.dispatch);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
var forceFocus = function forceFocus(editorView, api) {
|
|
42
|
-
return function (command) {
|
|
43
|
-
closeTypeAheadAndRunCommand(editorView, api)(command);
|
|
44
|
-
if (!editorView.hasFocus()) {
|
|
45
|
-
editorView.focus();
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
var ToolbarUndoRedo = exports.ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
|
|
50
|
-
var disabled = _ref.disabled,
|
|
51
|
-
isReducedSpacing = _ref.isReducedSpacing,
|
|
52
|
-
editorView = _ref.editorView,
|
|
53
|
-
api = _ref.api,
|
|
54
|
-
formatMessage = _ref.intl.formatMessage;
|
|
55
|
-
var _useSharedPluginState = (0, _hooks.useSharedPluginState)(api, ['history']),
|
|
56
|
-
historyState = _useSharedPluginState.historyState;
|
|
57
|
-
var handleUndo = function handleUndo() {
|
|
58
|
-
forceFocus(editorView, api)(_commands.undoFromToolbar);
|
|
59
|
-
};
|
|
60
|
-
var handleRedo = function handleRedo() {
|
|
61
|
-
forceFocus(editorView, api)(_commands.redoFromToolbar);
|
|
62
|
-
};
|
|
63
|
-
var labelUndo = formatMessage(_messages.undoRedoMessages.undo);
|
|
64
|
-
var labelRedo = formatMessage(_messages.undoRedoMessages.redo);
|
|
65
|
-
var _ref2 = historyState !== null && historyState !== void 0 ? historyState : {},
|
|
66
|
-
canUndo = _ref2.canUndo,
|
|
67
|
-
canRedo = _ref2.canRedo;
|
|
68
|
-
return (0, _react.jsx)("span", {
|
|
69
|
-
css: _styles.buttonGroupStyle
|
|
70
|
-
}, (0, _react.jsx)(_ToolbarButton.default, {
|
|
71
|
-
buttonId: _ToolbarButton.TOOLBAR_BUTTON.UNDO,
|
|
72
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
73
|
-
onClick: handleUndo,
|
|
74
|
-
disabled: !canUndo || disabled,
|
|
75
|
-
"aria-label": (0, _keymaps.tooltip)(_keymaps.undo, labelUndo),
|
|
76
|
-
"aria-keyshortcuts": (0, _keymaps2.getAriaKeyshortcuts)(_keymaps.undo),
|
|
77
|
-
title: (0, _react.jsx)(_keymaps.ToolTipContent, {
|
|
78
|
-
description: labelUndo,
|
|
79
|
-
keymap: _keymaps.undo
|
|
80
|
-
}),
|
|
81
|
-
iconBefore: (0, _react.jsx)(_undo.default, {
|
|
82
|
-
label: ""
|
|
83
|
-
}),
|
|
84
|
-
testId: "ak-editor-toolbar-button-undo"
|
|
85
|
-
}), (0, _react.jsx)(_ToolbarButton.default, {
|
|
86
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
87
|
-
buttonId: _ToolbarButton.TOOLBAR_BUTTON.REDO,
|
|
88
|
-
onClick: handleRedo,
|
|
89
|
-
disabled: !canRedo || disabled,
|
|
90
|
-
title: (0, _react.jsx)(_keymaps.ToolTipContent, {
|
|
91
|
-
description: labelRedo,
|
|
92
|
-
keymap: _keymaps.redo
|
|
93
|
-
}),
|
|
94
|
-
iconBefore: (0, _react.jsx)(_redo.default, {
|
|
95
|
-
label: ""
|
|
96
|
-
}),
|
|
97
|
-
testId: "ak-editor-toolbar-button-redo",
|
|
98
|
-
"aria-label": (0, _keymaps.tooltip)(_keymaps.redo, labelRedo),
|
|
99
|
-
"aria-keyshortcuts": (0, _keymaps2.getAriaKeyshortcuts)(_keymaps.redo)
|
|
100
|
-
}), (0, _react.jsx)("span", {
|
|
101
|
-
css: _styles.separatorStyles
|
|
102
|
-
}));
|
|
103
|
-
};
|
|
104
|
-
var _default = exports.default = (0, _reactIntlNext.injectIntl)(ToolbarUndoRedo);
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
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);
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
}({});
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
-
import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
|
|
6
|
-
const undoRedoPlugin = ({
|
|
7
|
-
api
|
|
8
|
-
}) => ({
|
|
9
|
-
name: 'undoRedoPlugin',
|
|
10
|
-
pmPlugins() {
|
|
11
|
-
return [{
|
|
12
|
-
name: 'undoRedoKeyMap',
|
|
13
|
-
plugin: () => keymapPlugin()
|
|
14
|
-
}, {
|
|
15
|
-
name: 'undoRedoPlugin',
|
|
16
|
-
plugin: options => createPlugin(options)
|
|
17
|
-
}];
|
|
18
|
-
},
|
|
19
|
-
primaryToolbarComponent({
|
|
20
|
-
editorView,
|
|
21
|
-
disabled,
|
|
22
|
-
isToolbarReducedSpacing
|
|
23
|
-
}) {
|
|
24
|
-
return /*#__PURE__*/React.createElement(ToolbarUndoRedo, {
|
|
25
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
26
|
-
disabled: disabled,
|
|
27
|
-
editorView: editorView,
|
|
28
|
-
api: api
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
export default undoRedoPlugin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { undo, redo, bindKeymapWithCommand, findKeyMapForBrowser, isCapsLockOnAndModifyKeyboardEvent } from '@atlaskit/editor-common/keymaps';
|
|
3
|
-
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
4
|
-
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/react';
|
|
3
|
-
import { injectIntl } from 'react-intl-next';
|
|
4
|
-
import UndoIcon from '@atlaskit/icon/glyph/undo';
|
|
5
|
-
import RedoIcon from '@atlaskit/icon/glyph/redo';
|
|
6
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
7
|
-
import { undo as undoKeymap, redo as redoKeymap, ToolTipContent, tooltip } from '../../../../keymaps';
|
|
8
|
-
import { separatorStyles, buttonGroupStyle } from '@atlaskit/editor-common/styles';
|
|
9
|
-
import ToolbarButton, { TOOLBAR_BUTTON } from '../../../../ui/ToolbarButton';
|
|
10
|
-
import { undoRedoMessages } from '@atlaskit/editor-common/messages';
|
|
11
|
-
import { undoFromToolbar, redoFromToolbar } from '../../commands';
|
|
12
|
-
import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
13
|
-
const closeTypeAheadAndRunCommand = (editorView, api) => command => {
|
|
14
|
-
var _api$typeAhead, _api$typeAhead$action;
|
|
15
|
-
if (!editorView) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
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)) {
|
|
19
|
-
var _api$typeAhead2, _api$typeAhead2$actio;
|
|
20
|
-
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({
|
|
21
|
-
attachCommand: command,
|
|
22
|
-
insertCurrentQueryAsRawText: false
|
|
23
|
-
});
|
|
24
|
-
} else {
|
|
25
|
-
command(editorView.state, editorView.dispatch);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
const forceFocus = (editorView, api) => command => {
|
|
29
|
-
closeTypeAheadAndRunCommand(editorView, api)(command);
|
|
30
|
-
if (!editorView.hasFocus()) {
|
|
31
|
-
editorView.focus();
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
export const ToolbarUndoRedo = ({
|
|
35
|
-
disabled,
|
|
36
|
-
isReducedSpacing,
|
|
37
|
-
editorView,
|
|
38
|
-
api,
|
|
39
|
-
intl: {
|
|
40
|
-
formatMessage
|
|
41
|
-
}
|
|
42
|
-
}) => {
|
|
43
|
-
const {
|
|
44
|
-
historyState
|
|
45
|
-
} = useSharedPluginState(api, ['history']);
|
|
46
|
-
const handleUndo = () => {
|
|
47
|
-
forceFocus(editorView, api)(undoFromToolbar);
|
|
48
|
-
};
|
|
49
|
-
const handleRedo = () => {
|
|
50
|
-
forceFocus(editorView, api)(redoFromToolbar);
|
|
51
|
-
};
|
|
52
|
-
const labelUndo = formatMessage(undoRedoMessages.undo);
|
|
53
|
-
const labelRedo = formatMessage(undoRedoMessages.redo);
|
|
54
|
-
const {
|
|
55
|
-
canUndo,
|
|
56
|
-
canRedo
|
|
57
|
-
} = historyState !== null && historyState !== void 0 ? historyState : {};
|
|
58
|
-
return 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
|
-
export default injectIntl(ToolbarUndoRedo);
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
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);
|
|
@@ -1,6 +0,0 @@
|
|
|
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
|
-
}({});
|
|
@@ -1,36 +0,0 @@
|
|
|
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
|
-
import ToolbarUndoRedo from './ui/ToolbarUndoRedo';
|
|
6
|
-
var undoRedoPlugin = function undoRedoPlugin(_ref) {
|
|
7
|
-
var api = _ref.api;
|
|
8
|
-
return {
|
|
9
|
-
name: 'undoRedoPlugin',
|
|
10
|
-
pmPlugins: function pmPlugins() {
|
|
11
|
-
return [{
|
|
12
|
-
name: 'undoRedoKeyMap',
|
|
13
|
-
plugin: function plugin() {
|
|
14
|
-
return keymapPlugin();
|
|
15
|
-
}
|
|
16
|
-
}, {
|
|
17
|
-
name: 'undoRedoPlugin',
|
|
18
|
-
plugin: function plugin(options) {
|
|
19
|
-
return createPlugin(options);
|
|
20
|
-
}
|
|
21
|
-
}];
|
|
22
|
-
},
|
|
23
|
-
primaryToolbarComponent: function primaryToolbarComponent(_ref2) {
|
|
24
|
-
var editorView = _ref2.editorView,
|
|
25
|
-
disabled = _ref2.disabled,
|
|
26
|
-
isToolbarReducedSpacing = _ref2.isToolbarReducedSpacing;
|
|
27
|
-
return /*#__PURE__*/React.createElement(ToolbarUndoRedo, {
|
|
28
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
29
|
-
disabled: disabled,
|
|
30
|
-
editorView: editorView,
|
|
31
|
-
api: api
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
export default undoRedoPlugin;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
-
import { undo, redo, bindKeymapWithCommand, findKeyMapForBrowser, isCapsLockOnAndModifyKeyboardEvent } from '@atlaskit/editor-common/keymaps';
|
|
3
|
-
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
4
|
-
import { keydownHandler } from '@atlaskit/editor-prosemirror/keymap';
|
|
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
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|