@atlaskit/editor-plugin-media 0.6.2 → 0.6.4
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 +12 -0
- package/dist/cjs/nodeviews/mediaInline.js +3 -1
- package/dist/cjs/pm-plugins/main.js +1 -1
- package/dist/cjs/toolbar/mediaInline.js +2 -2
- package/dist/cjs/utils/is-type.js +2 -2
- package/dist/cjs/utils/media-files.js +3 -5
- package/dist/es2019/nodeviews/mediaInline.js +6 -2
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/toolbar/mediaInline.js +2 -2
- package/dist/es2019/utils/is-type.js +2 -2
- package/dist/es2019/utils/media-files.js +3 -5
- package/dist/esm/nodeviews/mediaInline.js +4 -2
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/toolbar/mediaInline.js +2 -2
- package/dist/esm/utils/is-type.js +2 -2
- package/dist/esm/utils/media-files.js +3 -5
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/utils/is-type.d.ts +1 -1
- package/dist/types/utils/media-files.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/utils/is-type.d.ts +1 -1
- package/dist/types-ts4.5/utils/media-files.d.ts +2 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.6.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#60029](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60029) [`b9826ea49c47`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b9826ea49c47) - Update dependencies that were impacted by HOT-106483 to latest.
|
|
8
|
+
|
|
9
|
+
## 0.6.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#59409](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59409) [`e37f95e368fd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e37f95e368fd) - Refactor code to use allowInlineImages plugin state instead of FF check
|
|
14
|
+
|
|
3
15
|
## 0.6.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -24,6 +24,7 @@ var _selectionBasedNodeView = require("@atlaskit/editor-common/selection-based-n
|
|
|
24
24
|
var _mediaCard = require("@atlaskit/media-card");
|
|
25
25
|
var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
26
26
|
var _mediaUi = require("@atlaskit/media-ui");
|
|
27
|
+
var _isType = require("../utils/is-type");
|
|
27
28
|
var _mediaNodeUpdater = require("./mediaNodeUpdater");
|
|
28
29
|
var _styles = require("./styles");
|
|
29
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -183,7 +184,8 @@ var MediaInline = exports.MediaInline = function MediaInline(props) {
|
|
|
183
184
|
isSelected: false
|
|
184
185
|
});
|
|
185
186
|
}
|
|
186
|
-
|
|
187
|
+
var allowInlineImages = props.mediaPluginState.allowInlineImages;
|
|
188
|
+
if (allowInlineImages && (0, _isType.isImage)(type)) {
|
|
187
189
|
return /*#__PURE__*/_react.default.createElement(_mediaInline.MediaInlineImageCard, {
|
|
188
190
|
mediaClient: (0, _mediaClientReact.getMediaClient)(viewMediaClientConfig),
|
|
189
191
|
identifier: identifier,
|
|
@@ -244,7 +244,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
244
244
|
}
|
|
245
245
|
switch ((0, _mediaInline.getMediaNodeInsertionType)(state, (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
246
246
|
case 'inline':
|
|
247
|
-
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
247
|
+
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.allowInlineImages, _this.getInputMethod(pickerType));
|
|
248
248
|
break;
|
|
249
249
|
case 'block':
|
|
250
250
|
// read width state right before inserting to get up-to-date and define values
|
|
@@ -8,12 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
exports.getMediaInlineImageToolbar = exports.generateMediaInlineFloatingToolbar = void 0;
|
|
9
9
|
var _react = _interopRequireDefault(require("react"));
|
|
10
10
|
var _card = require("@atlaskit/editor-common/card");
|
|
11
|
-
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
12
11
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
13
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
13
|
var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
|
|
15
14
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
16
15
|
var _mediaUi = require("@atlaskit/media-ui");
|
|
16
|
+
var _isType = require("../utils/is-type");
|
|
17
17
|
var _commands = require("./commands");
|
|
18
18
|
var _filePreviewItem = require("./filePreviewItem");
|
|
19
19
|
var _utils = require("./utils");
|
|
@@ -25,7 +25,7 @@ var generateMediaInlineFloatingToolbar = exports.generateMediaInlineFloatingTool
|
|
|
25
25
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
26
26
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
27
27
|
var mediaType = state.selection instanceof _state.NodeSelection && state.selection.node.attrs.type;
|
|
28
|
-
if ((0,
|
|
28
|
+
if (mediaPluginState.allowInlineImages && (0, _isType.isImage)(mediaType)) {
|
|
29
29
|
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, widthPluginState);
|
|
30
30
|
}
|
|
31
31
|
var items = [{
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isVideo = exports.isImage = void 0;
|
|
7
|
-
var isImage = exports.isImage = function isImage(
|
|
8
|
-
return !!
|
|
7
|
+
var isImage = exports.isImage = function isImage(type) {
|
|
8
|
+
return !!type && (type.indexOf('image/') > -1 || type.indexOf('video/') > -1 || type === 'image');
|
|
9
9
|
};
|
|
10
10
|
var isVideo = exports.isVideo = function isVideo(fileType) {
|
|
11
11
|
return !!fileType && fileType.includes('video/');
|
|
@@ -10,7 +10,6 @@ var _selection = require("@atlaskit/editor-common/selection");
|
|
|
10
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
11
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
13
|
var _isType = require("./is-type");
|
|
15
14
|
var _mediaCommon = require("./media-common");
|
|
16
15
|
var canInsertMediaInline = exports.canInsertMediaInline = function canInsertMediaInline(state) {
|
|
@@ -77,10 +76,11 @@ function shouldAppendParagraph(state, node) {
|
|
|
77
76
|
* Create a new media inline to insert the new media.
|
|
78
77
|
* @param view Editor view
|
|
79
78
|
* @param mediaState Media file to be added to the editor
|
|
79
|
+
* @param allowInlineImages Configuration for allowing adding of inline images
|
|
80
80
|
* @param collection Collection for the media to be added
|
|
81
81
|
*/
|
|
82
82
|
var insertMediaInlineNode = exports.insertMediaInlineNode = function insertMediaInlineNode(editorAnalyticsAPI) {
|
|
83
|
-
return function (view, mediaState, collection, inputMethod) {
|
|
83
|
+
return function (view, mediaState, collection, allowInlineImages, inputMethod) {
|
|
84
84
|
var state = view.state,
|
|
85
85
|
dispatch = view.dispatch;
|
|
86
86
|
var schema = state.schema,
|
|
@@ -99,9 +99,7 @@ var insertMediaInlineNode = exports.insertMediaInlineNode = function insertMedia
|
|
|
99
99
|
id: id,
|
|
100
100
|
collection: collection
|
|
101
101
|
};
|
|
102
|
-
if (
|
|
103
|
-
// TODO: replace it with new shouldShowInlineImage
|
|
104
|
-
(0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support') && (0, _isType.isImage)(mediaState.fileMimeType)) {
|
|
102
|
+
if (allowInlineImages && (0, _isType.isImage)(mediaState.fileMimeType)) {
|
|
105
103
|
var _ref = dimensions || {
|
|
106
104
|
width: undefined,
|
|
107
105
|
height: undefined
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
3
|
-
import { MediaInlineImageCard
|
|
3
|
+
import { MediaInlineImageCard } from '@atlaskit/editor-common/media-inline';
|
|
4
4
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
6
6
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
7
7
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
8
8
|
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
9
|
+
import { isImage } from '../utils/is-type';
|
|
9
10
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
10
11
|
import { MediaInlineNodeSelector } from './styles';
|
|
11
12
|
export const createMediaNodeUpdater = props => {
|
|
@@ -110,7 +111,10 @@ export const MediaInline = props => {
|
|
|
110
111
|
isSelected: false
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
+
const {
|
|
115
|
+
allowInlineImages
|
|
116
|
+
} = props.mediaPluginState;
|
|
117
|
+
if (allowInlineImages && isImage(type)) {
|
|
114
118
|
return /*#__PURE__*/React.createElement(MediaInlineImageCard, {
|
|
115
119
|
mediaClient: getMediaClient(viewMediaClientConfig),
|
|
116
120
|
identifier: identifier,
|
|
@@ -175,7 +175,7 @@ export class MediaPluginStateImplementation {
|
|
|
175
175
|
}
|
|
176
176
|
switch (getMediaNodeInsertionType(state, (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
177
177
|
case 'inline':
|
|
178
|
-
insertMediaInlineNode(editorAnalyticsAPI)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
178
|
+
insertMediaInlineNode(editorAnalyticsAPI)(this.view, mediaStateWithContext, collection, this.allowInlineImages, this.getInputMethod(pickerType));
|
|
179
179
|
break;
|
|
180
180
|
case 'block':
|
|
181
181
|
// read width state right before inserting to get up-to-date and define values
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconEmbed, IconInline } from '@atlaskit/editor-common/card';
|
|
3
|
-
import { shouldShowInlineImage } from '@atlaskit/editor-common/media-inline';
|
|
4
3
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
5
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
5
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
7
6
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
8
7
|
import { messages } from '@atlaskit/media-ui';
|
|
8
|
+
import { isImage } from '../utils/is-type';
|
|
9
9
|
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
|
|
10
10
|
import { FilePreviewItem } from './filePreviewItem';
|
|
11
11
|
import { downloadMedia } from './utils';
|
|
@@ -17,7 +17,7 @@ export const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState
|
|
|
17
17
|
mediaInline
|
|
18
18
|
} = state.schema.nodes;
|
|
19
19
|
const mediaType = state.selection instanceof NodeSelection && state.selection.node.attrs.type;
|
|
20
|
-
if (
|
|
20
|
+
if (mediaPluginState.allowInlineImages && isImage(mediaType)) {
|
|
21
21
|
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, widthPluginState);
|
|
22
22
|
}
|
|
23
23
|
const items = [{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const isImage =
|
|
2
|
-
return !!
|
|
1
|
+
export const isImage = type => {
|
|
2
|
+
return !!type && (type.indexOf('image/') > -1 || type.indexOf('video/') > -1 || type === 'image');
|
|
3
3
|
};
|
|
4
4
|
export const isVideo = fileType => {
|
|
5
5
|
return !!fileType && fileType.includes('video/');
|
|
@@ -4,7 +4,6 @@ import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfPar
|
|
|
4
4
|
import { findFarthestParentNode, insideTableCell, isInLayoutColumn, isInListItem, isSupportedInParent, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { isImage } from './is-type';
|
|
9
8
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
10
9
|
export const canInsertMediaInline = state => {
|
|
@@ -79,9 +78,10 @@ function shouldAppendParagraph(state, node) {
|
|
|
79
78
|
* Create a new media inline to insert the new media.
|
|
80
79
|
* @param view Editor view
|
|
81
80
|
* @param mediaState Media file to be added to the editor
|
|
81
|
+
* @param allowInlineImages Configuration for allowing adding of inline images
|
|
82
82
|
* @param collection Collection for the media to be added
|
|
83
83
|
*/
|
|
84
|
-
export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, collection, inputMethod) => {
|
|
84
|
+
export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, collection, allowInlineImages, inputMethod) => {
|
|
85
85
|
const {
|
|
86
86
|
state,
|
|
87
87
|
dispatch
|
|
@@ -107,9 +107,7 @@ export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, co
|
|
|
107
107
|
id,
|
|
108
108
|
collection
|
|
109
109
|
};
|
|
110
|
-
if (
|
|
111
|
-
// TODO: replace it with new shouldShowInlineImage
|
|
112
|
-
getBooleanFF('platform.editor.media.inline-image.base-support') && isImage(mediaState.fileMimeType)) {
|
|
110
|
+
if (allowInlineImages && isImage(mediaState.fileMimeType)) {
|
|
113
111
|
const {
|
|
114
112
|
width,
|
|
115
113
|
height
|
|
@@ -14,12 +14,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
14
14
|
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; }
|
|
15
15
|
import React, { useEffect, useState } from 'react';
|
|
16
16
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
17
|
-
import { MediaInlineImageCard
|
|
17
|
+
import { MediaInlineImageCard } from '@atlaskit/editor-common/media-inline';
|
|
18
18
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
19
19
|
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
20
20
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
21
21
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
22
22
|
import { MediaInlineCardLoadingView } from '@atlaskit/media-ui';
|
|
23
|
+
import { isImage } from '../utils/is-type';
|
|
23
24
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
24
25
|
import { MediaInlineNodeSelector } from './styles';
|
|
25
26
|
export var createMediaNodeUpdater = function createMediaNodeUpdater(props) {
|
|
@@ -173,7 +174,8 @@ export var MediaInline = function MediaInline(props) {
|
|
|
173
174
|
isSelected: false
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
|
-
|
|
177
|
+
var allowInlineImages = props.mediaPluginState.allowInlineImages;
|
|
178
|
+
if (allowInlineImages && isImage(type)) {
|
|
177
179
|
return /*#__PURE__*/React.createElement(MediaInlineImageCard, {
|
|
178
180
|
mediaClient: getMediaClient(viewMediaClientConfig),
|
|
179
181
|
identifier: identifier,
|
|
@@ -229,7 +229,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
229
229
|
}
|
|
230
230
|
switch (getMediaNodeInsertionType(state, (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
231
231
|
case 'inline':
|
|
232
|
-
insertMediaInlineNode(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
232
|
+
insertMediaInlineNode(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.allowInlineImages, _this.getInputMethod(pickerType));
|
|
233
233
|
break;
|
|
234
234
|
case 'block':
|
|
235
235
|
// read width state right before inserting to get up-to-date and define values
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IconEmbed, IconInline } from '@atlaskit/editor-common/card';
|
|
3
|
-
import { shouldShowInlineImage } from '@atlaskit/editor-common/media-inline';
|
|
4
3
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
5
4
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
5
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
7
6
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
8
7
|
import { messages } from '@atlaskit/media-ui';
|
|
8
|
+
import { isImage } from '../utils/is-type';
|
|
9
9
|
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
|
|
10
10
|
import { FilePreviewItem } from './filePreviewItem';
|
|
11
11
|
import { downloadMedia } from './utils';
|
|
@@ -15,7 +15,7 @@ export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloa
|
|
|
15
15
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
16
16
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
17
17
|
var mediaType = state.selection instanceof NodeSelection && state.selection.node.attrs.type;
|
|
18
|
-
if (
|
|
18
|
+
if (mediaPluginState.allowInlineImages && isImage(mediaType)) {
|
|
19
19
|
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI, widthPluginState);
|
|
20
20
|
}
|
|
21
21
|
var items = [{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export var isImage = function isImage(
|
|
2
|
-
return !!
|
|
1
|
+
export var isImage = function isImage(type) {
|
|
2
|
+
return !!type && (type.indexOf('image/') > -1 || type.indexOf('video/') > -1 || type === 'image');
|
|
3
3
|
};
|
|
4
4
|
export var isVideo = function isVideo(fileType) {
|
|
5
5
|
return !!fileType && fileType.includes('video/');
|
|
@@ -4,7 +4,6 @@ import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfPar
|
|
|
4
4
|
import { findFarthestParentNode, insideTableCell, isInLayoutColumn, isInListItem, isSupportedInParent, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { isImage } from './is-type';
|
|
9
8
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
10
9
|
export var canInsertMediaInline = function canInsertMediaInline(state) {
|
|
@@ -71,10 +70,11 @@ function shouldAppendParagraph(state, node) {
|
|
|
71
70
|
* Create a new media inline to insert the new media.
|
|
72
71
|
* @param view Editor view
|
|
73
72
|
* @param mediaState Media file to be added to the editor
|
|
73
|
+
* @param allowInlineImages Configuration for allowing adding of inline images
|
|
74
74
|
* @param collection Collection for the media to be added
|
|
75
75
|
*/
|
|
76
76
|
export var insertMediaInlineNode = function insertMediaInlineNode(editorAnalyticsAPI) {
|
|
77
|
-
return function (view, mediaState, collection, inputMethod) {
|
|
77
|
+
return function (view, mediaState, collection, allowInlineImages, inputMethod) {
|
|
78
78
|
var state = view.state,
|
|
79
79
|
dispatch = view.dispatch;
|
|
80
80
|
var schema = state.schema,
|
|
@@ -93,9 +93,7 @@ export var insertMediaInlineNode = function insertMediaInlineNode(editorAnalytic
|
|
|
93
93
|
id: id,
|
|
94
94
|
collection: collection
|
|
95
95
|
};
|
|
96
|
-
if (
|
|
97
|
-
// TODO: replace it with new shouldShowInlineImage
|
|
98
|
-
getBooleanFF('platform.editor.media.inline-image.base-support') && isImage(mediaState.fileMimeType)) {
|
|
96
|
+
if (allowInlineImages && isImage(mediaState.fileMimeType)) {
|
|
99
97
|
var _ref = dimensions || {
|
|
100
98
|
width: undefined,
|
|
101
99
|
height: undefined
|
|
@@ -34,6 +34,7 @@ export interface MediaPluginState {
|
|
|
34
34
|
isResizing: boolean;
|
|
35
35
|
resizingWidth: number;
|
|
36
36
|
currentMaxWidth?: number;
|
|
37
|
+
allowInlineImages?: boolean;
|
|
37
38
|
dispatch?: Dispatch;
|
|
38
39
|
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
39
40
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const isImage: (
|
|
1
|
+
export declare const isImage: (type?: string) => boolean;
|
|
2
2
|
export declare const isVideo: (fileType?: string) => boolean;
|
|
@@ -11,9 +11,10 @@ export declare const canInsertMediaInline: (state: EditorState) => boolean;
|
|
|
11
11
|
* Create a new media inline to insert the new media.
|
|
12
12
|
* @param view Editor view
|
|
13
13
|
* @param mediaState Media file to be added to the editor
|
|
14
|
+
* @param allowInlineImages Configuration for allowing adding of inline images
|
|
14
15
|
* @param collection Collection for the media to be added
|
|
15
16
|
*/
|
|
16
|
-
export declare const insertMediaInlineNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, mediaState: MediaState, collection: string, inputMethod?: InputMethodInsertMedia) => boolean;
|
|
17
|
+
export declare const insertMediaInlineNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, mediaState: MediaState, collection: string, allowInlineImages: boolean, inputMethod?: InputMethodInsertMedia) => boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Insert a media into an existing media group
|
|
19
20
|
* or create a new media group to insert the new media.
|
|
@@ -34,6 +34,7 @@ export interface MediaPluginState {
|
|
|
34
34
|
isResizing: boolean;
|
|
35
35
|
resizingWidth: number;
|
|
36
36
|
currentMaxWidth?: number;
|
|
37
|
+
allowInlineImages?: boolean;
|
|
37
38
|
dispatch?: Dispatch;
|
|
38
39
|
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
39
40
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const isImage: (
|
|
1
|
+
export declare const isImage: (type?: string) => boolean;
|
|
2
2
|
export declare const isVideo: (fileType?: string) => boolean;
|
|
@@ -11,9 +11,10 @@ export declare const canInsertMediaInline: (state: EditorState) => boolean;
|
|
|
11
11
|
* Create a new media inline to insert the new media.
|
|
12
12
|
* @param view Editor view
|
|
13
13
|
* @param mediaState Media file to be added to the editor
|
|
14
|
+
* @param allowInlineImages Configuration for allowing adding of inline images
|
|
14
15
|
* @param collection Collection for the media to be added
|
|
15
16
|
*/
|
|
16
|
-
export declare const insertMediaInlineNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, mediaState: MediaState, collection: string, inputMethod?: InputMethodInsertMedia) => boolean;
|
|
17
|
+
export declare const insertMediaInlineNode: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (view: EditorView, mediaState: MediaState, collection: string, allowInlineImages: boolean, inputMethod?: InputMethodInsertMedia) => boolean;
|
|
17
18
|
/**
|
|
18
19
|
* Insert a media into an existing media group
|
|
19
20
|
* or create a new media group to insert the new media.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
52
52
|
"@atlaskit/editor-shared-styles": "^2.6.0",
|
|
53
53
|
"@atlaskit/editor-tables": "^2.3.0",
|
|
54
|
-
"@atlaskit/form": "^9.0.
|
|
54
|
+
"@atlaskit/form": "^9.0.3",
|
|
55
55
|
"@atlaskit/icon": "^22.0.0",
|
|
56
56
|
"@atlaskit/media-card": "^77.5.0",
|
|
57
57
|
"@atlaskit/media-client": "^25.1.0",
|