@atlaskit/editor-plugin-media 0.6.5 → 0.6.7
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 +12 -0
- package/dist/cjs/toolbar/commands.js +35 -1
- package/dist/cjs/toolbar/index.js +50 -8
- package/dist/cjs/toolbar/utils.js +14 -1
- package/dist/es2019/toolbar/commands.js +37 -1
- package/dist/es2019/toolbar/index.js +50 -12
- package/dist/es2019/toolbar/utils.js +13 -0
- package/dist/esm/toolbar/commands.js +35 -1
- package/dist/esm/toolbar/index.js +54 -12
- package/dist/esm/toolbar/utils.js +13 -0
- package/dist/types/toolbar/commands.d.ts +1 -0
- package/dist/types/toolbar/utils.d.ts +5 -0
- package/dist/types-ts4.5/toolbar/commands.d.ts +1 -0
- package/dist/types-ts4.5/toolbar/utils.d.ts +5 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.6.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58246](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58246) [`a381b2599716`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a381b2599716) - ED-21371 Update adf-schema to 35.1.0
|
|
8
|
+
|
|
9
|
+
## 0.6.6
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#60345](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/60345) [`0510fbeefadd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0510fbeefadd) - [ux] [ED-21290] Add inline and floating switcher buttons to media single floating toolbar and implement onClick handler
|
|
14
|
+
|
|
3
15
|
## 0.6.5
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.updateMediaSingleWidth = exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = exports.changeMediaInlineToMediaSingle = exports.changeMediaCardToInline = exports.changeInlineToMediaCard = exports.DEFAULT_BORDER_SIZE = exports.DEFAULT_BORDER_COLOR = void 0;
|
|
7
|
+
exports.updateMediaSingleWidth = exports.toggleBorderMark = exports.setBorderMark = exports.removeInlineCard = 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
10
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
@@ -248,4 +248,38 @@ var updateMediaSingleWidth = exports.updateMediaSingleWidth = function updateMed
|
|
|
248
248
|
return true;
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
+
};
|
|
252
|
+
var changeMediaSingleToMediaInline = exports.changeMediaSingleToMediaInline = function changeMediaSingleToMediaInline(editorAnalyticsAPI) {
|
|
253
|
+
return function (state, dispatch) {
|
|
254
|
+
var selectedNodeWithPos = (0, _utils2.getSelectedMediaSingle)(state);
|
|
255
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
256
|
+
mediaInline = _state$schema$nodes3.mediaInline,
|
|
257
|
+
paragraph = _state$schema$nodes3.paragraph;
|
|
258
|
+
if (!selectedNodeWithPos) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
var mediaSingleNode = selectedNodeWithPos.node;
|
|
262
|
+
var mediaNode = mediaSingleNode.firstChild;
|
|
263
|
+
if (!mediaNode) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
267
|
+
type: 'image'
|
|
268
|
+
// TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
|
|
269
|
+
}));
|
|
270
|
+
|
|
271
|
+
var space = state.schema.text(' ');
|
|
272
|
+
var content = _model.Fragment.from([mediaInlineNode, space]);
|
|
273
|
+
var node = paragraph.createChecked({}, content);
|
|
274
|
+
var from = state.selection.from;
|
|
275
|
+
var tr = state.tr;
|
|
276
|
+
tr = (0, _utils.removeSelectedNode)(tr);
|
|
277
|
+
tr = (0, _utils.safeInsert)(node, from, true)(tr);
|
|
278
|
+
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
279
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, from + 3));
|
|
280
|
+
if (dispatch) {
|
|
281
|
+
dispatch(tr);
|
|
282
|
+
}
|
|
283
|
+
return true;
|
|
284
|
+
};
|
|
251
285
|
};
|
|
@@ -225,6 +225,48 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
// floating and inline switcher
|
|
229
|
+
if (pluginState.allowInlineImages && selectedNode && (0, _utils2.canShowSwitchButtons)(selectedNode.node)) {
|
|
230
|
+
var _pluginInjectionApi$a4;
|
|
231
|
+
var inlineSwitcherTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
232
|
+
var floatingSwitcherTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
233
|
+
|
|
234
|
+
// This is temporary for PF release and can be removed once we have border and link support for inline images
|
|
235
|
+
// TODO: [ED-20261] remove this once both border and link marks are supported for inline image
|
|
236
|
+
var tempTooltipContent = /*#__PURE__*/_react.default.createElement("span", null, "Display inline ", /*#__PURE__*/_react.default.createElement("br", null), " \u26A0 This feature is being developed. The conversion process will not retain the image size, link, border, or any other data.");
|
|
237
|
+
toolbarButtons.push({
|
|
238
|
+
type: 'button',
|
|
239
|
+
id: 'editor.media.image.view.switcher.inline',
|
|
240
|
+
title: inlineSwitcherTitle,
|
|
241
|
+
tooltipContent: tempTooltipContent,
|
|
242
|
+
icon: function icon() {
|
|
243
|
+
return /*#__PURE__*/_react.default.createElement(_card.IconInline, {
|
|
244
|
+
size: "medium",
|
|
245
|
+
label: inlineSwitcherTitle
|
|
246
|
+
});
|
|
247
|
+
},
|
|
248
|
+
onClick: (0, _commands.changeMediaSingleToMediaInline)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions),
|
|
249
|
+
testId: 'image-inline-appearance'
|
|
250
|
+
}, {
|
|
251
|
+
type: 'button',
|
|
252
|
+
id: 'editor.media.image.view.switcher.floating',
|
|
253
|
+
title: floatingSwitcherTitle,
|
|
254
|
+
icon: function icon() {
|
|
255
|
+
return /*#__PURE__*/_react.default.createElement(_card.IconEmbed, {
|
|
256
|
+
size: "medium",
|
|
257
|
+
label: floatingSwitcherTitle
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
onClick: function onClick() {
|
|
261
|
+
return true;
|
|
262
|
+
},
|
|
263
|
+
testId: 'image-floating-appearance',
|
|
264
|
+
selected: true
|
|
265
|
+
}, {
|
|
266
|
+
type: 'separator'
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
228
270
|
// Pixel Entry Toolbar Support
|
|
229
271
|
var selection = state.selection;
|
|
230
272
|
var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
|
|
@@ -282,11 +324,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
282
324
|
}
|
|
283
325
|
},
|
|
284
326
|
onSubmit: function onSubmit(_ref2) {
|
|
285
|
-
var _pluginInjectionApi$
|
|
327
|
+
var _pluginInjectionApi$a5;
|
|
286
328
|
var width = _ref2.width,
|
|
287
329
|
validation = _ref2.validation;
|
|
288
330
|
var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
289
|
-
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
331
|
+
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
290
332
|
},
|
|
291
333
|
onMigrate: function onMigrate() {
|
|
292
334
|
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
@@ -341,10 +383,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
341
383
|
};
|
|
342
384
|
var openLink = function openLink() {
|
|
343
385
|
if (editorView) {
|
|
344
|
-
var _pluginInjectionApi$
|
|
386
|
+
var _pluginInjectionApi$a6;
|
|
345
387
|
var tr = editorView.state.tr,
|
|
346
388
|
dispatch = editorView.dispatch;
|
|
347
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
389
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
348
390
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
349
391
|
action: _analytics.ACTION.VISITED,
|
|
350
392
|
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
@@ -370,8 +412,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
370
412
|
}
|
|
371
413
|
}
|
|
372
414
|
if (allowAltTextOnImages) {
|
|
373
|
-
var _pluginInjectionApi$
|
|
374
|
-
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
415
|
+
var _pluginInjectionApi$a7;
|
|
416
|
+
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), {
|
|
375
417
|
type: 'separator'
|
|
376
418
|
});
|
|
377
419
|
}
|
|
@@ -461,14 +503,14 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
461
503
|
selectedNodeType = state.selection.node.type;
|
|
462
504
|
}
|
|
463
505
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
464
|
-
var _pluginInjectionApi$
|
|
506
|
+
var _pluginInjectionApi$a8;
|
|
465
507
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
466
508
|
baseToolbar.getDomRef = function () {
|
|
467
509
|
var _mediaPluginState$ele;
|
|
468
510
|
var selector = (0, _mediaFilmstrip.mediaFilmstripItemDOMSelector)(mediaOffset);
|
|
469
511
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
470
512
|
};
|
|
471
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
513
|
+
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);
|
|
472
514
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
473
515
|
baseToolbar.getDomRef = function () {
|
|
474
516
|
var _mediaPluginState$ele2;
|
|
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.removeMediaGroupNode = exports.getSelectedMediaSingle = exports.getSelectedMediaContainerNodeAttrs = exports.getSelectedLayoutIcon = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.calcNewLayout = void 0;
|
|
7
|
+
exports.removeMediaGroupNode = exports.getSelectedMediaSingle = exports.getSelectedMediaContainerNodeAttrs = exports.getSelectedLayoutIcon = exports.getPixelWidthOfElement = exports.getMaxToolbarWidth = exports.downloadMedia = exports.canShowSwitchButtons = exports.calcNewLayout = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _memoizeOne = _interopRequireDefault(require("memoize-one"));
|
|
@@ -13,6 +13,7 @@ var _utils = require("@atlaskit/editor-common/utils");
|
|
|
13
13
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
14
14
|
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
15
15
|
var _mediaClientReact = require("@atlaskit/media-client-react");
|
|
16
|
+
var _mediaSingle2 = require("../utils/media-single");
|
|
16
17
|
var getSelectedMediaContainerNodeAttrs = exports.getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
17
18
|
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
18
19
|
if (selectedNode && selectedNode.attrs) {
|
|
@@ -118,4 +119,16 @@ var getSelectedLayoutIcon = exports.getSelectedLayoutIcon = function getSelected
|
|
|
118
119
|
return layoutIcons.find(function (icon) {
|
|
119
120
|
return icon.value === (_utils.nonWrappedLayouts.includes(selectedLayout) ? 'center' : selectedLayout);
|
|
120
121
|
});
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Check if 'original size' and 'inline' buttons can be shown in the toolbar for a given mediaSingle node.
|
|
126
|
+
* @param mediaSingleNode node to be checked
|
|
127
|
+
*/
|
|
128
|
+
var canShowSwitchButtons = exports.canShowSwitchButtons = function canShowSwitchButtons(mediaSingleNode) {
|
|
129
|
+
if (mediaSingleNode) {
|
|
130
|
+
var mediaNode = mediaSingleNode.content.firstChild;
|
|
131
|
+
return mediaNode && !(0, _mediaSingle2.isVideo)(mediaNode.attrs.__fileMimeType);
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
121
134
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
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
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
6
6
|
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
@@ -224,4 +224,40 @@ export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation,
|
|
|
224
224
|
dispatch(tr);
|
|
225
225
|
}
|
|
226
226
|
return true;
|
|
227
|
+
};
|
|
228
|
+
export const changeMediaSingleToMediaInline = editorAnalyticsAPI => (state, dispatch) => {
|
|
229
|
+
const selectedNodeWithPos = getSelectedMediaSingle(state);
|
|
230
|
+
const {
|
|
231
|
+
mediaInline,
|
|
232
|
+
paragraph
|
|
233
|
+
} = state.schema.nodes;
|
|
234
|
+
if (!selectedNodeWithPos) {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
const mediaSingleNode = selectedNodeWithPos.node;
|
|
238
|
+
const mediaNode = mediaSingleNode.firstChild;
|
|
239
|
+
if (!mediaNode) {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
const mediaInlineNode = mediaInline.create({
|
|
243
|
+
...mediaNode.attrs,
|
|
244
|
+
type: 'image'
|
|
245
|
+
// TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
const space = state.schema.text(' ');
|
|
249
|
+
const content = Fragment.from([mediaInlineNode, space]);
|
|
250
|
+
const node = paragraph.createChecked({}, content);
|
|
251
|
+
const {
|
|
252
|
+
from
|
|
253
|
+
} = state.selection;
|
|
254
|
+
let tr = state.tr;
|
|
255
|
+
tr = removeSelectedNode(tr);
|
|
256
|
+
tr = safeInsert(node, from, true)(tr);
|
|
257
|
+
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
258
|
+
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
259
|
+
if (dispatch) {
|
|
260
|
+
dispatch(tr);
|
|
261
|
+
}
|
|
262
|
+
return true;
|
|
227
263
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
4
|
-
import { alignmentIcons, buildLayoutButtons, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
4
|
+
import { alignmentIcons, buildLayoutButtons, IconEmbed, IconInline, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
5
5
|
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
6
|
-
import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { findParentNodeOfType, hasParentNode, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -22,14 +22,14 @@ import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
|
|
|
22
22
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
23
23
|
import { isVideo } from '../utils/media-single';
|
|
24
24
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
25
|
-
import { changeMediaCardToInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
25
|
+
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
26
26
|
import { FilePreviewItem } from './filePreviewItem';
|
|
27
27
|
import { shouldShowImageBorder } from './imageBorder';
|
|
28
28
|
import { LayoutGroup } from './layout-group';
|
|
29
29
|
import { getLinkingToolbar, shouldShowMediaLinkToolbar } from './linking';
|
|
30
30
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
31
31
|
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
32
|
-
import { calcNewLayout, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
32
|
+
import { calcNewLayout, canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
33
33
|
const mediaTypeMessages = {
|
|
34
34
|
image: messages.file_image_is_selected,
|
|
35
35
|
video: messages.file_video_is_selected,
|
|
@@ -220,6 +220,44 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
|
|
223
|
+
// floating and inline switcher
|
|
224
|
+
if (pluginState.allowInlineImages && selectedNode && canShowSwitchButtons(selectedNode.node)) {
|
|
225
|
+
var _pluginInjectionApi$a4;
|
|
226
|
+
const inlineSwitcherTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
227
|
+
const floatingSwitcherTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
228
|
+
|
|
229
|
+
// This is temporary for PF release and can be removed once we have border and link support for inline images
|
|
230
|
+
// TODO: [ED-20261] remove this once both border and link marks are supported for inline image
|
|
231
|
+
const tempTooltipContent = /*#__PURE__*/React.createElement("span", null, "Display inline ", /*#__PURE__*/React.createElement("br", null), " \u26A0 This feature is being developed. The conversion process will not retain the image size, link, border, or any other data.");
|
|
232
|
+
toolbarButtons.push({
|
|
233
|
+
type: 'button',
|
|
234
|
+
id: 'editor.media.image.view.switcher.inline',
|
|
235
|
+
title: inlineSwitcherTitle,
|
|
236
|
+
tooltipContent: tempTooltipContent,
|
|
237
|
+
icon: () => /*#__PURE__*/React.createElement(IconInline, {
|
|
238
|
+
size: "medium",
|
|
239
|
+
label: inlineSwitcherTitle
|
|
240
|
+
}),
|
|
241
|
+
onClick: changeMediaSingleToMediaInline(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions),
|
|
242
|
+
testId: 'image-inline-appearance'
|
|
243
|
+
}, {
|
|
244
|
+
type: 'button',
|
|
245
|
+
id: 'editor.media.image.view.switcher.floating',
|
|
246
|
+
title: floatingSwitcherTitle,
|
|
247
|
+
icon: () => /*#__PURE__*/React.createElement(IconEmbed, {
|
|
248
|
+
size: "medium",
|
|
249
|
+
label: floatingSwitcherTitle
|
|
250
|
+
}),
|
|
251
|
+
onClick: () => {
|
|
252
|
+
return true;
|
|
253
|
+
},
|
|
254
|
+
testId: 'image-floating-appearance',
|
|
255
|
+
selected: true
|
|
256
|
+
}, {
|
|
257
|
+
type: 'separator'
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
|
|
223
261
|
// Pixel Entry Toolbar Support
|
|
224
262
|
const {
|
|
225
263
|
selection
|
|
@@ -284,9 +322,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
284
322
|
width,
|
|
285
323
|
validation
|
|
286
324
|
}) => {
|
|
287
|
-
var _pluginInjectionApi$
|
|
325
|
+
var _pluginInjectionApi$a5;
|
|
288
326
|
const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
289
|
-
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
327
|
+
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
290
328
|
},
|
|
291
329
|
onMigrate: () => {
|
|
292
330
|
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
@@ -346,14 +384,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
346
384
|
};
|
|
347
385
|
const openLink = () => {
|
|
348
386
|
if (editorView) {
|
|
349
|
-
var _pluginInjectionApi$
|
|
387
|
+
var _pluginInjectionApi$a6;
|
|
350
388
|
const {
|
|
351
389
|
state: {
|
|
352
390
|
tr
|
|
353
391
|
},
|
|
354
392
|
dispatch
|
|
355
393
|
} = editorView;
|
|
356
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
394
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
357
395
|
eventType: EVENT_TYPE.TRACK,
|
|
358
396
|
action: ACTION.VISITED,
|
|
359
397
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -379,8 +417,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
379
417
|
}
|
|
380
418
|
}
|
|
381
419
|
if (allowAltTextOnImages) {
|
|
382
|
-
var _pluginInjectionApi$
|
|
383
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
420
|
+
var _pluginInjectionApi$a7;
|
|
421
|
+
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), {
|
|
384
422
|
type: 'separator'
|
|
385
423
|
});
|
|
386
424
|
}
|
|
@@ -468,14 +506,14 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
468
506
|
selectedNodeType = state.selection.node.type;
|
|
469
507
|
}
|
|
470
508
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
471
|
-
var _pluginInjectionApi$
|
|
509
|
+
var _pluginInjectionApi$a8;
|
|
472
510
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
473
511
|
baseToolbar.getDomRef = () => {
|
|
474
512
|
var _mediaPluginState$ele;
|
|
475
513
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
476
514
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
477
515
|
};
|
|
478
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
516
|
+
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);
|
|
479
517
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
480
518
|
baseToolbar.getDomRef = () => {
|
|
481
519
|
var _mediaPluginState$ele2;
|
|
@@ -4,6 +4,7 @@ import { nonWrappedLayouts } from '@atlaskit/editor-common/utils';
|
|
|
4
4
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
6
6
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
7
|
+
import { isVideo } from '../utils/media-single';
|
|
7
8
|
export const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
|
|
8
9
|
const selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
9
10
|
if (selectedNode && selectedNode.attrs) {
|
|
@@ -91,4 +92,16 @@ export const getMaxToolbarWidth = () => {
|
|
|
91
92
|
export const getSelectedLayoutIcon = (layoutIcons, selectedNode) => {
|
|
92
93
|
const selectedLayout = selectedNode.attrs.layout;
|
|
93
94
|
return layoutIcons.find(icon => icon.value === (nonWrappedLayouts.includes(selectedLayout) ? 'center' : selectedLayout));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Check if 'original size' and 'inline' buttons can be shown in the toolbar for a given mediaSingle node.
|
|
99
|
+
* @param mediaSingleNode node to be checked
|
|
100
|
+
*/
|
|
101
|
+
export const canShowSwitchButtons = mediaSingleNode => {
|
|
102
|
+
if (mediaSingleNode) {
|
|
103
|
+
const mediaNode = mediaSingleNode.content.firstChild;
|
|
104
|
+
return mediaNode && !isVideo(mediaNode.attrs.__fileMimeType);
|
|
105
|
+
}
|
|
106
|
+
return false;
|
|
94
107
|
};
|
|
@@ -3,7 +3,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
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
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
|
-
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
8
|
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
9
9
|
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
@@ -241,4 +241,38 @@ export var updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyt
|
|
|
241
241
|
return true;
|
|
242
242
|
};
|
|
243
243
|
};
|
|
244
|
+
};
|
|
245
|
+
export var changeMediaSingleToMediaInline = function changeMediaSingleToMediaInline(editorAnalyticsAPI) {
|
|
246
|
+
return function (state, dispatch) {
|
|
247
|
+
var selectedNodeWithPos = getSelectedMediaSingle(state);
|
|
248
|
+
var _state$schema$nodes3 = state.schema.nodes,
|
|
249
|
+
mediaInline = _state$schema$nodes3.mediaInline,
|
|
250
|
+
paragraph = _state$schema$nodes3.paragraph;
|
|
251
|
+
if (!selectedNodeWithPos) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
var mediaSingleNode = selectedNodeWithPos.node;
|
|
255
|
+
var mediaNode = mediaSingleNode.firstChild;
|
|
256
|
+
if (!mediaNode) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
260
|
+
type: 'image'
|
|
261
|
+
// TODO: [ED-20261] copy marks across once both border and link marks are supported for inline image
|
|
262
|
+
}));
|
|
263
|
+
|
|
264
|
+
var space = state.schema.text(' ');
|
|
265
|
+
var content = Fragment.from([mediaInlineNode, space]);
|
|
266
|
+
var node = paragraph.createChecked({}, content);
|
|
267
|
+
var from = state.selection.from;
|
|
268
|
+
var tr = state.tr;
|
|
269
|
+
tr = removeSelectedNode(tr);
|
|
270
|
+
tr = safeInsert(node, from, true)(tr);
|
|
271
|
+
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
272
|
+
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
273
|
+
if (dispatch) {
|
|
274
|
+
dispatch(tr);
|
|
275
|
+
}
|
|
276
|
+
return true;
|
|
277
|
+
};
|
|
244
278
|
};
|
|
@@ -5,9 +5,9 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
5
5
|
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; }
|
|
6
6
|
import React from 'react';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { alignmentIcons, buildLayoutButtons, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
8
|
+
import { alignmentIcons, buildLayoutButtons, IconEmbed, IconInline, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
9
9
|
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
10
|
-
import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
11
11
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
12
|
import { findParentNodeOfType, hasParentNode, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
13
13
|
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
@@ -26,14 +26,14 @@ import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
|
|
|
26
26
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
27
27
|
import { isVideo } from '../utils/media-single';
|
|
28
28
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
29
|
-
import { changeMediaCardToInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
29
|
+
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
30
30
|
import { FilePreviewItem } from './filePreviewItem';
|
|
31
31
|
import { shouldShowImageBorder } from './imageBorder';
|
|
32
32
|
import { LayoutGroup } from './layout-group';
|
|
33
33
|
import { getLinkingToolbar, shouldShowMediaLinkToolbar } from './linking';
|
|
34
34
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
35
35
|
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
36
|
-
import { calcNewLayout, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
36
|
+
import { calcNewLayout, canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
37
37
|
var mediaTypeMessages = {
|
|
38
38
|
image: messages.file_image_is_selected,
|
|
39
39
|
video: messages.file_video_is_selected,
|
|
@@ -215,6 +215,48 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
+
// floating and inline switcher
|
|
219
|
+
if (pluginState.allowInlineImages && selectedNode && canShowSwitchButtons(selectedNode.node)) {
|
|
220
|
+
var _pluginInjectionApi$a4;
|
|
221
|
+
var inlineSwitcherTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
222
|
+
var floatingSwitcherTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
223
|
+
|
|
224
|
+
// This is temporary for PF release and can be removed once we have border and link support for inline images
|
|
225
|
+
// TODO: [ED-20261] remove this once both border and link marks are supported for inline image
|
|
226
|
+
var tempTooltipContent = /*#__PURE__*/React.createElement("span", null, "Display inline ", /*#__PURE__*/React.createElement("br", null), " \u26A0 This feature is being developed. The conversion process will not retain the image size, link, border, or any other data.");
|
|
227
|
+
toolbarButtons.push({
|
|
228
|
+
type: 'button',
|
|
229
|
+
id: 'editor.media.image.view.switcher.inline',
|
|
230
|
+
title: inlineSwitcherTitle,
|
|
231
|
+
tooltipContent: tempTooltipContent,
|
|
232
|
+
icon: function icon() {
|
|
233
|
+
return /*#__PURE__*/React.createElement(IconInline, {
|
|
234
|
+
size: "medium",
|
|
235
|
+
label: inlineSwitcherTitle
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
onClick: changeMediaSingleToMediaInline(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions),
|
|
239
|
+
testId: 'image-inline-appearance'
|
|
240
|
+
}, {
|
|
241
|
+
type: 'button',
|
|
242
|
+
id: 'editor.media.image.view.switcher.floating',
|
|
243
|
+
title: floatingSwitcherTitle,
|
|
244
|
+
icon: function icon() {
|
|
245
|
+
return /*#__PURE__*/React.createElement(IconEmbed, {
|
|
246
|
+
size: "medium",
|
|
247
|
+
label: floatingSwitcherTitle
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
onClick: function onClick() {
|
|
251
|
+
return true;
|
|
252
|
+
},
|
|
253
|
+
testId: 'image-floating-appearance',
|
|
254
|
+
selected: true
|
|
255
|
+
}, {
|
|
256
|
+
type: 'separator'
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
|
|
218
260
|
// Pixel Entry Toolbar Support
|
|
219
261
|
var selection = state.selection;
|
|
220
262
|
var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
@@ -272,11 +314,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
272
314
|
}
|
|
273
315
|
},
|
|
274
316
|
onSubmit: function onSubmit(_ref2) {
|
|
275
|
-
var _pluginInjectionApi$
|
|
317
|
+
var _pluginInjectionApi$a5;
|
|
276
318
|
var width = _ref2.width,
|
|
277
319
|
validation = _ref2.validation;
|
|
278
320
|
var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
279
|
-
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
321
|
+
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
280
322
|
},
|
|
281
323
|
onMigrate: function onMigrate() {
|
|
282
324
|
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
@@ -331,10 +373,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
331
373
|
};
|
|
332
374
|
var openLink = function openLink() {
|
|
333
375
|
if (editorView) {
|
|
334
|
-
var _pluginInjectionApi$
|
|
376
|
+
var _pluginInjectionApi$a6;
|
|
335
377
|
var tr = editorView.state.tr,
|
|
336
378
|
dispatch = editorView.dispatch;
|
|
337
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
379
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
338
380
|
eventType: EVENT_TYPE.TRACK,
|
|
339
381
|
action: ACTION.VISITED,
|
|
340
382
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -360,8 +402,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
360
402
|
}
|
|
361
403
|
}
|
|
362
404
|
if (allowAltTextOnImages) {
|
|
363
|
-
var _pluginInjectionApi$
|
|
364
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
405
|
+
var _pluginInjectionApi$a7;
|
|
406
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
365
407
|
type: 'separator'
|
|
366
408
|
});
|
|
367
409
|
}
|
|
@@ -451,14 +493,14 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
451
493
|
selectedNodeType = state.selection.node.type;
|
|
452
494
|
}
|
|
453
495
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
454
|
-
var _pluginInjectionApi$
|
|
496
|
+
var _pluginInjectionApi$a8;
|
|
455
497
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
456
498
|
baseToolbar.getDomRef = function () {
|
|
457
499
|
var _mediaPluginState$ele;
|
|
458
500
|
var selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
459
501
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
460
502
|
};
|
|
461
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
503
|
+
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);
|
|
462
504
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
463
505
|
baseToolbar.getDomRef = function () {
|
|
464
506
|
var _mediaPluginState$ele2;
|
|
@@ -6,6 +6,7 @@ import { nonWrappedLayouts } from '@atlaskit/editor-common/utils';
|
|
|
6
6
|
import { findParentNodeOfType, findSelectedNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
8
8
|
import { getMediaClient } from '@atlaskit/media-client-react';
|
|
9
|
+
import { isVideo } from '../utils/media-single';
|
|
9
10
|
export var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
10
11
|
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
11
12
|
if (selectedNode && selectedNode.attrs) {
|
|
@@ -111,4 +112,16 @@ export var getSelectedLayoutIcon = function getSelectedLayoutIcon(layoutIcons, s
|
|
|
111
112
|
return layoutIcons.find(function (icon) {
|
|
112
113
|
return icon.value === (nonWrappedLayouts.includes(selectedLayout) ? 'center' : selectedLayout);
|
|
113
114
|
});
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Check if 'original size' and 'inline' buttons can be shown in the toolbar for a given mediaSingle node.
|
|
119
|
+
* @param mediaSingleNode node to be checked
|
|
120
|
+
*/
|
|
121
|
+
export var canShowSwitchButtons = function canShowSwitchButtons(mediaSingleNode) {
|
|
122
|
+
if (mediaSingleNode) {
|
|
123
|
+
var mediaNode = mediaSingleNode.content.firstChild;
|
|
124
|
+
return mediaNode && !isVideo(mediaNode.attrs.__fileMimeType);
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
114
127
|
};
|
|
@@ -13,3 +13,4 @@ export declare const removeInlineCard: Command;
|
|
|
13
13
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
14
14
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
15
15
|
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
|
16
|
+
export declare const changeMediaSingleToMediaInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -12,3 +12,8 @@ export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(e
|
|
|
12
12
|
export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean, isNested?: boolean) => RichMediaLayout;
|
|
13
13
|
export declare const getMaxToolbarWidth: () => number;
|
|
14
14
|
export declare const getSelectedLayoutIcon: (layoutIcons: LayoutIcon[], selectedNode: ProseMirrorNode) => LayoutIcon | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Check if 'original size' and 'inline' buttons can be shown in the toolbar for a given mediaSingle node.
|
|
17
|
+
* @param mediaSingleNode node to be checked
|
|
18
|
+
*/
|
|
19
|
+
export declare const canShowSwitchButtons: (mediaSingleNode?: ProseMirrorNode) => boolean | null;
|
|
@@ -13,3 +13,4 @@ export declare const removeInlineCard: Command;
|
|
|
13
13
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
14
14
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
15
15
|
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
|
16
|
+
export declare const changeMediaSingleToMediaInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -12,3 +12,8 @@ export declare const getPixelWidthOfElement: import("memoize-one").MemoizedFn<(e
|
|
|
12
12
|
export declare const calcNewLayout: (width: number, layout: RichMediaLayout, contentWidth: number, fullWidthMode?: boolean, isNested?: boolean) => RichMediaLayout;
|
|
13
13
|
export declare const getMaxToolbarWidth: () => number;
|
|
14
14
|
export declare const getSelectedLayoutIcon: (layoutIcons: LayoutIcon[], selectedNode: ProseMirrorNode) => LayoutIcon | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Check if 'original size' and 'inline' buttons can be shown in the toolbar for a given mediaSingle node.
|
|
17
|
+
* @param mediaSingleNode node to be checked
|
|
18
|
+
*/
|
|
19
|
+
export declare const canShowSwitchButtons: (mediaSingleNode?: ProseMirrorNode) => boolean | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"./types": "./src/types.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/adf-schema": "^35.
|
|
35
|
+
"@atlaskit/adf-schema": "^35.1.0",
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.7.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
38
|
"@atlaskit/button": "^16.18.0",
|