@atlaskit/editor-plugin-media 8.6.0 → 8.7.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 +23 -0
- package/dist/cjs/mediaPlugin.js +76 -43
- package/dist/cjs/pm-plugins/actions.js +3 -1
- package/dist/cjs/pm-plugins/commands.js +23 -1
- package/dist/cjs/pm-plugins/main.js +18 -7
- package/dist/cjs/ui/CaptionPlaceholder/index.js +2 -2
- package/dist/cjs/ui/ImageEditor/ModalWrapper.js +69 -0
- package/dist/cjs/ui/ImageEditor/index.js +62 -0
- package/dist/cjs/ui/toolbar/index.js +24 -11
- package/dist/es2019/mediaPlugin.js +38 -3
- package/dist/es2019/pm-plugins/actions.js +3 -1
- package/dist/es2019/pm-plugins/commands.js +22 -0
- package/dist/es2019/pm-plugins/main.js +17 -8
- package/dist/es2019/ui/CaptionPlaceholder/index.js +2 -2
- package/dist/es2019/ui/ImageEditor/ModalWrapper.js +58 -0
- package/dist/es2019/ui/ImageEditor/index.js +53 -0
- package/dist/es2019/ui/toolbar/index.js +20 -6
- package/dist/esm/mediaPlugin.js +77 -44
- package/dist/esm/pm-plugins/actions.js +3 -1
- package/dist/esm/pm-plugins/commands.js +22 -0
- package/dist/esm/pm-plugins/main.js +19 -8
- package/dist/esm/ui/CaptionPlaceholder/index.js +2 -2
- package/dist/esm/ui/ImageEditor/ModalWrapper.js +60 -0
- package/dist/esm/ui/ImageEditor/index.js +52 -0
- package/dist/esm/ui/toolbar/index.js +23 -10
- package/dist/types/mediaPluginType.d.ts +2 -0
- package/dist/types/pm-plugins/actions.d.ts +2 -0
- package/dist/types/pm-plugins/commands.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +6 -3
- package/dist/types/pm-plugins/types.d.ts +3 -0
- package/dist/types/ui/ImageEditor/ModalWrapper.d.ts +13 -0
- package/dist/types/ui/ImageEditor/index.d.ts +12 -0
- package/dist/types/ui/toolbar/index.d.ts +4 -0
- package/dist/types-ts4.5/mediaPluginType.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/actions.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/commands.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -3
- package/dist/types-ts4.5/pm-plugins/types.d.ts +3 -0
- package/dist/types-ts4.5/ui/ImageEditor/ModalWrapper.d.ts +13 -0
- package/dist/types-ts4.5/ui/ImageEditor/index.d.ts +12 -0
- package/dist/types-ts4.5/ui/toolbar/index.d.ts +4 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 8.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`79b6f0fef0ecb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/79b6f0fef0ecb) -
|
|
8
|
+
Added a modal upon clicking the image editing button
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- [`53aef9589ca55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/53aef9589ca55) -
|
|
13
|
+
[EDITOR-3786] Make sure that for any check of `cc_editor_ai_content_mode` &&
|
|
14
|
+
`platform_editor_content_mode_button_mvp` in the code we are also checking
|
|
15
|
+
`confluence_compact_text_format`
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
|
|
18
|
+
## 8.6.1
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- [`b6a737b41d065`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b6a737b41d065) -
|
|
23
|
+
Clean up experiment platform_editor_fix_clone_nesting_exp
|
|
24
|
+
- Updated dependencies
|
|
25
|
+
|
|
3
26
|
## 8.6.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/dist/cjs/mediaPlugin.js
CHANGED
|
@@ -14,6 +14,7 @@ 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");
|
|
17
18
|
var _lazyMedia = require("./nodeviews/lazy-media");
|
|
18
19
|
var _lazyMediaGroup = require("./nodeviews/lazy-media-group");
|
|
19
20
|
var _lazyMediaInline = require("./nodeviews/lazy-media-inline");
|
|
@@ -34,6 +35,7 @@ var _pixelResizing = require("./pm-plugins/pixel-resizing");
|
|
|
34
35
|
var _pluginKey = require("./pm-plugins/plugin-key");
|
|
35
36
|
var _mediaCommon2 = require("./pm-plugins/utils/media-common");
|
|
36
37
|
var _mediaSingle2 = require("./pm-plugins/utils/media-single");
|
|
38
|
+
var _ModalWrapper = require("./ui/ImageEditor/ModalWrapper");
|
|
37
39
|
var _MediaPicker = require("./ui/MediaPicker");
|
|
38
40
|
var _PortalWrapper = require("./ui/MediaViewer/PortalWrapper");
|
|
39
41
|
var _toolbar = require("./ui/toolbar");
|
|
@@ -104,10 +106,36 @@ var MediaViewerFunctionalComponent = function MediaViewerFunctionalComponent(_re
|
|
|
104
106
|
items: mediaItems
|
|
105
107
|
});
|
|
106
108
|
};
|
|
107
|
-
var
|
|
108
|
-
var
|
|
109
|
-
|
|
110
|
-
|
|
109
|
+
var imageEditorStateSelector = function imageEditorStateSelector(states) {
|
|
110
|
+
var _states$mediaState6, _states$mediaState7, _states$mediaState8;
|
|
111
|
+
return {
|
|
112
|
+
isImageEditorVisible: (_states$mediaState6 = states.mediaState) === null || _states$mediaState6 === void 0 ? void 0 : _states$mediaState6.isImageEditorVisible,
|
|
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;
|
|
111
139
|
var previousMediaProvider;
|
|
112
140
|
var mediaErrorLocalIds = new Set();
|
|
113
141
|
return {
|
|
@@ -148,8 +176,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
148
176
|
return false;
|
|
149
177
|
}
|
|
150
178
|
previousMediaProvider = provider;
|
|
151
|
-
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (
|
|
152
|
-
var tr =
|
|
179
|
+
return (_api$core$actions$exe = api === null || api === void 0 ? void 0 : api.core.actions.execute(function (_ref5) {
|
|
180
|
+
var tr = _ref5.tr;
|
|
153
181
|
return tr.setMeta(_pluginKey.stateKey, {
|
|
154
182
|
mediaProvider: provider
|
|
155
183
|
});
|
|
@@ -159,19 +187,21 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
159
187
|
commands: {
|
|
160
188
|
showMediaViewer: _commands.showMediaViewer,
|
|
161
189
|
hideMediaViewer: _commands.hideMediaViewer,
|
|
162
|
-
trackMediaPaste: _commands.trackMediaPaste
|
|
190
|
+
trackMediaPaste: _commands.trackMediaPaste,
|
|
191
|
+
showImageEditor: _commands.showImageEditor,
|
|
192
|
+
hideImageEditor: _commands.hideImageEditor
|
|
163
193
|
},
|
|
164
194
|
nodes: function nodes() {
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
allowMediaGroup =
|
|
168
|
-
|
|
169
|
-
allowMediaSingle =
|
|
170
|
-
|
|
171
|
-
allowPixelResizing =
|
|
172
|
-
allowCaptions =
|
|
173
|
-
allowMediaInlineImages =
|
|
174
|
-
mediaFeatureFlags =
|
|
195
|
+
var _ref6 = options || {},
|
|
196
|
+
_ref6$allowMediaGroup = _ref6.allowMediaGroup,
|
|
197
|
+
allowMediaGroup = _ref6$allowMediaGroup === void 0 ? true : _ref6$allowMediaGroup,
|
|
198
|
+
_ref6$allowMediaSingl = _ref6.allowMediaSingle,
|
|
199
|
+
allowMediaSingle = _ref6$allowMediaSingl === void 0 ? false : _ref6$allowMediaSingl,
|
|
200
|
+
_ref6$allowPixelResiz = _ref6.allowPixelResizing,
|
|
201
|
+
allowPixelResizing = _ref6$allowPixelResiz === void 0 ? false : _ref6$allowPixelResiz,
|
|
202
|
+
allowCaptions = _ref6.allowCaptions,
|
|
203
|
+
allowMediaInlineImages = _ref6.allowMediaInlineImages,
|
|
204
|
+
mediaFeatureFlags = _ref6.featureFlags;
|
|
175
205
|
var allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags);
|
|
176
206
|
var mediaSingleOption = {
|
|
177
207
|
withCaption: allowCaptions,
|
|
@@ -205,16 +235,16 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
205
235
|
pmPlugins: function pmPlugins() {
|
|
206
236
|
var pmPlugins = [{
|
|
207
237
|
name: 'media',
|
|
208
|
-
plugin: function plugin(
|
|
209
|
-
var schema =
|
|
210
|
-
dispatch =
|
|
211
|
-
getIntl =
|
|
212
|
-
eventDispatcher =
|
|
213
|
-
providerFactory =
|
|
214
|
-
errorReporter =
|
|
215
|
-
portalProviderAPI =
|
|
216
|
-
dispatchAnalyticsEvent =
|
|
217
|
-
nodeViewPortalProviderAPI =
|
|
238
|
+
plugin: function plugin(_ref7) {
|
|
239
|
+
var schema = _ref7.schema,
|
|
240
|
+
dispatch = _ref7.dispatch,
|
|
241
|
+
getIntl = _ref7.getIntl,
|
|
242
|
+
eventDispatcher = _ref7.eventDispatcher,
|
|
243
|
+
providerFactory = _ref7.providerFactory,
|
|
244
|
+
errorReporter = _ref7.errorReporter,
|
|
245
|
+
portalProviderAPI = _ref7.portalProviderAPI,
|
|
246
|
+
dispatchAnalyticsEvent = _ref7.dispatchAnalyticsEvent,
|
|
247
|
+
nodeViewPortalProviderAPI = _ref7.nodeViewPortalProviderAPI;
|
|
218
248
|
return (0, _main.createPlugin)(schema, {
|
|
219
249
|
providerFactory: providerFactory,
|
|
220
250
|
nodeViews: {
|
|
@@ -233,17 +263,17 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
233
263
|
}
|
|
234
264
|
}, {
|
|
235
265
|
name: 'mediaKeymap',
|
|
236
|
-
plugin: function plugin(
|
|
266
|
+
plugin: function plugin(_ref8) {
|
|
237
267
|
var _api$analytics3, _api$selection;
|
|
238
|
-
var getIntl =
|
|
268
|
+
var getIntl = _ref8.getIntl;
|
|
239
269
|
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);
|
|
240
270
|
}
|
|
241
271
|
}];
|
|
242
272
|
if (options && options.allowMediaSingle) {
|
|
243
273
|
pmPlugins.push({
|
|
244
274
|
name: 'mediaSingleKeymap',
|
|
245
|
-
plugin: function plugin(
|
|
246
|
-
var schema =
|
|
275
|
+
plugin: function plugin(_ref9) {
|
|
276
|
+
var schema = _ref9.schema;
|
|
247
277
|
return (0, _keymapMedia.default)(schema);
|
|
248
278
|
}
|
|
249
279
|
});
|
|
@@ -255,9 +285,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
255
285
|
});
|
|
256
286
|
pmPlugins.push({
|
|
257
287
|
name: 'mediaAltTextKeymap',
|
|
258
|
-
plugin: function plugin(
|
|
288
|
+
plugin: function plugin(_ref0) {
|
|
259
289
|
var _api$analytics4;
|
|
260
|
-
var schema =
|
|
290
|
+
var schema = _ref0.schema;
|
|
261
291
|
return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
262
292
|
}
|
|
263
293
|
});
|
|
@@ -265,15 +295,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
265
295
|
if (options && options.allowLinking) {
|
|
266
296
|
pmPlugins.push({
|
|
267
297
|
name: 'mediaLinking',
|
|
268
|
-
plugin: function plugin(
|
|
269
|
-
var dispatch =
|
|
298
|
+
plugin: function plugin(_ref1) {
|
|
299
|
+
var dispatch = _ref1.dispatch;
|
|
270
300
|
return (0, _linking.default)(dispatch);
|
|
271
301
|
}
|
|
272
302
|
});
|
|
273
303
|
pmPlugins.push({
|
|
274
304
|
name: 'mediaLinkingKeymap',
|
|
275
|
-
plugin: function plugin(
|
|
276
|
-
var schema =
|
|
305
|
+
plugin: function plugin(_ref10) {
|
|
306
|
+
var schema = _ref10.schema;
|
|
277
307
|
return (0, _keymap3.default)(schema);
|
|
278
308
|
}
|
|
279
309
|
});
|
|
@@ -315,13 +345,16 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
315
345
|
});
|
|
316
346
|
return pmPlugins;
|
|
317
347
|
},
|
|
318
|
-
contentComponent: function contentComponent(
|
|
319
|
-
var editorView =
|
|
320
|
-
appearance =
|
|
348
|
+
contentComponent: function contentComponent(_ref11) {
|
|
349
|
+
var editorView = _ref11.editorView,
|
|
350
|
+
appearance = _ref11.appearance;
|
|
321
351
|
if (!editorView) {
|
|
322
352
|
return null;
|
|
323
353
|
}
|
|
324
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
354
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, (options === null || options === void 0 ? void 0 : options.allowImageEditing) && (0, _expValEquals.expValEquals)('platform_editor_add_image_editing', 'isEnabled', true) && /*#__PURE__*/_react.default.createElement(ImageEditorFunctionalComponent, {
|
|
355
|
+
api: api,
|
|
356
|
+
editorView: editorView
|
|
357
|
+
}), /*#__PURE__*/_react.default.createElement(MediaViewerFunctionalComponent, {
|
|
325
358
|
api: api,
|
|
326
359
|
editorView: editorView
|
|
327
360
|
}), /*#__PURE__*/_react.default.createElement(MediaPickerFunctionalComponent, {
|
|
@@ -330,8 +363,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
330
363
|
api: api
|
|
331
364
|
}));
|
|
332
365
|
},
|
|
333
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
334
|
-
var disabled =
|
|
366
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref12) {
|
|
367
|
+
var disabled = _ref12.disabled;
|
|
335
368
|
return /*#__PURE__*/_react.default.createElement(_ToolbarMedia.default, {
|
|
336
369
|
isDisabled: disabled,
|
|
337
370
|
isReducedSpacing: true,
|
|
@@ -7,5 +7,7 @@ exports.ACTIONS = void 0;
|
|
|
7
7
|
var ACTIONS = exports.ACTIONS = {
|
|
8
8
|
SHOW_MEDIA_VIEWER: 'SHOW_MEDIA_VIEWER',
|
|
9
9
|
HIDE_MEDIA_VIEWER: 'HIDE_MEDIA_VIEWER',
|
|
10
|
-
TRACK_MEDIA_PASTE: 'TRACK_MEDIA_PASTE'
|
|
10
|
+
TRACK_MEDIA_PASTE: 'TRACK_MEDIA_PASTE',
|
|
11
|
+
SHOW_IMAGE_EDITOR: 'SHOW_IMAGE_EDITOR',
|
|
12
|
+
HIDE_IMAGE_EDITOR: 'HIDE_IMAGE_EDITOR'
|
|
11
13
|
};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.trackMediaPaste = exports.showMediaViewer = exports.hideMediaViewer = void 0;
|
|
6
|
+
exports.trackMediaPaste = exports.showMediaViewer = exports.showImageEditor = exports.hideMediaViewer = exports.hideImageEditor = 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,4 +37,26 @@ 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;
|
|
40
62
|
};
|
|
@@ -90,6 +90,7 @@ 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);
|
|
93
94
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
94
95
|
(0, _defineProperty2.default)(this, "lastAddedMediaSingleFileIds", []);
|
|
95
96
|
(0, _defineProperty2.default)(this, "destroyed", false);
|
|
@@ -485,19 +486,14 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
485
486
|
return (0, _createClass2.default)(MediaPluginStateImplementation, [{
|
|
486
487
|
key: "clone",
|
|
487
488
|
value: function clone() {
|
|
489
|
+
var _originalTarget;
|
|
488
490
|
var clonedAt = (performance || Date).now();
|
|
489
491
|
|
|
490
492
|
// Prevent double wrapping
|
|
491
493
|
// If clone is repeatedly called, we want to proxy the underlying MediaPluginStateImplementation target, rather than the proxy itself
|
|
492
494
|
// If we proxy the proxy, then calling get in future will need to recursively unwrap proxies to find the original target, which causes performance issues
|
|
493
495
|
// Instead, we check if there is an original target stored on "this", and if so, we use that as the proxy target instead
|
|
494
|
-
|
|
495
|
-
var proxyTarget = this;
|
|
496
|
-
var originalTarget = this.originalTarget;
|
|
497
|
-
if (originalTarget !== undefined && (0, _expValEquals.expValEquals)('platform_editor_fix_clone_nesting_exp', 'isEnabled', true)) {
|
|
498
|
-
proxyTarget = originalTarget;
|
|
499
|
-
}
|
|
500
|
-
return new Proxy(proxyTarget, {
|
|
496
|
+
return new Proxy((_originalTarget = this.originalTarget) !== null && _originalTarget !== void 0 ? _originalTarget : this, {
|
|
501
497
|
get: function get(target, prop, receiver) {
|
|
502
498
|
if (prop === 'singletonCreatedAt') {
|
|
503
499
|
return clonedAt;
|
|
@@ -642,6 +638,11 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
642
638
|
value: function setResizingWidth(width) {
|
|
643
639
|
this.resizingWidth = width;
|
|
644
640
|
}
|
|
641
|
+
}, {
|
|
642
|
+
key: "setImageEditorVisibility",
|
|
643
|
+
value: function setImageEditorVisibility(isVisible) {
|
|
644
|
+
this.isImageEditorVisible = isVisible;
|
|
645
|
+
}
|
|
645
646
|
}, {
|
|
646
647
|
key: "updateElement",
|
|
647
648
|
value: function updateElement() {
|
|
@@ -883,6 +884,16 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
883
884
|
nextPluginState = pluginState.clone();
|
|
884
885
|
}
|
|
885
886
|
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;
|
|
886
897
|
}
|
|
887
898
|
|
|
888
899
|
// NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
|
|
@@ -55,7 +55,7 @@ var CaptionPlaceholder = exports.CaptionPlaceholder = /*#__PURE__*/_react.defaul
|
|
|
55
55
|
// This id is just used for setting styles at the moment, if it's needed for anything more specific
|
|
56
56
|
// It may need to be generated to avoid overlap
|
|
57
57
|
,
|
|
58
|
-
id: (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ? _mediaSingle.CAPTION_PLACEHOLDER_ID : undefined,
|
|
58
|
+
id: (0, _expValEquals.expValEquals)('confluence_compact_text_format', 'isEnabled', true) || (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ? _mediaSingle.CAPTION_PLACEHOLDER_ID : undefined,
|
|
59
59
|
"data-id": _mediaSingle.CAPTION_PLACEHOLDER_ID,
|
|
60
60
|
"data-testid": "caption-placeholder"
|
|
61
61
|
}, (0, _react2.jsx)(_reactIntlNext.FormattedMessage
|
|
@@ -83,7 +83,7 @@ var CaptionPlaceholderButton = exports.CaptionPlaceholderButton = /*#__PURE__*/_
|
|
|
83
83
|
testId: "caption-placeholder",
|
|
84
84
|
padding: "space.0",
|
|
85
85
|
xcss: placeholderButton
|
|
86
|
-
}, (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ?
|
|
86
|
+
}, (0, _expValEquals.expValEquals)('confluence_compact_text_format', 'isEnabled', true) || (0, _expValEquals.expValEquals)('cc_editor_ai_content_mode', 'variant', 'test') && (0, _platformFeatureFlags.fg)('platform_editor_content_mode_button_mvp') ?
|
|
87
87
|
// This id is just used for setting styles at the moment, if it's needed for anything more specific
|
|
88
88
|
// It may need to be generated to avoid overlap
|
|
89
89
|
// eslint-disable-next-line @atlaskit/design-system/use-primitives-text
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RenderImageEditor = void 0;
|
|
9
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
var _mediaClient = require("@atlaskit/media-client");
|
|
12
|
+
var _utils = require("../toolbar/utils");
|
|
13
|
+
var _index = require("./index");
|
|
14
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
|
+
var RenderImageEditor = exports.RenderImageEditor = function RenderImageEditor(_ref) {
|
|
16
|
+
var mediaClientConfig = _ref.mediaClientConfig,
|
|
17
|
+
onClose = _ref.onClose,
|
|
18
|
+
selectedNodeAttrs = _ref.selectedNodeAttrs,
|
|
19
|
+
errorReporter = _ref.errorReporter,
|
|
20
|
+
onSave = _ref.onSave;
|
|
21
|
+
var _useState = (0, _react.useState)(''),
|
|
22
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
23
|
+
imageUrl = _useState2[0],
|
|
24
|
+
setImageUrl = _useState2[1];
|
|
25
|
+
(0, _react.useEffect)(function () {
|
|
26
|
+
var getImageUrl = function getImageUrl() {
|
|
27
|
+
if ((0, _utils.isExternalMedia)(selectedNodeAttrs)) {
|
|
28
|
+
// External image - use the URL directly
|
|
29
|
+
setImageUrl(selectedNodeAttrs.url || '');
|
|
30
|
+
} else {
|
|
31
|
+
// File media - use MediaClient to get the image URL
|
|
32
|
+
var id = selectedNodeAttrs.id,
|
|
33
|
+
_selectedNodeAttrs$co = selectedNodeAttrs.collection,
|
|
34
|
+
collection = _selectedNodeAttrs$co === void 0 ? '' : _selectedNodeAttrs$co;
|
|
35
|
+
try {
|
|
36
|
+
var mediaClient = new _mediaClient.MediaClient(mediaClientConfig);
|
|
37
|
+
|
|
38
|
+
// Subscribe to file state to get file information
|
|
39
|
+
var subscription = mediaClient.file.getFileState(id, {
|
|
40
|
+
collectionName: collection
|
|
41
|
+
}).subscribe(function (fileState) {
|
|
42
|
+
if (fileState.status === 'processed' || fileState.status === 'processing') {
|
|
43
|
+
// Get the image URL from the processed file
|
|
44
|
+
mediaClient.file.getFileBinaryURL(id, collection).then(function (url) {
|
|
45
|
+
setImageUrl(url);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Cleanup subscription on unmount
|
|
51
|
+
return function () {
|
|
52
|
+
return subscription.unsubscribe();
|
|
53
|
+
};
|
|
54
|
+
} catch (error) {
|
|
55
|
+
if (errorReporter) {
|
|
56
|
+
errorReporter.captureException(error instanceof Error ? error : new Error(String(error)));
|
|
57
|
+
}
|
|
58
|
+
setImageUrl('');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
getImageUrl();
|
|
63
|
+
}, [selectedNodeAttrs, mediaClientConfig, errorReporter]);
|
|
64
|
+
return /*#__PURE__*/_react.default.createElement(_index.ImageEditor, {
|
|
65
|
+
isOpen: true,
|
|
66
|
+
onClose: onClose,
|
|
67
|
+
imageUrl: imageUrl
|
|
68
|
+
});
|
|
69
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.ImageEditor = void 0;
|
|
9
|
+
var _react = require("@emotion/react");
|
|
10
|
+
var _reactIntlNext = require("react-intl-next");
|
|
11
|
+
var _new = _interopRequireDefault(require("@atlaskit/button/new"));
|
|
12
|
+
var _modalDialog = _interopRequireWildcard(require("@atlaskit/modal-dialog"));
|
|
13
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
+
/**
|
|
15
|
+
* @jsxRuntime classic
|
|
16
|
+
* @jsx jsx
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
20
|
+
|
|
21
|
+
var imageWrapper = (0, _react.css)({
|
|
22
|
+
maxHeight: 'calc(100vh - 250px)',
|
|
23
|
+
width: '100%',
|
|
24
|
+
overflow: 'hidden',
|
|
25
|
+
display: 'flex',
|
|
26
|
+
justifyContent: 'center',
|
|
27
|
+
alignItems: 'center'
|
|
28
|
+
});
|
|
29
|
+
var imageStyle = (0, _react.css)({
|
|
30
|
+
maxWidth: '100%',
|
|
31
|
+
maxHeight: 'calc(100vh - 250px)',
|
|
32
|
+
width: 'auto',
|
|
33
|
+
height: 'auto',
|
|
34
|
+
objectFit: 'contain'
|
|
35
|
+
});
|
|
36
|
+
var ImageEditor = exports.ImageEditor = function ImageEditor(_ref) {
|
|
37
|
+
var isOpen = _ref.isOpen,
|
|
38
|
+
onClose = _ref.onClose,
|
|
39
|
+
imageUrl = _ref.imageUrl;
|
|
40
|
+
return (0, _react.jsx)(_modalDialog.ModalTransition, null, isOpen && (0, _react.jsx)(_modalDialog.default, {
|
|
41
|
+
onClose: onClose,
|
|
42
|
+
width: 1800
|
|
43
|
+
}, (0, _react.jsx)("br", null), (0, _react.jsx)(_modalDialog.ModalBody, null, (0, _react.jsx)("div", {
|
|
44
|
+
css: imageWrapper
|
|
45
|
+
}, imageUrl && (0, _react.jsx)("img", {
|
|
46
|
+
src: imageUrl,
|
|
47
|
+
alt: "Edit preview",
|
|
48
|
+
css: imageStyle
|
|
49
|
+
}))), (0, _react.jsx)(_modalDialog.ModalFooter, null, (0, _react.jsx)(_new.default, {
|
|
50
|
+
appearance: "subtle",
|
|
51
|
+
onClick: onClose
|
|
52
|
+
}, (0, _react.jsx)(_reactIntlNext.FormattedMessage, {
|
|
53
|
+
id: "editor.imageEditor.cancel",
|
|
54
|
+
defaultMessage: "Cancel"
|
|
55
|
+
})), (0, _react.jsx)(_new.default, {
|
|
56
|
+
appearance: "primary",
|
|
57
|
+
onClick: onClose
|
|
58
|
+
}, (0, _react.jsx)(_reactIntlNext.FormattedMessage, {
|
|
59
|
+
id: "editor.imageEditor.done",
|
|
60
|
+
defaultMessage: "Done"
|
|
61
|
+
})))));
|
|
62
|
+
};
|
|
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.overflowDropdwonBtnTriggerTestId = exports.handleShowMediaViewer = exports.floatingToolbar = void 0;
|
|
8
|
+
exports.overflowDropdwonBtnTriggerTestId = exports.handleShowMediaViewer = exports.handleShowImageEditor = exports.floatingToolbar = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
10
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
@@ -121,6 +121,15 @@ var handleShowMediaViewer = exports.handleShowMediaViewer = function handleShowM
|
|
|
121
121
|
}
|
|
122
122
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
|
|
123
123
|
};
|
|
124
|
+
var handleShowImageEditor = exports.handleShowImageEditor = function handleShowImageEditor(_ref2) {
|
|
125
|
+
var api = _ref2.api,
|
|
126
|
+
mediaPluginState = _ref2.mediaPluginState;
|
|
127
|
+
var selectedNodeAttrs = (0, _utils2.getSelectedNearestMediaContainerNodeAttrs)(mediaPluginState);
|
|
128
|
+
if (!selectedNodeAttrs) {
|
|
129
|
+
return false;
|
|
130
|
+
}
|
|
131
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showImageEditor(selectedNodeAttrs));
|
|
132
|
+
};
|
|
124
133
|
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
|
|
125
134
|
var _pluginInjectionApi$c;
|
|
126
135
|
var disableDownloadButton = (0, _utils2.getIsDownloadDisabledByDataSecurityPolicy)(mediaPluginState);
|
|
@@ -278,8 +287,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
278
287
|
allowPixelResizing = options.allowPixelResizing,
|
|
279
288
|
onCommentButtonMount = options.onCommentButtonMount;
|
|
280
289
|
var toolbarButtons = [];
|
|
281
|
-
var
|
|
282
|
-
hoverDecoration =
|
|
290
|
+
var _ref3 = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {},
|
|
291
|
+
hoverDecoration = _ref3.hoverDecoration;
|
|
283
292
|
var areAnyNewToolbarFlagsEnabled = (0, _toolbarFlagCheck.areToolbarFlagsEnabled)(Boolean(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.toolbar));
|
|
284
293
|
var disableDownloadButton = (0, _utils2.getIsDownloadDisabledByDataSecurityPolicy)(pluginState);
|
|
285
294
|
if ((0, _imageBorder.shouldShowImageBorder)(state)) {
|
|
@@ -565,9 +574,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
565
574
|
icon: _imageCrop.default,
|
|
566
575
|
title: intl.formatMessage(_messages.default.imageEdit),
|
|
567
576
|
onClick: function onClick() {
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
577
|
+
var _handleShowImageEdito;
|
|
578
|
+
return (_handleShowImageEdito = handleShowImageEditor({
|
|
579
|
+
api: pluginInjectionApi,
|
|
580
|
+
mediaPluginState: pluginState
|
|
581
|
+
})) !== null && _handleShowImageEdito !== void 0 ? _handleShowImageEdito : false;
|
|
571
582
|
},
|
|
572
583
|
supportsViewMode: false
|
|
573
584
|
});
|
|
@@ -723,9 +734,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
723
734
|
icon: _imageCrop.default,
|
|
724
735
|
title: intl.formatMessage(_messages.default.imageEdit),
|
|
725
736
|
onClick: function onClick() {
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
737
|
+
var _handleShowImageEdito2;
|
|
738
|
+
return (_handleShowImageEdito2 = handleShowImageEditor({
|
|
739
|
+
api: pluginInjectionApi,
|
|
740
|
+
mediaPluginState: pluginState
|
|
741
|
+
})) !== null && _handleShowImageEdito2 !== void 0 ? _handleShowImageEdito2 : false;
|
|
729
742
|
},
|
|
730
743
|
supportsViewMode: false
|
|
731
744
|
}, {
|
|
@@ -773,8 +786,8 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
773
786
|
allowMediaInline = (0, _platformFeatureFlags.fg)('platform_editor_remove_media_inline_feature_flag') ? allowMediaInlineImages : allowMediaInline;
|
|
774
787
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
775
788
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
776
|
-
var
|
|
777
|
-
hoverDecoration =
|
|
789
|
+
var _ref4 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
790
|
+
hoverDecoration = _ref4.hoverDecoration;
|
|
778
791
|
if (!mediaPluginState) {
|
|
779
792
|
return;
|
|
780
793
|
}
|