@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
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteSelection, splitBlock } from '@atlaskit/editor-prosemirror/commands';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { createParagraphNear, createNewParagraphBelow } from '
|
|
4
|
+
import { createParagraphNear, createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { isTemporary } from '../../../utils';
|
|
6
6
|
import { mapSlice } from '../../../utils/slice';
|
|
7
7
|
import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '../../../utils/dom';
|
|
@@ -1,36 +1,68 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* The way expand was built, no browser reconize selection on it.
|
|
5
|
+
* For instance, when a selection going to a "collapsed" expand
|
|
6
|
+
* the browser will try to send the cursor to inside the expand content (wrong),
|
|
7
|
+
* this behavior is caused because the expand content is never true hidden
|
|
8
|
+
* we just set the height to 1px.
|
|
9
|
+
*
|
|
10
|
+
* So, we need to capture a possible selection event
|
|
11
|
+
* when a collapsed exxpand is the next node in the common depth.
|
|
12
|
+
* If that is true, we create a new TextSelection and stop the event bubble
|
|
13
|
+
*/
|
|
2
14
|
const isCollpasedExpand = node => {
|
|
3
15
|
return Boolean(node && ['expand', 'nestedExpand'].includes(node.type.name) && !node.attrs.__expanded);
|
|
4
16
|
};
|
|
5
|
-
|
|
6
|
-
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* ED-18072 - Cannot shift + arrow past bodied extension if it is not empty
|
|
20
|
+
*/
|
|
21
|
+
const isBodiedExtension = node => {
|
|
22
|
+
return Boolean(node && ['bodiedExtension'].includes(node.type.name));
|
|
23
|
+
};
|
|
24
|
+
const isProblematicNode = node => {
|
|
25
|
+
return isCollpasedExpand(node) || isBodiedExtension(node);
|
|
26
|
+
};
|
|
27
|
+
const findFixedProblematicNodePosition = (doc, $head, direction) => {
|
|
28
|
+
if ($head.pos === 0 || $head.depth === 0) {
|
|
7
29
|
return null;
|
|
8
30
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
31
|
+
if (direction === 'up') {
|
|
32
|
+
const pos = $head.before();
|
|
33
|
+
const $posResolved = $head.doc.resolve(pos);
|
|
34
|
+
const maybeProblematicNode = $posResolved.nodeBefore;
|
|
35
|
+
if (maybeProblematicNode && isProblematicNode(maybeProblematicNode)) {
|
|
36
|
+
const nodeSize = maybeProblematicNode.nodeSize;
|
|
37
|
+
const nodeStartPosition = pos - nodeSize;
|
|
38
|
+
|
|
39
|
+
// ($head.pos - 1) will correspond to (nodeStartPosition + nodeSize) when we are at the start of the text node
|
|
40
|
+
const isAtEndOfProblematicNode = $head.pos - 1 === nodeStartPosition + nodeSize;
|
|
41
|
+
if (isAtEndOfProblematicNode) {
|
|
42
|
+
const startPosNode = Math.max(nodeStartPosition, 0);
|
|
43
|
+
const $startPosNode = $head.doc.resolve(Math.min(startPosNode, $head.doc.content.size));
|
|
44
|
+
return $startPosNode;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (direction === 'down') {
|
|
49
|
+
const pos = $head.after();
|
|
50
|
+
const maybeProblematicNode = doc.nodeAt(pos);
|
|
51
|
+
if (maybeProblematicNode && isProblematicNode(maybeProblematicNode) && $head.pos + 1 === pos) {
|
|
52
|
+
const nodeSize = maybeProblematicNode.nodeSize;
|
|
53
|
+
const nodePosition = pos + nodeSize;
|
|
54
|
+
const startPosNode = Math.max(nodePosition, 0);
|
|
55
|
+
const $startPosNode = $head.doc.resolve(Math.min(startPosNode, $head.doc.content.size));
|
|
56
|
+
return $startPosNode;
|
|
57
|
+
}
|
|
18
58
|
}
|
|
19
59
|
return null;
|
|
20
60
|
};
|
|
21
61
|
export const onKeydown = (view, event) => {
|
|
22
62
|
/*
|
|
23
|
-
* This workaround is needed for some specific
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* For instance, when a selection going to a "collapsed" expand
|
|
27
|
-
* the browser will try to send the cursor to inside the expand content (wrong),
|
|
28
|
-
* this behavior is caused because the expand content is never true hidden
|
|
29
|
-
* we just set the height to 1px.
|
|
30
|
-
*
|
|
31
|
-
* So, we need to capture a possible selection event
|
|
32
|
-
* when a collapsed exxpand is the next node in the common depth.
|
|
33
|
-
* If that is true, we create a new TextSelection and stop the event bubble
|
|
63
|
+
* This workaround is needed for some specific situations.
|
|
64
|
+
* - expand collapse
|
|
65
|
+
* - bodied extension
|
|
34
66
|
*/
|
|
35
67
|
if (!(event instanceof KeyboardEvent)) {
|
|
36
68
|
return false;
|
|
@@ -42,6 +74,7 @@ export const onKeydown = (view, event) => {
|
|
|
42
74
|
return false;
|
|
43
75
|
}
|
|
44
76
|
const {
|
|
77
|
+
doc,
|
|
45
78
|
selection: {
|
|
46
79
|
$head,
|
|
47
80
|
$anchor
|
|
@@ -51,9 +84,12 @@ export const onKeydown = (view, event) => {
|
|
|
51
84
|
return false;
|
|
52
85
|
}
|
|
53
86
|
const direction = ['ArrowLeft', 'ArrowUp', 'Home'].includes(event.key) ? 'up' : 'down';
|
|
54
|
-
const $fixedProblematicNodePosition = findFixedProblematicNodePosition($head, direction);
|
|
87
|
+
const $fixedProblematicNodePosition = findFixedProblematicNodePosition(doc, $head, direction);
|
|
55
88
|
if ($fixedProblematicNodePosition) {
|
|
56
|
-
|
|
89
|
+
// an offset is used here so that left arrow selects the first character before the node (consistent with arrow right)
|
|
90
|
+
const headOffset = event.key === 'ArrowLeft' ? -1 : 0;
|
|
91
|
+
const head = $fixedProblematicNodePosition.pos + headOffset;
|
|
92
|
+
const forcedTextSelection = TextSelection.create(view.state.doc, $anchor.pos, head);
|
|
57
93
|
const tr = view.state.tr;
|
|
58
94
|
tr.setSelection(forcedTextSelection);
|
|
59
95
|
view.dispatch(tr);
|
|
@@ -4,7 +4,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
4
4
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
5
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { uuid } from '@atlaskit/adf-schema';
|
|
7
|
-
import { filterCommand as filter, isEmptySelectionAtStart,
|
|
7
|
+
import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
8
8
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, withAnalytics } from '../../analytics';
|
|
9
9
|
import { insertTaskDecisionWithAnalytics } from '../commands';
|
|
10
10
|
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as keymaps from '../../../keymaps';
|
|
2
|
-
import { keymap } from '
|
|
2
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
4
4
|
export function keymapPlugin() {
|
|
5
5
|
const list = {};
|
package/dist/es2019/ui/styles.js
CHANGED
|
@@ -1,25 +1,9 @@
|
|
|
1
1
|
import { css } from '@emotion/react';
|
|
2
2
|
export { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
3
3
|
export { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
4
|
-
export const wrapperSmallStyle = css`
|
|
5
|
-
margin-left: ${"var(--ds-space-050, 4px)"};
|
|
6
|
-
min-width: 40px;
|
|
7
|
-
`;
|
|
8
4
|
export const expandIconWrapperStyle = css`
|
|
9
5
|
margin-left: -8px;
|
|
10
6
|
`;
|
|
11
|
-
export const buttonContentStyle = css`
|
|
12
|
-
display: flex;
|
|
13
|
-
min-width: 80px;
|
|
14
|
-
align-items: center;
|
|
15
|
-
overflow: hidden;
|
|
16
|
-
justify-content: center;
|
|
17
|
-
flex-direction: column;
|
|
18
|
-
padding: ${"var(--ds-space-075, 6px)"};
|
|
19
|
-
`;
|
|
20
|
-
export const buttonContentReducedSpacingStyle = css`
|
|
21
|
-
padding: ${"var(--ds-space-100, 8px)"};
|
|
22
|
-
`;
|
|
23
7
|
export const clickSelectWrapperStyle = css`
|
|
24
8
|
user-select: all;
|
|
25
9
|
`;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
2
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
4
3
|
import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
|
|
5
4
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
5
|
import { isNodeEmpty } from './document';
|
|
7
|
-
import { atTheBeginningOfDoc, atTheEndOfDoc } from './prosemirror/position';
|
|
8
|
-
import { isMediaNode } from '@atlaskit/editor-common/utils';
|
|
9
6
|
export { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
10
7
|
export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
|
|
11
8
|
export { sanitiseMarksInSelection } from './mark';
|
|
@@ -18,41 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
|
18
15
|
function isMarkTypeAllowedInNode(markType, state) {
|
|
19
16
|
return toggleMark(markType)(state);
|
|
20
17
|
}
|
|
21
|
-
export function canMoveUp(state) {
|
|
22
|
-
const {
|
|
23
|
-
selection
|
|
24
|
-
} = state;
|
|
25
|
-
/**
|
|
26
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
27
|
-
*/
|
|
28
|
-
if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
if (selection instanceof TextSelection) {
|
|
32
|
-
if (!selection.empty) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return !atTheBeginningOfDoc(state);
|
|
37
|
-
}
|
|
38
|
-
export function canMoveDown(state) {
|
|
39
|
-
const {
|
|
40
|
-
selection
|
|
41
|
-
} = state;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
45
|
-
*/
|
|
46
|
-
if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
if (selection instanceof TextSelection) {
|
|
50
|
-
if (!selection.empty) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return !atTheEndOfDoc(state);
|
|
55
|
-
}
|
|
56
18
|
export function isSelectionInsideLastNodeInDocument(selection) {
|
|
57
19
|
const docNode = selection.$anchor.node(0);
|
|
58
20
|
const rootNode = selection.$anchor.node(1);
|
|
@@ -177,48 +139,6 @@ export function whichTransitionEvent() {
|
|
|
177
139
|
}
|
|
178
140
|
return;
|
|
179
141
|
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Function will create a list of wrapper blocks present in a selection.
|
|
183
|
-
*/
|
|
184
|
-
function getSelectedWrapperNodes(state) {
|
|
185
|
-
const nodes = [];
|
|
186
|
-
if (state.selection) {
|
|
187
|
-
const {
|
|
188
|
-
$from,
|
|
189
|
-
$to
|
|
190
|
-
} = state.selection;
|
|
191
|
-
const {
|
|
192
|
-
blockquote,
|
|
193
|
-
panel,
|
|
194
|
-
orderedList,
|
|
195
|
-
bulletList,
|
|
196
|
-
listItem,
|
|
197
|
-
codeBlock,
|
|
198
|
-
decisionItem,
|
|
199
|
-
decisionList,
|
|
200
|
-
taskItem,
|
|
201
|
-
taskList
|
|
202
|
-
} = state.schema.nodes;
|
|
203
|
-
state.doc.nodesBetween($from.pos, $to.pos, node => {
|
|
204
|
-
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
205
|
-
nodes.push(node.type);
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
return nodes;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
214
|
-
*/
|
|
215
|
-
export function areBlockTypesDisabled(state) {
|
|
216
|
-
const nodesTypes = getSelectedWrapperNodes(state);
|
|
217
|
-
const {
|
|
218
|
-
panel
|
|
219
|
-
} = state.schema.nodes;
|
|
220
|
-
return nodesTypes.filter(type => type !== panel).length > 0;
|
|
221
|
-
}
|
|
222
142
|
export const isTemporary = id => {
|
|
223
143
|
return id.indexOf('temporary:') === 0;
|
|
224
144
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
-
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
3
1
|
import { addAnalytics } from '../plugins/analytics';
|
|
4
|
-
|
|
2
|
+
/**
|
|
3
|
+
* @private
|
|
4
|
+
* @deprecated Use import {inputRuleWithAnalytics} from "@atlaskit/editor-common/utils"; instead
|
|
5
|
+
*/
|
|
5
6
|
export const ruleWithAnalytics = getPayload => {
|
|
6
7
|
return originalRule => {
|
|
7
8
|
const onHandlerApply = (state, tr, matchResult) => {
|
|
@@ -16,62 +17,4 @@ export const ruleWithAnalytics = getPayload => {
|
|
|
16
17
|
onHandlerApply
|
|
17
18
|
};
|
|
18
19
|
};
|
|
19
|
-
};
|
|
20
|
-
export const createWrappingTextBlockRule = ({
|
|
21
|
-
match,
|
|
22
|
-
nodeType,
|
|
23
|
-
getAttrs
|
|
24
|
-
}) => {
|
|
25
|
-
const handler = (state, match, start, end) => {
|
|
26
|
-
const fixedStart = Math.max(start, 1);
|
|
27
|
-
const $start = state.doc.resolve(fixedStart);
|
|
28
|
-
const attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
29
|
-
const nodeBefore = $start.node(-1);
|
|
30
|
-
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
34
|
-
};
|
|
35
|
-
return createRule(match, handler);
|
|
36
|
-
};
|
|
37
|
-
export const createWrappingJoinRule = ({
|
|
38
|
-
match,
|
|
39
|
-
nodeType,
|
|
40
|
-
getAttrs,
|
|
41
|
-
joinPredicate
|
|
42
|
-
}) => {
|
|
43
|
-
const handler = (state, match, start, end) => {
|
|
44
|
-
const attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
|
|
45
|
-
const tr = state.tr;
|
|
46
|
-
const fixedStart = Math.max(start, 1);
|
|
47
|
-
tr.delete(fixedStart, end);
|
|
48
|
-
const $start = tr.doc.resolve(fixedStart);
|
|
49
|
-
const range = $start.blockRange();
|
|
50
|
-
const wrapping = range && findWrapping(range, nodeType, attrs);
|
|
51
|
-
if (!wrapping || !range) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
const parentNodePosMapped = tr.mapping.map(range.start);
|
|
55
|
-
const parentNode = tr.doc.nodeAt(parentNodePosMapped);
|
|
56
|
-
const lastWrap = wrapping[wrapping.length - 1];
|
|
57
|
-
if (parentNode && lastWrap) {
|
|
58
|
-
const allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
|
|
59
|
-
tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
|
|
60
|
-
}
|
|
61
|
-
tr.wrap(range, wrapping);
|
|
62
|
-
const before = tr.doc.resolve(fixedStart - 1).nodeBefore;
|
|
63
|
-
if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
|
|
64
|
-
tr.join(fixedStart - 1);
|
|
65
|
-
}
|
|
66
|
-
return tr;
|
|
67
|
-
};
|
|
68
|
-
return createRule(match, handler);
|
|
69
|
-
};
|
|
70
|
-
export const createJoinNodesRule = (match, nodeType) => {
|
|
71
|
-
return createWrappingJoinRule({
|
|
72
|
-
nodeType,
|
|
73
|
-
match,
|
|
74
|
-
getAttrs: {},
|
|
75
|
-
joinPredicate: (_, node) => node.type === nodeType
|
|
76
|
-
});
|
|
77
20
|
};
|
|
@@ -24,39 +24,6 @@ export const isMarkExcluded = (type, marks) => {
|
|
|
24
24
|
}
|
|
25
25
|
return false;
|
|
26
26
|
};
|
|
27
|
-
const not = fn => arg => !fn(arg);
|
|
28
|
-
export const removeBlockMarks = (state, marks) => {
|
|
29
|
-
const {
|
|
30
|
-
selection,
|
|
31
|
-
schema
|
|
32
|
-
} = state;
|
|
33
|
-
let {
|
|
34
|
-
tr
|
|
35
|
-
} = state;
|
|
36
|
-
|
|
37
|
-
// Marks might not exist in Schema
|
|
38
|
-
const marksToRemove = marks.filter(Boolean);
|
|
39
|
-
if (marksToRemove.length === 0) {
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** Saves an extra dispatch */
|
|
44
|
-
let blockMarksExists = false;
|
|
45
|
-
const hasMark = mark => marksToRemove.indexOf(mark.type) > -1;
|
|
46
|
-
/**
|
|
47
|
-
* When you need to toggle the selection
|
|
48
|
-
* when another type which does not allow alignment is applied
|
|
49
|
-
*/
|
|
50
|
-
state.doc.nodesBetween(selection.from, selection.to, (node, pos) => {
|
|
51
|
-
if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
|
|
52
|
-
blockMarksExists = true;
|
|
53
|
-
const resolvedPos = state.doc.resolve(pos);
|
|
54
|
-
const withoutBlockMarks = node.marks.filter(not(hasMark));
|
|
55
|
-
tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return blockMarksExists ? tr : undefined;
|
|
59
|
-
};
|
|
60
27
|
|
|
61
28
|
/**
|
|
62
29
|
* Removes marks from nodes in the current selection that are not supported
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,126 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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) { _defineProperty(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; }
|
|
4
|
-
import {
|
|
5
|
-
import { NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
7
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, withAnalytics } from '../plugins/analytics';
|
|
8
|
-
import { canMoveDown, canMoveUp } from '../utils';
|
|
9
|
-
export function preventDefault() {
|
|
10
|
-
return function () {
|
|
11
|
-
return true;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function insertNewLine() {
|
|
15
|
-
return function (state, dispatch) {
|
|
16
|
-
var $from = state.selection.$from;
|
|
17
|
-
var parent = $from.parent;
|
|
18
|
-
var hardBreak = state.schema.nodes.hardBreak;
|
|
19
|
-
if (hardBreak) {
|
|
20
|
-
var hardBreakNode = hardBreak.createChecked();
|
|
21
|
-
if (parent && parent.type.validContent(Fragment.from(hardBreakNode))) {
|
|
22
|
-
if (dispatch) {
|
|
23
|
-
dispatch(state.tr.replaceSelectionWith(hardBreakNode, false));
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (state.selection instanceof TextSelection) {
|
|
29
|
-
if (dispatch) {
|
|
30
|
-
dispatch(state.tr.insertText('\n'));
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
return false;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
export var insertNewLineWithAnalytics = withAnalytics({
|
|
38
|
-
action: ACTION.INSERTED,
|
|
39
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
40
|
-
actionSubjectId: ACTION_SUBJECT_ID.LINE_BREAK,
|
|
41
|
-
eventType: EVENT_TYPE.TRACK
|
|
42
|
-
})(insertNewLine());
|
|
43
|
-
export var createNewParagraphAbove = function createNewParagraphAbove(state, dispatch) {
|
|
44
|
-
var append = false;
|
|
45
|
-
if (!canMoveUp(state) && canCreateParagraphNear(state)) {
|
|
46
|
-
createParagraphNear(append)(state, dispatch);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
return false;
|
|
50
|
-
};
|
|
51
|
-
export var createNewParagraphBelow = function createNewParagraphBelow(state, dispatch) {
|
|
52
|
-
var append = true;
|
|
53
|
-
if (!canMoveDown(state) && canCreateParagraphNear(state)) {
|
|
54
|
-
createParagraphNear(append)(state, dispatch);
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
return false;
|
|
58
|
-
};
|
|
59
|
-
function canCreateParagraphNear(state) {
|
|
60
|
-
var $from = state.selection.$from;
|
|
61
|
-
var node = $from.node($from.depth);
|
|
62
|
-
var insideCodeBlock = !!node && node.type === state.schema.nodes.codeBlock;
|
|
63
|
-
var isNodeSelection = state.selection instanceof NodeSelection;
|
|
64
|
-
return $from.depth > 1 || isNodeSelection || insideCodeBlock;
|
|
65
|
-
}
|
|
66
|
-
export function createParagraphNear() {
|
|
67
|
-
var append = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
68
|
-
return function (state, dispatch) {
|
|
69
|
-
var paragraph = state.schema.nodes.paragraph;
|
|
70
|
-
if (!paragraph) {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
var insertPos;
|
|
74
|
-
if (state.selection instanceof TextSelection) {
|
|
75
|
-
if (topLevelNodeIsEmptyTextBlock(state)) {
|
|
76
|
-
return false;
|
|
77
|
-
}
|
|
78
|
-
insertPos = getInsertPosFromTextBlock(state, append);
|
|
79
|
-
} else {
|
|
80
|
-
insertPos = getInsertPosFromNonTextBlock(state, append);
|
|
81
|
-
}
|
|
82
|
-
var tr = state.tr.insert(insertPos, paragraph.createAndFill());
|
|
83
|
-
tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));
|
|
84
|
-
if (dispatch) {
|
|
85
|
-
dispatch(tr);
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
function getInsertPosFromTextBlock(state, append) {
|
|
91
|
-
var _state$selection = state.selection,
|
|
92
|
-
$from = _state$selection.$from,
|
|
93
|
-
$to = _state$selection.$to;
|
|
94
|
-
var pos;
|
|
95
|
-
if (!append) {
|
|
96
|
-
pos = $from.start(0);
|
|
97
|
-
} else {
|
|
98
|
-
pos = $to.end(0);
|
|
99
|
-
}
|
|
100
|
-
return pos;
|
|
101
|
-
}
|
|
102
|
-
function getInsertPosFromNonTextBlock(state, append) {
|
|
103
|
-
var _state$selection2 = state.selection,
|
|
104
|
-
$from = _state$selection2.$from,
|
|
105
|
-
$to = _state$selection2.$to;
|
|
106
|
-
var nodeAtSelection = state.selection instanceof NodeSelection && state.doc.nodeAt(state.selection.$anchor.pos);
|
|
107
|
-
var isMediaSelection = nodeAtSelection && nodeAtSelection.type.name === 'mediaGroup';
|
|
108
|
-
var pos;
|
|
109
|
-
if (!append) {
|
|
110
|
-
// The start position is different with text block because it starts from 0
|
|
111
|
-
pos = $from.start($from.depth);
|
|
112
|
-
// The depth is different with text block because it starts from 0
|
|
113
|
-
pos = $from.depth > 0 && !isMediaSelection ? pos - 1 : pos;
|
|
114
|
-
} else {
|
|
115
|
-
pos = $to.end($to.depth);
|
|
116
|
-
pos = $to.depth > 0 && !isMediaSelection ? pos + 1 : pos;
|
|
117
|
-
}
|
|
118
|
-
return pos;
|
|
119
|
-
}
|
|
120
|
-
function topLevelNodeIsEmptyTextBlock(state) {
|
|
121
|
-
var topLevelNode = state.selection.$from.node(1);
|
|
122
|
-
return topLevelNode.isTextblock && topLevelNode.type !== state.schema.nodes.codeBlock && topLevelNode.nodeSize === 2;
|
|
123
|
-
}
|
|
124
6
|
export function addParagraphAtEnd(tr) {
|
|
125
7
|
var paragraph = tr.doc.type.schema.nodes.paragraph,
|
|
126
8
|
doc = tr.doc;
|
|
@@ -144,9 +26,9 @@ export function createParagraphAtEnd() {
|
|
|
144
26
|
}
|
|
145
27
|
export var changeImageAlignment = function changeImageAlignment(align) {
|
|
146
28
|
return function (state, dispatch) {
|
|
147
|
-
var _state$
|
|
148
|
-
from = _state$
|
|
149
|
-
to = _state$
|
|
29
|
+
var _state$selection = state.selection,
|
|
30
|
+
from = _state$selection.from,
|
|
31
|
+
to = _state$selection.to;
|
|
150
32
|
var tr = state.tr;
|
|
151
33
|
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
152
34
|
if (node.type === state.schema.nodes.mediaSingle) {
|
|
@@ -205,9 +87,9 @@ export var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowe
|
|
|
205
87
|
markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
|
|
206
88
|
});
|
|
207
89
|
} else {
|
|
208
|
-
var _state$
|
|
209
|
-
from = _state$
|
|
210
|
-
to = _state$
|
|
90
|
+
var _state$selection2 = state.selection,
|
|
91
|
+
from = _state$selection2.from,
|
|
92
|
+
to = _state$selection2.to;
|
|
211
93
|
markApplied = toggleBlockMarkOnRange(from, to, tr, state);
|
|
212
94
|
}
|
|
213
95
|
if (markApplied && tr.docChanged) {
|
|
@@ -14,7 +14,7 @@ import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
|
14
14
|
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
15
15
|
import betterTypeHistoryPlugin from './pm-plugins/better-type-history';
|
|
16
16
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
17
|
-
import { keymap } from '
|
|
17
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
18
18
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
19
19
|
import compositionPlugin from './pm-plugins/composition';
|
|
20
20
|
// Chrome >= 88
|
|
@@ -3,15 +3,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
3
3
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
4
|
import { findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
5
5
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { PanelType } from '@atlaskit/adf-schema';
|
|
7
|
+
import { CellSelection } from '@atlaskit/editor-tables';
|
|
8
8
|
import { shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
9
|
-
import { withAnalytics as withAnalyticsDeprecated } from '../../analytics';
|
|
10
9
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
11
10
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
12
|
-
import { filterChildrenBetween } from '@atlaskit/editor-common/
|
|
13
|
-
import {
|
|
14
|
-
import { CellSelection } from '@atlaskit/editor-tables';
|
|
11
|
+
import { filterChildrenBetween, removeBlockMarks } from '@atlaskit/editor-common/utils';
|
|
12
|
+
import { CODE_BLOCK, BLOCK_QUOTE, PANEL, HEADINGS_BY_NAME, NORMAL_TEXT } from '../types';
|
|
15
13
|
import { transformToCodeBlockAction } from './transform-to-code-block';
|
|
16
14
|
export function setBlockType(name) {
|
|
17
15
|
return function (state, dispatch) {
|
|
@@ -26,15 +24,15 @@ export function setBlockType(name) {
|
|
|
26
24
|
return false;
|
|
27
25
|
};
|
|
28
26
|
}
|
|
29
|
-
export function setBlockTypeWithAnalytics(name, inputMethod) {
|
|
27
|
+
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
30
28
|
return function (state, dispatch) {
|
|
31
29
|
var nodes = state.schema.nodes;
|
|
32
30
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
33
|
-
return setNormalTextWithAnalytics(inputMethod)(state, dispatch);
|
|
31
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
34
32
|
}
|
|
35
33
|
var headingBlockType = HEADINGS_BY_NAME[name];
|
|
36
34
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
37
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod)(state, dispatch);
|
|
35
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(state, dispatch);
|
|
38
36
|
}
|
|
39
37
|
return false;
|
|
40
38
|
};
|
|
@@ -90,9 +88,9 @@ function withCurrentHeadingLevel(fn) {
|
|
|
90
88
|
return fn(level)(state, dispatch, view);
|
|
91
89
|
};
|
|
92
90
|
}
|
|
93
|
-
export function setNormalTextWithAnalytics(inputMethod) {
|
|
91
|
+
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
94
92
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
95
|
-
return
|
|
93
|
+
return withAnalytics(editorAnalyticsApi, {
|
|
96
94
|
action: ACTION.FORMATTED,
|
|
97
95
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
98
96
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -124,9 +122,9 @@ export function setHeading(level) {
|
|
|
124
122
|
return true;
|
|
125
123
|
};
|
|
126
124
|
}
|
|
127
|
-
export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod) {
|
|
125
|
+
export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
|
|
128
126
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
129
|
-
return
|
|
127
|
+
return withAnalytics(editorAnalyticsApi, {
|
|
130
128
|
action: ACTION.FORMATTED,
|
|
131
129
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
132
130
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { mapSlice } from '../../../utils/slice';
|
|
3
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import { timestampToString } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { timestampToString, mapSlice } from '@atlaskit/editor-common/utils';
|
|
5
4
|
export function transformToCodeBlockAction(state, start, attrs) {
|
|
6
5
|
var startOfCodeBlockText = state.selection.$from;
|
|
7
6
|
var endPosition = state.selection.empty ? startOfCodeBlockText.end() : state.selection.$to.pos;
|