@atlaskit/editor-plugin-paste 1.0.7 → 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 CHANGED
@@ -1,5 +1,12 @@
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
+
3
10
  ## 1.0.7
4
11
 
5
12
  ### 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();
@@ -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
- const insertPosition = $to.pos + 1;
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();
@@ -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();
@@ -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.7",
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.10.0",
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.0.0",
39
+ "@atlaskit/editor-plugin-annotation": "^1.1.0",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^1.0.0",
41
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.6.0",
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",
@@ -131,6 +131,9 @@
131
131
  },
132
132
  "platform.editor.place-cursor-inside-text-block": {
133
133
  "type": "boolean"
134
+ },
135
+ "platform.editor.multi-bodied-extension_0rygg": {
136
+ "type": "boolean"
134
137
  }
135
138
  }
136
139
  }