@atlaskit/editor-plugin-media 8.4.13 → 8.4.15
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 +16 -0
- package/dist/cjs/mediaPlugin.js +0 -2
- package/dist/cjs/pm-plugins/main.js +7 -66
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +10 -4
- package/dist/es2019/mediaPlugin.js +0 -2
- package/dist/es2019/pm-plugins/main.js +2 -59
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +11 -5
- package/dist/esm/mediaPlugin.js +0 -2
- package/dist/esm/pm-plugins/main.js +7 -66
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +11 -5
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 8.4.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`55920a92e882a`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/55920a92e882a) -
|
|
8
|
+
tsignores added for help-center local consumpton removed
|
|
9
|
+
- Updated dependencies
|
|
10
|
+
|
|
11
|
+
## 8.4.14
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [`5d8ba7e59f96f`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/5d8ba7e59f96f) -
|
|
16
|
+
simplify the media single resizer classnames
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 8.4.13
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/mediaPlugin.js
CHANGED
|
@@ -290,8 +290,6 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
290
290
|
var mediaSelectionHandlerPlugin = new _safePlugin.SafePlugin({
|
|
291
291
|
key: new _state.PluginKey('mediaSelectionHandlerPlugin'),
|
|
292
292
|
props: {
|
|
293
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
294
|
-
|
|
295
293
|
handleScrollToSelection: function handleScrollToSelection(view) {
|
|
296
294
|
var selection = view.state.selection;
|
|
297
295
|
if (!(selection instanceof _state.NodeSelection) || selection.node.type.name !== 'media') {
|
|
@@ -148,8 +148,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
if (_this.uploadInProgressSubscriptions.length > 0 && !_this.uploadInProgressSubscriptionsNotified) {
|
|
151
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
152
|
-
|
|
153
151
|
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
154
152
|
return fn(true);
|
|
155
153
|
});
|
|
@@ -199,8 +197,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
199
197
|
}
|
|
200
198
|
_this.waitForPendingTasks().then(function () {
|
|
201
199
|
if (_this.uploadInProgressSubscriptions.length > 0 && _this.uploadInProgressSubscriptionsNotified) {
|
|
202
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
203
|
-
|
|
204
200
|
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
205
201
|
return fn(false);
|
|
206
202
|
});
|
|
@@ -327,46 +323,25 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
327
323
|
*/
|
|
328
324
|
(0, _defineProperty2.default)(this, "handleMediaNodeUnmount", function (oldNode) {
|
|
329
325
|
_this.trackMediaNodeRemoval(oldNode);
|
|
330
|
-
|
|
331
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
332
|
-
|
|
333
326
|
_this.mediaNodes = _this.mediaNodes.filter(function (_ref4) {
|
|
334
327
|
var node = _ref4.node;
|
|
335
328
|
return oldNode !== node;
|
|
336
329
|
});
|
|
337
330
|
});
|
|
338
331
|
(0, _defineProperty2.default)(this, "handleMediaGroupUpdate", function (oldNodes, newNodes) {
|
|
339
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
340
|
-
|
|
341
332
|
var addedNodes = newNodes.filter(function (node) {
|
|
342
|
-
return (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
oldNodes.every(function (oldNode) {
|
|
346
|
-
return oldNode.attrs.id !== node.attrs.id;
|
|
347
|
-
})
|
|
348
|
-
);
|
|
333
|
+
return oldNodes.every(function (oldNode) {
|
|
334
|
+
return oldNode.attrs.id !== node.attrs.id;
|
|
335
|
+
});
|
|
349
336
|
});
|
|
350
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
351
|
-
|
|
352
337
|
var removedNodes = oldNodes.filter(function (node) {
|
|
353
|
-
return (
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
newNodes.every(function (newNode) {
|
|
357
|
-
return newNode.attrs.id !== node.attrs.id;
|
|
358
|
-
})
|
|
359
|
-
);
|
|
338
|
+
return newNodes.every(function (newNode) {
|
|
339
|
+
return newNode.attrs.id !== node.attrs.id;
|
|
340
|
+
});
|
|
360
341
|
});
|
|
361
|
-
|
|
362
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
363
|
-
|
|
364
342
|
addedNodes.forEach(function (node) {
|
|
365
343
|
_this.trackMediaNodeAddition(node);
|
|
366
344
|
});
|
|
367
|
-
|
|
368
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
369
|
-
|
|
370
345
|
removedNodes.forEach(function (oldNode) {
|
|
371
346
|
_this.trackMediaNodeRemoval(oldNode);
|
|
372
347
|
});
|
|
@@ -375,8 +350,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
375
350
|
return helpers.findMediaNode(_this, id);
|
|
376
351
|
});
|
|
377
352
|
(0, _defineProperty2.default)(this, "destroyAllPickers", function (pickers) {
|
|
378
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
379
|
-
|
|
380
353
|
pickers.forEach(function (picker) {
|
|
381
354
|
return picker.destroy();
|
|
382
355
|
});
|
|
@@ -544,8 +517,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
544
517
|
}, {
|
|
545
518
|
key: "unsubscribeFromUploadInProgressState",
|
|
546
519
|
value: function unsubscribeFromUploadInProgressState(fn) {
|
|
547
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
548
|
-
|
|
549
520
|
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(function (subscribedFn) {
|
|
550
521
|
return subscribedFn !== fn;
|
|
551
522
|
});
|
|
@@ -730,8 +701,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
730
701
|
var lastTrackedAddedNode = _this2.lastAddedMediaSingleFileIds[0];
|
|
731
702
|
// execute selection only if selection did not change after the node has been inserted
|
|
732
703
|
if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === _this2.view.state.selection.from) {
|
|
733
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
734
|
-
|
|
735
704
|
var lastAddedNode = _this2.mediaNodes.find(function (node) {
|
|
736
705
|
return node.node.attrs.id === lastTrackedAddedNode.id;
|
|
737
706
|
});
|
|
@@ -759,10 +728,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
759
728
|
}
|
|
760
729
|
}, {
|
|
761
730
|
key: "destroy",
|
|
762
|
-
value:
|
|
763
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
764
|
-
|
|
765
|
-
function destroy() {
|
|
731
|
+
value: function destroy() {
|
|
766
732
|
if (this.destroyed) {
|
|
767
733
|
return;
|
|
768
734
|
}
|
|
@@ -809,15 +775,11 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
809
775
|
_context2.t1 = this.customPicker = _context2.sent;
|
|
810
776
|
_context2.t0.push.call(_context2.t0, _context2.t1);
|
|
811
777
|
case 13:
|
|
812
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
813
|
-
|
|
814
778
|
pickers.forEach(function (picker) {
|
|
815
779
|
picker.onNewMedia(_this3.insertFile);
|
|
816
780
|
});
|
|
817
781
|
case 14:
|
|
818
782
|
// set new upload params for the pickers
|
|
819
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
820
|
-
|
|
821
783
|
pickers.forEach(function (picker) {
|
|
822
784
|
return picker.setUploadParams(uploadParams);
|
|
823
785
|
});
|
|
@@ -842,8 +804,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
842
804
|
value: function updateAndDispatch(props) {
|
|
843
805
|
var _this4 = this;
|
|
844
806
|
// update plugin state
|
|
845
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
846
|
-
|
|
847
807
|
Object.keys(props).forEach(function (_key) {
|
|
848
808
|
var key = _key;
|
|
849
809
|
var value = props[key];
|
|
@@ -864,11 +824,9 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
864
824
|
var intl = getIntl();
|
|
865
825
|
return new _safePlugin.SafePlugin({
|
|
866
826
|
state: {
|
|
867
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
868
827
|
init: function init(_config, state) {
|
|
869
828
|
return new MediaPluginStateImplementation(state, options, mediaOptions, dispatch, pluginInjectionApi);
|
|
870
829
|
},
|
|
871
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
872
830
|
apply: function apply(tr, pluginState) {
|
|
873
831
|
var _tr$getMeta;
|
|
874
832
|
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
@@ -893,8 +851,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
893
851
|
|
|
894
852
|
// remap editing media single position if we're in collab
|
|
895
853
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
896
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
897
|
-
|
|
898
854
|
pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
|
|
899
855
|
nextPluginState = nextPluginState.clone();
|
|
900
856
|
}
|
|
@@ -935,7 +891,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
935
891
|
return nextPluginState;
|
|
936
892
|
}
|
|
937
893
|
},
|
|
938
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
939
894
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
940
895
|
var _iterator = _createForOfIteratorHelper(transactions),
|
|
941
896
|
_step;
|
|
@@ -962,7 +917,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
962
917
|
return;
|
|
963
918
|
},
|
|
964
919
|
key: _pluginKey.stateKey,
|
|
965
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
966
920
|
view: function view(_view) {
|
|
967
921
|
var pluginState = getMediaPluginState(_view.state);
|
|
968
922
|
pluginState.setView(_view);
|
|
@@ -974,7 +928,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
974
928
|
};
|
|
975
929
|
},
|
|
976
930
|
props: {
|
|
977
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
978
931
|
decorations: function decorations(state) {
|
|
979
932
|
// Use this to indicate that the media node is selected
|
|
980
933
|
var mediaNodes = [];
|
|
@@ -984,7 +937,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
984
937
|
|
|
985
938
|
// Find any media nodes in the current selection
|
|
986
939
|
if (state.selection instanceof _state2.TextSelection || state.selection instanceof _state2.AllSelection || state.selection instanceof _state2.NodeSelection || state.selection instanceof _cellSelection.CellSelection) {
|
|
987
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
988
940
|
doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
|
|
989
941
|
if (node.type === schema.nodes.media) {
|
|
990
942
|
mediaNodes.push(_view2.Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -1014,8 +966,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1014
966
|
}
|
|
1015
967
|
var pos = $anchor.pos;
|
|
1016
968
|
if ($anchor.parent.type !== schema.nodes.paragraph && $anchor.parent.type !== schema.nodes.codeBlock) {
|
|
1017
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1018
|
-
|
|
1019
969
|
pos = (0, _transform.insertPoint)(state.doc, pos, schema.nodes.mediaGroup);
|
|
1020
970
|
}
|
|
1021
971
|
if (pos === null || pos === undefined) {
|
|
@@ -1036,7 +986,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1036
986
|
return _view2.DecorationSet.create(state.doc, dropPlaceholders);
|
|
1037
987
|
},
|
|
1038
988
|
nodeViews: options.nodeViews,
|
|
1039
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1040
989
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
1041
990
|
var selection = view.state.selection;
|
|
1042
991
|
if (text === ' ' && selection instanceof _state2.NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
@@ -1044,8 +993,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1044
993
|
var videoControlsWrapperRef = (_stateKey$getState = _pluginKey.stateKey.getState(view.state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.element;
|
|
1045
994
|
var videoControls = videoControlsWrapperRef === null || videoControlsWrapperRef === void 0 ? void 0 : videoControlsWrapperRef.querySelectorAll('button, [tabindex]:not([tabindex="-1"])');
|
|
1046
995
|
if (videoControls) {
|
|
1047
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1048
|
-
|
|
1049
996
|
var isVideoControl = Array.from(videoControls).some(function (videoControl) {
|
|
1050
997
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
1051
998
|
return document.activeElement === videoControl;
|
|
@@ -1058,7 +1005,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1058
1005
|
getMediaPluginState(view.state).splitMediaGroup();
|
|
1059
1006
|
return false;
|
|
1060
1007
|
},
|
|
1061
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1062
1008
|
handleClick: function handleClick(_editorView, _pos, event) {
|
|
1063
1009
|
var _event$target;
|
|
1064
1010
|
// Ignored via go/ees005
|
|
@@ -1082,7 +1028,6 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1082
1028
|
}
|
|
1083
1029
|
return false;
|
|
1084
1030
|
},
|
|
1085
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1086
1031
|
handleDoubleClickOn: function handleDoubleClickOn(view) {
|
|
1087
1032
|
var _pluginState$mediaOpt, _pluginInjectionApi$e;
|
|
1088
1033
|
// Check if media viewer is enabled
|
|
@@ -1118,11 +1063,7 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
|
|
|
1118
1063
|
}
|
|
1119
1064
|
return false;
|
|
1120
1065
|
},
|
|
1121
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1122
|
-
|
|
1123
1066
|
handleDOMEvents: {
|
|
1124
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1125
|
-
|
|
1126
1067
|
keydown: function keydown(view, event) {
|
|
1127
1068
|
var selection = view.state.selection;
|
|
1128
1069
|
if (selection instanceof _state2.NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
@@ -22,6 +22,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
|
|
|
22
22
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
23
23
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
24
24
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
25
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
25
26
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
26
27
|
var _main = require("../../pm-plugins/main");
|
|
27
28
|
var _analytics = require("../../pm-plugins/utils/analytics");
|
|
@@ -255,6 +256,14 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
|
|
|
255
256
|
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|
|
256
257
|
var minViewWidth = isResizing ? minWidth : "min(".concat(minWidth, "px, 100%)");
|
|
257
258
|
var resizerNextClassName = (0, _react.useMemo)(function () {
|
|
259
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_resizer_styles_cleanup', 'isEnabled', true)) {
|
|
260
|
+
var _classNameNext = (0, _classnames.default)(_styles.richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', className, _styles.resizerItemClassName, {
|
|
261
|
+
'display-handle': selected,
|
|
262
|
+
'richMedia-selected': selected,
|
|
263
|
+
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
264
|
+
});
|
|
265
|
+
return _classNameNext;
|
|
266
|
+
}
|
|
258
267
|
// TODO: ED-26962 - Clean up where this lives and how it gets generated
|
|
259
268
|
var classNameNext = (0, _classnames.default)(_styles.richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', className, {
|
|
260
269
|
'richMedia-selected': selected,
|
|
@@ -343,10 +352,7 @@ var ResizableMediaSingleNextFunctional = exports.ResizableMediaSingleNextFunctio
|
|
|
343
352
|
if (!guidelineSnapsReference.snaps.x) {
|
|
344
353
|
return;
|
|
345
354
|
}
|
|
346
|
-
var _findClosestSnap = (0, _guideline.findClosestSnap)(
|
|
347
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
348
|
-
|
|
349
|
-
width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, _mediaSingle.MEDIA_SINGLE_SNAP_GAP),
|
|
355
|
+
var _findClosestSnap = (0, _guideline.findClosestSnap)(width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, _mediaSingle.MEDIA_SINGLE_SNAP_GAP),
|
|
350
356
|
gap = _findClosestSnap.gap,
|
|
351
357
|
activeGuidelineKeys = _findClosestSnap.keys;
|
|
352
358
|
var relativeGuidelines = activeGuidelineKeys.length ? [] : getRelativeGuides();
|
|
@@ -282,8 +282,6 @@ export const mediaPlugin = ({
|
|
|
282
282
|
const mediaSelectionHandlerPlugin = new SafePlugin({
|
|
283
283
|
key: new PluginKey('mediaSelectionHandlerPlugin'),
|
|
284
284
|
props: {
|
|
285
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
286
|
-
|
|
287
285
|
handleScrollToSelection: view => {
|
|
288
286
|
const {
|
|
289
287
|
state: {
|
|
@@ -128,8 +128,6 @@ export class MediaPluginStateImplementation {
|
|
|
128
128
|
});
|
|
129
129
|
}
|
|
130
130
|
if (this.uploadInProgressSubscriptions.length > 0 && !this.uploadInProgressSubscriptionsNotified) {
|
|
131
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
132
|
-
|
|
133
131
|
this.uploadInProgressSubscriptions.forEach(fn => fn(true));
|
|
134
132
|
this.uploadInProgressSubscriptionsNotified = true;
|
|
135
133
|
}
|
|
@@ -177,8 +175,6 @@ export class MediaPluginStateImplementation {
|
|
|
177
175
|
}
|
|
178
176
|
this.waitForPendingTasks().then(() => {
|
|
179
177
|
if (this.uploadInProgressSubscriptions.length > 0 && this.uploadInProgressSubscriptionsNotified) {
|
|
180
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
181
|
-
|
|
182
178
|
this.uploadInProgressSubscriptions.forEach(fn => fn(false));
|
|
183
179
|
this.uploadInProgressSubscriptionsNotified = false;
|
|
184
180
|
}
|
|
@@ -303,35 +299,16 @@ export class MediaPluginStateImplementation {
|
|
|
303
299
|
*/
|
|
304
300
|
_defineProperty(this, "handleMediaNodeUnmount", oldNode => {
|
|
305
301
|
this.trackMediaNodeRemoval(oldNode);
|
|
306
|
-
|
|
307
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
308
|
-
|
|
309
302
|
this.mediaNodes = this.mediaNodes.filter(({
|
|
310
303
|
node
|
|
311
304
|
}) => oldNode !== node);
|
|
312
305
|
});
|
|
313
306
|
_defineProperty(this, "handleMediaGroupUpdate", (oldNodes, newNodes) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
const addedNodes = newNodes.filter(node =>
|
|
317
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
318
|
-
|
|
319
|
-
oldNodes.every(oldNode => oldNode.attrs.id !== node.attrs.id));
|
|
320
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
321
|
-
|
|
322
|
-
const removedNodes = oldNodes.filter(node =>
|
|
323
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
324
|
-
|
|
325
|
-
newNodes.every(newNode => newNode.attrs.id !== node.attrs.id));
|
|
326
|
-
|
|
327
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
328
|
-
|
|
307
|
+
const addedNodes = newNodes.filter(node => oldNodes.every(oldNode => oldNode.attrs.id !== node.attrs.id));
|
|
308
|
+
const removedNodes = oldNodes.filter(node => newNodes.every(newNode => newNode.attrs.id !== node.attrs.id));
|
|
329
309
|
addedNodes.forEach(node => {
|
|
330
310
|
this.trackMediaNodeAddition(node);
|
|
331
311
|
});
|
|
332
|
-
|
|
333
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
334
|
-
|
|
335
312
|
removedNodes.forEach(oldNode => {
|
|
336
313
|
this.trackMediaNodeRemoval(oldNode);
|
|
337
314
|
});
|
|
@@ -340,8 +317,6 @@ export class MediaPluginStateImplementation {
|
|
|
340
317
|
return helpers.findMediaNode(this, id);
|
|
341
318
|
});
|
|
342
319
|
_defineProperty(this, "destroyAllPickers", pickers => {
|
|
343
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
344
|
-
|
|
345
320
|
pickers.forEach(picker => picker.destroy());
|
|
346
321
|
this.pickers.splice(0, this.pickers.length);
|
|
347
322
|
});
|
|
@@ -515,8 +490,6 @@ export class MediaPluginStateImplementation {
|
|
|
515
490
|
this.uploadInProgressSubscriptions.push(fn);
|
|
516
491
|
}
|
|
517
492
|
unsubscribeFromUploadInProgressState(fn) {
|
|
518
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
519
|
-
|
|
520
493
|
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(subscribedFn => subscribedFn !== fn);
|
|
521
494
|
}
|
|
522
495
|
async setMediaProvider(mediaProvider) {
|
|
@@ -652,8 +625,6 @@ export class MediaPluginStateImplementation {
|
|
|
652
625
|
const lastTrackedAddedNode = this.lastAddedMediaSingleFileIds[0];
|
|
653
626
|
// execute selection only if selection did not change after the node has been inserted
|
|
654
627
|
if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === this.view.state.selection.from) {
|
|
655
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
656
|
-
|
|
657
628
|
const lastAddedNode = this.mediaNodes.find(node => {
|
|
658
629
|
return node.node.attrs.id === lastTrackedAddedNode.id;
|
|
659
630
|
});
|
|
@@ -678,8 +649,6 @@ export class MediaPluginStateImplementation {
|
|
|
678
649
|
setView(view) {
|
|
679
650
|
this.view = view;
|
|
680
651
|
}
|
|
681
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
682
|
-
|
|
683
652
|
destroy() {
|
|
684
653
|
if (this.destroyed) {
|
|
685
654
|
return;
|
|
@@ -712,17 +681,12 @@ export class MediaPluginStateImplementation {
|
|
|
712
681
|
pickerPromises.push(customPicker);
|
|
713
682
|
pickers.push(this.customPicker = await customPicker);
|
|
714
683
|
}
|
|
715
|
-
|
|
716
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
717
|
-
|
|
718
684
|
pickers.forEach(picker => {
|
|
719
685
|
picker.onNewMedia(this.insertFile);
|
|
720
686
|
});
|
|
721
687
|
}
|
|
722
688
|
|
|
723
689
|
// set new upload params for the pickers
|
|
724
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
725
|
-
|
|
726
690
|
pickers.forEach(picker => picker.setUploadParams(uploadParams));
|
|
727
691
|
}
|
|
728
692
|
collectionFromProvider() {
|
|
@@ -730,8 +694,6 @@ export class MediaPluginStateImplementation {
|
|
|
730
694
|
}
|
|
731
695
|
updateAndDispatch(props) {
|
|
732
696
|
// update plugin state
|
|
733
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
734
|
-
|
|
735
697
|
Object.keys(props).forEach(_key => {
|
|
736
698
|
const key = _key;
|
|
737
699
|
const value = props[key];
|
|
@@ -751,11 +713,9 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
751
713
|
const intl = getIntl();
|
|
752
714
|
return new SafePlugin({
|
|
753
715
|
state: {
|
|
754
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
755
716
|
init(_config, state) {
|
|
756
717
|
return new MediaPluginStateImplementation(state, options, mediaOptions, dispatch, pluginInjectionApi);
|
|
757
718
|
},
|
|
758
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
759
719
|
apply(tr, pluginState) {
|
|
760
720
|
var _tr$getMeta;
|
|
761
721
|
const isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
@@ -780,8 +740,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
780
740
|
|
|
781
741
|
// remap editing media single position if we're in collab
|
|
782
742
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
783
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
784
|
-
|
|
785
743
|
pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
|
|
786
744
|
nextPluginState = nextPluginState.clone();
|
|
787
745
|
}
|
|
@@ -826,7 +784,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
826
784
|
return nextPluginState;
|
|
827
785
|
}
|
|
828
786
|
},
|
|
829
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
830
787
|
appendTransaction(transactions, _oldState, newState) {
|
|
831
788
|
for (const transaction of transactions) {
|
|
832
789
|
const isSelectionOnMediaInsideMediaSingle = transaction.selectionSet && isNodeSelection(transaction.selection) && transaction.selection.node.type === newState.schema.nodes.media && transaction.selection.$anchor.parent.type === newState.schema.nodes.mediaSingle;
|
|
@@ -844,7 +801,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
844
801
|
return;
|
|
845
802
|
},
|
|
846
803
|
key: stateKey,
|
|
847
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
848
804
|
view: view => {
|
|
849
805
|
const pluginState = getMediaPluginState(view.state);
|
|
850
806
|
pluginState.setView(view);
|
|
@@ -856,7 +812,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
856
812
|
};
|
|
857
813
|
},
|
|
858
814
|
props: {
|
|
859
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
860
815
|
decorations: state => {
|
|
861
816
|
// Use this to indicate that the media node is selected
|
|
862
817
|
const mediaNodes = [];
|
|
@@ -870,7 +825,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
870
825
|
|
|
871
826
|
// Find any media nodes in the current selection
|
|
872
827
|
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
873
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
874
828
|
doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
|
|
875
829
|
if (node.type === schema.nodes.media) {
|
|
876
830
|
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -900,8 +854,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
900
854
|
}
|
|
901
855
|
let pos = $anchor.pos;
|
|
902
856
|
if ($anchor.parent.type !== schema.nodes.paragraph && $anchor.parent.type !== schema.nodes.codeBlock) {
|
|
903
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
904
|
-
|
|
905
857
|
pos = insertPoint(state.doc, pos, schema.nodes.mediaGroup);
|
|
906
858
|
}
|
|
907
859
|
if (pos === null || pos === undefined) {
|
|
@@ -922,7 +874,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
922
874
|
return DecorationSet.create(state.doc, dropPlaceholders);
|
|
923
875
|
},
|
|
924
876
|
nodeViews: options.nodeViews,
|
|
925
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
926
877
|
handleTextInput(view, from, to, text) {
|
|
927
878
|
const {
|
|
928
879
|
selection
|
|
@@ -932,8 +883,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
932
883
|
const videoControlsWrapperRef = (_stateKey$getState = stateKey.getState(view.state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.element;
|
|
933
884
|
const videoControls = videoControlsWrapperRef === null || videoControlsWrapperRef === void 0 ? void 0 : videoControlsWrapperRef.querySelectorAll('button, [tabindex]:not([tabindex="-1"])');
|
|
934
885
|
if (videoControls) {
|
|
935
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
936
|
-
|
|
937
886
|
const isVideoControl = Array.from(videoControls).some(videoControl => {
|
|
938
887
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
939
888
|
return document.activeElement === videoControl;
|
|
@@ -946,7 +895,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
946
895
|
getMediaPluginState(view.state).splitMediaGroup();
|
|
947
896
|
return false;
|
|
948
897
|
},
|
|
949
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
950
898
|
handleClick: (_editorView, _pos, event) => {
|
|
951
899
|
var _event$target;
|
|
952
900
|
// Ignored via go/ees005
|
|
@@ -970,7 +918,6 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
970
918
|
}
|
|
971
919
|
return false;
|
|
972
920
|
},
|
|
973
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
974
921
|
handleDoubleClickOn: view => {
|
|
975
922
|
var _pluginState$mediaOpt, _pluginInjectionApi$e, _pluginInjectionApi$e2;
|
|
976
923
|
// Check if media viewer is enabled
|
|
@@ -1006,11 +953,7 @@ export const createPlugin = (_schema, options, getIntl, pluginInjectionApi, node
|
|
|
1006
953
|
}
|
|
1007
954
|
return false;
|
|
1008
955
|
},
|
|
1009
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1010
|
-
|
|
1011
956
|
handleDOMEvents: {
|
|
1012
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1013
|
-
|
|
1014
957
|
keydown: (view, event) => {
|
|
1015
958
|
const {
|
|
1016
959
|
selection
|
|
@@ -11,13 +11,14 @@ import throttle from 'lodash/throttle';
|
|
|
11
11
|
import { findClosestSnap, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps, getGuidelinesWithHighlights, getGuidelineTypeFromKey, getRelativeGuidelines, getRelativeGuideSnaps } from '@atlaskit/editor-common/guideline';
|
|
12
12
|
import { calcMediaSingleMaxWidth, DEFAULT_IMAGE_WIDTH, MEDIA_SINGLE_ADJACENT_HANDLE_MARGIN, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
13
13
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
14
|
-
import { resizerStyles, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
14
|
+
import { resizerItemClassName, resizerStyles, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
15
15
|
import { calcPctFromPx, handleSides, imageAlignmentMap, wrappedLayouts } from '@atlaskit/editor-common/ui';
|
|
16
16
|
import { nonWrappedLayouts } from '@atlaskit/editor-common/utils';
|
|
17
17
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
18
18
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
19
19
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
|
|
20
20
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
21
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
21
22
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
22
23
|
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
23
24
|
import { getMediaResizeAnalyticsEvent } from '../../pm-plugins/utils/analytics';
|
|
@@ -235,6 +236,14 @@ export const ResizableMediaSingleNextFunctional = props => {
|
|
|
235
236
|
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|
|
236
237
|
const minViewWidth = isResizing ? minWidth : `min(${minWidth}px, 100%)`;
|
|
237
238
|
const resizerNextClassName = useMemo(() => {
|
|
239
|
+
if (expValEquals('platform_editor_resizer_styles_cleanup', 'isEnabled', true)) {
|
|
240
|
+
const classNameNext = classnames(richMediaClassName, `image-${layout}`, isResizing ? 'is-resizing' : 'not-resizing', className, resizerItemClassName, {
|
|
241
|
+
'display-handle': selected,
|
|
242
|
+
'richMedia-selected': selected,
|
|
243
|
+
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
244
|
+
});
|
|
245
|
+
return classNameNext;
|
|
246
|
+
}
|
|
238
247
|
// TODO: ED-26962 - Clean up where this lives and how it gets generated
|
|
239
248
|
const classNameNext = classnames(richMediaClassName, `image-${layout}`, isResizing ? 'is-resizing' : 'not-resizing', className, {
|
|
240
249
|
'richMedia-selected': selected,
|
|
@@ -327,10 +336,7 @@ export const ResizableMediaSingleNextFunctional = props => {
|
|
|
327
336
|
const {
|
|
328
337
|
gap,
|
|
329
338
|
keys: activeGuidelineKeys
|
|
330
|
-
} = findClosestSnap(
|
|
331
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
332
|
-
|
|
333
|
-
width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, MEDIA_SINGLE_SNAP_GAP);
|
|
339
|
+
} = findClosestSnap(width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, MEDIA_SINGLE_SNAP_GAP);
|
|
334
340
|
const relativeGuidelines = activeGuidelineKeys.length ? [] : getRelativeGuides();
|
|
335
341
|
lastSnappedGuidelineKeysRef.current = activeGuidelineKeys.length ? activeGuidelineKeys : relativeGuidelines.map(rg => rg.key);
|
|
336
342
|
const nextGuideLines = [...getGuidelinesWithHighlights(gap, MEDIA_SINGLE_SNAP_GAP, activeGuidelineKeys, guidelines), ...relativeGuidelines];
|
package/dist/esm/mediaPlugin.js
CHANGED
|
@@ -281,8 +281,6 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
281
281
|
var mediaSelectionHandlerPlugin = new SafePlugin({
|
|
282
282
|
key: new PluginKey('mediaSelectionHandlerPlugin'),
|
|
283
283
|
props: {
|
|
284
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
285
|
-
|
|
286
284
|
handleScrollToSelection: function handleScrollToSelection(view) {
|
|
287
285
|
var selection = view.state.selection;
|
|
288
286
|
if (!(selection instanceof NodeSelection) || selection.node.type.name !== 'media') {
|
|
@@ -140,8 +140,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
if (_this.uploadInProgressSubscriptions.length > 0 && !_this.uploadInProgressSubscriptionsNotified) {
|
|
143
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
144
|
-
|
|
145
143
|
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
146
144
|
return fn(true);
|
|
147
145
|
});
|
|
@@ -191,8 +189,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
191
189
|
}
|
|
192
190
|
_this.waitForPendingTasks().then(function () {
|
|
193
191
|
if (_this.uploadInProgressSubscriptions.length > 0 && _this.uploadInProgressSubscriptionsNotified) {
|
|
194
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
195
|
-
|
|
196
192
|
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
197
193
|
return fn(false);
|
|
198
194
|
});
|
|
@@ -319,46 +315,25 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
319
315
|
*/
|
|
320
316
|
_defineProperty(this, "handleMediaNodeUnmount", function (oldNode) {
|
|
321
317
|
_this.trackMediaNodeRemoval(oldNode);
|
|
322
|
-
|
|
323
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
324
|
-
|
|
325
318
|
_this.mediaNodes = _this.mediaNodes.filter(function (_ref4) {
|
|
326
319
|
var node = _ref4.node;
|
|
327
320
|
return oldNode !== node;
|
|
328
321
|
});
|
|
329
322
|
});
|
|
330
323
|
_defineProperty(this, "handleMediaGroupUpdate", function (oldNodes, newNodes) {
|
|
331
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
332
|
-
|
|
333
324
|
var addedNodes = newNodes.filter(function (node) {
|
|
334
|
-
return (
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
oldNodes.every(function (oldNode) {
|
|
338
|
-
return oldNode.attrs.id !== node.attrs.id;
|
|
339
|
-
})
|
|
340
|
-
);
|
|
325
|
+
return oldNodes.every(function (oldNode) {
|
|
326
|
+
return oldNode.attrs.id !== node.attrs.id;
|
|
327
|
+
});
|
|
341
328
|
});
|
|
342
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
343
|
-
|
|
344
329
|
var removedNodes = oldNodes.filter(function (node) {
|
|
345
|
-
return (
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
newNodes.every(function (newNode) {
|
|
349
|
-
return newNode.attrs.id !== node.attrs.id;
|
|
350
|
-
})
|
|
351
|
-
);
|
|
330
|
+
return newNodes.every(function (newNode) {
|
|
331
|
+
return newNode.attrs.id !== node.attrs.id;
|
|
332
|
+
});
|
|
352
333
|
});
|
|
353
|
-
|
|
354
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
355
|
-
|
|
356
334
|
addedNodes.forEach(function (node) {
|
|
357
335
|
_this.trackMediaNodeAddition(node);
|
|
358
336
|
});
|
|
359
|
-
|
|
360
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
361
|
-
|
|
362
337
|
removedNodes.forEach(function (oldNode) {
|
|
363
338
|
_this.trackMediaNodeRemoval(oldNode);
|
|
364
339
|
});
|
|
@@ -367,8 +342,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
367
342
|
return helpers.findMediaNode(_this, id);
|
|
368
343
|
});
|
|
369
344
|
_defineProperty(this, "destroyAllPickers", function (pickers) {
|
|
370
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
371
|
-
|
|
372
345
|
pickers.forEach(function (picker) {
|
|
373
346
|
return picker.destroy();
|
|
374
347
|
});
|
|
@@ -536,8 +509,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
536
509
|
}, {
|
|
537
510
|
key: "unsubscribeFromUploadInProgressState",
|
|
538
511
|
value: function unsubscribeFromUploadInProgressState(fn) {
|
|
539
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
540
|
-
|
|
541
512
|
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(function (subscribedFn) {
|
|
542
513
|
return subscribedFn !== fn;
|
|
543
514
|
});
|
|
@@ -722,8 +693,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
722
693
|
var lastTrackedAddedNode = _this2.lastAddedMediaSingleFileIds[0];
|
|
723
694
|
// execute selection only if selection did not change after the node has been inserted
|
|
724
695
|
if ((lastTrackedAddedNode === null || lastTrackedAddedNode === void 0 ? void 0 : lastTrackedAddedNode.selectionPosition) === _this2.view.state.selection.from) {
|
|
725
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
726
|
-
|
|
727
696
|
var lastAddedNode = _this2.mediaNodes.find(function (node) {
|
|
728
697
|
return node.node.attrs.id === lastTrackedAddedNode.id;
|
|
729
698
|
});
|
|
@@ -751,10 +720,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
751
720
|
}
|
|
752
721
|
}, {
|
|
753
722
|
key: "destroy",
|
|
754
|
-
value:
|
|
755
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
756
|
-
|
|
757
|
-
function destroy() {
|
|
723
|
+
value: function destroy() {
|
|
758
724
|
if (this.destroyed) {
|
|
759
725
|
return;
|
|
760
726
|
}
|
|
@@ -801,15 +767,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
801
767
|
_context2.t1 = this.customPicker = _context2.sent;
|
|
802
768
|
_context2.t0.push.call(_context2.t0, _context2.t1);
|
|
803
769
|
case 13:
|
|
804
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
805
|
-
|
|
806
770
|
pickers.forEach(function (picker) {
|
|
807
771
|
picker.onNewMedia(_this3.insertFile);
|
|
808
772
|
});
|
|
809
773
|
case 14:
|
|
810
774
|
// set new upload params for the pickers
|
|
811
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
812
|
-
|
|
813
775
|
pickers.forEach(function (picker) {
|
|
814
776
|
return picker.setUploadParams(uploadParams);
|
|
815
777
|
});
|
|
@@ -834,8 +796,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
834
796
|
value: function updateAndDispatch(props) {
|
|
835
797
|
var _this4 = this;
|
|
836
798
|
// update plugin state
|
|
837
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
838
|
-
|
|
839
799
|
Object.keys(props).forEach(function (_key) {
|
|
840
800
|
var key = _key;
|
|
841
801
|
var value = props[key];
|
|
@@ -856,11 +816,9 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
856
816
|
var intl = getIntl();
|
|
857
817
|
return new SafePlugin({
|
|
858
818
|
state: {
|
|
859
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
860
819
|
init: function init(_config, state) {
|
|
861
820
|
return new MediaPluginStateImplementation(state, options, mediaOptions, dispatch, pluginInjectionApi);
|
|
862
821
|
},
|
|
863
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
864
822
|
apply: function apply(tr, pluginState) {
|
|
865
823
|
var _tr$getMeta;
|
|
866
824
|
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
@@ -885,8 +843,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
885
843
|
|
|
886
844
|
// remap editing media single position if we're in collab
|
|
887
845
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
888
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
889
|
-
|
|
890
846
|
pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
|
|
891
847
|
nextPluginState = nextPluginState.clone();
|
|
892
848
|
}
|
|
@@ -927,7 +883,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
927
883
|
return nextPluginState;
|
|
928
884
|
}
|
|
929
885
|
},
|
|
930
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
931
886
|
appendTransaction: function appendTransaction(transactions, _oldState, newState) {
|
|
932
887
|
var _iterator = _createForOfIteratorHelper(transactions),
|
|
933
888
|
_step;
|
|
@@ -954,7 +909,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
954
909
|
return;
|
|
955
910
|
},
|
|
956
911
|
key: stateKey,
|
|
957
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
958
912
|
view: function view(_view) {
|
|
959
913
|
var pluginState = getMediaPluginState(_view.state);
|
|
960
914
|
pluginState.setView(_view);
|
|
@@ -966,7 +920,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
966
920
|
};
|
|
967
921
|
},
|
|
968
922
|
props: {
|
|
969
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
970
923
|
decorations: function decorations(state) {
|
|
971
924
|
// Use this to indicate that the media node is selected
|
|
972
925
|
var mediaNodes = [];
|
|
@@ -976,7 +929,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
976
929
|
|
|
977
930
|
// Find any media nodes in the current selection
|
|
978
931
|
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
979
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
980
932
|
doc.nodesBetween(state.selection.from, state.selection.to, function (node, pos) {
|
|
981
933
|
if (node.type === schema.nodes.media) {
|
|
982
934
|
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
@@ -1006,8 +958,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1006
958
|
}
|
|
1007
959
|
var pos = $anchor.pos;
|
|
1008
960
|
if ($anchor.parent.type !== schema.nodes.paragraph && $anchor.parent.type !== schema.nodes.codeBlock) {
|
|
1009
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1010
|
-
|
|
1011
961
|
pos = insertPoint(state.doc, pos, schema.nodes.mediaGroup);
|
|
1012
962
|
}
|
|
1013
963
|
if (pos === null || pos === undefined) {
|
|
@@ -1028,7 +978,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1028
978
|
return DecorationSet.create(state.doc, dropPlaceholders);
|
|
1029
979
|
},
|
|
1030
980
|
nodeViews: options.nodeViews,
|
|
1031
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1032
981
|
handleTextInput: function handleTextInput(view, from, to, text) {
|
|
1033
982
|
var selection = view.state.selection;
|
|
1034
983
|
if (text === ' ' && selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
@@ -1036,8 +985,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1036
985
|
var videoControlsWrapperRef = (_stateKey$getState = stateKey.getState(view.state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.element;
|
|
1037
986
|
var videoControls = videoControlsWrapperRef === null || videoControlsWrapperRef === void 0 ? void 0 : videoControlsWrapperRef.querySelectorAll('button, [tabindex]:not([tabindex="-1"])');
|
|
1038
987
|
if (videoControls) {
|
|
1039
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1040
|
-
|
|
1041
988
|
var isVideoControl = Array.from(videoControls).some(function (videoControl) {
|
|
1042
989
|
// eslint-disable-next-line @atlaskit/platform/no-direct-document-usage
|
|
1043
990
|
return document.activeElement === videoControl;
|
|
@@ -1050,7 +997,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1050
997
|
getMediaPluginState(view.state).splitMediaGroup();
|
|
1051
998
|
return false;
|
|
1052
999
|
},
|
|
1053
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1054
1000
|
handleClick: function handleClick(_editorView, _pos, event) {
|
|
1055
1001
|
var _event$target;
|
|
1056
1002
|
// Ignored via go/ees005
|
|
@@ -1074,7 +1020,6 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1074
1020
|
}
|
|
1075
1021
|
return false;
|
|
1076
1022
|
},
|
|
1077
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1078
1023
|
handleDoubleClickOn: function handleDoubleClickOn(view) {
|
|
1079
1024
|
var _pluginState$mediaOpt, _pluginInjectionApi$e;
|
|
1080
1025
|
// Check if media viewer is enabled
|
|
@@ -1110,11 +1055,7 @@ export var createPlugin = function createPlugin(_schema, options, getIntl, plugi
|
|
|
1110
1055
|
}
|
|
1111
1056
|
return false;
|
|
1112
1057
|
},
|
|
1113
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1114
|
-
|
|
1115
1058
|
handleDOMEvents: {
|
|
1116
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
1117
|
-
|
|
1118
1059
|
keydown: function keydown(view, event) {
|
|
1119
1060
|
var selection = view.state.selection;
|
|
1120
1061
|
if (selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle') {
|
|
@@ -13,13 +13,14 @@ import throttle from 'lodash/throttle';
|
|
|
13
13
|
import { findClosestSnap, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps, getGuidelinesWithHighlights, getGuidelineTypeFromKey, getRelativeGuidelines, getRelativeGuideSnaps } from '@atlaskit/editor-common/guideline';
|
|
14
14
|
import { calcMediaSingleMaxWidth, DEFAULT_IMAGE_WIDTH, MEDIA_SINGLE_ADJACENT_HANDLE_MARGIN, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_VIDEO_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
15
15
|
import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
16
|
-
import { resizerStyles, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
16
|
+
import { resizerItemClassName, resizerStyles, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
17
17
|
import { calcPctFromPx, handleSides, imageAlignmentMap, wrappedLayouts } from '@atlaskit/editor-common/ui';
|
|
18
18
|
import { nonWrappedLayouts } from '@atlaskit/editor-common/utils';
|
|
19
19
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
20
20
|
import { findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
21
21
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth, akEditorGutterPaddingDynamic, akEditorGutterPaddingReduced, akEditorFullPageNarrowBreakout } from '@atlaskit/editor-shared-styles';
|
|
22
22
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
23
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
23
24
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
24
25
|
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
25
26
|
import { getMediaResizeAnalyticsEvent } from '../../pm-plugins/utils/analytics';
|
|
@@ -245,6 +246,14 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
|
|
|
245
246
|
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|
|
246
247
|
var minViewWidth = isResizing ? minWidth : "min(".concat(minWidth, "px, 100%)");
|
|
247
248
|
var resizerNextClassName = useMemo(function () {
|
|
249
|
+
if (expValEquals('platform_editor_resizer_styles_cleanup', 'isEnabled', true)) {
|
|
250
|
+
var _classNameNext = classnames(richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', className, resizerItemClassName, {
|
|
251
|
+
'display-handle': selected,
|
|
252
|
+
'richMedia-selected': selected,
|
|
253
|
+
'rich-media-wrapped': layout === 'wrap-left' || layout === 'wrap-right'
|
|
254
|
+
});
|
|
255
|
+
return _classNameNext;
|
|
256
|
+
}
|
|
248
257
|
// TODO: ED-26962 - Clean up where this lives and how it gets generated
|
|
249
258
|
var classNameNext = classnames(richMediaClassName, "image-".concat(layout), isResizing ? 'is-resizing' : 'not-resizing', className, {
|
|
250
259
|
'richMedia-selected': selected,
|
|
@@ -333,10 +342,7 @@ export var ResizableMediaSingleNextFunctional = function ResizableMediaSingleNex
|
|
|
333
342
|
if (!guidelineSnapsReference.snaps.x) {
|
|
334
343
|
return;
|
|
335
344
|
}
|
|
336
|
-
var _findClosestSnap = findClosestSnap(
|
|
337
|
-
// @ts-ignore - Workaround for help-center local consumption
|
|
338
|
-
|
|
339
|
-
width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, MEDIA_SINGLE_SNAP_GAP),
|
|
345
|
+
var _findClosestSnap = findClosestSnap(width, guidelineSnapsReference.snaps.x, guidelineSnapsReference.guidelineReference, MEDIA_SINGLE_SNAP_GAP),
|
|
340
346
|
gap = _findClosestSnap.gap,
|
|
341
347
|
activeGuidelineKeys = _findClosestSnap.keys;
|
|
342
348
|
var relativeGuidelines = activeGuidelineKeys.length ? [] : getRelativeGuides();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.15",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@atlaskit/form": "^14.3.0",
|
|
55
55
|
"@atlaskit/icon": "^29.0.0",
|
|
56
56
|
"@atlaskit/icon-lab": "^5.12.0",
|
|
57
|
-
"@atlaskit/media-card": "^79.
|
|
57
|
+
"@atlaskit/media-card": "^79.9.0",
|
|
58
58
|
"@atlaskit/media-client": "^35.6.0",
|
|
59
59
|
"@atlaskit/media-client-react": "^4.1.0",
|
|
60
60
|
"@atlaskit/media-common": "^12.3.0",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@atlaskit/primitives": "^16.4.0",
|
|
67
67
|
"@atlaskit/textfield": "^8.1.0",
|
|
68
68
|
"@atlaskit/theme": "^21.0.0",
|
|
69
|
-
"@atlaskit/tmp-editor-statsig": "^14.
|
|
69
|
+
"@atlaskit/tmp-editor-statsig": "^14.2.0",
|
|
70
70
|
"@atlaskit/tokens": "^8.4.0",
|
|
71
71
|
"@atlaskit/tooltip": "^20.10.0",
|
|
72
72
|
"@babel/runtime": "^7.0.0",
|