@atlaskit/editor-core 190.1.14 → 190.1.16

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/afm-cc/tsconfig.json +6 -0
  3. package/dist/cjs/plugins/index.js +0 -14
  4. package/dist/cjs/presets/default.js +2 -2
  5. package/dist/cjs/presets/universal.js +4 -2
  6. package/dist/cjs/version-wrapper.js +1 -1
  7. package/dist/es2019/plugins/index.js +0 -2
  8. package/dist/es2019/presets/default.js +1 -1
  9. package/dist/es2019/presets/universal.js +4 -2
  10. package/dist/es2019/version-wrapper.js +1 -1
  11. package/dist/esm/plugins/index.js +0 -2
  12. package/dist/esm/presets/default.js +1 -1
  13. package/dist/esm/presets/universal.js +4 -2
  14. package/dist/esm/version-wrapper.js +1 -1
  15. package/dist/types/plugins/index.d.ts +0 -2
  16. package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  17. package/dist/types/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  18. package/dist/types/ui/ContentStyles/index.d.ts +2 -2
  19. package/dist/types-ts4.5/plugins/index.d.ts +0 -2
  20. package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +2 -2
  21. package/dist/types-ts4.5/ui/ConfigPanel/FormErrorBoundary.d.ts +1 -1
  22. package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
  23. package/package.json +4 -2
  24. package/tsconfig.json +1 -1
  25. package/dist/cjs/plugins/breakout/commands/remove-breakout.js +0 -30
  26. package/dist/cjs/plugins/breakout/commands/set-breakout-mode.js +0 -29
  27. package/dist/cjs/plugins/breakout/index.js +0 -218
  28. package/dist/cjs/plugins/breakout/plugin-key.js +0 -11
  29. package/dist/cjs/plugins/breakout/types.js +0 -5
  30. package/dist/cjs/plugins/breakout/ui/LayoutButton.js +0 -133
  31. package/dist/cjs/plugins/breakout/utils/find-breakout-node.js +0 -42
  32. package/dist/cjs/plugins/breakout/utils/get-breakout-mode.js +0 -24
  33. package/dist/cjs/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -27
  34. package/dist/cjs/plugins/breakout/utils/is-supported-node.js +0 -15
  35. package/dist/cjs/plugins/undo-redo/attach-input-meta.js +0 -26
  36. package/dist/cjs/plugins/undo-redo/commands.js +0 -13
  37. package/dist/cjs/plugins/undo-redo/enums.js +0 -12
  38. package/dist/cjs/plugins/undo-redo/index.js +0 -44
  39. package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +0 -23
  40. package/dist/cjs/plugins/undo-redo/pm-plugins/main.js +0 -14
  41. package/dist/cjs/plugins/undo-redo/pm-plugins/plugin-key.js +0 -8
  42. package/dist/cjs/plugins/undo-redo/types.js +0 -5
  43. package/dist/cjs/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -104
  44. package/dist/es2019/plugins/breakout/commands/remove-breakout.js +0 -22
  45. package/dist/es2019/plugins/breakout/commands/set-breakout-mode.js +0 -23
  46. package/dist/es2019/plugins/breakout/index.js +0 -208
  47. package/dist/es2019/plugins/breakout/plugin-key.js +0 -3
  48. package/dist/es2019/plugins/breakout/types.js +0 -1
  49. package/dist/es2019/plugins/breakout/ui/LayoutButton.js +0 -117
  50. package/dist/es2019/plugins/breakout/utils/find-breakout-node.js +0 -37
  51. package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -16
  52. package/dist/es2019/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
  53. package/dist/es2019/plugins/breakout/utils/is-supported-node.js +0 -9
  54. package/dist/es2019/plugins/undo-redo/attach-input-meta.js +0 -16
  55. package/dist/es2019/plugins/undo-redo/commands.js +0 -7
  56. package/dist/es2019/plugins/undo-redo/enums.js +0 -6
  57. package/dist/es2019/plugins/undo-redo/index.js +0 -32
  58. package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +0 -17
  59. package/dist/es2019/plugins/undo-redo/pm-plugins/main.js +0 -9
  60. package/dist/es2019/plugins/undo-redo/pm-plugins/plugin-key.js +0 -2
  61. package/dist/es2019/plugins/undo-redo/types.js +0 -1
  62. package/dist/es2019/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -94
  63. package/dist/esm/plugins/breakout/commands/remove-breakout.js +0 -24
  64. package/dist/esm/plugins/breakout/commands/set-breakout-mode.js +0 -23
  65. package/dist/esm/plugins/breakout/index.js +0 -211
  66. package/dist/esm/plugins/breakout/plugin-key.js +0 -5
  67. package/dist/esm/plugins/breakout/types.js +0 -1
  68. package/dist/esm/plugins/breakout/ui/LayoutButton.js +0 -126
  69. package/dist/esm/plugins/breakout/utils/find-breakout-node.js +0 -37
  70. package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -18
  71. package/dist/esm/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
  72. package/dist/esm/plugins/breakout/utils/is-supported-node.js +0 -9
  73. package/dist/esm/plugins/undo-redo/attach-input-meta.js +0 -20
  74. package/dist/esm/plugins/undo-redo/commands.js +0 -7
  75. package/dist/esm/plugins/undo-redo/enums.js +0 -6
  76. package/dist/esm/plugins/undo-redo/index.js +0 -36
  77. package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +0 -17
  78. package/dist/esm/plugins/undo-redo/pm-plugins/main.js +0 -8
  79. package/dist/esm/plugins/undo-redo/pm-plugins/plugin-key.js +0 -2
  80. package/dist/esm/plugins/undo-redo/types.js +0 -1
  81. package/dist/esm/plugins/undo-redo/ui/ToolbarUndoRedo/index.js +0 -93
  82. package/dist/types/plugins/breakout/commands/remove-breakout.d.ts +0 -2
  83. package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
  84. package/dist/types/plugins/breakout/index.d.ts +0 -12
  85. package/dist/types/plugins/breakout/plugin-key.d.ts +0 -5
  86. package/dist/types/plugins/breakout/types.d.ts +0 -4
  87. package/dist/types/plugins/breakout/ui/LayoutButton.d.ts +0 -17
  88. package/dist/types/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
  89. package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
  90. package/dist/types/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
  91. package/dist/types/plugins/breakout/utils/is-supported-node.d.ts +0 -6
  92. package/dist/types/plugins/undo-redo/attach-input-meta.d.ts +0 -5
  93. package/dist/types/plugins/undo-redo/commands.d.ts +0 -4
  94. package/dist/types/plugins/undo-redo/enums.d.ts +0 -4
  95. package/dist/types/plugins/undo-redo/index.d.ts +0 -3
  96. package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +0 -2
  97. package/dist/types/plugins/undo-redo/pm-plugins/main.d.ts +0 -2
  98. package/dist/types/plugins/undo-redo/pm-plugins/plugin-key.d.ts +0 -2
  99. package/dist/types/plugins/undo-redo/types.d.ts +0 -6
  100. package/dist/types/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +0 -20
  101. package/dist/types-ts4.5/plugins/breakout/commands/remove-breakout.d.ts +0 -2
  102. package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
  103. package/dist/types-ts4.5/plugins/breakout/index.d.ts +0 -14
  104. package/dist/types-ts4.5/plugins/breakout/plugin-key.d.ts +0 -5
  105. package/dist/types-ts4.5/plugins/breakout/types.d.ts +0 -4
  106. package/dist/types-ts4.5/plugins/breakout/ui/LayoutButton.d.ts +0 -17
  107. package/dist/types-ts4.5/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
  108. package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
  109. package/dist/types-ts4.5/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
  110. package/dist/types-ts4.5/plugins/breakout/utils/is-supported-node.d.ts +0 -6
  111. package/dist/types-ts4.5/plugins/undo-redo/attach-input-meta.d.ts +0 -5
  112. package/dist/types-ts4.5/plugins/undo-redo/commands.d.ts +0 -4
  113. package/dist/types-ts4.5/plugins/undo-redo/enums.d.ts +0 -4
  114. package/dist/types-ts4.5/plugins/undo-redo/index.d.ts +0 -3
  115. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +0 -2
  116. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/main.d.ts +0 -2
  117. package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/plugin-key.d.ts +0 -2
  118. package/dist/types-ts4.5/plugins/undo-redo/types.d.ts +0 -9
  119. package/dist/types-ts4.5/plugins/undo-redo/ui/ToolbarUndoRedo/index.d.ts +0 -20
@@ -1,126 +0,0 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
9
- var _templateObject;
10
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
- /** @jsx jsx */
13
- import React from 'react';
14
- import { css, jsx } from '@emotion/react';
15
- import { B300, N300, N20A } from '@atlaskit/theme/colors';
16
- import { injectIntl } from 'react-intl-next';
17
- import { findParentDomRefOfType, findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
18
- import { Popup } from '@atlaskit/editor-common/ui';
19
- import CollapseIcon from '@atlaskit/icon/glyph/editor/collapse';
20
- import ExpandIcon from '@atlaskit/icon/glyph/editor/expand';
21
- import ToolbarButton from '../../../ui/ToolbarButton';
22
- import { getBreakoutMode } from '../utils/get-breakout-mode';
23
- import { setBreakoutMode } from '../commands/set-breakout-mode';
24
- import { removeBreakout } from '../commands/remove-breakout';
25
- import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
26
- import { isBreakoutMarkAllowed } from '../utils/is-breakout-mark-allowed';
27
- import { getPluginState } from '../plugin-key';
28
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
29
- import { isSupportedNodeForBreakout } from '../utils/is-supported-node';
30
- import { layers } from '@atlaskit/theme/constants';
31
- import { getNextBreakoutMode, getTitle } from '@atlaskit/editor-common/utils';
32
- var toolbarButtonWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n && button {\n background: ", ";\n color: ", ";\n :hover {\n background: ", ";\n color: ", " !important;\n }\n }\n"])), "var(--ds-background-neutral, ".concat(N20A, ")"), "var(--ds-icon, ".concat(N300, ")"), "var(--ds-background-neutral-hovered, ".concat(B300, ")"), "var(--ds-icon, white)");
33
- function getBreakoutNodeElement(pluginState, selection, editorView) {
34
- if (!pluginState.breakoutNode) {
35
- return undefined;
36
- }
37
- if (selection instanceof NodeSelection && isSupportedNodeForBreakout(selection.node)) {
38
- return findDomRefAtPos(selection.from, editorView.domAtPos.bind(editorView));
39
- }
40
- return findParentDomRefOfType(pluginState.breakoutNode.node.type, editorView.domAtPos.bind(editorView))(selection);
41
- }
42
- var LayoutButton = /*#__PURE__*/function (_React$Component) {
43
- _inherits(LayoutButton, _React$Component);
44
- var _super = _createSuper(LayoutButton);
45
- function LayoutButton() {
46
- var _this;
47
- _classCallCheck(this, LayoutButton);
48
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
49
- args[_key] = arguments[_key];
50
- }
51
- _this = _super.call.apply(_super, [this].concat(args));
52
- _defineProperty(_assertThisInitialized(_this), "handleClick", function (breakoutMode) {
53
- return function () {
54
- var _this$props$editorVie = _this.props.editorView,
55
- state = _this$props$editorVie.state,
56
- dispatch = _this$props$editorVie.dispatch;
57
- if (['wide', 'full-width'].indexOf(breakoutMode) !== -1) {
58
- setBreakoutMode(breakoutMode)(state, dispatch);
59
- } else {
60
- removeBreakout()(state, dispatch);
61
- }
62
- };
63
- });
64
- return _this;
65
- }
66
- _createClass(LayoutButton, [{
67
- key: "render",
68
- value: function render() {
69
- var _this$props = this.props,
70
- formatMessage = _this$props.intl.formatMessage,
71
- mountPoint = _this$props.mountPoint,
72
- boundariesElement = _this$props.boundariesElement,
73
- scrollableElement = _this$props.scrollableElement,
74
- editorView = _this$props.editorView,
75
- node = _this$props.node;
76
- var state = editorView.state;
77
- if (!node || !isBreakoutMarkAllowed(state)) {
78
- return null;
79
- }
80
- var breakoutMode = getBreakoutMode(editorView.state);
81
- var titleMessage = getTitle(breakoutMode);
82
- var title = formatMessage(titleMessage);
83
- var nextBreakoutMode = getNextBreakoutMode(breakoutMode);
84
- var belowOtherPopupsZIndex = layers.layer() - 1;
85
- var pluginState = getPluginState(state);
86
- if (!pluginState) {
87
- return null;
88
- }
89
- var element = getBreakoutNodeElement(pluginState, state.selection, editorView);
90
- if (!element) {
91
- return null;
92
- }
93
- var closestEl = element.querySelector(".".concat(BreakoutCssClassName.BREAKOUT_MARK_DOM));
94
- if (closestEl && closestEl.firstChild) {
95
- element = closestEl.firstChild;
96
- }
97
- return jsx(Popup, {
98
- ariaLabel: title,
99
- target: element,
100
- offset: [5, 0],
101
- alignY: "start",
102
- alignX: "end",
103
- mountTo: mountPoint,
104
- boundariesElement: boundariesElement,
105
- scrollableElement: scrollableElement,
106
- stick: true,
107
- forcePlacement: true,
108
- zIndex: belowOtherPopupsZIndex
109
- }, jsx("div", {
110
- css: toolbarButtonWrapper
111
- }, jsx(ToolbarButton, {
112
- title: title,
113
- testId: titleMessage.id,
114
- onClick: this.handleClick(nextBreakoutMode),
115
- iconBefore: breakoutMode === 'full-width' ? jsx(CollapseIcon, {
116
- label: title
117
- }) : jsx(ExpandIcon, {
118
- label: title
119
- })
120
- })));
121
- }
122
- }]);
123
- return LayoutButton;
124
- }(React.Component);
125
- _defineProperty(LayoutButton, "displayName", 'LayoutButton');
126
- export default injectIntl(LayoutButton);
@@ -1,37 +0,0 @@
1
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
2
- import { findParentNode } from '@atlaskit/editor-prosemirror/utils';
3
- import { isSupportedNodeForBreakout } from './is-supported-node';
4
-
5
- /**
6
- * Find the nearest parent node to the selection that supports breakout, or if the nearest
7
- * matching parent node is the doc, return undefined.
8
- * For depth, if a node is selected and supports breakout, return the depth of the node.
9
- * @param selection Current editor selection
10
- */
11
- export function findSupportedNodeForBreakout(selection) {
12
- if (selection instanceof NodeSelection) {
13
- var supportsBreakout = isSupportedNodeForBreakout(selection.node);
14
- if (supportsBreakout) {
15
- return {
16
- pos: selection.from,
17
- start: selection.from,
18
- node: selection.node,
19
- // If a selected expand is in a doc, the depth of that expand is 0. Therefore
20
- // we don't need to subtract 1 or instantly return false if the depth is 0
21
- depth: selection.$anchor.depth
22
- };
23
- }
24
- }
25
- var breakoutNode = findParentNode(isSupportedNodeForBreakout)(selection);
26
- if (!breakoutNode || breakoutNode.depth === 0) {
27
- // If this node doesn't exist or the only supporting node is the document
28
- // (with depth 0), then we're not inside a node that supports breakout
29
- return undefined;
30
- }
31
- return {
32
- node: breakoutNode.node,
33
- start: breakoutNode.start,
34
- pos: breakoutNode.pos,
35
- depth: breakoutNode.depth - 1
36
- };
37
- }
@@ -1,18 +0,0 @@
1
- import { findSupportedNodeForBreakout } from './find-breakout-node';
2
- /**
3
- * Get the current mode of the breakout at the selection
4
- * @param state Current EditorState
5
- */
6
- export function getBreakoutMode(state) {
7
- var node = findSupportedNodeForBreakout(state.selection);
8
- if (!node) {
9
- return;
10
- }
11
- var breakoutMark = node.node.marks.find(function (m) {
12
- return m.type.name === 'breakout';
13
- });
14
- if (!breakoutMark) {
15
- return;
16
- }
17
- return breakoutMark.attrs.mode;
18
- }
@@ -1,22 +0,0 @@
1
- import { findSupportedNodeForBreakout } from './find-breakout-node';
2
-
3
- /**
4
- * Check if breakout should be allowed for the current selection. If a node is selected,
5
- * can this node be broken out, if text, can the enclosing parent node be broken out.
6
- *
7
- * Currently breakout of a node is not possible if it's nested in anything but the document, however
8
- * this logic supports this changing.
9
- */
10
- export function isBreakoutMarkAllowed(state) {
11
- if (!state.schema.marks.breakout) {
12
- return false;
13
- }
14
- var supportedNodeParent = findSupportedNodeForBreakout(state.selection);
15
- if (!supportedNodeParent) {
16
- return false;
17
- }
18
- // At the moment we can only breakout when the depth is 0, ie. doc is the only node
19
- // that supports breakout. This *could* change though.
20
- var parent = state.selection.$from.node(supportedNodeParent.depth);
21
- return parent.type.allowsMarkType(state.schema.marks.breakout);
22
- }
@@ -1,9 +0,0 @@
1
- var supportedNodesForBreakout = ['codeBlock', 'layoutSection', 'expand'];
2
-
3
- /**
4
- * Check if breakout can be applied to a node
5
- * @param node Node to check
6
- */
7
- export function isSupportedNodeForBreakout(node) {
8
- return supportedNodesForBreakout.indexOf(node.type.name) !== -1;
9
- }
@@ -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,8 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { pluginKey } from './plugin-key';
3
- export var createPlugin = function createPlugin(_ref) {
4
- var dispatch = _ref.dispatch;
5
- return new SafePlugin({
6
- key: pluginKey
7
- });
8
- };
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export var pluginKey = new PluginKey('undoRedoPlugin');
@@ -1 +0,0 @@
1
- export {};
@@ -1,93 +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
- var closeTypeAheadAndRunCommand = function closeTypeAheadAndRunCommand(editorView, api) {
14
- return function (command) {
15
- var _api$typeAhead;
16
- if (!editorView) {
17
- return;
18
- }
19
- 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)) {
20
- var _api$typeAhead2;
21
- 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({
22
- attachCommand: command,
23
- insertCurrentQueryAsRawText: false
24
- });
25
- } else {
26
- command(editorView.state, editorView.dispatch);
27
- }
28
- };
29
- };
30
- var forceFocus = function forceFocus(editorView, api) {
31
- return function (command) {
32
- closeTypeAheadAndRunCommand(editorView, api)(command);
33
- if (!editorView.hasFocus()) {
34
- editorView.focus();
35
- }
36
- };
37
- };
38
- export var ToolbarUndoRedo = function ToolbarUndoRedo(_ref) {
39
- var disabled = _ref.disabled,
40
- isReducedSpacing = _ref.isReducedSpacing,
41
- editorView = _ref.editorView,
42
- api = _ref.api,
43
- formatMessage = _ref.intl.formatMessage;
44
- var _useSharedPluginState = useSharedPluginState(api, ['history']),
45
- historyState = _useSharedPluginState.historyState;
46
- var handleUndo = function handleUndo() {
47
- forceFocus(editorView, api)(undoFromToolbar);
48
- };
49
- var handleRedo = function handleRedo() {
50
- forceFocus(editorView, api)(redoFromToolbar);
51
- };
52
- var labelUndo = formatMessage(undoRedoMessages.undo);
53
- var labelRedo = formatMessage(undoRedoMessages.redo);
54
- var _ref2 = historyState !== null && historyState !== void 0 ? historyState : {},
55
- canUndo = _ref2.canUndo,
56
- canRedo = _ref2.canRedo;
57
- return jsx("span", {
58
- css: buttonGroupStyle
59
- }, jsx(ToolbarButton, {
60
- buttonId: TOOLBAR_BUTTON.UNDO,
61
- spacing: isReducedSpacing ? 'none' : 'default',
62
- onClick: handleUndo,
63
- disabled: !canUndo || disabled,
64
- "aria-label": tooltip(undoKeymap, labelUndo),
65
- "aria-keyshortcuts": getAriaKeyshortcuts(undoKeymap),
66
- title: jsx(ToolTipContent, {
67
- description: labelUndo,
68
- keymap: undoKeymap
69
- }),
70
- iconBefore: jsx(UndoIcon, {
71
- label: ""
72
- }),
73
- testId: "ak-editor-toolbar-button-undo"
74
- }), jsx(ToolbarButton, {
75
- spacing: isReducedSpacing ? 'none' : 'default',
76
- buttonId: TOOLBAR_BUTTON.REDO,
77
- onClick: handleRedo,
78
- disabled: !canRedo || disabled,
79
- title: jsx(ToolTipContent, {
80
- description: labelRedo,
81
- keymap: redoKeymap
82
- }),
83
- iconBefore: jsx(RedoIcon, {
84
- label: ""
85
- }),
86
- testId: "ak-editor-toolbar-button-redo",
87
- "aria-label": tooltip(redoKeymap, labelRedo),
88
- "aria-keyshortcuts": getAriaKeyshortcuts(redoKeymap)
89
- }), jsx("span", {
90
- css: separatorStyles
91
- }));
92
- };
93
- export default injectIntl(ToolbarUndoRedo);
@@ -1,2 +0,0 @@
1
- import type { Command } from '../../../types';
2
- export declare function removeBreakout(): Command;
@@ -1,3 +0,0 @@
1
- import type { BreakoutMode } from '@atlaskit/editor-common/types';
2
- import type { Command } from '../../../types';
3
- export declare function setBreakoutMode(mode: BreakoutMode): Command;
@@ -1,12 +0,0 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
3
- import type { BreakoutPluginState } from './types';
4
- interface BreakoutPluginOptions {
5
- allowBreakoutButton?: boolean;
6
- }
7
- declare const breakoutPlugin: NextEditorPlugin<'breakout', {
8
- pluginConfiguration: BreakoutPluginOptions | undefined;
9
- dependencies: [WidthPlugin];
10
- sharedState: Partial<BreakoutPluginState>;
11
- }>;
12
- export default breakoutPlugin;
@@ -1,5 +0,0 @@
1
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import type { BreakoutPluginState } from './types';
4
- export declare const pluginKey: PluginKey<BreakoutPluginState>;
5
- export declare const getPluginState: (state: EditorState) => BreakoutPluginState | undefined;
@@ -1,4 +0,0 @@
1
- import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
- export interface BreakoutPluginState {
3
- breakoutNode: ContentNodeWithPos | undefined;
4
- }
@@ -1,17 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import type { WrappedComponentProps } from 'react-intl-next';
4
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
- export interface Props {
7
- editorView: EditorView;
8
- mountPoint?: HTMLElement;
9
- node: PMNode | null;
10
- boundariesElement?: HTMLElement;
11
- scrollableElement?: HTMLElement;
12
- handleClick?: Function;
13
- }
14
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
15
- WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
16
- };
17
- export default _default;
@@ -1,9 +0,0 @@
1
- import type { Selection } from '@atlaskit/editor-prosemirror/state';
2
- import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
3
- /**
4
- * Find the nearest parent node to the selection that supports breakout, or if the nearest
5
- * matching parent node is the doc, return undefined.
6
- * For depth, if a node is selected and supports breakout, return the depth of the node.
7
- * @param selection Current editor selection
8
- */
9
- export declare function findSupportedNodeForBreakout(selection: Selection): ContentNodeWithPos | undefined;
@@ -1,7 +0,0 @@
1
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import type { BreakoutMode } from '@atlaskit/editor-common/types';
3
- /**
4
- * Get the current mode of the breakout at the selection
5
- * @param state Current EditorState
6
- */
7
- export declare function getBreakoutMode(state: EditorState): BreakoutMode | undefined;
@@ -1,9 +0,0 @@
1
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- /**
3
- * Check if breakout should be allowed for the current selection. If a node is selected,
4
- * can this node be broken out, if text, can the enclosing parent node be broken out.
5
- *
6
- * Currently breakout of a node is not possible if it's nested in anything but the document, however
7
- * this logic supports this changing.
8
- */
9
- export declare function isBreakoutMarkAllowed(state: EditorState): boolean;
@@ -1,6 +0,0 @@
1
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
2
- /**
3
- * Check if breakout can be applied to a node
4
- * @param node Node to check
5
- */
6
- export declare function isSupportedNodeForBreakout(node: PMNode): boolean;
@@ -1,5 +0,0 @@
1
- import type { HigherOrderCommand } from '../../types/command';
2
- import type { InputSource } from './enums';
3
- type AttachInputMeta = (inputSource: InputSource) => HigherOrderCommand;
4
- export declare const attachInputMeta: AttachInputMeta;
5
- export {};
@@ -1,4 +0,0 @@
1
- export declare const undoFromKeyboard: import("../..").Command;
2
- export declare const redoFromKeyboard: import("../..").Command;
3
- export declare const undoFromToolbar: import("../..").Command;
4
- export declare const redoFromToolbar: import("../..").Command;
@@ -1,4 +0,0 @@
1
- export declare enum InputSource {
2
- TOOLBAR = "toolbar",
3
- KEYBOARD = "keyboard"
4
- }
@@ -1,3 +0,0 @@
1
- import type { UndoRedoPlugin } from './types';
2
- declare const undoRedoPlugin: UndoRedoPlugin;
3
- export default undoRedoPlugin;
@@ -1,2 +0,0 @@
1
- import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- export declare function keymapPlugin(): SafePlugin;
@@ -1,2 +0,0 @@
1
- import { PMPluginFactory } from '../../../types';
2
- export declare const createPlugin: PMPluginFactory;
@@ -1,2 +0,0 @@
1
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
2
- export declare const pluginKey: PluginKey<any>;
@@ -1,6 +0,0 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
3
- import type { HistoryPlugin } from '@atlaskit/editor-plugin-history';
4
- export type UndoRedoPlugin = NextEditorPlugin<'undoRedoPlugin', {
5
- dependencies: [TypeAheadPlugin, HistoryPlugin];
6
- }>;
@@ -1,20 +0,0 @@
1
- /// <reference types="react" />
2
- /** @jsx jsx */
3
- import { jsx } from '@emotion/react';
4
- import type { WrappedComponentProps } from 'react-intl-next';
5
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
6
- import type { UndoRedoPlugin } from '../../types';
7
- import type { ExtractInjectionAPI } from '@atlaskit/editor-common/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;
@@ -1,2 +0,0 @@
1
- import type { Command } from '../../../types';
2
- export declare function removeBreakout(): Command;
@@ -1,3 +0,0 @@
1
- import type { BreakoutMode } from '@atlaskit/editor-common/types';
2
- import type { Command } from '../../../types';
3
- export declare function setBreakoutMode(mode: BreakoutMode): Command;
@@ -1,14 +0,0 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
2
- import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
3
- import type { BreakoutPluginState } from './types';
4
- interface BreakoutPluginOptions {
5
- allowBreakoutButton?: boolean;
6
- }
7
- declare const breakoutPlugin: NextEditorPlugin<'breakout', {
8
- pluginConfiguration: BreakoutPluginOptions | undefined;
9
- dependencies: [
10
- WidthPlugin
11
- ];
12
- sharedState: Partial<BreakoutPluginState>;
13
- }>;
14
- export default breakoutPlugin;
@@ -1,5 +0,0 @@
1
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
- import type { BreakoutPluginState } from './types';
4
- export declare const pluginKey: PluginKey<BreakoutPluginState>;
5
- export declare const getPluginState: (state: EditorState) => BreakoutPluginState | undefined;
@@ -1,4 +0,0 @@
1
- import type { ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
2
- export interface BreakoutPluginState {
3
- breakoutNode: ContentNodeWithPos | undefined;
4
- }
@@ -1,17 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import type { WrappedComponentProps } from 'react-intl-next';
4
- import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
- import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
6
- export interface Props {
7
- editorView: EditorView;
8
- mountPoint?: HTMLElement;
9
- node: PMNode | null;
10
- boundariesElement?: HTMLElement;
11
- scrollableElement?: HTMLElement;
12
- handleClick?: Function;
13
- }
14
- declare const _default: React.FC<import("react-intl-next").WithIntlProps<Props & WrappedComponentProps<"intl">>> & {
15
- WrappedComponent: React.ComponentType<Props & WrappedComponentProps<"intl">>;
16
- };
17
- export default _default;