@atlaskit/editor-plugin-media 0.3.17 → 0.4.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 +18 -0
- package/dist/cjs/plugin.js +21 -19
- package/dist/cjs/pm-plugins/keymap.js +96 -1
- package/dist/cjs/pm-plugins/main.js +14 -10
- package/dist/cjs/pm-plugins/mediaResizeAnnouncerMess.js +34 -0
- package/dist/cjs/toolbar/commands.js +1 -1
- package/dist/cjs/toolbar/index.js +1 -1
- package/dist/cjs/utils/{is-image.js → is-type.js} +4 -1
- package/dist/cjs/utils/media-inline.js +27 -0
- package/dist/cjs/utils/media-single.js +3 -3
- package/dist/es2019/plugin.js +5 -2
- package/dist/es2019/pm-plugins/keymap.js +87 -2
- package/dist/es2019/pm-plugins/main.js +18 -14
- package/dist/es2019/pm-plugins/mediaResizeAnnouncerMess.js +28 -0
- package/dist/es2019/toolbar/commands.js +1 -1
- package/dist/es2019/toolbar/index.js +1 -1
- package/dist/es2019/utils/{is-image.js → is-type.js} +3 -0
- package/dist/es2019/utils/media-inline.js +21 -0
- package/dist/es2019/utils/media-single.js +1 -1
- package/dist/esm/plugin.js +21 -19
- package/dist/esm/pm-plugins/keymap.js +97 -2
- package/dist/esm/pm-plugins/main.js +18 -14
- package/dist/esm/pm-plugins/mediaResizeAnnouncerMess.js +28 -0
- package/dist/esm/toolbar/commands.js +1 -1
- package/dist/esm/toolbar/index.js +1 -1
- package/dist/esm/utils/{is-image.js → is-type.js} +3 -0
- package/dist/esm/utils/media-inline.js +21 -0
- package/dist/esm/utils/media-single.js +1 -1
- package/dist/types/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/pm-plugins/mediaResizeAnnouncerMess.d.ts +27 -0
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/toolbar/commands.d.ts +2 -1
- package/dist/{types-ts4.5/utils/is-image.d.ts → types/utils/is-type.d.ts} +1 -0
- package/dist/types/utils/media-inline.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/mediaResizeAnnouncerMess.d.ts +27 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/toolbar/commands.d.ts +2 -1
- package/dist/{types/utils/is-image.d.ts → types-ts4.5/utils/is-type.d.ts} +1 -0
- package/dist/types-ts4.5/utils/media-inline.d.ts +4 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#43145](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43145) [`999af31b6ad`](https://bitbucket.org/atlassian/atlassian-frontend/commits/999af31b6ad) - [ux] [ED-20776] Change mediaInline node insertion logic behind 'platform.editor.media.inline-image.base-support' feature flag. With the flag on, Adding an image to a non-empty paragraph and list node inserts an media inline node, instead of media single node.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#43108](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43108) [`b779a47b799`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b779a47b799) - ECA11Y-86: Added ability to resize media via keyboard and added announcer
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#43379](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/43379) [`482c025520d`](https://bitbucket.org/atlassian/atlassian-frontend/commits/482c025520d) - ED-20763 Upgrade ADF schema version to 33.2.3 for MBE nodes.
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 0.3.17
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -58,6 +58,7 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
58
58
|
options = _ref2$config === void 0 ? {} : _ref2$config,
|
|
59
59
|
api = _ref2.api;
|
|
60
60
|
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
61
|
+
var apiWidth = api === null || api === void 0 ? void 0 : api.width;
|
|
61
62
|
return {
|
|
62
63
|
name: 'media',
|
|
63
64
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -145,16 +146,17 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
145
146
|
}
|
|
146
147
|
}, {
|
|
147
148
|
name: 'mediaKeymap',
|
|
148
|
-
plugin: function plugin() {
|
|
149
|
+
plugin: function plugin(_ref5) {
|
|
149
150
|
var _api$analytics2;
|
|
150
|
-
|
|
151
|
+
var getIntl = _ref5.getIntl;
|
|
152
|
+
return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, apiWidth, getIntl);
|
|
151
153
|
}
|
|
152
154
|
}];
|
|
153
155
|
if (options && options.allowMediaSingle) {
|
|
154
156
|
pmPlugins.push({
|
|
155
157
|
name: 'mediaSingleKeymap',
|
|
156
|
-
plugin: function plugin(
|
|
157
|
-
var schema =
|
|
158
|
+
plugin: function plugin(_ref6) {
|
|
159
|
+
var schema = _ref6.schema;
|
|
158
160
|
return (0, _keymapMediaSingle.default)(schema);
|
|
159
161
|
}
|
|
160
162
|
});
|
|
@@ -166,9 +168,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
166
168
|
});
|
|
167
169
|
pmPlugins.push({
|
|
168
170
|
name: 'mediaAltTextKeymap',
|
|
169
|
-
plugin: function plugin(
|
|
171
|
+
plugin: function plugin(_ref7) {
|
|
170
172
|
var _api$analytics3;
|
|
171
|
-
var schema =
|
|
173
|
+
var schema = _ref7.schema;
|
|
172
174
|
return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
173
175
|
}
|
|
174
176
|
});
|
|
@@ -176,15 +178,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
176
178
|
if (options && options.allowLinking) {
|
|
177
179
|
pmPlugins.push({
|
|
178
180
|
name: 'mediaLinking',
|
|
179
|
-
plugin: function plugin(
|
|
180
|
-
var dispatch =
|
|
181
|
+
plugin: function plugin(_ref8) {
|
|
182
|
+
var dispatch = _ref8.dispatch;
|
|
181
183
|
return (0, _linking.default)(dispatch);
|
|
182
184
|
}
|
|
183
185
|
});
|
|
184
186
|
pmPlugins.push({
|
|
185
187
|
name: 'mediaLinkingKeymap',
|
|
186
|
-
plugin: function plugin(
|
|
187
|
-
var schema =
|
|
188
|
+
plugin: function plugin(_ref9) {
|
|
189
|
+
var schema = _ref9.schema;
|
|
188
190
|
return (0, _keymap3.default)(schema);
|
|
189
191
|
}
|
|
190
192
|
});
|
|
@@ -220,19 +222,19 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
220
222
|
});
|
|
221
223
|
return pmPlugins;
|
|
222
224
|
},
|
|
223
|
-
contentComponent: function contentComponent(
|
|
224
|
-
var editorView =
|
|
225
|
-
appearance =
|
|
225
|
+
contentComponent: function contentComponent(_ref10) {
|
|
226
|
+
var editorView = _ref10.editorView,
|
|
227
|
+
appearance = _ref10.appearance;
|
|
226
228
|
return /*#__PURE__*/_react.default.createElement(MediaPickerFunctionalComponent, {
|
|
227
229
|
editorDomElement: editorView.dom,
|
|
228
230
|
appearance: appearance,
|
|
229
231
|
api: api
|
|
230
232
|
});
|
|
231
233
|
},
|
|
232
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
233
|
-
var editorView =
|
|
234
|
-
eventDispatcher =
|
|
235
|
-
disabled =
|
|
234
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
|
|
235
|
+
var editorView = _ref11.editorView,
|
|
236
|
+
eventDispatcher = _ref11.eventDispatcher,
|
|
237
|
+
disabled = _ref11.disabled;
|
|
236
238
|
return /*#__PURE__*/_react.default.createElement(_ToolbarMedia.default, {
|
|
237
239
|
isDisabled: disabled,
|
|
238
240
|
isReducedSpacing: true,
|
|
@@ -240,8 +242,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
240
242
|
});
|
|
241
243
|
},
|
|
242
244
|
pluginsOptions: {
|
|
243
|
-
quickInsert: function quickInsert(
|
|
244
|
-
var formatMessage =
|
|
245
|
+
quickInsert: function quickInsert(_ref12) {
|
|
246
|
+
var formatMessage = _ref12.formatMessage;
|
|
245
247
|
return [{
|
|
246
248
|
id: 'media',
|
|
247
249
|
title: formatMessage(_messages.toolbarInsertBlockMessages.mediaFiles),
|
|
@@ -6,12 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.keymapPlugin = keymapPlugin;
|
|
8
8
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
9
10
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
10
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
11
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
12
14
|
var _captions = require("../commands/captions");
|
|
13
15
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
14
|
-
|
|
16
|
+
var _commands = require("../toolbar/commands");
|
|
17
|
+
var _utils = require("../toolbar/utils");
|
|
18
|
+
var _mediaResizeAnnouncerMess = require("./mediaResizeAnnouncerMess");
|
|
19
|
+
function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlugin, getIntl) {
|
|
15
20
|
var list = {};
|
|
16
21
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.undo.common, ignoreLinksInSteps, list);
|
|
17
22
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, splitMediaGroup, list);
|
|
@@ -22,6 +27,10 @@ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
|
22
27
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
23
28
|
}
|
|
24
29
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, splitMediaGroup, list);
|
|
30
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.increaseMediaSize.common, handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
31
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.decreaseMediaSize.common, handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
32
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.quickIncreaseMediaSize.common, handleMediaQuickIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
33
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.quickDecreaseMediaSize.common, handleMediaQuickDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
25
34
|
return (0, _keymap.keymap)(list);
|
|
26
35
|
}
|
|
27
36
|
var ignoreLinksInSteps = function ignoreLinksInSteps(state) {
|
|
@@ -33,6 +42,92 @@ var splitMediaGroup = function splitMediaGroup(state) {
|
|
|
33
42
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
34
43
|
return mediaPluginState.splitMediaGroup();
|
|
35
44
|
};
|
|
45
|
+
var createAnnouncer = function createAnnouncer(action, mediaWidth, changeAmount, validation, getIntl) {
|
|
46
|
+
var announcerContainer = document.getElementById('media-announcer') || document.createElement('div');
|
|
47
|
+
var intl = getIntl();
|
|
48
|
+
if (!announcerContainer.id) {
|
|
49
|
+
announcerContainer.id = 'media-announcer';
|
|
50
|
+
announcerContainer.setAttribute('role', 'status');
|
|
51
|
+
announcerContainer.setAttribute('aria-live', 'polite');
|
|
52
|
+
announcerContainer.setAttribute('aria-atomic', 'true');
|
|
53
|
+
var style = announcerContainer.style;
|
|
54
|
+
style.position = 'absolute';
|
|
55
|
+
style.width = '1px';
|
|
56
|
+
style.height = '1px';
|
|
57
|
+
style.marginTop = '-1px';
|
|
58
|
+
style.opacity = '0';
|
|
59
|
+
style.overflow = 'hidden';
|
|
60
|
+
document.body.appendChild(announcerContainer);
|
|
61
|
+
} else {
|
|
62
|
+
var newMediaWidth = mediaWidth + changeAmount;
|
|
63
|
+
if (validation === 'greater-than-max') {
|
|
64
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.MediaWidthIsMax);
|
|
65
|
+
} else if (validation === 'less-than-min') {
|
|
66
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.MediaWidthIsMin);
|
|
67
|
+
} else {
|
|
68
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.DefaultMediaWidth, {
|
|
69
|
+
action: action,
|
|
70
|
+
newMediaWidth: newMediaWidth
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
var handleMediaSizeChange = function handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, changeAmount, action, getIntl) {
|
|
76
|
+
return function (state, dispatch) {
|
|
77
|
+
var _selectedNode$node, _selectedNode$node2, _widthPlugin$sharedSt;
|
|
78
|
+
var selectedNode = (0, _utils.getSelectedMediaSingle)(state);
|
|
79
|
+
var layout = selectedNode === null || selectedNode === void 0 || (_selectedNode$node = selectedNode.node) === null || _selectedNode$node === void 0 || (_selectedNode$node = _selectedNode$node.attrs) === null || _selectedNode$node === void 0 ? void 0 : _selectedNode$node.layout;
|
|
80
|
+
var mediaWidth = selectedNode === null || selectedNode === void 0 || (_selectedNode$node2 = selectedNode.node) === null || _selectedNode$node2 === void 0 || (_selectedNode$node2 = _selectedNode$node2.attrs) === null || _selectedNode$node2 === void 0 ? void 0 : _selectedNode$node2.width;
|
|
81
|
+
var contentWidth =
|
|
82
|
+
// @ts-ignore readonly sharedState
|
|
83
|
+
(widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
84
|
+
var minWidth = _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
|
|
85
|
+
var maxWidth;
|
|
86
|
+
var validation = 'valid';
|
|
87
|
+
var newWidth = mediaWidth + changeAmount;
|
|
88
|
+
var intl = getIntl();
|
|
89
|
+
if (options !== null && options !== void 0 && options.fullWidthEnabled) {
|
|
90
|
+
var _widthPlugin$sharedSt2;
|
|
91
|
+
// @ts-ignore readonly sharedState
|
|
92
|
+
maxWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength;
|
|
93
|
+
} else {
|
|
94
|
+
var _widthPlugin$sharedSt3;
|
|
95
|
+
maxWidth = (0, _mediaSingle.calcMediaSingleMaxWidth)( // @ts-ignore readonly sharedState
|
|
96
|
+
widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width);
|
|
97
|
+
}
|
|
98
|
+
if (newWidth > maxWidth) {
|
|
99
|
+
newWidth = maxWidth;
|
|
100
|
+
validation = 'greater-than-max';
|
|
101
|
+
} else if (newWidth < minWidth) {
|
|
102
|
+
newWidth = minWidth;
|
|
103
|
+
validation = 'less-than-min';
|
|
104
|
+
} else {
|
|
105
|
+
newWidth;
|
|
106
|
+
validation = 'valid';
|
|
107
|
+
}
|
|
108
|
+
if (action === 'increased') {
|
|
109
|
+
action = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.IncreasedAction);
|
|
110
|
+
} else if (action === 'decreased') {
|
|
111
|
+
action = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.DecreasedAction);
|
|
112
|
+
}
|
|
113
|
+
var newLayout = (0, _utils.calcNewLayout)(newWidth, layout, contentWidth, options === null || options === void 0 ? void 0 : options.fullWidthEnabled);
|
|
114
|
+
(0, _commands.updateMediaSingleWidth)(editorAnalyticsAPI)(newWidth, validation, 'keyboard', newLayout)(state, dispatch);
|
|
115
|
+
createAnnouncer(action, mediaWidth, changeAmount, validation, getIntl);
|
|
116
|
+
return true;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
var handleMediaIncrease = function handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
120
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 1, 'increased', getIntl);
|
|
121
|
+
};
|
|
122
|
+
var handleMediaDecrease = function handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
123
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -1, 'decreased', getIntl);
|
|
124
|
+
};
|
|
125
|
+
var handleMediaQuickIncrease = function handleMediaQuickIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
126
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 10, 'increased', getIntl);
|
|
127
|
+
};
|
|
128
|
+
var handleMediaQuickDecrease = function handleMediaQuickDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
129
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -10, 'decreased', getIntl);
|
|
130
|
+
};
|
|
36
131
|
var insertAndSelectCaption = function insertAndSelectCaption(editorAnalyticsAPI) {
|
|
37
132
|
return function (state, dispatch) {
|
|
38
133
|
var selection = state.selection,
|
|
@@ -38,6 +38,7 @@ var _pickerFacade = _interopRequireDefault(require("../picker-facade"));
|
|
|
38
38
|
var _DropPlaceholder = _interopRequireDefault(require("../ui/Media/DropPlaceholder"));
|
|
39
39
|
var _mediaCommon2 = require("../utils/media-common");
|
|
40
40
|
var _mediaFiles = require("../utils/media-files");
|
|
41
|
+
var _mediaInline = require("../utils/media-inline");
|
|
41
42
|
var _mediaSingle2 = require("../utils/media-single");
|
|
42
43
|
var _mediaTaskManager = require("./mediaTaskManager");
|
|
43
44
|
var _pluginKey = require("./plugin-key");
|
|
@@ -224,7 +225,7 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
224
225
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
225
226
|
*/
|
|
226
227
|
(0, _defineProperty2.default)(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
227
|
-
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2;
|
|
228
|
+
var _this$pluginInjection, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection2;
|
|
228
229
|
var state = _this.view.state;
|
|
229
230
|
var editorAnalyticsAPI = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 || (_this$pluginInjection = _this$pluginInjection.analytics) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.actions;
|
|
230
231
|
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
@@ -241,15 +242,18 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
|
|
|
241
242
|
allUploadsFinished: false
|
|
242
243
|
});
|
|
243
244
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
245
|
+
switch ((0, _mediaInline.getMediaNodeInsertionType)(state, (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
246
|
+
case 'inline':
|
|
247
|
+
(0, _mediaFiles.insertMediaInlineNode)(editorAnalyticsAPI)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
248
|
+
break;
|
|
249
|
+
case 'block':
|
|
250
|
+
// read width state right before inserting to get up-to-date and define values
|
|
251
|
+
var widthPluginState = (_this$pluginInjection2 = _this.pluginInjectionApi) === null || _this$pluginInjection2 === void 0 ? void 0 : _this$pluginInjection2.width.sharedState.currentState();
|
|
252
|
+
(0, _mediaSingle2.insertMediaSingleNode)(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
253
|
+
break;
|
|
254
|
+
case 'group':
|
|
255
|
+
(0, _mediaFiles.insertMediaGroupNode)(editorAnalyticsAPI)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
256
|
+
break;
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
// do events when media state changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mediaResizeAnnouncerMess = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var mediaResizeAnnouncerMess = exports.mediaResizeAnnouncerMess = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
MediaWidthIsMax: {
|
|
10
|
+
id: 'fabric.editor.media.pixelEntry.MediaWidthIsMax',
|
|
11
|
+
defaultMessage: 'Media increased to the maximum size',
|
|
12
|
+
description: 'The media has the maximum allowed width'
|
|
13
|
+
},
|
|
14
|
+
MediaWidthIsMin: {
|
|
15
|
+
id: 'fabric.editor.media.MediaWidthIsMin',
|
|
16
|
+
defaultMessage: 'Media decreased to the minimum size',
|
|
17
|
+
description: 'The media has the minimum allowed width'
|
|
18
|
+
},
|
|
19
|
+
DefaultMediaWidth: {
|
|
20
|
+
id: 'fabric.editor.media.DefaultMediaWidth',
|
|
21
|
+
defaultMessage: 'Media width {action} to {newMediaWidth} pixels.',
|
|
22
|
+
description: 'Media width {action} to {newMediaWidth} pixels.'
|
|
23
|
+
},
|
|
24
|
+
IncreasedAction: {
|
|
25
|
+
id: 'fabric.editor.media.decreased',
|
|
26
|
+
defaultMessage: 'increased',
|
|
27
|
+
description: 'Increased action'
|
|
28
|
+
},
|
|
29
|
+
DecreasedAction: {
|
|
30
|
+
id: 'fabric.editor.media.decreased',
|
|
31
|
+
defaultMessage: 'decreased',
|
|
32
|
+
description: 'Decreased action'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -203,7 +203,7 @@ var setBorderMark = exports.setBorderMark = function setBorderMark(editorAnalyti
|
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
205
|
var updateMediaSingleWidth = exports.updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyticsAPI) {
|
|
206
|
-
return function (width, validation, layout) {
|
|
206
|
+
return function (width, validation, input, layout) {
|
|
207
207
|
return function (state, dispatch) {
|
|
208
208
|
var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
209
209
|
if (!selectedMediaSingleNode) {
|
|
@@ -322,7 +322,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
322
322
|
var width = _ref2.width,
|
|
323
323
|
validation = _ref2.validation;
|
|
324
324
|
var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
325
|
-
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
|
|
325
|
+
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
326
326
|
},
|
|
327
327
|
onMigrate: function onMigrate() {
|
|
328
328
|
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isImage = void 0;
|
|
6
|
+
exports.isVideo = exports.isImage = void 0;
|
|
7
7
|
var isImage = exports.isImage = function isImage(fileType) {
|
|
8
8
|
return !!fileType && (fileType.indexOf('image/') > -1 || fileType.indexOf('video/') > -1);
|
|
9
|
+
};
|
|
10
|
+
var isVideo = exports.isVideo = function isVideo(fileType) {
|
|
11
|
+
return !!fileType && fileType.includes('video/');
|
|
9
12
|
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getMediaNodeInsertionType = void 0;
|
|
7
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _mediaCommon = require("@atlaskit/media-common");
|
|
9
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
|
+
var _mediaFiles = require("../utils/media-files");
|
|
11
|
+
var _mediaSingle = require("../utils/media-single");
|
|
12
|
+
var _isType = require("./is-type");
|
|
13
|
+
var _mediaCommon2 = require("./media-common");
|
|
14
|
+
var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function getMediaNodeInsertionType(state, mediaFeatureFlags, fileMimeType) {
|
|
15
|
+
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || (0, _utils.isInListItem)(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
16
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support')) {
|
|
17
|
+
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
18
|
+
return 'inline';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
if ((0, _mediaSingle.isMediaSingle)(state.schema, fileMimeType)) {
|
|
22
|
+
return 'block';
|
|
23
|
+
} else if (canInsertInlineNode) {
|
|
24
|
+
return 'inline';
|
|
25
|
+
}
|
|
26
|
+
return 'group';
|
|
27
|
+
};
|
|
@@ -18,7 +18,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
18
18
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
19
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
20
|
var _mediaCommon = require("../utils/media-common");
|
|
21
|
-
var
|
|
21
|
+
var _isType = require("./is-type");
|
|
22
22
|
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; }
|
|
23
23
|
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; }
|
|
24
24
|
var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
|
|
@@ -62,7 +62,7 @@ function insertNodesWithOptionalParagraph(nodes) {
|
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
64
|
var isMediaSingle = exports.isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
65
|
-
return !!schema.nodes.mediaSingle && (0,
|
|
65
|
+
return !!schema.nodes.mediaSingle && (0, _isType.isImage)(fileMimeType);
|
|
66
66
|
};
|
|
67
67
|
var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
|
|
68
68
|
var state = view.state,
|
|
@@ -75,7 +75,7 @@ var insertMediaAsMediaSingle = exports.insertMediaAsMediaSingle = function inser
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// if not an image type media node
|
|
78
|
-
if (node.type !== media || !(0,
|
|
78
|
+
if (node.type !== media || !(0, _isType.isImage)(node.attrs.__fileMimeType) && node.attrs.type !== 'external') {
|
|
79
79
|
return false;
|
|
80
80
|
}
|
|
81
81
|
var mediaSingleNode = mediaSingle.create({}, node);
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -49,6 +49,7 @@ export const mediaPlugin = ({
|
|
|
49
49
|
}) => {
|
|
50
50
|
var _api$featureFlags;
|
|
51
51
|
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
52
|
+
const apiWidth = api === null || api === void 0 ? void 0 : api.width;
|
|
52
53
|
return {
|
|
53
54
|
name: 'media',
|
|
54
55
|
getSharedState(editorState) {
|
|
@@ -136,9 +137,11 @@ export const mediaPlugin = ({
|
|
|
136
137
|
}
|
|
137
138
|
}, {
|
|
138
139
|
name: 'mediaKeymap',
|
|
139
|
-
plugin: (
|
|
140
|
+
plugin: ({
|
|
141
|
+
getIntl
|
|
142
|
+
}) => {
|
|
140
143
|
var _api$analytics2;
|
|
141
|
-
return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
|
|
144
|
+
return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, apiWidth, getIntl);
|
|
142
145
|
}
|
|
143
146
|
}];
|
|
144
147
|
if (options && options.allowMediaSingle) {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, enter, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
1
|
+
import { bindKeymapWithCommand, decreaseMediaSize, enter, increaseMediaSize, insertNewLine, moveDown, moveLeft, moveRight, quickDecreaseMediaSize, quickIncreaseMediaSize, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { calcMediaSingleMaxWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
2
3
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
5
7
|
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
6
8
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
7
|
-
|
|
9
|
+
import { updateMediaSingleWidth } from '../toolbar/commands';
|
|
10
|
+
import { calcNewLayout, getSelectedMediaSingle } from '../toolbar/utils';
|
|
11
|
+
import { mediaResizeAnnouncerMess } from './mediaResizeAnnouncerMess';
|
|
12
|
+
export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlugin, getIntl) {
|
|
8
13
|
const list = {};
|
|
9
14
|
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
10
15
|
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
@@ -15,6 +20,10 @@ export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
|
15
20
|
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
16
21
|
}
|
|
17
22
|
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
23
|
+
bindKeymapWithCommand(increaseMediaSize.common, handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
24
|
+
bindKeymapWithCommand(decreaseMediaSize.common, handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
25
|
+
bindKeymapWithCommand(quickIncreaseMediaSize.common, handleMediaQuickIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
26
|
+
bindKeymapWithCommand(quickDecreaseMediaSize.common, handleMediaQuickDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
18
27
|
return keymap(list);
|
|
19
28
|
}
|
|
20
29
|
const ignoreLinksInSteps = state => {
|
|
@@ -26,6 +35,82 @@ const splitMediaGroup = state => {
|
|
|
26
35
|
const mediaPluginState = stateKey.getState(state);
|
|
27
36
|
return mediaPluginState.splitMediaGroup();
|
|
28
37
|
};
|
|
38
|
+
const createAnnouncer = (action, mediaWidth, changeAmount, validation, getIntl) => {
|
|
39
|
+
let announcerContainer = document.getElementById('media-announcer') || document.createElement('div');
|
|
40
|
+
const intl = getIntl();
|
|
41
|
+
if (!announcerContainer.id) {
|
|
42
|
+
announcerContainer.id = 'media-announcer';
|
|
43
|
+
announcerContainer.setAttribute('role', 'status');
|
|
44
|
+
announcerContainer.setAttribute('aria-live', 'polite');
|
|
45
|
+
announcerContainer.setAttribute('aria-atomic', 'true');
|
|
46
|
+
const style = announcerContainer.style;
|
|
47
|
+
style.position = 'absolute';
|
|
48
|
+
style.width = '1px';
|
|
49
|
+
style.height = '1px';
|
|
50
|
+
style.marginTop = '-1px';
|
|
51
|
+
style.opacity = '0';
|
|
52
|
+
style.overflow = 'hidden';
|
|
53
|
+
document.body.appendChild(announcerContainer);
|
|
54
|
+
} else {
|
|
55
|
+
const newMediaWidth = mediaWidth + changeAmount;
|
|
56
|
+
if (validation === 'greater-than-max') {
|
|
57
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMax);
|
|
58
|
+
} else if (validation === 'less-than-min') {
|
|
59
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMin);
|
|
60
|
+
} else {
|
|
61
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.DefaultMediaWidth, {
|
|
62
|
+
action: action,
|
|
63
|
+
newMediaWidth: newMediaWidth
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const handleMediaSizeChange = (editorAnalyticsAPI, widthPlugin, options, changeAmount, action, getIntl) => (state, dispatch) => {
|
|
69
|
+
var _selectedNode$node, _selectedNode$node$at, _selectedNode$node2, _selectedNode$node2$a, _widthPlugin$sharedSt;
|
|
70
|
+
const selectedNode = getSelectedMediaSingle(state);
|
|
71
|
+
const layout = selectedNode === null || selectedNode === void 0 ? void 0 : (_selectedNode$node = selectedNode.node) === null || _selectedNode$node === void 0 ? void 0 : (_selectedNode$node$at = _selectedNode$node.attrs) === null || _selectedNode$node$at === void 0 ? void 0 : _selectedNode$node$at.layout;
|
|
72
|
+
const mediaWidth = selectedNode === null || selectedNode === void 0 ? void 0 : (_selectedNode$node2 = selectedNode.node) === null || _selectedNode$node2 === void 0 ? void 0 : (_selectedNode$node2$a = _selectedNode$node2.attrs) === null || _selectedNode$node2$a === void 0 ? void 0 : _selectedNode$node2$a.width;
|
|
73
|
+
const contentWidth =
|
|
74
|
+
// @ts-ignore readonly sharedState
|
|
75
|
+
(widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength) || akEditorDefaultLayoutWidth;
|
|
76
|
+
const minWidth = MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
|
|
77
|
+
let maxWidth;
|
|
78
|
+
let validation = 'valid';
|
|
79
|
+
let newWidth = mediaWidth + changeAmount;
|
|
80
|
+
const intl = getIntl();
|
|
81
|
+
if (options !== null && options !== void 0 && options.fullWidthEnabled) {
|
|
82
|
+
var _widthPlugin$sharedSt2;
|
|
83
|
+
// @ts-ignore readonly sharedState
|
|
84
|
+
maxWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength;
|
|
85
|
+
} else {
|
|
86
|
+
var _widthPlugin$sharedSt3;
|
|
87
|
+
maxWidth = calcMediaSingleMaxWidth( // @ts-ignore readonly sharedState
|
|
88
|
+
widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width);
|
|
89
|
+
}
|
|
90
|
+
if (newWidth > maxWidth) {
|
|
91
|
+
newWidth = maxWidth;
|
|
92
|
+
validation = 'greater-than-max';
|
|
93
|
+
} else if (newWidth < minWidth) {
|
|
94
|
+
newWidth = minWidth;
|
|
95
|
+
validation = 'less-than-min';
|
|
96
|
+
} else {
|
|
97
|
+
newWidth;
|
|
98
|
+
validation = 'valid';
|
|
99
|
+
}
|
|
100
|
+
if (action === 'increased') {
|
|
101
|
+
action = intl.formatMessage(mediaResizeAnnouncerMess.IncreasedAction);
|
|
102
|
+
} else if (action === 'decreased') {
|
|
103
|
+
action = intl.formatMessage(mediaResizeAnnouncerMess.DecreasedAction);
|
|
104
|
+
}
|
|
105
|
+
const newLayout = calcNewLayout(newWidth, layout, contentWidth, options === null || options === void 0 ? void 0 : options.fullWidthEnabled);
|
|
106
|
+
updateMediaSingleWidth(editorAnalyticsAPI)(newWidth, validation, 'keyboard', newLayout)(state, dispatch);
|
|
107
|
+
createAnnouncer(action, mediaWidth, changeAmount, validation, getIntl);
|
|
108
|
+
return true;
|
|
109
|
+
};
|
|
110
|
+
const handleMediaIncrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 1, 'increased', getIntl);
|
|
111
|
+
const handleMediaDecrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -1, 'decreased', getIntl);
|
|
112
|
+
const handleMediaQuickIncrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 10, 'increased', getIntl);
|
|
113
|
+
const handleMediaQuickDecrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -10, 'decreased', getIntl);
|
|
29
114
|
const insertAndSelectCaption = editorAnalyticsAPI => (state, dispatch) => {
|
|
30
115
|
const {
|
|
31
116
|
selection,
|
|
@@ -6,7 +6,7 @@ import { RawIntlProvider } from 'react-intl-next';
|
|
|
6
6
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
7
|
import { CAPTION_PLACEHOLDER_ID, getMaxWidthForNestedNodeNext } from '@atlaskit/editor-common/media-single';
|
|
8
8
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
9
|
-
import { browser, ErrorReporter
|
|
9
|
+
import { browser, ErrorReporter } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import { AllSelection, NodeSelection, Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
11
11
|
import { insertPoint } from '@atlaskit/editor-prosemirror/transform';
|
|
12
12
|
import { findDomRefAtPos, findParentNodeOfType, findSelectedNodeOfType, isNodeSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
@@ -18,9 +18,10 @@ import * as helpers from '../commands/helpers';
|
|
|
18
18
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
19
19
|
import PickerFacade from '../picker-facade';
|
|
20
20
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
21
|
+
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
22
|
+
import { insertMediaGroupNode, insertMediaInlineNode } from '../utils/media-files';
|
|
23
|
+
import { getMediaNodeInsertionType } from '../utils/media-inline';
|
|
24
|
+
import { insertMediaSingleNode } from '../utils/media-single';
|
|
24
25
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
25
26
|
import { stateKey } from './plugin-key';
|
|
26
27
|
export { stateKey } from './plugin-key';
|
|
@@ -152,7 +153,7 @@ export class MediaPluginStateImplementation {
|
|
|
152
153
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
153
154
|
*/
|
|
154
155
|
_defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType) => {
|
|
155
|
-
var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2;
|
|
156
|
+
var _this$pluginInjection, _this$pluginInjection2, _mediaState$collectio, _this$mediaOptions2, _this$pluginInjection3;
|
|
156
157
|
const {
|
|
157
158
|
state
|
|
158
159
|
} = this.view;
|
|
@@ -172,15 +173,18 @@ export class MediaPluginStateImplementation {
|
|
|
172
173
|
allUploadsFinished: false
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
176
|
+
switch (getMediaNodeInsertionType(state, (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags, mediaStateWithContext.fileMimeType)) {
|
|
177
|
+
case 'inline':
|
|
178
|
+
insertMediaInlineNode(editorAnalyticsAPI)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
179
|
+
break;
|
|
180
|
+
case 'block':
|
|
181
|
+
// read width state right before inserting to get up-to-date and define values
|
|
182
|
+
const widthPluginState = (_this$pluginInjection3 = this.pluginInjectionApi) === null || _this$pluginInjection3 === void 0 ? void 0 : _this$pluginInjection3.width.sharedState.currentState();
|
|
183
|
+
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState, editorAnalyticsAPI);
|
|
184
|
+
break;
|
|
185
|
+
case 'group':
|
|
186
|
+
insertMediaGroupNode(editorAnalyticsAPI)(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
|
|
187
|
+
break;
|
|
184
188
|
}
|
|
185
189
|
|
|
186
190
|
// do events when media state changes
|