@atlaskit/editor-plugin-paste 1.12.4 → 1.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/handlers.js +16 -1
- package/dist/cjs/pm-plugins/analytics.js +2 -2
- package/dist/cjs/pm-plugins/main.js +7 -3
- package/dist/cjs/pm-plugins/move-analytics/plugin.js +12 -50
- package/dist/cjs/pm-plugins/move-analytics/utils.js +1 -86
- package/dist/es2019/handlers.js +16 -1
- package/dist/es2019/pm-plugins/analytics.js +2 -2
- package/dist/es2019/pm-plugins/main.js +7 -3
- package/dist/es2019/pm-plugins/move-analytics/plugin.js +9 -46
- package/dist/es2019/pm-plugins/move-analytics/utils.js +0 -97
- package/dist/esm/handlers.js +16 -1
- package/dist/esm/pm-plugins/analytics.js +2 -2
- package/dist/esm/pm-plugins/main.js +7 -3
- package/dist/esm/pm-plugins/move-analytics/plugin.js +13 -50
- package/dist/esm/pm-plugins/move-analytics/utils.js +0 -85
- package/dist/types/handlers.d.ts +1 -1
- package/dist/types/pm-plugins/analytics.d.ts +1 -1
- package/dist/types/pm-plugins/move-analytics/utils.d.ts +0 -8
- package/dist/types-ts4.5/handlers.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/analytics.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/move-analytics/utils.d.ts +0 -8
- package/package.json +8 -5
- package/.eslintrc.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-paste
|
|
2
2
|
|
|
3
|
+
## 1.12.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`037ce68784704`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/037ce68784704) -
|
|
8
|
+
ED-25123 Update document moved to fire for all cases
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 1.12.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#143700](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/143700)
|
|
16
|
+
[`9ef9b7e3bc1d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9ef9b7e3bc1d7) -
|
|
17
|
+
[ux] [ED-24868] Paste gating for codeblock and media in quotes.
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 1.12.4
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/cjs/handlers.js
CHANGED
|
@@ -41,6 +41,7 @@ var _utils3 = require("@atlaskit/editor-tables/utils");
|
|
|
41
41
|
var _commands = require("./commands");
|
|
42
42
|
var _edgeCases = require("./edge-cases");
|
|
43
43
|
var _lists = require("./edge-cases/lists");
|
|
44
|
+
var _main = require("./pm-plugins/main");
|
|
44
45
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
45
46
|
var _util = require("./util");
|
|
46
47
|
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; } } }; }
|
|
@@ -905,10 +906,11 @@ function flattenNestedListInSlice(slice) {
|
|
|
905
906
|
var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
906
907
|
return new _model.Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
907
908
|
}
|
|
908
|
-
function handleRichText(slice, queueCardsFromChangedTr) {
|
|
909
|
+
function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodeblockSupported) {
|
|
909
910
|
return function (state, dispatch) {
|
|
910
911
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
911
912
|
var _state$schema$nodes4 = state.schema.nodes,
|
|
913
|
+
blockquote = _state$schema$nodes4.blockquote,
|
|
912
914
|
codeBlock = _state$schema$nodes4.codeBlock,
|
|
913
915
|
heading = _state$schema$nodes4.heading,
|
|
914
916
|
paragraph = _state$schema$nodes4.paragraph,
|
|
@@ -943,12 +945,25 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
943
945
|
var noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
944
946
|
var panelParentOverCurrentSelection = (0, _utils2.findParentNodeOfType)(panel)(tr.selection);
|
|
945
947
|
var isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
948
|
+
var sliceContainsCodeblockOrMedia = false;
|
|
949
|
+
var codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
950
|
+
slice.content.forEach(function (child) {
|
|
951
|
+
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
952
|
+
sliceContainsCodeblockOrMedia = true;
|
|
953
|
+
}
|
|
954
|
+
});
|
|
955
|
+
var blockquoteNode = (0, _utils2.findParentNodeOfType)(blockquote)(tr.selection);
|
|
946
956
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
947
957
|
(0, _edgeCases.insertSliceForLists)({
|
|
948
958
|
tr: tr,
|
|
949
959
|
slice: slice,
|
|
950
960
|
schema: schema
|
|
951
961
|
});
|
|
962
|
+
} else if (
|
|
963
|
+
// If nesting media or codeblock in blockquote is not supported
|
|
964
|
+
// we want to insert slice after the blockquote.
|
|
965
|
+
(0, _main.isInsideBlockQuote)(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
966
|
+
tr = (0, _utils2.safeInsert)(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
952
967
|
} else if (noNeedForSafeInsert) {
|
|
953
968
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
954
969
|
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)) {
|
|
@@ -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, isNestingMediaOrCodeblockSupported) {
|
|
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, isNestingMediaOrCodeblockSupported));
|
|
322
322
|
};
|
|
323
323
|
var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI) {
|
|
324
324
|
return function (createPayloadByTransaction) {
|
|
@@ -173,8 +173,11 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
173
173
|
/**
|
|
174
174
|
* We want to return false for external copied image to allow
|
|
175
175
|
* it to be uploaded by the client.
|
|
176
|
+
*
|
|
177
|
+
* Scenario where we are pasting an external image inside a block quote
|
|
178
|
+
* is skipped and handled in handleRichText
|
|
176
179
|
*/
|
|
177
|
-
if ((0, _util.htmlContainsSingleFile)(html)) {
|
|
180
|
+
if ((0, _util.htmlContainsSingleFile)(html) && !isInsideBlockQuote(view.state)) {
|
|
178
181
|
return true;
|
|
179
182
|
}
|
|
180
183
|
|
|
@@ -370,7 +373,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
370
373
|
|
|
371
374
|
// finally, handle rich-text copy-paste
|
|
372
375
|
if (isRichText || isNestedMarkdownTable) {
|
|
373
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
376
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l, _pluginInjectionApi$f2;
|
|
374
377
|
// linkify the text where possible
|
|
375
378
|
slice = (0, _utils.linkifyContent)(state.schema)(slice);
|
|
376
379
|
if ((0, _analytics2.handlePasteLinkOnSelectedTextWithAnalytics)(editorAnalyticsAPI)(view, event, slice, _analytics.PasteTypes.richText)(state, dispatch)) {
|
|
@@ -447,7 +450,8 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
447
450
|
if ((0, _analytics2.handlePasteNonNestableBlockNodesIntoListWithAnalytics)(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
448
451
|
return true;
|
|
449
452
|
}
|
|
450
|
-
|
|
453
|
+
var isNestingMediaOrCodeblockSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.sharedState.currentState()) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.nestMediaAndCodeblockInQuote) || (0, _platformFeatureFlags.fg)('editor_nest_media_and_codeblock_in_quotes_jira');
|
|
454
|
+
return (0, _analytics2.handleRichTextWithAnalytics)(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
451
455
|
}
|
|
452
456
|
return false;
|
|
453
457
|
},
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.createPlugin = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
11
9
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -14,8 +12,6 @@ var _pluginFactory = require("./plugin-factory");
|
|
|
14
12
|
var _pluginKey = require("./plugin-key");
|
|
15
13
|
var _types = require("./types");
|
|
16
14
|
var _utils = require("./utils");
|
|
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; }
|
|
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; }
|
|
19
15
|
// This plugin exists only in FullPage/FullWidth Editor and is used to register an event that tells us
|
|
20
16
|
// that a user cut and than pasted a node. This order of actions could be considered an alternative
|
|
21
17
|
// to new Drag and Drop functionality. The event (document moved) is not accurate, but should be enough to be
|
|
@@ -44,15 +40,9 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
|
|
|
44
40
|
if (!hasCutAction) {
|
|
45
41
|
return;
|
|
46
42
|
}
|
|
47
|
-
var content = slice.content
|
|
48
|
-
size = slice.size;
|
|
43
|
+
var content = slice.content;
|
|
49
44
|
var nodeName = (_content$firstChild = content.firstChild) === null || _content$firstChild === void 0 ? void 0 : _content$firstChild.type.name;
|
|
50
|
-
|
|
51
|
-
// We should not account for pastes that go inside another node and create nested content as DnD can't do it when nested-dnd is disabled
|
|
52
|
-
if ((!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !(0, _utils.isValidNodeName)(contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName, nodeName) || size !== (contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.size) || !(0, _utils.isCursorSelectionAndInsideTopLevelNode)(state.selection)) && (0, _experiments.editorExperiment)('nested-dnd', false)) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !(0, _utils.isCursorSelectionAtTopLevel)(state.selection) && (0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
45
|
+
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !(0, _utils.isCursorSelectionAtTopLevel)(state.selection)) {
|
|
56
46
|
return;
|
|
57
47
|
}
|
|
58
48
|
var tr = state.tr;
|
|
@@ -61,12 +51,13 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
|
|
|
61
51
|
actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
|
|
62
52
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.NODE,
|
|
63
53
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
64
|
-
attributes:
|
|
65
|
-
nodeType: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName
|
|
66
|
-
}, (0, _experiments.editorExperiment)('nested-dnd', true) && {
|
|
54
|
+
attributes: {
|
|
55
|
+
nodeType: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName,
|
|
67
56
|
nodeDepth: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeDepth,
|
|
68
57
|
destinationNodeDepth: (0, _utils.getParentNodeDepth)(state.selection)
|
|
69
|
-
|
|
58
|
+
|
|
59
|
+
// keep nodeName from copied slice
|
|
60
|
+
}
|
|
70
61
|
})(tr);
|
|
71
62
|
|
|
72
63
|
// reset to default state
|
|
@@ -104,52 +95,23 @@ var createPlugin = exports.createPlugin = function createPlugin(dispatch, editor
|
|
|
104
95
|
resetState = true;
|
|
105
96
|
}
|
|
106
97
|
var selection = state.selection;
|
|
107
|
-
|
|
108
|
-
// So we are only interested in cut slices that contain the entire node, not just a part of it.
|
|
109
|
-
if (!resetState && nodeName === 'paragraph' && !(0, _utils.isEntireTopLevelHeadingOrParagraphSelected)(selection, nodeName) && (0, _experiments.editorExperiment)('nested-dnd', false)) {
|
|
110
|
-
resetState = true;
|
|
111
|
-
}
|
|
112
|
-
if (!resetState && nodeName === 'heading' && !(0, _utils.isEntireTopLevelHeadingOrParagraphSelected)(selection, nodeName) && (0, _experiments.editorExperiment)('nested-dnd', false)) {
|
|
113
|
-
resetState = true;
|
|
114
|
-
}
|
|
115
|
-
if (!resetState && !(0, _utils.isEntireNestedParagraphOrHeadingSelected)(selection) && (0, _experiments.editorExperiment)('nested-dnd', true)) {
|
|
116
|
-
resetState = true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// DnD can't drag just one paragraph (when blockquote contains multiple paragraphs) or just a part of a paragraph in the blockquote.
|
|
120
|
-
// DnD will select and drag the whole blockquote. So we need to register cut events that have the entire blockquote too.
|
|
121
|
-
if (!resetState && nodeName === 'blockquote' && !(0, _utils.isEntireTopLevelBlockquoteSelected)(state) && (0, _experiments.editorExperiment)('nested-dnd', false)) {
|
|
98
|
+
if (!resetState && !(0, _utils.isEntireNestedParagraphOrHeadingSelected)(selection)) {
|
|
122
99
|
resetState = true;
|
|
123
100
|
}
|
|
124
101
|
if (!resetState && (0, _utils.isInlineNode)(nodeName) && (0, _utils.isNestedInlineNode)(selection)) {
|
|
125
102
|
resetState = true;
|
|
126
103
|
}
|
|
127
|
-
if (!resetState &&
|
|
128
|
-
resetState = true;
|
|
129
|
-
}
|
|
130
|
-
if (!resetState && (0, _utils.isNestedInTable)(state) && (0, _experiments.editorExperiment)('nested-dnd', true) && (0, _experiments.editorExperiment)('table-nested-dnd', false)) {
|
|
131
|
-
resetState = true;
|
|
132
|
-
}
|
|
133
|
-
var isBlockNode = (0, _utils.isBlockNodeWithoutTable)(nodeName);
|
|
134
|
-
if (!resetState && (0, _utils.isNodeSelection)(selection) && isBlockNode && selection.$anchor.node().type.name !== 'doc' && (0, _experiments.editorExperiment)('nested-dnd', false) // checks that the block node is not a topLevel node
|
|
135
|
-
) {
|
|
136
|
-
resetState = true;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Some blockNodes can have text inside of them cut, in that case TextSelection occurs, we don't need to track
|
|
140
|
-
// these cut events.
|
|
141
|
-
if (!resetState && (0, _utils.isTextSelection)(selection) && isBlockNode && (0, _experiments.editorExperiment)('nested-dnd', false)) {
|
|
104
|
+
if (!resetState && (0, _utils.isNestedInTable)(state) && (0, _experiments.editorExperiment)('table-nested-dnd', false)) {
|
|
142
105
|
resetState = true;
|
|
143
106
|
}
|
|
144
107
|
if (resetState) {
|
|
145
108
|
(0, _commands.resetContentMoved)()(state, dispatch);
|
|
146
109
|
} else {
|
|
147
|
-
(0, _commands.updateContentMoved)(
|
|
110
|
+
(0, _commands.updateContentMoved)({
|
|
148
111
|
size: size,
|
|
149
|
-
nodeName: nodeName
|
|
150
|
-
}, (0, _experiments.editorExperiment)('nested-dnd', true) && {
|
|
112
|
+
nodeName: nodeName,
|
|
151
113
|
nodeDepth: (0, _utils.getParentNodeDepth)(selection)
|
|
152
|
-
}
|
|
114
|
+
}, 'contentCut')(state, dispatch);
|
|
153
115
|
}
|
|
154
116
|
isCutEvent = false;
|
|
155
117
|
return slice;
|
|
@@ -4,9 +4,8 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.isNestedInlineNode = exports.isNestedInTable = exports.isInlineNode = exports.isExcludedNode = exports.isEntireNestedParagraphOrHeadingSelected = exports.isCursorSelectionAtTopLevel = exports.getParentNodeDepth = void 0;
|
|
8
8
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
10
9
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
10
|
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
12
11
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
@@ -14,15 +13,6 @@ var excludedNodes = ['caption', 'layoutColumn', 'listItem', 'tableHeader', 'tabl
|
|
|
14
13
|
var isExcludedNode = exports.isExcludedNode = function isExcludedNode(nodeName) {
|
|
15
14
|
return excludedNodes.includes(nodeName);
|
|
16
15
|
};
|
|
17
|
-
var isCursorSelectionAndInsideTopLevelNode = exports.isCursorSelectionAndInsideTopLevelNode = function isCursorSelectionAndInsideTopLevelNode(selection) {
|
|
18
|
-
var $from = selection.$from,
|
|
19
|
-
from = selection.from,
|
|
20
|
-
to = selection.to;
|
|
21
|
-
if (from !== to || $from.depth > 1) {
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
16
|
var isCursorSelectionAtTopLevel = exports.isCursorSelectionAtTopLevel = function isCursorSelectionAtTopLevel(selection) {
|
|
27
17
|
var from = selection.from,
|
|
28
18
|
to = selection.to,
|
|
@@ -56,15 +46,6 @@ var isNestedInlineNode = exports.isNestedInlineNode = function isNestedInlineNod
|
|
|
56
46
|
}
|
|
57
47
|
return true;
|
|
58
48
|
};
|
|
59
|
-
var blockNodes = ['bodiedExtension', 'blockCard', 'codeBlock', 'embedCard', 'expand', 'extension', 'layoutSection', 'mediaGroup', 'mediaSingle', 'panel', 'rule'];
|
|
60
|
-
var isBlockNodeWithoutTable = exports.isBlockNodeWithoutTable = function isBlockNodeWithoutTable(nodeName) {
|
|
61
|
-
return blockNodes.includes(nodeName);
|
|
62
|
-
};
|
|
63
|
-
var parentNodes = ['expand', 'extension', 'bodiedExtension', 'layoutSection'];
|
|
64
|
-
var isNestedTable = exports.isNestedTable = function isNestedTable(selection) {
|
|
65
|
-
var parentNode = selection.$anchor.node(1);
|
|
66
|
-
return parentNode && parentNodes.includes(parentNode.type.name);
|
|
67
|
-
};
|
|
68
49
|
var isNestedInTable = exports.isNestedInTable = function isNestedInTable(state) {
|
|
69
50
|
var schema = state.schema,
|
|
70
51
|
selection = state.selection;
|
|
@@ -87,72 +68,6 @@ var getParentNodeDepth = exports.getParentNodeDepth = function getParentNodeDept
|
|
|
87
68
|
}
|
|
88
69
|
return parentNode.node.type.name === 'heading' || parentNode.node.type.name === 'paragraph' ? parentNode.depth - 1 : parentNode.depth;
|
|
89
70
|
};
|
|
90
|
-
var getPastedNameOfInlineNode = function getPastedNameOfInlineNode(nodeName) {
|
|
91
|
-
if (inlineNodes.includes(nodeName)) {
|
|
92
|
-
return 'paragraph';
|
|
93
|
-
}
|
|
94
|
-
return nodeName;
|
|
95
|
-
};
|
|
96
|
-
var isValidNodeName = exports.isValidNodeName = function isValidNodeName(copiedNodeName, pastedNodeName) {
|
|
97
|
-
if (copiedNodeName === pastedNodeName) {
|
|
98
|
-
return true;
|
|
99
|
-
}
|
|
100
|
-
if (getPastedNameOfInlineNode(copiedNodeName) === pastedNodeName) {
|
|
101
|
-
return true;
|
|
102
|
-
}
|
|
103
|
-
return false;
|
|
104
|
-
};
|
|
105
|
-
var isTextSelection = exports.isTextSelection = function isTextSelection(selection) {
|
|
106
|
-
return selection instanceof _state.TextSelection && selection.from !== selection.to;
|
|
107
|
-
};
|
|
108
|
-
var isNodeSelection = exports.isNodeSelection = function isNodeSelection(selection) {
|
|
109
|
-
return selection instanceof _state.NodeSelection;
|
|
110
|
-
};
|
|
111
|
-
var isEntireHeadingOrParagraphSelected = function isEntireHeadingOrParagraphSelected(selection, nodeName) {
|
|
112
|
-
if (!isTextSelection(selection)) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
var $from = selection.$from,
|
|
116
|
-
$to = selection.$to;
|
|
117
|
-
if (!($from.parent.type.name === nodeName)) {
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if ($from.parent === $to.parent) {
|
|
121
|
-
var node = $from.parent;
|
|
122
|
-
return $from.parentOffset === 0 && $to.parentOffset === node.content.size;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
var isEntireTopLevelHeadingOrParagraphSelected = exports.isEntireTopLevelHeadingOrParagraphSelected = function isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) {
|
|
126
|
-
if (selection.$from.depth !== 1) {
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
return isEntireHeadingOrParagraphSelected(selection, nodeName);
|
|
130
|
-
};
|
|
131
|
-
var isEntireTopLevelBlockquoteSelected = exports.isEntireTopLevelBlockquoteSelected = function isEntireTopLevelBlockquoteSelected(state) {
|
|
132
|
-
var schema = state.schema,
|
|
133
|
-
selection = state.selection;
|
|
134
|
-
var blockquote = schema.nodes.blockquote;
|
|
135
|
-
var blockquoteNode = (0, _utils.findParentNodeOfTypeClosestToPos)(selection.$from, blockquote);
|
|
136
|
-
if (!blockquoteNode) {
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// checks if it is a top level blockquote
|
|
141
|
-
var depth = blockquoteNode.depth;
|
|
142
|
-
if (depth !== 1) {
|
|
143
|
-
return false;
|
|
144
|
-
}
|
|
145
|
-
var from = selection.from,
|
|
146
|
-
to = selection.to;
|
|
147
|
-
var selectedNodesCount = 0;
|
|
148
|
-
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
149
|
-
if (pos >= from && pos + node.nodeSize <= to) {
|
|
150
|
-
selectedNodesCount++;
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
return selectedNodesCount === blockquoteNode.node.childCount;
|
|
155
|
-
};
|
|
156
71
|
var isEntireNestedParagraphOrHeadingSelected = exports.isEntireNestedParagraphOrHeadingSelected = function isEntireNestedParagraphOrHeadingSelected(selection) {
|
|
157
72
|
var $from = selection.$from,
|
|
158
73
|
$to = selection.$to;
|
package/dist/es2019/handlers.js
CHANGED
|
@@ -14,6 +14,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
|
14
14
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
15
15
|
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
|
|
16
16
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
17
|
+
import { isInsideBlockQuote } from './pm-plugins/main';
|
|
17
18
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
18
19
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './util';
|
|
19
20
|
const insideExpand = state => {
|
|
@@ -880,10 +881,11 @@ export function flattenNestedListInSlice(slice) {
|
|
|
880
881
|
const contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
881
882
|
return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
882
883
|
}
|
|
883
|
-
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
884
|
+
export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodeblockSupported) {
|
|
884
885
|
return (state, dispatch) => {
|
|
885
886
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
886
887
|
const {
|
|
888
|
+
blockquote,
|
|
887
889
|
codeBlock,
|
|
888
890
|
heading,
|
|
889
891
|
paragraph,
|
|
@@ -921,12 +923,25 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
921
923
|
const noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
922
924
|
let panelParentOverCurrentSelection = findParentNodeOfType(panel)(tr.selection);
|
|
923
925
|
const isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
926
|
+
let sliceContainsCodeblockOrMedia = false;
|
|
927
|
+
const codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
928
|
+
slice.content.forEach(child => {
|
|
929
|
+
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
930
|
+
sliceContainsCodeblockOrMedia = true;
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
const blockquoteNode = findParentNodeOfType(blockquote)(tr.selection);
|
|
924
934
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
925
935
|
insertSliceForLists({
|
|
926
936
|
tr,
|
|
927
937
|
slice,
|
|
928
938
|
schema
|
|
929
939
|
});
|
|
940
|
+
} else if (
|
|
941
|
+
// If nesting media or codeblock in blockquote is not supported
|
|
942
|
+
// we want to insert slice after the blockquote.
|
|
943
|
+
isInsideBlockQuote(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
944
|
+
tr = safeInsert(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
930
945
|
} else if (noNeedForSafeInsert) {
|
|
931
946
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
932
947
|
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)) {
|
|
@@ -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, isNestingMediaOrCodeblockSupported) => {
|
|
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, isNestingMediaOrCodeblockSupported));
|
|
299
299
|
};
|
|
300
300
|
const injectAnalyticsPayloadBeforeCommand = editorAnalyticsAPI => createPayloadByTransaction => {
|
|
301
301
|
return mainCommand => {
|
|
@@ -137,8 +137,11 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
137
137
|
/**
|
|
138
138
|
* We want to return false for external copied image to allow
|
|
139
139
|
* it to be uploaded by the client.
|
|
140
|
+
*
|
|
141
|
+
* Scenario where we are pasting an external image inside a block quote
|
|
142
|
+
* is skipped and handled in handleRichText
|
|
140
143
|
*/
|
|
141
|
-
if (htmlContainsSingleFile(html)) {
|
|
144
|
+
if (htmlContainsSingleFile(html) && !isInsideBlockQuote(view.state)) {
|
|
142
145
|
return true;
|
|
143
146
|
}
|
|
144
147
|
|
|
@@ -341,7 +344,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
341
344
|
|
|
342
345
|
// finally, handle rich-text copy-paste
|
|
343
346
|
if (isRichText || isNestedMarkdownTable) {
|
|
344
|
-
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l;
|
|
347
|
+
var _pluginInjectionApi$c3, _pluginInjectionApi$c4, _pluginInjectionApi$e3, _pluginInjectionApi$e4, _pluginInjectionApi$f, _pluginInjectionApi$f2, _pluginInjectionApi$l, _pluginInjectionApi$f3, _pluginInjectionApi$f4;
|
|
345
348
|
// linkify the text where possible
|
|
346
349
|
slice = linkifyContent(state.schema)(slice);
|
|
347
350
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -416,7 +419,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
416
419
|
if (handlePasteNonNestableBlockNodesIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
417
420
|
return true;
|
|
418
421
|
}
|
|
419
|
-
|
|
422
|
+
const isNestingMediaOrCodeblockSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.sharedState.currentState()) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.nestMediaAndCodeblockInQuote) || fg('editor_nest_media_and_codeblock_in_quotes_jira');
|
|
423
|
+
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
420
424
|
}
|
|
421
425
|
return false;
|
|
422
426
|
},
|
|
@@ -5,7 +5,7 @@ import { resetContentMoved, resetContentMovedTransform, updateContentMoved } fro
|
|
|
5
5
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
6
6
|
import { pluginKey } from './plugin-key';
|
|
7
7
|
import { defaultState } from './types';
|
|
8
|
-
import { getParentNodeDepth,
|
|
8
|
+
import { getParentNodeDepth, isCursorSelectionAtTopLevel, isEntireNestedParagraphOrHeadingSelected, isExcludedNode, isInlineNode, isNestedInlineNode, isNestedInTable } from './utils';
|
|
9
9
|
|
|
10
10
|
// This plugin exists only in FullPage/FullWidth Editor and is used to register an event that tells us
|
|
11
11
|
// that a user cut and than pasted a node. This order of actions could be considered an alternative
|
|
@@ -38,16 +38,10 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
const {
|
|
41
|
-
content
|
|
42
|
-
size
|
|
41
|
+
content
|
|
43
42
|
} = slice;
|
|
44
43
|
const nodeName = (_content$firstChild = content.firstChild) === null || _content$firstChild === void 0 ? void 0 : _content$firstChild.type.name;
|
|
45
|
-
|
|
46
|
-
// We should not account for pastes that go inside another node and create nested content as DnD can't do it when nested-dnd is disabled
|
|
47
|
-
if ((!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isValidNodeName(contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName, nodeName) || size !== (contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.size) || !isCursorSelectionAndInsideTopLevelNode(state.selection)) && editorExperiment('nested-dnd', false)) {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isCursorSelectionAtTopLevel(state.selection) && editorExperiment('nested-dnd', true)) {
|
|
44
|
+
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isCursorSelectionAtTopLevel(state.selection)) {
|
|
51
45
|
return;
|
|
52
46
|
}
|
|
53
47
|
const {
|
|
@@ -60,10 +54,9 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
|
60
54
|
eventType: EVENT_TYPE.TRACK,
|
|
61
55
|
attributes: {
|
|
62
56
|
nodeType: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
})
|
|
57
|
+
nodeDepth: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeDepth,
|
|
58
|
+
destinationNodeDepth: getParentNodeDepth(state.selection)
|
|
59
|
+
|
|
67
60
|
// keep nodeName from copied slice
|
|
68
61
|
}
|
|
69
62
|
})(tr);
|
|
@@ -108,41 +101,13 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
|
108
101
|
const {
|
|
109
102
|
selection
|
|
110
103
|
} = state;
|
|
111
|
-
|
|
112
|
-
// So we are only interested in cut slices that contain the entire node, not just a part of it.
|
|
113
|
-
if (!resetState && nodeName === 'paragraph' && !isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) && editorExperiment('nested-dnd', false)) {
|
|
114
|
-
resetState = true;
|
|
115
|
-
}
|
|
116
|
-
if (!resetState && nodeName === 'heading' && !isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) && editorExperiment('nested-dnd', false)) {
|
|
117
|
-
resetState = true;
|
|
118
|
-
}
|
|
119
|
-
if (!resetState && !isEntireNestedParagraphOrHeadingSelected(selection) && editorExperiment('nested-dnd', true)) {
|
|
120
|
-
resetState = true;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
// DnD can't drag just one paragraph (when blockquote contains multiple paragraphs) or just a part of a paragraph in the blockquote.
|
|
124
|
-
// DnD will select and drag the whole blockquote. So we need to register cut events that have the entire blockquote too.
|
|
125
|
-
if (!resetState && nodeName === 'blockquote' && !isEntireTopLevelBlockquoteSelected(state) && editorExperiment('nested-dnd', false)) {
|
|
104
|
+
if (!resetState && !isEntireNestedParagraphOrHeadingSelected(selection)) {
|
|
126
105
|
resetState = true;
|
|
127
106
|
}
|
|
128
107
|
if (!resetState && isInlineNode(nodeName) && isNestedInlineNode(selection)) {
|
|
129
108
|
resetState = true;
|
|
130
109
|
}
|
|
131
|
-
if (!resetState &&
|
|
132
|
-
resetState = true;
|
|
133
|
-
}
|
|
134
|
-
if (!resetState && isNestedInTable(state) && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false)) {
|
|
135
|
-
resetState = true;
|
|
136
|
-
}
|
|
137
|
-
const isBlockNode = isBlockNodeWithoutTable(nodeName);
|
|
138
|
-
if (!resetState && isNodeSelection(selection) && isBlockNode && selection.$anchor.node().type.name !== 'doc' && editorExperiment('nested-dnd', false) // checks that the block node is not a topLevel node
|
|
139
|
-
) {
|
|
140
|
-
resetState = true;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Some blockNodes can have text inside of them cut, in that case TextSelection occurs, we don't need to track
|
|
144
|
-
// these cut events.
|
|
145
|
-
if (!resetState && isTextSelection(selection) && isBlockNode && editorExperiment('nested-dnd', false)) {
|
|
110
|
+
if (!resetState && isNestedInTable(state) && editorExperiment('table-nested-dnd', false)) {
|
|
146
111
|
resetState = true;
|
|
147
112
|
}
|
|
148
113
|
if (resetState) {
|
|
@@ -151,9 +116,7 @@ export const createPlugin = (dispatch, editorAnalyticsAPI) => {
|
|
|
151
116
|
updateContentMoved({
|
|
152
117
|
size: size,
|
|
153
118
|
nodeName: nodeName,
|
|
154
|
-
|
|
155
|
-
nodeDepth: getParentNodeDepth(selection)
|
|
156
|
-
})
|
|
119
|
+
nodeDepth: getParentNodeDepth(selection)
|
|
157
120
|
}, 'contentCut')(state, dispatch);
|
|
158
121
|
}
|
|
159
122
|
isCutEvent = false;
|
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
1
|
import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
3
2
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
4
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
5
4
|
const excludedNodes = ['caption', 'layoutColumn', 'listItem', 'tableHeader', 'tableCell', 'tableRow', 'text', 'placeholder', 'unsupportedBlock', 'unsupportedInline', 'hardBreak', 'confluenceUnsupportedBlock', 'confluenceUnsupportedInline', 'taskItem', 'decisionItem', ...(editorExperiment('nested-dnd', false) ? ['bulletList', 'orderedList', 'taskList', 'decisionList', 'nestedExpand', 'media'] : [])];
|
|
6
5
|
export const isExcludedNode = nodeName => excludedNodes.includes(nodeName);
|
|
7
|
-
export const isCursorSelectionAndInsideTopLevelNode = selection => {
|
|
8
|
-
const {
|
|
9
|
-
$from,
|
|
10
|
-
from,
|
|
11
|
-
to
|
|
12
|
-
} = selection;
|
|
13
|
-
if (from !== to || $from.depth > 1) {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
return true;
|
|
17
|
-
};
|
|
18
6
|
export const isCursorSelectionAtTopLevel = selection => {
|
|
19
7
|
const {
|
|
20
8
|
from,
|
|
@@ -50,15 +38,6 @@ export const isNestedInlineNode = selection => {
|
|
|
50
38
|
}
|
|
51
39
|
return true;
|
|
52
40
|
};
|
|
53
|
-
const blockNodes = ['bodiedExtension', 'blockCard', 'codeBlock', 'embedCard', 'expand', 'extension', 'layoutSection', 'mediaGroup', 'mediaSingle', 'panel', 'rule'];
|
|
54
|
-
export const isBlockNodeWithoutTable = nodeName => {
|
|
55
|
-
return blockNodes.includes(nodeName);
|
|
56
|
-
};
|
|
57
|
-
const parentNodes = ['expand', 'extension', 'bodiedExtension', 'layoutSection'];
|
|
58
|
-
export const isNestedTable = selection => {
|
|
59
|
-
const parentNode = selection.$anchor.node(1);
|
|
60
|
-
return parentNode && parentNodes.includes(parentNode.type.name);
|
|
61
|
-
};
|
|
62
41
|
export const isNestedInTable = state => {
|
|
63
42
|
const {
|
|
64
43
|
schema,
|
|
@@ -83,82 +62,6 @@ export const getParentNodeDepth = selection => {
|
|
|
83
62
|
}
|
|
84
63
|
return parentNode.node.type.name === 'heading' || parentNode.node.type.name === 'paragraph' ? parentNode.depth - 1 : parentNode.depth;
|
|
85
64
|
};
|
|
86
|
-
const getPastedNameOfInlineNode = nodeName => {
|
|
87
|
-
if (inlineNodes.includes(nodeName)) {
|
|
88
|
-
return 'paragraph';
|
|
89
|
-
}
|
|
90
|
-
return nodeName;
|
|
91
|
-
};
|
|
92
|
-
export const isValidNodeName = (copiedNodeName, pastedNodeName) => {
|
|
93
|
-
if (copiedNodeName === pastedNodeName) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
if (getPastedNameOfInlineNode(copiedNodeName) === pastedNodeName) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
return false;
|
|
100
|
-
};
|
|
101
|
-
export const isTextSelection = selection => {
|
|
102
|
-
return selection instanceof TextSelection && selection.from !== selection.to;
|
|
103
|
-
};
|
|
104
|
-
export const isNodeSelection = selection => {
|
|
105
|
-
return selection instanceof NodeSelection;
|
|
106
|
-
};
|
|
107
|
-
const isEntireHeadingOrParagraphSelected = (selection, nodeName) => {
|
|
108
|
-
if (!isTextSelection(selection)) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
const {
|
|
112
|
-
$from,
|
|
113
|
-
$to
|
|
114
|
-
} = selection;
|
|
115
|
-
if (!($from.parent.type.name === nodeName)) {
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
if ($from.parent === $to.parent) {
|
|
119
|
-
const node = $from.parent;
|
|
120
|
-
return $from.parentOffset === 0 && $to.parentOffset === node.content.size;
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
export const isEntireTopLevelHeadingOrParagraphSelected = (selection, nodeName) => {
|
|
124
|
-
if (selection.$from.depth !== 1) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
return isEntireHeadingOrParagraphSelected(selection, nodeName);
|
|
128
|
-
};
|
|
129
|
-
export const isEntireTopLevelBlockquoteSelected = state => {
|
|
130
|
-
const {
|
|
131
|
-
schema,
|
|
132
|
-
selection
|
|
133
|
-
} = state;
|
|
134
|
-
const {
|
|
135
|
-
blockquote
|
|
136
|
-
} = schema.nodes;
|
|
137
|
-
const blockquoteNode = findParentNodeOfTypeClosestToPos(selection.$from, blockquote);
|
|
138
|
-
if (!blockquoteNode) {
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
// checks if it is a top level blockquote
|
|
143
|
-
const {
|
|
144
|
-
depth
|
|
145
|
-
} = blockquoteNode;
|
|
146
|
-
if (depth !== 1) {
|
|
147
|
-
return false;
|
|
148
|
-
}
|
|
149
|
-
const {
|
|
150
|
-
from,
|
|
151
|
-
to
|
|
152
|
-
} = selection;
|
|
153
|
-
let selectedNodesCount = 0;
|
|
154
|
-
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
155
|
-
if (pos >= from && pos + node.nodeSize <= to) {
|
|
156
|
-
selectedNodesCount++;
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
return selectedNodesCount === blockquoteNode.node.childCount;
|
|
161
|
-
};
|
|
162
65
|
export const isEntireNestedParagraphOrHeadingSelected = selection => {
|
|
163
66
|
const {
|
|
164
67
|
$from,
|
package/dist/esm/handlers.js
CHANGED
|
@@ -22,6 +22,7 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
|
22
22
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
23
23
|
import { insertSliceForLists, insertSliceForTaskInsideList, insertSliceInsideBlockquote } from './edge-cases';
|
|
24
24
|
import { insertSliceInsideOfPanelNodeSelected } from './edge-cases/lists';
|
|
25
|
+
import { isInsideBlockQuote } from './pm-plugins/main';
|
|
25
26
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
26
27
|
import { addReplaceSelectedTableAnalytics, applyTextMarksToSlice, hasOnlyNodesOfType, isEmptyNode, isSelectionInsidePanel } from './util';
|
|
27
28
|
var insideExpand = function insideExpand(state) {
|
|
@@ -881,10 +882,11 @@ export function flattenNestedListInSlice(slice) {
|
|
|
881
882
|
var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
882
883
|
return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
883
884
|
}
|
|
884
|
-
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
885
|
+
export function handleRichText(slice, queueCardsFromChangedTr, isNestingMediaOrCodeblockSupported) {
|
|
885
886
|
return function (state, dispatch) {
|
|
886
887
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
887
888
|
var _state$schema$nodes4 = state.schema.nodes,
|
|
889
|
+
blockquote = _state$schema$nodes4.blockquote,
|
|
888
890
|
codeBlock = _state$schema$nodes4.codeBlock,
|
|
889
891
|
heading = _state$schema$nodes4.heading,
|
|
890
892
|
paragraph = _state$schema$nodes4.paragraph,
|
|
@@ -919,12 +921,25 @@ export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
919
921
|
var noNeedForSafeInsert = selection.$to.node().type.validContent(slice.content) || textNodes.includes(selection.$to.node().type) && selectionParent.type.validContent(slice.content);
|
|
920
922
|
var panelParentOverCurrentSelection = findParentNodeOfType(panel)(tr.selection);
|
|
921
923
|
var isTargetPanelEmpty = panelParentOverCurrentSelection && ((_panelParentOverCurre = panelParentOverCurrentSelection.node) === null || _panelParentOverCurre === void 0 ? void 0 : _panelParentOverCurre.content.size) === 2;
|
|
924
|
+
var sliceContainsCodeblockOrMedia = false;
|
|
925
|
+
var codeBlockAndMediaNodes = ['codeBlock', 'mediaSingle', 'mediaGroup'];
|
|
926
|
+
slice.content.forEach(function (child) {
|
|
927
|
+
if (codeBlockAndMediaNodes.includes(child.type.name)) {
|
|
928
|
+
sliceContainsCodeblockOrMedia = true;
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
var blockquoteNode = findParentNodeOfType(blockquote)(tr.selection);
|
|
922
932
|
if (!isSliceContentTaskListNodes && (isSliceContentListNodes || isTargetPanelEmpty)) {
|
|
923
933
|
insertSliceForLists({
|
|
924
934
|
tr: tr,
|
|
925
935
|
slice: slice,
|
|
926
936
|
schema: schema
|
|
927
937
|
});
|
|
938
|
+
} else if (
|
|
939
|
+
// If nesting media or codeblock in blockquote is not supported
|
|
940
|
+
// we want to insert slice after the blockquote.
|
|
941
|
+
isInsideBlockQuote(state) && sliceContainsCodeblockOrMedia && !isNestingMediaOrCodeblockSupported && blockquoteNode) {
|
|
942
|
+
tr = safeInsert(slice.content, blockquoteNode.start + blockquoteNode.node.nodeSize - 1)(tr);
|
|
928
943
|
} else if (noNeedForSafeInsert) {
|
|
929
944
|
var _firstChildOfSlice$ty2, _firstChildOfSlice$co, _firstChildOfSlice$co2;
|
|
930
945
|
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)) {
|
|
@@ -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, isNestingMediaOrCodeblockSupported) {
|
|
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, isNestingMediaOrCodeblockSupported));
|
|
310
310
|
};
|
|
311
311
|
var injectAnalyticsPayloadBeforeCommand = function injectAnalyticsPayloadBeforeCommand(editorAnalyticsAPI) {
|
|
312
312
|
return function (createPayloadByTransaction) {
|
|
@@ -160,8 +160,11 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
160
160
|
/**
|
|
161
161
|
* We want to return false for external copied image to allow
|
|
162
162
|
* it to be uploaded by the client.
|
|
163
|
+
*
|
|
164
|
+
* Scenario where we are pasting an external image inside a block quote
|
|
165
|
+
* is skipped and handled in handleRichText
|
|
163
166
|
*/
|
|
164
|
-
if (htmlContainsSingleFile(html)) {
|
|
167
|
+
if (htmlContainsSingleFile(html) && !isInsideBlockQuote(view.state)) {
|
|
165
168
|
return true;
|
|
166
169
|
}
|
|
167
170
|
|
|
@@ -357,7 +360,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
357
360
|
|
|
358
361
|
// finally, handle rich-text copy-paste
|
|
359
362
|
if (isRichText || isNestedMarkdownTable) {
|
|
360
|
-
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l;
|
|
363
|
+
var _pluginInjectionApi$c2, _pluginInjectionApi$e2, _pluginInjectionApi$f, _pluginInjectionApi$l, _pluginInjectionApi$f2;
|
|
361
364
|
// linkify the text where possible
|
|
362
365
|
slice = linkifyContent(state.schema)(slice);
|
|
363
366
|
if (handlePasteLinkOnSelectedTextWithAnalytics(editorAnalyticsAPI)(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -434,7 +437,8 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
434
437
|
if (handlePasteNonNestableBlockNodesIntoListWithAnalytics(editorAnalyticsAPI)(view, event, slice)(state, dispatch)) {
|
|
435
438
|
return true;
|
|
436
439
|
}
|
|
437
|
-
|
|
440
|
+
var isNestingMediaOrCodeblockSupported = (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.featureFlags) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.sharedState.currentState()) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.nestMediaAndCodeblockInQuote) || fg('editor_nest_media_and_codeblock_in_quotes_jira');
|
|
441
|
+
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi, isNestingMediaOrCodeblockSupported)(state, dispatch);
|
|
438
442
|
}
|
|
439
443
|
return false;
|
|
440
444
|
},
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
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; }
|
|
3
|
-
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) { _defineProperty(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; }
|
|
4
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
3
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -8,7 +5,7 @@ import { resetContentMoved, resetContentMovedTransform, updateContentMoved } fro
|
|
|
8
5
|
import { createPluginState, getPluginState } from './plugin-factory';
|
|
9
6
|
import { pluginKey } from './plugin-key';
|
|
10
7
|
import { defaultState } from './types';
|
|
11
|
-
import { getParentNodeDepth,
|
|
8
|
+
import { getParentNodeDepth, isCursorSelectionAtTopLevel, isEntireNestedParagraphOrHeadingSelected, isExcludedNode, isInlineNode, isNestedInlineNode, isNestedInTable } from './utils';
|
|
12
9
|
|
|
13
10
|
// This plugin exists only in FullPage/FullWidth Editor and is used to register an event that tells us
|
|
14
11
|
// that a user cut and than pasted a node. This order of actions could be considered an alternative
|
|
@@ -38,15 +35,9 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
|
|
|
38
35
|
if (!hasCutAction) {
|
|
39
36
|
return;
|
|
40
37
|
}
|
|
41
|
-
var content = slice.content
|
|
42
|
-
size = slice.size;
|
|
38
|
+
var content = slice.content;
|
|
43
39
|
var nodeName = (_content$firstChild = content.firstChild) === null || _content$firstChild === void 0 ? void 0 : _content$firstChild.type.name;
|
|
44
|
-
|
|
45
|
-
// We should not account for pastes that go inside another node and create nested content as DnD can't do it when nested-dnd is disabled
|
|
46
|
-
if ((!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isValidNodeName(contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName, nodeName) || size !== (contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.size) || !isCursorSelectionAndInsideTopLevelNode(state.selection)) && editorExperiment('nested-dnd', false)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isCursorSelectionAtTopLevel(state.selection) && editorExperiment('nested-dnd', true)) {
|
|
40
|
+
if (!nodeName || !(contentMoved !== null && contentMoved !== void 0 && contentMoved.nodeName) || !isCursorSelectionAtTopLevel(state.selection)) {
|
|
50
41
|
return;
|
|
51
42
|
}
|
|
52
43
|
var tr = state.tr;
|
|
@@ -55,12 +46,13 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
|
|
|
55
46
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
56
47
|
actionSubjectId: ACTION_SUBJECT_ID.NODE,
|
|
57
48
|
eventType: EVENT_TYPE.TRACK,
|
|
58
|
-
attributes:
|
|
59
|
-
nodeType: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName
|
|
60
|
-
}, editorExperiment('nested-dnd', true) && {
|
|
49
|
+
attributes: {
|
|
50
|
+
nodeType: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeName,
|
|
61
51
|
nodeDepth: contentMoved === null || contentMoved === void 0 ? void 0 : contentMoved.nodeDepth,
|
|
62
52
|
destinationNodeDepth: getParentNodeDepth(state.selection)
|
|
63
|
-
|
|
53
|
+
|
|
54
|
+
// keep nodeName from copied slice
|
|
55
|
+
}
|
|
64
56
|
})(tr);
|
|
65
57
|
|
|
66
58
|
// reset to default state
|
|
@@ -98,52 +90,23 @@ export var createPlugin = function createPlugin(dispatch, editorAnalyticsAPI) {
|
|
|
98
90
|
resetState = true;
|
|
99
91
|
}
|
|
100
92
|
var selection = state.selection;
|
|
101
|
-
|
|
102
|
-
// So we are only interested in cut slices that contain the entire node, not just a part of it.
|
|
103
|
-
if (!resetState && nodeName === 'paragraph' && !isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) && editorExperiment('nested-dnd', false)) {
|
|
104
|
-
resetState = true;
|
|
105
|
-
}
|
|
106
|
-
if (!resetState && nodeName === 'heading' && !isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) && editorExperiment('nested-dnd', false)) {
|
|
107
|
-
resetState = true;
|
|
108
|
-
}
|
|
109
|
-
if (!resetState && !isEntireNestedParagraphOrHeadingSelected(selection) && editorExperiment('nested-dnd', true)) {
|
|
110
|
-
resetState = true;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// DnD can't drag just one paragraph (when blockquote contains multiple paragraphs) or just a part of a paragraph in the blockquote.
|
|
114
|
-
// DnD will select and drag the whole blockquote. So we need to register cut events that have the entire blockquote too.
|
|
115
|
-
if (!resetState && nodeName === 'blockquote' && !isEntireTopLevelBlockquoteSelected(state) && editorExperiment('nested-dnd', false)) {
|
|
93
|
+
if (!resetState && !isEntireNestedParagraphOrHeadingSelected(selection)) {
|
|
116
94
|
resetState = true;
|
|
117
95
|
}
|
|
118
96
|
if (!resetState && isInlineNode(nodeName) && isNestedInlineNode(selection)) {
|
|
119
97
|
resetState = true;
|
|
120
98
|
}
|
|
121
|
-
if (!resetState &&
|
|
122
|
-
resetState = true;
|
|
123
|
-
}
|
|
124
|
-
if (!resetState && isNestedInTable(state) && editorExperiment('nested-dnd', true) && editorExperiment('table-nested-dnd', false)) {
|
|
125
|
-
resetState = true;
|
|
126
|
-
}
|
|
127
|
-
var isBlockNode = isBlockNodeWithoutTable(nodeName);
|
|
128
|
-
if (!resetState && isNodeSelection(selection) && isBlockNode && selection.$anchor.node().type.name !== 'doc' && editorExperiment('nested-dnd', false) // checks that the block node is not a topLevel node
|
|
129
|
-
) {
|
|
130
|
-
resetState = true;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// Some blockNodes can have text inside of them cut, in that case TextSelection occurs, we don't need to track
|
|
134
|
-
// these cut events.
|
|
135
|
-
if (!resetState && isTextSelection(selection) && isBlockNode && editorExperiment('nested-dnd', false)) {
|
|
99
|
+
if (!resetState && isNestedInTable(state) && editorExperiment('table-nested-dnd', false)) {
|
|
136
100
|
resetState = true;
|
|
137
101
|
}
|
|
138
102
|
if (resetState) {
|
|
139
103
|
resetContentMoved()(state, dispatch);
|
|
140
104
|
} else {
|
|
141
|
-
updateContentMoved(
|
|
105
|
+
updateContentMoved({
|
|
142
106
|
size: size,
|
|
143
|
-
nodeName: nodeName
|
|
144
|
-
}, editorExperiment('nested-dnd', true) && {
|
|
107
|
+
nodeName: nodeName,
|
|
145
108
|
nodeDepth: getParentNodeDepth(selection)
|
|
146
|
-
}
|
|
109
|
+
}, 'contentCut')(state, dispatch);
|
|
147
110
|
}
|
|
148
111
|
isCutEvent = false;
|
|
149
112
|
return slice;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { findParentNodeClosestToPos, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
4
3
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
5
4
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
@@ -7,15 +6,6 @@ var excludedNodes = ['caption', 'layoutColumn', 'listItem', 'tableHeader', 'tabl
|
|
|
7
6
|
export var isExcludedNode = function isExcludedNode(nodeName) {
|
|
8
7
|
return excludedNodes.includes(nodeName);
|
|
9
8
|
};
|
|
10
|
-
export var isCursorSelectionAndInsideTopLevelNode = function isCursorSelectionAndInsideTopLevelNode(selection) {
|
|
11
|
-
var $from = selection.$from,
|
|
12
|
-
from = selection.from,
|
|
13
|
-
to = selection.to;
|
|
14
|
-
if (from !== to || $from.depth > 1) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
};
|
|
19
9
|
export var isCursorSelectionAtTopLevel = function isCursorSelectionAtTopLevel(selection) {
|
|
20
10
|
var from = selection.from,
|
|
21
11
|
to = selection.to,
|
|
@@ -49,15 +39,6 @@ export var isNestedInlineNode = function isNestedInlineNode(selection) {
|
|
|
49
39
|
}
|
|
50
40
|
return true;
|
|
51
41
|
};
|
|
52
|
-
var blockNodes = ['bodiedExtension', 'blockCard', 'codeBlock', 'embedCard', 'expand', 'extension', 'layoutSection', 'mediaGroup', 'mediaSingle', 'panel', 'rule'];
|
|
53
|
-
export var isBlockNodeWithoutTable = function isBlockNodeWithoutTable(nodeName) {
|
|
54
|
-
return blockNodes.includes(nodeName);
|
|
55
|
-
};
|
|
56
|
-
var parentNodes = ['expand', 'extension', 'bodiedExtension', 'layoutSection'];
|
|
57
|
-
export var isNestedTable = function isNestedTable(selection) {
|
|
58
|
-
var parentNode = selection.$anchor.node(1);
|
|
59
|
-
return parentNode && parentNodes.includes(parentNode.type.name);
|
|
60
|
-
};
|
|
61
42
|
export var isNestedInTable = function isNestedInTable(state) {
|
|
62
43
|
var schema = state.schema,
|
|
63
44
|
selection = state.selection;
|
|
@@ -80,72 +61,6 @@ export var getParentNodeDepth = function getParentNodeDepth(selection) {
|
|
|
80
61
|
}
|
|
81
62
|
return parentNode.node.type.name === 'heading' || parentNode.node.type.name === 'paragraph' ? parentNode.depth - 1 : parentNode.depth;
|
|
82
63
|
};
|
|
83
|
-
var getPastedNameOfInlineNode = function getPastedNameOfInlineNode(nodeName) {
|
|
84
|
-
if (inlineNodes.includes(nodeName)) {
|
|
85
|
-
return 'paragraph';
|
|
86
|
-
}
|
|
87
|
-
return nodeName;
|
|
88
|
-
};
|
|
89
|
-
export var isValidNodeName = function isValidNodeName(copiedNodeName, pastedNodeName) {
|
|
90
|
-
if (copiedNodeName === pastedNodeName) {
|
|
91
|
-
return true;
|
|
92
|
-
}
|
|
93
|
-
if (getPastedNameOfInlineNode(copiedNodeName) === pastedNodeName) {
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
};
|
|
98
|
-
export var isTextSelection = function isTextSelection(selection) {
|
|
99
|
-
return selection instanceof TextSelection && selection.from !== selection.to;
|
|
100
|
-
};
|
|
101
|
-
export var isNodeSelection = function isNodeSelection(selection) {
|
|
102
|
-
return selection instanceof NodeSelection;
|
|
103
|
-
};
|
|
104
|
-
var isEntireHeadingOrParagraphSelected = function isEntireHeadingOrParagraphSelected(selection, nodeName) {
|
|
105
|
-
if (!isTextSelection(selection)) {
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
var $from = selection.$from,
|
|
109
|
-
$to = selection.$to;
|
|
110
|
-
if (!($from.parent.type.name === nodeName)) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
if ($from.parent === $to.parent) {
|
|
114
|
-
var node = $from.parent;
|
|
115
|
-
return $from.parentOffset === 0 && $to.parentOffset === node.content.size;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
export var isEntireTopLevelHeadingOrParagraphSelected = function isEntireTopLevelHeadingOrParagraphSelected(selection, nodeName) {
|
|
119
|
-
if (selection.$from.depth !== 1) {
|
|
120
|
-
return false;
|
|
121
|
-
}
|
|
122
|
-
return isEntireHeadingOrParagraphSelected(selection, nodeName);
|
|
123
|
-
};
|
|
124
|
-
export var isEntireTopLevelBlockquoteSelected = function isEntireTopLevelBlockquoteSelected(state) {
|
|
125
|
-
var schema = state.schema,
|
|
126
|
-
selection = state.selection;
|
|
127
|
-
var blockquote = schema.nodes.blockquote;
|
|
128
|
-
var blockquoteNode = findParentNodeOfTypeClosestToPos(selection.$from, blockquote);
|
|
129
|
-
if (!blockquoteNode) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// checks if it is a top level blockquote
|
|
134
|
-
var depth = blockquoteNode.depth;
|
|
135
|
-
if (depth !== 1) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
var from = selection.from,
|
|
139
|
-
to = selection.to;
|
|
140
|
-
var selectedNodesCount = 0;
|
|
141
|
-
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
142
|
-
if (pos >= from && pos + node.nodeSize <= to) {
|
|
143
|
-
selectedNodesCount++;
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
return selectedNodesCount === blockquoteNode.node.childCount;
|
|
148
|
-
};
|
|
149
64
|
export var isEntireNestedParagraphOrHeadingSelected = function isEntireNestedParagraphOrHeadingSelected(selection) {
|
|
150
65
|
var $from = selection.$from,
|
|
151
66
|
$to = selection.$to;
|
package/dist/types/handlers.d.ts
CHANGED
|
@@ -51,7 +51,7 @@ export declare function handleParagraphBlockMarks(state: EditorState, slice: Sli
|
|
|
51
51
|
* ┗━p -> "two"
|
|
52
52
|
*/
|
|
53
53
|
export declare function flattenNestedListInSlice(slice: Slice): Slice;
|
|
54
|
-
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
54
|
+
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, isNestingMediaOrCodeblockSupported?: boolean): Command;
|
|
55
55
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
56
56
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
57
57
|
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) => Command;
|
|
31
|
+
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, isNestingMediaOrCodeblockSupported: boolean) => 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;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const isExcludedNode: (nodeName: string) => boolean;
|
|
3
|
-
export declare const isCursorSelectionAndInsideTopLevelNode: (selection: Selection) => boolean;
|
|
4
3
|
export declare const isCursorSelectionAtTopLevel: (selection: Selection) => boolean;
|
|
5
4
|
export declare const isInlineNode: (nodeName: string) => boolean;
|
|
6
5
|
export declare const isNestedInlineNode: (selection: Selection) => boolean;
|
|
7
|
-
export declare const isBlockNodeWithoutTable: (nodeName: string) => boolean;
|
|
8
|
-
export declare const isNestedTable: (selection: Selection) => boolean;
|
|
9
6
|
export declare const isNestedInTable: (state: EditorState) => boolean;
|
|
10
7
|
export declare const getParentNodeDepth: (selection: Selection) => number;
|
|
11
|
-
export declare const isValidNodeName: (copiedNodeName: string, pastedNodeName: string) => boolean;
|
|
12
|
-
export declare const isTextSelection: (selection: Selection) => boolean;
|
|
13
|
-
export declare const isNodeSelection: (selection: Selection) => boolean;
|
|
14
|
-
export declare const isEntireTopLevelHeadingOrParagraphSelected: (selection: Selection, nodeName: 'paragraph' | 'heading') => boolean | undefined;
|
|
15
|
-
export declare const isEntireTopLevelBlockquoteSelected: (state: EditorState) => boolean;
|
|
16
8
|
export declare const isEntireNestedParagraphOrHeadingSelected: (selection: Selection) => boolean;
|
|
@@ -51,7 +51,7 @@ export declare function handleParagraphBlockMarks(state: EditorState, slice: Sli
|
|
|
51
51
|
* ┗━p -> "two"
|
|
52
52
|
*/
|
|
53
53
|
export declare function flattenNestedListInSlice(slice: Slice): Slice;
|
|
54
|
-
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined): Command;
|
|
54
|
+
export declare function handleRichText(slice: Slice, queueCardsFromChangedTr: QueueCardsFromTransactionAction | undefined, isNestingMediaOrCodeblockSupported?: boolean): Command;
|
|
55
55
|
export declare function handlePasteIntoCaption(slice: Slice): Command;
|
|
56
56
|
export declare const handleSelectedTable: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (slice: Slice) => Command;
|
|
57
57
|
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) => Command;
|
|
31
|
+
export declare const handleRichTextWithAnalytics: (view: EditorView, event: ClipboardEvent, slice: Slice, pluginInjectionApi: ExtractInjectionAPI<PastePlugin> | undefined, isNestingMediaOrCodeblockSupported: boolean) => 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;
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { EditorState, Selection } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const isExcludedNode: (nodeName: string) => boolean;
|
|
3
|
-
export declare const isCursorSelectionAndInsideTopLevelNode: (selection: Selection) => boolean;
|
|
4
3
|
export declare const isCursorSelectionAtTopLevel: (selection: Selection) => boolean;
|
|
5
4
|
export declare const isInlineNode: (nodeName: string) => boolean;
|
|
6
5
|
export declare const isNestedInlineNode: (selection: Selection) => boolean;
|
|
7
|
-
export declare const isBlockNodeWithoutTable: (nodeName: string) => boolean;
|
|
8
|
-
export declare const isNestedTable: (selection: Selection) => boolean;
|
|
9
6
|
export declare const isNestedInTable: (state: EditorState) => boolean;
|
|
10
7
|
export declare const getParentNodeDepth: (selection: Selection) => number;
|
|
11
|
-
export declare const isValidNodeName: (copiedNodeName: string, pastedNodeName: string) => boolean;
|
|
12
|
-
export declare const isTextSelection: (selection: Selection) => boolean;
|
|
13
|
-
export declare const isNodeSelection: (selection: Selection) => boolean;
|
|
14
|
-
export declare const isEntireTopLevelHeadingOrParagraphSelected: (selection: Selection, nodeName: 'paragraph' | 'heading') => boolean | undefined;
|
|
15
|
-
export declare const isEntireTopLevelBlockquoteSelected: (state: EditorState) => boolean;
|
|
16
8
|
export declare const isEntireNestedParagraphOrHeadingSelected: (selection: Selection) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-paste",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.6",
|
|
4
4
|
"description": "Paste plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/editor-common": "^
|
|
34
|
+
"@atlaskit/editor-common": "^91.1.0",
|
|
35
35
|
"@atlaskit/editor-markdown-transformer": "^5.12.0",
|
|
36
36
|
"@atlaskit/editor-plugin-analytics": "^1.8.0",
|
|
37
37
|
"@atlaskit/editor-plugin-annotation": "^1.19.0",
|
|
38
38
|
"@atlaskit/editor-plugin-better-type-history": "^1.8.0",
|
|
39
|
-
"@atlaskit/editor-plugin-card": "^3.
|
|
39
|
+
"@atlaskit/editor-plugin-card": "^3.2.0",
|
|
40
40
|
"@atlaskit/editor-plugin-feature-flags": "^1.2.0",
|
|
41
41
|
"@atlaskit/editor-plugin-list": "^3.8.0",
|
|
42
|
-
"@atlaskit/editor-plugin-media": "^1.
|
|
42
|
+
"@atlaskit/editor-plugin-media": "^1.33.0",
|
|
43
43
|
"@atlaskit/editor-plugin-mentions": "^2.6.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
45
45
|
"@atlaskit/editor-tables": "^2.8.0",
|
|
46
46
|
"@atlaskit/media-client": "^28.0.0",
|
|
47
|
-
"@atlaskit/media-common": "^11.
|
|
47
|
+
"@atlaskit/media-common": "^11.5.0",
|
|
48
48
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
49
49
|
"@atlaskit/tmp-editor-statsig": "*",
|
|
50
50
|
"@babel/runtime": "^7.0.0",
|
|
@@ -120,6 +120,9 @@
|
|
|
120
120
|
},
|
|
121
121
|
"platform_editor_nest_nested_expand_in_expand_jira": {
|
|
122
122
|
"type": "boolean"
|
|
123
|
+
},
|
|
124
|
+
"editor_nest_media_and_codeblock_in_quotes_jira": {
|
|
125
|
+
"type": "boolean"
|
|
123
126
|
}
|
|
124
127
|
}
|
|
125
128
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
module.exports = {
|
|
2
|
-
rules: {
|
|
3
|
-
'@typescript-eslint/no-duplicate-imports': 'error',
|
|
4
|
-
'@typescript-eslint/no-explicit-any': 'error',
|
|
5
|
-
'@typescript-eslint/ban-types': [
|
|
6
|
-
'error',
|
|
7
|
-
{
|
|
8
|
-
types: {
|
|
9
|
-
'React.FC':
|
|
10
|
-
'Please use types directly on props instead, and explicitly define children if required',
|
|
11
|
-
'React.FunctionalComponent':
|
|
12
|
-
'Please use types directly on props instead, and explicitly define children if required',
|
|
13
|
-
},
|
|
14
|
-
extendDefaults: false,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
};
|