@atlaskit/editor-plugin-media 0.12.0 → 0.12.2
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 +13 -0
- package/dist/cjs/pm-plugins/main.js +46 -64
- package/dist/cjs/toolbar/commands.js +24 -4
- package/dist/es2019/pm-plugins/main.js +4 -6
- package/dist/es2019/toolbar/commands.js +25 -5
- package/dist/esm/pm-plugins/main.js +46 -64
- package/dist/esm/toolbar/commands.js +25 -5
- package/dist/types/next-plugin-type.d.ts +2 -0
- package/dist/types/pm-plugins/main.d.ts +2 -3
- package/dist/types/pm-plugins/types.d.ts +1 -2
- package/dist/types-ts4.5/next-plugin-type.d.ts +2 -0
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -3
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -2
- package/package.json +12 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.12.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#68640](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/68640) [`6a3ea210641a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/6a3ea210641a) - Create new context identifier plugin which contains the provider.
|
|
8
|
+
|
|
9
|
+
## 0.12.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#66027](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/66027) [`9e0417874343`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9e0417874343) - [CXP-2867] Fix superfluous newline in inline-to-card conversion
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 0.12.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -91,37 +91,14 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
91
91
|
(0, _defineProperty2.default)(this, "taskManager", new _mediaTaskManager.MediaTaskManager());
|
|
92
92
|
(0, _defineProperty2.default)(this, "pickers", []);
|
|
93
93
|
(0, _defineProperty2.default)(this, "pickerPromises", []);
|
|
94
|
-
(0, _defineProperty2.default)(this, "onContextIdentifierProvider", /*#__PURE__*/function () {
|
|
95
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_name, provider) {
|
|
96
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
97
|
-
while (1) switch (_context.prev = _context.next) {
|
|
98
|
-
case 0:
|
|
99
|
-
if (!provider) {
|
|
100
|
-
_context.next = 4;
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
_context.next = 3;
|
|
104
|
-
return provider;
|
|
105
|
-
case 3:
|
|
106
|
-
_this.contextIdentifierProvider = _context.sent;
|
|
107
|
-
case 4:
|
|
108
|
-
case "end":
|
|
109
|
-
return _context.stop();
|
|
110
|
-
}
|
|
111
|
-
}, _callee);
|
|
112
|
-
}));
|
|
113
|
-
return function (_x, _x2) {
|
|
114
|
-
return _ref.apply(this, arguments);
|
|
115
|
-
};
|
|
116
|
-
}());
|
|
117
94
|
(0, _defineProperty2.default)(this, "setMediaProvider", /*#__PURE__*/function () {
|
|
118
|
-
var
|
|
95
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(mediaProvider) {
|
|
119
96
|
var viewMediaClientConfig, wrappedError, view, allowsUploads;
|
|
120
|
-
return _regenerator.default.wrap(function
|
|
121
|
-
while (1) switch (
|
|
97
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
98
|
+
while (1) switch (_context.prev = _context.next) {
|
|
122
99
|
case 0:
|
|
123
100
|
if (mediaProvider) {
|
|
124
|
-
|
|
101
|
+
_context.next = 5;
|
|
125
102
|
break;
|
|
126
103
|
}
|
|
127
104
|
_this.destroyPickers();
|
|
@@ -131,13 +108,13 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
131
108
|
allowsUploads: _this.allowsUploads
|
|
132
109
|
}));
|
|
133
110
|
}
|
|
134
|
-
return
|
|
111
|
+
return _context.abrupt("return");
|
|
135
112
|
case 5:
|
|
136
|
-
|
|
137
|
-
|
|
113
|
+
_context.prev = 5;
|
|
114
|
+
_context.next = 8;
|
|
138
115
|
return mediaProvider;
|
|
139
116
|
case 8:
|
|
140
|
-
_this.mediaProvider =
|
|
117
|
+
_this.mediaProvider = _context.sent;
|
|
141
118
|
// TODO [MS-2038]: remove once context api is removed
|
|
142
119
|
// We want to re assign the view and upload configs if they are missing for backwards compatibility
|
|
143
120
|
// as currently integrators can pass context || mediaClientConfig
|
|
@@ -148,12 +125,12 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
148
125
|
}
|
|
149
126
|
}
|
|
150
127
|
(0, _assert.default)(_this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(_this.mediaProvider));
|
|
151
|
-
|
|
128
|
+
_context.next = 21;
|
|
152
129
|
break;
|
|
153
130
|
case 13:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(
|
|
131
|
+
_context.prev = 13;
|
|
132
|
+
_context.t0 = _context["catch"](5);
|
|
133
|
+
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
157
134
|
_this.errorReporter.captureException(wrappedError);
|
|
158
135
|
_this.destroyPickers();
|
|
159
136
|
_this.allowsUploads = false;
|
|
@@ -162,7 +139,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
162
139
|
allowsUploads: _this.allowsUploads
|
|
163
140
|
}));
|
|
164
141
|
}
|
|
165
|
-
return
|
|
142
|
+
return _context.abrupt("return");
|
|
166
143
|
case 21:
|
|
167
144
|
_this.mediaClientConfig = _this.mediaProvider.viewMediaClientConfig;
|
|
168
145
|
_this.allowsUploads = !!_this.mediaProvider.uploadMediaClientConfig;
|
|
@@ -174,42 +151,42 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
174
151
|
}));
|
|
175
152
|
}
|
|
176
153
|
if (!_this.allowsUploads) {
|
|
177
|
-
|
|
154
|
+
_context.next = 35;
|
|
178
155
|
break;
|
|
179
156
|
}
|
|
180
157
|
_this.uploadMediaClientConfig = _this.mediaProvider.uploadMediaClientConfig;
|
|
181
158
|
if (!(_this.mediaProvider.uploadParams && _this.uploadMediaClientConfig)) {
|
|
182
|
-
|
|
159
|
+
_context.next = 32;
|
|
183
160
|
break;
|
|
184
161
|
}
|
|
185
|
-
|
|
162
|
+
_context.next = 30;
|
|
186
163
|
return _this.initPickers(_this.mediaProvider.uploadParams, _pickerFacade.default);
|
|
187
164
|
case 30:
|
|
188
|
-
|
|
165
|
+
_context.next = 33;
|
|
189
166
|
break;
|
|
190
167
|
case 32:
|
|
191
168
|
_this.destroyPickers();
|
|
192
169
|
case 33:
|
|
193
|
-
|
|
170
|
+
_context.next = 36;
|
|
194
171
|
break;
|
|
195
172
|
case 35:
|
|
196
173
|
_this.destroyPickers();
|
|
197
174
|
case 36:
|
|
198
175
|
case "end":
|
|
199
|
-
return
|
|
176
|
+
return _context.stop();
|
|
200
177
|
}
|
|
201
|
-
},
|
|
178
|
+
}, _callee, null, [[5, 13]]);
|
|
202
179
|
}));
|
|
203
|
-
return function (
|
|
204
|
-
return
|
|
180
|
+
return function (_x) {
|
|
181
|
+
return _ref.apply(this, arguments);
|
|
205
182
|
};
|
|
206
183
|
}());
|
|
207
184
|
(0, _defineProperty2.default)(this, "getMediaOptions", function () {
|
|
208
185
|
return _this.options;
|
|
209
186
|
});
|
|
210
|
-
(0, _defineProperty2.default)(this, "isMediaSchemaNode", function (
|
|
187
|
+
(0, _defineProperty2.default)(this, "isMediaSchemaNode", function (_ref2) {
|
|
211
188
|
var _this$mediaOptions;
|
|
212
|
-
var type =
|
|
189
|
+
var type = _ref2.type;
|
|
213
190
|
var _this$view$state$sche = _this.view.state.schema.nodes,
|
|
214
191
|
mediaInline = _this$view$state$sche.mediaInline,
|
|
215
192
|
mediaSingle = _this$view$state$sche.mediaSingle,
|
|
@@ -362,8 +339,8 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
362
339
|
*/
|
|
363
340
|
(0, _defineProperty2.default)(this, "handleMediaNodeUnmount", function (oldNode) {
|
|
364
341
|
_this.trackMediaNodeRemoval(oldNode);
|
|
365
|
-
_this.mediaNodes = _this.mediaNodes.filter(function (
|
|
366
|
-
var node =
|
|
342
|
+
_this.mediaNodes = _this.mediaNodes.filter(function (_ref3) {
|
|
343
|
+
var node = _ref3.node;
|
|
367
344
|
return oldNode !== node;
|
|
368
345
|
});
|
|
369
346
|
});
|
|
@@ -497,7 +474,6 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
497
474
|
options.providerFactory.subscribe('mediaProvider', function (_name, provider) {
|
|
498
475
|
return _this.setMediaProvider(provider);
|
|
499
476
|
});
|
|
500
|
-
options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
|
|
501
477
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support')) {
|
|
502
478
|
this.allowInlineImages = true;
|
|
503
479
|
}
|
|
@@ -563,6 +539,12 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
563
539
|
}
|
|
564
540
|
return;
|
|
565
541
|
}
|
|
542
|
+
}, {
|
|
543
|
+
key: "contextIdentifierProvider",
|
|
544
|
+
get: function get() {
|
|
545
|
+
var _this$pluginInjection3;
|
|
546
|
+
return (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.contextIdentifier) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.sharedState.currentState()) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.contextIdentifierProvider;
|
|
547
|
+
}
|
|
566
548
|
}, {
|
|
567
549
|
key: "setView",
|
|
568
550
|
value: function setView(view) {
|
|
@@ -583,21 +565,21 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
583
565
|
}, {
|
|
584
566
|
key: "initPickers",
|
|
585
567
|
value: function () {
|
|
586
|
-
var _initPickers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
568
|
+
var _initPickers = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(uploadParams, Picker) {
|
|
587
569
|
var _this2 = this;
|
|
588
570
|
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker;
|
|
589
|
-
return _regenerator.default.wrap(function
|
|
590
|
-
while (1) switch (
|
|
571
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
572
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
591
573
|
case 0:
|
|
592
574
|
if (!(this.destroyed || !this.uploadMediaClientConfig)) {
|
|
593
|
-
|
|
575
|
+
_context2.next = 2;
|
|
594
576
|
break;
|
|
595
577
|
}
|
|
596
|
-
return
|
|
578
|
+
return _context2.abrupt("return");
|
|
597
579
|
case 2:
|
|
598
580
|
errorReporter = this.errorReporter, pickers = this.pickers, pickerPromises = this.pickerPromises; // create pickers if they don't exist, re-use otherwise
|
|
599
581
|
if (pickers.length) {
|
|
600
|
-
|
|
582
|
+
_context2.next = 14;
|
|
601
583
|
break;
|
|
602
584
|
}
|
|
603
585
|
pickerFacadeConfig = {
|
|
@@ -605,17 +587,17 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
605
587
|
errorReporter: errorReporter
|
|
606
588
|
};
|
|
607
589
|
if (!this.options.customMediaPicker) {
|
|
608
|
-
|
|
590
|
+
_context2.next = 13;
|
|
609
591
|
break;
|
|
610
592
|
}
|
|
611
593
|
customPicker = new Picker('customMediaPicker', pickerFacadeConfig, this.options.customMediaPicker).init();
|
|
612
594
|
pickerPromises.push(customPicker);
|
|
613
|
-
|
|
614
|
-
|
|
595
|
+
_context2.t0 = pickers;
|
|
596
|
+
_context2.next = 11;
|
|
615
597
|
return customPicker;
|
|
616
598
|
case 11:
|
|
617
|
-
|
|
618
|
-
|
|
599
|
+
_context2.t1 = this.customPicker = _context2.sent;
|
|
600
|
+
_context2.t0.push.call(_context2.t0, _context2.t1);
|
|
619
601
|
case 13:
|
|
620
602
|
pickers.forEach(function (picker) {
|
|
621
603
|
picker.onNewMedia(_this2.insertFile);
|
|
@@ -627,11 +609,11 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
627
609
|
});
|
|
628
610
|
case 15:
|
|
629
611
|
case "end":
|
|
630
|
-
return
|
|
612
|
+
return _context2.stop();
|
|
631
613
|
}
|
|
632
|
-
},
|
|
614
|
+
}, _callee2, this);
|
|
633
615
|
}));
|
|
634
|
-
function initPickers(
|
|
616
|
+
function initPickers(_x2, _x3) {
|
|
635
617
|
return _initPickers.apply(this, arguments);
|
|
636
618
|
}
|
|
637
619
|
return initPickers;
|
|
@@ -28,10 +28,13 @@ var getNodeType = exports.getNodeType = function getNodeType(state) {
|
|
|
28
28
|
};
|
|
29
29
|
var changeInlineToMediaCard = exports.changeInlineToMediaCard = function changeInlineToMediaCard(editorAnalyticsAPI, forceFocusSelector) {
|
|
30
30
|
return function (state, dispatch) {
|
|
31
|
+
var _findParentNodeCloses, _parent$content$first, _parent$content$lastC, _parent$content$lastC2;
|
|
31
32
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
32
33
|
media = _state$schema$nodes2.media,
|
|
33
34
|
mediaInline = _state$schema$nodes2.mediaInline,
|
|
34
|
-
mediaGroup = _state$schema$nodes2.mediaGroup
|
|
35
|
+
mediaGroup = _state$schema$nodes2.mediaGroup,
|
|
36
|
+
paragraph = _state$schema$nodes2.paragraph,
|
|
37
|
+
heading = _state$schema$nodes2.heading;
|
|
35
38
|
var selectedNode = state.selection instanceof _state.NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
36
39
|
if (!selectedNode) {
|
|
37
40
|
return false;
|
|
@@ -46,10 +49,26 @@ var changeInlineToMediaCard = exports.changeInlineToMediaCard = function changeI
|
|
|
46
49
|
collection: collection
|
|
47
50
|
});
|
|
48
51
|
var group = mediaGroup.createChecked({}, mediaNode);
|
|
49
|
-
var
|
|
52
|
+
var parent = (_findParentNodeCloses = (0, _utils.findParentNodeClosestToPos)(state.selection.$from, function (node) {
|
|
53
|
+
return node.type === paragraph || node.type === heading;
|
|
54
|
+
})) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
|
|
50
55
|
var tr = state.tr;
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
if (!!parent && parent.content.size === 2 && ((_parent$content$first = parent.content.firstChild) === null || _parent$content$first === void 0 ? void 0 : _parent$content$first.type.name) === 'mediaInline' && ((_parent$content$lastC = parent.content.lastChild) === null || _parent$content$lastC === void 0 ? void 0 : _parent$content$lastC.type.name) === 'text' && ((_parent$content$lastC2 = parent.content.lastChild) === null || _parent$content$lastC2 === void 0 || (_parent$content$lastC2 = _parent$content$lastC2.text) === null || _parent$content$lastC2 === void 0 ? void 0 : _parent$content$lastC2.trim()) === '') {
|
|
57
|
+
/// Empty paragraph or empty heading
|
|
58
|
+
/// Drop the corresponding card on the current line
|
|
59
|
+
var insertPos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
60
|
+
if (insertPos < 0) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
tr = tr.delete(insertPos, insertPos + parent.nodeSize);
|
|
64
|
+
tr = (0, _utils.safeInsert)(group, insertPos, false)(tr);
|
|
65
|
+
} else {
|
|
66
|
+
/// Non-empty paragraph, non-empty heading, or other nodes (e.g., action, list)
|
|
67
|
+
/// Drop the corresponding card underneath the current line
|
|
68
|
+
var _insertPos = state.tr.doc.resolve(state.selection.from).end();
|
|
69
|
+
tr = (0, _utils.removeSelectedNode)(tr);
|
|
70
|
+
tr = (0, _utils.safeInsert)(group, _insertPos, false)(tr);
|
|
71
|
+
}
|
|
53
72
|
if (dispatch) {
|
|
54
73
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
55
74
|
action: _analytics.ACTION.CHANGED_TYPE,
|
|
@@ -60,6 +79,7 @@ var changeInlineToMediaCard = exports.changeInlineToMediaCard = function changeI
|
|
|
60
79
|
previousType: _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE
|
|
61
80
|
}
|
|
62
81
|
})(tr);
|
|
82
|
+
var nodePos = state.tr.doc.resolve(state.selection.from).end();
|
|
63
83
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.ally-media-file-dropdown_1kxo8')) {
|
|
64
84
|
var $endOfNode = tr.doc.resolve(nodePos + 1);
|
|
65
85
|
var newSelection = new _state.NodeSelection($endOfNode);
|
|
@@ -65,11 +65,6 @@ export class MediaPluginStateImplementation {
|
|
|
65
65
|
_defineProperty(this, "taskManager", new MediaTaskManager());
|
|
66
66
|
_defineProperty(this, "pickers", []);
|
|
67
67
|
_defineProperty(this, "pickerPromises", []);
|
|
68
|
-
_defineProperty(this, "onContextIdentifierProvider", async (_name, provider) => {
|
|
69
|
-
if (provider) {
|
|
70
|
-
this.contextIdentifierProvider = await provider;
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
68
|
_defineProperty(this, "setMediaProvider", async mediaProvider => {
|
|
74
69
|
if (!mediaProvider) {
|
|
75
70
|
this.destroyPickers();
|
|
@@ -427,7 +422,6 @@ export class MediaPluginStateImplementation {
|
|
|
427
422
|
} = _state.schema;
|
|
428
423
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|
|
429
424
|
options.providerFactory.subscribe('mediaProvider', (_name, provider) => this.setMediaProvider(provider));
|
|
430
|
-
options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
|
|
431
425
|
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
432
426
|
this.allowInlineImages = true;
|
|
433
427
|
}
|
|
@@ -485,6 +479,10 @@ export class MediaPluginStateImplementation {
|
|
|
485
479
|
}
|
|
486
480
|
return;
|
|
487
481
|
}
|
|
482
|
+
get contextIdentifierProvider() {
|
|
483
|
+
var _this$pluginInjection5, _this$pluginInjection6, _this$pluginInjection7;
|
|
484
|
+
return (_this$pluginInjection5 = this.pluginInjectionApi) === null || _this$pluginInjection5 === void 0 ? void 0 : (_this$pluginInjection6 = _this$pluginInjection5.contextIdentifier) === null || _this$pluginInjection6 === void 0 ? void 0 : (_this$pluginInjection7 = _this$pluginInjection6.sharedState.currentState()) === null || _this$pluginInjection7 === void 0 ? void 0 : _this$pluginInjection7.contextIdentifierProvider;
|
|
485
|
+
}
|
|
488
486
|
setView(view) {
|
|
489
487
|
this.view = view;
|
|
490
488
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { findParentNodeClosestToPos, isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
7
7
|
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
@@ -18,10 +18,13 @@ export const getNodeType = state => {
|
|
|
18
18
|
return isSelectionMediaSingleNode(state) ? mediaSingle.name : mediaInline.name;
|
|
19
19
|
};
|
|
20
20
|
export const changeInlineToMediaCard = (editorAnalyticsAPI, forceFocusSelector) => (state, dispatch) => {
|
|
21
|
+
var _findParentNodeCloses, _parent$content$first, _parent$content$lastC, _parent$content$lastC2, _parent$content$lastC3;
|
|
21
22
|
const {
|
|
22
23
|
media,
|
|
23
24
|
mediaInline,
|
|
24
|
-
mediaGroup
|
|
25
|
+
mediaGroup,
|
|
26
|
+
paragraph,
|
|
27
|
+
heading
|
|
25
28
|
} = state.schema.nodes;
|
|
26
29
|
const selectedNode = state.selection instanceof NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
27
30
|
if (!selectedNode) {
|
|
@@ -38,10 +41,26 @@ export const changeInlineToMediaCard = (editorAnalyticsAPI, forceFocusSelector)
|
|
|
38
41
|
collection
|
|
39
42
|
});
|
|
40
43
|
const group = mediaGroup.createChecked({}, mediaNode);
|
|
41
|
-
const
|
|
44
|
+
const parent = (_findParentNodeCloses = findParentNodeClosestToPos(state.selection.$from, node => {
|
|
45
|
+
return node.type === paragraph || node.type === heading;
|
|
46
|
+
})) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
|
|
42
47
|
let tr = state.tr;
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
if (!!parent && parent.content.size === 2 && ((_parent$content$first = parent.content.firstChild) === null || _parent$content$first === void 0 ? void 0 : _parent$content$first.type.name) === 'mediaInline' && ((_parent$content$lastC = parent.content.lastChild) === null || _parent$content$lastC === void 0 ? void 0 : _parent$content$lastC.type.name) === 'text' && ((_parent$content$lastC2 = parent.content.lastChild) === null || _parent$content$lastC2 === void 0 ? void 0 : (_parent$content$lastC3 = _parent$content$lastC2.text) === null || _parent$content$lastC3 === void 0 ? void 0 : _parent$content$lastC3.trim()) === '') {
|
|
49
|
+
/// Empty paragraph or empty heading
|
|
50
|
+
/// Drop the corresponding card on the current line
|
|
51
|
+
const insertPos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
52
|
+
if (insertPos < 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
tr = tr.delete(insertPos, insertPos + parent.nodeSize);
|
|
56
|
+
tr = safeInsert(group, insertPos, false)(tr);
|
|
57
|
+
} else {
|
|
58
|
+
/// Non-empty paragraph, non-empty heading, or other nodes (e.g., action, list)
|
|
59
|
+
/// Drop the corresponding card underneath the current line
|
|
60
|
+
const insertPos = state.tr.doc.resolve(state.selection.from).end();
|
|
61
|
+
tr = removeSelectedNode(tr);
|
|
62
|
+
tr = safeInsert(group, insertPos, false)(tr);
|
|
63
|
+
}
|
|
45
64
|
if (dispatch) {
|
|
46
65
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
47
66
|
action: ACTION.CHANGED_TYPE,
|
|
@@ -52,6 +71,7 @@ export const changeInlineToMediaCard = (editorAnalyticsAPI, forceFocusSelector)
|
|
|
52
71
|
previousType: ACTION_SUBJECT_ID.MEDIA_INLINE
|
|
53
72
|
}
|
|
54
73
|
})(tr);
|
|
74
|
+
const nodePos = state.tr.doc.resolve(state.selection.from).end();
|
|
55
75
|
if (getBooleanFF('platform.editor.ally-media-file-dropdown_1kxo8')) {
|
|
56
76
|
const $endOfNode = tr.doc.resolve(nodePos + 1);
|
|
57
77
|
const newSelection = new NodeSelection($endOfNode);
|
|
@@ -76,37 +76,14 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
76
76
|
_defineProperty(this, "taskManager", new MediaTaskManager());
|
|
77
77
|
_defineProperty(this, "pickers", []);
|
|
78
78
|
_defineProperty(this, "pickerPromises", []);
|
|
79
|
-
_defineProperty(this, "onContextIdentifierProvider", /*#__PURE__*/function () {
|
|
80
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_name, provider) {
|
|
81
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
82
|
-
while (1) switch (_context.prev = _context.next) {
|
|
83
|
-
case 0:
|
|
84
|
-
if (!provider) {
|
|
85
|
-
_context.next = 4;
|
|
86
|
-
break;
|
|
87
|
-
}
|
|
88
|
-
_context.next = 3;
|
|
89
|
-
return provider;
|
|
90
|
-
case 3:
|
|
91
|
-
_this.contextIdentifierProvider = _context.sent;
|
|
92
|
-
case 4:
|
|
93
|
-
case "end":
|
|
94
|
-
return _context.stop();
|
|
95
|
-
}
|
|
96
|
-
}, _callee);
|
|
97
|
-
}));
|
|
98
|
-
return function (_x, _x2) {
|
|
99
|
-
return _ref.apply(this, arguments);
|
|
100
|
-
};
|
|
101
|
-
}());
|
|
102
79
|
_defineProperty(this, "setMediaProvider", /*#__PURE__*/function () {
|
|
103
|
-
var
|
|
80
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(mediaProvider) {
|
|
104
81
|
var viewMediaClientConfig, wrappedError, view, allowsUploads;
|
|
105
|
-
return _regeneratorRuntime.wrap(function
|
|
106
|
-
while (1) switch (
|
|
82
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
83
|
+
while (1) switch (_context.prev = _context.next) {
|
|
107
84
|
case 0:
|
|
108
85
|
if (mediaProvider) {
|
|
109
|
-
|
|
86
|
+
_context.next = 5;
|
|
110
87
|
break;
|
|
111
88
|
}
|
|
112
89
|
_this.destroyPickers();
|
|
@@ -116,13 +93,13 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
116
93
|
allowsUploads: _this.allowsUploads
|
|
117
94
|
}));
|
|
118
95
|
}
|
|
119
|
-
return
|
|
96
|
+
return _context.abrupt("return");
|
|
120
97
|
case 5:
|
|
121
|
-
|
|
122
|
-
|
|
98
|
+
_context.prev = 5;
|
|
99
|
+
_context.next = 8;
|
|
123
100
|
return mediaProvider;
|
|
124
101
|
case 8:
|
|
125
|
-
_this.mediaProvider =
|
|
102
|
+
_this.mediaProvider = _context.sent;
|
|
126
103
|
// TODO [MS-2038]: remove once context api is removed
|
|
127
104
|
// We want to re assign the view and upload configs if they are missing for backwards compatibility
|
|
128
105
|
// as currently integrators can pass context || mediaClientConfig
|
|
@@ -133,12 +110,12 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
133
110
|
}
|
|
134
111
|
}
|
|
135
112
|
assert(_this.mediaProvider.viewMediaClientConfig, "MediaProvider promise did not resolve to a valid instance of MediaProvider - ".concat(_this.mediaProvider));
|
|
136
|
-
|
|
113
|
+
_context.next = 21;
|
|
137
114
|
break;
|
|
138
115
|
case 13:
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(
|
|
116
|
+
_context.prev = 13;
|
|
117
|
+
_context.t0 = _context["catch"](5);
|
|
118
|
+
wrappedError = new Error("Media functionality disabled due to rejected provider: ".concat(_context.t0 instanceof Error ? _context.t0.message : String(_context.t0)));
|
|
142
119
|
_this.errorReporter.captureException(wrappedError);
|
|
143
120
|
_this.destroyPickers();
|
|
144
121
|
_this.allowsUploads = false;
|
|
@@ -147,7 +124,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
147
124
|
allowsUploads: _this.allowsUploads
|
|
148
125
|
}));
|
|
149
126
|
}
|
|
150
|
-
return
|
|
127
|
+
return _context.abrupt("return");
|
|
151
128
|
case 21:
|
|
152
129
|
_this.mediaClientConfig = _this.mediaProvider.viewMediaClientConfig;
|
|
153
130
|
_this.allowsUploads = !!_this.mediaProvider.uploadMediaClientConfig;
|
|
@@ -159,42 +136,42 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
159
136
|
}));
|
|
160
137
|
}
|
|
161
138
|
if (!_this.allowsUploads) {
|
|
162
|
-
|
|
139
|
+
_context.next = 35;
|
|
163
140
|
break;
|
|
164
141
|
}
|
|
165
142
|
_this.uploadMediaClientConfig = _this.mediaProvider.uploadMediaClientConfig;
|
|
166
143
|
if (!(_this.mediaProvider.uploadParams && _this.uploadMediaClientConfig)) {
|
|
167
|
-
|
|
144
|
+
_context.next = 32;
|
|
168
145
|
break;
|
|
169
146
|
}
|
|
170
|
-
|
|
147
|
+
_context.next = 30;
|
|
171
148
|
return _this.initPickers(_this.mediaProvider.uploadParams, PickerFacade);
|
|
172
149
|
case 30:
|
|
173
|
-
|
|
150
|
+
_context.next = 33;
|
|
174
151
|
break;
|
|
175
152
|
case 32:
|
|
176
153
|
_this.destroyPickers();
|
|
177
154
|
case 33:
|
|
178
|
-
|
|
155
|
+
_context.next = 36;
|
|
179
156
|
break;
|
|
180
157
|
case 35:
|
|
181
158
|
_this.destroyPickers();
|
|
182
159
|
case 36:
|
|
183
160
|
case "end":
|
|
184
|
-
return
|
|
161
|
+
return _context.stop();
|
|
185
162
|
}
|
|
186
|
-
},
|
|
163
|
+
}, _callee, null, [[5, 13]]);
|
|
187
164
|
}));
|
|
188
|
-
return function (
|
|
189
|
-
return
|
|
165
|
+
return function (_x) {
|
|
166
|
+
return _ref.apply(this, arguments);
|
|
190
167
|
};
|
|
191
168
|
}());
|
|
192
169
|
_defineProperty(this, "getMediaOptions", function () {
|
|
193
170
|
return _this.options;
|
|
194
171
|
});
|
|
195
|
-
_defineProperty(this, "isMediaSchemaNode", function (
|
|
172
|
+
_defineProperty(this, "isMediaSchemaNode", function (_ref2) {
|
|
196
173
|
var _this$mediaOptions;
|
|
197
|
-
var type =
|
|
174
|
+
var type = _ref2.type;
|
|
198
175
|
var _this$view$state$sche = _this.view.state.schema.nodes,
|
|
199
176
|
mediaInline = _this$view$state$sche.mediaInline,
|
|
200
177
|
mediaSingle = _this$view$state$sche.mediaSingle,
|
|
@@ -347,8 +324,8 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
347
324
|
*/
|
|
348
325
|
_defineProperty(this, "handleMediaNodeUnmount", function (oldNode) {
|
|
349
326
|
_this.trackMediaNodeRemoval(oldNode);
|
|
350
|
-
_this.mediaNodes = _this.mediaNodes.filter(function (
|
|
351
|
-
var node =
|
|
327
|
+
_this.mediaNodes = _this.mediaNodes.filter(function (_ref3) {
|
|
328
|
+
var node = _ref3.node;
|
|
352
329
|
return oldNode !== node;
|
|
353
330
|
});
|
|
354
331
|
});
|
|
@@ -482,7 +459,6 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
482
459
|
options.providerFactory.subscribe('mediaProvider', function (_name, provider) {
|
|
483
460
|
return _this.setMediaProvider(provider);
|
|
484
461
|
});
|
|
485
|
-
options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
|
|
486
462
|
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
487
463
|
this.allowInlineImages = true;
|
|
488
464
|
}
|
|
@@ -548,6 +524,12 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
548
524
|
}
|
|
549
525
|
return;
|
|
550
526
|
}
|
|
527
|
+
}, {
|
|
528
|
+
key: "contextIdentifierProvider",
|
|
529
|
+
get: function get() {
|
|
530
|
+
var _this$pluginInjection3;
|
|
531
|
+
return (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.contextIdentifier) === null || _this$pluginInjection3 === void 0 || (_this$pluginInjection3 = _this$pluginInjection3.sharedState.currentState()) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.contextIdentifierProvider;
|
|
532
|
+
}
|
|
551
533
|
}, {
|
|
552
534
|
key: "setView",
|
|
553
535
|
value: function setView(view) {
|
|
@@ -568,21 +550,21 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
568
550
|
}, {
|
|
569
551
|
key: "initPickers",
|
|
570
552
|
value: function () {
|
|
571
|
-
var _initPickers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
553
|
+
var _initPickers = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(uploadParams, Picker) {
|
|
572
554
|
var _this2 = this;
|
|
573
555
|
var errorReporter, pickers, pickerPromises, pickerFacadeConfig, customPicker;
|
|
574
|
-
return _regeneratorRuntime.wrap(function
|
|
575
|
-
while (1) switch (
|
|
556
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
557
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
576
558
|
case 0:
|
|
577
559
|
if (!(this.destroyed || !this.uploadMediaClientConfig)) {
|
|
578
|
-
|
|
560
|
+
_context2.next = 2;
|
|
579
561
|
break;
|
|
580
562
|
}
|
|
581
|
-
return
|
|
563
|
+
return _context2.abrupt("return");
|
|
582
564
|
case 2:
|
|
583
565
|
errorReporter = this.errorReporter, pickers = this.pickers, pickerPromises = this.pickerPromises; // create pickers if they don't exist, re-use otherwise
|
|
584
566
|
if (pickers.length) {
|
|
585
|
-
|
|
567
|
+
_context2.next = 14;
|
|
586
568
|
break;
|
|
587
569
|
}
|
|
588
570
|
pickerFacadeConfig = {
|
|
@@ -590,17 +572,17 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
590
572
|
errorReporter: errorReporter
|
|
591
573
|
};
|
|
592
574
|
if (!this.options.customMediaPicker) {
|
|
593
|
-
|
|
575
|
+
_context2.next = 13;
|
|
594
576
|
break;
|
|
595
577
|
}
|
|
596
578
|
customPicker = new Picker('customMediaPicker', pickerFacadeConfig, this.options.customMediaPicker).init();
|
|
597
579
|
pickerPromises.push(customPicker);
|
|
598
|
-
|
|
599
|
-
|
|
580
|
+
_context2.t0 = pickers;
|
|
581
|
+
_context2.next = 11;
|
|
600
582
|
return customPicker;
|
|
601
583
|
case 11:
|
|
602
|
-
|
|
603
|
-
|
|
584
|
+
_context2.t1 = this.customPicker = _context2.sent;
|
|
585
|
+
_context2.t0.push.call(_context2.t0, _context2.t1);
|
|
604
586
|
case 13:
|
|
605
587
|
pickers.forEach(function (picker) {
|
|
606
588
|
picker.onNewMedia(_this2.insertFile);
|
|
@@ -612,11 +594,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
612
594
|
});
|
|
613
595
|
case 15:
|
|
614
596
|
case "end":
|
|
615
|
-
return
|
|
597
|
+
return _context2.stop();
|
|
616
598
|
}
|
|
617
|
-
},
|
|
599
|
+
}, _callee2, this);
|
|
618
600
|
}));
|
|
619
|
-
function initPickers(
|
|
601
|
+
function initPickers(_x2, _x3) {
|
|
620
602
|
return _initPickers.apply(this, arguments);
|
|
621
603
|
}
|
|
622
604
|
return initPickers;
|
|
@@ -4,7 +4,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { findParentNodeClosestToPos, isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
10
10
|
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
@@ -21,10 +21,13 @@ export var getNodeType = function getNodeType(state) {
|
|
|
21
21
|
};
|
|
22
22
|
export var changeInlineToMediaCard = function changeInlineToMediaCard(editorAnalyticsAPI, forceFocusSelector) {
|
|
23
23
|
return function (state, dispatch) {
|
|
24
|
+
var _findParentNodeCloses, _parent$content$first, _parent$content$lastC, _parent$content$lastC2;
|
|
24
25
|
var _state$schema$nodes2 = state.schema.nodes,
|
|
25
26
|
media = _state$schema$nodes2.media,
|
|
26
27
|
mediaInline = _state$schema$nodes2.mediaInline,
|
|
27
|
-
mediaGroup = _state$schema$nodes2.mediaGroup
|
|
28
|
+
mediaGroup = _state$schema$nodes2.mediaGroup,
|
|
29
|
+
paragraph = _state$schema$nodes2.paragraph,
|
|
30
|
+
heading = _state$schema$nodes2.heading;
|
|
28
31
|
var selectedNode = state.selection instanceof NodeSelection && state.selection.node.type === mediaInline && state.selection.node;
|
|
29
32
|
if (!selectedNode) {
|
|
30
33
|
return false;
|
|
@@ -39,10 +42,26 @@ export var changeInlineToMediaCard = function changeInlineToMediaCard(editorAnal
|
|
|
39
42
|
collection: collection
|
|
40
43
|
});
|
|
41
44
|
var group = mediaGroup.createChecked({}, mediaNode);
|
|
42
|
-
var
|
|
45
|
+
var parent = (_findParentNodeCloses = findParentNodeClosestToPos(state.selection.$from, function (node) {
|
|
46
|
+
return node.type === paragraph || node.type === heading;
|
|
47
|
+
})) === null || _findParentNodeCloses === void 0 ? void 0 : _findParentNodeCloses.node;
|
|
43
48
|
var tr = state.tr;
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
if (!!parent && parent.content.size === 2 && ((_parent$content$first = parent.content.firstChild) === null || _parent$content$first === void 0 ? void 0 : _parent$content$first.type.name) === 'mediaInline' && ((_parent$content$lastC = parent.content.lastChild) === null || _parent$content$lastC === void 0 ? void 0 : _parent$content$lastC.type.name) === 'text' && ((_parent$content$lastC2 = parent.content.lastChild) === null || _parent$content$lastC2 === void 0 || (_parent$content$lastC2 = _parent$content$lastC2.text) === null || _parent$content$lastC2 === void 0 ? void 0 : _parent$content$lastC2.trim()) === '') {
|
|
50
|
+
/// Empty paragraph or empty heading
|
|
51
|
+
/// Drop the corresponding card on the current line
|
|
52
|
+
var insertPos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
53
|
+
if (insertPos < 0) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
tr = tr.delete(insertPos, insertPos + parent.nodeSize);
|
|
57
|
+
tr = safeInsert(group, insertPos, false)(tr);
|
|
58
|
+
} else {
|
|
59
|
+
/// Non-empty paragraph, non-empty heading, or other nodes (e.g., action, list)
|
|
60
|
+
/// Drop the corresponding card underneath the current line
|
|
61
|
+
var _insertPos = state.tr.doc.resolve(state.selection.from).end();
|
|
62
|
+
tr = removeSelectedNode(tr);
|
|
63
|
+
tr = safeInsert(group, _insertPos, false)(tr);
|
|
64
|
+
}
|
|
46
65
|
if (dispatch) {
|
|
47
66
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent({
|
|
48
67
|
action: ACTION.CHANGED_TYPE,
|
|
@@ -53,6 +72,7 @@ export var changeInlineToMediaCard = function changeInlineToMediaCard(editorAnal
|
|
|
53
72
|
previousType: ACTION_SUBJECT_ID.MEDIA_INLINE
|
|
54
73
|
}
|
|
55
74
|
})(tr);
|
|
75
|
+
var nodePos = state.tr.doc.resolve(state.selection.from).end();
|
|
56
76
|
if (getBooleanFF('platform.editor.ally-media-file-dropdown_1kxo8')) {
|
|
57
77
|
var $endOfNode = tr.doc.resolve(nodePos + 1);
|
|
58
78
|
var newSelection = new NodeSelection($endOfNode);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
5
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -17,6 +18,7 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
|
|
|
17
18
|
dependencies: [
|
|
18
19
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
19
20
|
OptionalPlugin<AnalyticsPlugin>,
|
|
21
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
20
22
|
GuidelinePlugin,
|
|
21
23
|
GridPlugin,
|
|
22
24
|
WidthPlugin,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -40,7 +40,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
40
40
|
allowInlineImages: boolean;
|
|
41
41
|
private view;
|
|
42
42
|
private destroyed;
|
|
43
|
-
private contextIdentifierProvider?;
|
|
44
43
|
private errorReporter;
|
|
45
44
|
private customPicker?;
|
|
46
45
|
private removeOnCloseListener;
|
|
@@ -58,7 +57,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
58
57
|
singletonCreatedAt: number;
|
|
59
58
|
constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
|
|
60
59
|
clone(): this;
|
|
61
|
-
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
62
60
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
63
61
|
getMediaOptions: () => MediaPluginOptions;
|
|
64
62
|
setIsResizing(isResizing: boolean): void;
|
|
@@ -66,6 +64,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
66
64
|
updateElement(): void;
|
|
67
65
|
private isMediaSchemaNode;
|
|
68
66
|
private getDomElement;
|
|
67
|
+
get contextIdentifierProvider(): import("@atlaskit/editor-common/provider-factory").ContextIdentifierProvider | undefined;
|
|
69
68
|
/**
|
|
70
69
|
* we insert a new file by inserting a initial state for that file.
|
|
71
70
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { MediaClientConfig } from '@atlaskit/media-core';
|
|
@@ -36,7 +36,6 @@ export interface MediaPluginState {
|
|
|
36
36
|
currentMaxWidth?: number;
|
|
37
37
|
allowInlineImages?: boolean;
|
|
38
38
|
dispatch?: Dispatch;
|
|
39
|
-
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
40
39
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
41
40
|
getMediaOptions: () => MediaPluginOptions;
|
|
42
41
|
insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
2
2
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
3
|
+
import type { ContextIdentifierPlugin } from '@atlaskit/editor-plugin-context-identifier';
|
|
3
4
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
4
5
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
5
6
|
import type { FeatureFlagsPlugin } from '@atlaskit/editor-plugin-feature-flags';
|
|
@@ -17,6 +18,7 @@ export type MediaNextEditorPluginType = NextEditorPlugin<'media', {
|
|
|
17
18
|
dependencies: [
|
|
18
19
|
OptionalPlugin<FeatureFlagsPlugin>,
|
|
19
20
|
OptionalPlugin<AnalyticsPlugin>,
|
|
21
|
+
OptionalPlugin<ContextIdentifierPlugin>,
|
|
20
22
|
GuidelinePlugin,
|
|
21
23
|
GridPlugin,
|
|
22
24
|
WidthPlugin,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IntlShape } from 'react-intl-next';
|
|
2
2
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
3
3
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
4
|
-
import type {
|
|
4
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
5
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
6
|
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
7
7
|
import type { Node as PMNode, Schema } from '@atlaskit/editor-prosemirror/model';
|
|
@@ -40,7 +40,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
40
40
|
allowInlineImages: boolean;
|
|
41
41
|
private view;
|
|
42
42
|
private destroyed;
|
|
43
|
-
private contextIdentifierProvider?;
|
|
44
43
|
private errorReporter;
|
|
45
44
|
private customPicker?;
|
|
46
45
|
private removeOnCloseListener;
|
|
@@ -58,7 +57,6 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
58
57
|
singletonCreatedAt: number;
|
|
59
58
|
constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
|
|
60
59
|
clone(): this;
|
|
61
|
-
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
62
60
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
63
61
|
getMediaOptions: () => MediaPluginOptions;
|
|
64
62
|
setIsResizing(isResizing: boolean): void;
|
|
@@ -66,6 +64,7 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
|
|
|
66
64
|
updateElement(): void;
|
|
67
65
|
private isMediaSchemaNode;
|
|
68
66
|
private getDomElement;
|
|
67
|
+
get contextIdentifierProvider(): import("@atlaskit/editor-common/provider-factory").ContextIdentifierProvider | undefined;
|
|
69
68
|
/**
|
|
70
69
|
* we insert a new file by inserting a initial state for that file.
|
|
71
70
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RichMediaLayout as MediaSingleLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
|
-
import type {
|
|
3
|
+
import type { MediaProvider } from '@atlaskit/editor-common/provider-factory';
|
|
4
4
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
import type { MediaClientConfig } from '@atlaskit/media-core';
|
|
@@ -36,7 +36,6 @@ export interface MediaPluginState {
|
|
|
36
36
|
currentMaxWidth?: number;
|
|
37
37
|
allowInlineImages?: boolean;
|
|
38
38
|
dispatch?: Dispatch;
|
|
39
|
-
onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
|
|
40
39
|
setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
|
|
41
40
|
getMediaOptions: () => MediaPluginOptions;
|
|
42
41
|
insertFile: (mediaState: MediaState, onMediaStateChanged: MediaStateEventSubscriber, pickerType?: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.2",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"@atlaskit/analytics-namespaced-context": "^6.9.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
39
39
|
"@atlaskit/button": "^17.2.0",
|
|
40
|
-
"@atlaskit/editor-common": "^77.
|
|
40
|
+
"@atlaskit/editor-common": "^77.1.0",
|
|
41
41
|
"@atlaskit/editor-palette": "1.5.2",
|
|
42
42
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
43
43
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|
|
44
44
|
"@atlaskit/editor-plugin-editor-disabled": "^0.2.0",
|
|
45
45
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
46
|
-
"@atlaskit/editor-plugin-floating-toolbar": "^0.
|
|
46
|
+
"@atlaskit/editor-plugin-floating-toolbar": "^0.9.0",
|
|
47
47
|
"@atlaskit/editor-plugin-focus": "^0.2.0",
|
|
48
48
|
"@atlaskit/editor-plugin-grid": "^0.3.0",
|
|
49
49
|
"@atlaskit/editor-plugin-guideline": "^0.5.0",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@atlaskit/editor-plugin-width": "^0.2.0",
|
|
52
52
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
53
53
|
"@atlaskit/editor-shared-styles": "^2.9.0",
|
|
54
|
-
"@atlaskit/editor-tables": "^2.
|
|
54
|
+
"@atlaskit/editor-tables": "^2.5.0",
|
|
55
55
|
"@atlaskit/form": "^9.0.3",
|
|
56
56
|
"@atlaskit/icon": "^22.0.0",
|
|
57
57
|
"@atlaskit/media-card": "^77.7.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
66
66
|
"@atlaskit/textfield": "^6.0.0",
|
|
67
67
|
"@atlaskit/theme": "^12.6.0",
|
|
68
|
-
"@atlaskit/tokens": "^1.
|
|
68
|
+
"@atlaskit/tokens": "^1.35.0",
|
|
69
69
|
"@atlaskit/tooltip": "^18.1.0",
|
|
70
70
|
"@babel/runtime": "^7.0.0",
|
|
71
71
|
"@emotion/react": "^11.7.1",
|
|
@@ -75,17 +75,9 @@
|
|
|
75
75
|
"uuid": "^3.1.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
|
-
"@af/visual-regression": "*",
|
|
79
|
-
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
80
|
-
"@atlaskit/util-data-test": "^17.8.0",
|
|
81
78
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
82
|
-
"@atlassian/feature-flags-test-utils": "^0.1.1",
|
|
83
|
-
"@testing-library/react": "^12.1.5",
|
|
84
|
-
"@testing-library/user-event": "^14.4.3",
|
|
85
|
-
"enzyme": "^3.10.0",
|
|
86
79
|
"react-dom": "^16.8.0",
|
|
87
|
-
"typescript": "~4.9.5"
|
|
88
|
-
"wait-for-expect": "^1.2.0"
|
|
80
|
+
"typescript": "~4.9.5"
|
|
89
81
|
},
|
|
90
82
|
"peerDependencies": {
|
|
91
83
|
"@atlaskit/media-core": "^34.1.2",
|
|
@@ -152,5 +144,10 @@
|
|
|
152
144
|
"type": "boolean"
|
|
153
145
|
}
|
|
154
146
|
},
|
|
155
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|
|
147
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
148
|
+
"stricter": {
|
|
149
|
+
"no-unused-dependencies": {
|
|
150
|
+
"checkDevDependencies": true
|
|
151
|
+
}
|
|
152
|
+
}
|
|
156
153
|
}
|