@atlaskit/editor-plugin-paste 13.1.1 → 13.2.0

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,26 @@
1
1
  # @atlaskit/editor-plugin-paste
2
2
 
3
+ ## 13.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`75bc915c1fe98`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/75bc915c1fe98) -
8
+ Hide paste actions when pasting agent mentions behind the platform_editor_agent_mentions
9
+ experiment. The paste plugin now exposes the source pasted slice so consumers can inspect the
10
+ paste handler content without depending on the last transaction step slice.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 13.1.2
17
+
18
+ ### Patch Changes
19
+
20
+ - [`49b8e9a322976`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/49b8e9a322976) -
21
+ Reduce q4 lovability experiment exposure noise in code block setup and bookkeeping paths
22
+ - Updated dependencies
23
+
3
24
  ## 13.1.1
4
25
 
5
26
  ### Patch Changes
@@ -253,7 +253,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
253
253
  _insm.insm.endHeavyTask('paste');
254
254
  }
255
255
  });
256
- var getLastPastedSlice = function getLastPastedSlice(tr) {
256
+ var getLastReplaceStepSlice = function getLastReplaceStepSlice(tr) {
257
257
  var slice;
258
258
  var _iterator = _createForOfIteratorHelper(tr.steps),
259
259
  _step;
@@ -325,7 +325,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
325
325
  var _pluginInjectionApi$b;
326
326
  tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
327
327
  }
328
- if ((0, _expValEquals.expValEquals)('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
328
+ if ((0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
329
329
  tr = (0, _normalizePastedCodeBlockAttrs.normalizePastedCodeBlockAttrs)(tr, schema.nodes.codeBlock);
330
330
  }
331
331
  var isDocChanged = tr.docChanged;
@@ -338,7 +338,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
338
338
  // we make sure to call paste options toolbar
339
339
  // only for a valid paste action
340
340
  if (isDocChanged) {
341
- var pastedSlice = getLastPastedSlice(tr);
341
+ var pastedSlice = getLastReplaceStepSlice(tr);
342
342
  if (pastedSlice) {
343
343
  var _input;
344
344
  var pasteStartPos = state.selection.from;
@@ -353,7 +353,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
353
353
  isPlainText: Boolean(isPlainText),
354
354
  pastedSlice: pastedSlice,
355
355
  pastedAt: Date.now(),
356
- pasteSource: (0, _util.getPasteSource)(event)
356
+ pasteSource: (0, _util.getPasteSource)(event),
357
+ sourcePastedSlice: slice
357
358
  };
358
359
  tr.setMeta(_pluginFactory.pluginKey, {
359
360
  type: _actions.PastePluginActionTypes.ON_PASTE,
@@ -221,7 +221,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
221
221
  insm.endHeavyTask('paste');
222
222
  }
223
223
  });
224
- const getLastPastedSlice = tr => {
224
+ const getLastReplaceStepSlice = tr => {
225
225
  let slice;
226
226
  for (const step of tr.steps) {
227
227
  const stepSlice = extractSliceFromStep(step);
@@ -284,7 +284,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
284
284
  var _pluginInjectionApi$b;
285
285
  tr = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
286
286
  }
287
- if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
287
+ if (expValEqualsNoExposure('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
288
288
  tr = normalizePastedCodeBlockAttrs(tr, schema.nodes.codeBlock);
289
289
  }
290
290
  const isDocChanged = tr.docChanged;
@@ -297,7 +297,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
297
297
  // we make sure to call paste options toolbar
298
298
  // only for a valid paste action
299
299
  if (isDocChanged) {
300
- const pastedSlice = getLastPastedSlice(tr);
300
+ const pastedSlice = getLastReplaceStepSlice(tr);
301
301
  if (pastedSlice) {
302
302
  var _input;
303
303
  const pasteStartPos = state.selection.from;
@@ -312,7 +312,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
312
312
  isPlainText: Boolean(isPlainText),
313
313
  pastedSlice,
314
314
  pastedAt: Date.now(),
315
- pasteSource: getPasteSource(event)
315
+ pasteSource: getPasteSource(event),
316
+ sourcePastedSlice: slice
316
317
  };
317
318
  tr.setMeta(stateKey, {
318
319
  type: PastePluginActionTypes.ON_PASTE,
@@ -245,7 +245,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
245
245
  insm.endHeavyTask('paste');
246
246
  }
247
247
  });
248
- var getLastPastedSlice = function getLastPastedSlice(tr) {
248
+ var getLastReplaceStepSlice = function getLastReplaceStepSlice(tr) {
249
249
  var slice;
250
250
  var _iterator = _createForOfIteratorHelper(tr.steps),
251
251
  _step;
@@ -317,7 +317,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
317
317
  var _pluginInjectionApi$b;
318
318
  tr = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$b = pluginInjectionApi.betterTypeHistory) === null || _pluginInjectionApi$b === void 0 ? void 0 : _pluginInjectionApi$b.actions.flagPasteEvent(tr);
319
319
  }
320
- if (expValEquals('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
320
+ if (expValEqualsNoExposure('platform_editor_code_block_q4_lovability', 'isEnabled', true)) {
321
321
  tr = normalizePastedCodeBlockAttrs(tr, schema.nodes.codeBlock);
322
322
  }
323
323
  var isDocChanged = tr.docChanged;
@@ -330,7 +330,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
330
330
  // we make sure to call paste options toolbar
331
331
  // only for a valid paste action
332
332
  if (isDocChanged) {
333
- var pastedSlice = getLastPastedSlice(tr);
333
+ var pastedSlice = getLastReplaceStepSlice(tr);
334
334
  if (pastedSlice) {
335
335
  var _input;
336
336
  var pasteStartPos = state.selection.from;
@@ -345,7 +345,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
345
345
  isPlainText: Boolean(isPlainText),
346
346
  pastedSlice: pastedSlice,
347
347
  pastedAt: Date.now(),
348
- pasteSource: getPasteSource(event)
348
+ pasteSource: getPasteSource(event),
349
+ sourcePastedSlice: slice
349
350
  };
350
351
  tr.setMeta(stateKey, {
351
352
  type: PastePluginActionTypes.ON_PASTE,
@@ -42,10 +42,24 @@ export type LastContentPasted = {
42
42
  isPlainText: boolean;
43
43
  isShiftPressed: boolean;
44
44
  pastedAt: number;
45
+ /**
46
+ * Backwards-compatible field for existing paste option consumers.
47
+ *
48
+ * This is the last slice extracted from a ReplaceStep or ReplaceAroundStep
49
+ * in the paste transaction. It is not necessarily the original clipboard
50
+ * slice or the full content inserted by the paste.
51
+ */
45
52
  pastedSlice: Slice;
46
53
  pasteEndPos: number;
47
54
  pasteSource: PasteSource;
48
55
  pasteStartPos: number;
56
+ /**
57
+ * The paste handler slice captured before inspecting transaction steps.
58
+ * This has already passed through clipboard parsing and paste transforms,
59
+ * but does not depend on which ReplaceStep or ReplaceAroundStep happens to
60
+ * be last in the paste transaction.
61
+ */
62
+ sourcePastedSlice?: Slice;
49
63
  text?: string;
50
64
  };
51
65
  export type PastePluginOptions = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste",
3
- "version": "13.1.1",
3
+ "version": "13.2.0",
4
4
  "description": "Paste plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/media-common": "^14.1.0",
42
42
  "@atlaskit/platform-feature-flags": "^2.0.0",
43
43
  "@atlaskit/prosemirror-history": "^1.0.0",
44
- "@atlaskit/tmp-editor-statsig": "^110.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^111.0.0",
45
45
  "@atlaskit/tokens": "^15.0.0",
46
46
  "@babel/runtime": "^7.0.0",
47
47
  "lodash": "^4.17.21",
@@ -123,7 +123,7 @@
123
123
  "type": "boolean"
124
124
  },
125
125
  "platform_editor_agent_mentions": {
126
- "type": "boolean"
126
+ "type": "experiment"
127
127
  },
128
128
  "platform_editor_paste_renderer_analytics": {
129
129
  "type": "boolean"