@atlaskit/editor-core 188.12.1 → 188.12.2
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 +6 -0
- package/dist/cjs/plugins/paste/plugins/media.js +50 -24
- package/dist/cjs/plugins/paste/pm-plugins/main.js +1 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/paste/plugins/media.js +53 -25
- package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -5
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/paste/plugins/media.js +50 -23
- package/dist/esm/plugins/paste/pm-plugins/main.js +4 -5
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/paste/plugins/media.d.ts +11 -0
- package/dist/types-ts4.5/plugins/paste/plugins/media.d.ts +11 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 188.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#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.
|
|
8
|
+
|
|
3
9
|
## 188.12.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -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
|
|
@@ -395,6 +395,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
|
|
|
395
395
|
}
|
|
396
396
|
slice = (0, _utils3.transformSingleLineCodeBlockToCodeMark)(slice, schema);
|
|
397
397
|
slice = (0, _media.transformSliceToCorrectMediaWrapper)(slice, schema);
|
|
398
|
+
slice = (0, _media.transformSliceToMediaSingleWithNewExperience)(slice, schema);
|
|
398
399
|
slice = (0, _utils5.transformSliceToDecisionList)(slice, schema);
|
|
399
400
|
|
|
400
401
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/editor-core";
|
|
8
|
-
var version = exports.version = "188.12.
|
|
8
|
+
var version = exports.version = "188.12.2";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -2,6 +2,13 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
|
2
2
|
import { mapSlice, unwrap, removeNestedEmptyEls, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
|
|
3
3
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
4
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
5
|
+
import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Ensure correct layout in nested mode
|
|
9
|
+
*
|
|
10
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
11
|
+
*/
|
|
5
12
|
export function transformSliceForMedia(slice, schema) {
|
|
6
13
|
const {
|
|
7
14
|
mediaSingle,
|
|
@@ -9,8 +16,6 @@ export function transformSliceForMedia(slice, schema) {
|
|
|
9
16
|
table,
|
|
10
17
|
bulletList,
|
|
11
18
|
orderedList,
|
|
12
|
-
media,
|
|
13
|
-
mediaInline,
|
|
14
19
|
expand,
|
|
15
20
|
nestedExpand
|
|
16
21
|
} = schema.nodes;
|
|
@@ -41,29 +46,6 @@ export function transformSliceForMedia(slice, schema) {
|
|
|
41
46
|
return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
|
-
const __mediaTraceId = getRandomHex(8);
|
|
45
|
-
newSlice = mapSlice(newSlice, node => {
|
|
46
|
-
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
47
|
-
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
48
|
-
// sharing dependencies with editor-core to support products using it with various versions
|
|
49
|
-
// of editor packages.
|
|
50
|
-
// The duplication is in the following file:
|
|
51
|
-
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
52
|
-
if (node.type.name === 'media') {
|
|
53
|
-
return media.createChecked({
|
|
54
|
-
...node.attrs,
|
|
55
|
-
__external: node.attrs.type === 'external',
|
|
56
|
-
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
57
|
-
}, node.content, node.marks);
|
|
58
|
-
}
|
|
59
|
-
if (node.type.name === 'mediaInline') {
|
|
60
|
-
return mediaInline.createChecked({
|
|
61
|
-
...node.attrs,
|
|
62
|
-
__mediaTraceId
|
|
63
|
-
}, node.content, node.marks);
|
|
64
|
-
}
|
|
65
|
-
return node;
|
|
66
|
-
});
|
|
67
49
|
return newSlice;
|
|
68
50
|
};
|
|
69
51
|
}
|
|
@@ -90,6 +72,52 @@ export const transformSliceToCorrectMediaWrapper = (slice, schema) => {
|
|
|
90
72
|
});
|
|
91
73
|
};
|
|
92
74
|
|
|
75
|
+
/**
|
|
76
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
77
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
78
|
+
*
|
|
79
|
+
*/
|
|
80
|
+
export const transformSliceToMediaSingleWithNewExperience = (slice, schema) => {
|
|
81
|
+
const {
|
|
82
|
+
mediaInline,
|
|
83
|
+
mediaSingle,
|
|
84
|
+
media
|
|
85
|
+
} = schema.nodes;
|
|
86
|
+
const newSlice = mapSlice(slice, node => {
|
|
87
|
+
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
88
|
+
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
89
|
+
// sharing dependencies with editor-core to support products using it with various versions
|
|
90
|
+
// of editor packages.
|
|
91
|
+
// The duplication is in the following file:
|
|
92
|
+
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
93
|
+
if (node.type === mediaSingle) {
|
|
94
|
+
return getBooleanFF('platform.editor.media.extended-resize-experience') ? mediaSingle.createChecked({
|
|
95
|
+
width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
|
|
96
|
+
widthType: node.attrs.widthType || 'pixel',
|
|
97
|
+
layout: node.attrs.layout
|
|
98
|
+
}, node.content, node.marks) : node;
|
|
99
|
+
}
|
|
100
|
+
return node;
|
|
101
|
+
});
|
|
102
|
+
return mapSlice(newSlice, node => {
|
|
103
|
+
const __mediaTraceId = getRandomHex(8);
|
|
104
|
+
if (node.type === media) {
|
|
105
|
+
return media.createChecked({
|
|
106
|
+
...node.attrs,
|
|
107
|
+
__external: node.attrs.type === 'external',
|
|
108
|
+
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
109
|
+
}, node.content, node.marks);
|
|
110
|
+
}
|
|
111
|
+
if (node.type.name === 'mediaInline') {
|
|
112
|
+
return mediaInline.createChecked({
|
|
113
|
+
...node.attrs,
|
|
114
|
+
__mediaTraceId
|
|
115
|
+
}, node.content, node.marks);
|
|
116
|
+
}
|
|
117
|
+
return node;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
|
|
93
121
|
/**
|
|
94
122
|
* Check base styles to see if an element will be invisible when rendered in a document.
|
|
95
123
|
* @param element
|
|
@@ -5,19 +5,17 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
|
5
5
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
6
6
|
import { mapChildren } from '../../../utils/slice';
|
|
7
7
|
import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
|
|
8
|
-
import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
|
|
9
|
-
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../plugins/media';
|
|
8
|
+
import { isPastedFile as isPastedFileFromEvent, md } from '@atlaskit/editor-common/paste';
|
|
9
|
+
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../plugins/media';
|
|
10
10
|
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
|
|
11
|
-
import { linkifyContent } from '@atlaskit/editor-common/utils';
|
|
11
|
+
import { linkifyContent, measureRender } from '@atlaskit/editor-common/utils';
|
|
12
12
|
import { transformSliceNestedExpandToExpand } from '../../expand/utils';
|
|
13
13
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from '../handlers';
|
|
14
14
|
import { transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '../../code-block/utils';
|
|
15
15
|
import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handleCodeBlockWithAnalytics, handleMediaSingleWithAnalytics, handlePastePreservingMarksWithAnalytics, handleMarkdownWithAnalytics, handleRichTextWithAnalytics, handleExpandWithAnalytics, handleSelectedTableWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, sendPasteAnalyticsEvent, handlePasteIntoCaptionWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics } from './analytics';
|
|
16
16
|
import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../analytics';
|
|
17
17
|
import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
|
|
18
|
-
import { measureRender } from '@atlaskit/editor-common/utils';
|
|
19
18
|
import { upgradeTextToLists, splitParagraphs } from '../commands';
|
|
20
|
-
import { md } from '@atlaskit/editor-common/paste';
|
|
21
19
|
import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
|
|
22
20
|
import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
|
|
23
21
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
@@ -365,6 +363,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
365
363
|
}
|
|
366
364
|
slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
|
|
367
365
|
slice = transformSliceToCorrectMediaWrapper(slice, schema);
|
|
366
|
+
slice = transformSliceToMediaSingleWithNewExperience(slice, schema);
|
|
368
367
|
slice = transformSliceToDecisionList(slice, schema);
|
|
369
368
|
|
|
370
369
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
@@ -5,6 +5,13 @@ import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
|
5
5
|
import { mapSlice, unwrap, removeNestedEmptyEls, walkUpTreeUntil } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
7
7
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
8
|
+
import { DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Ensure correct layout in nested mode
|
|
12
|
+
*
|
|
13
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
14
|
+
*/
|
|
8
15
|
export function transformSliceForMedia(slice, schema) {
|
|
9
16
|
var _schema$nodes = schema.nodes,
|
|
10
17
|
mediaSingle = _schema$nodes.mediaSingle,
|
|
@@ -12,8 +19,6 @@ export function transformSliceForMedia(slice, schema) {
|
|
|
12
19
|
table = _schema$nodes.table,
|
|
13
20
|
bulletList = _schema$nodes.bulletList,
|
|
14
21
|
orderedList = _schema$nodes.orderedList,
|
|
15
|
-
media = _schema$nodes.media,
|
|
16
|
-
mediaInline = _schema$nodes.mediaInline,
|
|
17
22
|
expand = _schema$nodes.expand,
|
|
18
23
|
nestedExpand = _schema$nodes.nestedExpand;
|
|
19
24
|
return function (selection) {
|
|
@@ -40,27 +45,6 @@ export function transformSliceForMedia(slice, schema) {
|
|
|
40
45
|
return node.type.name === 'mediaSingle' ? mediaSingle.createChecked(attrs, node.content, node.marks) : node;
|
|
41
46
|
});
|
|
42
47
|
}
|
|
43
|
-
var __mediaTraceId = getRandomHex(8);
|
|
44
|
-
newSlice = mapSlice(newSlice, function (node) {
|
|
45
|
-
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
46
|
-
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
47
|
-
// sharing dependencies with editor-core to support products using it with various versions
|
|
48
|
-
// of editor packages.
|
|
49
|
-
// The duplication is in the following file:
|
|
50
|
-
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
51
|
-
if (node.type.name === 'media') {
|
|
52
|
-
return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
53
|
-
__external: node.attrs.type === 'external',
|
|
54
|
-
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
55
|
-
}), node.content, node.marks);
|
|
56
|
-
}
|
|
57
|
-
if (node.type.name === 'mediaInline') {
|
|
58
|
-
return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
59
|
-
__mediaTraceId: __mediaTraceId
|
|
60
|
-
}), node.content, node.marks);
|
|
61
|
-
}
|
|
62
|
-
return node;
|
|
63
|
-
});
|
|
64
48
|
return newSlice;
|
|
65
49
|
};
|
|
66
50
|
}
|
|
@@ -86,6 +70,49 @@ export var transformSliceToCorrectMediaWrapper = function transformSliceToCorrec
|
|
|
86
70
|
});
|
|
87
71
|
};
|
|
88
72
|
|
|
73
|
+
/**
|
|
74
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
75
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
76
|
+
*
|
|
77
|
+
*/
|
|
78
|
+
export var transformSliceToMediaSingleWithNewExperience = function transformSliceToMediaSingleWithNewExperience(slice, schema) {
|
|
79
|
+
var _schema$nodes3 = schema.nodes,
|
|
80
|
+
mediaInline = _schema$nodes3.mediaInline,
|
|
81
|
+
mediaSingle = _schema$nodes3.mediaSingle,
|
|
82
|
+
media = _schema$nodes3.media;
|
|
83
|
+
var newSlice = mapSlice(slice, function (node) {
|
|
84
|
+
// This logic is duplicated in editor-plugin-ai where external images can be inserted
|
|
85
|
+
// from external sources through the use of AI. The editor-plugin-ai package is avoiding
|
|
86
|
+
// sharing dependencies with editor-core to support products using it with various versions
|
|
87
|
+
// of editor packages.
|
|
88
|
+
// The duplication is in the following file:
|
|
89
|
+
// packages/editor/editor-plugin-ai/src/prebuilt/content-transformers/markdown-to-pm/markdown-transformer.ts
|
|
90
|
+
if (node.type === mediaSingle) {
|
|
91
|
+
return getBooleanFF('platform.editor.media.extended-resize-experience') ? mediaSingle.createChecked({
|
|
92
|
+
width: node.attrs.width || DEFAULT_IMAGE_WIDTH,
|
|
93
|
+
widthType: node.attrs.widthType || 'pixel',
|
|
94
|
+
layout: node.attrs.layout
|
|
95
|
+
}, node.content, node.marks) : node;
|
|
96
|
+
}
|
|
97
|
+
return node;
|
|
98
|
+
});
|
|
99
|
+
return mapSlice(newSlice, function (node) {
|
|
100
|
+
var __mediaTraceId = getRandomHex(8);
|
|
101
|
+
if (node.type === media) {
|
|
102
|
+
return media.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
103
|
+
__external: node.attrs.type === 'external',
|
|
104
|
+
__mediaTraceId: node.attrs.type === 'external' ? null : __mediaTraceId
|
|
105
|
+
}), node.content, node.marks);
|
|
106
|
+
}
|
|
107
|
+
if (node.type.name === 'mediaInline') {
|
|
108
|
+
return mediaInline.createChecked(_objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
109
|
+
__mediaTraceId: __mediaTraceId
|
|
110
|
+
}), node.content, node.marks);
|
|
111
|
+
}
|
|
112
|
+
return node;
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
|
|
89
116
|
/**
|
|
90
117
|
* Check base styles to see if an element will be invisible when rendered in a document.
|
|
91
118
|
* @param element
|
|
@@ -7,19 +7,17 @@ import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
|
7
7
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
8
8
|
import { mapChildren } from '../../../utils/slice';
|
|
9
9
|
import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
|
|
10
|
-
import { isPastedFile as isPastedFileFromEvent } from '@atlaskit/editor-common/paste';
|
|
11
|
-
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../plugins/media';
|
|
10
|
+
import { isPastedFile as isPastedFileFromEvent, md } from '@atlaskit/editor-common/paste';
|
|
11
|
+
import { transformSliceForMedia, transformSliceToCorrectMediaWrapper, transformSliceToMediaSingleWithNewExperience, unwrapNestedMediaElements } from '../plugins/media';
|
|
12
12
|
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
|
|
13
|
-
import { linkifyContent } from '@atlaskit/editor-common/utils';
|
|
13
|
+
import { linkifyContent, measureRender } from '@atlaskit/editor-common/utils';
|
|
14
14
|
import { transformSliceNestedExpandToExpand } from '../../expand/utils';
|
|
15
15
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from '../handlers';
|
|
16
16
|
import { transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '../../code-block/utils';
|
|
17
17
|
import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handleCodeBlockWithAnalytics, handleMediaSingleWithAnalytics, handlePastePreservingMarksWithAnalytics, handleMarkdownWithAnalytics, handleRichTextWithAnalytics, handleExpandWithAnalytics, handleSelectedTableWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, sendPasteAnalyticsEvent, handlePasteIntoCaptionWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics } from './analytics';
|
|
18
18
|
import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../analytics';
|
|
19
19
|
import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
|
|
20
|
-
import { measureRender } from '@atlaskit/editor-common/utils';
|
|
21
20
|
import { upgradeTextToLists, splitParagraphs } from '../commands';
|
|
22
|
-
import { md } from '@atlaskit/editor-common/paste';
|
|
23
21
|
import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
|
|
24
22
|
import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
|
|
25
23
|
import { clipboardTextSerializer } from './clipboard-text-serializer';
|
|
@@ -385,6 +383,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
385
383
|
}
|
|
386
384
|
slice = transformSingleLineCodeBlockToCodeMark(slice, schema);
|
|
387
385
|
slice = transformSliceToCorrectMediaWrapper(slice, schema);
|
|
386
|
+
slice = transformSliceToMediaSingleWithNewExperience(slice, schema);
|
|
388
387
|
slice = transformSliceToDecisionList(slice, schema);
|
|
389
388
|
|
|
390
389
|
// splitting linebreaks into paragraphs must happen before upgrading text to lists
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { Slice, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* Ensure correct layout in nested mode
|
|
5
|
+
*
|
|
6
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
7
|
+
*/
|
|
3
8
|
export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
|
|
4
9
|
export declare const isImage: (fileType?: string) => boolean;
|
|
5
10
|
export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema: Schema) => Slice;
|
|
11
|
+
/**
|
|
12
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
13
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema) => Slice;
|
|
6
17
|
/**
|
|
7
18
|
* Given a html string, we attempt to hoist any nested `<img>` tags,
|
|
8
19
|
* not directly wrapped by a `<div>` as ProseMirror no-op's
|
|
@@ -1,8 +1,19 @@
|
|
|
1
1
|
import type { Slice, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
2
2
|
import type { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
/**
|
|
4
|
+
* Ensure correct layout in nested mode
|
|
5
|
+
*
|
|
6
|
+
* TODO: this func is only used in handlePaste, so layout update won't work for drop event
|
|
7
|
+
*/
|
|
3
8
|
export declare function transformSliceForMedia(slice: Slice, schema: Schema): (selection: Selection) => Slice;
|
|
4
9
|
export declare const isImage: (fileType?: string) => boolean;
|
|
5
10
|
export declare const transformSliceToCorrectMediaWrapper: (slice: Slice, schema: Schema) => Slice;
|
|
11
|
+
/**
|
|
12
|
+
* This func will be called when copy & paste, drag & drop external html with media, media files, and slices from editor
|
|
13
|
+
* Because width may not be available when transform, DEFAULT_IMAGE_WIDTH is used as a fallback
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
export declare const transformSliceToMediaSingleWithNewExperience: (slice: Slice, schema: Schema) => Slice;
|
|
6
17
|
/**
|
|
7
18
|
* Given a html string, we attempt to hoist any nested `<img>` tags,
|
|
8
19
|
* not directly wrapped by a `<div>` as ProseMirror no-op's
|