@atlaskit/editor-plugin-paste 1.0.6 → 1.0.8
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 +16 -0
- package/dist/cjs/edge-cases/index.js +2 -1
- package/dist/cjs/edge-cases/lists.js +14 -1
- package/dist/cjs/handlers.js +6 -1
- package/dist/cjs/pm-plugins/main.js +27 -19
- package/dist/es2019/edge-cases/index.js +2 -1
- package/dist/es2019/edge-cases/lists.js +15 -2
- package/dist/es2019/handlers.js +6 -1
- package/dist/es2019/pm-plugins/main.js +27 -19
- package/dist/esm/edge-cases/index.js +2 -1
- package/dist/esm/edge-cases/lists.js +14 -1
- package/dist/esm/handlers.js +6 -1
- package/dist/esm/pm-plugins/main.js +27 -19
- package/dist/types/edge-cases/lists.d.ts +3 -2
- package/dist/types-ts4.5/edge-cases/lists.d.ts +3 -2
- package/package.json +12 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 1.0.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#78591](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78591) [`578ff696d240`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/578ff696d240) - ED-22330 Adapted paste logic for empty panels in MBE.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 1.0.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#78224](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78224) [`6b4c9dd4ad34`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6b4c9dd4ad34) - ED-22219: adf-schema updated to 35.5.2
|
|
15
|
+
- [#76560](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76560) [`ecab0d093882`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ecab0d093882) - Fixed misplaced cursor positon when code block is pasted into extended nested expand
|
|
16
|
+
- [#78176](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78176) [`7482f69bb25f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7482f69bb25f) - ED-21833: Stop showing paste options toolbar for smart links
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 1.0.6
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
|
@@ -38,7 +38,8 @@ function insertSliceForLists(_ref) {
|
|
|
38
38
|
if (panelNode && (0, _util.isEmptyNode)(panelNode) && $from.node() === $to.node()) {
|
|
39
39
|
return (0, _lists.insertSliceInsideOfPanelNodeSelected)(panelNode)({
|
|
40
40
|
tr: tr,
|
|
41
|
-
slice: slice
|
|
41
|
+
slice: slice,
|
|
42
|
+
schema: schema
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
45
|
if (!$cursor || selectionIsInsideList) {
|
|
@@ -11,6 +11,8 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
11
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
13
|
var _transform = require("@atlaskit/editor-prosemirror/transform");
|
|
14
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
15
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
16
|
function insertSliceIntoEmptyNode(_ref) {
|
|
15
17
|
var tr = _ref.tr,
|
|
16
18
|
slice = _ref.slice;
|
|
@@ -69,7 +71,8 @@ function insertSliceIntoRangeSelectionInsideList(_ref4) {
|
|
|
69
71
|
function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
70
72
|
return function (_ref5) {
|
|
71
73
|
var tr = _ref5.tr,
|
|
72
|
-
slice = _ref5.slice
|
|
74
|
+
slice = _ref5.slice,
|
|
75
|
+
schema = _ref5.schema;
|
|
73
76
|
var selection = tr.selection,
|
|
74
77
|
_tr$selection2 = tr.selection,
|
|
75
78
|
$to = _tr$selection2.$to,
|
|
@@ -80,6 +83,16 @@ function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
|
80
83
|
if (panelNode && !panelNode.type.validContent(_model.Fragment.from(slice.content))) {
|
|
81
84
|
var _parentNode$firstChil;
|
|
82
85
|
var insertPosition = $to.pos + 1;
|
|
86
|
+
|
|
87
|
+
/* Adapting above logic to handle MBE, as it currently assumes that slice can be safely inserted after the panel node, which is not the case for MBE
|
|
88
|
+
If insertPosition is in MBE and current slice contains invalid content for MBE, we need to insert the slice after the MBE node
|
|
89
|
+
*/
|
|
90
|
+
if (schema && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.multi-bodied-extension_0rygg')) {
|
|
91
|
+
var mbeParentOfPanel = (0, _utils2.findParentNodeOfType)(schema.nodes.multiBodiedExtension)(selection);
|
|
92
|
+
if (mbeParentOfPanel && !mbeParentOfPanel.node.type.validContent(_model.Fragment.from(slice.content))) {
|
|
93
|
+
insertPosition = mbeParentOfPanel.start + mbeParentOfPanel.node.nodeSize - 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
83
96
|
tr.replaceRange(insertPosition, insertPosition, slice);
|
|
84
97
|
// need to delete the empty paragraph at the top of the panel
|
|
85
98
|
var parentNode = tr.doc.resolve($from.before()).node();
|
package/dist/cjs/handlers.js
CHANGED
|
@@ -931,7 +931,12 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
931
931
|
// need to make sure the cursor position is is right after the panel, expand, or decisionList
|
|
932
932
|
// still in the same table cell, see issue: https://product-fabric.atlassian.net/browse/ED-17862
|
|
933
933
|
var shouldUpdateCursorPosAfterPaste = ['panel', 'nestedExpand', 'decisionList', 'codeBlock'].includes(((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 || (_slice$content$lastCh = _slice$content$lastCh.type) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.name) || '');
|
|
934
|
-
|
|
934
|
+
var lastChild = slice.content.lastChild;
|
|
935
|
+
var $nextPos = tr.doc.resolve(tr.mapping.map(selection.from));
|
|
936
|
+
var nextSelection = lastChild !== null && lastChild !== void 0 && lastChild.type.isTextblock ? _state.TextSelection.findFrom($nextPos, -1, true) : new _selection.GapCursorSelection($nextPos, _selection.Side.RIGHT);
|
|
937
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.place-cursor-inside-text-block') && nextSelection) {
|
|
938
|
+
tr.setSelection(nextSelection);
|
|
939
|
+
} else if ((0, _utils.insideTableCell)(state) && shouldUpdateCursorPosAfterPaste) {
|
|
935
940
|
var nextPos = tr.doc.resolve(tr.mapping.map(selection.$from.pos));
|
|
936
941
|
tr.setSelection(new _selection.GapCursorSelection(nextPos, _selection.Side.RIGHT));
|
|
937
942
|
}
|
|
@@ -207,7 +207,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
207
207
|
}
|
|
208
208
|
// creating a custom dispatch because we want to add a meta whenever we do a paste.
|
|
209
209
|
var dispatch = function dispatch(tr) {
|
|
210
|
-
var _state$doc$resolve$no
|
|
210
|
+
var _state$doc$resolve$no;
|
|
211
211
|
// https://product-fabric.atlassian.net/browse/ED-12633
|
|
212
212
|
// don't add closeHistory call if we're pasting a text inside placeholder text as we want the whole action
|
|
213
213
|
// to be atomic
|
|
@@ -238,28 +238,36 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
238
238
|
var _pluginInjectionApi$b;
|
|
239
239
|
tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
|
|
240
240
|
}
|
|
241
|
+
var isDocChanged = tr.docChanged;
|
|
241
242
|
(0, _card.addLinkMetadata)(view.state.selection, tr, {
|
|
242
243
|
action: isPlainText ? _analytics.ACTION.PASTED_AS_PLAIN : _analytics.ACTION.PASTED,
|
|
243
244
|
inputMethod: _analytics.INPUT_METHOD.CLIPBOARD
|
|
244
245
|
});
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
246
|
+
|
|
247
|
+
// handleMacroAutoConvert dispatches twice
|
|
248
|
+
// we make sure to call paste options toolbar
|
|
249
|
+
// only for a valid paste action
|
|
250
|
+
if (isDocChanged) {
|
|
251
|
+
var _input;
|
|
252
|
+
var pasteStartPos = Math.min(state.selection.anchor, state.selection.head);
|
|
253
|
+
var pasteEndPos = tr.selection.to;
|
|
254
|
+
var contentPasted = {
|
|
255
|
+
pasteStartPos: pasteStartPos,
|
|
256
|
+
pasteEndPos: pasteEndPos,
|
|
257
|
+
text: text,
|
|
258
|
+
isShiftPressed: Boolean(
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
260
|
+
view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey)),
|
|
261
|
+
isPlainText: Boolean(isPlainText),
|
|
262
|
+
pastedSlice: tr.doc.slice(pasteStartPos, pasteEndPos),
|
|
263
|
+
pastedAt: Date.now(),
|
|
264
|
+
pasteSource: (0, _util.getPasteSource)(event)
|
|
265
|
+
};
|
|
266
|
+
tr.setMeta(_pluginFactory.pluginKey, {
|
|
267
|
+
type: _actions.PastePluginActionTypes.ON_PASTE,
|
|
268
|
+
contentPasted: contentPasted
|
|
269
|
+
});
|
|
270
|
+
}
|
|
263
271
|
view.dispatch(tr);
|
|
264
272
|
};
|
|
265
273
|
slice = (0, _handlers.handleParagraphBlockMarks)(state, slice);
|
|
@@ -34,7 +34,8 @@ export function insertSliceForLists({
|
|
|
34
34
|
if (panelNode && isEmptyNode(panelNode) && $from.node() === $to.node()) {
|
|
35
35
|
return insertSliceInsideOfPanelNodeSelected(panelNode)({
|
|
36
36
|
tr,
|
|
37
|
-
slice
|
|
37
|
+
slice,
|
|
38
|
+
schema
|
|
38
39
|
});
|
|
39
40
|
}
|
|
40
41
|
if (!$cursor || selectionIsInsideList) {
|
|
@@ -2,6 +2,8 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { Transform } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
export function insertSliceIntoEmptyNode({
|
|
6
8
|
tr,
|
|
7
9
|
slice
|
|
@@ -69,7 +71,8 @@ export function insertSliceIntoRangeSelectionInsideList({
|
|
|
69
71
|
export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
70
72
|
return ({
|
|
71
73
|
tr,
|
|
72
|
-
slice
|
|
74
|
+
slice,
|
|
75
|
+
schema
|
|
73
76
|
}) => {
|
|
74
77
|
const {
|
|
75
78
|
selection,
|
|
@@ -85,7 +88,17 @@ export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
|
85
88
|
// if content of slice isn't valid for a panel node, insert the invalid node and following content after
|
|
86
89
|
if (panelNode && !panelNode.type.validContent(Fragment.from(slice.content))) {
|
|
87
90
|
var _parentNode$firstChil;
|
|
88
|
-
|
|
91
|
+
let insertPosition = $to.pos + 1;
|
|
92
|
+
|
|
93
|
+
/* Adapting above logic to handle MBE, as it currently assumes that slice can be safely inserted after the panel node, which is not the case for MBE
|
|
94
|
+
If insertPosition is in MBE and current slice contains invalid content for MBE, we need to insert the slice after the MBE node
|
|
95
|
+
*/
|
|
96
|
+
if (schema && getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
|
|
97
|
+
const mbeParentOfPanel = findParentNodeOfType(schema.nodes.multiBodiedExtension)(selection);
|
|
98
|
+
if (mbeParentOfPanel && !mbeParentOfPanel.node.type.validContent(Fragment.from(slice.content))) {
|
|
99
|
+
insertPosition = mbeParentOfPanel.start + mbeParentOfPanel.node.nodeSize - 1;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
89
102
|
tr.replaceRange(insertPosition, insertPosition, slice);
|
|
90
103
|
// need to delete the empty paragraph at the top of the panel
|
|
91
104
|
const parentNode = tr.doc.resolve($from.before()).node();
|
package/dist/es2019/handlers.js
CHANGED
|
@@ -908,7 +908,12 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
908
908
|
// need to make sure the cursor position is is right after the panel, expand, or decisionList
|
|
909
909
|
// still in the same table cell, see issue: https://product-fabric.atlassian.net/browse/ED-17862
|
|
910
910
|
const shouldUpdateCursorPosAfterPaste = ['panel', 'nestedExpand', 'decisionList', 'codeBlock'].includes(((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 ? void 0 : (_slice$content$lastCh2 = _slice$content$lastCh.type) === null || _slice$content$lastCh2 === void 0 ? void 0 : _slice$content$lastCh2.name) || '');
|
|
911
|
-
|
|
911
|
+
const lastChild = slice.content.lastChild;
|
|
912
|
+
const $nextPos = tr.doc.resolve(tr.mapping.map(selection.from));
|
|
913
|
+
const nextSelection = lastChild !== null && lastChild !== void 0 && lastChild.type.isTextblock ? TextSelection.findFrom($nextPos, -1, true) : new GapCursorSelection($nextPos, Side.RIGHT);
|
|
914
|
+
if (getBooleanFF('platform.editor.place-cursor-inside-text-block') && nextSelection) {
|
|
915
|
+
tr.setSelection(nextSelection);
|
|
916
|
+
} else if (insideTableCell(state) && shouldUpdateCursorPosAfterPaste) {
|
|
912
917
|
const nextPos = tr.doc.resolve(tr.mapping.map(selection.$from.pos));
|
|
913
918
|
tr.setSelection(new GapCursorSelection(nextPos, Side.RIGHT));
|
|
914
919
|
}
|
|
@@ -174,7 +174,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
174
174
|
}
|
|
175
175
|
// creating a custom dispatch because we want to add a meta whenever we do a paste.
|
|
176
176
|
const dispatch = tr => {
|
|
177
|
-
var _state$doc$resolve$no
|
|
177
|
+
var _state$doc$resolve$no;
|
|
178
178
|
// https://product-fabric.atlassian.net/browse/ED-12633
|
|
179
179
|
// don't add closeHistory call if we're pasting a text inside placeholder text as we want the whole action
|
|
180
180
|
// to be atomic
|
|
@@ -207,28 +207,36 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
207
207
|
var _pluginInjectionApi$b;
|
|
208
208
|
tr = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
|
|
209
209
|
}
|
|
210
|
+
const isDocChanged = tr.docChanged;
|
|
210
211
|
addLinkMetadata(view.state.selection, tr, {
|
|
211
212
|
action: isPlainText ? ACTION.PASTED_AS_PLAIN : ACTION.PASTED,
|
|
212
213
|
inputMethod: INPUT_METHOD.CLIPBOARD
|
|
213
214
|
});
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
215
|
+
|
|
216
|
+
// handleMacroAutoConvert dispatches twice
|
|
217
|
+
// we make sure to call paste options toolbar
|
|
218
|
+
// only for a valid paste action
|
|
219
|
+
if (isDocChanged) {
|
|
220
|
+
var _input;
|
|
221
|
+
const pasteStartPos = Math.min(state.selection.anchor, state.selection.head);
|
|
222
|
+
const pasteEndPos = tr.selection.to;
|
|
223
|
+
const contentPasted = {
|
|
224
|
+
pasteStartPos,
|
|
225
|
+
pasteEndPos,
|
|
226
|
+
text,
|
|
227
|
+
isShiftPressed: Boolean(
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey)),
|
|
230
|
+
isPlainText: Boolean(isPlainText),
|
|
231
|
+
pastedSlice: tr.doc.slice(pasteStartPos, pasteEndPos),
|
|
232
|
+
pastedAt: Date.now(),
|
|
233
|
+
pasteSource: getPasteSource(event)
|
|
234
|
+
};
|
|
235
|
+
tr.setMeta(stateKey, {
|
|
236
|
+
type: PastePluginActionTypes.ON_PASTE,
|
|
237
|
+
contentPasted
|
|
238
|
+
});
|
|
239
|
+
}
|
|
232
240
|
view.dispatch(tr);
|
|
233
241
|
};
|
|
234
242
|
slice = handleParagraphBlockMarks(state, slice);
|
|
@@ -29,7 +29,8 @@ export function insertSliceForLists(_ref) {
|
|
|
29
29
|
if (panelNode && isEmptyNode(panelNode) && $from.node() === $to.node()) {
|
|
30
30
|
return insertSliceInsideOfPanelNodeSelected(panelNode)({
|
|
31
31
|
tr: tr,
|
|
32
|
-
slice: slice
|
|
32
|
+
slice: slice,
|
|
33
|
+
schema: schema
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
36
|
if (!$cursor || selectionIsInsideList) {
|
|
@@ -2,6 +2,8 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { Transform } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
+
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
7
|
export function insertSliceIntoEmptyNode(_ref) {
|
|
6
8
|
var tr = _ref.tr,
|
|
7
9
|
slice = _ref.slice;
|
|
@@ -60,7 +62,8 @@ export function insertSliceIntoRangeSelectionInsideList(_ref4) {
|
|
|
60
62
|
export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
61
63
|
return function (_ref5) {
|
|
62
64
|
var tr = _ref5.tr,
|
|
63
|
-
slice = _ref5.slice
|
|
65
|
+
slice = _ref5.slice,
|
|
66
|
+
schema = _ref5.schema;
|
|
64
67
|
var selection = tr.selection,
|
|
65
68
|
_tr$selection2 = tr.selection,
|
|
66
69
|
$to = _tr$selection2.$to,
|
|
@@ -71,6 +74,16 @@ export function insertSliceInsideOfPanelNodeSelected(panelNode) {
|
|
|
71
74
|
if (panelNode && !panelNode.type.validContent(Fragment.from(slice.content))) {
|
|
72
75
|
var _parentNode$firstChil;
|
|
73
76
|
var insertPosition = $to.pos + 1;
|
|
77
|
+
|
|
78
|
+
/* Adapting above logic to handle MBE, as it currently assumes that slice can be safely inserted after the panel node, which is not the case for MBE
|
|
79
|
+
If insertPosition is in MBE and current slice contains invalid content for MBE, we need to insert the slice after the MBE node
|
|
80
|
+
*/
|
|
81
|
+
if (schema && getBooleanFF('platform.editor.multi-bodied-extension_0rygg')) {
|
|
82
|
+
var mbeParentOfPanel = findParentNodeOfType(schema.nodes.multiBodiedExtension)(selection);
|
|
83
|
+
if (mbeParentOfPanel && !mbeParentOfPanel.node.type.validContent(Fragment.from(slice.content))) {
|
|
84
|
+
insertPosition = mbeParentOfPanel.start + mbeParentOfPanel.node.nodeSize - 1;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
74
87
|
tr.replaceRange(insertPosition, insertPosition, slice);
|
|
75
88
|
// need to delete the empty paragraph at the top of the panel
|
|
76
89
|
var parentNode = tr.doc.resolve($from.before()).node();
|
package/dist/esm/handlers.js
CHANGED
|
@@ -909,7 +909,12 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
909
909
|
// need to make sure the cursor position is is right after the panel, expand, or decisionList
|
|
910
910
|
// still in the same table cell, see issue: https://product-fabric.atlassian.net/browse/ED-17862
|
|
911
911
|
var shouldUpdateCursorPosAfterPaste = ['panel', 'nestedExpand', 'decisionList', 'codeBlock'].includes(((_slice$content$lastCh = slice.content.lastChild) === null || _slice$content$lastCh === void 0 || (_slice$content$lastCh = _slice$content$lastCh.type) === null || _slice$content$lastCh === void 0 ? void 0 : _slice$content$lastCh.name) || '');
|
|
912
|
-
|
|
912
|
+
var lastChild = slice.content.lastChild;
|
|
913
|
+
var $nextPos = tr.doc.resolve(tr.mapping.map(selection.from));
|
|
914
|
+
var nextSelection = lastChild !== null && lastChild !== void 0 && lastChild.type.isTextblock ? TextSelection.findFrom($nextPos, -1, true) : new GapCursorSelection($nextPos, Side.RIGHT);
|
|
915
|
+
if (getBooleanFF('platform.editor.place-cursor-inside-text-block') && nextSelection) {
|
|
916
|
+
tr.setSelection(nextSelection);
|
|
917
|
+
} else if (insideTableCell(state) && shouldUpdateCursorPosAfterPaste) {
|
|
913
918
|
var nextPos = tr.doc.resolve(tr.mapping.map(selection.$from.pos));
|
|
914
919
|
tr.setSelection(new GapCursorSelection(nextPos, Side.RIGHT));
|
|
915
920
|
}
|
|
@@ -194,7 +194,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
194
194
|
}
|
|
195
195
|
// creating a custom dispatch because we want to add a meta whenever we do a paste.
|
|
196
196
|
var dispatch = function dispatch(tr) {
|
|
197
|
-
var _state$doc$resolve$no
|
|
197
|
+
var _state$doc$resolve$no;
|
|
198
198
|
// https://product-fabric.atlassian.net/browse/ED-12633
|
|
199
199
|
// don't add closeHistory call if we're pasting a text inside placeholder text as we want the whole action
|
|
200
200
|
// to be atomic
|
|
@@ -225,28 +225,36 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
225
225
|
var _pluginInjectionApi$b;
|
|
226
226
|
tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
|
|
227
227
|
}
|
|
228
|
+
var isDocChanged = tr.docChanged;
|
|
228
229
|
addLinkMetadata(view.state.selection, tr, {
|
|
229
230
|
action: isPlainText ? ACTION.PASTED_AS_PLAIN : ACTION.PASTED,
|
|
230
231
|
inputMethod: INPUT_METHOD.CLIPBOARD
|
|
231
232
|
});
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
233
|
+
|
|
234
|
+
// handleMacroAutoConvert dispatches twice
|
|
235
|
+
// we make sure to call paste options toolbar
|
|
236
|
+
// only for a valid paste action
|
|
237
|
+
if (isDocChanged) {
|
|
238
|
+
var _input;
|
|
239
|
+
var pasteStartPos = Math.min(state.selection.anchor, state.selection.head);
|
|
240
|
+
var pasteEndPos = tr.selection.to;
|
|
241
|
+
var contentPasted = {
|
|
242
|
+
pasteStartPos: pasteStartPos,
|
|
243
|
+
pasteEndPos: pasteEndPos,
|
|
244
|
+
text: text,
|
|
245
|
+
isShiftPressed: Boolean(
|
|
246
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
247
|
+
view.shiftKey || ((_input = view.input) === null || _input === void 0 ? void 0 : _input.shiftKey)),
|
|
248
|
+
isPlainText: Boolean(isPlainText),
|
|
249
|
+
pastedSlice: tr.doc.slice(pasteStartPos, pasteEndPos),
|
|
250
|
+
pastedAt: Date.now(),
|
|
251
|
+
pasteSource: getPasteSource(event)
|
|
252
|
+
};
|
|
253
|
+
tr.setMeta(stateKey, {
|
|
254
|
+
type: PastePluginActionTypes.ON_PASTE,
|
|
255
|
+
contentPasted: contentPasted
|
|
256
|
+
});
|
|
257
|
+
}
|
|
250
258
|
view.dispatch(tr);
|
|
251
259
|
};
|
|
252
260
|
slice = handleParagraphBlockMarks(state, slice);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare function insertSliceIntoEmptyNode({ tr, slice, }: {
|
|
4
4
|
tr: Transaction;
|
|
@@ -12,7 +12,8 @@ export declare function insertSliceIntoRangeSelectionInsideList({ tr, slice, }:
|
|
|
12
12
|
tr: Transaction;
|
|
13
13
|
slice: Slice;
|
|
14
14
|
}): Transaction | undefined;
|
|
15
|
-
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice }: {
|
|
15
|
+
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice, schema, }: {
|
|
16
16
|
tr: Transaction;
|
|
17
17
|
slice: Slice;
|
|
18
|
+
schema?: Schema<any, any> | undefined;
|
|
18
19
|
}) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
1
|
+
import type { Node as PMNode, Schema, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export declare function insertSliceIntoEmptyNode({ tr, slice, }: {
|
|
4
4
|
tr: Transaction;
|
|
@@ -12,7 +12,8 @@ export declare function insertSliceIntoRangeSelectionInsideList({ tr, slice, }:
|
|
|
12
12
|
tr: Transaction;
|
|
13
13
|
slice: Slice;
|
|
14
14
|
}): Transaction | undefined;
|
|
15
|
-
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice }: {
|
|
15
|
+
export declare function insertSliceInsideOfPanelNodeSelected(panelNode: PMNode): ({ tr, slice, schema, }: {
|
|
16
16
|
tr: Transaction;
|
|
17
17
|
slice: Slice;
|
|
18
|
+
schema?: Schema<any, any> | undefined;
|
|
18
19
|
}) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
".": "./src/index.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/editor-common": "^78.
|
|
36
|
+
"@atlaskit/editor-common": "^78.11.0",
|
|
37
37
|
"@atlaskit/editor-markdown-transformer": "^5.4.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
39
|
-
"@atlaskit/editor-plugin-annotation": "^1.
|
|
39
|
+
"@atlaskit/editor-plugin-annotation": "^1.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-better-type-history": "^1.0.0",
|
|
41
|
-
"@atlaskit/editor-plugin-card": "^1.
|
|
41
|
+
"@atlaskit/editor-plugin-card": "^1.1.0",
|
|
42
42
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
43
43
|
"@atlaskit/editor-plugin-list": "^3.1.0",
|
|
44
|
-
"@atlaskit/editor-plugin-media": "^1.
|
|
44
|
+
"@atlaskit/editor-plugin-media": "^1.7.0",
|
|
45
45
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
46
46
|
"@atlaskit/editor-tables": "^2.5.0",
|
|
47
47
|
"@atlaskit/media-client": "^26.2.0",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@af/visual-regression": "*",
|
|
59
|
-
"@atlaskit/adf-schema": "^35.5.
|
|
59
|
+
"@atlaskit/adf-schema": "^35.5.2",
|
|
60
60
|
"@atlaskit/editor-plugin-block-type": "^3.0.0",
|
|
61
61
|
"@atlaskit/editor-plugin-history": "^1.0.0",
|
|
62
62
|
"@atlaskit/editor-plugin-type-ahead": "^1.0.0",
|
|
@@ -128,6 +128,12 @@
|
|
|
128
128
|
},
|
|
129
129
|
"platform.editor.handle-paste-for-action-in-panel": {
|
|
130
130
|
"type": "boolean"
|
|
131
|
+
},
|
|
132
|
+
"platform.editor.place-cursor-inside-text-block": {
|
|
133
|
+
"type": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"platform.editor.multi-bodied-extension_0rygg": {
|
|
136
|
+
"type": "boolean"
|
|
131
137
|
}
|
|
132
138
|
}
|
|
133
139
|
}
|