@atlaskit/editor-plugin-media 0.4.9 → 0.4.10
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 +7 -0
- package/dist/cjs/toolbar/index.js +2 -74
- package/dist/cjs/toolbar/mediaInline.js +127 -0
- package/dist/es2019/toolbar/index.js +2 -76
- package/dist/es2019/toolbar/mediaInline.js +121 -0
- package/dist/esm/toolbar/index.js +2 -74
- package/dist/esm/toolbar/mediaInline.js +117 -0
- package/dist/types/toolbar/mediaInline.d.ts +8 -0
- package/dist/types-ts4.5/toolbar/mediaInline.d.ts +8 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58567](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58567) [`5c0892098c84`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c0892098c84) - add media inline image floating toolbar under FF
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 0.4.9
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -38,6 +38,7 @@ var _imageBorder = require("./imageBorder");
|
|
|
38
38
|
var _layoutGroup = require("./layout-group");
|
|
39
39
|
var _linking3 = require("./linking");
|
|
40
40
|
var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
|
|
41
|
+
var _mediaInline = require("./mediaInline");
|
|
41
42
|
var _utils2 = require("./utils");
|
|
42
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
43
44
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -129,79 +130,6 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
129
130
|
}];
|
|
130
131
|
return items;
|
|
131
132
|
};
|
|
132
|
-
var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
133
|
-
var mediaInline = state.schema.nodes.mediaInline;
|
|
134
|
-
var items = [{
|
|
135
|
-
id: 'editor.media.view.switcher',
|
|
136
|
-
type: 'dropdown',
|
|
137
|
-
title: intl.formatMessage(_mediaUi.messages.changeView),
|
|
138
|
-
options: [{
|
|
139
|
-
id: 'editor.media.view.switcher.inline',
|
|
140
|
-
title: intl.formatMessage(_messages.cardMessages.inline),
|
|
141
|
-
selected: true,
|
|
142
|
-
disabled: false,
|
|
143
|
-
onClick: function onClick() {
|
|
144
|
-
return true;
|
|
145
|
-
},
|
|
146
|
-
testId: 'inline-appearance'
|
|
147
|
-
}, {
|
|
148
|
-
id: 'editor.media.view.switcher.thumbnail',
|
|
149
|
-
title: intl.formatMessage(_mediaUi.messages.displayThumbnail),
|
|
150
|
-
selected: false,
|
|
151
|
-
disabled: false,
|
|
152
|
-
onClick: (0, _commands.changeInlineToMediaCard)(editorAnalyticsAPI),
|
|
153
|
-
testId: 'thumbnail-appearance'
|
|
154
|
-
}]
|
|
155
|
-
}, {
|
|
156
|
-
type: 'separator'
|
|
157
|
-
}, {
|
|
158
|
-
type: 'custom',
|
|
159
|
-
fallback: [],
|
|
160
|
-
render: function render() {
|
|
161
|
-
return /*#__PURE__*/_react.default.createElement(_filePreviewItem.FilePreviewItem, {
|
|
162
|
-
key: "editor.media.card.preview",
|
|
163
|
-
mediaPluginState: mediaPluginState,
|
|
164
|
-
intl: intl
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}, {
|
|
168
|
-
type: 'separator'
|
|
169
|
-
}, {
|
|
170
|
-
id: 'editor.media.card.download',
|
|
171
|
-
type: 'button',
|
|
172
|
-
icon: _download.default,
|
|
173
|
-
onClick: function onClick() {
|
|
174
|
-
(0, _utils2.downloadMedia)(mediaPluginState);
|
|
175
|
-
return true;
|
|
176
|
-
},
|
|
177
|
-
title: intl.formatMessage(_mediaUi.messages.download)
|
|
178
|
-
}, {
|
|
179
|
-
type: 'separator'
|
|
180
|
-
}, {
|
|
181
|
-
type: 'copy-button',
|
|
182
|
-
items: [{
|
|
183
|
-
state: state,
|
|
184
|
-
formatMessage: intl.formatMessage,
|
|
185
|
-
nodeType: mediaInline
|
|
186
|
-
}, {
|
|
187
|
-
type: 'separator'
|
|
188
|
-
}]
|
|
189
|
-
}, {
|
|
190
|
-
id: 'editor.media.delete',
|
|
191
|
-
type: 'button',
|
|
192
|
-
appearance: 'danger',
|
|
193
|
-
focusEditoronEnter: true,
|
|
194
|
-
icon: _remove.default,
|
|
195
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
196
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
197
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
198
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
199
|
-
title: intl.formatMessage(_messages.default.remove),
|
|
200
|
-
onClick: _commands.removeInlineCard,
|
|
201
|
-
testId: 'media-toolbar-remove-button'
|
|
202
|
-
}];
|
|
203
|
-
return items;
|
|
204
|
-
};
|
|
205
133
|
var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
|
|
206
134
|
var _pluginInjectionApi$d;
|
|
207
135
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
@@ -534,7 +462,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
534
462
|
var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(_styles.MediaInlineNodeSelector));
|
|
535
463
|
return element || mediaPluginState.element;
|
|
536
464
|
};
|
|
537
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions);
|
|
465
|
+
items = (0, _mediaInline.generateMediaInlineFloatingToolbar)(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions);
|
|
538
466
|
} else {
|
|
539
467
|
baseToolbar.getDomRef = function () {
|
|
540
468
|
var _mediaPluginState$ele3;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getMediaInlineImageToolbar = exports.generateMediaInlineFloatingToolbar = void 0;
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
11
|
+
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
12
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _download = _interopRequireDefault(require("@atlaskit/icon/glyph/download"));
|
|
14
|
+
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
15
|
+
var _mediaUi = require("@atlaskit/media-ui");
|
|
16
|
+
var _commands = require("./commands");
|
|
17
|
+
var _filePreviewItem = require("./filePreviewItem");
|
|
18
|
+
var _utils = require("./utils");
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
21
|
+
var generateMediaInlineFloatingToolbar = exports.generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
22
|
+
var mediaInline = state.schema.nodes.mediaInline;
|
|
23
|
+
var mediaType = state.selection instanceof _state.NodeSelection && state.selection.node.attrs.type;
|
|
24
|
+
if ((0, _mediaInline.shouldShowInlineImage)(mediaType)) {
|
|
25
|
+
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI);
|
|
26
|
+
}
|
|
27
|
+
var items = [{
|
|
28
|
+
id: 'editor.media.view.switcher',
|
|
29
|
+
type: 'dropdown',
|
|
30
|
+
title: intl.formatMessage(_mediaUi.messages.changeView),
|
|
31
|
+
options: [{
|
|
32
|
+
id: 'editor.media.view.switcher.inline',
|
|
33
|
+
title: intl.formatMessage(_messages.cardMessages.inline),
|
|
34
|
+
selected: true,
|
|
35
|
+
disabled: false,
|
|
36
|
+
onClick: function onClick() {
|
|
37
|
+
return true;
|
|
38
|
+
},
|
|
39
|
+
testId: 'inline-appearance'
|
|
40
|
+
}, {
|
|
41
|
+
id: 'editor.media.view.switcher.thumbnail',
|
|
42
|
+
title: intl.formatMessage(_mediaUi.messages.displayThumbnail),
|
|
43
|
+
selected: false,
|
|
44
|
+
disabled: false,
|
|
45
|
+
onClick: (0, _commands.changeInlineToMediaCard)(editorAnalyticsAPI),
|
|
46
|
+
testId: 'thumbnail-appearance'
|
|
47
|
+
}]
|
|
48
|
+
}, {
|
|
49
|
+
type: 'separator'
|
|
50
|
+
}, {
|
|
51
|
+
type: 'custom',
|
|
52
|
+
fallback: [],
|
|
53
|
+
render: function render() {
|
|
54
|
+
return /*#__PURE__*/_react.default.createElement(_filePreviewItem.FilePreviewItem, {
|
|
55
|
+
key: "editor.media.card.preview",
|
|
56
|
+
mediaPluginState: mediaPluginState,
|
|
57
|
+
intl: intl
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}, {
|
|
61
|
+
type: 'separator'
|
|
62
|
+
}, {
|
|
63
|
+
id: 'editor.media.card.download',
|
|
64
|
+
type: 'button',
|
|
65
|
+
icon: _download.default,
|
|
66
|
+
onClick: function onClick() {
|
|
67
|
+
(0, _utils.downloadMedia)(mediaPluginState);
|
|
68
|
+
return true;
|
|
69
|
+
},
|
|
70
|
+
title: intl.formatMessage(_mediaUi.messages.download)
|
|
71
|
+
}, {
|
|
72
|
+
type: 'separator'
|
|
73
|
+
}, {
|
|
74
|
+
type: 'copy-button',
|
|
75
|
+
items: [{
|
|
76
|
+
state: state,
|
|
77
|
+
formatMessage: intl.formatMessage,
|
|
78
|
+
nodeType: mediaInline
|
|
79
|
+
}, {
|
|
80
|
+
type: 'separator'
|
|
81
|
+
}]
|
|
82
|
+
}, {
|
|
83
|
+
id: 'editor.media.delete',
|
|
84
|
+
type: 'button',
|
|
85
|
+
appearance: 'danger',
|
|
86
|
+
focusEditoronEnter: true,
|
|
87
|
+
icon: _remove.default,
|
|
88
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
89
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
90
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
91
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
92
|
+
title: intl.formatMessage(_messages.default.remove),
|
|
93
|
+
onClick: _commands.removeInlineCard,
|
|
94
|
+
testId: 'media-toolbar-remove-button'
|
|
95
|
+
}];
|
|
96
|
+
return items;
|
|
97
|
+
};
|
|
98
|
+
var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
99
|
+
var mediaInline = state.schema.nodes.mediaInline;
|
|
100
|
+
// if type is image, return inline image floating toolbar items
|
|
101
|
+
var inlineImageItems = [
|
|
102
|
+
// TODO: border marks, media single switcher, link, alt text, etc
|
|
103
|
+
{
|
|
104
|
+
type: 'copy-button',
|
|
105
|
+
items: [{
|
|
106
|
+
state: state,
|
|
107
|
+
formatMessage: intl.formatMessage,
|
|
108
|
+
nodeType: mediaInline
|
|
109
|
+
}, {
|
|
110
|
+
type: 'separator'
|
|
111
|
+
}]
|
|
112
|
+
}, {
|
|
113
|
+
id: 'editor.media.delete',
|
|
114
|
+
type: 'button',
|
|
115
|
+
appearance: 'danger',
|
|
116
|
+
focusEditoronEnter: true,
|
|
117
|
+
icon: _remove.default,
|
|
118
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
119
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
120
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
121
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
122
|
+
title: intl.formatMessage(_messages.default.remove),
|
|
123
|
+
onClick: _commands.removeInlineCard,
|
|
124
|
+
testId: 'media-toolbar-remove-button'
|
|
125
|
+
}];
|
|
126
|
+
return inlineImageItems;
|
|
127
|
+
};
|
|
@@ -22,12 +22,13 @@ 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 {
|
|
25
|
+
import { changeMediaCardToInline, 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
|
+
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
31
32
|
import { calcNewLayout, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
32
33
|
const remove = (state, dispatch) => {
|
|
33
34
|
if (dispatch) {
|
|
@@ -117,81 +118,6 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
117
118
|
}];
|
|
118
119
|
return items;
|
|
119
120
|
};
|
|
120
|
-
const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) => {
|
|
121
|
-
const {
|
|
122
|
-
mediaInline
|
|
123
|
-
} = state.schema.nodes;
|
|
124
|
-
const items = [{
|
|
125
|
-
id: 'editor.media.view.switcher',
|
|
126
|
-
type: 'dropdown',
|
|
127
|
-
title: intl.formatMessage(messages.changeView),
|
|
128
|
-
options: [{
|
|
129
|
-
id: 'editor.media.view.switcher.inline',
|
|
130
|
-
title: intl.formatMessage(cardMessages.inline),
|
|
131
|
-
selected: true,
|
|
132
|
-
disabled: false,
|
|
133
|
-
onClick: () => {
|
|
134
|
-
return true;
|
|
135
|
-
},
|
|
136
|
-
testId: 'inline-appearance'
|
|
137
|
-
}, {
|
|
138
|
-
id: 'editor.media.view.switcher.thumbnail',
|
|
139
|
-
title: intl.formatMessage(messages.displayThumbnail),
|
|
140
|
-
selected: false,
|
|
141
|
-
disabled: false,
|
|
142
|
-
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
143
|
-
testId: 'thumbnail-appearance'
|
|
144
|
-
}]
|
|
145
|
-
}, {
|
|
146
|
-
type: 'separator'
|
|
147
|
-
}, {
|
|
148
|
-
type: 'custom',
|
|
149
|
-
fallback: [],
|
|
150
|
-
render: () => {
|
|
151
|
-
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
152
|
-
key: "editor.media.card.preview",
|
|
153
|
-
mediaPluginState: mediaPluginState,
|
|
154
|
-
intl: intl
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}, {
|
|
158
|
-
type: 'separator'
|
|
159
|
-
}, {
|
|
160
|
-
id: 'editor.media.card.download',
|
|
161
|
-
type: 'button',
|
|
162
|
-
icon: DownloadIcon,
|
|
163
|
-
onClick: () => {
|
|
164
|
-
downloadMedia(mediaPluginState);
|
|
165
|
-
return true;
|
|
166
|
-
},
|
|
167
|
-
title: intl.formatMessage(messages.download)
|
|
168
|
-
}, {
|
|
169
|
-
type: 'separator'
|
|
170
|
-
}, {
|
|
171
|
-
type: 'copy-button',
|
|
172
|
-
items: [{
|
|
173
|
-
state,
|
|
174
|
-
formatMessage: intl.formatMessage,
|
|
175
|
-
nodeType: mediaInline
|
|
176
|
-
}, {
|
|
177
|
-
type: 'separator'
|
|
178
|
-
}]
|
|
179
|
-
}, {
|
|
180
|
-
id: 'editor.media.delete',
|
|
181
|
-
type: 'button',
|
|
182
|
-
appearance: 'danger',
|
|
183
|
-
focusEditoronEnter: true,
|
|
184
|
-
icon: RemoveIcon,
|
|
185
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
186
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
187
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
188
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
189
|
-
title: intl.formatMessage(commonMessages.remove),
|
|
190
|
-
onClick: removeInlineCard,
|
|
191
|
-
testId: 'media-toolbar-remove-button'
|
|
192
|
-
}];
|
|
193
|
-
return items;
|
|
194
|
-
};
|
|
195
121
|
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
|
|
196
122
|
var _pluginInjectionApi$d;
|
|
197
123
|
const {
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shouldShowInlineImage } from '@atlaskit/editor-common/media-inline';
|
|
3
|
+
import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
6
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
7
|
+
import { messages } from '@atlaskit/media-ui';
|
|
8
|
+
import { changeInlineToMediaCard, removeInlineCard } from './commands';
|
|
9
|
+
import { FilePreviewItem } from './filePreviewItem';
|
|
10
|
+
import { downloadMedia } from './utils';
|
|
11
|
+
export const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) => {
|
|
12
|
+
const {
|
|
13
|
+
mediaInline
|
|
14
|
+
} = state.schema.nodes;
|
|
15
|
+
const mediaType = state.selection instanceof NodeSelection && state.selection.node.attrs.type;
|
|
16
|
+
if (shouldShowInlineImage(mediaType)) {
|
|
17
|
+
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI);
|
|
18
|
+
}
|
|
19
|
+
const items = [{
|
|
20
|
+
id: 'editor.media.view.switcher',
|
|
21
|
+
type: 'dropdown',
|
|
22
|
+
title: intl.formatMessage(messages.changeView),
|
|
23
|
+
options: [{
|
|
24
|
+
id: 'editor.media.view.switcher.inline',
|
|
25
|
+
title: intl.formatMessage(cardMessages.inline),
|
|
26
|
+
selected: true,
|
|
27
|
+
disabled: false,
|
|
28
|
+
onClick: () => {
|
|
29
|
+
return true;
|
|
30
|
+
},
|
|
31
|
+
testId: 'inline-appearance'
|
|
32
|
+
}, {
|
|
33
|
+
id: 'editor.media.view.switcher.thumbnail',
|
|
34
|
+
title: intl.formatMessage(messages.displayThumbnail),
|
|
35
|
+
selected: false,
|
|
36
|
+
disabled: false,
|
|
37
|
+
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
38
|
+
testId: 'thumbnail-appearance'
|
|
39
|
+
}]
|
|
40
|
+
}, {
|
|
41
|
+
type: 'separator'
|
|
42
|
+
}, {
|
|
43
|
+
type: 'custom',
|
|
44
|
+
fallback: [],
|
|
45
|
+
render: () => {
|
|
46
|
+
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
47
|
+
key: "editor.media.card.preview",
|
|
48
|
+
mediaPluginState: mediaPluginState,
|
|
49
|
+
intl: intl
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
type: 'separator'
|
|
54
|
+
}, {
|
|
55
|
+
id: 'editor.media.card.download',
|
|
56
|
+
type: 'button',
|
|
57
|
+
icon: DownloadIcon,
|
|
58
|
+
onClick: () => {
|
|
59
|
+
downloadMedia(mediaPluginState);
|
|
60
|
+
return true;
|
|
61
|
+
},
|
|
62
|
+
title: intl.formatMessage(messages.download)
|
|
63
|
+
}, {
|
|
64
|
+
type: 'separator'
|
|
65
|
+
}, {
|
|
66
|
+
type: 'copy-button',
|
|
67
|
+
items: [{
|
|
68
|
+
state,
|
|
69
|
+
formatMessage: intl.formatMessage,
|
|
70
|
+
nodeType: mediaInline
|
|
71
|
+
}, {
|
|
72
|
+
type: 'separator'
|
|
73
|
+
}]
|
|
74
|
+
}, {
|
|
75
|
+
id: 'editor.media.delete',
|
|
76
|
+
type: 'button',
|
|
77
|
+
appearance: 'danger',
|
|
78
|
+
focusEditoronEnter: true,
|
|
79
|
+
icon: RemoveIcon,
|
|
80
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
81
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
82
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
83
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
84
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
85
|
+
onClick: removeInlineCard,
|
|
86
|
+
testId: 'media-toolbar-remove-button'
|
|
87
|
+
}];
|
|
88
|
+
return items;
|
|
89
|
+
};
|
|
90
|
+
export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) => {
|
|
91
|
+
const {
|
|
92
|
+
mediaInline
|
|
93
|
+
} = state.schema.nodes;
|
|
94
|
+
// if type is image, return inline image floating toolbar items
|
|
95
|
+
const inlineImageItems = [
|
|
96
|
+
// TODO: border marks, media single switcher, link, alt text, etc
|
|
97
|
+
{
|
|
98
|
+
type: 'copy-button',
|
|
99
|
+
items: [{
|
|
100
|
+
state,
|
|
101
|
+
formatMessage: intl.formatMessage,
|
|
102
|
+
nodeType: mediaInline
|
|
103
|
+
}, {
|
|
104
|
+
type: 'separator'
|
|
105
|
+
}]
|
|
106
|
+
}, {
|
|
107
|
+
id: 'editor.media.delete',
|
|
108
|
+
type: 'button',
|
|
109
|
+
appearance: 'danger',
|
|
110
|
+
focusEditoronEnter: true,
|
|
111
|
+
icon: RemoveIcon,
|
|
112
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
113
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
114
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
115
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
116
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
117
|
+
onClick: removeInlineCard,
|
|
118
|
+
testId: 'media-toolbar-remove-button'
|
|
119
|
+
}];
|
|
120
|
+
return inlineImageItems;
|
|
121
|
+
};
|
|
@@ -26,12 +26,13 @@ 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 {
|
|
29
|
+
import { changeMediaCardToInline, 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
|
+
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
35
36
|
import { calcNewLayout, downloadMedia, getMaxToolbarWidth, getPixelWidthOfElement, getSelectedLayoutIcon, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
36
37
|
var remove = function remove(state, dispatch) {
|
|
37
38
|
if (dispatch) {
|
|
@@ -119,79 +120,6 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
119
120
|
}];
|
|
120
121
|
return items;
|
|
121
122
|
};
|
|
122
|
-
var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
123
|
-
var mediaInline = state.schema.nodes.mediaInline;
|
|
124
|
-
var items = [{
|
|
125
|
-
id: 'editor.media.view.switcher',
|
|
126
|
-
type: 'dropdown',
|
|
127
|
-
title: intl.formatMessage(messages.changeView),
|
|
128
|
-
options: [{
|
|
129
|
-
id: 'editor.media.view.switcher.inline',
|
|
130
|
-
title: intl.formatMessage(cardMessages.inline),
|
|
131
|
-
selected: true,
|
|
132
|
-
disabled: false,
|
|
133
|
-
onClick: function onClick() {
|
|
134
|
-
return true;
|
|
135
|
-
},
|
|
136
|
-
testId: 'inline-appearance'
|
|
137
|
-
}, {
|
|
138
|
-
id: 'editor.media.view.switcher.thumbnail',
|
|
139
|
-
title: intl.formatMessage(messages.displayThumbnail),
|
|
140
|
-
selected: false,
|
|
141
|
-
disabled: false,
|
|
142
|
-
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
143
|
-
testId: 'thumbnail-appearance'
|
|
144
|
-
}]
|
|
145
|
-
}, {
|
|
146
|
-
type: 'separator'
|
|
147
|
-
}, {
|
|
148
|
-
type: 'custom',
|
|
149
|
-
fallback: [],
|
|
150
|
-
render: function render() {
|
|
151
|
-
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
152
|
-
key: "editor.media.card.preview",
|
|
153
|
-
mediaPluginState: mediaPluginState,
|
|
154
|
-
intl: intl
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
}, {
|
|
158
|
-
type: 'separator'
|
|
159
|
-
}, {
|
|
160
|
-
id: 'editor.media.card.download',
|
|
161
|
-
type: 'button',
|
|
162
|
-
icon: DownloadIcon,
|
|
163
|
-
onClick: function onClick() {
|
|
164
|
-
downloadMedia(mediaPluginState);
|
|
165
|
-
return true;
|
|
166
|
-
},
|
|
167
|
-
title: intl.formatMessage(messages.download)
|
|
168
|
-
}, {
|
|
169
|
-
type: 'separator'
|
|
170
|
-
}, {
|
|
171
|
-
type: 'copy-button',
|
|
172
|
-
items: [{
|
|
173
|
-
state: state,
|
|
174
|
-
formatMessage: intl.formatMessage,
|
|
175
|
-
nodeType: mediaInline
|
|
176
|
-
}, {
|
|
177
|
-
type: 'separator'
|
|
178
|
-
}]
|
|
179
|
-
}, {
|
|
180
|
-
id: 'editor.media.delete',
|
|
181
|
-
type: 'button',
|
|
182
|
-
appearance: 'danger',
|
|
183
|
-
focusEditoronEnter: true,
|
|
184
|
-
icon: RemoveIcon,
|
|
185
|
-
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
186
|
-
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
187
|
-
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
188
|
-
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
189
|
-
title: intl.formatMessage(commonMessages.remove),
|
|
190
|
-
onClick: removeInlineCard,
|
|
191
|
-
testId: 'media-toolbar-remove-button'
|
|
192
|
-
}];
|
|
193
|
-
return items;
|
|
194
|
-
};
|
|
195
123
|
var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
|
|
196
124
|
var _pluginInjectionApi$d;
|
|
197
125
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shouldShowInlineImage } from '@atlaskit/editor-common/media-inline';
|
|
3
|
+
import commonMessages, { cardMessages } from '@atlaskit/editor-common/messages';
|
|
4
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
+
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
6
|
+
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
7
|
+
import { messages } from '@atlaskit/media-ui';
|
|
8
|
+
import { changeInlineToMediaCard, removeInlineCard } from './commands';
|
|
9
|
+
import { FilePreviewItem } from './filePreviewItem';
|
|
10
|
+
import { downloadMedia } from './utils';
|
|
11
|
+
export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
12
|
+
var mediaInline = state.schema.nodes.mediaInline;
|
|
13
|
+
var mediaType = state.selection instanceof NodeSelection && state.selection.node.attrs.type;
|
|
14
|
+
if (shouldShowInlineImage(mediaType)) {
|
|
15
|
+
return getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI);
|
|
16
|
+
}
|
|
17
|
+
var items = [{
|
|
18
|
+
id: 'editor.media.view.switcher',
|
|
19
|
+
type: 'dropdown',
|
|
20
|
+
title: intl.formatMessage(messages.changeView),
|
|
21
|
+
options: [{
|
|
22
|
+
id: 'editor.media.view.switcher.inline',
|
|
23
|
+
title: intl.formatMessage(cardMessages.inline),
|
|
24
|
+
selected: true,
|
|
25
|
+
disabled: false,
|
|
26
|
+
onClick: function onClick() {
|
|
27
|
+
return true;
|
|
28
|
+
},
|
|
29
|
+
testId: 'inline-appearance'
|
|
30
|
+
}, {
|
|
31
|
+
id: 'editor.media.view.switcher.thumbnail',
|
|
32
|
+
title: intl.formatMessage(messages.displayThumbnail),
|
|
33
|
+
selected: false,
|
|
34
|
+
disabled: false,
|
|
35
|
+
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
36
|
+
testId: 'thumbnail-appearance'
|
|
37
|
+
}]
|
|
38
|
+
}, {
|
|
39
|
+
type: 'separator'
|
|
40
|
+
}, {
|
|
41
|
+
type: 'custom',
|
|
42
|
+
fallback: [],
|
|
43
|
+
render: function render() {
|
|
44
|
+
return /*#__PURE__*/React.createElement(FilePreviewItem, {
|
|
45
|
+
key: "editor.media.card.preview",
|
|
46
|
+
mediaPluginState: mediaPluginState,
|
|
47
|
+
intl: intl
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}, {
|
|
51
|
+
type: 'separator'
|
|
52
|
+
}, {
|
|
53
|
+
id: 'editor.media.card.download',
|
|
54
|
+
type: 'button',
|
|
55
|
+
icon: DownloadIcon,
|
|
56
|
+
onClick: function onClick() {
|
|
57
|
+
downloadMedia(mediaPluginState);
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
title: intl.formatMessage(messages.download)
|
|
61
|
+
}, {
|
|
62
|
+
type: 'separator'
|
|
63
|
+
}, {
|
|
64
|
+
type: 'copy-button',
|
|
65
|
+
items: [{
|
|
66
|
+
state: state,
|
|
67
|
+
formatMessage: intl.formatMessage,
|
|
68
|
+
nodeType: mediaInline
|
|
69
|
+
}, {
|
|
70
|
+
type: 'separator'
|
|
71
|
+
}]
|
|
72
|
+
}, {
|
|
73
|
+
id: 'editor.media.delete',
|
|
74
|
+
type: 'button',
|
|
75
|
+
appearance: 'danger',
|
|
76
|
+
focusEditoronEnter: true,
|
|
77
|
+
icon: RemoveIcon,
|
|
78
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
79
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
80
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
81
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
82
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
83
|
+
onClick: removeInlineCard,
|
|
84
|
+
testId: 'media-toolbar-remove-button'
|
|
85
|
+
}];
|
|
86
|
+
return items;
|
|
87
|
+
};
|
|
88
|
+
export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) {
|
|
89
|
+
var mediaInline = state.schema.nodes.mediaInline;
|
|
90
|
+
// if type is image, return inline image floating toolbar items
|
|
91
|
+
var inlineImageItems = [
|
|
92
|
+
// TODO: border marks, media single switcher, link, alt text, etc
|
|
93
|
+
{
|
|
94
|
+
type: 'copy-button',
|
|
95
|
+
items: [{
|
|
96
|
+
state: state,
|
|
97
|
+
formatMessage: intl.formatMessage,
|
|
98
|
+
nodeType: mediaInline
|
|
99
|
+
}, {
|
|
100
|
+
type: 'separator'
|
|
101
|
+
}]
|
|
102
|
+
}, {
|
|
103
|
+
id: 'editor.media.delete',
|
|
104
|
+
type: 'button',
|
|
105
|
+
appearance: 'danger',
|
|
106
|
+
focusEditoronEnter: true,
|
|
107
|
+
icon: RemoveIcon,
|
|
108
|
+
onMouseEnter: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
109
|
+
onMouseLeave: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
110
|
+
onFocus: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, true),
|
|
111
|
+
onBlur: hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaInline, false),
|
|
112
|
+
title: intl.formatMessage(commonMessages.remove),
|
|
113
|
+
onClick: removeInlineCard,
|
|
114
|
+
testId: 'media-toolbar-remove-button'
|
|
115
|
+
}];
|
|
116
|
+
return inlineImageItems;
|
|
117
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { MediaPluginState } from '../pm-plugins/types';
|
|
7
|
+
export declare const generateMediaInlineFloatingToolbar: (state: EditorState, intl: IntlShape, mediaPluginState: MediaPluginState, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarItem<Command>[];
|
|
8
|
+
export declare const getMediaInlineImageToolbar: (state: EditorState, intl: IntlShape, mediaPluginState: MediaPluginState, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarItem<Command>[];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import type { Command, FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { MediaPluginState } from '../pm-plugins/types';
|
|
7
|
+
export declare const generateMediaInlineFloatingToolbar: (state: EditorState, intl: IntlShape, mediaPluginState: MediaPluginState, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarItem<Command>[];
|
|
8
|
+
export declare const getMediaInlineImageToolbar: (state: EditorState, intl: IntlShape, mediaPluginState: MediaPluginState, hoverDecoration: HoverDecorationHandler | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarItem<Command>[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.10",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.7.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
38
|
"@atlaskit/button": "^16.17.0",
|
|
39
|
-
"@atlaskit/editor-common": "^76.
|
|
39
|
+
"@atlaskit/editor-common": "^76.25.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.5.2",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
42
42
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|