@atlaskit/editor-plugin-paste 0.2.7 → 0.2.9
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 +14 -0
- package/dist/cjs/edge-cases/index.js +9 -1
- package/dist/cjs/handlers.js +27 -1
- package/dist/es2019/edge-cases/index.js +9 -1
- package/dist/es2019/handlers.js +29 -3
- package/dist/esm/edge-cases/index.js +8 -1
- package/dist/esm/handlers.js +29 -3
- package/dist/types/edge-cases/index.d.ts +3 -0
- package/dist/types-ts4.5/edge-cases/index.d.ts +3 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 0.2.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#66826](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66826) [`5e9f6778a15a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5e9f6778a15a) - [ux] resolved a bug where the cursor mispalced after pasting the media into the panel
|
|
8
|
+
- [#67283](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67283) [`4f10a52c6e39`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4f10a52c6e39) - ED-21613 handle incorrect cursor position - when task is copied into a list
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 0.2.8
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#66495](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66495) [`8d310bc51505`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8d310bc51505) - ED-21623: Fixing paste behaviour for nested codeblock in panel
|
|
16
|
+
|
|
3
17
|
## 0.2.7
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.insertSliceForLists = insertSliceForLists;
|
|
7
7
|
exports.insertSliceForListsInsideBlockquote = insertSliceForListsInsideBlockquote;
|
|
8
|
+
exports.updateSelectionAfterReplace = updateSelectionAfterReplace;
|
|
8
9
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
10
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
@@ -70,6 +71,13 @@ function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
70
71
|
//insert blockquote explicitly and set the selection in blockquote since replaceSelection will only insert the list
|
|
71
72
|
var schema = tr.doc.type.schema;
|
|
72
73
|
tr.replaceSelection(new _model.Slice(_model.Fragment.from(schema.nodes.blockquote.createAndFill()), 0, 0));
|
|
74
|
+
updateSelectionAfterReplace({
|
|
75
|
+
tr: tr
|
|
76
|
+
});
|
|
77
|
+
tr.replaceSelection(slice);
|
|
78
|
+
}
|
|
79
|
+
function updateSelectionAfterReplace(_ref4) {
|
|
80
|
+
var tr = _ref4.tr;
|
|
73
81
|
// ProseMirror doesn't give a proper way to tell us where something was inserted.
|
|
74
82
|
// However, we can know "how" it inserted something.
|
|
75
83
|
//
|
|
@@ -78,6 +86,7 @@ function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
78
86
|
// The `replaceStep.to and replaceStep.from`, tell us the real position
|
|
79
87
|
// where the content will be insert.
|
|
80
88
|
// Then, we can use the `tr.mapping.map` to the updated position after the replace operation
|
|
89
|
+
|
|
81
90
|
var replaceStep = tr.steps[0];
|
|
82
91
|
if (!(replaceStep instanceof _transform.ReplaceStep)) {
|
|
83
92
|
return tr;
|
|
@@ -88,5 +97,4 @@ function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
88
97
|
if (nextSelection) {
|
|
89
98
|
tr.setSelection(nextSelection);
|
|
90
99
|
}
|
|
91
|
-
tr.replaceSelection(slice);
|
|
92
100
|
}
|
package/dist/cjs/handlers.js
CHANGED
|
@@ -86,6 +86,7 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
|
|
|
86
86
|
selection = state.tr.selection;
|
|
87
87
|
var codeMark = schema.marks.code,
|
|
88
88
|
_schema$nodes = schema.nodes,
|
|
89
|
+
codeBlock = _schema$nodes.codeBlock,
|
|
89
90
|
decisionItem = _schema$nodes.decisionItem,
|
|
90
91
|
emoji = _schema$nodes.emoji,
|
|
91
92
|
hardBreak = _schema$nodes.hardBreak,
|
|
@@ -142,9 +143,29 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
|
|
|
142
143
|
// Whole codeblock node has reverse slice depths.
|
|
143
144
|
transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
|
|
144
145
|
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
146
|
+
} else if (['mediaSingle'].includes(transformedSlice.content.firstChild.type.name) && selectionIsPanel) {
|
|
147
|
+
var parentNode = (0, _utils2.findParentNodeOfType)(panel)(selection);
|
|
148
|
+
if (selectionIsPanel && parentNode && (0, _utils.isNodeEmpty)(parentNode.node)) {
|
|
149
|
+
tr.insert(selection.$from.pos, transformedSlice.content).scrollIntoView();
|
|
150
|
+
// Place the cursor at the the end of the insersertion
|
|
151
|
+
var endPos = tr.selection.from + transformedSlice.size;
|
|
152
|
+
tr.setSelection(new _state.TextSelection(tr.doc.resolve(endPos)));
|
|
153
|
+
} else {
|
|
154
|
+
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
155
|
+
}
|
|
145
156
|
} else {
|
|
146
157
|
// This maintains both the selection (destination) and the slice (paste content).
|
|
147
158
|
(0, _utils2.safeInsert)(transformedSlice.content)(tr).scrollIntoView();
|
|
159
|
+
//safeInsert doesn't set correct cursor position inside codeBlock
|
|
160
|
+
//it moves the cursor to beginning of the codeblock
|
|
161
|
+
//we manually shift the cursor to end of the codeblock
|
|
162
|
+
var currentPosition = tr.selection.$from;
|
|
163
|
+
var currentNode = currentPosition.parent;
|
|
164
|
+
if (currentNode.type === codeBlock) {
|
|
165
|
+
var endPosOfCodeBlock = currentPosition.end();
|
|
166
|
+
var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
|
|
167
|
+
tr.setSelection(new _state.TextSelection(endResolvedPosition, endResolvedPosition));
|
|
168
|
+
}
|
|
148
169
|
}
|
|
149
170
|
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
|
|
150
171
|
if (dispatch) {
|
|
@@ -816,7 +837,7 @@ function flattenNestedListInSlice(slice) {
|
|
|
816
837
|
}
|
|
817
838
|
function handleRichText(slice, queueCardsFromChangedTr) {
|
|
818
839
|
return function (state, dispatch) {
|
|
819
|
-
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
840
|
+
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre, _slice$content$firstC3;
|
|
820
841
|
var _state$schema$nodes3 = state.schema.nodes,
|
|
821
842
|
codeBlock = _state$schema$nodes3.codeBlock,
|
|
822
843
|
heading = _state$schema$nodes3.heading,
|
|
@@ -899,6 +920,11 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
899
920
|
if (tr.selection.empty && tr.selection.$from.parent.type === codeBlock) {
|
|
900
921
|
tr.setSelection(_state.TextSelection.near(tr.selection.$from, 1));
|
|
901
922
|
}
|
|
923
|
+
if ((0, _utils.isInListItem)(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 || (_slice$content$firstC3 = _slice$content$firstC3.type) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.name) || '')) {
|
|
924
|
+
(0, _edgeCases.updateSelectionAfterReplace)({
|
|
925
|
+
tr: tr
|
|
926
|
+
});
|
|
927
|
+
}
|
|
902
928
|
tr.scrollIntoView();
|
|
903
929
|
|
|
904
930
|
// queue link cards, ignoring any errors
|
|
@@ -71,6 +71,14 @@ export function insertSliceForListsInsideBlockquote({
|
|
|
71
71
|
schema
|
|
72
72
|
} = tr.doc.type;
|
|
73
73
|
tr.replaceSelection(new Slice(Fragment.from(schema.nodes.blockquote.createAndFill()), 0, 0));
|
|
74
|
+
updateSelectionAfterReplace({
|
|
75
|
+
tr
|
|
76
|
+
});
|
|
77
|
+
tr.replaceSelection(slice);
|
|
78
|
+
}
|
|
79
|
+
export function updateSelectionAfterReplace({
|
|
80
|
+
tr
|
|
81
|
+
}) {
|
|
74
82
|
// ProseMirror doesn't give a proper way to tell us where something was inserted.
|
|
75
83
|
// However, we can know "how" it inserted something.
|
|
76
84
|
//
|
|
@@ -79,6 +87,7 @@ export function insertSliceForListsInsideBlockquote({
|
|
|
79
87
|
// The `replaceStep.to and replaceStep.from`, tell us the real position
|
|
80
88
|
// where the content will be insert.
|
|
81
89
|
// Then, we can use the `tr.mapping.map` to the updated position after the replace operation
|
|
90
|
+
|
|
82
91
|
const replaceStep = tr.steps[0];
|
|
83
92
|
if (!(replaceStep instanceof ReplaceStep)) {
|
|
84
93
|
return tr;
|
|
@@ -89,5 +98,4 @@ export function insertSliceForListsInsideBlockquote({
|
|
|
89
98
|
if (nextSelection) {
|
|
90
99
|
tr.setSelection(nextSelection);
|
|
91
100
|
}
|
|
92
|
-
tr.replaceSelection(slice);
|
|
93
101
|
}
|
package/dist/es2019/handlers.js
CHANGED
|
@@ -3,7 +3,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
4
4
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
5
5
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
6
|
-
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isNodeEmpty, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
7
7
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
8
8
|
import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
9
9
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -12,7 +12,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
|
12
12
|
// TODO: ED-20519 Needs Macro extraction
|
|
13
13
|
|
|
14
14
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
15
|
-
import { insertSliceForLists, insertSliceForListsInsideBlockquote } from './edge-cases';
|
|
15
|
+
import { insertSliceForLists, insertSliceForListsInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
16
16
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
17
17
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
|
|
18
18
|
|
|
@@ -60,6 +60,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
|
|
|
60
60
|
code: codeMark
|
|
61
61
|
},
|
|
62
62
|
nodes: {
|
|
63
|
+
codeBlock,
|
|
63
64
|
decisionItem,
|
|
64
65
|
emoji,
|
|
65
66
|
hardBreak,
|
|
@@ -118,9 +119,29 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
|
|
|
118
119
|
// Whole codeblock node has reverse slice depths.
|
|
119
120
|
transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
|
|
120
121
|
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
122
|
+
} else if (['mediaSingle'].includes(transformedSlice.content.firstChild.type.name) && selectionIsPanel) {
|
|
123
|
+
const parentNode = findParentNodeOfType(panel)(selection);
|
|
124
|
+
if (selectionIsPanel && parentNode && isNodeEmpty(parentNode.node)) {
|
|
125
|
+
tr.insert(selection.$from.pos, transformedSlice.content).scrollIntoView();
|
|
126
|
+
// Place the cursor at the the end of the insersertion
|
|
127
|
+
const endPos = tr.selection.from + transformedSlice.size;
|
|
128
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(endPos)));
|
|
129
|
+
} else {
|
|
130
|
+
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
131
|
+
}
|
|
121
132
|
} else {
|
|
122
133
|
// This maintains both the selection (destination) and the slice (paste content).
|
|
123
134
|
safeInsert(transformedSlice.content)(tr).scrollIntoView();
|
|
135
|
+
//safeInsert doesn't set correct cursor position inside codeBlock
|
|
136
|
+
//it moves the cursor to beginning of the codeblock
|
|
137
|
+
//we manually shift the cursor to end of the codeblock
|
|
138
|
+
const currentPosition = tr.selection.$from;
|
|
139
|
+
const currentNode = currentPosition.parent;
|
|
140
|
+
if (currentNode.type === codeBlock) {
|
|
141
|
+
const endPosOfCodeBlock = currentPosition.end();
|
|
142
|
+
const endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
|
|
143
|
+
tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
|
|
144
|
+
}
|
|
124
145
|
}
|
|
125
146
|
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
126
147
|
if (dispatch) {
|
|
@@ -795,7 +816,7 @@ export function flattenNestedListInSlice(slice) {
|
|
|
795
816
|
}
|
|
796
817
|
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
797
818
|
return (state, dispatch) => {
|
|
798
|
-
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
819
|
+
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre, _slice$content$firstC3, _slice$content$firstC4;
|
|
799
820
|
const {
|
|
800
821
|
codeBlock,
|
|
801
822
|
heading,
|
|
@@ -881,6 +902,11 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
881
902
|
if (tr.selection.empty && tr.selection.$from.parent.type === codeBlock) {
|
|
882
903
|
tr.setSelection(TextSelection.near(tr.selection.$from, 1));
|
|
883
904
|
}
|
|
905
|
+
if (isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 ? void 0 : (_slice$content$firstC4 = _slice$content$firstC3.type) === null || _slice$content$firstC4 === void 0 ? void 0 : _slice$content$firstC4.name) || '')) {
|
|
906
|
+
updateSelectionAfterReplace({
|
|
907
|
+
tr
|
|
908
|
+
});
|
|
909
|
+
}
|
|
884
910
|
tr.scrollIntoView();
|
|
885
911
|
|
|
886
912
|
// queue link cards, ignoring any errors
|
|
@@ -63,6 +63,13 @@ export function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
63
63
|
//insert blockquote explicitly and set the selection in blockquote since replaceSelection will only insert the list
|
|
64
64
|
var schema = tr.doc.type.schema;
|
|
65
65
|
tr.replaceSelection(new Slice(Fragment.from(schema.nodes.blockquote.createAndFill()), 0, 0));
|
|
66
|
+
updateSelectionAfterReplace({
|
|
67
|
+
tr: tr
|
|
68
|
+
});
|
|
69
|
+
tr.replaceSelection(slice);
|
|
70
|
+
}
|
|
71
|
+
export function updateSelectionAfterReplace(_ref4) {
|
|
72
|
+
var tr = _ref4.tr;
|
|
66
73
|
// ProseMirror doesn't give a proper way to tell us where something was inserted.
|
|
67
74
|
// However, we can know "how" it inserted something.
|
|
68
75
|
//
|
|
@@ -71,6 +78,7 @@ export function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
71
78
|
// The `replaceStep.to and replaceStep.from`, tell us the real position
|
|
72
79
|
// where the content will be insert.
|
|
73
80
|
// Then, we can use the `tr.mapping.map` to the updated position after the replace operation
|
|
81
|
+
|
|
74
82
|
var replaceStep = tr.steps[0];
|
|
75
83
|
if (!(replaceStep instanceof ReplaceStep)) {
|
|
76
84
|
return tr;
|
|
@@ -81,5 +89,4 @@ export function insertSliceForListsInsideBlockquote(_ref3) {
|
|
|
81
89
|
if (nextSelection) {
|
|
82
90
|
tr.setSelection(nextSelection);
|
|
83
91
|
}
|
|
84
|
-
tr.replaceSelection(slice);
|
|
85
92
|
}
|
package/dist/esm/handlers.js
CHANGED
|
@@ -11,7 +11,7 @@ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
|
11
11
|
import { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
12
12
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
13
13
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
14
|
-
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
14
|
+
import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isListItemNode, isListNode, isNodeEmpty, isParagraph, isText, linkifyContent, mapSlice } from '@atlaskit/editor-common/utils';
|
|
15
15
|
import { closeHistory } from '@atlaskit/editor-prosemirror/history';
|
|
16
16
|
import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
17
17
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -20,7 +20,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
|
20
20
|
// TODO: ED-20519 Needs Macro extraction
|
|
21
21
|
|
|
22
22
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
23
|
-
import { insertSliceForLists, insertSliceForListsInsideBlockquote } from './edge-cases';
|
|
23
|
+
import { insertSliceForLists, insertSliceForListsInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
24
24
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
25
25
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType } from './util';
|
|
26
26
|
|
|
@@ -65,6 +65,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
|
|
|
65
65
|
selection = state.tr.selection;
|
|
66
66
|
var codeMark = schema.marks.code,
|
|
67
67
|
_schema$nodes = schema.nodes,
|
|
68
|
+
codeBlock = _schema$nodes.codeBlock,
|
|
68
69
|
decisionItem = _schema$nodes.decisionItem,
|
|
69
70
|
emoji = _schema$nodes.emoji,
|
|
70
71
|
hardBreak = _schema$nodes.hardBreak,
|
|
@@ -121,9 +122,29 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
|
|
|
121
122
|
// Whole codeblock node has reverse slice depths.
|
|
122
123
|
transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
|
|
123
124
|
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
125
|
+
} else if (['mediaSingle'].includes(transformedSlice.content.firstChild.type.name) && selectionIsPanel) {
|
|
126
|
+
var parentNode = findParentNodeOfType(panel)(selection);
|
|
127
|
+
if (selectionIsPanel && parentNode && isNodeEmpty(parentNode.node)) {
|
|
128
|
+
tr.insert(selection.$from.pos, transformedSlice.content).scrollIntoView();
|
|
129
|
+
// Place the cursor at the the end of the insersertion
|
|
130
|
+
var endPos = tr.selection.from + transformedSlice.size;
|
|
131
|
+
tr.setSelection(new TextSelection(tr.doc.resolve(endPos)));
|
|
132
|
+
} else {
|
|
133
|
+
tr.replaceSelection(transformedSlice).scrollIntoView();
|
|
134
|
+
}
|
|
124
135
|
} else {
|
|
125
136
|
// This maintains both the selection (destination) and the slice (paste content).
|
|
126
137
|
safeInsert(transformedSlice.content)(tr).scrollIntoView();
|
|
138
|
+
//safeInsert doesn't set correct cursor position inside codeBlock
|
|
139
|
+
//it moves the cursor to beginning of the codeblock
|
|
140
|
+
//we manually shift the cursor to end of the codeblock
|
|
141
|
+
var currentPosition = tr.selection.$from;
|
|
142
|
+
var currentNode = currentPosition.parent;
|
|
143
|
+
if (currentNode.type === codeBlock) {
|
|
144
|
+
var endPosOfCodeBlock = currentPosition.end();
|
|
145
|
+
var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
|
|
146
|
+
tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
|
|
147
|
+
}
|
|
127
148
|
}
|
|
128
149
|
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
129
150
|
if (dispatch) {
|
|
@@ -795,7 +816,7 @@ export function flattenNestedListInSlice(slice) {
|
|
|
795
816
|
}
|
|
796
817
|
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
797
818
|
return function (state, dispatch) {
|
|
798
|
-
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
819
|
+
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre, _slice$content$firstC3;
|
|
799
820
|
var _state$schema$nodes3 = state.schema.nodes,
|
|
800
821
|
codeBlock = _state$schema$nodes3.codeBlock,
|
|
801
822
|
heading = _state$schema$nodes3.heading,
|
|
@@ -878,6 +899,11 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
878
899
|
if (tr.selection.empty && tr.selection.$from.parent.type === codeBlock) {
|
|
879
900
|
tr.setSelection(TextSelection.near(tr.selection.$from, 1));
|
|
880
901
|
}
|
|
902
|
+
if (isInListItem(state) && ['taskList', 'taskItem'].includes(((_slice$content$firstC3 = slice.content.firstChild) === null || _slice$content$firstC3 === void 0 || (_slice$content$firstC3 = _slice$content$firstC3.type) === null || _slice$content$firstC3 === void 0 ? void 0 : _slice$content$firstC3.name) || '')) {
|
|
903
|
+
updateSelectionAfterReplace({
|
|
904
|
+
tr: tr
|
|
905
|
+
});
|
|
906
|
+
}
|
|
881
907
|
tr.scrollIntoView();
|
|
882
908
|
|
|
883
909
|
// queue link cards, ignoring any errors
|
|
@@ -8,4 +8,7 @@ export declare function insertSliceForLists({ tr, slice, schema, }: {
|
|
|
8
8
|
export declare function insertSliceForListsInsideBlockquote({ tr, slice, }: {
|
|
9
9
|
tr: Transaction;
|
|
10
10
|
slice: PMSlice;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function updateSelectionAfterReplace({ tr }: {
|
|
13
|
+
tr: Transaction;
|
|
11
14
|
}): Transaction | undefined;
|
|
@@ -8,4 +8,7 @@ export declare function insertSliceForLists({ tr, slice, schema, }: {
|
|
|
8
8
|
export declare function insertSliceForListsInsideBlockquote({ tr, slice, }: {
|
|
9
9
|
tr: Transaction;
|
|
10
10
|
slice: PMSlice;
|
|
11
|
+
}): void;
|
|
12
|
+
export declare function updateSelectionAfterReplace({ tr }: {
|
|
13
|
+
tr: Transaction;
|
|
11
14
|
}): Transaction | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"releaseModel": "continuous",
|
|
15
15
|
"runReact18": false
|
|
16
16
|
},
|
|
17
|
-
"repository": "https://bitbucket.org/atlassian/atlassian-frontend",
|
|
17
|
+
"repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
|
|
18
18
|
"main": "dist/cjs/index.js",
|
|
19
19
|
"module": "dist/esm/index.js",
|
|
20
20
|
"module:es2019": "dist/es2019/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^76.
|
|
36
|
+
"@atlaskit/editor-common": "^76.41.0",
|
|
37
37
|
"@atlaskit/editor-markdown-transformer": "^5.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
39
39
|
"@atlaskit/editor-plugin-annotation": "^0.1.0",
|