@atlaskit/editor-plugin-paste 0.2.6 → 0.2.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 0.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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
8
+
9
+ ## 0.2.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [#64972](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64972) [`a72ac4c06038`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a72ac4c06038) - ED-21627 Fixed issue with parsing of task as string - when pasting into an existing task
14
+
3
15
  ## 0.2.6
4
16
 
5
17
  ### Patch Changes
@@ -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,
@@ -131,8 +132,9 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
131
132
  filters.push((0, _util.applyTextMarksToSlice)(schema, selection.$head.marks()));
132
133
  }
133
134
  var transformedSlice = compose.apply(null, filters)(slice);
135
+ var isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
134
136
  var tr = (0, _history.closeHistory)(state.tr);
135
- var transformedSliceIsValidNode = transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskList', 'taskItem', 'panel'].includes(transformedSlice.content.firstChild.type.name) && !(0, _utils.isInListItem)(state);
137
+ var transformedSliceIsValidNode = (transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskItem', 'taskList', 'panel'].includes(transformedSlice.content.firstChild.type.name)) && (!(0, _utils.isInListItem)(state) || (0, _utils.isInListItem)(state) && isFirstChildTaskNode);
136
138
  // If the slice or the selection are valid nodes to handle,
137
139
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
138
140
  // or the slice's first node is a paragraph,
@@ -144,6 +146,16 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
144
146
  } else {
145
147
  // This maintains both the selection (destination) and the slice (paste content).
146
148
  (0, _utils2.safeInsert)(transformedSlice.content)(tr).scrollIntoView();
149
+ //safeInsert doesn't set correct cursor position inside codeBlock
150
+ //it moves the cursor to beginning of the codeblock
151
+ //we manually shift the cursor to end of the codeblock
152
+ var currentPosition = tr.selection.$from;
153
+ var currentNode = currentPosition.parent;
154
+ if (currentNode.type === codeBlock) {
155
+ var endPosOfCodeBlock = currentPosition.end();
156
+ var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
157
+ tr.setSelection(new _state.TextSelection(endResolvedPosition, endResolvedPosition));
158
+ }
147
159
  }
148
160
  queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, _analytics.INPUT_METHOD.CLIPBOARD);
149
161
  if (dispatch) {
@@ -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,
@@ -107,8 +108,9 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
107
108
  filters.push(applyTextMarksToSlice(schema, selection.$head.marks()));
108
109
  }
109
110
  const transformedSlice = compose.apply(null, filters)(slice);
111
+ const isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
110
112
  const tr = closeHistory(state.tr);
111
- const transformedSliceIsValidNode = transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskList', 'taskItem', 'panel'].includes(transformedSlice.content.firstChild.type.name) && !isInListItem(state);
113
+ const transformedSliceIsValidNode = (transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskItem', 'taskList', 'panel'].includes(transformedSlice.content.firstChild.type.name)) && (!isInListItem(state) || isInListItem(state) && isFirstChildTaskNode);
112
114
  // If the slice or the selection are valid nodes to handle,
113
115
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
114
116
  // or the slice's first node is a paragraph,
@@ -120,6 +122,16 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
120
122
  } else {
121
123
  // This maintains both the selection (destination) and the slice (paste content).
122
124
  safeInsert(transformedSlice.content)(tr).scrollIntoView();
125
+ //safeInsert doesn't set correct cursor position inside codeBlock
126
+ //it moves the cursor to beginning of the codeblock
127
+ //we manually shift the cursor to end of the codeblock
128
+ const currentPosition = tr.selection.$from;
129
+ const currentNode = currentPosition.parent;
130
+ if (currentNode.type === codeBlock) {
131
+ const endPosOfCodeBlock = currentPosition.end();
132
+ const endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
133
+ tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
134
+ }
123
135
  }
124
136
  queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
125
137
  if (dispatch) {
@@ -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,
@@ -110,8 +111,9 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
110
111
  filters.push(applyTextMarksToSlice(schema, selection.$head.marks()));
111
112
  }
112
113
  var transformedSlice = compose.apply(null, filters)(slice);
114
+ var isFirstChildTaskNode = transformedSlice.content.firstChild.type === taskList || transformedSlice.content.firstChild.type === taskItem;
113
115
  var tr = closeHistory(state.tr);
114
- var transformedSliceIsValidNode = transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskList', 'taskItem', 'panel'].includes(transformedSlice.content.firstChild.type.name) && !isInListItem(state);
116
+ var transformedSliceIsValidNode = (transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskItem', 'taskList', 'panel'].includes(transformedSlice.content.firstChild.type.name)) && (!isInListItem(state) || isInListItem(state) && isFirstChildTaskNode);
115
117
  // If the slice or the selection are valid nodes to handle,
116
118
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
117
119
  // or the slice's first node is a paragraph,
@@ -123,6 +125,16 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
123
125
  } else {
124
126
  // This maintains both the selection (destination) and the slice (paste content).
125
127
  safeInsert(transformedSlice.content)(tr).scrollIntoView();
128
+ //safeInsert doesn't set correct cursor position inside codeBlock
129
+ //it moves the cursor to beginning of the codeblock
130
+ //we manually shift the cursor to end of the codeblock
131
+ var currentPosition = tr.selection.$from;
132
+ var currentNode = currentPosition.parent;
133
+ if (currentNode.type === codeBlock) {
134
+ var endPosOfCodeBlock = currentPosition.end();
135
+ var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
136
+ tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
137
+ }
126
138
  }
127
139
  queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
128
140
  if (dispatch) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,8 +33,8 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^76.36.0",
37
- "@atlaskit/editor-markdown-transformer": "^5.2.5",
36
+ "@atlaskit/editor-common": "^76.39.0",
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",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^0.1.0",