@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.
- package/CHANGELOG.md +15 -0
- package/afm-cc/tsconfig.json +6 -0
- package/dist/cjs/plugins/index.js +0 -14
- package/dist/cjs/presets/default.js +2 -2
- package/dist/cjs/presets/universal.js +4 -2
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -2
- package/dist/es2019/presets/default.js +1 -1
- package/dist/es2019/presets/universal.js +4 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -2
- package/dist/esm/presets/default.js +1 -1
- package/dist/esm/presets/universal.js +4 -2
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -2
- 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 -2
- 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 +4 -2
- package/tsconfig.json +1 -1
- package/dist/cjs/plugins/breakout/commands/remove-breakout.js +0 -30
- package/dist/cjs/plugins/breakout/commands/set-breakout-mode.js +0 -29
- package/dist/cjs/plugins/breakout/index.js +0 -218
- package/dist/cjs/plugins/breakout/plugin-key.js +0 -11
- package/dist/cjs/plugins/breakout/types.js +0 -5
- package/dist/cjs/plugins/breakout/ui/LayoutButton.js +0 -133
- package/dist/cjs/plugins/breakout/utils/find-breakout-node.js +0 -42
- package/dist/cjs/plugins/breakout/utils/get-breakout-mode.js +0 -24
- package/dist/cjs/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -27
- package/dist/cjs/plugins/breakout/utils/is-supported-node.js +0 -15
- 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/breakout/commands/remove-breakout.js +0 -22
- package/dist/es2019/plugins/breakout/commands/set-breakout-mode.js +0 -23
- package/dist/es2019/plugins/breakout/index.js +0 -208
- package/dist/es2019/plugins/breakout/plugin-key.js +0 -3
- package/dist/es2019/plugins/breakout/types.js +0 -1
- package/dist/es2019/plugins/breakout/ui/LayoutButton.js +0 -117
- package/dist/es2019/plugins/breakout/utils/find-breakout-node.js +0 -37
- package/dist/es2019/plugins/breakout/utils/get-breakout-mode.js +0 -16
- package/dist/es2019/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/es2019/plugins/breakout/utils/is-supported-node.js +0 -9
- 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/breakout/commands/remove-breakout.js +0 -24
- package/dist/esm/plugins/breakout/commands/set-breakout-mode.js +0 -23
- package/dist/esm/plugins/breakout/index.js +0 -211
- package/dist/esm/plugins/breakout/plugin-key.js +0 -5
- package/dist/esm/plugins/breakout/types.js +0 -1
- package/dist/esm/plugins/breakout/ui/LayoutButton.js +0 -126
- package/dist/esm/plugins/breakout/utils/find-breakout-node.js +0 -37
- package/dist/esm/plugins/breakout/utils/get-breakout-mode.js +0 -18
- package/dist/esm/plugins/breakout/utils/is-breakout-mark-allowed.js +0 -22
- package/dist/esm/plugins/breakout/utils/is-supported-node.js +0 -9
- 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/breakout/commands/remove-breakout.d.ts +0 -2
- package/dist/types/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
- package/dist/types/plugins/breakout/index.d.ts +0 -12
- package/dist/types/plugins/breakout/plugin-key.d.ts +0 -5
- package/dist/types/plugins/breakout/types.d.ts +0 -4
- package/dist/types/plugins/breakout/ui/LayoutButton.d.ts +0 -17
- package/dist/types/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
- package/dist/types/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
- package/dist/types/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
- package/dist/types/plugins/breakout/utils/is-supported-node.d.ts +0 -6
- 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/breakout/commands/remove-breakout.d.ts +0 -2
- package/dist/types-ts4.5/plugins/breakout/commands/set-breakout-mode.d.ts +0 -3
- package/dist/types-ts4.5/plugins/breakout/index.d.ts +0 -14
- package/dist/types-ts4.5/plugins/breakout/plugin-key.d.ts +0 -5
- package/dist/types-ts4.5/plugins/breakout/types.d.ts +0 -4
- package/dist/types-ts4.5/plugins/breakout/ui/LayoutButton.d.ts +0 -17
- package/dist/types-ts4.5/plugins/breakout/utils/find-breakout-node.d.ts +0 -9
- package/dist/types-ts4.5/plugins/breakout/utils/get-breakout-mode.d.ts +0 -7
- package/dist/types-ts4.5/plugins/breakout/utils/is-breakout-mark-allowed.d.ts +0 -9
- package/dist/types-ts4.5/plugins/breakout/utils/is-supported-node.d.ts +0 -6
- 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
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getBreakoutMode = getBreakoutMode;
|
|
7
|
-
var _findBreakoutNode = require("./find-breakout-node");
|
|
8
|
-
/**
|
|
9
|
-
* Get the current mode of the breakout at the selection
|
|
10
|
-
* @param state Current EditorState
|
|
11
|
-
*/
|
|
12
|
-
function getBreakoutMode(state) {
|
|
13
|
-
var node = (0, _findBreakoutNode.findSupportedNodeForBreakout)(state.selection);
|
|
14
|
-
if (!node) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
var breakoutMark = node.node.marks.find(function (m) {
|
|
18
|
-
return m.type.name === 'breakout';
|
|
19
|
-
});
|
|
20
|
-
if (!breakoutMark) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
return breakoutMark.attrs.mode;
|
|
24
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isBreakoutMarkAllowed = isBreakoutMarkAllowed;
|
|
7
|
-
var _findBreakoutNode = require("./find-breakout-node");
|
|
8
|
-
/**
|
|
9
|
-
* Check if breakout should be allowed for the current selection. If a node is selected,
|
|
10
|
-
* can this node be broken out, if text, can the enclosing parent node be broken out.
|
|
11
|
-
*
|
|
12
|
-
* Currently breakout of a node is not possible if it's nested in anything but the document, however
|
|
13
|
-
* this logic supports this changing.
|
|
14
|
-
*/
|
|
15
|
-
function isBreakoutMarkAllowed(state) {
|
|
16
|
-
if (!state.schema.marks.breakout) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
var supportedNodeParent = (0, _findBreakoutNode.findSupportedNodeForBreakout)(state.selection);
|
|
20
|
-
if (!supportedNodeParent) {
|
|
21
|
-
return false;
|
|
22
|
-
}
|
|
23
|
-
// At the moment we can only breakout when the depth is 0, ie. doc is the only node
|
|
24
|
-
// that supports breakout. This *could* change though.
|
|
25
|
-
var parent = state.selection.$from.node(supportedNodeParent.depth);
|
|
26
|
-
return parent.type.allowsMarkType(state.schema.marks.breakout);
|
|
27
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isSupportedNodeForBreakout = isSupportedNodeForBreakout;
|
|
7
|
-
var supportedNodesForBreakout = ['codeBlock', 'layoutSection', 'expand'];
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Check if breakout can be applied to a node
|
|
11
|
-
* @param node Node to check
|
|
12
|
-
*/
|
|
13
|
-
function isSupportedNodeForBreakout(node) {
|
|
14
|
-
return supportedNodesForBreakout.indexOf(node.type.name) !== -1;
|
|
15
|
-
}
|
|
@@ -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,22 +0,0 @@
|
|
|
1
|
-
import { findSupportedNodeForBreakout } from '../utils/find-breakout-node';
|
|
2
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export function removeBreakout() {
|
|
4
|
-
return (state, dispatch) => {
|
|
5
|
-
const node = findSupportedNodeForBreakout(state.selection);
|
|
6
|
-
if (!node) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const marks = node.node.marks.filter(m => m.type.name !== 'breakout');
|
|
10
|
-
const tr = state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, marks);
|
|
11
|
-
tr.setMeta('scrollIntoView', false);
|
|
12
|
-
if (state.selection instanceof NodeSelection) {
|
|
13
|
-
if (state.selection.$anchor.pos === node.pos) {
|
|
14
|
-
tr.setSelection(NodeSelection.create(tr.doc, node.pos));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
if (dispatch) {
|
|
18
|
-
dispatch(tr);
|
|
19
|
-
}
|
|
20
|
-
return true;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { findSupportedNodeForBreakout } from '../utils/find-breakout-node';
|
|
2
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
export function setBreakoutMode(mode) {
|
|
4
|
-
return (state, dispatch) => {
|
|
5
|
-
const node = findSupportedNodeForBreakout(state.selection);
|
|
6
|
-
if (!node) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const tr = state.tr.setNodeMarkup(node.pos, node.node.type, node.node.attrs, [state.schema.marks.breakout.create({
|
|
10
|
-
mode
|
|
11
|
-
})]);
|
|
12
|
-
tr.setMeta('scrollIntoView', false);
|
|
13
|
-
if (state.selection instanceof NodeSelection) {
|
|
14
|
-
if (state.selection.$anchor.pos === node.pos) {
|
|
15
|
-
tr.setSelection(NodeSelection.create(tr.doc, node.pos));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
if (dispatch) {
|
|
19
|
-
dispatch(tr);
|
|
20
|
-
}
|
|
21
|
-
return true;
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { breakout } from '@atlaskit/adf-schema';
|
|
5
|
-
import { calcBreakoutWidthPx } from '@atlaskit/editor-common/utils';
|
|
6
|
-
import LayoutButton from './ui/LayoutButton';
|
|
7
|
-
import { pluginKey } from './plugin-key';
|
|
8
|
-
import { findSupportedNodeForBreakout } from './utils/find-breakout-node';
|
|
9
|
-
import { akEditorSwoopCubicBezier } from '@atlaskit/editor-shared-styles';
|
|
10
|
-
import { BreakoutCssClassName } from '@atlaskit/editor-common/styles';
|
|
11
|
-
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
12
|
-
class BreakoutView {
|
|
13
|
-
constructor(
|
|
14
|
-
/**
|
|
15
|
-
* Note: this is actually a PMMark -- however our version
|
|
16
|
-
* of the prosemirror and prosemirror types mean using PMNode
|
|
17
|
-
* is not problematic.
|
|
18
|
-
*/
|
|
19
|
-
mark, view, pluginInjectionApi) {
|
|
20
|
-
_defineProperty(this, "updateWidth", widthState => {
|
|
21
|
-
// we skip updating the width of breakout nodes if the editorView dom
|
|
22
|
-
// element was hidden (to avoid breakout width and button thrashing
|
|
23
|
-
// when an editor is hidden, re-rendered and unhidden).
|
|
24
|
-
if (widthState === undefined || widthState.width === 0) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let containerStyle = ``;
|
|
28
|
-
let contentStyle = ``;
|
|
29
|
-
let breakoutWidthPx = calcBreakoutWidthPx(this.mark.attrs.mode, widthState.width);
|
|
30
|
-
if (widthState.lineLength) {
|
|
31
|
-
if (breakoutWidthPx < widthState.lineLength) {
|
|
32
|
-
breakoutWidthPx = widthState.lineLength;
|
|
33
|
-
}
|
|
34
|
-
containerStyle += `
|
|
35
|
-
transform: none;
|
|
36
|
-
display: flex;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
`;
|
|
39
|
-
|
|
40
|
-
// There is a delay in the animation because widthState is delayed.
|
|
41
|
-
// When the editor goes full width the animation for the editor
|
|
42
|
-
// begins and finishes before widthState can update the new dimensions.
|
|
43
|
-
contentStyle += `
|
|
44
|
-
min-width: ${breakoutWidthPx}px;
|
|
45
|
-
transition: min-width 0.5s ${akEditorSwoopCubicBezier};
|
|
46
|
-
`;
|
|
47
|
-
} else {
|
|
48
|
-
// fallback method
|
|
49
|
-
// (lineLength is not normally undefined, but might be in e.g. SSR or initial render)
|
|
50
|
-
//
|
|
51
|
-
// this approach doesn't work well with position: fixed, so
|
|
52
|
-
// it breaks things like sticky headers
|
|
53
|
-
containerStyle += `width: ${breakoutWidthPx}px; transform: translateX(-50%); margin-left: 50%;`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// NOTE: This is a hack to ignore mutation since mark NodeView doesn't support
|
|
57
|
-
// `ignoreMutation` life-cycle event. @see ED-9947
|
|
58
|
-
const viewDomObserver = this.view.domObserver;
|
|
59
|
-
if (viewDomObserver && this.view.dom) {
|
|
60
|
-
viewDomObserver.stop();
|
|
61
|
-
setTimeout(() => {
|
|
62
|
-
viewDomObserver.start();
|
|
63
|
-
}, 0);
|
|
64
|
-
}
|
|
65
|
-
if (typeof this.dom.style.cssText !== 'undefined') {
|
|
66
|
-
this.dom.style.cssText = containerStyle;
|
|
67
|
-
this.contentDOM.style.cssText = contentStyle;
|
|
68
|
-
} else {
|
|
69
|
-
this.dom.setAttribute('style', containerStyle);
|
|
70
|
-
this.contentDOM.setAttribute('style', contentStyle);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
const contentDOM = document.createElement('div');
|
|
74
|
-
contentDOM.className = BreakoutCssClassName.BREAKOUT_MARK_DOM;
|
|
75
|
-
const dom = document.createElement('div');
|
|
76
|
-
dom.className = BreakoutCssClassName.BREAKOUT_MARK;
|
|
77
|
-
dom.setAttribute('data-layout', mark.attrs.mode);
|
|
78
|
-
dom.appendChild(contentDOM);
|
|
79
|
-
this.dom = dom;
|
|
80
|
-
this.mark = mark;
|
|
81
|
-
this.view = view;
|
|
82
|
-
this.contentDOM = contentDOM;
|
|
83
|
-
this.unsubscribe = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width.sharedState.onChange(({
|
|
84
|
-
nextSharedState
|
|
85
|
-
}) => this.updateWidth(nextSharedState));
|
|
86
|
-
this.updateWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width.sharedState.currentState());
|
|
87
|
-
}
|
|
88
|
-
// NOTE: Lifecycle events doesn't work for mark NodeView. So currently this is a no-op.
|
|
89
|
-
// @see https://github.com/ProseMirror/prosemirror/issues/1082
|
|
90
|
-
destroy() {
|
|
91
|
-
var _this$unsubscribe;
|
|
92
|
-
(_this$unsubscribe = this.unsubscribe) === null || _this$unsubscribe === void 0 ? void 0 : _this$unsubscribe.call(this);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function shouldPluginStateUpdate(newBreakoutNode, currentBreakoutNode) {
|
|
96
|
-
if (newBreakoutNode && currentBreakoutNode) {
|
|
97
|
-
return newBreakoutNode !== currentBreakoutNode;
|
|
98
|
-
}
|
|
99
|
-
return newBreakoutNode || currentBreakoutNode ? true : false;
|
|
100
|
-
}
|
|
101
|
-
function createPlugin(pluginInjectionApi, {
|
|
102
|
-
dispatch
|
|
103
|
-
}) {
|
|
104
|
-
return new SafePlugin({
|
|
105
|
-
state: {
|
|
106
|
-
init() {
|
|
107
|
-
return {
|
|
108
|
-
breakoutNode: undefined
|
|
109
|
-
};
|
|
110
|
-
},
|
|
111
|
-
apply(tr, pluginState) {
|
|
112
|
-
const breakoutNode = findSupportedNodeForBreakout(tr.selection);
|
|
113
|
-
if (shouldPluginStateUpdate(breakoutNode, pluginState.breakoutNode)) {
|
|
114
|
-
const nextPluginState = {
|
|
115
|
-
...pluginState,
|
|
116
|
-
breakoutNode
|
|
117
|
-
};
|
|
118
|
-
dispatch(pluginKey, nextPluginState);
|
|
119
|
-
return nextPluginState;
|
|
120
|
-
}
|
|
121
|
-
return pluginState;
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
key: pluginKey,
|
|
125
|
-
props: {
|
|
126
|
-
nodeViews: {
|
|
127
|
-
// Note: When we upgrade to prosemirror 1.27.2 -- we should
|
|
128
|
-
// move this to markViews.
|
|
129
|
-
// See the following link for more details:
|
|
130
|
-
// https://prosemirror.net/docs/ref/#view.EditorProps.nodeViews.
|
|
131
|
-
breakout: (mark, view) => {
|
|
132
|
-
return new BreakoutView(mark, view, pluginInjectionApi);
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
const LayoutButtonWrapper = ({
|
|
139
|
-
api,
|
|
140
|
-
editorView,
|
|
141
|
-
boundariesElement,
|
|
142
|
-
scrollableElement,
|
|
143
|
-
mountPoint
|
|
144
|
-
}) => {
|
|
145
|
-
var _breakoutState$breako, _breakoutState$breako2;
|
|
146
|
-
// Re-render with `width` (but don't use state) due to https://bitbucket.org/atlassian/%7Bc8e2f021-38d2-46d0-9b7a-b3f7b428f724%7D/pull-requests/24272
|
|
147
|
-
const {
|
|
148
|
-
breakoutState
|
|
149
|
-
} = useSharedPluginState(api, ['width', 'breakout']);
|
|
150
|
-
return /*#__PURE__*/React.createElement(LayoutButton, {
|
|
151
|
-
editorView: editorView,
|
|
152
|
-
mountPoint: mountPoint,
|
|
153
|
-
boundariesElement: boundariesElement,
|
|
154
|
-
scrollableElement: scrollableElement,
|
|
155
|
-
node: (_breakoutState$breako = breakoutState === null || breakoutState === void 0 ? void 0 : (_breakoutState$breako2 = breakoutState.breakoutNode) === null || _breakoutState$breako2 === void 0 ? void 0 : _breakoutState$breako2.node) !== null && _breakoutState$breako !== void 0 ? _breakoutState$breako : null
|
|
156
|
-
});
|
|
157
|
-
};
|
|
158
|
-
const breakoutPlugin = ({
|
|
159
|
-
config: options,
|
|
160
|
-
api
|
|
161
|
-
}) => ({
|
|
162
|
-
name: 'breakout',
|
|
163
|
-
pmPlugins() {
|
|
164
|
-
return [{
|
|
165
|
-
name: 'breakout',
|
|
166
|
-
plugin: props => createPlugin(api, props)
|
|
167
|
-
}];
|
|
168
|
-
},
|
|
169
|
-
marks() {
|
|
170
|
-
return [{
|
|
171
|
-
name: 'breakout',
|
|
172
|
-
mark: breakout
|
|
173
|
-
}];
|
|
174
|
-
},
|
|
175
|
-
getSharedState(editorState) {
|
|
176
|
-
if (!editorState) {
|
|
177
|
-
return {
|
|
178
|
-
breakoutNode: undefined
|
|
179
|
-
};
|
|
180
|
-
}
|
|
181
|
-
const pluginState = pluginKey.getState(editorState);
|
|
182
|
-
if (!pluginState) {
|
|
183
|
-
return {
|
|
184
|
-
breakoutNode: undefined
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
return pluginState;
|
|
188
|
-
},
|
|
189
|
-
contentComponent({
|
|
190
|
-
editorView,
|
|
191
|
-
popupsMountPoint,
|
|
192
|
-
popupsBoundariesElement,
|
|
193
|
-
popupsScrollableElement
|
|
194
|
-
}) {
|
|
195
|
-
// This is a bit crappy, but should be resolved once we move to a static schema.
|
|
196
|
-
if (options && !options.allowBreakoutButton) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
return /*#__PURE__*/React.createElement(LayoutButtonWrapper, {
|
|
200
|
-
api: api,
|
|
201
|
-
mountPoint: popupsMountPoint,
|
|
202
|
-
editorView: editorView,
|
|
203
|
-
boundariesElement: popupsBoundariesElement,
|
|
204
|
-
scrollableElement: popupsScrollableElement
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
export default breakoutPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|