@atlaskit/editor-plugin-paste 0.2.15 → 0.2.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 0.2.16
4
+
5
+ ### Patch Changes
6
+
7
+ - [#69736](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/69736) [`febb7827b916`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/febb7827b916) - ED-21619 Set correct cursor position on pasting a rule inside panel
8
+ - Updated dependencies
9
+
3
10
  ## 0.2.15
4
11
 
5
12
  ### Patch Changes
@@ -159,17 +159,17 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
159
159
  if (pastingDecisionIntoExtendedPanel && selectionIsValidNode) {
160
160
  tr.replaceSelection(transformedSlice).scrollIntoView();
161
161
  } else {
162
+ var _transformedSlice$con2;
162
163
  // This maintains both the selection (destination) and the slice (paste content).
163
164
  (0, _utils2.safeInsert)(transformedSlice.content)(tr).scrollIntoView();
164
- //safeInsert doesn't set correct cursor position inside codeBlock or decision
165
- //it moves the cursor to beginning of the node
166
- //we manually shift the cursor to end of the codeblock
167
- var currentPosition = tr.selection.$from;
168
- var currentNode = currentPosition.parent;
169
- if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
170
- var endPosOfNode = currentPosition.end();
171
- var endResolvedPosition = tr.doc.resolve(endPosOfNode);
172
- tr.setSelection(new _state.TextSelection(endResolvedPosition, endResolvedPosition));
165
+ if (((_transformedSlice$con2 = transformedSlice.content.lastChild) === null || _transformedSlice$con2 === void 0 || (_transformedSlice$con2 = _transformedSlice$con2.type) === null || _transformedSlice$con2 === void 0 ? void 0 : _transformedSlice$con2.name) === 'rule') {
166
+ tr.setSelection(_state.TextSelection.near(tr.doc.resolve(selection.$from.pos + transformedSlice.content.size)));
167
+ } else {
168
+ // safeInsert doesn't set correct cursor position
169
+ // it moves the cursor to beginning of the node
170
+ // we manually shift the cursor to end of the node
171
+ var nextPos = tr.doc.resolve(tr.selection.$from.end());
172
+ tr.setSelection(new _state.TextSelection(nextPos));
173
173
  }
174
174
  }
175
175
  }
@@ -134,17 +134,17 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
134
134
  if (pastingDecisionIntoExtendedPanel && selectionIsValidNode) {
135
135
  tr.replaceSelection(transformedSlice).scrollIntoView();
136
136
  } else {
137
+ var _transformedSlice$con2, _transformedSlice$con3;
137
138
  // This maintains both the selection (destination) and the slice (paste content).
138
139
  safeInsert(transformedSlice.content)(tr).scrollIntoView();
139
- //safeInsert doesn't set correct cursor position inside codeBlock or decision
140
- //it moves the cursor to beginning of the node
141
- //we manually shift the cursor to end of the codeblock
142
- const currentPosition = tr.selection.$from;
143
- const currentNode = currentPosition.parent;
144
- if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
145
- const endPosOfNode = currentPosition.end();
146
- const endResolvedPosition = tr.doc.resolve(endPosOfNode);
147
- tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
140
+ if (((_transformedSlice$con2 = transformedSlice.content.lastChild) === null || _transformedSlice$con2 === void 0 ? void 0 : (_transformedSlice$con3 = _transformedSlice$con2.type) === null || _transformedSlice$con3 === void 0 ? void 0 : _transformedSlice$con3.name) === 'rule') {
141
+ tr.setSelection(TextSelection.near(tr.doc.resolve(selection.$from.pos + transformedSlice.content.size)));
142
+ } else {
143
+ // safeInsert doesn't set correct cursor position
144
+ // it moves the cursor to beginning of the node
145
+ // we manually shift the cursor to end of the node
146
+ const nextPos = tr.doc.resolve(tr.selection.$from.end());
147
+ tr.setSelection(new TextSelection(nextPos));
148
148
  }
149
149
  }
150
150
  }
@@ -137,17 +137,17 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
137
137
  if (pastingDecisionIntoExtendedPanel && selectionIsValidNode) {
138
138
  tr.replaceSelection(transformedSlice).scrollIntoView();
139
139
  } else {
140
+ var _transformedSlice$con2;
140
141
  // This maintains both the selection (destination) and the slice (paste content).
141
142
  safeInsert(transformedSlice.content)(tr).scrollIntoView();
142
- //safeInsert doesn't set correct cursor position inside codeBlock or decision
143
- //it moves the cursor to beginning of the node
144
- //we manually shift the cursor to end of the codeblock
145
- var currentPosition = tr.selection.$from;
146
- var currentNode = currentPosition.parent;
147
- if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
148
- var endPosOfNode = currentPosition.end();
149
- var endResolvedPosition = tr.doc.resolve(endPosOfNode);
150
- tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
143
+ if (((_transformedSlice$con2 = transformedSlice.content.lastChild) === null || _transformedSlice$con2 === void 0 || (_transformedSlice$con2 = _transformedSlice$con2.type) === null || _transformedSlice$con2 === void 0 ? void 0 : _transformedSlice$con2.name) === 'rule') {
144
+ tr.setSelection(TextSelection.near(tr.doc.resolve(selection.$from.pos + transformedSlice.content.size)));
145
+ } else {
146
+ // safeInsert doesn't set correct cursor position
147
+ // it moves the cursor to beginning of the node
148
+ // we manually shift the cursor to end of the node
149
+ var nextPos = tr.doc.resolve(tr.selection.$from.end());
150
+ tr.setSelection(new TextSelection(nextPos));
151
151
  }
152
152
  }
153
153
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "0.2.15",
3
+ "version": "0.2.16",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,7 +36,7 @@
36
36
  "@atlaskit/editor-common": "^77.1.0",
37
37
  "@atlaskit/editor-markdown-transformer": "^5.3.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^0.4.0",
39
- "@atlaskit/editor-plugin-annotation": "^0.2.0",
39
+ "@atlaskit/editor-plugin-annotation": "^0.3.0",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^0.1.0",
41
41
  "@atlaskit/editor-plugin-card": "^0.16.0",
42
42
  "@atlaskit/editor-plugin-feature-flags": "^1.0.0",