@atlaskit/editor-plugin-media 1.7.0 → 1.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/pm-plugins/main.js +28 -0
- package/dist/cjs/toolbar/commands.js +5 -4
- package/dist/cjs/toolbar/comments.js +8 -2
- package/dist/cjs/toolbar/imageBorder.js +2 -1
- package/dist/cjs/toolbar/index.js +7 -8
- package/dist/cjs/utils/current-media-node.js +3 -19
- package/dist/es2019/pm-plugins/main.js +18 -0
- package/dist/es2019/toolbar/commands.js +2 -1
- package/dist/es2019/toolbar/comments.js +8 -2
- package/dist/es2019/toolbar/imageBorder.js +2 -1
- package/dist/es2019/toolbar/index.js +7 -8
- package/dist/es2019/utils/current-media-node.js +1 -19
- package/dist/esm/pm-plugins/main.js +28 -0
- package/dist/esm/toolbar/commands.js +2 -1
- package/dist/esm/toolbar/comments.js +8 -2
- package/dist/esm/toolbar/imageBorder.js +2 -1
- package/dist/esm/toolbar/index.js +7 -8
- package/dist/esm/utils/current-media-node.js +1 -17
- package/dist/types/pm-plugins/main.d.ts +6 -0
- package/dist/types/pm-plugins/types.d.ts +2 -0
- package/dist/types/toolbar/comments.d.ts +3 -3
- package/dist/types/utils/current-media-node.d.ts +0 -4
- package/dist/types-ts4.5/pm-plugins/main.d.ts +6 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +2 -0
- package/dist/types-ts4.5/toolbar/comments.d.ts +3 -3
- package/dist/types-ts4.5/utils/current-media-node.d.ts +0 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 1.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.8.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#77607](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/77607) [`78ab76808037`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/78ab76808037) - Fixed bug where save button state was not updated correctly for when media upload is in progress or finish uploading
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#78508](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/78508) [`3459ec92fed3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/3459ec92fed3) - [ux] When comment button in media floating toolbar is click, setInlineCommentDraftState from annotation plugin is evoked to apply draft docration and display inline comment create popup
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 1.7.0
|
|
4
21
|
|
|
5
22
|
### Minor Changes
|
|
@@ -87,6 +87,8 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
87
87
|
(0, _defineProperty2.default)(this, "isResizing", false);
|
|
88
88
|
(0, _defineProperty2.default)(this, "resizingWidth", 0);
|
|
89
89
|
(0, _defineProperty2.default)(this, "allowInlineImages", false);
|
|
90
|
+
(0, _defineProperty2.default)(this, "uploadInProgressSubscriptions", []);
|
|
91
|
+
(0, _defineProperty2.default)(this, "uploadInProgressSubscriptionsNotified", false);
|
|
90
92
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
91
93
|
(0, _defineProperty2.default)(this, "lastAddedMediaSingleFileIds", []);
|
|
92
94
|
(0, _defineProperty2.default)(this, "destroyed", false);
|
|
@@ -231,6 +233,12 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
231
233
|
allUploadsFinished: false
|
|
232
234
|
});
|
|
233
235
|
}
|
|
236
|
+
if (_this.uploadInProgressSubscriptions.length > 0 && !_this.uploadInProgressSubscriptionsNotified) {
|
|
237
|
+
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
238
|
+
return fn(true);
|
|
239
|
+
});
|
|
240
|
+
_this.uploadInProgressSubscriptionsNotified = true;
|
|
241
|
+
}
|
|
234
242
|
switch ((0, _mediaInline2.getMediaNodeInsertionType)(state, _this.mediaOptions, mediaStateWithContext.fileMimeType)) {
|
|
235
243
|
case 'inline':
|
|
236
244
|
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.allowInlineImages, _this.getInputMethod(pickerType));
|
|
@@ -273,6 +281,14 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
273
281
|
if (!view.hasFocus()) {
|
|
274
282
|
view.focus();
|
|
275
283
|
}
|
|
284
|
+
_this.waitForPendingTasks().then(function () {
|
|
285
|
+
if (_this.uploadInProgressSubscriptions.length > 0 && _this.uploadInProgressSubscriptionsNotified) {
|
|
286
|
+
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
287
|
+
return fn(false);
|
|
288
|
+
});
|
|
289
|
+
_this.uploadInProgressSubscriptionsNotified = false;
|
|
290
|
+
}
|
|
291
|
+
});
|
|
276
292
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.autoselect-inserted-image_oumto')) {
|
|
277
293
|
_this.selectLastAddedMediaNode();
|
|
278
294
|
}
|
|
@@ -507,6 +523,18 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
507
523
|
}
|
|
508
524
|
});
|
|
509
525
|
}
|
|
526
|
+
}, {
|
|
527
|
+
key: "subscribeToUploadInProgressState",
|
|
528
|
+
value: function subscribeToUploadInProgressState(fn) {
|
|
529
|
+
this.uploadInProgressSubscriptions.push(fn);
|
|
530
|
+
}
|
|
531
|
+
}, {
|
|
532
|
+
key: "unsubscribeFromUploadInProgressState",
|
|
533
|
+
value: function unsubscribeFromUploadInProgressState(fn) {
|
|
534
|
+
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(function (subscribedFn) {
|
|
535
|
+
return subscribedFn !== fn;
|
|
536
|
+
});
|
|
537
|
+
}
|
|
510
538
|
}, {
|
|
511
539
|
key: "setIsResizing",
|
|
512
540
|
value: function setIsResizing(isResizing) {
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.updateMediaSingleWidth = exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = exports.getNodeType = exports.changeMediaSingleToMediaInline = exports.changeMediaInlineToMediaSingle = exports.changeMediaCardToInline = exports.changeInlineToMediaCard = exports.DEFAULT_BORDER_SIZE = exports.DEFAULT_BORDER_COLOR = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
10
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
12
13
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
@@ -14,7 +15,7 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
14
15
|
var _analytics2 = require("../utils/analytics");
|
|
15
16
|
var _currentMediaNode = require("../utils/current-media-node");
|
|
16
17
|
var _mediaCommon = require("../utils/media-common");
|
|
17
|
-
var
|
|
18
|
+
var _mediaSingle2 = require("../utils/media-single");
|
|
18
19
|
var _utils2 = require("./utils");
|
|
19
20
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
21
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
@@ -141,7 +142,7 @@ var changeMediaInlineToMediaSingle = exports.changeMediaInlineToMediaSingle = fu
|
|
|
141
142
|
return false;
|
|
142
143
|
}
|
|
143
144
|
if (view) {
|
|
144
|
-
return (0,
|
|
145
|
+
return (0, _mediaSingle2.changeFromMediaInlineToMediaSingleNode)(view, selectedNode, widthPluginState, editorAnalyticsAPI);
|
|
145
146
|
}
|
|
146
147
|
return true;
|
|
147
148
|
};
|
|
@@ -157,7 +158,7 @@ var removeInlineCard = exports.removeInlineCard = function removeInlineCard(stat
|
|
|
157
158
|
};
|
|
158
159
|
var toggleBorderMark = exports.toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
|
|
159
160
|
return function (state, dispatch) {
|
|
160
|
-
var nodeWithPos = (0,
|
|
161
|
+
var nodeWithPos = (0, _mediaSingle.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
|
|
161
162
|
if (!nodeWithPos) {
|
|
162
163
|
return false;
|
|
163
164
|
}
|
|
@@ -217,7 +218,7 @@ var setBorderMark = exports.setBorderMark = function setBorderMark(editorAnalyti
|
|
|
217
218
|
return function (attrs) {
|
|
218
219
|
return function (state, dispatch) {
|
|
219
220
|
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
220
|
-
var nodeWithPos = (0,
|
|
221
|
+
var nodeWithPos = (0, _mediaSingle.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
|
|
221
222
|
if (!nodeWithPos) {
|
|
222
223
|
return false;
|
|
223
224
|
}
|
|
@@ -6,12 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.commentButton = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
9
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
10
11
|
var _media = require("@atlaskit/editor-common/media");
|
|
11
12
|
var _comment = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
|
|
12
|
-
var commentButton = exports.commentButton = function commentButton(intl, state,
|
|
13
|
+
var commentButton = exports.commentButton = function commentButton(intl, state, api) {
|
|
13
14
|
var title = intl.formatMessage(_media.commentMessages.addCommentOnMedia);
|
|
14
|
-
var onClickHandler = function onClickHandler() {
|
|
15
|
+
var onClickHandler = function onClickHandler(state, dispatch) {
|
|
16
|
+
if (api && api.annotation) {
|
|
17
|
+
api.annotation.actions.setInlineCommentDraftState(true,
|
|
18
|
+
// TODO: might need to update to reflect it's from media floating toolbar
|
|
19
|
+
_analytics.INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
20
|
+
}
|
|
15
21
|
return true;
|
|
16
22
|
};
|
|
17
23
|
return {
|
|
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.shouldShowImageBorder = shouldShowImageBorder;
|
|
7
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
7
8
|
var _currentMediaNode = require("../utils/current-media-node");
|
|
8
9
|
function shouldShowImageBorder(editorState) {
|
|
9
10
|
var border = editorState.schema.marks.border;
|
|
10
11
|
if (!border) {
|
|
11
12
|
return false;
|
|
12
13
|
}
|
|
13
|
-
var nodeWithPos = (0,
|
|
14
|
+
var nodeWithPos = (0, _mediaSingle.currentMediaNodeWithPos)(editorState) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(editorState);
|
|
14
15
|
if (!nodeWithPos) {
|
|
15
16
|
return false;
|
|
16
17
|
}
|
|
@@ -406,8 +406,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
406
406
|
});
|
|
407
407
|
}
|
|
408
408
|
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
409
|
-
|
|
410
|
-
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions), {
|
|
409
|
+
toolbarButtons.push((0, _comments.commentButton)(intl, state, pluginInjectionApi), {
|
|
411
410
|
type: 'separator'
|
|
412
411
|
});
|
|
413
412
|
}
|
|
@@ -426,10 +425,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
426
425
|
};
|
|
427
426
|
var openLink = function openLink() {
|
|
428
427
|
if (editorView) {
|
|
429
|
-
var _pluginInjectionApi$
|
|
428
|
+
var _pluginInjectionApi$a6;
|
|
430
429
|
var tr = editorView.state.tr,
|
|
431
430
|
dispatch = editorView.dispatch;
|
|
432
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
431
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
433
432
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
434
433
|
action: _analytics.ACTION.VISITED,
|
|
435
434
|
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
@@ -466,8 +465,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
466
465
|
}
|
|
467
466
|
}
|
|
468
467
|
if (allowAltTextOnImages) {
|
|
469
|
-
var _pluginInjectionApi$
|
|
470
|
-
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
468
|
+
var _pluginInjectionApi$a7;
|
|
469
|
+
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
471
470
|
type: 'separator'
|
|
472
471
|
});
|
|
473
472
|
}
|
|
@@ -556,14 +555,14 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
556
555
|
selectedNodeType = state.selection.node.type;
|
|
557
556
|
}
|
|
558
557
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
559
|
-
var _pluginInjectionApi$
|
|
558
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f2;
|
|
560
559
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
561
560
|
baseToolbar.getDomRef = function () {
|
|
562
561
|
var _mediaPluginState$ele;
|
|
563
562
|
var selector = (0, _mediaFilmstrip.mediaFilmstripItemDOMSelector)(mediaOffset);
|
|
564
563
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
565
564
|
};
|
|
566
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
565
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector);
|
|
567
566
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
568
567
|
baseToolbar.getDomRef = function () {
|
|
569
568
|
var _mediaPluginState$ele2;
|
|
@@ -3,25 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.currentMediaOrInlineNodeBorderMark = exports.
|
|
6
|
+
exports.currentMediaOrInlineNodeBorderMark = exports.currentMediaNode = exports.currentMediaInlineNodeWithPos = exports.currentMediaInlineNode = void 0;
|
|
7
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
7
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var currentMediaNodeWithPos = exports.currentMediaNodeWithPos = function currentMediaNodeWithPos(editorState) {
|
|
9
|
-
var doc = editorState.doc,
|
|
10
|
-
selection = editorState.selection,
|
|
11
|
-
schema = editorState.schema;
|
|
12
|
-
if (!doc || !selection || !(selection instanceof _state.NodeSelection) || selection.node.type !== schema.nodes.mediaSingle) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
var pos = selection.$anchor.pos + 1;
|
|
16
|
-
var node = doc.nodeAt(pos);
|
|
17
|
-
if (!node || node.type !== schema.nodes.media) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
node: node,
|
|
22
|
-
pos: pos
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
9
|
var currentMediaInlineNodeWithPos = exports.currentMediaInlineNodeWithPos = function currentMediaInlineNodeWithPos(editorState) {
|
|
26
10
|
var doc = editorState.doc,
|
|
27
11
|
selection = editorState.selection,
|
|
@@ -41,7 +25,7 @@ var currentMediaInlineNodeWithPos = exports.currentMediaInlineNodeWithPos = func
|
|
|
41
25
|
};
|
|
42
26
|
var currentMediaNode = exports.currentMediaNode = function currentMediaNode(editorState) {
|
|
43
27
|
var _currentMediaNodeWith;
|
|
44
|
-
return (_currentMediaNodeWith = currentMediaNodeWithPos(editorState)) === null || _currentMediaNodeWith === void 0 ? void 0 : _currentMediaNodeWith.node;
|
|
28
|
+
return (_currentMediaNodeWith = (0, _mediaSingle.currentMediaNodeWithPos)(editorState)) === null || _currentMediaNodeWith === void 0 ? void 0 : _currentMediaNodeWith.node;
|
|
45
29
|
};
|
|
46
30
|
var currentMediaInlineNode = exports.currentMediaInlineNode = function currentMediaInlineNode(editorState) {
|
|
47
31
|
var _currentMediaInlineNo;
|
|
@@ -60,6 +60,8 @@ export class MediaPluginStateImplementation {
|
|
|
60
60
|
_defineProperty(this, "isResizing", false);
|
|
61
61
|
_defineProperty(this, "resizingWidth", 0);
|
|
62
62
|
_defineProperty(this, "allowInlineImages", false);
|
|
63
|
+
_defineProperty(this, "uploadInProgressSubscriptions", []);
|
|
64
|
+
_defineProperty(this, "uploadInProgressSubscriptionsNotified", false);
|
|
63
65
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
64
66
|
_defineProperty(this, "lastAddedMediaSingleFileIds", []);
|
|
65
67
|
_defineProperty(this, "destroyed", false);
|
|
@@ -179,6 +181,10 @@ export class MediaPluginStateImplementation {
|
|
|
179
181
|
allUploadsFinished: false
|
|
180
182
|
});
|
|
181
183
|
}
|
|
184
|
+
if (this.uploadInProgressSubscriptions.length > 0 && !this.uploadInProgressSubscriptionsNotified) {
|
|
185
|
+
this.uploadInProgressSubscriptions.forEach(fn => fn(true));
|
|
186
|
+
this.uploadInProgressSubscriptionsNotified = true;
|
|
187
|
+
}
|
|
182
188
|
switch (getMediaNodeInsertionType(state, this.mediaOptions, mediaStateWithContext.fileMimeType)) {
|
|
183
189
|
case 'inline':
|
|
184
190
|
insertMediaInlineNode(editorAnalyticsAPI)(this.view, mediaStateWithContext, collection, this.allowInlineImages, this.getInputMethod(pickerType));
|
|
@@ -221,6 +227,12 @@ export class MediaPluginStateImplementation {
|
|
|
221
227
|
if (!view.hasFocus()) {
|
|
222
228
|
view.focus();
|
|
223
229
|
}
|
|
230
|
+
this.waitForPendingTasks().then(() => {
|
|
231
|
+
if (this.uploadInProgressSubscriptions.length > 0 && this.uploadInProgressSubscriptionsNotified) {
|
|
232
|
+
this.uploadInProgressSubscriptions.forEach(fn => fn(false));
|
|
233
|
+
this.uploadInProgressSubscriptionsNotified = false;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
224
236
|
if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto')) {
|
|
225
237
|
this.selectLastAddedMediaNode();
|
|
226
238
|
}
|
|
@@ -452,6 +464,12 @@ export class MediaPluginStateImplementation {
|
|
|
452
464
|
}
|
|
453
465
|
});
|
|
454
466
|
}
|
|
467
|
+
subscribeToUploadInProgressState(fn) {
|
|
468
|
+
this.uploadInProgressSubscriptions.push(fn);
|
|
469
|
+
}
|
|
470
|
+
unsubscribeFromUploadInProgressState(fn) {
|
|
471
|
+
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(subscribedFn => subscribedFn !== fn);
|
|
472
|
+
}
|
|
455
473
|
setIsResizing(isResizing) {
|
|
456
474
|
this.isResizing = isResizing;
|
|
457
475
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
2
3
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
4
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
5
|
import { findParentNodeClosestToPos, isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
6
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
7
|
-
import { currentMediaInlineNodeWithPos
|
|
8
|
+
import { currentMediaInlineNodeWithPos } from '../utils/current-media-node';
|
|
8
9
|
import { isSelectionMediaSingleNode } from '../utils/media-common';
|
|
9
10
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
10
11
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
3
4
|
import { commentMessages as messages } from '@atlaskit/editor-common/media';
|
|
4
5
|
import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
5
|
-
export const commentButton = (intl, state,
|
|
6
|
+
export const commentButton = (intl, state, api) => {
|
|
6
7
|
const title = intl.formatMessage(messages.addCommentOnMedia);
|
|
7
|
-
const onClickHandler = () => {
|
|
8
|
+
const onClickHandler = (state, dispatch) => {
|
|
9
|
+
if (api && api.annotation) {
|
|
10
|
+
api.annotation.actions.setInlineCommentDraftState(true,
|
|
11
|
+
// TODO: might need to update to reflect it's from media floating toolbar
|
|
12
|
+
INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
13
|
+
}
|
|
8
14
|
return true;
|
|
9
15
|
};
|
|
10
16
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
2
|
+
import { currentMediaInlineNodeWithPos } from '../utils/current-media-node';
|
|
2
3
|
export function shouldShowImageBorder(editorState) {
|
|
3
4
|
const border = editorState.schema.marks.border;
|
|
4
5
|
if (!border) {
|
|
@@ -403,8 +403,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
403
403
|
});
|
|
404
404
|
}
|
|
405
405
|
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
406
|
-
|
|
407
|
-
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions), {
|
|
406
|
+
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
408
407
|
type: 'separator'
|
|
409
408
|
});
|
|
410
409
|
}
|
|
@@ -425,14 +424,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
425
424
|
};
|
|
426
425
|
const openLink = () => {
|
|
427
426
|
if (editorView) {
|
|
428
|
-
var _pluginInjectionApi$
|
|
427
|
+
var _pluginInjectionApi$a6;
|
|
429
428
|
const {
|
|
430
429
|
state: {
|
|
431
430
|
tr
|
|
432
431
|
},
|
|
433
432
|
dispatch
|
|
434
433
|
} = editorView;
|
|
435
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
434
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
436
435
|
eventType: EVENT_TYPE.TRACK,
|
|
437
436
|
action: ACTION.VISITED,
|
|
438
437
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -469,8 +468,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
469
468
|
}
|
|
470
469
|
}
|
|
471
470
|
if (allowAltTextOnImages) {
|
|
472
|
-
var _pluginInjectionApi$
|
|
473
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
471
|
+
var _pluginInjectionApi$a7;
|
|
472
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
474
473
|
type: 'separator'
|
|
475
474
|
});
|
|
476
475
|
}
|
|
@@ -557,14 +556,14 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
557
556
|
selectedNodeType = state.selection.node.type;
|
|
558
557
|
}
|
|
559
558
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
560
|
-
var _pluginInjectionApi$
|
|
559
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f3, _pluginInjectionApi$f4;
|
|
561
560
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
562
561
|
baseToolbar.getDomRef = () => {
|
|
563
562
|
var _mediaPluginState$ele;
|
|
564
563
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
565
564
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
566
565
|
};
|
|
567
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
566
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.actions) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.forceFocusSelector);
|
|
568
567
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
569
568
|
baseToolbar.getDomRef = () => {
|
|
570
569
|
var _mediaPluginState$ele2;
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
1
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export const currentMediaNodeWithPos = editorState => {
|
|
3
|
-
const {
|
|
4
|
-
doc,
|
|
5
|
-
selection,
|
|
6
|
-
schema
|
|
7
|
-
} = editorState;
|
|
8
|
-
if (!doc || !selection || !(selection instanceof NodeSelection) || selection.node.type !== schema.nodes.mediaSingle) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
const pos = selection.$anchor.pos + 1;
|
|
12
|
-
const node = doc.nodeAt(pos);
|
|
13
|
-
if (!node || node.type !== schema.nodes.media) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
node,
|
|
18
|
-
pos
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
3
|
export const currentMediaInlineNodeWithPos = editorState => {
|
|
22
4
|
const {
|
|
23
5
|
doc,
|
|
@@ -72,6 +72,8 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
72
72
|
_defineProperty(this, "isResizing", false);
|
|
73
73
|
_defineProperty(this, "resizingWidth", 0);
|
|
74
74
|
_defineProperty(this, "allowInlineImages", false);
|
|
75
|
+
_defineProperty(this, "uploadInProgressSubscriptions", []);
|
|
76
|
+
_defineProperty(this, "uploadInProgressSubscriptionsNotified", false);
|
|
75
77
|
// this is only a temporary variable, which gets cleared after the last inserted node has been selected
|
|
76
78
|
_defineProperty(this, "lastAddedMediaSingleFileIds", []);
|
|
77
79
|
_defineProperty(this, "destroyed", false);
|
|
@@ -216,6 +218,12 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
216
218
|
allUploadsFinished: false
|
|
217
219
|
});
|
|
218
220
|
}
|
|
221
|
+
if (_this.uploadInProgressSubscriptions.length > 0 && !_this.uploadInProgressSubscriptionsNotified) {
|
|
222
|
+
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
223
|
+
return fn(true);
|
|
224
|
+
});
|
|
225
|
+
_this.uploadInProgressSubscriptionsNotified = true;
|
|
226
|
+
}
|
|
219
227
|
switch (getMediaNodeInsertionType(state, _this.mediaOptions, mediaStateWithContext.fileMimeType)) {
|
|
220
228
|
case 'inline':
|
|
221
229
|
insertMediaInlineNode(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.allowInlineImages, _this.getInputMethod(pickerType));
|
|
@@ -258,6 +266,14 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
258
266
|
if (!view.hasFocus()) {
|
|
259
267
|
view.focus();
|
|
260
268
|
}
|
|
269
|
+
_this.waitForPendingTasks().then(function () {
|
|
270
|
+
if (_this.uploadInProgressSubscriptions.length > 0 && _this.uploadInProgressSubscriptionsNotified) {
|
|
271
|
+
_this.uploadInProgressSubscriptions.forEach(function (fn) {
|
|
272
|
+
return fn(false);
|
|
273
|
+
});
|
|
274
|
+
_this.uploadInProgressSubscriptionsNotified = false;
|
|
275
|
+
}
|
|
276
|
+
});
|
|
261
277
|
if (getBooleanFF('platform.editor.media.autoselect-inserted-image_oumto')) {
|
|
262
278
|
_this.selectLastAddedMediaNode();
|
|
263
279
|
}
|
|
@@ -492,6 +508,18 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
492
508
|
}
|
|
493
509
|
});
|
|
494
510
|
}
|
|
511
|
+
}, {
|
|
512
|
+
key: "subscribeToUploadInProgressState",
|
|
513
|
+
value: function subscribeToUploadInProgressState(fn) {
|
|
514
|
+
this.uploadInProgressSubscriptions.push(fn);
|
|
515
|
+
}
|
|
516
|
+
}, {
|
|
517
|
+
key: "unsubscribeFromUploadInProgressState",
|
|
518
|
+
value: function unsubscribeFromUploadInProgressState(fn) {
|
|
519
|
+
this.uploadInProgressSubscriptions = this.uploadInProgressSubscriptions.filter(function (subscribedFn) {
|
|
520
|
+
return subscribedFn !== fn;
|
|
521
|
+
});
|
|
522
|
+
}
|
|
495
523
|
}, {
|
|
496
524
|
key: "setIsResizing",
|
|
497
525
|
value: function setIsResizing(isResizing) {
|
|
@@ -2,12 +2,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
5
6
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
7
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import { findParentNodeClosestToPos, isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
9
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
10
|
-
import { currentMediaInlineNodeWithPos
|
|
11
|
+
import { currentMediaInlineNodeWithPos } from '../utils/current-media-node';
|
|
11
12
|
import { isSelectionMediaSingleNode } from '../utils/media-common';
|
|
12
13
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
13
14
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
|
|
3
4
|
import { commentMessages as messages } from '@atlaskit/editor-common/media';
|
|
4
5
|
import CommentIcon from '@atlaskit/icon/glyph/comment';
|
|
5
|
-
export var commentButton = function commentButton(intl, state,
|
|
6
|
+
export var commentButton = function commentButton(intl, state, api) {
|
|
6
7
|
var title = intl.formatMessage(messages.addCommentOnMedia);
|
|
7
|
-
var onClickHandler = function onClickHandler() {
|
|
8
|
+
var onClickHandler = function onClickHandler(state, dispatch) {
|
|
9
|
+
if (api && api.annotation) {
|
|
10
|
+
api.annotation.actions.setInlineCommentDraftState(true,
|
|
11
|
+
// TODO: might need to update to reflect it's from media floating toolbar
|
|
12
|
+
INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
|
|
13
|
+
}
|
|
8
14
|
return true;
|
|
9
15
|
};
|
|
10
16
|
return {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
2
|
+
import { currentMediaInlineNodeWithPos } from '../utils/current-media-node';
|
|
2
3
|
export function shouldShowImageBorder(editorState) {
|
|
3
4
|
var border = editorState.schema.marks.border;
|
|
4
5
|
if (!border) {
|
|
@@ -396,8 +396,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
396
396
|
});
|
|
397
397
|
}
|
|
398
398
|
if (editorFeatureFlags && editorFeatureFlags.commentsOnMedia) {
|
|
399
|
-
|
|
400
|
-
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions), {
|
|
399
|
+
toolbarButtons.push(commentButton(intl, state, pluginInjectionApi), {
|
|
401
400
|
type: 'separator'
|
|
402
401
|
});
|
|
403
402
|
}
|
|
@@ -416,10 +415,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
416
415
|
};
|
|
417
416
|
var openLink = function openLink() {
|
|
418
417
|
if (editorView) {
|
|
419
|
-
var _pluginInjectionApi$
|
|
418
|
+
var _pluginInjectionApi$a6;
|
|
420
419
|
var tr = editorView.state.tr,
|
|
421
420
|
dispatch = editorView.dispatch;
|
|
422
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
421
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
423
422
|
eventType: EVENT_TYPE.TRACK,
|
|
424
423
|
action: ACTION.VISITED,
|
|
425
424
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -456,8 +455,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
456
455
|
}
|
|
457
456
|
}
|
|
458
457
|
if (allowAltTextOnImages) {
|
|
459
|
-
var _pluginInjectionApi$
|
|
460
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
458
|
+
var _pluginInjectionApi$a7;
|
|
459
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
461
460
|
type: 'separator'
|
|
462
461
|
});
|
|
463
462
|
}
|
|
@@ -546,14 +545,14 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
546
545
|
selectedNodeType = state.selection.node.type;
|
|
547
546
|
}
|
|
548
547
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
549
|
-
var _pluginInjectionApi$
|
|
548
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f2;
|
|
550
549
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
551
550
|
baseToolbar.getDomRef = function () {
|
|
552
551
|
var _mediaPluginState$ele;
|
|
553
552
|
var selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
554
553
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
555
554
|
};
|
|
556
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
555
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector);
|
|
557
556
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
558
557
|
baseToolbar.getDomRef = function () {
|
|
559
558
|
var _mediaPluginState$ele2;
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
+
import { currentMediaNodeWithPos } from '@atlaskit/editor-common/media-single';
|
|
1
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
export var currentMediaNodeWithPos = function currentMediaNodeWithPos(editorState) {
|
|
3
|
-
var doc = editorState.doc,
|
|
4
|
-
selection = editorState.selection,
|
|
5
|
-
schema = editorState.schema;
|
|
6
|
-
if (!doc || !selection || !(selection instanceof NodeSelection) || selection.node.type !== schema.nodes.mediaSingle) {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
var pos = selection.$anchor.pos + 1;
|
|
10
|
-
var node = doc.nodeAt(pos);
|
|
11
|
-
if (!node || node.type !== schema.nodes.media) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
node: node,
|
|
16
|
-
pos: pos
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
3
|
export var currentMediaInlineNodeWithPos = function currentMediaInlineNodeWithPos(editorState) {
|
|
20
4
|
var doc = editorState.doc,
|
|
21
5
|
selection = editorState.selection,
|
|
@@ -37,6 +37,10 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
37
37
|
resizingWidth: number;
|
|
38
38
|
currentMaxWidth?: number;
|
|
39
39
|
allowInlineImages: boolean;
|
|
40
|
+
uploadInProgressSubscriptions: {
|
|
41
|
+
(isUploading: boolean): void;
|
|
42
|
+
}[];
|
|
43
|
+
uploadInProgressSubscriptionsNotified: boolean;
|
|
40
44
|
lastAddedMediaSingleFileIds: {
|
|
41
45
|
id: string;
|
|
42
46
|
selectionPosition: number;
|
|
@@ -60,6 +64,8 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
60
64
|
singletonCreatedAt: number;
|
|
61
65
|
constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
|
|
62
66
|
clone(): this;
|
|
67
|
+
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
68
|
+
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
63
69
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
64
70
|
getMediaOptions: () => MediaPluginOptions;
|
|
65
71
|
setIsResizing(isResizing: boolean): void;
|
|
@@ -66,5 +66,7 @@ export interface MediaPluginState {
|
|
|
66
66
|
destroy(): void;
|
|
67
67
|
updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
|
|
68
68
|
clone(): MediaPluginState;
|
|
69
|
+
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
70
|
+
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
69
71
|
}
|
|
70
72
|
export type EventInput = 'keyboard' | 'mouse' | 'floatingToolBar';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Command, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
|
|
4
|
+
import type { MediaNextEditorPluginType } from '../next-plugin-type';
|
|
5
|
+
export declare const commentButton: (intl: IntlShape, state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { BorderMarkAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export declare const currentMediaNodeWithPos: (editorState: EditorState) => {
|
|
5
|
-
node: PMNode;
|
|
6
|
-
pos: number;
|
|
7
|
-
} | undefined;
|
|
8
4
|
export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) => {
|
|
9
5
|
node: PMNode;
|
|
10
6
|
pos: number;
|
|
@@ -37,6 +37,10 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
37
37
|
resizingWidth: number;
|
|
38
38
|
currentMaxWidth?: number;
|
|
39
39
|
allowInlineImages: boolean;
|
|
40
|
+
uploadInProgressSubscriptions: {
|
|
41
|
+
(isUploading: boolean): void;
|
|
42
|
+
}[];
|
|
43
|
+
uploadInProgressSubscriptionsNotified: boolean;
|
|
40
44
|
lastAddedMediaSingleFileIds: {
|
|
41
45
|
id: string;
|
|
42
46
|
selectionPosition: number;
|
|
@@ -60,6 +64,8 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
60
64
|
singletonCreatedAt: number;
|
|
61
65
|
constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
|
|
62
66
|
clone(): this;
|
|
67
|
+
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
68
|
+
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
63
69
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
64
70
|
getMediaOptions: () => MediaPluginOptions;
|
|
65
71
|
setIsResizing(isResizing: boolean): void;
|
|
@@ -66,5 +66,7 @@ export interface MediaPluginState {
|
|
|
66
66
|
destroy(): void;
|
|
67
67
|
updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
|
|
68
68
|
clone(): MediaPluginState;
|
|
69
|
+
subscribeToUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
70
|
+
unsubscribeFromUploadInProgressState(fn: (isUploading: boolean) => void): void;
|
|
69
71
|
}
|
|
70
72
|
export type EventInput = 'keyboard' | 'mouse' | 'floatingToolBar';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Command, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
|
|
4
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
|
|
4
|
+
import type { MediaNextEditorPluginType } from '../next-plugin-type';
|
|
5
|
+
export declare const commentButton: (intl: IntlShape, state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { BorderMarkAttributes } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
export declare const currentMediaNodeWithPos: (editorState: EditorState) => {
|
|
5
|
-
node: PMNode;
|
|
6
|
-
pos: number;
|
|
7
|
-
} | undefined;
|
|
8
4
|
export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) => {
|
|
9
5
|
node: PMNode;
|
|
10
6
|
pos: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.1",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@atlaskit/editor-common": "^78.11.0",
|
|
41
41
|
"@atlaskit/editor-palette": "1.5.2",
|
|
42
42
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
43
|
-
"@atlaskit/editor-plugin-annotation": "1.1
|
|
43
|
+
"@atlaskit/editor-plugin-annotation": "1.2.1",
|
|
44
44
|
"@atlaskit/editor-plugin-decorations": "^1.0.0",
|
|
45
45
|
"@atlaskit/editor-plugin-editor-disabled": "^1.0.0",
|
|
46
46
|
"@atlaskit/editor-plugin-floating-toolbar": "^1.2.0",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"@atlaskit/media-common": "^11.0.0",
|
|
61
61
|
"@atlaskit/media-filmstrip": "^47.0.0",
|
|
62
62
|
"@atlaskit/media-picker": "^66.3.0",
|
|
63
|
-
"@atlaskit/media-ui": "^25.
|
|
63
|
+
"@atlaskit/media-ui": "^25.4.0",
|
|
64
64
|
"@atlaskit/media-viewer": "^48.3.0",
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
66
66
|
"@atlaskit/primitives": "^4.0.0",
|