@atlaskit/editor-plugin-paste 27.0.4 → 27.0.7
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 +18 -0
- package/dist/cjs/editor-commands/commands.js +4 -3
- package/dist/cjs/pm-plugins/analytics.js +75 -73
- package/dist/cjs/pm-plugins/create-clipboard-text-serializer.js +2 -2
- package/dist/cjs/pm-plugins/main.js +65 -56
- package/dist/cjs/pm-plugins/media.js +9 -8
- package/dist/cjs/pm-plugins/move-analytics/plugin-factory.js +2 -2
- package/dist/cjs/pm-plugins/move-analytics/plugin.js +5 -5
- package/dist/cjs/pm-plugins/plugin-factory.js +2 -2
- package/dist/cjs/pm-plugins/util/edge-cases/handleVSCodeBlock.js +2 -2
- package/dist/cjs/pm-plugins/util/get-markdown-slice.js +2 -2
- package/dist/cjs/pm-plugins/util/handlers.js +52 -48
- package/dist/cjs/pm-plugins/util/index.js +8 -6
- package/dist/cjs/pm-plugins/util/sync-block.js +7 -7
- package/dist/cjs/ui/Flag.js +2 -2
- package/dist/es2019/editor-commands/commands.js +2 -1
- package/dist/es2019/pm-plugins/analytics.js +4 -2
- package/dist/es2019/pm-plugins/create-clipboard-text-serializer.js +1 -1
- package/dist/es2019/pm-plugins/main.js +19 -10
- package/dist/es2019/pm-plugins/media.js +4 -3
- package/dist/es2019/pm-plugins/move-analytics/plugin-factory.js +1 -1
- package/dist/es2019/pm-plugins/move-analytics/plugin.js +1 -1
- package/dist/es2019/pm-plugins/plugin-factory.js +1 -1
- package/dist/es2019/pm-plugins/util/edge-cases/handleVSCodeBlock.js +1 -1
- package/dist/es2019/pm-plugins/util/get-markdown-slice.js +1 -1
- package/dist/es2019/pm-plugins/util/handlers.js +11 -7
- package/dist/es2019/pm-plugins/util/index.js +4 -2
- package/dist/es2019/pm-plugins/util/sync-block.js +2 -2
- package/dist/es2019/ui/Flag.js +1 -1
- package/dist/esm/editor-commands/commands.js +2 -1
- package/dist/esm/pm-plugins/analytics.js +4 -2
- package/dist/esm/pm-plugins/create-clipboard-text-serializer.js +1 -1
- package/dist/esm/pm-plugins/main.js +19 -10
- package/dist/esm/pm-plugins/media.js +4 -3
- package/dist/esm/pm-plugins/move-analytics/plugin-factory.js +1 -1
- package/dist/esm/pm-plugins/move-analytics/plugin.js +1 -1
- package/dist/esm/pm-plugins/plugin-factory.js +1 -1
- package/dist/esm/pm-plugins/util/edge-cases/handleVSCodeBlock.js +1 -1
- package/dist/esm/pm-plugins/util/get-markdown-slice.js +1 -1
- package/dist/esm/pm-plugins/util/handlers.js +11 -7
- package/dist/esm/pm-plugins/util/index.js +4 -2
- package/dist/esm/pm-plugins/util/sync-block.js +2 -2
- package/dist/esm/ui/Flag.js +1 -1
- package/dist/types/editor-commands/commands.d.ts +1 -1
- package/dist/types/pastePluginType.d.ts +14 -13
- package/dist/types/pm-plugins/analytics.d.ts +6 -3
- package/dist/types/pm-plugins/main.d.ts +6 -4
- package/dist/types/pm-plugins/media.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/commands.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/plugin.d.ts +1 -1
- package/dist/types/pm-plugins/plugin-factory.d.ts +1 -1
- package/dist/types/pm-plugins/util/handlers.d.ts +8 -6
- package/dist/types/pm-plugins/util/index.d.ts +3 -2
- package/dist/types/pm-plugins/util/sync-block.d.ts +3 -2
- package/dist/types/ui/Flag.d.ts +1 -1
- package/package.json +4 -4
|
@@ -10,23 +10,32 @@ exports.isSharePointUrl = isSharePointUrl;
|
|
|
10
10
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _uuid = require("uuid");
|
|
13
|
-
var
|
|
13
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
14
|
+
var _pasteEvents = require("@atlaskit/editor-common/analytics/types/paste-events");
|
|
14
15
|
var _card = require("@atlaskit/editor-common/card");
|
|
15
|
-
var
|
|
16
|
-
var
|
|
16
|
+
var _moduleHelpers = require("@atlaskit/editor-common/extensions/module-helpers");
|
|
17
|
+
var _inside = require("@atlaskit/editor-common/inside");
|
|
17
18
|
var _nesting = require("@atlaskit/editor-common/nesting");
|
|
18
|
-
var
|
|
19
|
+
var _clipboard = require("@atlaskit/editor-common/paste/clipboard");
|
|
20
|
+
var _md = require("@atlaskit/editor-common/paste/md");
|
|
19
21
|
var _measureRender = require("@atlaskit/editor-common/performance/measure-render");
|
|
20
22
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
21
|
-
var _syncBlock = require("@atlaskit/editor-common/sync-block");
|
|
23
|
+
var _syncBlock = require("@atlaskit/editor-common/styles/sync-block");
|
|
22
24
|
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
25
|
+
var _codeBlock = require("@atlaskit/editor-common/transforms/code-block");
|
|
26
|
+
var _decisionList = require("@atlaskit/editor-common/transforms/decision-list");
|
|
27
|
+
var _extension = require("@atlaskit/editor-common/transforms/extension");
|
|
28
|
+
var _syncBlock2 = require("@atlaskit/editor-common/transforms/sync-block");
|
|
23
29
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
30
|
+
var _annotation = require("@atlaskit/editor-common/utils/annotation");
|
|
31
|
+
var _hyperlink = require("@atlaskit/editor-common/utils/hyperlink");
|
|
32
|
+
var _slice = require("@atlaskit/editor-common/utils/slice");
|
|
24
33
|
var _editorMarkdownTransformer = require("@atlaskit/editor-markdown-transformer");
|
|
25
34
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
26
35
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
27
|
-
var
|
|
28
|
-
var
|
|
29
|
-
var
|
|
36
|
+
var _handlePaste = require("@atlaskit/editor-tables/utils/handle-paste");
|
|
37
|
+
var _api = require("@atlaskit/insm/api");
|
|
38
|
+
var _clientIdCache = require("@atlaskit/media-common/clientIdCache");
|
|
30
39
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
31
40
|
var _fg = require("@atlaskit/platform-feature-flags/fg");
|
|
32
41
|
var _editorExperiment = require("@atlaskit/tmp-editor-statsig/editor-experiment");
|
|
@@ -35,7 +44,7 @@ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equa
|
|
|
35
44
|
var _actions = require("../editor-actions/actions");
|
|
36
45
|
var _commands = require("../editor-commands/commands");
|
|
37
46
|
var _media = require("../pm-plugins/media");
|
|
38
|
-
var
|
|
47
|
+
var _analytics = require("./analytics");
|
|
39
48
|
var _clipboardParser = require("./clipboard-parser");
|
|
40
49
|
var _createClipboardTextSerializer = require("./create-clipboard-text-serializer");
|
|
41
50
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -44,7 +53,7 @@ var _handleVSCodeBlock = require("./util/edge-cases/handleVSCodeBlock");
|
|
|
44
53
|
var _getMarkdownSlice = require("./util/get-markdown-slice");
|
|
45
54
|
var _handlers = require("./util/handlers");
|
|
46
55
|
var _normalizePastedCodeBlockAttrs = require("./util/normalize-pasted-code-block-attrs");
|
|
47
|
-
var
|
|
56
|
+
var _syncBlock3 = require("./util/sync-block");
|
|
48
57
|
var _tinyMCE = require("./util/tinyMCE");
|
|
49
58
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
50
59
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
@@ -90,7 +99,7 @@ function isSharePointUrl(url) {
|
|
|
90
99
|
function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, getIntl, cardOptions, sanitizePrivateContent, providerFactory, pasteWarningOptions, markdownToPmConverter) {
|
|
91
100
|
var _pluginInjectionApi$a;
|
|
92
101
|
var editorAnalyticsAPI = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
93
|
-
var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema,
|
|
102
|
+
var atlassianMarkDownParser = new _editorMarkdownTransformer.MarkdownTransformer(schema, _md.md);
|
|
94
103
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
95
104
|
if (markdownToPmConverter && (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_paste_as_md_use_gfm')) {
|
|
96
105
|
return (0, _getMarkdownSlice.getMarkdownSliceViaGfm)(text, schema, openStart, openEnd, markdownToPmConverter, (0, _isExperimentEnabled.isExperimentEnabled)('platform_editor_gfm_link_paste_fix'));
|
|
@@ -120,7 +129,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
120
129
|
case 1:
|
|
121
130
|
_context.prev = 1;
|
|
122
131
|
_context.next = 2;
|
|
123
|
-
return (0,
|
|
132
|
+
return (0, _moduleHelpers.getExtensionAutoConvertersFromProvider)(extensionProviderPromise);
|
|
124
133
|
case 2:
|
|
125
134
|
extensionAutoConverter = _context.sent;
|
|
126
135
|
_context.next = 4;
|
|
@@ -159,7 +168,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
159
168
|
paste: function paste(view, event) {
|
|
160
169
|
mostRecentPasteEvent = event;
|
|
161
170
|
if (event.clipboardData) {
|
|
162
|
-
|
|
171
|
+
_api.insm.startHeavyTask('paste');
|
|
163
172
|
}
|
|
164
173
|
return false;
|
|
165
174
|
}
|
|
@@ -178,7 +187,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
178
187
|
// Extract clientId values from pasted HTML for media cross-product copy/paste
|
|
179
188
|
// This must be done before ProseMirror parses the HTML, as clientId is not stored in ADF
|
|
180
189
|
if ((0, _fg.fg)('platform_media_cross_client_copy_with_auth')) {
|
|
181
|
-
(0,
|
|
190
|
+
(0, _clientIdCache.extractClientIdsFromHtml)(html);
|
|
182
191
|
}
|
|
183
192
|
// Links copied from iOS Safari share button only have the text/uri-list data type
|
|
184
193
|
// ProseMirror don't do anything with this type so we want to make our own open slice
|
|
@@ -195,16 +204,16 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
195
204
|
|
|
196
205
|
// Strip Legacy Content Macro (LCM) extensions on paste
|
|
197
206
|
if (!(0, _fg.fg)('platform_editor_legacy_content_macro_insert')) {
|
|
198
|
-
slice = (0,
|
|
207
|
+
slice = (0, _extension.transformSliceToRemoveLegacyContentMacro)(slice, schema);
|
|
199
208
|
}
|
|
200
|
-
var isPastedFile = (0,
|
|
209
|
+
var isPastedFile = (0, _clipboard.isPastedFile)(event);
|
|
201
210
|
var isPlainText = text && !html;
|
|
202
211
|
var isRichText = !!html;
|
|
203
212
|
|
|
204
213
|
// Bail if copied content has files
|
|
205
214
|
if (isPastedFile) {
|
|
206
215
|
if (!html) {
|
|
207
|
-
|
|
216
|
+
_api.insm.endHeavyTask('paste');
|
|
208
217
|
/**
|
|
209
218
|
* Microsoft Office, Number, Pages, etc. adds an image to clipboard
|
|
210
219
|
* with other mime-types so we don't let the event reach media.
|
|
@@ -223,7 +232,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
223
232
|
* is skipped and handled in handleRichText
|
|
224
233
|
*/
|
|
225
234
|
if ((0, _util.htmlContainsSingleFile)(html) && !isInsideBlockQuote(view.state)) {
|
|
226
|
-
|
|
235
|
+
_api.insm.endHeavyTask('paste');
|
|
227
236
|
return true;
|
|
228
237
|
}
|
|
229
238
|
|
|
@@ -235,14 +244,14 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
235
244
|
event.stopPropagation();
|
|
236
245
|
}
|
|
237
246
|
var state = view.state;
|
|
238
|
-
var content = (0,
|
|
247
|
+
var content = (0, _analytics.getContentNodeTypes)(slice.content);
|
|
239
248
|
// eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
|
|
240
249
|
var pasteId = (0, _uuid.v4)();
|
|
241
250
|
var measureName = "".concat(PASTE, "_").concat(pasteId);
|
|
242
251
|
(0, _measureRender.measureRender)(measureName, function (_ref) {
|
|
243
252
|
var duration = _ref.duration,
|
|
244
253
|
distortedDuration = _ref.distortedDuration;
|
|
245
|
-
var payload = (0,
|
|
254
|
+
var payload = (0, _analytics.createPasteMeasurePayload)({
|
|
246
255
|
view: view,
|
|
247
256
|
duration: duration,
|
|
248
257
|
content: content,
|
|
@@ -251,7 +260,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
251
260
|
if (payload) {
|
|
252
261
|
dispatchAnalyticsEvent(payload);
|
|
253
262
|
}
|
|
254
|
-
|
|
263
|
+
_api.insm.endHeavyTask('paste');
|
|
255
264
|
});
|
|
256
265
|
var getLastReplaceStepSlice = function getLastReplaceStepSlice(tr) {
|
|
257
266
|
var slice;
|
|
@@ -328,8 +337,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
328
337
|
}
|
|
329
338
|
var isDocChanged = tr.docChanged;
|
|
330
339
|
(0, _card.addLinkMetadata)(view.state.selection, tr, {
|
|
331
|
-
action: isPlainText ?
|
|
332
|
-
inputMethod:
|
|
340
|
+
action: isPlainText ? _enums.ACTION.PASTED_AS_PLAIN : _enums.ACTION.PASTED,
|
|
341
|
+
inputMethod: _enums.INPUT_METHOD.CLIPBOARD
|
|
333
342
|
});
|
|
334
343
|
|
|
335
344
|
// handleMacroAutoConvert dispatches twice
|
|
@@ -378,12 +387,12 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
378
387
|
event: event,
|
|
379
388
|
text: text
|
|
380
389
|
});
|
|
381
|
-
slice = (0,
|
|
382
|
-
var plainTextPasteSlice = (0,
|
|
383
|
-
if ((0,
|
|
390
|
+
slice = (0, _syncBlock3.handleSyncBlocksPaste)(slice, schema, (0, _util.getPasteSource)(event), html, pasteWarningOptions, pluginInjectionApi);
|
|
391
|
+
var plainTextPasteSlice = (0, _hyperlink.linkifyContent)(state.schema)(slice);
|
|
392
|
+
if ((0, _analytics.handlePasteAsPlainTextWithAnalytics)(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
|
|
384
393
|
return true;
|
|
385
394
|
}
|
|
386
|
-
if ((0,
|
|
395
|
+
if ((0, _analytics.handlePasteIntoCaptionWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _pasteEvents.PasteTypes.richText)(state, dispatch)) {
|
|
387
396
|
// Create a custom handler to avoid handling with handleRichText method
|
|
388
397
|
// As SafeInsert is used inside handleRichText which caused some bad UX like this:
|
|
389
398
|
// https://product-fabric.atlassian.net/browse/MEX-1520
|
|
@@ -410,15 +419,15 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
410
419
|
if (markdownSlice) {
|
|
411
420
|
var _pluginInjectionApi$c, _pluginInjectionApi$e;
|
|
412
421
|
// linkify text prior to converting to macro
|
|
413
|
-
if ((0,
|
|
422
|
+
if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, markdownSlice, _pasteEvents.PasteTypes.markdown)(state, dispatch)) {
|
|
414
423
|
return true;
|
|
415
424
|
}
|
|
416
425
|
|
|
417
426
|
// run macro autoconvert prior to other conversions
|
|
418
427
|
if ((0, _handlers.handleMacroAutoConvert)(text, markdownSlice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.card) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.actions) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.queueCardsFromChangedTr, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e = pluginInjectionApi.extension) === null || _pluginInjectionApi$e === void 0 || (_pluginInjectionApi$e = _pluginInjectionApi$e.actions) === null || _pluginInjectionApi$e === void 0 ? void 0 : _pluginInjectionApi$e.runMacroAutoConvert, cardOptions, extensionAutoConverter, editorAnalyticsAPI)(state, dispatch, view)) {
|
|
419
428
|
// TODO: ED-26959 - handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
420
|
-
(0,
|
|
421
|
-
type:
|
|
429
|
+
(0, _analytics.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, markdownSlice, {
|
|
430
|
+
type: _pasteEvents.PasteTypes.markdown
|
|
422
431
|
});
|
|
423
432
|
return true;
|
|
424
433
|
}
|
|
@@ -443,47 +452,47 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
443
452
|
}
|
|
444
453
|
|
|
445
454
|
// If we're in a code block, append the text contents of clipboard inside it
|
|
446
|
-
if ((0,
|
|
455
|
+
if ((0, _analytics.handleCodeBlockWithAnalytics)(editorAnalyticsAPI)(view, event, slice, text)(state, dispatch)) {
|
|
447
456
|
return true;
|
|
448
457
|
}
|
|
449
|
-
if ((0,
|
|
458
|
+
if ((0, _analytics.handleMediaSingleWithAnalytics)(editorAnalyticsAPI)(view, event, slice, isPastedFile ? _pasteEvents.PasteTypes.binary : _pasteEvents.PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.actions.insertMediaAsMediaSingle)(state, dispatch, view)) {
|
|
450
459
|
return true;
|
|
451
460
|
}
|
|
452
|
-
if ((0,
|
|
461
|
+
if ((0, _analytics.handleSelectedTableWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
453
462
|
return true;
|
|
454
463
|
}
|
|
455
464
|
var isNestedMarkdownTable = false;
|
|
456
465
|
|
|
457
466
|
// if paste a markdown table inside a table cell, we should treat it as a table slice
|
|
458
467
|
var isParentNodeTdOrTh = selectionParentType === schema.nodes.tableCell || selectionParentType === schema.nodes.tableHeader;
|
|
459
|
-
isNestedMarkdownTable = !!(markdownSlice && isPlainText && isParentNodeTdOrTh && (0,
|
|
468
|
+
isNestedMarkdownTable = !!(markdownSlice && isPlainText && isParentNodeTdOrTh && (0, _analytics.getContentNodeTypes)(markdownSlice.content).includes((_schema$nodes$table = schema.nodes.table) === null || _schema$nodes$table === void 0 ? void 0 : _schema$nodes$table.name));
|
|
460
469
|
slice = isNestedMarkdownTable ? markdownSlice : slice;
|
|
461
470
|
|
|
462
471
|
// get editor-tables to handle pasting tables if it can
|
|
463
472
|
// otherwise, just the replace the selection with the content
|
|
464
|
-
if ((0,
|
|
473
|
+
if ((0, _handlePaste.handlePaste)(view, event, slice, {
|
|
465
474
|
pasteSource: (0, _util.getPasteSource)(event)
|
|
466
475
|
})) {
|
|
467
|
-
(0,
|
|
468
|
-
type:
|
|
476
|
+
(0, _analytics.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, slice, {
|
|
477
|
+
type: _pasteEvents.PasteTypes.richText
|
|
469
478
|
});
|
|
470
479
|
return true;
|
|
471
480
|
}
|
|
472
481
|
|
|
473
482
|
// handle paste of nested tables to ensure nesting limits are respected
|
|
474
|
-
if ((0,
|
|
483
|
+
if ((0, _analytics.handleNestedTablePasteWithAnalytics)(editorAnalyticsAPI, (0, _nesting.isNestedTablesSupported)(state.schema))(view, event, slice)(state, dispatch)) {
|
|
475
484
|
return true;
|
|
476
485
|
}
|
|
477
|
-
if ((0,
|
|
486
|
+
if ((0, _analytics.handlePasteIntoTaskAndDecisionWithAnalytics)(view, event, slice, isPlainText ? _pasteEvents.PasteTypes.plain : _pasteEvents.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
478
487
|
return true;
|
|
479
488
|
}
|
|
480
489
|
|
|
481
490
|
// If the clipboard only contains plain text, attempt to parse it as Markdown
|
|
482
491
|
if (isPlainText && markdownSlice && !isNestedMarkdownTable) {
|
|
483
|
-
if ((0,
|
|
492
|
+
if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, markdownSlice, _pasteEvents.PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
|
|
484
493
|
return true;
|
|
485
494
|
}
|
|
486
|
-
return (0,
|
|
495
|
+
return (0, _analytics.handleMarkdownWithAnalytics)(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
|
|
487
496
|
}
|
|
488
497
|
if (isRichText && isInsideBlockQuote(state)) {
|
|
489
498
|
//If pasting inside blockquote
|
|
@@ -491,7 +500,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
491
500
|
//prevent doing this if there is list inside blockquote as the list is pasted incorrectly inside blockquote due to wrong openStart and openEnd
|
|
492
501
|
var blockquote = schema.nodes.blockquote;
|
|
493
502
|
var children = [];
|
|
494
|
-
(0,
|
|
503
|
+
(0, _slice.mapChildren)(slice.content, function (node) {
|
|
495
504
|
if (node.type === blockquote && !(0, _utils2.contains)(node, state.schema.nodes.listItem)) {
|
|
496
505
|
for (var i = 0; i < node.childCount; i++) {
|
|
497
506
|
children.push(node.child(i));
|
|
@@ -507,16 +516,16 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
507
516
|
if (isRichText || isNestedMarkdownTable) {
|
|
508
517
|
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$l;
|
|
509
518
|
// linkify the text where possible
|
|
510
|
-
slice = (0,
|
|
511
|
-
if ((0,
|
|
519
|
+
slice = (0, _hyperlink.linkifyContent)(state.schema)(slice);
|
|
520
|
+
if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _pasteEvents.PasteTypes.richText)(state, dispatch)) {
|
|
512
521
|
return true;
|
|
513
522
|
}
|
|
514
523
|
|
|
515
524
|
// run macro autoconvert prior to other conversions
|
|
516
525
|
if ((0, _handlers.handleMacroAutoConvert)(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.card) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.actions) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.queueCardsFromChangedTr, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$e2 = pluginInjectionApi.extension) === null || _pluginInjectionApi$e2 === void 0 || (_pluginInjectionApi$e2 = _pluginInjectionApi$e2.actions) === null || _pluginInjectionApi$e2 === void 0 ? void 0 : _pluginInjectionApi$e2.runMacroAutoConvert, cardOptions, extensionAutoConverter, editorAnalyticsAPI)(state, dispatch, view)) {
|
|
517
526
|
// TODO: ED-26959 - handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
518
|
-
(0,
|
|
519
|
-
type:
|
|
527
|
+
(0, _analytics.sendPasteAnalyticsEvent)(editorAnalyticsAPI)(view, event, slice, {
|
|
528
|
+
type: _pasteEvents.PasteTypes.richText
|
|
520
529
|
});
|
|
521
530
|
return true;
|
|
522
531
|
}
|
|
@@ -541,11 +550,11 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
541
550
|
}
|
|
542
551
|
// remove annotation marks from the pasted data if they are not present in the document
|
|
543
552
|
// for the cases when they are pasted from external pages
|
|
544
|
-
if (slice.content.size && (0,
|
|
553
|
+
if (slice.content.size && (0, _annotation.containsAnyAnnotations)(slice, state)) {
|
|
545
554
|
var _pluginInjectionApi$a2;
|
|
546
555
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 || _pluginInjectionApi$a2.actions.stripNonExistingAnnotations(slice, state);
|
|
547
556
|
}
|
|
548
|
-
if ((0,
|
|
557
|
+
if ((0, _analytics.handlePastePreservingMarksWithAnalytics)(view, event, slice, _pasteEvents.PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
549
558
|
return true;
|
|
550
559
|
}
|
|
551
560
|
|
|
@@ -568,19 +577,19 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
568
577
|
});
|
|
569
578
|
slice = sliceCopy;
|
|
570
579
|
}
|
|
571
|
-
if ((0,
|
|
580
|
+
if ((0, _analytics.handleExpandWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
572
581
|
return true;
|
|
573
582
|
}
|
|
574
|
-
if (!(0,
|
|
583
|
+
if (!(0, _inside.insideTable)(state)) {
|
|
575
584
|
slice = (0, _transforms.transformSliceNestedExpandToExpand)(slice, state.schema);
|
|
576
585
|
}
|
|
577
|
-
if ((0,
|
|
586
|
+
if ((0, _analytics.handlePastePanelOrDecisionIntoListWithAnalytics)(editorAnalyticsAPI)(view, event, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$l = pluginInjectionApi.list) === null || _pluginInjectionApi$l === void 0 ? void 0 : _pluginInjectionApi$l.actions.findRootParentListNode)(state, dispatch)) {
|
|
578
587
|
return true;
|
|
579
588
|
}
|
|
580
|
-
if ((0,
|
|
589
|
+
if ((0, _analytics.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
581
590
|
return true;
|
|
582
591
|
}
|
|
583
|
-
return (0,
|
|
592
|
+
return (0, _analytics.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
|
|
584
593
|
}
|
|
585
594
|
return false;
|
|
586
595
|
},
|
|
@@ -593,7 +602,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
593
602
|
/* Bitbucket copies diffs as multiple adjacent code blocks
|
|
594
603
|
* so we merge ALL adjacent code blocks to support paste here */
|
|
595
604
|
if (pastedFromBitBucket) {
|
|
596
|
-
slice = (0,
|
|
605
|
+
slice = (0, _codeBlock.transformSliceToJoinAdjacentCodeBlocks)(slice);
|
|
597
606
|
}
|
|
598
607
|
// Filter out expand nodes if allowExpand is false
|
|
599
608
|
if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && (_pluginInjectionApi$e3 = pluginInjectionApi.expand) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.sharedState) !== null && _pluginInjectionApi$e3 !== void 0 && (_pluginInjectionApi$e3 = _pluginInjectionApi$e3.currentState()) !== null && _pluginInjectionApi$e3 !== void 0 && _pluginInjectionApi$e3.allowInsertion)) {
|
|
@@ -602,7 +611,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
602
611
|
slice = (0, _transforms.transformSingleLineCodeBlockToCodeMark)(slice, schema);
|
|
603
612
|
slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
|
|
604
613
|
slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema, pluginInjectionApi);
|
|
605
|
-
slice = (0,
|
|
614
|
+
slice = (0, _decisionList.transformSliceToDecisionList)(slice, schema);
|
|
606
615
|
|
|
607
616
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
608
617
|
slice = (0, _commands.splitParagraphs)(slice, schema);
|
|
@@ -657,7 +666,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
657
666
|
// Remove breakout marks HTML around sync block renderer nodes
|
|
658
667
|
// so the breakout mark doesn't get applied to the wrong nodes
|
|
659
668
|
if (html.indexOf(_syncBlock.SyncBlockRendererDataAttributeName) >= 0) {
|
|
660
|
-
html = (0,
|
|
669
|
+
html = (0, _syncBlock2.removeBreakoutFromRendererSyncBlockHTML)(html);
|
|
661
670
|
}
|
|
662
671
|
|
|
663
672
|
// When platform_editor_nest_table_in_panel is OFF,
|
|
@@ -8,10 +8,11 @@ exports.isImage = void 0;
|
|
|
8
8
|
exports.transformSliceForMedia = transformSliceForMedia;
|
|
9
9
|
exports.unwrapNestedMediaElements = exports.transformSliceToMediaSingleWithNewExperience = exports.transformSliceToCorrectMediaWrapper = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
var
|
|
11
|
+
var _constants = require("@atlaskit/editor-common/media-single/constants");
|
|
12
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
+
var _slice = require("@atlaskit/editor-common/utils/slice");
|
|
13
14
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
14
|
-
var
|
|
15
|
+
var _helpers = require("@atlaskit/media-common/helpers");
|
|
15
16
|
var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
|
|
16
17
|
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; }
|
|
17
18
|
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; }
|
|
@@ -32,7 +33,7 @@ function transformSliceForMedia(slice, schema, api) {
|
|
|
32
33
|
return function (selection) {
|
|
33
34
|
var newSlice = slice;
|
|
34
35
|
if ((0, _utils2.hasParentNodeOfType)([layoutSection, table, bulletList, orderedList, expand, nestedExpand])(selection)) {
|
|
35
|
-
newSlice = (0,
|
|
36
|
+
newSlice = (0, _slice.mapSlice)(newSlice, function (node) {
|
|
36
37
|
var _api$media, _mediaState$mediaOpti;
|
|
37
38
|
var mediaState = api === null || api === void 0 || (_api$media = api.media) === null || _api$media === void 0 ? void 0 : _api$media.sharedState.currentState();
|
|
38
39
|
var extendedOrLegacyAttrs = mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti = mediaState.mediaOptions) !== null && _mediaState$mediaOpti !== void 0 && _mediaState$mediaOpti.allowPixelResizing ? {
|
|
@@ -70,7 +71,7 @@ var transformSliceToCorrectMediaWrapper = exports.transformSliceToCorrectMediaWr
|
|
|
70
71
|
mediaGroup = _schema$nodes2.mediaGroup,
|
|
71
72
|
mediaSingle = _schema$nodes2.mediaSingle,
|
|
72
73
|
media = _schema$nodes2.media;
|
|
73
|
-
return (0,
|
|
74
|
+
return (0, _slice.mapSlice)(slice, function (node, parent) {
|
|
74
75
|
if (!parent && node.type === media) {
|
|
75
76
|
if (mediaSingle && (isImage(node.attrs.__fileMimeType) || node.attrs.type === 'external')) {
|
|
76
77
|
return mediaSingle.createChecked({}, node);
|
|
@@ -92,7 +93,7 @@ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMedia
|
|
|
92
93
|
mediaInline = _schema$nodes3.mediaInline,
|
|
93
94
|
mediaSingle = _schema$nodes3.mediaSingle,
|
|
94
95
|
media = _schema$nodes3.media;
|
|
95
|
-
var newSlice = (0,
|
|
96
|
+
var newSlice = (0, _slice.mapSlice)(slice, function (node) {
|
|
96
97
|
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
97
98
|
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
98
99
|
// sharing dependencies with editor-core to support products using it with various versions
|
|
@@ -103,15 +104,15 @@ var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMedia
|
|
|
103
104
|
var _api$media2, _mediaState$mediaOpti2;
|
|
104
105
|
var mediaState = api === null || api === void 0 || (_api$media2 = api.media) === null || _api$media2 === void 0 ? void 0 : _api$media2.sharedState.currentState();
|
|
105
106
|
return mediaState !== null && mediaState !== void 0 && (_mediaState$mediaOpti2 = mediaState.mediaOptions) !== null && _mediaState$mediaOpti2 !== void 0 && _mediaState$mediaOpti2.allowPixelResizing ? mediaSingle.createChecked({
|
|
106
|
-
width: node.attrs.width ||
|
|
107
|
+
width: node.attrs.width || _constants.DEFAULT_IMAGE_WIDTH,
|
|
107
108
|
widthType: node.attrs.widthType || 'pixel',
|
|
108
109
|
layout: node.attrs.layout
|
|
109
110
|
}, node.content, node.marks) : node;
|
|
110
111
|
}
|
|
111
112
|
return node;
|
|
112
113
|
});
|
|
113
|
-
return (0,
|
|
114
|
-
var __mediaTraceId = (0,
|
|
114
|
+
return (0, _slice.mapSlice)(newSlice, function (node) {
|
|
115
|
+
var __mediaTraceId = (0, _helpers.getRandomHex)(8);
|
|
115
116
|
if (node.type === media) {
|
|
116
117
|
var _api$media3;
|
|
117
118
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$media3 = api.media) === null || _api$media3 === void 0 ? void 0 : _api$media3.commands.trackMediaPaste(node.attrs));
|
|
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _pluginStateFactory = require("@atlaskit/editor-common/utils/plugin-state-factory");
|
|
8
8
|
var _pluginKey = require("./plugin-key");
|
|
9
9
|
var _reducer = require("./reducer");
|
|
10
|
-
var dest = (0,
|
|
10
|
+
var dest = (0, _pluginStateFactory.pluginFactory)(_pluginKey.pluginKey, _reducer.reducer);
|
|
11
11
|
var createPluginState = exports.createPluginState = dest.createPluginState;
|
|
12
12
|
var createCommand = exports.createCommand = dest.createCommand;
|
|
13
13
|
var getPluginState = exports.getPluginState = dest.getPluginState;
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createPlugin = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _enums = require("@atlaskit/editor-common/analytics/types/enums");
|
|
8
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
9
|
var _commands = require("./commands");
|
|
10
10
|
var _pluginFactory = require("./plugin-factory");
|
|
@@ -46,10 +46,10 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
|
|
|
46
46
|
}
|
|
47
47
|
var tr = state.tr;
|
|
48
48
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
49
|
-
action:
|
|
50
|
-
actionSubject:
|
|
51
|
-
actionSubjectId:
|
|
52
|
-
eventType:
|
|
49
|
+
action: _enums.ACTION.MOVED,
|
|
50
|
+
actionSubject: _enums.ACTION_SUBJECT.DOCUMENT,
|
|
51
|
+
actionSubjectId: _enums.ACTION_SUBJECT_ID.NODE,
|
|
52
|
+
eventType: _enums.EVENT_TYPE.TRACK,
|
|
53
53
|
attributes: {
|
|
54
54
|
nodeDepth: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeDepth,
|
|
55
55
|
destinationNodeDepth: (0, _utils.getParentNodeDepth)(state.selection),
|
|
@@ -7,13 +7,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.pluginKey = exports.getPluginState = exports.createPluginState = exports.createCommand = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var
|
|
10
|
+
var _pluginStateFactory = require("@atlaskit/editor-common/utils/plugin-state-factory");
|
|
11
11
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
12
|
var _reducer = require("./reducer");
|
|
13
13
|
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; }
|
|
14
14
|
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; } // eslint-disable-next-line @typescript-eslint/consistent-type-imports
|
|
15
15
|
var pluginKey = exports.pluginKey = new _state.PluginKey('pastePlugin');
|
|
16
|
-
var dest = (0,
|
|
16
|
+
var dest = (0, _pluginStateFactory.pluginFactory)(pluginKey, _reducer.reducer, {
|
|
17
17
|
mapping: function mapping(tr, pluginState) {
|
|
18
18
|
if (tr.docChanged) {
|
|
19
19
|
var atLeastOnePositionChanged = false;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleVSCodeBlock = handleVSCodeBlock;
|
|
7
7
|
var _constants = require("@atlaskit/code/constants");
|
|
8
|
-
var
|
|
8
|
+
var _slice = require("@atlaskit/editor-common/utils/slice");
|
|
9
9
|
function safelyGetVSCodeLanguage(editorData) {
|
|
10
10
|
try {
|
|
11
11
|
var vscodeData = editorData ? JSON.parse(editorData) : undefined;
|
|
@@ -24,7 +24,7 @@ function handleVSCodeBlock(_ref) {
|
|
|
24
24
|
return l.alias[0] === language;
|
|
25
25
|
})) {
|
|
26
26
|
var schema = state.schema;
|
|
27
|
-
slice = (0,
|
|
27
|
+
slice = (0, _slice.mapSlice)(slice, function (node) {
|
|
28
28
|
var _schema$nodes$codeBlo;
|
|
29
29
|
if (node.type.name === ((_schema$nodes$codeBlo = schema.nodes.codeBlock) === null || _schema$nodes$codeBlo === void 0 ? void 0 : _schema$nodes$codeBlo.name)) {
|
|
30
30
|
return schema.nodes.codeBlock.createChecked({
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getMarkdownSliceViaGfm = getMarkdownSliceViaGfm;
|
|
7
|
-
var
|
|
7
|
+
var _error = require("@atlaskit/editor-common/monitoring/error");
|
|
8
8
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
9
9
|
var _index = require("./index");
|
|
10
10
|
/**
|
|
@@ -33,7 +33,7 @@ function getMarkdownSliceViaGfm(text, schema, openStart, openEnd, markdownToPmCo
|
|
|
33
33
|
return new _model.Slice(doc.content, openStart, openEnd);
|
|
34
34
|
}
|
|
35
35
|
} catch (e) {
|
|
36
|
-
void (0,
|
|
36
|
+
void (0, _error.logException)(e instanceof Error ? e : new Error(String(e)), {
|
|
37
37
|
location: 'editor-plugin-paste/getMarkdownSlice'
|
|
38
38
|
});
|
|
39
39
|
}
|