@atlaskit/editor-plugin-media 0.4.0 → 0.4.1
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 +7 -0
- package/dist/cjs/pm-plugins/main.js +14 -10
- package/dist/cjs/utils/{is-image.js → is-type.js} +4 -1
- package/dist/cjs/utils/media-inline.js +27 -0
- package/dist/cjs/utils/media-single.js +3 -3
- package/dist/es2019/pm-plugins/main.js +18 -14
- package/dist/es2019/utils/{is-image.js → is-type.js} +3 -0
- package/dist/es2019/utils/media-inline.js +21 -0
- package/dist/es2019/utils/media-single.js +1 -1
- package/dist/esm/pm-plugins/main.js +18 -14
- package/dist/esm/utils/{is-image.js → is-type.js} +3 -0
- package/dist/esm/utils/media-inline.js +21 -0
- package/dist/esm/utils/media-single.js +1 -1
- package/dist/{types-ts4.5/utils/is-image.d.ts → types/utils/is-type.d.ts} +1 -0
- package/dist/types/utils/media-inline.d.ts +4 -0
- package/dist/{types/utils/is-image.d.ts → types-ts4.5/utils/is-type.d.ts} +1 -0
- package/dist/types-ts4.5/utils/media-inline.d.ts +4 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#43145](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43145) [`999af31b6ad`](https://bitbucket.org/atlassian/atlassian-frontend/commits/999af31b6ad) - [ux] [ED-20776] Change mediaInline node insertion logic behind 'platform.editor.media.inline-image.base-support' feature flag. With the flag on, Adding an image to a non-empty paragraph and list node inserts an media inline node, instead of media single node.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 0.4.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
|
@@ -38,6 +38,7 @@ var _pickerFacade = _interopRequireDefault(require("../picker-facade"));
|
|
|
38
38
|
var _DropPlaceholder = _interopRequireDefault(require("../ui/Media/DropPlaceholder"));
|
|
39
39
|
var _mediaCommon2 = require("../utils/media-common");
|
|
40
40
|
var _mediaFiles = require("../utils/media-files");
|
|
41
|
+
var _mediaInline = require("../utils/media-inline");
|
|
41
42
|
var _mediaSingle2 = require("../utils/media-single");
|
|
42
43
|
var _mediaTaskManager = require("./mediaTaskManager");
|
|
43
44
|
var _pluginKey = require("./plugin-key");
|
|
@@ -224,7 +225,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
224
225
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
225
226
|
*/
|
|
226
227
|
(0, _defineProperty2.default)(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
227
|
-
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2;
|
|
228
|
+
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection2;
|
|
228
229
|
var state = _this.view.state;
|
|
229
230
|
var editorAnalyticsAPI = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 || (_this$pluginInjection = _this$pluginInjection.analytics) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.actions;
|
|
230
231
|
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
@@ -241,15 +242,18 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
241
242
|
allUploadsFinished: false
|
|
242
243
|
});
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
switch ((0, _mediaInline.getMediaNodeInsertionType)(state, (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
246
|
+
case 'inline':
|
|
247
|
+
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
248
|
+
break;
|
|
249
|
+
case 'block':
|
|
250
|
+
// read width state right before inserting to get up-to-date and define values
|
|
251
|
+
var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
|
|
252
|
+
(0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
253
|
+
break;
|
|
254
|
+
case 'group':
|
|
255
|
+
(0, _mediaFiles.insertMediaGroupNode)(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
256
|
+
break;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
// do events when media state changes
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isImage = void 0;
|
|
6
|
+
exports.isVideo = exports.isImage = void 0;
|
|
7
7
|
var isImage = exports.isImage = function isImage(fileType) {
|
|
8
8
|
return !!fileType && (fileType.indexOf('image/') > -1 || fileType.indexOf('video/') > -1);
|
|
9
|
+
};
|
|
10
|
+
var isVideo = exports.isVideo = function isVideo(fileType) {
|
|
11
|
+
return !!fileType && fileType.includes('video/');
|
|
9
12
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMediaNodeInsertionType = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _mediaFiles = require("../utils/media-files");
|
|
11
|
+
var _mediaSingle = require("../utils/media-single");
|
|
12
|
+
var _isType = require("./is-type");
|
|
13
|
+
var _mediaCommon2 = require("./media-common");
|
|
14
|
+
var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function getMediaNodeInsertionType(state, mediaFeatureFlags, fileMimeType) {
|
|
15
|
+
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || (0, _utils.isInListItem)(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
16
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support')) {
|
|
17
|
+
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
18
|
+
return 'inline';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if ((0, _mediaSingle.isMediaSingle)(state.schema, fileMimeType)) {
|
|
22
|
+
return 'block';
|
|
23
|
+
} else if (canInsertInlineNode) {
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
26
|
+
return 'group';
|
|
27
|
+
};
|
|
@@ -18,7 +18,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
18
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
20
|
var _mediaCommon = require("../utils/media-common");
|
|
21
|
-
var
|
|
21
|
+
var _isType = require("./is-type");
|
|
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; }
|
|
24
24
|
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
@@ -62,7 +62,7 @@ function insertNodesWithOptionalParagraph(nodes) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
var isMediaSingle = exports.isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
65
|
-
return !!schema.nodes.mediaSingle && (0,
|
|
65
|
+
return !!schema.nodes.mediaSingle && (0, _isType.isImage)(fileMimeType);
|
|
66
66
|
};
|
|
67
67
|
var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
|
|
68
68
|
var state = view.state,
|
|
@@ -75,7 +75,7 @@ var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function inser
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// if not an image type media node
|
|
78
|
-
if (node.type !== media || !(0,
|
|
78
|
+
if (node.type !== media || !(0, _isType.isImage)(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
var mediaSingleNode = mediaSingle.create({}, node);
|
|
@@ -6,7 +6,7 @@ import { RawIntlProvider } from 'react-intl-next';
|
|
|
6
6
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
8
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
|
-
import { browser, ErrorReporter
|
|
9
|
+
import { browser, ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { insertPoint } from '@atlaskit/editor-prosemirror/transform';
|
|
12
12
|
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -18,9 +18,10 @@ import * as helpers from '../commands/helpers';
|
|
|
18
18
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
19
19
|
import PickerFacade from '../picker-facade';
|
|
20
20
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
21
|
+
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
22
|
+
import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
23
|
+
import { getMediaNodeInsertionType } from '../utils/media-inline';
|
|
24
|
+
import { insertMediaSingleNode } from '../utils/media-single';
|
|
24
25
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
25
26
|
import { stateKey } from './plugin-key';
|
|
26
27
|
export { stateKey } from './plugin-key';
|
|
@@ -152,7 +153,7 @@ export class MediaPluginStateImplementation {
|
|
|
152
153
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
153
154
|
*/
|
|
154
155
|
_defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType) => {
|
|
155
|
-
var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2;
|
|
156
|
+
var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection3;
|
|
156
157
|
const {
|
|
157
158
|
state
|
|
158
159
|
} = this.view;
|
|
@@ -172,15 +173,18 @@ export class MediaPluginStateImplementation {
|
|
|
172
173
|
allUploadsFinished: false
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
switch (getMediaNodeInsertionType(state, (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
177
|
+
case 'inline':
|
|
178
|
+
insertMediaInlineNode(editorAnalyticsAPI)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
179
|
+
break;
|
|
180
|
+
case 'block':
|
|
181
|
+
// read width state right before inserting to get up-to-date and define values
|
|
182
|
+
const widthPluginState = (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.width.sharedState.currentState();
|
|
183
|
+
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
184
|
+
break;
|
|
185
|
+
case 'group':
|
|
186
|
+
insertMediaGroupNode(editorAnalyticsAPI)(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
|
|
187
|
+
break;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
// do events when media state changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isInEmptyLine, isInListItem } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { canInsertMediaInline } from '../utils/media-files';
|
|
5
|
+
import { isMediaSingle } from '../utils/media-single';
|
|
6
|
+
import { isVideo } from './is-type';
|
|
7
|
+
import { isInsidePotentialEmptyParagraph } from './media-common';
|
|
8
|
+
export const getMediaNodeInsertionType = (state, mediaFeatureFlags, fileMimeType) => {
|
|
9
|
+
const canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state);
|
|
10
|
+
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
11
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
12
|
+
return 'inline';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (isMediaSingle(state.schema, fileMimeType)) {
|
|
16
|
+
return 'block';
|
|
17
|
+
} else if (canInsertInlineNode) {
|
|
18
|
+
return 'inline';
|
|
19
|
+
}
|
|
20
|
+
return 'group';
|
|
21
|
+
};
|
|
@@ -8,7 +8,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
8
8
|
import { safeInsert as pmSafeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
11
|
-
import { isImage } from './is-
|
|
11
|
+
import { isImage } from './is-type';
|
|
12
12
|
const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
|
|
13
13
|
action: ACTION.INSERTED,
|
|
14
14
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
@@ -15,7 +15,7 @@ import { RawIntlProvider } from 'react-intl-next';
|
|
|
15
15
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
16
|
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
17
17
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
18
|
-
import { browser, ErrorReporter
|
|
18
|
+
import { browser, ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
19
19
|
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
20
20
|
import { insertPoint } from '@atlaskit/editor-prosemirror/transform';
|
|
21
21
|
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -27,9 +27,10 @@ import * as helpers from '../commands/helpers';
|
|
|
27
27
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
28
28
|
import PickerFacade from '../picker-facade';
|
|
29
29
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
30
|
+
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
31
|
+
import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
32
|
+
import { getMediaNodeInsertionType } from '../utils/media-inline';
|
|
33
|
+
import { insertMediaSingleNode } from '../utils/media-single';
|
|
33
34
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
34
35
|
import { stateKey } from './plugin-key';
|
|
35
36
|
export { stateKey } from './plugin-key';
|
|
@@ -209,7 +210,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
209
210
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
210
211
|
*/
|
|
211
212
|
_defineProperty(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
212
|
-
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2;
|
|
213
|
+
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection2;
|
|
213
214
|
var state = _this.view.state;
|
|
214
215
|
var editorAnalyticsAPI = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 || (_this$pluginInjection = _this$pluginInjection.analytics) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.actions;
|
|
215
216
|
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
@@ -226,15 +227,18 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
226
227
|
allUploadsFinished: false
|
|
227
228
|
});
|
|
228
229
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
230
|
+
switch (getMediaNodeInsertionType(state, (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
231
|
+
case 'inline':
|
|
232
|
+
insertMediaInlineNode(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
233
|
+
break;
|
|
234
|
+
case 'block':
|
|
235
|
+
// read width state right before inserting to get up-to-date and define values
|
|
236
|
+
var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
|
|
237
|
+
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
238
|
+
break;
|
|
239
|
+
case 'group':
|
|
240
|
+
insertMediaGroupNode(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
241
|
+
break;
|
|
238
242
|
}
|
|
239
243
|
|
|
240
244
|
// do events when media state changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { isInEmptyLine, isInListItem } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
3
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
|
+
import { canInsertMediaInline } from '../utils/media-files';
|
|
5
|
+
import { isMediaSingle } from '../utils/media-single';
|
|
6
|
+
import { isVideo } from './is-type';
|
|
7
|
+
import { isInsidePotentialEmptyParagraph } from './media-common';
|
|
8
|
+
export var getMediaNodeInsertionType = function getMediaNodeInsertionType(state, mediaFeatureFlags, fileMimeType) {
|
|
9
|
+
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state);
|
|
10
|
+
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
11
|
+
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
12
|
+
return 'inline';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
if (isMediaSingle(state.schema, fileMimeType)) {
|
|
16
|
+
return 'block';
|
|
17
|
+
} else if (canInsertInlineNode) {
|
|
18
|
+
return 'inline';
|
|
19
|
+
}
|
|
20
|
+
return 'group';
|
|
21
|
+
};
|
|
@@ -11,7 +11,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
11
11
|
import { safeInsert as pmSafeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
12
12
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
13
13
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
14
|
-
import { isImage } from './is-
|
|
14
|
+
import { isImage } from './is-type';
|
|
15
15
|
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
16
16
|
return {
|
|
17
17
|
action: ACTION.INSERTED,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
|
+
export type MediaNodeType = 'inline' | 'block' | 'group';
|
|
4
|
+
export declare const getMediaNodeInsertionType: (state: EditorState, mediaFeatureFlags?: MediaFeatureFlags, fileMimeType?: string) => MediaNodeType;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
import type { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
|
+
export type MediaNodeType = 'inline' | 'block' | 'group';
|
|
4
|
+
export declare const getMediaNodeInsertionType: (state: EditorState, mediaFeatureFlags?: MediaFeatureFlags, fileMimeType?: string) => MediaNodeType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@atlaskit/editor-shared-styles": "^2.6.0",
|
|
53
53
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
54
54
|
"@atlaskit/form": "^9.0.0",
|
|
55
|
-
"@atlaskit/icon": "^
|
|
55
|
+
"@atlaskit/icon": "^22.0.0",
|
|
56
56
|
"@atlaskit/media-card": "^77.4.0",
|
|
57
57
|
"@atlaskit/media-client": "^25.0.0",
|
|
58
58
|
"@atlaskit/media-client-react": "^1.4.0",
|