@atlaskit/editor-plugin-media 8.9.0 → 9.0.0
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 +18 -0
- package/dist/cjs/mediaPlugin.js +44 -77
- package/dist/cjs/pm-plugins/commands.js +1 -23
- package/dist/cjs/pm-plugins/main.js +0 -16
- package/dist/cjs/ui/toolbar/index.js +3 -2
- package/dist/es2019/mediaPlugin.js +4 -39
- package/dist/es2019/pm-plugins/commands.js +0 -22
- package/dist/es2019/pm-plugins/main.js +0 -14
- package/dist/es2019/ui/toolbar/index.js +3 -2
- package/dist/esm/mediaPlugin.js +45 -78
- package/dist/esm/pm-plugins/commands.js +0 -22
- package/dist/esm/pm-plugins/main.js +0 -16
- package/dist/esm/ui/toolbar/index.js +3 -2
- package/dist/types/mediaPluginType.d.ts +3 -3
- package/dist/types/pm-plugins/commands.d.ts +0 -2
- package/dist/types/pm-plugins/main.d.ts +1 -4
- package/dist/types/pm-plugins/types.d.ts +0 -3
- package/dist/types-ts4.5/mediaPluginType.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +0 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -4
- package/dist/types-ts4.5/pm-plugins/types.d.ts +0 -3
- package/package.json +17 -18
- package/dist/cjs/ui/ImageEditor/ModalWrapper.js +0 -69
- package/dist/cjs/ui/ImageEditor/index.js +0 -62
- package/dist/es2019/ui/ImageEditor/ModalWrapper.js +0 -58
- package/dist/es2019/ui/ImageEditor/index.js +0 -53
- package/dist/esm/ui/ImageEditor/ModalWrapper.js +0 -60
- package/dist/esm/ui/ImageEditor/index.js +0 -52
- package/dist/types/ui/ImageEditor/ModalWrapper.d.ts +0 -13
- package/dist/types/ui/ImageEditor/index.d.ts +0 -12
- package/dist/types-ts4.5/ui/ImageEditor/ModalWrapper.d.ts +0 -13
- package/dist/types-ts4.5/ui/ImageEditor/index.d.ts +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 9.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 8.10.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`3323827ca91e6`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/3323827ca91e6) -
|
|
14
|
+
[ux] EDITOR-4139 Refactor existing image editing functionality into its own plugin
|
|
15
|
+
editor-plugin-media-editing
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 8.9.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/dist/cjs/mediaPlugin.js
CHANGED
|
@@ -14,7 +14,6 @@ var _toolbarFlagCheck = require("@atlaskit/editor-common/toolbar-flag-check");
|
|
|
14
14
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
15
15
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
16
16
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
17
|
-
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
18
17
|
var _lazyMedia = require("./nodeviews/lazy-media");
|
|
19
18
|
var _lazyMediaGroup = require("./nodeviews/lazy-media-group");
|
|
20
19
|
var _lazyMediaInline = require("./nodeviews/lazy-media-inline");
|
|
@@ -35,7 +34,6 @@ var _pixelResizing = require("./pm-plugins/pixel-resizing");
|
|
|
35
34
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
36
35
|
var _mediaCommon2 = require("./pm-plugins/utils/media-common");
|
|
37
36
|
var _mediaSingle2 = require("./pm-plugins/utils/media-single");
|
|
38
|
-
var _ModalWrapper = require("./ui/ImageEditor/ModalWrapper");
|
|
39
37
|
var _MediaPicker = require("./ui/MediaPicker");
|
|
40
38
|
var _PortalWrapper = require("./ui/MediaViewer/PortalWrapper");
|
|
41
39
|
var _toolbar = require("./ui/toolbar");
|
|
@@ -106,36 +104,10 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
|
|
|
106
104
|
items: mediaItems
|
|
107
105
|
});
|
|
108
106
|
};
|
|
109
|
-
var
|
|
110
|
-
var
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
imageEditorSelectedMedia: (_states$mediaState7 = states.mediaState) === null || _states$mediaState7 === void 0 ? void 0 : _states$mediaState7.imageEditorSelectedMedia,
|
|
114
|
-
mediaClientConfig: (_states$mediaState8 = states.mediaState) === null || _states$mediaState8 === void 0 ? void 0 : _states$mediaState8.mediaClientConfig
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
var ImageEditorFunctionalComponent = function ImageEditorFunctionalComponent(_ref3) {
|
|
118
|
-
var api = _ref3.api;
|
|
119
|
-
var _useSharedPluginState3 = (0, _hooks.useSharedPluginStateWithSelector)(api, ['media'], imageEditorStateSelector),
|
|
120
|
-
isImageEditorVisible = _useSharedPluginState3.isImageEditorVisible,
|
|
121
|
-
imageEditorSelectedMedia = _useSharedPluginState3.imageEditorSelectedMedia,
|
|
122
|
-
mediaClientConfig = _useSharedPluginState3.mediaClientConfig;
|
|
123
|
-
if (!isImageEditorVisible || !imageEditorSelectedMedia || !mediaClientConfig) {
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
var handleOnClose = function handleOnClose() {
|
|
127
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.hideImageEditor);
|
|
128
|
-
};
|
|
129
|
-
return /*#__PURE__*/_react.default.createElement(_ModalWrapper.RenderImageEditor, {
|
|
130
|
-
mediaClientConfig: mediaClientConfig,
|
|
131
|
-
onClose: handleOnClose,
|
|
132
|
-
selectedNodeAttrs: imageEditorSelectedMedia
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
136
|
-
var _ref4$config = _ref4.config,
|
|
137
|
-
options = _ref4$config === void 0 ? {} : _ref4$config,
|
|
138
|
-
api = _ref4.api;
|
|
107
|
+
var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
108
|
+
var _ref3$config = _ref3.config,
|
|
109
|
+
options = _ref3$config === void 0 ? {} : _ref3$config,
|
|
110
|
+
api = _ref3.api;
|
|
139
111
|
var previousMediaProvider;
|
|
140
112
|
var mediaErrorLocalIds = new Set();
|
|
141
113
|
return {
|
|
@@ -176,8 +148,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
176
148
|
return false;
|
|
177
149
|
}
|
|
178
150
|
previousMediaProvider = provider;
|
|
179
|
-
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
180
|
-
var tr =
|
|
151
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref4) {
|
|
152
|
+
var tr = _ref4.tr;
|
|
181
153
|
return tr.setMeta(_pluginKey.stateKey, {
|
|
182
154
|
mediaProvider: provider
|
|
183
155
|
});
|
|
@@ -187,21 +159,19 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
187
159
|
commands: {
|
|
188
160
|
showMediaViewer: _commands.showMediaViewer,
|
|
189
161
|
hideMediaViewer: _commands.hideMediaViewer,
|
|
190
|
-
trackMediaPaste: _commands.trackMediaPaste
|
|
191
|
-
showImageEditor: _commands.showImageEditor,
|
|
192
|
-
hideImageEditor: _commands.hideImageEditor
|
|
162
|
+
trackMediaPaste: _commands.trackMediaPaste
|
|
193
163
|
},
|
|
194
164
|
nodes: function nodes() {
|
|
195
|
-
var
|
|
196
|
-
|
|
197
|
-
allowMediaGroup =
|
|
198
|
-
|
|
199
|
-
allowMediaSingle =
|
|
200
|
-
|
|
201
|
-
allowPixelResizing =
|
|
202
|
-
allowCaptions =
|
|
203
|
-
allowMediaInlineImages =
|
|
204
|
-
mediaFeatureFlags =
|
|
165
|
+
var _ref5 = options || {},
|
|
166
|
+
_ref5$allowMediaGroup = _ref5.allowMediaGroup,
|
|
167
|
+
allowMediaGroup = _ref5$allowMediaGroup === void 0 ? true : _ref5$allowMediaGroup,
|
|
168
|
+
_ref5$allowMediaSingl = _ref5.allowMediaSingle,
|
|
169
|
+
allowMediaSingle = _ref5$allowMediaSingl === void 0 ? false : _ref5$allowMediaSingl,
|
|
170
|
+
_ref5$allowPixelResiz = _ref5.allowPixelResizing,
|
|
171
|
+
allowPixelResizing = _ref5$allowPixelResiz === void 0 ? false : _ref5$allowPixelResiz,
|
|
172
|
+
allowCaptions = _ref5.allowCaptions,
|
|
173
|
+
allowMediaInlineImages = _ref5.allowMediaInlineImages,
|
|
174
|
+
mediaFeatureFlags = _ref5.featureFlags;
|
|
205
175
|
var allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
|
|
206
176
|
var mediaSingleOption = {
|
|
207
177
|
withCaption: allowCaptions,
|
|
@@ -235,16 +205,16 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
235
205
|
pmPlugins: function pmPlugins() {
|
|
236
206
|
var pmPlugins = [{
|
|
237
207
|
name: 'media',
|
|
238
|
-
plugin: function plugin(
|
|
239
|
-
var schema =
|
|
240
|
-
dispatch =
|
|
241
|
-
getIntl =
|
|
242
|
-
eventDispatcher =
|
|
243
|
-
providerFactory =
|
|
244
|
-
errorReporter =
|
|
245
|
-
portalProviderAPI =
|
|
246
|
-
dispatchAnalyticsEvent =
|
|
247
|
-
nodeViewPortalProviderAPI =
|
|
208
|
+
plugin: function plugin(_ref6) {
|
|
209
|
+
var schema = _ref6.schema,
|
|
210
|
+
dispatch = _ref6.dispatch,
|
|
211
|
+
getIntl = _ref6.getIntl,
|
|
212
|
+
eventDispatcher = _ref6.eventDispatcher,
|
|
213
|
+
providerFactory = _ref6.providerFactory,
|
|
214
|
+
errorReporter = _ref6.errorReporter,
|
|
215
|
+
portalProviderAPI = _ref6.portalProviderAPI,
|
|
216
|
+
dispatchAnalyticsEvent = _ref6.dispatchAnalyticsEvent,
|
|
217
|
+
nodeViewPortalProviderAPI = _ref6.nodeViewPortalProviderAPI;
|
|
248
218
|
return (0, _main.createPlugin)(schema, {
|
|
249
219
|
providerFactory: providerFactory,
|
|
250
220
|
nodeViews: {
|
|
@@ -263,17 +233,17 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
263
233
|
}
|
|
264
234
|
}, {
|
|
265
235
|
name: 'mediaKeymap',
|
|
266
|
-
plugin: function plugin(
|
|
236
|
+
plugin: function plugin(_ref7) {
|
|
267
237
|
var _api$analytics3, _api$selection;
|
|
268
|
-
var getIntl =
|
|
238
|
+
var getIntl = _ref7.getIntl;
|
|
269
239
|
return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions, api === null || api === void 0 || (_api$selection = api.selection) === null || _api$selection === void 0 ? void 0 : _api$selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
|
|
270
240
|
}
|
|
271
241
|
}];
|
|
272
242
|
if (options && options.allowMediaSingle) {
|
|
273
243
|
pmPlugins.push({
|
|
274
244
|
name: 'mediaSingleKeymap',
|
|
275
|
-
plugin: function plugin(
|
|
276
|
-
var schema =
|
|
245
|
+
plugin: function plugin(_ref8) {
|
|
246
|
+
var schema = _ref8.schema;
|
|
277
247
|
return (0, _keymapMedia.default)(schema);
|
|
278
248
|
}
|
|
279
249
|
});
|
|
@@ -285,9 +255,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
285
255
|
});
|
|
286
256
|
pmPlugins.push({
|
|
287
257
|
name: 'mediaAltTextKeymap',
|
|
288
|
-
plugin: function plugin(
|
|
258
|
+
plugin: function plugin(_ref9) {
|
|
289
259
|
var _api$analytics4;
|
|
290
|
-
var schema =
|
|
260
|
+
var schema = _ref9.schema;
|
|
291
261
|
return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
292
262
|
}
|
|
293
263
|
});
|
|
@@ -295,15 +265,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
295
265
|
if (options && options.allowLinking) {
|
|
296
266
|
pmPlugins.push({
|
|
297
267
|
name: 'mediaLinking',
|
|
298
|
-
plugin: function plugin(
|
|
299
|
-
var dispatch =
|
|
268
|
+
plugin: function plugin(_ref0) {
|
|
269
|
+
var dispatch = _ref0.dispatch;
|
|
300
270
|
return (0, _linking.default)(dispatch);
|
|
301
271
|
}
|
|
302
272
|
});
|
|
303
273
|
pmPlugins.push({
|
|
304
274
|
name: 'mediaLinkingKeymap',
|
|
305
|
-
plugin: function plugin(
|
|
306
|
-
var schema =
|
|
275
|
+
plugin: function plugin(_ref1) {
|
|
276
|
+
var schema = _ref1.schema;
|
|
307
277
|
return (0, _keymap3.default)(schema);
|
|
308
278
|
}
|
|
309
279
|
});
|
|
@@ -345,16 +315,13 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
345
315
|
});
|
|
346
316
|
return pmPlugins;
|
|
347
317
|
},
|
|
348
|
-
contentComponent: function contentComponent(
|
|
349
|
-
var editorView =
|
|
350
|
-
appearance =
|
|
318
|
+
contentComponent: function contentComponent(_ref10) {
|
|
319
|
+
var editorView = _ref10.editorView,
|
|
320
|
+
appearance = _ref10.appearance;
|
|
351
321
|
if (!editorView) {
|
|
352
322
|
return null;
|
|
353
323
|
}
|
|
354
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null,
|
|
355
|
-
api: api,
|
|
356
|
-
editorView: editorView
|
|
357
|
-
}), /*#__PURE__*/_react.default.createElement(MediaViewerFunctionalComponent, {
|
|
324
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(MediaViewerFunctionalComponent, {
|
|
358
325
|
api: api,
|
|
359
326
|
editorView: editorView
|
|
360
327
|
}), /*#__PURE__*/_react.default.createElement(MediaPickerFunctionalComponent, {
|
|
@@ -363,8 +330,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
363
330
|
api: api
|
|
364
331
|
}));
|
|
365
332
|
},
|
|
366
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
367
|
-
var disabled =
|
|
333
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
|
|
334
|
+
var disabled = _ref11.disabled;
|
|
368
335
|
return /*#__PURE__*/_react.default.createElement(_ToolbarMedia.default, {
|
|
369
336
|
isDisabled: disabled,
|
|
370
337
|
isReducedSpacing: true,
|
|
@@ -386,7 +353,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref4) {
|
|
|
386
353
|
allowLinking: options && options.allowLinking,
|
|
387
354
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
388
355
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
389
|
-
allowImageEditing: options && options.allowImageEditing,
|
|
356
|
+
allowImageEditing: !!(api !== null && api !== void 0 && api.mediaEditing) && options && options.allowImageEditing,
|
|
390
357
|
allowImagePreview: options && options.allowImagePreview,
|
|
391
358
|
altTextValidator: options && options.altTextValidator,
|
|
392
359
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.trackMediaPaste = exports.showMediaViewer = exports.
|
|
6
|
+
exports.trackMediaPaste = exports.showMediaViewer = exports.hideMediaViewer = void 0;
|
|
7
7
|
var _actions = require("../pm-plugins/actions");
|
|
8
8
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
9
9
|
var _mediaCommon = require("../pm-plugins/utils/media-common");
|
|
@@ -37,26 +37,4 @@ var trackMediaPaste = exports.trackMediaPaste = function trackMediaPaste(attrs)
|
|
|
37
37
|
});
|
|
38
38
|
return tr;
|
|
39
39
|
};
|
|
40
|
-
};
|
|
41
|
-
var showImageEditor = exports.showImageEditor = function showImageEditor(media) {
|
|
42
|
-
return function (_ref4) {
|
|
43
|
-
var tr = _ref4.tr;
|
|
44
|
-
tr.setMeta(_pluginKey.stateKey, {
|
|
45
|
-
type: _actions.ACTIONS.SHOW_IMAGE_EDITOR,
|
|
46
|
-
imageEditorSelectedMedia: media,
|
|
47
|
-
isImageEditorVisible: true
|
|
48
|
-
});
|
|
49
|
-
tr.setMeta('addToHistory', false);
|
|
50
|
-
return tr;
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
var hideImageEditor = exports.hideImageEditor = function hideImageEditor(_ref5) {
|
|
54
|
-
var tr = _ref5.tr;
|
|
55
|
-
tr.setMeta(_pluginKey.stateKey, {
|
|
56
|
-
type: _actions.ACTIONS.HIDE_IMAGE_EDITOR,
|
|
57
|
-
imageEditorSelectedMedia: null,
|
|
58
|
-
isImageEditorVisible: false
|
|
59
|
-
});
|
|
60
|
-
tr.setMeta('addToHistory', false);
|
|
61
|
-
return tr;
|
|
62
40
|
};
|
|
@@ -90,7 +90,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
90
90
|
(0, _defineProperty2.default)(this, "allowInlineImages", false);
|
|
91
91
|
(0, _defineProperty2.default)(this, "uploadInProgressSubscriptions", []);
|
|
92
92
|
(0, _defineProperty2.default)(this, "uploadInProgressSubscriptionsNotified", false);
|
|
93
|
-
(0, _defineProperty2.default)(this, "isImageEditorVisible", false);
|
|
94
93
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
95
94
|
(0, _defineProperty2.default)(this, "lastAddedMediaSingleFileIds", []);
|
|
96
95
|
(0, _defineProperty2.default)(this, "destroyed", false);
|
|
@@ -638,11 +637,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
638
637
|
value: function setResizingWidth(width) {
|
|
639
638
|
this.resizingWidth = width;
|
|
640
639
|
}
|
|
641
|
-
}, {
|
|
642
|
-
key: "setImageEditorVisibility",
|
|
643
|
-
value: function setImageEditorVisibility(isVisible) {
|
|
644
|
-
this.isImageEditorVisible = isVisible;
|
|
645
|
-
}
|
|
646
640
|
}, {
|
|
647
641
|
key: "updateElement",
|
|
648
642
|
value: function updateElement() {
|
|
@@ -884,16 +878,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
884
878
|
nextPluginState = pluginState.clone();
|
|
885
879
|
}
|
|
886
880
|
break;
|
|
887
|
-
case _actions.ACTIONS.SHOW_IMAGE_EDITOR:
|
|
888
|
-
pluginState.imageEditorSelectedMedia = meta.imageEditorSelectedMedia;
|
|
889
|
-
pluginState.isImageEditorVisible = meta.isImageEditorVisible;
|
|
890
|
-
nextPluginState = nextPluginState.clone();
|
|
891
|
-
break;
|
|
892
|
-
case _actions.ACTIONS.HIDE_IMAGE_EDITOR:
|
|
893
|
-
pluginState.imageEditorSelectedMedia = undefined;
|
|
894
|
-
pluginState.isImageEditorVisible = meta.isImageEditorVisible;
|
|
895
|
-
nextPluginState = nextPluginState.clone();
|
|
896
|
-
break;
|
|
897
881
|
}
|
|
898
882
|
|
|
899
883
|
// NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
|
|
@@ -123,13 +123,14 @@ var handleShowMediaViewer = exports.handleShowMediaViewer = function handleShowM
|
|
|
123
123
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
|
|
124
124
|
};
|
|
125
125
|
var handleShowImageEditor = exports.handleShowImageEditor = function handleShowImageEditor(_ref2) {
|
|
126
|
+
var _api$mediaEditing;
|
|
126
127
|
var api = _ref2.api,
|
|
127
128
|
mediaPluginState = _ref2.mediaPluginState;
|
|
128
129
|
var selectedNodeAttrs = (0, _utils2.getSelectedNearestMediaContainerNodeAttrs)(mediaPluginState);
|
|
129
130
|
if (!selectedNodeAttrs) {
|
|
130
131
|
return false;
|
|
131
132
|
}
|
|
132
|
-
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 :
|
|
133
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 || (_api$mediaEditing = api.mediaEditing) === null || _api$mediaEditing === void 0 ? void 0 : _api$mediaEditing.commands.showImageEditor(selectedNodeAttrs));
|
|
133
134
|
};
|
|
134
135
|
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
|
|
135
136
|
var _pluginInjectionApi$c;
|
|
@@ -563,7 +564,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
563
564
|
});
|
|
564
565
|
}
|
|
565
566
|
// Image Editing Support
|
|
566
|
-
if (allowImageEditing && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true)) {
|
|
567
|
+
if (!!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.mediaEditing) && allowImageEditing && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true)) {
|
|
567
568
|
var _mediaNode$attrs;
|
|
568
569
|
var _selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
569
570
|
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
@@ -6,7 +6,6 @@ import { areToolbarFlagsEnabled } from '@atlaskit/editor-common/toolbar-flag-che
|
|
|
6
6
|
import { NodeSelection, PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
8
8
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
|
-
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
10
9
|
import { lazyMediaView } from './nodeviews/lazy-media';
|
|
11
10
|
import { lazyMediaGroupView } from './nodeviews/lazy-media-group';
|
|
12
11
|
import { lazyMediaInlineView } from './nodeviews/lazy-media-inline';
|
|
@@ -17,7 +16,7 @@ import { mediaInlineSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaInli
|
|
|
17
16
|
import { mediaSingleSpecWithFixedToDOM } from './nodeviews/toDOM-fixes/mediaSingle';
|
|
18
17
|
import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
|
|
19
18
|
import keymapMediaAltTextPlugin from './pm-plugins/alt-text/keymap';
|
|
20
|
-
import { hideMediaViewer, showMediaViewer, trackMediaPaste
|
|
19
|
+
import { hideMediaViewer, showMediaViewer, trackMediaPaste } from './pm-plugins/commands';
|
|
21
20
|
import keymapPlugin from './pm-plugins/keymap';
|
|
22
21
|
import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
|
|
23
22
|
import linkingPlugin from './pm-plugins/linking';
|
|
@@ -27,7 +26,6 @@ import { createPlugin as createMediaPixelResizingPlugin } from './pm-plugins/pix
|
|
|
27
26
|
import { stateKey } from './pm-plugins/plugin-key';
|
|
28
27
|
import { createMediaIdentifierArray, extractMediaNodes } from './pm-plugins/utils/media-common';
|
|
29
28
|
import { insertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
|
|
30
|
-
import { RenderImageEditor } from './ui/ImageEditor/ModalWrapper';
|
|
31
29
|
import { MediaPickerComponents } from './ui/MediaPicker';
|
|
32
30
|
import { RenderMediaViewer } from './ui/MediaViewer/PortalWrapper';
|
|
33
31
|
import { floatingToolbar } from './ui/toolbar';
|
|
@@ -101,34 +99,6 @@ const MediaViewerFunctionalComponent = ({
|
|
|
101
99
|
items: mediaItems
|
|
102
100
|
});
|
|
103
101
|
};
|
|
104
|
-
const imageEditorStateSelector = states => {
|
|
105
|
-
var _states$mediaState6, _states$mediaState7, _states$mediaState8;
|
|
106
|
-
return {
|
|
107
|
-
isImageEditorVisible: (_states$mediaState6 = states.mediaState) === null || _states$mediaState6 === void 0 ? void 0 : _states$mediaState6.isImageEditorVisible,
|
|
108
|
-
imageEditorSelectedMedia: (_states$mediaState7 = states.mediaState) === null || _states$mediaState7 === void 0 ? void 0 : _states$mediaState7.imageEditorSelectedMedia,
|
|
109
|
-
mediaClientConfig: (_states$mediaState8 = states.mediaState) === null || _states$mediaState8 === void 0 ? void 0 : _states$mediaState8.mediaClientConfig
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const ImageEditorFunctionalComponent = ({
|
|
113
|
-
api
|
|
114
|
-
}) => {
|
|
115
|
-
const {
|
|
116
|
-
isImageEditorVisible,
|
|
117
|
-
imageEditorSelectedMedia,
|
|
118
|
-
mediaClientConfig
|
|
119
|
-
} = useSharedPluginStateWithSelector(api, ['media'], imageEditorStateSelector);
|
|
120
|
-
if (!isImageEditorVisible || !imageEditorSelectedMedia || !mediaClientConfig) {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
const handleOnClose = () => {
|
|
124
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.hideImageEditor);
|
|
125
|
-
};
|
|
126
|
-
return /*#__PURE__*/React.createElement(RenderImageEditor, {
|
|
127
|
-
mediaClientConfig: mediaClientConfig,
|
|
128
|
-
onClose: handleOnClose,
|
|
129
|
-
selectedNodeAttrs: imageEditorSelectedMedia
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
102
|
export const mediaPlugin = ({
|
|
133
103
|
config: options = {},
|
|
134
104
|
api
|
|
@@ -183,9 +153,7 @@ export const mediaPlugin = ({
|
|
|
183
153
|
commands: {
|
|
184
154
|
showMediaViewer,
|
|
185
155
|
hideMediaViewer,
|
|
186
|
-
trackMediaPaste
|
|
187
|
-
showImageEditor,
|
|
188
|
-
hideImageEditor
|
|
156
|
+
trackMediaPaste
|
|
189
157
|
},
|
|
190
158
|
nodes() {
|
|
191
159
|
const {
|
|
@@ -351,10 +319,7 @@ export const mediaPlugin = ({
|
|
|
351
319
|
if (!editorView) {
|
|
352
320
|
return null;
|
|
353
321
|
}
|
|
354
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null,
|
|
355
|
-
api: api,
|
|
356
|
-
editorView: editorView
|
|
357
|
-
}), /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
|
|
322
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(MediaViewerFunctionalComponent, {
|
|
358
323
|
api: api,
|
|
359
324
|
editorView: editorView
|
|
360
325
|
}), /*#__PURE__*/React.createElement(MediaPickerFunctionalComponent, {
|
|
@@ -385,7 +350,7 @@ export const mediaPlugin = ({
|
|
|
385
350
|
allowLinking: options && options.allowLinking,
|
|
386
351
|
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
387
352
|
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
388
|
-
allowImageEditing: options && options.allowImageEditing,
|
|
353
|
+
allowImageEditing: !!(api !== null && api !== void 0 && api.mediaEditing) && options && options.allowImageEditing,
|
|
389
354
|
allowImagePreview: options && options.allowImagePreview,
|
|
390
355
|
altTextValidator: options && options.altTextValidator,
|
|
391
356
|
fullWidthEnabled: options && options.fullWidthEnabled,
|
|
@@ -30,26 +30,4 @@ export const trackMediaPaste = attrs => ({
|
|
|
30
30
|
identifier
|
|
31
31
|
});
|
|
32
32
|
return tr;
|
|
33
|
-
};
|
|
34
|
-
export const showImageEditor = media => ({
|
|
35
|
-
tr
|
|
36
|
-
}) => {
|
|
37
|
-
tr.setMeta(stateKey, {
|
|
38
|
-
type: ACTIONS.SHOW_IMAGE_EDITOR,
|
|
39
|
-
imageEditorSelectedMedia: media,
|
|
40
|
-
isImageEditorVisible: true
|
|
41
|
-
});
|
|
42
|
-
tr.setMeta('addToHistory', false);
|
|
43
|
-
return tr;
|
|
44
|
-
};
|
|
45
|
-
export const hideImageEditor = ({
|
|
46
|
-
tr
|
|
47
|
-
}) => {
|
|
48
|
-
tr.setMeta(stateKey, {
|
|
49
|
-
type: ACTIONS.HIDE_IMAGE_EDITOR,
|
|
50
|
-
imageEditorSelectedMedia: null,
|
|
51
|
-
isImageEditorVisible: false
|
|
52
|
-
});
|
|
53
|
-
tr.setMeta('addToHistory', false);
|
|
54
|
-
return tr;
|
|
55
33
|
};
|
|
@@ -67,7 +67,6 @@ export class MediaPluginStateImplementation {
|
|
|
67
67
|
_defineProperty(this, "allowInlineImages", false);
|
|
68
68
|
_defineProperty(this, "uploadInProgressSubscriptions", []);
|
|
69
69
|
_defineProperty(this, "uploadInProgressSubscriptionsNotified", false);
|
|
70
|
-
_defineProperty(this, "isImageEditorVisible", false);
|
|
71
70
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
72
71
|
_defineProperty(this, "lastAddedMediaSingleFileIds", []);
|
|
73
72
|
_defineProperty(this, "destroyed", false);
|
|
@@ -569,9 +568,6 @@ export class MediaPluginStateImplementation {
|
|
|
569
568
|
setResizingWidth(width) {
|
|
570
569
|
this.resizingWidth = width;
|
|
571
570
|
}
|
|
572
|
-
setImageEditorVisibility(isVisible) {
|
|
573
|
-
this.isImageEditorVisible = isVisible;
|
|
574
|
-
}
|
|
575
571
|
updateElement() {
|
|
576
572
|
let newElement;
|
|
577
573
|
const selectedContainer = this.selectedMediaContainerNode();
|
|
@@ -775,16 +771,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
775
771
|
nextPluginState = pluginState.clone();
|
|
776
772
|
}
|
|
777
773
|
break;
|
|
778
|
-
case ACTIONS.SHOW_IMAGE_EDITOR:
|
|
779
|
-
pluginState.imageEditorSelectedMedia = meta.imageEditorSelectedMedia;
|
|
780
|
-
pluginState.isImageEditorVisible = meta.isImageEditorVisible;
|
|
781
|
-
nextPluginState = nextPluginState.clone();
|
|
782
|
-
break;
|
|
783
|
-
case ACTIONS.HIDE_IMAGE_EDITOR:
|
|
784
|
-
pluginState.imageEditorSelectedMedia = undefined;
|
|
785
|
-
pluginState.isImageEditorVisible = meta.isImageEditorVisible;
|
|
786
|
-
nextPluginState = nextPluginState.clone();
|
|
787
|
-
break;
|
|
788
774
|
}
|
|
789
775
|
|
|
790
776
|
// NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
|
|
@@ -114,11 +114,12 @@ export const handleShowImageEditor = ({
|
|
|
114
114
|
api,
|
|
115
115
|
mediaPluginState
|
|
116
116
|
}) => {
|
|
117
|
+
var _api$mediaEditing;
|
|
117
118
|
const selectedNodeAttrs = getSelectedNearestMediaContainerNodeAttrs(mediaPluginState);
|
|
118
119
|
if (!selectedNodeAttrs) {
|
|
119
120
|
return false;
|
|
120
121
|
}
|
|
121
|
-
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.
|
|
122
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : (_api$mediaEditing = api.mediaEditing) === null || _api$mediaEditing === void 0 ? void 0 : _api$mediaEditing.commands.showImageEditor(selectedNodeAttrs));
|
|
122
123
|
};
|
|
123
124
|
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) => {
|
|
124
125
|
var _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3;
|
|
@@ -562,7 +563,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
562
563
|
});
|
|
563
564
|
}
|
|
564
565
|
// Image Editing Support
|
|
565
|
-
if (allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
|
|
566
|
+
if (!!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.mediaEditing) && allowImageEditing && expValEquals('platform_editor_add_image_editing', 'isEnabled', true)) {
|
|
566
567
|
var _mediaNode$attrs;
|
|
567
568
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
568
569
|
const mediaNode = selectedMediaSingleNode === null || selectedMediaSingleNode === void 0 ? void 0 : selectedMediaSingleNode.node.content.firstChild;
|