@atlaskit/editor-plugin-paste 9.0.9 → 9.0.10

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,14 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 9.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`d193def6569f2`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d193def6569f2) -
8
+ Fixed mixed HTML/Editor content copy/paste issue on mediaInline node by preventing
9
+ unwrapNestedMediaElements from hoisting images out of mediaInline wrappers.
10
+ - Updated dependencies
11
+
3
12
  ## 9.0.9
4
13
 
5
14
  ### Patch Changes
@@ -172,7 +172,7 @@ var extractListFromParagraph = exports.extractListFromParagraph = function extra
172
172
  // Ignored via go/ees005
173
173
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
174
174
  // Ignored via go/ees005
175
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
175
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
176
176
  order: parseInt(firstNonHardBreakNode.text.split('.')[0])
177
177
  } : undefined;
178
178
  var newList = nodeType.createChecked(attrs, [listItemNode]);
@@ -12,6 +12,7 @@ var _mediaSingle = require("@atlaskit/editor-common/media-single");
12
12
  var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
14
14
  var _mediaCommon = require("@atlaskit/media-common");
15
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
15
16
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
16
17
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
17
18
  /**
@@ -177,6 +178,16 @@ var unwrapNestedMediaElements = exports.unwrapNestedMediaElements = function unw
177
178
  return;
178
179
  }
179
180
 
181
+ // Bypass mediaInline images - don't hoist images that are inside a mediaInline wrapper
182
+ // as this would break parseDOM matching for mediaInline nodes
183
+ // We remove the img from the DOM since mediaInline is a leaf node with no content
184
+ if (imageTag.closest('[data-node-type="mediaInline"]') && (0, _expValEquals.expValEquals)('platform_editor_inline_media_copy_paste_fix', 'isEnabled', true)) {
185
+ // Remove the img element so ProseMirror doesn't try to parse it
186
+ // mediaInline nodes are leaf nodes and cannot have children
187
+ imageTag.remove();
188
+ return;
189
+ }
190
+
180
191
  // If either the parent or the image itself contains styles that would make
181
192
  // them invisible on copy, dont paste them.
182
193
  if (isElementInvisible(mediaParent) || isElementInvisible(imageTag)) {
@@ -147,7 +147,7 @@ function escapeBackslashAndLinksExceptCodeBlock(textInput) {
147
147
  return line;
148
148
  } else {
149
149
  // Ignored via go/ees005
150
- // eslint-disable-next-line require-unicode-regexp
150
+ // eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
151
151
  var escaped = line.replace(/\\/g, '\\\\');
152
152
  escaped = escapeLinks(escaped);
153
153
  return escaped;
@@ -154,7 +154,7 @@ export const extractListFromParagraph = (node, parent, schema) => {
154
154
  // Ignored via go/ees005
155
155
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
156
156
  // Ignored via go/ees005
157
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
157
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
158
158
  order: parseInt(firstNonHardBreakNode.text.split('.')[0])
159
159
  } : undefined;
160
160
  const newList = nodeType.createChecked(attrs, [listItemNode]);
@@ -2,6 +2,7 @@ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
2
2
  import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
3
3
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
4
4
  import { getRandomHex } from '@atlaskit/media-common';
5
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
6
  /**
6
7
  * Ensure correct layout in nested mode
7
8
  *
@@ -173,6 +174,16 @@ export const unwrapNestedMediaElements = html => {
173
174
  return;
174
175
  }
175
176
 
177
+ // Bypass mediaInline images - don't hoist images that are inside a mediaInline wrapper
178
+ // as this would break parseDOM matching for mediaInline nodes
179
+ // We remove the img from the DOM since mediaInline is a leaf node with no content
180
+ if (imageTag.closest('[data-node-type="mediaInline"]') && expValEquals('platform_editor_inline_media_copy_paste_fix', 'isEnabled', true)) {
181
+ // Remove the img element so ProseMirror doesn't try to parse it
182
+ // mediaInline nodes are leaf nodes and cannot have children
183
+ imageTag.remove();
184
+ return;
185
+ }
186
+
176
187
  // If either the parent or the image itself contains styles that would make
177
188
  // them invisible on copy, dont paste them.
178
189
  if (isElementInvisible(mediaParent) || isElementInvisible(imageTag)) {
@@ -125,7 +125,7 @@ export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
125
125
  return line;
126
126
  } else {
127
127
  // Ignored via go/ees005
128
- // eslint-disable-next-line require-unicode-regexp
128
+ // eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
129
129
  let escaped = line.replace(/\\/g, '\\\\');
130
130
  escaped = escapeLinks(escaped);
131
131
  return escaped;
@@ -166,7 +166,7 @@ export var extractListFromParagraph = function extractListFromParagraph(node, pa
166
166
  // Ignored via go/ees005
167
167
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
168
168
  // Ignored via go/ees005
169
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
169
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
170
170
  order: parseInt(firstNonHardBreakNode.text.split('.')[0])
171
171
  } : undefined;
172
172
  var newList = nodeType.createChecked(attrs, [listItemNode]);
@@ -5,6 +5,7 @@ import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
5
5
  import { mapSlice, removeNestedEmptyEls, unwrap, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
6
6
  import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { getRandomHex } from '@atlaskit/media-common';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
8
9
  /**
9
10
  * Ensure correct layout in nested mode
10
11
  *
@@ -168,6 +169,16 @@ export var unwrapNestedMediaElements = function unwrapNestedMediaElements(html)
168
169
  return;
169
170
  }
170
171
 
172
+ // Bypass mediaInline images - don't hoist images that are inside a mediaInline wrapper
173
+ // as this would break parseDOM matching for mediaInline nodes
174
+ // We remove the img from the DOM since mediaInline is a leaf node with no content
175
+ if (imageTag.closest('[data-node-type="mediaInline"]') && expValEquals('platform_editor_inline_media_copy_paste_fix', 'isEnabled', true)) {
176
+ // Remove the img element so ProseMirror doesn't try to parse it
177
+ // mediaInline nodes are leaf nodes and cannot have children
178
+ imageTag.remove();
179
+ return;
180
+ }
181
+
171
182
  // If either the parent or the image itself contains styles that would make
172
183
  // them invisible on copy, dont paste them.
173
184
  if (isElementInvisible(mediaParent) || isElementInvisible(imageTag)) {
@@ -126,7 +126,7 @@ export function escapeBackslashAndLinksExceptCodeBlock(textInput) {
126
126
  return line;
127
127
  } else {
128
128
  // Ignored via go/ees005
129
- // eslint-disable-next-line require-unicode-regexp
129
+ // eslint-disable-next-line require-unicode-regexp, @atlassian/perf-linting/no-expensive-split-replace -- Ignored via go/ees017 (to be fixed)
130
130
  var escaped = line.replace(/\\/g, '\\\\');
131
131
  escaped = escapeLinks(escaped);
132
132
  return escaped;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "9.0.9",
3
+ "version": "9.0.10",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,7 +37,7 @@
37
37
  "@atlaskit/editor-plugin-expand": "^9.1.0",
38
38
  "@atlaskit/editor-plugin-feature-flags": "^7.0.0",
39
39
  "@atlaskit/editor-plugin-list": "^10.0.0",
40
- "@atlaskit/editor-plugin-media": "^10.0.0",
40
+ "@atlaskit/editor-plugin-media": "^10.1.0",
41
41
  "@atlaskit/editor-plugin-mentions": "^10.0.0",
42
42
  "@atlaskit/editor-prosemirror": "^7.3.0",
43
43
  "@atlaskit/editor-tables": "^2.9.0",
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/media-common": "^13.0.0",
49
49
  "@atlaskit/platform-feature-flags": "^1.1.0",
50
50
  "@atlaskit/prosemirror-history": "^0.2.0",
51
- "@atlaskit/tmp-editor-statsig": "^43.0.0",
51
+ "@atlaskit/tmp-editor-statsig": "^44.0.0",
52
52
  "@atlaskit/tokens": "^11.1.0",
53
53
  "@babel/runtime": "^7.0.0",
54
54
  "lodash": "^4.17.21",
@@ -118,6 +118,9 @@
118
118
  },
119
119
  "platform_media_cross_client_copy_with_auth": {
120
120
  "type": "boolean"
121
+ },
122
+ "platform_editor_inline_media_copy_paste_fix": {
123
+ "type": "boolean"
121
124
  }
122
125
  }
123
126
  }