@atlaskit/editor-plugin-paste 1.0.4 → 1.0.6

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
+ ## 1.0.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#75436](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75436) [`bfcf32bb4fa3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bfcf32bb4fa3) - [ux] ED-21941 Disable resize/layout options for table, media and extension when added to MBE. Table rendering fixed for Confluence editor
8
+
9
+ ## 1.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#75378](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75378) [`caf4a7eff92d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/caf4a7eff92d) - ED-22246 Fix pasting text into action/decision inside panel
14
+
3
15
  ## 1.0.4
4
16
 
5
17
  ### Patch Changes
@@ -132,7 +132,10 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
132
132
  // and the slice's first node is a paragraph
133
133
  // and it is not from a depth that would indicate it being from inside from another node (e.g. text from a decision)
134
134
  // then we can rely on the default behaviour.
135
- var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
135
+ var selectionIsTaskOrDecision = (0, _utils2.hasParentNode)(function (node) {
136
+ return node.type === taskItem || node.type === decisionItem;
137
+ })(selection);
138
+ var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
136
139
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
137
140
  return false;
138
141
  }
@@ -815,13 +818,18 @@ function handleParagraphBlockMarks(state, slice) {
815
818
  return new _model.Slice(slice.content, openStart, slice.openEnd);
816
819
  }
817
820
 
818
- // If the paragraph contains marks forbidden by the parent node (e.g. alignment/indentation),
819
- // drop those marks from the slice
821
+ // If the paragraph or heading contains marks forbidden by the parent node
822
+ // (e.g. alignment/indentation), drop those marks from the slice
820
823
  return (0, _utils.mapSlice)(slice, function (node) {
821
824
  if (node.type === schema.nodes.paragraph) {
822
825
  return schema.nodes.paragraph.createChecked(undefined, node.content, node.marks.filter(function (mark) {
823
826
  return !forbiddenMarkTypes.includes(mark.type);
824
827
  }));
828
+ } else if (node.type === schema.nodes.heading) {
829
+ // Preserve heading attributes to keep formatting
830
+ return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
831
+ return !forbiddenMarkTypes.includes(mark.type);
832
+ }));
825
833
  }
826
834
  return node;
827
835
  });
@@ -7,7 +7,7 @@ import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isL
7
7
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
8
8
  import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
9
9
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
10
- import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
10
+ import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
11
11
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
12
12
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
13
13
  // TODO: ED-20519 Needs Macro extraction
@@ -107,7 +107,8 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
107
107
  // and the slice's first node is a paragraph
108
108
  // and it is not from a depth that would indicate it being from inside from another node (e.g. text from a decision)
109
109
  // then we can rely on the default behaviour.
110
- const sliceIsAPanelReceivingLowDepthText = selectionIsPanel && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
110
+ const selectionIsTaskOrDecision = hasParentNode(node => node.type === taskItem || node.type === decisionItem)(selection);
111
+ const sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
111
112
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
112
113
  return false;
113
114
  }
@@ -795,11 +796,14 @@ export function handleParagraphBlockMarks(state, slice) {
795
796
  return new Slice(slice.content, openStart, slice.openEnd);
796
797
  }
797
798
 
798
- // If the paragraph contains marks forbidden by the parent node (e.g. alignment/indentation),
799
- // drop those marks from the slice
799
+ // If the paragraph or heading contains marks forbidden by the parent node
800
+ // (e.g. alignment/indentation), drop those marks from the slice
800
801
  return mapSlice(slice, node => {
801
802
  if (node.type === schema.nodes.paragraph) {
802
803
  return schema.nodes.paragraph.createChecked(undefined, node.content, node.marks.filter(mark => !forbiddenMarkTypes.includes(mark.type)));
804
+ } else if (node.type === schema.nodes.heading) {
805
+ // Preserve heading attributes to keep formatting
806
+ return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(mark => !forbiddenMarkTypes.includes(mark.type)));
803
807
  }
804
808
  return node;
805
809
  });
@@ -15,7 +15,7 @@ import { canLinkBeCreatedInRange, insideTableCell, isInListItem, isLinkMark, isL
15
15
  import { closeHistory } from '@atlaskit/editor-prosemirror/history';
16
16
  import { Fragment, Node as PMNode, Slice } from '@atlaskit/editor-prosemirror/model';
17
17
  import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
18
- import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
18
+ import { canInsert, contains, findParentNodeOfType, findParentNodeOfTypeClosestToPos, hasParentNode, hasParentNodeOfType, safeInsert } from '@atlaskit/editor-prosemirror/utils';
19
19
  import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
20
20
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
21
21
  // TODO: ED-20519 Needs Macro extraction
@@ -110,7 +110,10 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChange
110
110
  // and the slice's first node is a paragraph
111
111
  // and it is not from a depth that would indicate it being from inside from another node (e.g. text from a decision)
112
112
  // then we can rely on the default behaviour.
113
- var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
113
+ var selectionIsTaskOrDecision = hasParentNode(function (node) {
114
+ return node.type === taskItem || node.type === decisionItem;
115
+ })(selection);
116
+ var sliceIsAPanelReceivingLowDepthText = selectionIsPanel && !selectionIsTaskOrDecision && ((_slice$content$firstC = slice.content.firstChild) === null || _slice$content$firstC === void 0 ? void 0 : _slice$content$firstC.type) === paragraph && slice.openEnd < 2;
114
117
  if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
115
118
  return false;
116
119
  }
@@ -793,13 +796,18 @@ export function handleParagraphBlockMarks(state, slice) {
793
796
  return new Slice(slice.content, openStart, slice.openEnd);
794
797
  }
795
798
 
796
- // If the paragraph contains marks forbidden by the parent node (e.g. alignment/indentation),
797
- // drop those marks from the slice
799
+ // If the paragraph or heading contains marks forbidden by the parent node
800
+ // (e.g. alignment/indentation), drop those marks from the slice
798
801
  return mapSlice(slice, function (node) {
799
802
  if (node.type === schema.nodes.paragraph) {
800
803
  return schema.nodes.paragraph.createChecked(undefined, node.content, node.marks.filter(function (mark) {
801
804
  return !forbiddenMarkTypes.includes(mark.type);
802
805
  }));
806
+ } else if (node.type === schema.nodes.heading) {
807
+ // Preserve heading attributes to keep formatting
808
+ return schema.nodes.heading.createChecked(node.attrs, node.content, node.marks.filter(function (mark) {
809
+ return !forbiddenMarkTypes.includes(mark.type);
810
+ }));
803
811
  }
804
812
  return node;
805
813
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
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.4.0",
37
- "@atlaskit/editor-markdown-transformer": "^5.3.0",
36
+ "@atlaskit/editor-common": "^78.8.0",
37
+ "@atlaskit/editor-markdown-transformer": "^5.4.0",
38
38
  "@atlaskit/editor-plugin-analytics": "^1.0.0",
39
39
  "@atlaskit/editor-plugin-annotation": "^1.0.0",
40
40
  "@atlaskit/editor-plugin-better-type-history": "^1.0.0",
41
41
  "@atlaskit/editor-plugin-card": "^1.0.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.2.0",
44
+ "@atlaskit/editor-plugin-media": "^1.4.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",