@atlaskit/editor-core 187.9.0 → 187.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/commands/index.js +8 -134
- package/dist/cjs/plugins/base/index.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
- package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/cjs/plugins/block-type/index.js +16 -13
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
- package/dist/cjs/plugins/block-type/utils.js +73 -2
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/emoji/commands/insert-emoji.js +31 -28
- package/dist/cjs/plugins/emoji/index.js +4 -3
- package/dist/cjs/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
- package/dist/cjs/plugins/extension/pm-plugins/main.js +54 -9
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/cjs/plugins/media/utils/media-common.js +5 -5
- package/dist/cjs/plugins/selection/pm-plugins/events/keydown.js +61 -25
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
- package/dist/cjs/ui/styles.js +4 -11
- package/dist/cjs/utils/index.js +4 -80
- package/dist/cjs/utils/input-rules.js +6 -66
- package/dist/cjs/utils/mark.js +2 -38
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -128
- package/dist/es2019/plugins/base/index.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
- package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/es2019/plugins/block-type/index.js +21 -12
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
- package/dist/es2019/plugins/block-type/utils.js +70 -1
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/emoji/commands/insert-emoji.js +5 -5
- package/dist/es2019/plugins/emoji/index.js +6 -3
- package/dist/es2019/plugins/emoji/pm-plugins/ascii-input-rules.js +14 -11
- package/dist/es2019/plugins/extension/pm-plugins/main.js +50 -0
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/selection/pm-plugins/events/keydown.js +60 -24
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/ui/styles.js +0 -16
- package/dist/es2019/utils/index.js +0 -80
- package/dist/es2019/utils/input-rules.js +4 -61
- package/dist/es2019/utils/mark.js +0 -33
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +7 -125
- package/dist/esm/plugins/base/index.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
- package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/esm/plugins/block-type/index.js +15 -12
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
- package/dist/esm/plugins/block-type/utils.js +69 -1
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/emoji/commands/insert-emoji.js +29 -27
- package/dist/esm/plugins/emoji/index.js +4 -3
- package/dist/esm/plugins/emoji/pm-plugins/ascii-input-rules.js +23 -18
- package/dist/esm/plugins/extension/pm-plugins/main.js +45 -0
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +1 -1
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/selection/pm-plugins/events/keydown.js +62 -25
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/esm/ui/styles.js +3 -6
- package/dist/esm/utils/index.js +3 -77
- package/dist/esm/utils/input-rules.js +4 -61
- package/dist/esm/utils/mark.js +0 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +0 -6
- package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types/plugins/block-type/index.d.ts +1 -1
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/block-type/styles.d.ts +1 -1
- package/dist/types/plugins/block-type/types.d.ts +2 -3
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types/plugins/block-type/utils.d.ts +15 -1
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/styles.d.ts +0 -3
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/input-rules.d.ts +4 -16
- package/dist/types/utils/mark.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -6
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/pm-plugins/ascii-input-rules.d.ts +3 -2
- package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +1 -0
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
- package/dist/types-ts4.5/utils/mark.d.ts +0 -1
- package/package.json +4 -4
- package/report.api.md +6 -16
- package/tmp/api-report-tmp.d.ts +5 -16
- package/dist/cjs/types/allowed-block-types.js +0 -5
- package/dist/cjs/utils/keymap.js +0 -38
- package/dist/es2019/types/allowed-block-types.js +0 -1
- package/dist/es2019/utils/keymap.js +0 -33
- package/dist/esm/types/allowed-block-types.js +0 -1
- package/dist/esm/utils/keymap.js +0 -33
- package/dist/types/types/allowed-block-types.d.ts +0 -1
- package/dist/types/utils/keymap.d.ts +0 -11
- package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
- package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
- /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
- /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
|
@@ -5,38 +5,69 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.onKeydown = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
/*
|
|
9
|
+
* The way expand was built, no browser reconize selection on it.
|
|
10
|
+
* For instance, when a selection going to a "collapsed" expand
|
|
11
|
+
* the browser will try to send the cursor to inside the expand content (wrong),
|
|
12
|
+
* this behavior is caused because the expand content is never true hidden
|
|
13
|
+
* we just set the height to 1px.
|
|
14
|
+
*
|
|
15
|
+
* So, we need to capture a possible selection event
|
|
16
|
+
* when a collapsed exxpand is the next node in the common depth.
|
|
17
|
+
* If that is true, we create a new TextSelection and stop the event bubble
|
|
18
|
+
*/
|
|
8
19
|
var isCollpasedExpand = function isCollpasedExpand(node) {
|
|
9
20
|
return Boolean(node && ['expand', 'nestedExpand'].includes(node.type.name) && !node.attrs.__expanded);
|
|
10
21
|
};
|
|
11
|
-
|
|
12
|
-
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* ED-18072 - Cannot shift + arrow past bodied extension if it is not empty
|
|
25
|
+
*/
|
|
26
|
+
var isBodiedExtension = function isBodiedExtension(node) {
|
|
27
|
+
return Boolean(node && ['bodiedExtension'].includes(node.type.name));
|
|
28
|
+
};
|
|
29
|
+
var isProblematicNode = function isProblematicNode(node) {
|
|
30
|
+
return isCollpasedExpand(node) || isBodiedExtension(node);
|
|
31
|
+
};
|
|
32
|
+
var findFixedProblematicNodePosition = function findFixedProblematicNodePosition(doc, $head, direction) {
|
|
33
|
+
if ($head.pos === 0 || $head.depth === 0) {
|
|
13
34
|
return null;
|
|
14
35
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
if (direction === 'up') {
|
|
37
|
+
var pos = $head.before();
|
|
38
|
+
var $posResolved = $head.doc.resolve(pos);
|
|
39
|
+
var maybeProblematicNode = $posResolved.nodeBefore;
|
|
40
|
+
if (maybeProblematicNode && isProblematicNode(maybeProblematicNode)) {
|
|
41
|
+
var nodeSize = maybeProblematicNode.nodeSize;
|
|
42
|
+
var nodeStartPosition = pos - nodeSize;
|
|
43
|
+
|
|
44
|
+
// ($head.pos - 1) will correspond to (nodeStartPosition + nodeSize) when we are at the start of the text node
|
|
45
|
+
var isAtEndOfProblematicNode = $head.pos - 1 === nodeStartPosition + nodeSize;
|
|
46
|
+
if (isAtEndOfProblematicNode) {
|
|
47
|
+
var startPosNode = Math.max(nodeStartPosition, 0);
|
|
48
|
+
var $startPosNode = $head.doc.resolve(Math.min(startPosNode, $head.doc.content.size));
|
|
49
|
+
return $startPosNode;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (direction === 'down') {
|
|
54
|
+
var _pos = $head.after();
|
|
55
|
+
var _maybeProblematicNode = doc.nodeAt(_pos);
|
|
56
|
+
if (_maybeProblematicNode && isProblematicNode(_maybeProblematicNode) && $head.pos + 1 === _pos) {
|
|
57
|
+
var _nodeSize = _maybeProblematicNode.nodeSize;
|
|
58
|
+
var nodePosition = _pos + _nodeSize;
|
|
59
|
+
var _startPosNode = Math.max(nodePosition, 0);
|
|
60
|
+
var _$startPosNode = $head.doc.resolve(Math.min(_startPosNode, $head.doc.content.size));
|
|
61
|
+
return _$startPosNode;
|
|
62
|
+
}
|
|
24
63
|
}
|
|
25
64
|
return null;
|
|
26
65
|
};
|
|
27
66
|
var onKeydown = function onKeydown(view, event) {
|
|
28
67
|
/*
|
|
29
|
-
* This workaround is needed for some specific
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* For instance, when a selection going to a "collapsed" expand
|
|
33
|
-
* the browser will try to send the cursor to inside the expand content (wrong),
|
|
34
|
-
* this behavior is caused because the expand content is never true hidden
|
|
35
|
-
* we just set the height to 1px.
|
|
36
|
-
*
|
|
37
|
-
* So, we need to capture a possible selection event
|
|
38
|
-
* when a collapsed exxpand is the next node in the common depth.
|
|
39
|
-
* If that is true, we create a new TextSelection and stop the event bubble
|
|
68
|
+
* This workaround is needed for some specific situations.
|
|
69
|
+
* - expand collapse
|
|
70
|
+
* - bodied extension
|
|
40
71
|
*/
|
|
41
72
|
if (!(event instanceof KeyboardEvent)) {
|
|
42
73
|
return false;
|
|
@@ -47,16 +78,21 @@ var onKeydown = function onKeydown(view, event) {
|
|
|
47
78
|
if (!['ArrowUp', 'ArrowDown', 'ArrowRight', 'ArrowLeft', 'Home', 'End'].includes(event.key)) {
|
|
48
79
|
return false;
|
|
49
80
|
}
|
|
50
|
-
var _view$state
|
|
81
|
+
var _view$state = view.state,
|
|
82
|
+
doc = _view$state.doc,
|
|
83
|
+
_view$state$selection = _view$state.selection,
|
|
51
84
|
$head = _view$state$selection.$head,
|
|
52
85
|
$anchor = _view$state$selection.$anchor;
|
|
53
86
|
if (event.key === 'ArrowRight' && $head.nodeAfter || event.key === 'ArrowLeft' && $head.nodeBefore) {
|
|
54
87
|
return false;
|
|
55
88
|
}
|
|
56
89
|
var direction = ['ArrowLeft', 'ArrowUp', 'Home'].includes(event.key) ? 'up' : 'down';
|
|
57
|
-
var $fixedProblematicNodePosition = findFixedProblematicNodePosition($head, direction);
|
|
90
|
+
var $fixedProblematicNodePosition = findFixedProblematicNodePosition(doc, $head, direction);
|
|
58
91
|
if ($fixedProblematicNodePosition) {
|
|
59
|
-
|
|
92
|
+
// an offset is used here so that left arrow selects the first character before the node (consistent with arrow right)
|
|
93
|
+
var headOffset = event.key === 'ArrowLeft' ? -1 : 0;
|
|
94
|
+
var head = $fixedProblematicNodePosition.pos + headOffset;
|
|
95
|
+
var forcedTextSelection = _state.TextSelection.create(view.state.doc, $anchor.pos, head);
|
|
60
96
|
var tr = view.state.tr;
|
|
61
97
|
tr.setSelection(forcedTextSelection);
|
|
62
98
|
view.dispatch(tr);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.keymapPlugin = keymapPlugin;
|
|
8
8
|
var keymaps = _interopRequireWildcard(require("../../../keymaps"));
|
|
9
|
-
var
|
|
9
|
+
var _keymaps2 = require("@atlaskit/editor-common/keymaps");
|
|
10
10
|
var _commands = require("../commands");
|
|
11
11
|
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); }
|
|
12
12
|
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; }
|
|
@@ -14,5 +14,5 @@ function keymapPlugin() {
|
|
|
14
14
|
var list = {};
|
|
15
15
|
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), _commands.redoFromKeyboard, list);
|
|
16
16
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, _commands.undoFromKeyboard, list);
|
|
17
|
-
return (0,
|
|
17
|
+
return (0, _keymaps2.keymap)(list);
|
|
18
18
|
}
|
package/dist/cjs/ui/styles.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.expandIconWrapperStyle = exports.clickSelectWrapperStyle =
|
|
7
|
+
exports.expandIconWrapperStyle = exports.clickSelectWrapperStyle = void 0;
|
|
8
8
|
Object.defineProperty(exports, "scrollbarStyles", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
@@ -17,19 +17,12 @@ Object.defineProperty(exports, "shortcutStyle", {
|
|
|
17
17
|
return _shortcut.shortcutStyle;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
exports.wrapperSmallStyle = void 0;
|
|
21
20
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
22
21
|
var _react = require("@emotion/react");
|
|
23
22
|
var _shortcut = require("@atlaskit/editor-shared-styles/shortcut");
|
|
24
23
|
var _scrollbar = require("@atlaskit/editor-shared-styles/scrollbar");
|
|
25
|
-
var _templateObject, _templateObject2
|
|
26
|
-
var
|
|
27
|
-
exports.wrapperSmallStyle = wrapperSmallStyle;
|
|
28
|
-
var expandIconWrapperStyle = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
|
|
24
|
+
var _templateObject, _templateObject2;
|
|
25
|
+
var expandIconWrapperStyle = (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n margin-left: -8px;\n"])));
|
|
29
26
|
exports.expandIconWrapperStyle = expandIconWrapperStyle;
|
|
30
|
-
var
|
|
31
|
-
exports.buttonContentStyle = buttonContentStyle;
|
|
32
|
-
var buttonContentReducedSpacingStyle = (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
33
|
-
exports.buttonContentReducedSpacingStyle = buttonContentReducedSpacingStyle;
|
|
34
|
-
var clickSelectWrapperStyle = (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n user-select: all;\n"])));
|
|
27
|
+
var clickSelectWrapperStyle = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n user-select: all;\n"])));
|
|
35
28
|
exports.clickSelectWrapperStyle = clickSelectWrapperStyle;
|
package/dist/cjs/utils/index.js
CHANGED
|
@@ -10,9 +10,6 @@ Object.defineProperty(exports, "SetAttrsStep", {
|
|
|
10
10
|
return _steps.SetAttrsStep;
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
|
-
exports.areBlockTypesDisabled = areBlockTypesDisabled;
|
|
14
|
-
exports.canMoveDown = canMoveDown;
|
|
15
|
-
exports.canMoveUp = canMoveUp;
|
|
16
13
|
exports.checkNodeDown = checkNodeDown;
|
|
17
14
|
exports.compose = compose;
|
|
18
15
|
exports.dedupe = dedupe;
|
|
@@ -138,18 +135,16 @@ exports.sum = sum;
|
|
|
138
135
|
exports.toJSON = toJSON;
|
|
139
136
|
exports.whichTransitionEvent = whichTransitionEvent;
|
|
140
137
|
var _commands = require("@atlaskit/editor-prosemirror/commands");
|
|
141
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
142
138
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
143
139
|
var _cursor = require("../plugins/fake-text-cursor/cursor");
|
|
144
140
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
145
141
|
var _document = require("./document");
|
|
146
|
-
var _position = require("./prosemirror/position");
|
|
147
|
-
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
148
142
|
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
149
143
|
var _mark = require("./mark");
|
|
150
144
|
var _nodes = require("./nodes");
|
|
151
145
|
var _selection = require("./selection");
|
|
152
146
|
var _measureEnum = _interopRequireDefault(require("./performance/measure-enum"));
|
|
147
|
+
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
153
148
|
var _steps = require("@atlaskit/adf-schema/steps");
|
|
154
149
|
function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
155
150
|
return !mark.type.excludes(markType) && !markType.excludes(mark.type);
|
|
@@ -157,37 +152,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
|
157
152
|
function isMarkTypeAllowedInNode(markType, state) {
|
|
158
153
|
return (0, _commands.toggleMark)(markType)(state);
|
|
159
154
|
}
|
|
160
|
-
function canMoveUp(state) {
|
|
161
|
-
var selection = state.selection;
|
|
162
|
-
/**
|
|
163
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
164
|
-
*/
|
|
165
|
-
if (selection instanceof _state.NodeSelection && (0, _utils2.isMediaNode)(selection.node)) {
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
if (selection instanceof _state.TextSelection) {
|
|
169
|
-
if (!selection.empty) {
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
return !(0, _position.atTheBeginningOfDoc)(state);
|
|
174
|
-
}
|
|
175
|
-
function canMoveDown(state) {
|
|
176
|
-
var selection = state.selection;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
180
|
-
*/
|
|
181
|
-
if (selection instanceof _state.NodeSelection && (0, _utils2.isMediaNode)(selection.node)) {
|
|
182
|
-
return true;
|
|
183
|
-
}
|
|
184
|
-
if (selection instanceof _state.TextSelection) {
|
|
185
|
-
if (!selection.empty) {
|
|
186
|
-
return true;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return !(0, _position.atTheEndOfDoc)(state);
|
|
190
|
-
}
|
|
191
155
|
function isSelectionInsideLastNodeInDocument(selection) {
|
|
192
156
|
var docNode = selection.$anchor.node(0);
|
|
193
157
|
var rootNode = selection.$anchor.node(1);
|
|
@@ -312,46 +276,6 @@ function whichTransitionEvent() {
|
|
|
312
276
|
}
|
|
313
277
|
return;
|
|
314
278
|
}
|
|
315
|
-
|
|
316
|
-
/**
|
|
317
|
-
* Function will create a list of wrapper blocks present in a selection.
|
|
318
|
-
*/
|
|
319
|
-
function getSelectedWrapperNodes(state) {
|
|
320
|
-
var nodes = [];
|
|
321
|
-
if (state.selection) {
|
|
322
|
-
var _state$selection = state.selection,
|
|
323
|
-
$from = _state$selection.$from,
|
|
324
|
-
$to = _state$selection.$to;
|
|
325
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
326
|
-
blockquote = _state$schema$nodes.blockquote,
|
|
327
|
-
panel = _state$schema$nodes.panel,
|
|
328
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
329
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
330
|
-
listItem = _state$schema$nodes.listItem,
|
|
331
|
-
codeBlock = _state$schema$nodes.codeBlock,
|
|
332
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
333
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
334
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
335
|
-
taskList = _state$schema$nodes.taskList;
|
|
336
|
-
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
337
|
-
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
338
|
-
nodes.push(node.type);
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
return nodes;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
/**
|
|
346
|
-
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
347
|
-
*/
|
|
348
|
-
function areBlockTypesDisabled(state) {
|
|
349
|
-
var nodesTypes = getSelectedWrapperNodes(state);
|
|
350
|
-
var panel = state.schema.nodes.panel;
|
|
351
|
-
return nodesTypes.filter(function (type) {
|
|
352
|
-
return type !== panel;
|
|
353
|
-
}).length > 0;
|
|
354
|
-
}
|
|
355
279
|
var isTemporary = function isTemporary(id) {
|
|
356
280
|
return id.indexOf('temporary:') === 0;
|
|
357
281
|
};
|
|
@@ -410,9 +334,9 @@ var isEmptyNode = function isEmptyNode(schema) {
|
|
|
410
334
|
};
|
|
411
335
|
exports.isEmptyNode = isEmptyNode;
|
|
412
336
|
var insideTableCell = function insideTableCell(state) {
|
|
413
|
-
var _state$schema$
|
|
414
|
-
tableCell = _state$schema$
|
|
415
|
-
tableHeader = _state$schema$
|
|
337
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
338
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
339
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
416
340
|
return (0, _utils.hasParentNodeOfType)([tableCell, tableHeader])(state.selection);
|
|
417
341
|
};
|
|
418
342
|
exports.insideTableCell = insideTableCell;
|
|
@@ -4,14 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.ruleWithAnalytics =
|
|
7
|
+
exports.ruleWithAnalytics = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
10
|
-
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
11
9
|
var _analytics = require("../plugins/analytics");
|
|
12
|
-
var _analytics2 = require("@atlaskit/editor-common/analytics");
|
|
13
10
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
11
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
* @deprecated Use import {inputRuleWithAnalytics} from "@atlaskit/editor-common/utils"; instead
|
|
15
|
+
*/
|
|
15
16
|
var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
16
17
|
return function (originalRule) {
|
|
17
18
|
var onHandlerApply = function onHandlerApply(state, tr, matchResult) {
|
|
@@ -26,65 +27,4 @@ var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
|
26
27
|
});
|
|
27
28
|
};
|
|
28
29
|
};
|
|
29
|
-
exports.ruleWithAnalytics = ruleWithAnalytics;
|
|
30
|
-
var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
31
|
-
var match = _ref.match,
|
|
32
|
-
nodeType = _ref.nodeType,
|
|
33
|
-
getAttrs = _ref.getAttrs;
|
|
34
|
-
var handler = function handler(state, match, start, end) {
|
|
35
|
-
var fixedStart = Math.max(start, 1);
|
|
36
|
-
var $start = state.doc.resolve(fixedStart);
|
|
37
|
-
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
38
|
-
var nodeBefore = $start.node(-1);
|
|
39
|
-
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
43
|
-
};
|
|
44
|
-
return (0, _prosemirrorInputRules.createRule)(match, handler);
|
|
45
|
-
};
|
|
46
|
-
exports.createWrappingTextBlockRule = createWrappingTextBlockRule;
|
|
47
|
-
var createWrappingJoinRule = function createWrappingJoinRule(_ref2) {
|
|
48
|
-
var match = _ref2.match,
|
|
49
|
-
nodeType = _ref2.nodeType,
|
|
50
|
-
getAttrs = _ref2.getAttrs,
|
|
51
|
-
joinPredicate = _ref2.joinPredicate;
|
|
52
|
-
var handler = function handler(state, match, start, end) {
|
|
53
|
-
var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
|
|
54
|
-
var tr = state.tr;
|
|
55
|
-
var fixedStart = Math.max(start, 1);
|
|
56
|
-
tr.delete(fixedStart, end);
|
|
57
|
-
var $start = tr.doc.resolve(fixedStart);
|
|
58
|
-
var range = $start.blockRange();
|
|
59
|
-
var wrapping = range && (0, _transform.findWrapping)(range, nodeType, attrs);
|
|
60
|
-
if (!wrapping || !range) {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
var parentNodePosMapped = tr.mapping.map(range.start);
|
|
64
|
-
var parentNode = tr.doc.nodeAt(parentNodePosMapped);
|
|
65
|
-
var lastWrap = wrapping[wrapping.length - 1];
|
|
66
|
-
if (parentNode && lastWrap) {
|
|
67
|
-
var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
|
|
68
|
-
tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
|
|
69
|
-
}
|
|
70
|
-
tr.wrap(range, wrapping);
|
|
71
|
-
var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
|
|
72
|
-
if (before && before.type === nodeType && (0, _transform.canJoin)(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, _analytics2.JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
|
|
73
|
-
tr.join(fixedStart - 1);
|
|
74
|
-
}
|
|
75
|
-
return tr;
|
|
76
|
-
};
|
|
77
|
-
return (0, _prosemirrorInputRules.createRule)(match, handler);
|
|
78
|
-
};
|
|
79
|
-
exports.createWrappingJoinRule = createWrappingJoinRule;
|
|
80
|
-
var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
81
|
-
return createWrappingJoinRule({
|
|
82
|
-
nodeType: nodeType,
|
|
83
|
-
match: match,
|
|
84
|
-
getAttrs: {},
|
|
85
|
-
joinPredicate: function joinPredicate(_, node) {
|
|
86
|
-
return node.type === nodeType;
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
};
|
|
90
|
-
exports.createJoinNodesRule = createJoinNodesRule;
|
|
30
|
+
exports.ruleWithAnalytics = ruleWithAnalytics;
|
package/dist/cjs/utils/mark.js
CHANGED
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.sanitiseSelectionMarksForWrapping = exports.sanitiseMarksInSelection = exports.
|
|
7
|
+
exports.sanitiseSelectionMarksForWrapping = exports.sanitiseMarksInSelection = exports.isMarkExcluded = exports.isMarkAllowedInRange = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var isMarkAllowedInRange = function isMarkAllowedInRange(doc, ranges, type) {
|
|
10
10
|
var _loop = function _loop() {
|
|
@@ -40,47 +40,11 @@ var isMarkExcluded = function isMarkExcluded(type, marks) {
|
|
|
40
40
|
}
|
|
41
41
|
return false;
|
|
42
42
|
};
|
|
43
|
-
exports.isMarkExcluded = isMarkExcluded;
|
|
44
|
-
var not = function not(fn) {
|
|
45
|
-
return function (arg) {
|
|
46
|
-
return !fn(arg);
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
var removeBlockMarks = function removeBlockMarks(state, marks) {
|
|
50
|
-
var selection = state.selection,
|
|
51
|
-
schema = state.schema;
|
|
52
|
-
var tr = state.tr;
|
|
53
|
-
|
|
54
|
-
// Marks might not exist in Schema
|
|
55
|
-
var marksToRemove = marks.filter(Boolean);
|
|
56
|
-
if (marksToRemove.length === 0) {
|
|
57
|
-
return undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/** Saves an extra dispatch */
|
|
61
|
-
var blockMarksExists = false;
|
|
62
|
-
var hasMark = function hasMark(mark) {
|
|
63
|
-
return marksToRemove.indexOf(mark.type) > -1;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* When you need to toggle the selection
|
|
67
|
-
* when another type which does not allow alignment is applied
|
|
68
|
-
*/
|
|
69
|
-
state.doc.nodesBetween(selection.from, selection.to, function (node, pos) {
|
|
70
|
-
if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
|
|
71
|
-
blockMarksExists = true;
|
|
72
|
-
var resolvedPos = state.doc.resolve(pos);
|
|
73
|
-
var withoutBlockMarks = node.marks.filter(not(hasMark));
|
|
74
|
-
tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
return blockMarksExists ? tr : undefined;
|
|
78
|
-
};
|
|
79
43
|
|
|
80
44
|
/**
|
|
81
45
|
* Removes marks from nodes in the current selection that are not supported
|
|
82
46
|
*/
|
|
83
|
-
exports.
|
|
47
|
+
exports.isMarkExcluded = isMarkExcluded;
|
|
84
48
|
var sanitiseSelectionMarksForWrapping = function sanitiseSelectionMarksForWrapping(state, newParentType) {
|
|
85
49
|
var tr = state.tr;
|
|
86
50
|
sanitiseMarksInSelection(tr, newParentType);
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/editor-core";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "187.
|
|
9
|
+
var version = "187.10.0";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,132 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
1
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, withAnalytics } from '../plugins/analytics';
|
|
5
|
-
import { canMoveDown, canMoveUp } from '../utils';
|
|
6
|
-
export function preventDefault() {
|
|
7
|
-
return function () {
|
|
8
|
-
return true;
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function insertNewLine() {
|
|
12
|
-
return function (state, dispatch) {
|
|
13
|
-
const {
|
|
14
|
-
$from
|
|
15
|
-
} = state.selection;
|
|
16
|
-
const parent = $from.parent;
|
|
17
|
-
const {
|
|
18
|
-
hardBreak
|
|
19
|
-
} = state.schema.nodes;
|
|
20
|
-
if (hardBreak) {
|
|
21
|
-
const hardBreakNode = hardBreak.createChecked();
|
|
22
|
-
if (parent && parent.type.validContent(Fragment.from(hardBreakNode))) {
|
|
23
|
-
if (dispatch) {
|
|
24
|
-
dispatch(state.tr.replaceSelectionWith(hardBreakNode, false));
|
|
25
|
-
}
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (state.selection instanceof TextSelection) {
|
|
30
|
-
if (dispatch) {
|
|
31
|
-
dispatch(state.tr.insertText('\n'));
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
return false;
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
export const insertNewLineWithAnalytics = withAnalytics({
|
|
39
|
-
action: ACTION.INSERTED,
|
|
40
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
41
|
-
actionSubjectId: ACTION_SUBJECT_ID.LINE_BREAK,
|
|
42
|
-
eventType: EVENT_TYPE.TRACK
|
|
43
|
-
})(insertNewLine());
|
|
44
|
-
export const createNewParagraphAbove = (state, dispatch) => {
|
|
45
|
-
const append = false;
|
|
46
|
-
if (!canMoveUp(state) && canCreateParagraphNear(state)) {
|
|
47
|
-
createParagraphNear(append)(state, dispatch);
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
return false;
|
|
51
|
-
};
|
|
52
|
-
export const createNewParagraphBelow = (state, dispatch) => {
|
|
53
|
-
const append = true;
|
|
54
|
-
if (!canMoveDown(state) && canCreateParagraphNear(state)) {
|
|
55
|
-
createParagraphNear(append)(state, dispatch);
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
return false;
|
|
59
|
-
};
|
|
60
|
-
function canCreateParagraphNear(state) {
|
|
61
|
-
const {
|
|
62
|
-
selection: {
|
|
63
|
-
$from
|
|
64
|
-
}
|
|
65
|
-
} = state;
|
|
66
|
-
const node = $from.node($from.depth);
|
|
67
|
-
const insideCodeBlock = !!node && node.type === state.schema.nodes.codeBlock;
|
|
68
|
-
const isNodeSelection = state.selection instanceof NodeSelection;
|
|
69
|
-
return $from.depth > 1 || isNodeSelection || insideCodeBlock;
|
|
70
|
-
}
|
|
71
|
-
export function createParagraphNear(append = true) {
|
|
72
|
-
return function (state, dispatch) {
|
|
73
|
-
const paragraph = state.schema.nodes.paragraph;
|
|
74
|
-
if (!paragraph) {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
let insertPos;
|
|
78
|
-
if (state.selection instanceof TextSelection) {
|
|
79
|
-
if (topLevelNodeIsEmptyTextBlock(state)) {
|
|
80
|
-
return false;
|
|
81
|
-
}
|
|
82
|
-
insertPos = getInsertPosFromTextBlock(state, append);
|
|
83
|
-
} else {
|
|
84
|
-
insertPos = getInsertPosFromNonTextBlock(state, append);
|
|
85
|
-
}
|
|
86
|
-
const tr = state.tr.insert(insertPos, paragraph.createAndFill());
|
|
87
|
-
tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));
|
|
88
|
-
if (dispatch) {
|
|
89
|
-
dispatch(tr);
|
|
90
|
-
}
|
|
91
|
-
return true;
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
function getInsertPosFromTextBlock(state, append) {
|
|
95
|
-
const {
|
|
96
|
-
$from,
|
|
97
|
-
$to
|
|
98
|
-
} = state.selection;
|
|
99
|
-
let pos;
|
|
100
|
-
if (!append) {
|
|
101
|
-
pos = $from.start(0);
|
|
102
|
-
} else {
|
|
103
|
-
pos = $to.end(0);
|
|
104
|
-
}
|
|
105
|
-
return pos;
|
|
106
|
-
}
|
|
107
|
-
function getInsertPosFromNonTextBlock(state, append) {
|
|
108
|
-
const {
|
|
109
|
-
$from,
|
|
110
|
-
$to
|
|
111
|
-
} = state.selection;
|
|
112
|
-
const nodeAtSelection = state.selection instanceof NodeSelection && state.doc.nodeAt(state.selection.$anchor.pos);
|
|
113
|
-
const isMediaSelection = nodeAtSelection && nodeAtSelection.type.name === 'mediaGroup';
|
|
114
|
-
let pos;
|
|
115
|
-
if (!append) {
|
|
116
|
-
// The start position is different with text block because it starts from 0
|
|
117
|
-
pos = $from.start($from.depth);
|
|
118
|
-
// The depth is different with text block because it starts from 0
|
|
119
|
-
pos = $from.depth > 0 && !isMediaSelection ? pos - 1 : pos;
|
|
120
|
-
} else {
|
|
121
|
-
pos = $to.end($to.depth);
|
|
122
|
-
pos = $to.depth > 0 && !isMediaSelection ? pos + 1 : pos;
|
|
123
|
-
}
|
|
124
|
-
return pos;
|
|
125
|
-
}
|
|
126
|
-
function topLevelNodeIsEmptyTextBlock(state) {
|
|
127
|
-
const topLevelNode = state.selection.$from.node(1);
|
|
128
|
-
return topLevelNode.isTextblock && topLevelNode.type !== state.schema.nodes.codeBlock && topLevelNode.nodeSize === 2;
|
|
129
|
-
}
|
|
130
3
|
export function addParagraphAtEnd(tr) {
|
|
131
4
|
const {
|
|
132
5
|
doc: {
|
|
@@ -11,7 +11,7 @@ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
|
11
11
|
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
12
12
|
import betterTypeHistoryPlugin from './pm-plugins/better-type-history';
|
|
13
13
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
14
|
-
import { keymap } from '
|
|
14
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
15
15
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
16
16
|
import compositionPlugin from './pm-plugins/composition';
|
|
17
17
|
// Chrome >= 88
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
2
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
4
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
5
5
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
6
|
-
import { withAnalytics as withAnalyticsDeprecated } from '../../analytics';
|
|
7
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
7
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
9
|
-
import { filterChildrenBetween } from '@atlaskit/editor-common/
|
|
10
|
-
import {
|
|
11
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
|
+
import { filterChildrenBetween, removeBlockMarks } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { CODE_BLOCK, BLOCK_QUOTE, PANEL, HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
|
|
12
10
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
13
11
|
export function setBlockType(name) {
|
|
14
12
|
return (state, dispatch) => {
|
|
@@ -25,17 +23,17 @@ export function setBlockType(name) {
|
|
|
25
23
|
return false;
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
|
-
export function setBlockTypeWithAnalytics(name, inputMethod) {
|
|
26
|
+
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
29
27
|
return (state, dispatch) => {
|
|
30
28
|
const {
|
|
31
29
|
nodes
|
|
32
30
|
} = state.schema;
|
|
33
31
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
34
|
-
return setNormalTextWithAnalytics(inputMethod)(state, dispatch);
|
|
32
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
35
33
|
}
|
|
36
34
|
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
37
35
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
38
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod)(state, dispatch);
|
|
36
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
39
37
|
}
|
|
40
38
|
return false;
|
|
41
39
|
};
|
|
@@ -86,8 +84,8 @@ function withCurrentHeadingLevel(fn) {
|
|
|
86
84
|
return fn(level)(state, dispatch, view);
|
|
87
85
|
};
|
|
88
86
|
}
|
|
89
|
-
export function setNormalTextWithAnalytics(inputMethod) {
|
|
90
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
87
|
+
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
88
|
+
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
91
89
|
action: ACTION.FORMATTED,
|
|
92
90
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
93
91
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -121,8 +119,8 @@ export function setHeading(level) {
|
|
|
121
119
|
return true;
|
|
122
120
|
};
|
|
123
121
|
}
|
|
124
|
-
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod) => {
|
|
125
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
122
|
+
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod, editorAnalyticsApi) => {
|
|
123
|
+
return withCurrentHeadingLevel(previousHeadingLevel => withAnalytics(editorAnalyticsApi, {
|
|
126
124
|
action: ACTION.FORMATTED,
|
|
127
125
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
128
126
|
eventType: EVENT_TYPE.TRACK,
|