@atlaskit/editor-plugin-paste 0.2.9 → 0.2.11

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.11
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 0.2.10
10
+
11
+ ### Patch Changes
12
+
13
+ - [#67922](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67922) [`cd95401d8cde`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cd95401d8cde) - ED-21865 Set correct cursor position when decision is pasted inside panel
14
+
3
15
  ## 0.2.9
4
16
 
5
17
  ### Patch Changes
@@ -36,6 +36,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
36
36
  var _state = require("@atlaskit/editor-prosemirror/state");
37
37
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
38
38
  var _utils3 = require("@atlaskit/editor-tables/utils");
39
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
39
40
  var _commands = require("./commands");
40
41
  var _edgeCases = require("./edge-cases");
41
42
  var _pluginFactory = require("./pm-plugins/plugin-factory");
@@ -86,7 +87,6 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
86
87
  selection = state.tr.selection;
87
88
  var codeMark = schema.marks.code,
88
89
  _schema$nodes = schema.nodes,
89
- codeBlock = _schema$nodes.codeBlock,
90
90
  decisionItem = _schema$nodes.decisionItem,
91
91
  emoji = _schema$nodes.emoji,
92
92
  hardBreak = _schema$nodes.hardBreak,
@@ -139,7 +139,8 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
139
139
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
140
140
  // or the slice's first node is a paragraph,
141
141
  // then we can replace the selection with our slice.
142
- if ((transformedSliceIsValidNode || selectionIsValidNode) && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
142
+ var pastingDecisionIntoExtendedPanel = selectionIsPanel && transformedSlice.content.firstChild.type.name === 'decisionList' && (0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-extended-panel');
143
+ if ((transformedSliceIsValidNode || selectionIsValidNode) && !pastingDecisionIntoExtendedPanel && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
143
144
  // Whole codeblock node has reverse slice depths.
144
145
  transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
145
146
  tr.replaceSelection(transformedSlice).scrollIntoView();
@@ -156,14 +157,14 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
156
157
  } else {
157
158
  // This maintains both the selection (destination) and the slice (paste content).
158
159
  (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
160
+ //safeInsert doesn't set correct cursor position inside codeBlock or decision
161
+ //it moves the cursor to beginning of the node
161
162
  //we manually shift the cursor to end of the codeblock
162
163
  var currentPosition = tr.selection.$from;
163
164
  var currentNode = currentPosition.parent;
164
- if (currentNode.type === codeBlock) {
165
- var endPosOfCodeBlock = currentPosition.end();
166
- var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
165
+ if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
166
+ var endPosOfNode = currentPosition.end();
167
+ var endResolvedPosition = tr.doc.resolve(endPosOfNode);
167
168
  tr.setSelection(new _state.TextSelection(endResolvedPosition, endResolvedPosition));
168
169
  }
169
170
  }
@@ -9,6 +9,7 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
9
9
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
10
  import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
12
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
13
  // TODO: ED-20519 Needs Macro extraction
13
14
 
14
15
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
@@ -60,7 +61,6 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
60
61
  code: codeMark
61
62
  },
62
63
  nodes: {
63
- codeBlock,
64
64
  decisionItem,
65
65
  emoji,
66
66
  hardBreak,
@@ -115,7 +115,8 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
115
115
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
116
116
  // or the slice's first node is a paragraph,
117
117
  // then we can replace the selection with our slice.
118
- if ((transformedSliceIsValidNode || selectionIsValidNode) && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
118
+ const pastingDecisionIntoExtendedPanel = selectionIsPanel && transformedSlice.content.firstChild.type.name === 'decisionList' && getBooleanFF('platform.editor.allow-extended-panel');
119
+ if ((transformedSliceIsValidNode || selectionIsValidNode) && !pastingDecisionIntoExtendedPanel && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
119
120
  // Whole codeblock node has reverse slice depths.
120
121
  transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
121
122
  tr.replaceSelection(transformedSlice).scrollIntoView();
@@ -132,14 +133,14 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
132
133
  } else {
133
134
  // This maintains both the selection (destination) and the slice (paste content).
134
135
  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
136
+ //safeInsert doesn't set correct cursor position inside codeBlock or decision
137
+ //it moves the cursor to beginning of the node
137
138
  //we manually shift the cursor to end of the codeblock
138
139
  const currentPosition = tr.selection.$from;
139
140
  const currentNode = currentPosition.parent;
140
- if (currentNode.type === codeBlock) {
141
- const endPosOfCodeBlock = currentPosition.end();
142
- const endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
141
+ if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
142
+ const endPosOfNode = currentPosition.end();
143
+ const endResolvedPosition = tr.doc.resolve(endPosOfNode);
143
144
  tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
144
145
  }
145
146
  }
@@ -17,6 +17,7 @@ import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/mo
17
17
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
18
18
  import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
19
19
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
20
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
20
21
  // TODO: ED-20519 Needs Macro extraction
21
22
 
22
23
  import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
@@ -65,7 +66,6 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
65
66
  selection = state.tr.selection;
66
67
  var codeMark = schema.marks.code,
67
68
  _schema$nodes = schema.nodes,
68
- codeBlock = _schema$nodes.codeBlock,
69
69
  decisionItem = _schema$nodes.decisionItem,
70
70
  emoji = _schema$nodes.emoji,
71
71
  hardBreak = _schema$nodes.hardBreak,
@@ -118,7 +118,8 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
118
118
  // and the slice is not a whole node (i.e. openStart is 1 and openEnd is 0)
119
119
  // or the slice's first node is a paragraph,
120
120
  // then we can replace the selection with our slice.
121
- if ((transformedSliceIsValidNode || selectionIsValidNode) && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
121
+ var pastingDecisionIntoExtendedPanel = selectionIsPanel && transformedSlice.content.firstChild.type.name === 'decisionList' && getBooleanFF('platform.editor.allow-extended-panel');
122
+ if ((transformedSliceIsValidNode || selectionIsValidNode) && !pastingDecisionIntoExtendedPanel && !(transformedSlice.openStart === 1 && transformedSlice.openEnd === 0 ||
122
123
  // Whole codeblock node has reverse slice depths.
123
124
  transformedSlice.openStart === 0 && transformedSlice.openEnd === 1) || ((_transformedSlice$con = transformedSlice.content.firstChild) === null || _transformedSlice$con === void 0 ? void 0 : _transformedSlice$con.type) === paragraph) {
124
125
  tr.replaceSelection(transformedSlice).scrollIntoView();
@@ -135,14 +136,14 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
135
136
  } else {
136
137
  // This maintains both the selection (destination) and the slice (paste content).
137
138
  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
139
+ //safeInsert doesn't set correct cursor position inside codeBlock or decision
140
+ //it moves the cursor to beginning of the node
140
141
  //we manually shift the cursor to end of the codeblock
141
142
  var currentPosition = tr.selection.$from;
142
143
  var currentNode = currentPosition.parent;
143
- if (currentNode.type === codeBlock) {
144
- var endPosOfCodeBlock = currentPosition.end();
145
- var endResolvedPosition = tr.doc.resolve(endPosOfCodeBlock);
144
+ if (['codeBlock', 'decisionItem'].includes(currentNode.type.name)) {
145
+ var endPosOfNode = currentPosition.end();
146
+ var endResolvedPosition = tr.doc.resolve(endPosOfNode);
146
147
  tr.setSelection(new TextSelection(endResolvedPosition, endResolvedPosition));
147
148
  }
148
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "0.2.9",
3
+ "version": "0.2.11",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -33,7 +33,7 @@
33
33
  ".": "./src/index.ts"
34
34
  },
35
35
  "dependencies": {
36
- "@atlaskit/editor-common": "^76.41.0",
36
+ "@atlaskit/editor-common": "^77.0.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",
@@ -43,7 +43,7 @@
43
43
  "@atlaskit/editor-plugin-list": "^3.1.0",
44
44
  "@atlaskit/editor-plugin-media": "^0.11.0",
45
45
  "@atlaskit/editor-prosemirror": "1.1.0",
46
- "@atlaskit/editor-tables": "^2.3.0",
46
+ "@atlaskit/editor-tables": "^2.4.0",
47
47
  "@atlaskit/media-client": "^26.1.0",
48
48
  "@atlaskit/media-common": "^11.0.0",
49
49
  "@atlaskit/platform-feature-flags": "^0.2.0",
@@ -116,6 +116,9 @@
116
116
  "platform-feature-flags": {
117
117
  "platform.editor.media.extended-resize-experience": {
118
118
  "type": "boolean"
119
+ },
120
+ "platform.editor.allow-extended-panel": {
121
+ "type": "boolean"
119
122
  }
120
123
  }
121
124
  }