@atlaskit/editor-core 188.12.1 → 188.12.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 +13 -0
- package/dist/cjs/create-editor/sort-by-order.js +13 -20
- package/dist/cjs/plugins/annotation/utils.js +23 -43
- package/dist/cjs/plugins/code-block/utils.js +18 -43
- package/dist/cjs/plugins/paste/handlers.js +36 -18
- package/dist/cjs/plugins/paste/plugins/media.js +50 -24
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +6 -6
- package/dist/cjs/plugins/paste/pm-plugins/main.js +53 -51
- package/dist/cjs/plugins/paste/util/index.js +2 -2
- package/dist/cjs/plugins/rank.js +2 -27
- package/dist/cjs/plugins/tasks-and-decisions/utils.js +8 -12
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/create-editor/sort-by-order.js +1 -17
- package/dist/es2019/plugins/annotation/utils.js +6 -43
- package/dist/es2019/plugins/code-block/utils.js +1 -44
- package/dist/es2019/plugins/paste/handlers.js +18 -3
- package/dist/es2019/plugins/paste/plugins/media.js +53 -25
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +3 -3
- package/dist/es2019/plugins/paste/pm-plugins/main.js +11 -13
- package/dist/es2019/plugins/paste/util/index.js +1 -1
- package/dist/es2019/plugins/rank.js +2 -27
- package/dist/es2019/plugins/tasks-and-decisions/utils.js +2 -12
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/create-editor/sort-by-order.js +1 -17
- package/dist/esm/plugins/annotation/utils.js +8 -37
- package/dist/esm/plugins/code-block/utils.js +1 -42
- package/dist/esm/plugins/paste/handlers.js +23 -3
- package/dist/esm/plugins/paste/plugins/media.js +50 -23
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +3 -3
- package/dist/esm/plugins/paste/pm-plugins/main.js +11 -13
- package/dist/esm/plugins/paste/util/index.js +1 -1
- package/dist/esm/plugins/rank.js +2 -27
- package/dist/esm/plugins/tasks-and-decisions/utils.js +2 -12
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/create-editor/sort-by-order.d.ts +1 -14
- package/dist/types/plugins/annotation/utils.d.ts +3 -3
- package/dist/types/plugins/code-block/utils.d.ts +1 -6
- package/dist/types/plugins/paste/handlers.d.ts +2 -2
- package/dist/types/plugins/paste/plugins/media.d.ts +11 -0
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +1 -1
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/rank.d.ts +2 -6
- package/dist/types/plugins/tasks-and-decisions/utils.d.ts +2 -3
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/create-editor/sort-by-order.d.ts +1 -14
- package/dist/types-ts4.5/plugins/annotation/utils.d.ts +3 -3
- package/dist/types-ts4.5/plugins/code-block/utils.d.ts +1 -6
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -2
- package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +11 -0
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +1 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/rank.d.ts +2 -6
- package/dist/types-ts4.5/plugins/tasks-and-decisions/utils.d.ts +2 -3
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 188.12.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41923](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41923) [`0120da635b9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0120da635b9) - [ED-20519] Decoupling more paste plugin from editor-core moving common functions to editor-common
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 188.12.2
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#40916](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40916) [`0b80e2e68ea`](https://bitbucket.org/atlassian/atlassian-frontend/commits/0b80e2e68ea) - [ux] media single node with external type media should not show migration ui. Update external image with natural dimensions accordingly, and fixed whitespace issue in external image.
|
|
15
|
+
|
|
3
16
|
## 188.12.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -1,25 +1,18 @@
|
|
|
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
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function sortByOrderWithTypeName(item) {
|
|
22
|
-
return function (a, b) {
|
|
23
|
-
return _rank.default[item].indexOf(a.type.name) - _rank.default[item].indexOf(b.type.name);
|
|
24
|
-
};
|
|
25
|
-
}
|
|
6
|
+
Object.defineProperty(exports, "sortByOrder", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _legacyRankPlugins.sortByOrder;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "sortByOrderWithTypeName", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _legacyRankPlugins.sortByOrderWithTypeName;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
var _legacyRankPlugins = require("@atlaskit/editor-common/legacy-rank-plugins");
|
|
@@ -5,10 +5,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.addDraftDecoration = void 0;
|
|
7
7
|
exports.annotationExists = annotationExists;
|
|
8
|
-
exports
|
|
8
|
+
Object.defineProperty(exports, "containsAnyAnnotations", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _utils.containsAnyAnnotations;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
9
14
|
exports.getPluginState = exports.getDraftCommandAnalyticsPayload = exports.getAnnotationViewKey = exports.getAllAnnotations = exports.findAnnotationsInSelection = void 0;
|
|
10
15
|
exports.getSelectionPositions = getSelectionPositions;
|
|
11
|
-
exports
|
|
16
|
+
Object.defineProperty(exports, "hasAnnotationMark", {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function get() {
|
|
19
|
+
return _utils.hasAnnotationMark;
|
|
20
|
+
}
|
|
21
|
+
});
|
|
12
22
|
exports.hasInvalidNodes = void 0;
|
|
13
23
|
exports.hasInvalidWhitespaceNode = hasInvalidWhitespaceNode;
|
|
14
24
|
exports.isSelectionValid = exports.inlineCommentPluginKey = void 0;
|
|
@@ -20,8 +30,12 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
20
30
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
21
31
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
22
32
|
var _types = require("./types");
|
|
23
|
-
var
|
|
24
|
-
|
|
33
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
34
|
+
function sum(arr, f) {
|
|
35
|
+
return arr.reduce(function (val, x) {
|
|
36
|
+
return val + f(x);
|
|
37
|
+
}, 0);
|
|
38
|
+
}
|
|
25
39
|
/**
|
|
26
40
|
* Finds the marks in the nodes to the left and right.
|
|
27
41
|
* @param $pos Position to center search around
|
|
@@ -63,9 +77,9 @@ var filterAnnotationIds = function filterAnnotationIds(marks) {
|
|
|
63
77
|
var reorderAnnotations = function reorderAnnotations(annotations, $from) {
|
|
64
78
|
var idSet = surroundingMarks($from).map(filterAnnotationIds);
|
|
65
79
|
annotations.sort(function (a, b) {
|
|
66
|
-
return
|
|
80
|
+
return sum(idSet, function (ids) {
|
|
67
81
|
return ids.indexOf(a.id);
|
|
68
|
-
}) -
|
|
82
|
+
}) - sum(idSet, function (ids) {
|
|
69
83
|
return ids.indexOf(b.id);
|
|
70
84
|
});
|
|
71
85
|
});
|
|
@@ -278,7 +292,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
|
|
|
278
292
|
var foundInvalidWhitespace = false;
|
|
279
293
|
var content = selection.content().content;
|
|
280
294
|
content.descendants(function (node) {
|
|
281
|
-
if ((0,
|
|
295
|
+
if ((0, _utils.isText)(node, schema)) {
|
|
282
296
|
return false;
|
|
283
297
|
}
|
|
284
298
|
if (node.textContent.trim() === '') {
|
|
@@ -291,7 +305,7 @@ function hasInvalidWhitespaceNode(selection, schema) {
|
|
|
291
305
|
// and there are multiple nodes
|
|
292
306
|
!node.eq(content.firstChild) &&
|
|
293
307
|
// and it is a paragraph node
|
|
294
|
-
(0,
|
|
308
|
+
(0, _utils.isParagraph)(node, schema);
|
|
295
309
|
if (!nodeIsTrailingNewLine) {
|
|
296
310
|
foundInvalidWhitespace = true;
|
|
297
311
|
}
|
|
@@ -301,14 +315,6 @@ function hasInvalidWhitespaceNode(selection, schema) {
|
|
|
301
315
|
return foundInvalidWhitespace;
|
|
302
316
|
}
|
|
303
317
|
|
|
304
|
-
/*
|
|
305
|
-
* verifies if node contains annotation mark
|
|
306
|
-
*/
|
|
307
|
-
function hasAnnotationMark(node, state) {
|
|
308
|
-
var annotationMark = state.schema.marks.annotation;
|
|
309
|
-
return !!(annotationMark && node && node.marks.length && annotationMark.isInSet(node.marks));
|
|
310
|
-
}
|
|
311
|
-
|
|
312
318
|
/*
|
|
313
319
|
* verifies that the annotation exists by the given id
|
|
314
320
|
*/
|
|
@@ -317,32 +323,6 @@ function annotationExists(annotationId, state) {
|
|
|
317
323
|
return !!(commentsPluginState !== null && commentsPluginState !== void 0 && commentsPluginState.annotations) && Object.keys(commentsPluginState.annotations).includes(annotationId);
|
|
318
324
|
}
|
|
319
325
|
|
|
320
|
-
/*
|
|
321
|
-
* verifies that slice contains any annotations
|
|
322
|
-
*/
|
|
323
|
-
function containsAnyAnnotations(slice, state) {
|
|
324
|
-
if (!slice.content.size) {
|
|
325
|
-
return false;
|
|
326
|
-
}
|
|
327
|
-
var hasAnnotation = false;
|
|
328
|
-
slice.content.forEach(function (node) {
|
|
329
|
-
hasAnnotation = hasAnnotation || hasAnnotationMark(node, state);
|
|
330
|
-
// return early if annotation found already
|
|
331
|
-
if (hasAnnotation) {
|
|
332
|
-
return true;
|
|
333
|
-
}
|
|
334
|
-
// check annotations in descendants
|
|
335
|
-
node.descendants(function (node) {
|
|
336
|
-
if (hasAnnotationMark(node, state)) {
|
|
337
|
-
hasAnnotation = true;
|
|
338
|
-
return false;
|
|
339
|
-
}
|
|
340
|
-
return true;
|
|
341
|
-
});
|
|
342
|
-
});
|
|
343
|
-
return hasAnnotation;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
326
|
/*
|
|
347
327
|
* remove annotations that dont exsist in plugin state from slice
|
|
348
328
|
*/
|
|
@@ -364,7 +344,7 @@ function stripNonExistingAnnotations(slice, state) {
|
|
|
364
344
|
* from node
|
|
365
345
|
*/
|
|
366
346
|
function stripNonExistingAnnotationsFromNode(node, state) {
|
|
367
|
-
if (hasAnnotationMark(node, state)) {
|
|
347
|
+
if ((0, _utils.hasAnnotationMark)(node, state)) {
|
|
368
348
|
node.marks = node.marks.filter(function (mark) {
|
|
369
349
|
if (mark.type.name === 'annotation') {
|
|
370
350
|
return annotationExists(mark.attrs.id, state);
|
|
@@ -3,47 +3,22 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
11
|
-
function joinCodeBlocks(left, right) {
|
|
12
|
-
var textContext = "".concat(left.textContent, "\n").concat(right.textContent);
|
|
13
|
-
return left.type.create(left.attrs, left.type.schema.text(textContext));
|
|
14
|
-
}
|
|
15
|
-
function mergeAdjacentCodeBlocks(fragment) {
|
|
16
|
-
var children = [];
|
|
17
|
-
fragment.forEach(function (maybeCodeBlock) {
|
|
18
|
-
if (maybeCodeBlock.type === maybeCodeBlock.type.schema.nodes.codeBlock) {
|
|
19
|
-
var peekAtPrevious = children[children.length - 1];
|
|
20
|
-
if (peekAtPrevious && peekAtPrevious.type === maybeCodeBlock.type) {
|
|
21
|
-
return children.push(joinCodeBlocks(children.pop(), maybeCodeBlock));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
return children.push(maybeCodeBlock);
|
|
25
|
-
});
|
|
26
|
-
return _model.Fragment.from(children);
|
|
27
|
-
}
|
|
28
|
-
function transformSliceToJoinAdjacentCodeBlocks(slice) {
|
|
29
|
-
slice = (0, _slice.mapSlice)(slice, function (node) {
|
|
30
|
-
return node.isBlock && !node.isTextblock ? node.copy(mergeAdjacentCodeBlocks(node.content)) : node;
|
|
31
|
-
});
|
|
32
|
-
// mapSlice won't be able to merge adjacent top-level code-blocks
|
|
33
|
-
return new _model.Slice(mergeAdjacentCodeBlocks(slice.content), slice.openStart, slice.openEnd);
|
|
34
|
-
}
|
|
35
|
-
var transformSingleLineCodeBlockToCodeMark = exports.transformSingleLineCodeBlockToCodeMark = function transformSingleLineCodeBlockToCodeMark(slice, schema) {
|
|
36
|
-
if (slice.content.childCount === 1 && (slice.openStart || slice.openEnd)) {
|
|
37
|
-
var maybeCodeBlock = slice.content.firstChild;
|
|
38
|
-
if (maybeCodeBlock && maybeCodeBlock.type === schema.nodes.codeBlock) {
|
|
39
|
-
if (maybeCodeBlock.textContent && maybeCodeBlock.textContent.indexOf('\n') === -1) {
|
|
40
|
-
return new _model.Slice(_model.Fragment.from(schema.text(maybeCodeBlock.textContent, [schema.marks.code.create()])), 0, 0);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
6
|
+
Object.defineProperty(exports, "findCodeBlock", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _transforms.findCodeBlock;
|
|
43
10
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "transformSingleLineCodeBlockToCodeMark", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _transforms.transformSingleLineCodeBlockToCodeMark;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "transformSliceToJoinAdjacentCodeBlocks", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _transforms.transformSliceToJoinAdjacentCodeBlocks;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
var _transforms = require("@atlaskit/editor-common/transforms");
|
|
@@ -31,13 +31,12 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
31
31
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
32
32
|
var _v = _interopRequireDefault(require("uuid/v4"));
|
|
33
33
|
var _utils2 = require("@atlaskit/editor-tables/utils");
|
|
34
|
-
var _utils3 = require("
|
|
35
|
-
var
|
|
34
|
+
var _utils3 = require("@atlaskit/editor-common/utils");
|
|
35
|
+
var _coreUtils = require("@atlaskit/editor-common/core-utils");
|
|
36
36
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
37
37
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
38
38
|
var _macro = require("../macro");
|
|
39
39
|
var _util = require("./util");
|
|
40
|
-
var _utils4 = require("@atlaskit/editor-common/utils");
|
|
41
40
|
var _edgeCases = require("./edge-cases");
|
|
42
41
|
var _commands = require("./commands");
|
|
43
42
|
var _pluginFactory = require("./pm-plugins/plugin-factory");
|
|
@@ -46,10 +45,29 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
46
45
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
47
46
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
48
47
|
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; }
|
|
49
|
-
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; }
|
|
48
|
+
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; } // TODO: ED-20519 Needs Macro extraction
|
|
49
|
+
/** Helper type for single arg function */
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Compose 1 to n functions.
|
|
53
|
+
* @param func first function
|
|
54
|
+
* @param funcs additional functions
|
|
55
|
+
*/
|
|
56
|
+
function compose(func) {
|
|
57
|
+
for (var _len = arguments.length, funcs = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
58
|
+
funcs[_key - 1] = arguments[_key];
|
|
59
|
+
}
|
|
60
|
+
var allFuncs = [func].concat(funcs);
|
|
61
|
+
return function composed(raw) {
|
|
62
|
+
return allFuncs.reduceRight(function (memo, func) {
|
|
63
|
+
return func(memo);
|
|
64
|
+
}, raw);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
50
68
|
// remove text attribute from mention for copy/paste (GDPR)
|
|
51
69
|
function handleMention(slice, schema) {
|
|
52
|
-
return (0,
|
|
70
|
+
return (0, _utils3.mapSlice)(slice, function (node) {
|
|
53
71
|
if (node.type.name === schema.nodes.mention.name) {
|
|
54
72
|
var mention = node.attrs;
|
|
55
73
|
var newMention = _objectSpread(_objectSpread({}, mention), {}, {
|
|
@@ -105,13 +123,13 @@ function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
|
|
|
105
123
|
if (sliceIsInvalid || sliceIsAPanelReceivingLowDepthText || !selectionIsValidNode && !selectionHasValidParentNode) {
|
|
106
124
|
return false;
|
|
107
125
|
}
|
|
108
|
-
var filters = [(0,
|
|
126
|
+
var filters = [(0, _utils3.linkifyContent)(schema)];
|
|
109
127
|
var selectionMarks = selection.$head.marks();
|
|
110
128
|
if (selection instanceof _state.TextSelection && Array.isArray(selectionMarks) && selectionMarks.length > 0 && (0, _util.hasOnlyNodesOfType)(paragraph, text, emoji, mention, hardBreak)(slice) && (!codeMark.isInSet(selectionMarks) || (0, _mark.anyMarkActive)(state, codeMark)) // check if there is a code mark anywhere in the selection
|
|
111
129
|
) {
|
|
112
130
|
filters.push((0, _util.applyTextMarksToSlice)(schema, selection.$head.marks()));
|
|
113
131
|
}
|
|
114
|
-
var transformedSlice =
|
|
132
|
+
var transformedSlice = compose.apply(null, filters)(slice);
|
|
115
133
|
var tr = (0, _history.closeHistory)(state.tr);
|
|
116
134
|
var transformedSliceIsValidNode = transformedSlice.content.firstChild.type.inlineContent || ['decisionList', 'decisionItem', 'taskList', 'taskItem', 'panel'].includes(transformedSlice.content.firstChild.type.name) && !(0, _utils3.isInListItem)(state);
|
|
117
135
|
// If the slice or the selection are valid nodes to handle,
|
|
@@ -154,7 +172,7 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
154
172
|
|
|
155
173
|
// Slice info
|
|
156
174
|
var sliceContent = slice.content;
|
|
157
|
-
var sliceIsListItems = (0,
|
|
175
|
+
var sliceIsListItems = (0, _utils3.isListNode)(sliceContent.firstChild) && (0, _utils3.isListNode)(sliceContent.lastChild);
|
|
158
176
|
|
|
159
177
|
// Find case of slices that can be inserted into a list item
|
|
160
178
|
// (eg. paragraphs, list items, code blocks, media single)
|
|
@@ -181,7 +199,7 @@ function handlePasteNonNestableBlockNodesIntoList(slice) {
|
|
|
181
199
|
var selectionIsInNestedList = !!grandParentListNode;
|
|
182
200
|
var selectedListItemHasNestedList = false;
|
|
183
201
|
selectionParentListItemNode.node.content.forEach(function (child) {
|
|
184
|
-
if ((0,
|
|
202
|
+
if ((0, _utils3.isListNode)(child)) {
|
|
185
203
|
selectedListItemHasNestedList = true;
|
|
186
204
|
}
|
|
187
205
|
});
|
|
@@ -325,7 +343,7 @@ function handlePasteLinkOnSelectedText(slice) {
|
|
|
325
343
|
}
|
|
326
344
|
|
|
327
345
|
// if we have a link, apply it to the selected text if we have any and it's allowed
|
|
328
|
-
if (linkMark && selection instanceof _state.TextSelection && !selection.empty && (0,
|
|
346
|
+
if (linkMark && selection instanceof _state.TextSelection && !selection.empty && (0, _utils3.canLinkBeCreatedInRange)(from, to)(state)) {
|
|
329
347
|
tr.addMark(from, to, linkMark);
|
|
330
348
|
if (dispatch) {
|
|
331
349
|
dispatch(tr);
|
|
@@ -574,7 +592,7 @@ function handleMediaSingle(inputMethod, insertMediaAsMediaSingle) {
|
|
|
574
592
|
var _insertMediaAsMediaSi;
|
|
575
593
|
return (_insertMediaAsMediaSi = insertMediaAsMediaSingle === null || insertMediaAsMediaSingle === void 0 ? void 0 : insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod)) !== null && _insertMediaAsMediaSi !== void 0 ? _insertMediaAsMediaSi : false;
|
|
576
594
|
}
|
|
577
|
-
if ((0,
|
|
595
|
+
if ((0, _coreUtils.insideTable)(state) && isOnlyMediaSingle(state, slice)) {
|
|
578
596
|
var tr = state.tr.replaceSelection(slice);
|
|
579
597
|
var nextPos = tr.doc.resolve(tr.mapping.map(state.selection.$from.pos));
|
|
580
598
|
if (dispatch) {
|
|
@@ -600,7 +618,7 @@ function handleExpandPasteInTable(slice) {
|
|
|
600
618
|
return function (state, dispatch) {
|
|
601
619
|
// Do not handle expand if it's not being pasted into a table
|
|
602
620
|
// OR if it's nested within another node when being pasted into a table
|
|
603
|
-
if (!(0,
|
|
621
|
+
if (!(0, _coreUtils.insideTable)(state) || !checkExpand(slice)) {
|
|
604
622
|
return false;
|
|
605
623
|
}
|
|
606
624
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
@@ -608,7 +626,7 @@ function handleExpandPasteInTable(slice) {
|
|
|
608
626
|
nestedExpand = _state$schema$nodes2.nestedExpand;
|
|
609
627
|
var tr = state.tr;
|
|
610
628
|
var hasExpand = false;
|
|
611
|
-
var newSlice = (0,
|
|
629
|
+
var newSlice = (0, _utils3.mapSlice)(slice, function (maybeNode) {
|
|
612
630
|
if (maybeNode.type === expand) {
|
|
613
631
|
hasExpand = true;
|
|
614
632
|
try {
|
|
@@ -668,7 +686,7 @@ function hasInlineCode(state, slice) {
|
|
|
668
686
|
}
|
|
669
687
|
function rollupLeafListItems(list, leafListItems) {
|
|
670
688
|
list.content.forEach(function (child) {
|
|
671
|
-
if ((0,
|
|
689
|
+
if ((0, _utils3.isListNode)(child) || (0, _utils3.isListItemNode)(child) && (0, _utils3.isListNode)(child.firstChild)) {
|
|
672
690
|
rollupLeafListItems(child, leafListItems);
|
|
673
691
|
} else {
|
|
674
692
|
leafListItems.push(child);
|
|
@@ -677,7 +695,7 @@ function rollupLeafListItems(list, leafListItems) {
|
|
|
677
695
|
}
|
|
678
696
|
function shouldFlattenList(state, slice) {
|
|
679
697
|
var node = slice.content.firstChild;
|
|
680
|
-
return node && (0,
|
|
698
|
+
return node && (0, _coreUtils.insideTable)(state) && (0, _utils3.isListNode)(node) && slice.openStart > slice.openEnd;
|
|
681
699
|
}
|
|
682
700
|
function sliceHasTopLevelMarks(slice) {
|
|
683
701
|
var hasTopLevelMarks = false;
|
|
@@ -751,7 +769,7 @@ function handleParagraphBlockMarks(state, slice) {
|
|
|
751
769
|
|
|
752
770
|
// If the paragraph contains marks forbidden by the parent node (e.g. alignment/indentation),
|
|
753
771
|
// drop those marks from the slice
|
|
754
|
-
return (0,
|
|
772
|
+
return (0, _utils3.mapSlice)(slice, function (node) {
|
|
755
773
|
if (node.type === schema.nodes.paragraph) {
|
|
756
774
|
return schema.nodes.paragraph.createChecked(undefined, node.content, node.marks.filter(function (mark) {
|
|
757
775
|
return !forbiddenMarkTypes.includes(mark.type);
|
|
@@ -821,8 +839,8 @@ function handleRichText(slice, queueCardsFromChangedTr) {
|
|
|
821
839
|
slice = flattenNestedListInSlice(slice);
|
|
822
840
|
}
|
|
823
841
|
(0, _history.closeHistory)(tr);
|
|
824
|
-
var isFirstChildListNode = (0,
|
|
825
|
-
var isLastChildListNode = (0,
|
|
842
|
+
var isFirstChildListNode = (0, _utils3.isListNode)(firstChildOfSlice);
|
|
843
|
+
var isLastChildListNode = (0, _utils3.isListNode)(lastChildOfSlice);
|
|
826
844
|
var isSliceContentListNodes = isFirstChildListNode || isLastChildListNode;
|
|
827
845
|
var isFirstChildTaskListNode = (firstChildOfSlice === null || firstChildOfSlice === void 0 || (_firstChildOfSlice$ty = firstChildOfSlice.type) === null || _firstChildOfSlice$ty === void 0 ? void 0 : _firstChildOfSlice$ty.name) === 'taskList';
|
|
828
846
|
var isLastChildTaskListNode = (lastChildOfSlice === null || lastChildOfSlice === void 0 || (_lastChildOfSlice$typ = lastChildOfSlice.type) === null || _lastChildOfSlice$typ === void 0 ? void 0 : _lastChildOfSlice$typ.name) === 'taskList';
|
|
@@ -6,14 +6,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.isImage = void 0;
|
|
8
8
|
exports.transformSliceForMedia = transformSliceForMedia;
|
|
9
|
-
exports.unwrapNestedMediaElements = exports.transformSliceToCorrectMediaWrapper = void 0;
|
|
9
|
+
exports.unwrapNestedMediaElements = exports.transformSliceToMediaSingleWithNewExperience = exports.transformSliceToCorrectMediaWrapper = void 0;
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
13
13
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
14
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
15
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
15
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
|
+
/**
|
|
19
|
+
* Ensure correct layout in nested mode
|
|
20
|
+
*
|
|
21
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
22
|
+
*/
|
|
17
23
|
function transformSliceForMedia(slice, schema) {
|
|
18
24
|
var _schema$nodes = schema.nodes,
|
|
19
25
|
mediaSingle = _schema$nodes.mediaSingle,
|
|
@@ -21,8 +27,6 @@ function transformSliceForMedia(slice, schema) {
|
|
|
21
27
|
table = _schema$nodes.table,
|
|
22
28
|
bulletList = _schema$nodes.bulletList,
|
|
23
29
|
orderedList = _schema$nodes.orderedList,
|
|
24
|
-
media = _schema$nodes.media,
|
|
25
|
-
mediaInline = _schema$nodes.mediaInline,
|
|
26
30
|
expand = _schema$nodes.expand,
|
|
27
31
|
nestedExpand = _schema$nodes.nestedExpand;
|
|
28
32
|
return function (selection) {
|
|
@@ -49,27 +53,6 @@ function transformSliceForMedia(slice, schema) {
|
|
|
49
53
|
return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
|
|
50
54
|
});
|
|
51
55
|
}
|
|
52
|
-
var __mediaTraceId = (0, _mediaCommon.getRandomHex)(8);
|
|
53
|
-
newSlice = (0, _utils2.mapSlice)(newSlice, function (node) {
|
|
54
|
-
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
55
|
-
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
56
|
-
// sharing dependencies with editor-core to support products using it with various versions
|
|
57
|
-
// of editor packages.
|
|
58
|
-
// The duplication is in the following file:
|
|
59
|
-
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
60
|
-
if (node.type.name === 'media') {
|
|
61
|
-
return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
62
|
-
__external: node.attrs.type === 'external',
|
|
63
|
-
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
64
|
-
}), node.content, node.marks);
|
|
65
|
-
}
|
|
66
|
-
if (node.type.name === 'mediaInline') {
|
|
67
|
-
return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
68
|
-
__mediaTraceId: __mediaTraceId
|
|
69
|
-
}), node.content, node.marks);
|
|
70
|
-
}
|
|
71
|
-
return node;
|
|
72
|
-
});
|
|
73
56
|
return newSlice;
|
|
74
57
|
};
|
|
75
58
|
}
|
|
@@ -95,6 +78,49 @@ var transformSliceToCorrectMediaWrapper = exports.transformSliceToCorrectMediaWr
|
|
|
95
78
|
});
|
|
96
79
|
};
|
|
97
80
|
|
|
81
|
+
/**
|
|
82
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
83
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
84
|
+
*
|
|
85
|
+
*/
|
|
86
|
+
var transformSliceToMediaSingleWithNewExperience = exports.transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema) {
|
|
87
|
+
var _schema$nodes3 = schema.nodes,
|
|
88
|
+
mediaInline = _schema$nodes3.mediaInline,
|
|
89
|
+
mediaSingle = _schema$nodes3.mediaSingle,
|
|
90
|
+
media = _schema$nodes3.media;
|
|
91
|
+
var newSlice = (0, _utils2.mapSlice)(slice, function (node) {
|
|
92
|
+
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
93
|
+
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
94
|
+
// sharing dependencies with editor-core to support products using it with various versions
|
|
95
|
+
// of editor packages.
|
|
96
|
+
// The duplication is in the following file:
|
|
97
|
+
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
98
|
+
if (node.type === mediaSingle) {
|
|
99
|
+
return (0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience') ? mediaSingle.createChecked({
|
|
100
|
+
width: node.attrs.width || _mediaSingle.DEFAULT_IMAGE_WIDTH,
|
|
101
|
+
widthType: node.attrs.widthType || 'pixel',
|
|
102
|
+
layout: node.attrs.layout
|
|
103
|
+
}, node.content, node.marks) : node;
|
|
104
|
+
}
|
|
105
|
+
return node;
|
|
106
|
+
});
|
|
107
|
+
return (0, _utils2.mapSlice)(newSlice, function (node) {
|
|
108
|
+
var __mediaTraceId = (0, _mediaCommon.getRandomHex)(8);
|
|
109
|
+
if (node.type === media) {
|
|
110
|
+
return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
111
|
+
__external: node.attrs.type === 'external',
|
|
112
|
+
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
113
|
+
}), node.content, node.marks);
|
|
114
|
+
}
|
|
115
|
+
if (node.type.name === 'mediaInline') {
|
|
116
|
+
return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
117
|
+
__mediaTraceId: __mediaTraceId
|
|
118
|
+
}), node.content, node.marks);
|
|
119
|
+
}
|
|
120
|
+
return node;
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
|
|
98
124
|
/**
|
|
99
125
|
* Check base styles to see if an element will be invisible when rendered in a document.
|
|
100
126
|
* @param element
|
|
@@ -13,11 +13,11 @@ exports.handleSelectedTableWithAnalytics = exports.handleRichTextWithAnalytics =
|
|
|
13
13
|
exports.sendPasteAnalyticsEvent = sendPasteAnalyticsEvent;
|
|
14
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
var _analytics = require("
|
|
16
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
17
|
+
var _analytics2 = require("../../analytics");
|
|
17
18
|
var _util = require("../util");
|
|
18
19
|
var _handlers = require("../handlers");
|
|
19
20
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
20
|
-
var _slice = require("../../../utils/slice");
|
|
21
21
|
var _utils2 = require("@atlaskit/editor-common/utils");
|
|
22
22
|
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; }
|
|
23
23
|
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; }
|
|
@@ -101,7 +101,7 @@ function getContent(_ref) {
|
|
|
101
101
|
}
|
|
102
102
|
function getMediaTraceId(slice) {
|
|
103
103
|
var traceId;
|
|
104
|
-
(0,
|
|
104
|
+
(0, _utils2.mapSlice)(slice, function (node) {
|
|
105
105
|
if (node.type.name === 'media' || node.type.name === 'mediaInline') {
|
|
106
106
|
traceId = node.attrs.__mediaTraceId;
|
|
107
107
|
}
|
|
@@ -176,7 +176,7 @@ function createPasteAnalyticsPayloadBySelection(event, slice, pasteContext) {
|
|
|
176
176
|
// If we have a link among the pasted content, grab the
|
|
177
177
|
// domain and send it up with the analytics event
|
|
178
178
|
if (content === _analytics.PasteContents.url || content === _analytics.PasteContents.mixed) {
|
|
179
|
-
(0,
|
|
179
|
+
(0, _utils2.mapSlice)(slice, function (node) {
|
|
180
180
|
var linkMark = node.marks.find(function (mark) {
|
|
181
181
|
return mark.type.name === 'link';
|
|
182
182
|
});
|
|
@@ -223,7 +223,7 @@ function createPasteAnalyticsPayload(view, event, slice, pasteContext) {
|
|
|
223
223
|
// so pasteCommandWithAnalytics is useless in this case.
|
|
224
224
|
function sendPasteAnalyticsEvent(view, event, slice, pasteContext) {
|
|
225
225
|
var payload = createPasteAnalyticsPayload(view, event, slice, pasteContext);
|
|
226
|
-
view.dispatch((0,
|
|
226
|
+
view.dispatch((0, _analytics2.addAnalytics)(view.state, view.state.tr, payload));
|
|
227
227
|
}
|
|
228
228
|
var handlePasteAsPlainTextWithAnalytics = exports.handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainTextWithAnalytics(view, event, slice) {
|
|
229
229
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
@@ -284,7 +284,7 @@ function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
|
|
|
284
284
|
if (dispatch && originalTransaction.docChanged) {
|
|
285
285
|
// it needs to know the selection before the changes
|
|
286
286
|
var payload = createPayloadByTransaction(state.selection);
|
|
287
|
-
(0,
|
|
287
|
+
(0, _analytics2.addAnalytics)(state, originalTransaction, payload);
|
|
288
288
|
dispatch(originalTransaction);
|
|
289
289
|
}
|
|
290
290
|
return true;
|