@atlaskit/editor-plugin-paste 2.1.1 → 2.1.3
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 +19 -0
- package/dist/cjs/pm-plugins/analytics.js +4 -4
- package/dist/cjs/pm-plugins/main.js +9 -3
- package/dist/cjs/pm-plugins/util/edge-cases/handleVSCodeBlock.js +42 -0
- package/dist/cjs/pm-plugins/util/handlers.js +1 -16
- package/dist/es2019/pm-plugins/analytics.js +2 -2
- package/dist/es2019/pm-plugins/main.js +9 -3
- package/dist/es2019/pm-plugins/util/edge-cases/handleVSCodeBlock.js +37 -0
- package/dist/es2019/pm-plugins/util/handlers.js +1 -16
- package/dist/esm/pm-plugins/analytics.js +6 -5
- package/dist/esm/pm-plugins/main.js +9 -3
- package/dist/esm/pm-plugins/util/edge-cases/handleVSCodeBlock.js +36 -0
- package/dist/esm/pm-plugins/util/handlers.js +1 -16
- package/dist/types/pm-plugins/analytics.d.ts +1 -1
- package/dist/types/pm-plugins/util/edge-cases/handleVSCodeBlock.d.ts +10 -0
- package/dist/types/pm-plugins/util/handlers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/util/edge-cases/handleVSCodeBlock.d.ts +10 -0
- package/dist/types-ts4.5/pm-plugins/util/handlers.d.ts +1 -1
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 2.1.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#107782](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107782)
|
|
8
|
+
[`bc422d0adbbb5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/bc422d0adbbb5) -
|
|
9
|
+
[ux] ED-26378 remove editor_nest_media_and_codeblock_in_quotes_jira
|
|
10
|
+
- [#107782](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/107782)
|
|
11
|
+
[`cccc7a8347929`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/cccc7a8347929) -
|
|
12
|
+
[ux] ED-26378 Remove editor_nest_media_and_codeblock_in_quotes_jira and
|
|
13
|
+
nestMediaAndCodeblockInQuote
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 2.1.2
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 2.1.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -314,11 +314,11 @@ var handleMarkdownWithAnalytics = exports.handleMarkdownWithAnalytics = function
|
|
|
314
314
|
type: _analytics.PasteTypes.markdown
|
|
315
315
|
}))((0, _handlers.handleMarkdown)(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.card) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.actions) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.queueCardsFromChangedTr));
|
|
316
316
|
};
|
|
317
|
-
var handleRichTextWithAnalytics = exports.handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi
|
|
317
|
+
var handleRichTextWithAnalytics = exports.handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
318
318
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c4;
|
|
319
319
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
320
320
|
type: _analytics.PasteTypes.richText
|
|
321
|
-
}, pluginInjectionApi))((0, _handlers.handleRichText)(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.card) === null || _pluginInjectionApi$c4 === void 0 || (_pluginInjectionApi$c4 = _pluginInjectionApi$c4.actions) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.queueCardsFromChangedTr
|
|
321
|
+
}, pluginInjectionApi))((0, _handlers.handleRichText)(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.card) === null || _pluginInjectionApi$c4 === void 0 || (_pluginInjectionApi$c4 = _pluginInjectionApi$c4.actions) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.queueCardsFromChangedTr));
|
|
322
322
|
};
|
|
323
323
|
var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI) {
|
|
324
324
|
return function (createPayloadByTransaction) {
|
|
@@ -410,12 +410,12 @@ var createPasteMeasurePayload = exports.createPasteMeasurePayload = function cre
|
|
|
410
410
|
}
|
|
411
411
|
};
|
|
412
412
|
};
|
|
413
|
-
var
|
|
413
|
+
var _getContentNodeTypes = exports.getContentNodeTypes = function getContentNodeTypes(content) {
|
|
414
414
|
var nodeTypes = new Set();
|
|
415
415
|
if (content.size) {
|
|
416
416
|
content.forEach(function (node) {
|
|
417
417
|
if (node.content && node.content.size) {
|
|
418
|
-
nodeTypes = new Set([].concat((0, _toConsumableArray2.default)(nodeTypes), (0, _toConsumableArray2.default)(
|
|
418
|
+
nodeTypes = new Set([].concat((0, _toConsumableArray2.default)(nodeTypes), (0, _toConsumableArray2.default)(_getContentNodeTypes(node.content))));
|
|
419
419
|
}
|
|
420
420
|
nodeTypes.add(node.type.name);
|
|
421
421
|
});
|
|
@@ -30,6 +30,7 @@ var _analytics2 = require("./analytics");
|
|
|
30
30
|
var _clipboardTextSerializer = require("./clipboard-text-serializer");
|
|
31
31
|
var _pluginFactory = require("./plugin-factory");
|
|
32
32
|
var _util = require("./util");
|
|
33
|
+
var _handleVSCodeBlock = require("./util/edge-cases/handleVSCodeBlock");
|
|
33
34
|
var _handlers = require("./util/handlers");
|
|
34
35
|
var _tinyMCE = require("./util/tinyMCE");
|
|
35
36
|
var isInsideBlockQuote = exports.isInsideBlockQuote = function isInsideBlockQuote(state) {
|
|
@@ -275,6 +276,12 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
275
276
|
view.dispatch(tr.setMeta('uiEvent', 'paste'));
|
|
276
277
|
};
|
|
277
278
|
slice = (0, _handlers.handleParagraphBlockMarks)(state, slice);
|
|
279
|
+
slice = (0, _handleVSCodeBlock.handleVSCodeBlock)({
|
|
280
|
+
state: state,
|
|
281
|
+
slice: slice,
|
|
282
|
+
event: event,
|
|
283
|
+
text: text
|
|
284
|
+
});
|
|
278
285
|
var plainTextPasteSlice = (0, _utils.linkifyContent)(state.schema)(slice);
|
|
279
286
|
if ((0, _analytics2.handlePasteAsPlainTextWithAnalytics)(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
|
|
280
287
|
return true;
|
|
@@ -399,7 +406,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
399
406
|
|
|
400
407
|
// finally, handle rich-text copy-paste
|
|
401
408
|
if (isRichText || isNestedMarkdownTable) {
|
|
402
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l
|
|
409
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
403
410
|
// linkify the text where possible
|
|
404
411
|
slice = (0, _utils.linkifyContent)(state.schema)(slice);
|
|
405
412
|
if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
|
|
@@ -468,8 +475,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
468
475
|
if ((0, _analytics2.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
469
476
|
return true;
|
|
470
477
|
}
|
|
471
|
-
|
|
472
|
-
return (0, _analytics2.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
478
|
+
return (0, _analytics2.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi)(state, dispatch);
|
|
473
479
|
}
|
|
474
480
|
return false;
|
|
475
481
|
},
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.handleVSCodeBlock = handleVSCodeBlock;
|
|
7
|
+
var _constants = require("@atlaskit/code/constants");
|
|
8
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
function safelyGetVSCodeLanguage(editorData) {
|
|
11
|
+
try {
|
|
12
|
+
var vscodeData = editorData ? JSON.parse(editorData) : undefined;
|
|
13
|
+
return vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;
|
|
14
|
+
} catch (_e) {}
|
|
15
|
+
}
|
|
16
|
+
function handleVSCodeBlock(_ref) {
|
|
17
|
+
var _event$clipboardData;
|
|
18
|
+
var state = _ref.state,
|
|
19
|
+
slice = _ref.slice,
|
|
20
|
+
text = _ref.text,
|
|
21
|
+
event = _ref.event;
|
|
22
|
+
if (!(0, _platformFeatureFlags.fg)('platform_editor_vs_code_block_paste')) {
|
|
23
|
+
return slice;
|
|
24
|
+
}
|
|
25
|
+
var vscodeData = event === null || event === void 0 || (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('vscode-editor-data');
|
|
26
|
+
var language = safelyGetVSCodeLanguage(vscodeData);
|
|
27
|
+
if (text && language && _constants.SUPPORTED_LANGUAGES.some(function (l) {
|
|
28
|
+
return l.alias[0] === language;
|
|
29
|
+
})) {
|
|
30
|
+
var schema = state.schema;
|
|
31
|
+
slice = (0, _utils.mapSlice)(slice, function (node) {
|
|
32
|
+
var _schema$nodes$codeBlo;
|
|
33
|
+
if (node.type.name === ((_schema$nodes$codeBlo = schema.nodes.codeBlock) === null || _schema$nodes$codeBlo === void 0 ? void 0 : _schema$nodes$codeBlo.name)) {
|
|
34
|
+
return schema.nodes.codeBlock.createChecked({
|
|
35
|
+
language: language
|
|
36
|
+
}, schema.text(text));
|
|
37
|
+
}
|
|
38
|
+
return node;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return slice;
|
|
42
|
+
}
|
|
@@ -44,7 +44,6 @@ var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
|
44
44
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
45
45
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
46
46
|
var _commands = require("../../editor-commands/commands");
|
|
47
|
-
var _main = require("../main");
|
|
48
47
|
var _pluginFactory = require("../plugin-factory");
|
|
49
48
|
var _edgeCases = require("./edge-cases");
|
|
50
49
|
var _lists = require("./edge-cases/lists");
|
|
@@ -971,11 +970,10 @@ function flattenNestedListInSlice(slice) {
|
|
|
971
970
|
var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
972
971
|
return new _model.Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
973
972
|
}
|
|
974
|
-
function handleRichText(slice, queueCardsFromChangedTr
|
|
973
|
+
function handleRichText(slice, queueCardsFromChangedTr) {
|
|
975
974
|
return function (state, dispatch) {
|
|
976
975
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
977
976
|
var _state$schema$nodes4 = state.schema.nodes,
|
|
978
|
-
blockquote = _state$schema$nodes4.blockquote,
|
|
979
977
|
codeBlock = _state$schema$nodes4.codeBlock,
|
|
980
978
|
heading = _state$schema$nodes4.heading,
|
|
981
979
|
paragraph = _state$schema$nodes4.paragraph,
|
|
@@ -1010,25 +1008,12 @@ function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodebloc
|
|
|
1010
1008
|
var noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
1011
1009
|
var panelParentOverCurrentSelection = (0, _utils2.findParentNodeOfType)(panel)(tr.selection);
|
|
1012
1010
|
var isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
1013
|
-
var sliceContainsCodeblockOrMedia = false;
|
|
1014
|
-
var codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
1015
|
-
slice.content.forEach(function (child) {
|
|
1016
|
-
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
1017
|
-
sliceContainsCodeblockOrMedia = true;
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
|
-
var blockquoteNode = (0, _utils2.findParentNodeOfType)(blockquote)(tr.selection);
|
|
1021
1011
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
1022
1012
|
(0, _edgeCases.insertSliceForLists)({
|
|
1023
1013
|
tr: tr,
|
|
1024
1014
|
slice: slice,
|
|
1025
1015
|
schema: schema
|
|
1026
1016
|
});
|
|
1027
|
-
} else if (
|
|
1028
|
-
// If nesting media or codeblock in blockquote is not supported
|
|
1029
|
-
// we want to insert slice after the blockquote.
|
|
1030
|
-
(0, _main.isInsideBlockQuote)(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
1031
|
-
tr = (0, _utils2.safeInsert)(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
1032
1017
|
} else if (noNeedForSafeInsert) {
|
|
1033
1018
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
1034
1019
|
if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
|
|
@@ -291,11 +291,11 @@ export const handleMarkdownWithAnalytics = (view, event, slice, pluginInjectionA
|
|
|
291
291
|
type: PasteTypes.markdown
|
|
292
292
|
}))(handleMarkdown(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c5 = pluginInjectionApi.card) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : (_pluginInjectionApi$c6 = _pluginInjectionApi$c5.actions) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.queueCardsFromChangedTr));
|
|
293
293
|
};
|
|
294
|
-
export const handleRichTextWithAnalytics = (view, event, slice, pluginInjectionApi
|
|
294
|
+
export const handleRichTextWithAnalytics = (view, event, slice, pluginInjectionApi) => {
|
|
295
295
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c7, _pluginInjectionApi$c8;
|
|
296
296
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
297
297
|
type: PasteTypes.richText
|
|
298
|
-
}, pluginInjectionApi))(handleRichText(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.card) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.queueCardsFromChangedTr
|
|
298
|
+
}, pluginInjectionApi))(handleRichText(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.card) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.actions) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : _pluginInjectionApi$c8.queueCardsFromChangedTr));
|
|
299
299
|
};
|
|
300
300
|
const injectAnalyticsPayloadBeforeCommand = editorAnalyticsAPI => createPayloadByTransaction => {
|
|
301
301
|
return mainCommand => {
|
|
@@ -20,6 +20,7 @@ import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnal
|
|
|
20
20
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
21
21
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
22
22
|
import { escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
23
|
+
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
23
24
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
|
|
24
25
|
import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
|
|
25
26
|
export const isInsideBlockQuote = state => {
|
|
@@ -249,6 +250,12 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
249
250
|
view.dispatch(tr.setMeta('uiEvent', 'paste'));
|
|
250
251
|
};
|
|
251
252
|
slice = handleParagraphBlockMarks(state, slice);
|
|
253
|
+
slice = handleVSCodeBlock({
|
|
254
|
+
state,
|
|
255
|
+
slice,
|
|
256
|
+
event,
|
|
257
|
+
text
|
|
258
|
+
});
|
|
252
259
|
const plainTextPasteSlice = linkifyContent(state.schema)(slice);
|
|
253
260
|
if (handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
|
|
254
261
|
return true;
|
|
@@ -375,7 +382,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
375
382
|
|
|
376
383
|
// finally, handle rich-text copy-paste
|
|
377
384
|
if (isRichText || isNestedMarkdownTable) {
|
|
378
|
-
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l
|
|
385
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l;
|
|
379
386
|
// linkify the text where possible
|
|
380
387
|
slice = linkifyContent(state.schema)(slice);
|
|
381
388
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -442,8 +449,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
442
449
|
if (handlePasteNonNestableBlockNodesIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
443
450
|
return true;
|
|
444
451
|
}
|
|
445
|
-
|
|
446
|
-
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
452
|
+
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi)(state, dispatch);
|
|
447
453
|
}
|
|
448
454
|
return false;
|
|
449
455
|
},
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { SUPPORTED_LANGUAGES } from '@atlaskit/code/constants';
|
|
2
|
+
import { mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
function safelyGetVSCodeLanguage(editorData) {
|
|
5
|
+
try {
|
|
6
|
+
const vscodeData = editorData ? JSON.parse(editorData) : undefined;
|
|
7
|
+
return vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;
|
|
8
|
+
} catch (_e) {}
|
|
9
|
+
}
|
|
10
|
+
export function handleVSCodeBlock({
|
|
11
|
+
state,
|
|
12
|
+
slice,
|
|
13
|
+
text,
|
|
14
|
+
event
|
|
15
|
+
}) {
|
|
16
|
+
var _event$clipboardData;
|
|
17
|
+
if (!fg('platform_editor_vs_code_block_paste')) {
|
|
18
|
+
return slice;
|
|
19
|
+
}
|
|
20
|
+
const vscodeData = event === null || event === void 0 ? void 0 : (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('vscode-editor-data');
|
|
21
|
+
const language = safelyGetVSCodeLanguage(vscodeData);
|
|
22
|
+
if (text && language && SUPPORTED_LANGUAGES.some(l => l.alias[0] === language)) {
|
|
23
|
+
const {
|
|
24
|
+
schema
|
|
25
|
+
} = state;
|
|
26
|
+
slice = mapSlice(slice, node => {
|
|
27
|
+
var _schema$nodes$codeBlo;
|
|
28
|
+
if (node.type.name === ((_schema$nodes$codeBlo = schema.nodes.codeBlock) === null || _schema$nodes$codeBlo === void 0 ? void 0 : _schema$nodes$codeBlo.name)) {
|
|
29
|
+
return schema.nodes.codeBlock.createChecked({
|
|
30
|
+
language
|
|
31
|
+
}, schema.text(text));
|
|
32
|
+
}
|
|
33
|
+
return node;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
return slice;
|
|
37
|
+
}
|
|
@@ -15,7 +15,6 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
15
15
|
// TODO: ED-20519 Needs Macro extraction
|
|
16
16
|
|
|
17
17
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
|
|
18
|
-
import { isInsideBlockQuote } from '../main';
|
|
19
18
|
import { getPluginState as getPastePluginState } from '../plugin-factory';
|
|
20
19
|
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
21
20
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
@@ -951,11 +950,10 @@ export function flattenNestedListInSlice(slice) {
|
|
|
951
950
|
const contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
952
951
|
return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
953
952
|
}
|
|
954
|
-
export function handleRichText(slice, queueCardsFromChangedTr
|
|
953
|
+
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
955
954
|
return (state, dispatch) => {
|
|
956
955
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
957
956
|
const {
|
|
958
|
-
blockquote,
|
|
959
957
|
codeBlock,
|
|
960
958
|
heading,
|
|
961
959
|
paragraph,
|
|
@@ -993,25 +991,12 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
993
991
|
const noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
994
992
|
const panelParentOverCurrentSelection = findParentNodeOfType(panel)(tr.selection);
|
|
995
993
|
const isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
996
|
-
let sliceContainsCodeblockOrMedia = false;
|
|
997
|
-
const codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
998
|
-
slice.content.forEach(child => {
|
|
999
|
-
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
1000
|
-
sliceContainsCodeblockOrMedia = true;
|
|
1001
|
-
}
|
|
1002
|
-
});
|
|
1003
|
-
const blockquoteNode = findParentNodeOfType(blockquote)(tr.selection);
|
|
1004
994
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
1005
995
|
insertSliceForLists({
|
|
1006
996
|
tr,
|
|
1007
997
|
slice,
|
|
1008
998
|
schema
|
|
1009
999
|
});
|
|
1010
|
-
} else if (
|
|
1011
|
-
// If nesting media or codeblock in blockquote is not supported
|
|
1012
|
-
// we want to insert slice after the blockquote.
|
|
1013
|
-
isInsideBlockQuote(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
1014
|
-
tr = safeInsert(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
1015
1000
|
} else if (noNeedForSafeInsert) {
|
|
1016
1001
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
1017
1002
|
if ((firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 ? void 0 : (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
|
|
@@ -302,11 +302,11 @@ export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(vi
|
|
|
302
302
|
type: PasteTypes.markdown
|
|
303
303
|
}))(handleMarkdown(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.card) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.actions) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.queueCardsFromChangedTr));
|
|
304
304
|
};
|
|
305
|
-
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi
|
|
305
|
+
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
306
306
|
var _pluginInjectionApi$a4, _pluginInjectionApi$c4;
|
|
307
307
|
return injectAnalyticsPayloadBeforeCommand(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
308
308
|
type: PasteTypes.richText
|
|
309
|
-
}, pluginInjectionApi))(handleRichText(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.card) === null || _pluginInjectionApi$c4 === void 0 || (_pluginInjectionApi$c4 = _pluginInjectionApi$c4.actions) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.queueCardsFromChangedTr
|
|
309
|
+
}, pluginInjectionApi))(handleRichText(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.card) === null || _pluginInjectionApi$c4 === void 0 || (_pluginInjectionApi$c4 = _pluginInjectionApi$c4.actions) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : _pluginInjectionApi$c4.queueCardsFromChangedTr));
|
|
310
310
|
};
|
|
311
311
|
var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI) {
|
|
312
312
|
return function (createPayloadByTransaction) {
|
|
@@ -398,15 +398,16 @@ export var createPasteMeasurePayload = function createPasteMeasurePayload(_ref3)
|
|
|
398
398
|
}
|
|
399
399
|
};
|
|
400
400
|
};
|
|
401
|
-
|
|
401
|
+
var _getContentNodeTypes = function getContentNodeTypes(content) {
|
|
402
402
|
var nodeTypes = new Set();
|
|
403
403
|
if (content.size) {
|
|
404
404
|
content.forEach(function (node) {
|
|
405
405
|
if (node.content && node.content.size) {
|
|
406
|
-
nodeTypes = new Set([].concat(_toConsumableArray(nodeTypes), _toConsumableArray(
|
|
406
|
+
nodeTypes = new Set([].concat(_toConsumableArray(nodeTypes), _toConsumableArray(_getContentNodeTypes(node.content))));
|
|
407
407
|
}
|
|
408
408
|
nodeTypes.add(node.type.name);
|
|
409
409
|
});
|
|
410
410
|
}
|
|
411
411
|
return Array.from(nodeTypes);
|
|
412
|
-
};
|
|
412
|
+
};
|
|
413
|
+
export { _getContentNodeTypes as getContentNodeTypes };
|
|
@@ -22,6 +22,7 @@ import { createPasteMeasurePayload, getContentNodeTypes, handleCodeBlockWithAnal
|
|
|
22
22
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
23
23
|
import { createPluginState, pluginKey as stateKey } from './plugin-factory';
|
|
24
24
|
import { escapeLinks, getPasteSource, htmlContainsSingleFile, htmlHasInvalidLinkTags, isPastedFromExcel, isPastedFromWord, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from './util';
|
|
25
|
+
import { handleVSCodeBlock } from './util/edge-cases/handleVSCodeBlock';
|
|
25
26
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks, handleTableContentPasteInBodiedExtension } from './util/handlers';
|
|
26
27
|
import { htmlHasIncompleteTable, isPastedFromTinyMCEConfluence, tryRebuildCompleteTableHtml } from './util/tinyMCE';
|
|
27
28
|
export var isInsideBlockQuote = function isInsideBlockQuote(state) {
|
|
@@ -267,6 +268,12 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
267
268
|
view.dispatch(tr.setMeta('uiEvent', 'paste'));
|
|
268
269
|
};
|
|
269
270
|
slice = handleParagraphBlockMarks(state, slice);
|
|
271
|
+
slice = handleVSCodeBlock({
|
|
272
|
+
state: state,
|
|
273
|
+
slice: slice,
|
|
274
|
+
event: event,
|
|
275
|
+
text: text
|
|
276
|
+
});
|
|
270
277
|
var plainTextPasteSlice = linkifyContent(state.schema)(slice);
|
|
271
278
|
if (handlePasteAsPlainTextWithAnalytics(editorAnalyticsAPI)(view, event, plainTextPasteSlice)(state, dispatch, view)) {
|
|
272
279
|
return true;
|
|
@@ -391,7 +398,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
391
398
|
|
|
392
399
|
// finally, handle rich-text copy-paste
|
|
393
400
|
if (isRichText || isNestedMarkdownTable) {
|
|
394
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l
|
|
401
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
395
402
|
// linkify the text where possible
|
|
396
403
|
slice = linkifyContent(state.schema)(slice);
|
|
397
404
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -460,8 +467,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
460
467
|
if (handlePasteNonNestableBlockNodesIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
461
468
|
return true;
|
|
462
469
|
}
|
|
463
|
-
|
|
464
|
-
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
470
|
+
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi)(state, dispatch);
|
|
465
471
|
}
|
|
466
472
|
return false;
|
|
467
473
|
},
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { SUPPORTED_LANGUAGES } from '@atlaskit/code/constants';
|
|
2
|
+
import { mapSlice } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
function safelyGetVSCodeLanguage(editorData) {
|
|
5
|
+
try {
|
|
6
|
+
var vscodeData = editorData ? JSON.parse(editorData) : undefined;
|
|
7
|
+
return vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;
|
|
8
|
+
} catch (_e) {}
|
|
9
|
+
}
|
|
10
|
+
export function handleVSCodeBlock(_ref) {
|
|
11
|
+
var _event$clipboardData;
|
|
12
|
+
var state = _ref.state,
|
|
13
|
+
slice = _ref.slice,
|
|
14
|
+
text = _ref.text,
|
|
15
|
+
event = _ref.event;
|
|
16
|
+
if (!fg('platform_editor_vs_code_block_paste')) {
|
|
17
|
+
return slice;
|
|
18
|
+
}
|
|
19
|
+
var vscodeData = event === null || event === void 0 || (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData('vscode-editor-data');
|
|
20
|
+
var language = safelyGetVSCodeLanguage(vscodeData);
|
|
21
|
+
if (text && language && SUPPORTED_LANGUAGES.some(function (l) {
|
|
22
|
+
return l.alias[0] === language;
|
|
23
|
+
})) {
|
|
24
|
+
var schema = state.schema;
|
|
25
|
+
slice = mapSlice(slice, function (node) {
|
|
26
|
+
var _schema$nodes$codeBlo;
|
|
27
|
+
if (node.type.name === ((_schema$nodes$codeBlo = schema.nodes.codeBlock) === null || _schema$nodes$codeBlo === void 0 ? void 0 : _schema$nodes$codeBlo.name)) {
|
|
28
|
+
return schema.nodes.codeBlock.createChecked({
|
|
29
|
+
language: language
|
|
30
|
+
}, schema.text(text));
|
|
31
|
+
}
|
|
32
|
+
return node;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return slice;
|
|
36
|
+
}
|
|
@@ -23,7 +23,6 @@ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
|
23
23
|
// TODO: ED-20519 Needs Macro extraction
|
|
24
24
|
|
|
25
25
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from '../../editor-commands/commands';
|
|
26
|
-
import { isInsideBlockQuote } from '../main';
|
|
27
26
|
import { getPluginState as getPastePluginState } from '../plugin-factory';
|
|
28
27
|
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote, updateSelectionAfterReplace } from './edge-cases';
|
|
29
28
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
@@ -945,11 +944,10 @@ export function flattenNestedListInSlice(slice) {
|
|
|
945
944
|
var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
946
945
|
return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
947
946
|
}
|
|
948
|
-
export function handleRichText(slice, queueCardsFromChangedTr
|
|
947
|
+
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
949
948
|
return function (state, dispatch) {
|
|
950
949
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
951
950
|
var _state$schema$nodes4 = state.schema.nodes,
|
|
952
|
-
blockquote = _state$schema$nodes4.blockquote,
|
|
953
951
|
codeBlock = _state$schema$nodes4.codeBlock,
|
|
954
952
|
heading = _state$schema$nodes4.heading,
|
|
955
953
|
paragraph = _state$schema$nodes4.paragraph,
|
|
@@ -984,25 +982,12 @@ export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrC
|
|
|
984
982
|
var noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
985
983
|
var panelParentOverCurrentSelection = findParentNodeOfType(panel)(tr.selection);
|
|
986
984
|
var isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
987
|
-
var sliceContainsCodeblockOrMedia = false;
|
|
988
|
-
var codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
989
|
-
slice.content.forEach(function (child) {
|
|
990
|
-
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
991
|
-
sliceContainsCodeblockOrMedia = true;
|
|
992
|
-
}
|
|
993
|
-
});
|
|
994
|
-
var blockquoteNode = findParentNodeOfType(blockquote)(tr.selection);
|
|
995
985
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
996
986
|
insertSliceForLists({
|
|
997
987
|
tr: tr,
|
|
998
988
|
slice: slice,
|
|
999
989
|
schema: schema
|
|
1000
990
|
});
|
|
1001
|
-
} else if (
|
|
1002
|
-
// If nesting media or codeblock in blockquote is not supported
|
|
1003
|
-
// we want to insert slice after the blockquote.
|
|
1004
|
-
isInsideBlockQuote(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
1005
|
-
tr = safeInsert(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
1006
991
|
} else if (noNeedForSafeInsert) {
|
|
1007
992
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
1008
993
|
if ((firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty2 = firstChildOfSlice.type) === null || _firstChildOfSlice$ty2 === void 0 ? void 0 : _firstChildOfSlice$ty2.name) === 'blockquote' && firstChildOfSlice !== null && firstChildOfSlice !== void 0 && (_firstChildOfSlice$co = firstChildOfSlice.content.firstChild) !== null && _firstChildOfSlice$co !== void 0 && _firstChildOfSlice$co.type.name && ['bulletList', 'orderedList', 'mediaSingle'].includes(firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$co2 = firstChildOfSlice.content.firstChild) === null || _firstChildOfSlice$co2 === void 0 ? void 0 : _firstChildOfSlice$co2.type.name)) {
|
|
@@ -28,7 +28,7 @@ export declare const handleCodeBlockWithAnalytics: (editorAnalyticsAPI: EditorAn
|
|
|
28
28
|
export declare const handleMediaSingleWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined) => Command;
|
|
29
29
|
export declare const handlePastePreservingMarksWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
30
30
|
export declare const handleMarkdownWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
31
|
-
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined
|
|
31
|
+
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
32
32
|
export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
|
|
33
33
|
export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
34
|
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
interface VSCodeBlockParams {
|
|
4
|
+
state: EditorState;
|
|
5
|
+
slice: Slice;
|
|
6
|
+
text: string;
|
|
7
|
+
event: ClipboardEvent;
|
|
8
|
+
}
|
|
9
|
+
export declare function handleVSCodeBlock({ state, slice, text, event }: VSCodeBlockParams): Slice;
|
|
10
|
+
export {};
|
|
@@ -52,7 +52,7 @@ export declare function handleParagraphBlockMarks(state: EditorState, slice: Sli
|
|
|
52
52
|
* ┗━p -> "two"
|
|
53
53
|
*/
|
|
54
54
|
export declare function flattenNestedListInSlice(slice: Slice): Slice;
|
|
55
|
-
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined
|
|
55
|
+
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
56
56
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
57
57
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
58
58
|
export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
|
|
@@ -28,7 +28,7 @@ export declare const handleCodeBlockWithAnalytics: (editorAnalyticsAPI: EditorAn
|
|
|
28
28
|
export declare const handleMediaSingleWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, insertMediaAsMediaSingle: InsertMediaAsMediaSingle | undefined) => Command;
|
|
29
29
|
export declare const handlePastePreservingMarksWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, type: PasteType, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
30
30
|
export declare const handleMarkdownWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
31
|
-
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined
|
|
31
|
+
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined) => Command;
|
|
32
32
|
export declare const handlePastePanelOrDecisionIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice, findRootParentListNode: FindRootParentListNode | undefined) => Command;
|
|
33
33
|
export declare const handlePasteNonNestableBlockNodesIntoListWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
34
34
|
export declare const handleExpandWithAnalytics: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, isNestingExpandsSupported: boolean) => (view: EditorView, event: ClipboardEvent, slice: Slice) => Command;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Slice } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
interface VSCodeBlockParams {
|
|
4
|
+
state: EditorState;
|
|
5
|
+
slice: Slice;
|
|
6
|
+
text: string;
|
|
7
|
+
event: ClipboardEvent;
|
|
8
|
+
}
|
|
9
|
+
export declare function handleVSCodeBlock({ state, slice, text, event }: VSCodeBlockParams): Slice;
|
|
10
|
+
export {};
|
|
@@ -52,7 +52,7 @@ export declare function handleParagraphBlockMarks(state: EditorState, slice: Sli
|
|
|
52
52
|
* ┗━p -> "two"
|
|
53
53
|
*/
|
|
54
54
|
export declare function flattenNestedListInSlice(slice: Slice): Slice;
|
|
55
|
-
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined
|
|
55
|
+
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
56
56
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
57
57
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
58
58
|
export declare function checkTaskListInList(state: EditorState, slice: Slice): boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,8 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
|
-
"@atlaskit/
|
|
35
|
+
"@atlaskit/code": "^15.6.9",
|
|
36
|
+
"@atlaskit/editor-common": "^99.8.0",
|
|
36
37
|
"@atlaskit/editor-markdown-transformer": "^5.14.0",
|
|
37
38
|
"@atlaskit/editor-plugin-analytics": "^1.11.0",
|
|
38
39
|
"@atlaskit/editor-plugin-annotation": "^1.27.0",
|
|
@@ -46,8 +47,8 @@
|
|
|
46
47
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
47
48
|
"@atlaskit/media-client": "^31.1.0",
|
|
48
49
|
"@atlaskit/media-common": "^11.8.0",
|
|
49
|
-
"@atlaskit/platform-feature-flags": "^0.
|
|
50
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
50
|
+
"@atlaskit/platform-feature-flags": "^1.0.0",
|
|
51
|
+
"@atlaskit/tmp-editor-statsig": "^2.42.0",
|
|
51
52
|
"@babel/runtime": "^7.0.0",
|
|
52
53
|
"lodash": "^4.17.21",
|
|
53
54
|
"uuid": "^3.1.0"
|
|
@@ -113,10 +114,10 @@
|
|
|
113
114
|
"platform_editor_nest_nested_expand_in_expand_jira": {
|
|
114
115
|
"type": "boolean"
|
|
115
116
|
},
|
|
116
|
-
"
|
|
117
|
+
"platform_editor_use_nested_table_pm_nodes": {
|
|
117
118
|
"type": "boolean"
|
|
118
119
|
},
|
|
119
|
-
"
|
|
120
|
+
"platform_editor_vs_code_block_paste": {
|
|
120
121
|
"type": "boolean"
|
|
121
122
|
},
|
|
122
123
|
"platform_editor_advanced_layouts_post_fix_patch_2": {
|