@atlaskit/editor-plugin-media 0.9.1 → 0.10.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/toolbar/commands.js +4 -5
- package/dist/cjs/toolbar/imageBorder.js +1 -1
- package/dist/cjs/toolbar/index.js +1 -1
- package/dist/cjs/toolbar/mediaInline.js +39 -11
- package/dist/cjs/utils/current-media-node.js +3 -3
- package/dist/es2019/toolbar/commands.js +6 -7
- package/dist/es2019/toolbar/imageBorder.js +2 -2
- package/dist/es2019/toolbar/index.js +2 -2
- package/dist/es2019/toolbar/mediaInline.js +42 -12
- package/dist/es2019/utils/current-media-node.js +2 -2
- package/dist/esm/toolbar/commands.js +6 -7
- package/dist/esm/toolbar/imageBorder.js +2 -2
- package/dist/esm/toolbar/index.js +2 -2
- package/dist/esm/toolbar/mediaInline.js +40 -12
- package/dist/esm/utils/current-media-node.js +2 -2
- package/dist/types/utils/current-media-node.d.ts +1 -1
- package/dist/types-ts4.5/utils/current-media-node.d.ts +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.10.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#65562](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65562) [`857a5d841564`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/857a5d841564) - add analytics to track media single to media inline convert
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.10.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [#64354](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/64354) [`b07fcd05c2c9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b07fcd05c2c9) - [ux] Added border support for media inline node
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [#65031](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65031) [`a00094111b5a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a00094111b5a) - ED-21609 Update adf-schema to 35.3.0
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 0.9.1
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -118,7 +118,7 @@ var removeInlineCard = exports.removeInlineCard = function removeInlineCard(stat
|
|
|
118
118
|
};
|
|
119
119
|
var toggleBorderMark = exports.toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
|
|
120
120
|
return function (state, dispatch) {
|
|
121
|
-
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
|
|
121
|
+
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
|
|
122
122
|
if (!nodeWithPos) {
|
|
123
123
|
return false;
|
|
124
124
|
}
|
|
@@ -173,7 +173,7 @@ var setBorderMark = exports.setBorderMark = function setBorderMark(editorAnalyti
|
|
|
173
173
|
return function (attrs) {
|
|
174
174
|
return function (state, dispatch) {
|
|
175
175
|
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
176
|
-
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state);
|
|
176
|
+
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(state) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(state);
|
|
177
177
|
if (!nodeWithPos) {
|
|
178
178
|
return false;
|
|
179
179
|
}
|
|
@@ -265,9 +265,7 @@ var changeMediaSingleToMediaInline = exports.changeMediaSingleToMediaInline = fu
|
|
|
265
265
|
}
|
|
266
266
|
var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
267
267
|
type: 'image'
|
|
268
|
-
|
|
269
|
-
}));
|
|
270
|
-
|
|
268
|
+
}), null, mediaNode.marks);
|
|
271
269
|
var space = state.schema.text(' ');
|
|
272
270
|
var content = _model.Fragment.from([mediaInlineNode, space]);
|
|
273
271
|
var node = paragraph.createChecked({}, content);
|
|
@@ -278,6 +276,7 @@ var changeMediaSingleToMediaInline = exports.changeMediaSingleToMediaInline = fu
|
|
|
278
276
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
279
277
|
tr.setSelection(_state.TextSelection.create(tr.doc, from + 3));
|
|
280
278
|
if (dispatch) {
|
|
279
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent((0, _analytics2.getChangeMediaAnalytics)(_analytics.ACTION_SUBJECT_ID.MEDIA_SINGLE, _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE, (0, _analytics2.findChangeFromLocation)(state.selection)))(tr);
|
|
281
280
|
dispatch(tr);
|
|
282
281
|
}
|
|
283
282
|
return true;
|
|
@@ -10,7 +10,7 @@ function shouldShowImageBorder(editorState) {
|
|
|
10
10
|
if (!border) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
|
-
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(editorState);
|
|
13
|
+
var nodeWithPos = (0, _currentMediaNode.currentMediaNodeWithPos)(editorState) || (0, _currentMediaNode.currentMediaInlineNodeWithPos)(editorState);
|
|
14
14
|
if (!nodeWithPos) {
|
|
15
15
|
return false;
|
|
16
16
|
}
|
|
@@ -159,7 +159,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
159
159
|
}
|
|
160
160
|
var dispatch = editorView.dispatch,
|
|
161
161
|
state = editorView.state;
|
|
162
|
-
var borderMark = (0, _currentMediaNode.
|
|
162
|
+
var borderMark = (0, _currentMediaNode.currentMediaOrInlineNodeBorderMark)(state);
|
|
163
163
|
return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
|
|
164
164
|
toggleBorder: function toggleBorder() {
|
|
165
165
|
var _pluginInjectionApi$a;
|
|
@@ -16,10 +16,13 @@ var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove
|
|
|
16
16
|
var _mediaUi = require("@atlaskit/media-ui");
|
|
17
17
|
var _linking = require("../commands/linking");
|
|
18
18
|
var _linking2 = require("../pm-plugins/linking");
|
|
19
|
+
var _ImageBorder = _interopRequireDefault(require("../ui/ImageBorder"));
|
|
20
|
+
var _currentMediaNode = require("../utils/current-media-node");
|
|
19
21
|
var _isType = require("../utils/is-type");
|
|
20
22
|
var _altText = require("./alt-text");
|
|
21
23
|
var _commands = require("./commands");
|
|
22
24
|
var _filePreviewItem = require("./filePreviewItem");
|
|
25
|
+
var _imageBorder = require("./imageBorder");
|
|
23
26
|
var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
|
|
24
27
|
var _utils = require("./utils");
|
|
25
28
|
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); }
|
|
@@ -111,13 +114,38 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
|
|
|
111
114
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
112
115
|
var mediaInlineImageTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
113
116
|
var mediaSingleTitle = intl.formatMessage(_messages.mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
114
|
-
|
|
115
|
-
// TODO: border marks, media single switcher, alt text, etc
|
|
116
117
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
var inlineImageItems = [];
|
|
119
|
+
if ((0, _imageBorder.shouldShowImageBorder)(state)) {
|
|
120
|
+
inlineImageItems.push({
|
|
121
|
+
type: 'custom',
|
|
122
|
+
fallback: [],
|
|
123
|
+
render: function render(editorView) {
|
|
124
|
+
if (!editorView) {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
var dispatch = editorView.dispatch,
|
|
128
|
+
state = editorView.state;
|
|
129
|
+
var borderMark = (0, _currentMediaNode.currentMediaOrInlineNodeBorderMark)(state);
|
|
130
|
+
return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
|
|
131
|
+
toggleBorder: function toggleBorder() {
|
|
132
|
+
var _pluginInjectionApi$a2;
|
|
133
|
+
(0, _commands.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
|
|
134
|
+
},
|
|
135
|
+
setBorder: function setBorder(attrs) {
|
|
136
|
+
var _pluginInjectionApi$a3;
|
|
137
|
+
(0, _commands.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
|
|
138
|
+
},
|
|
139
|
+
borderMark: borderMark,
|
|
140
|
+
intl: intl
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
inlineImageItems.push({
|
|
145
|
+
type: 'separator'
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
inlineImageItems.push({
|
|
121
149
|
id: 'editor.media.convert.mediainline',
|
|
122
150
|
type: 'button',
|
|
123
151
|
title: mediaInlineImageTitle,
|
|
@@ -144,10 +172,10 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
|
|
|
144
172
|
onClick: (0, _commands.changeMediaInlineToMediaSingle)(editorAnalyticsAPI, widthPluginState)
|
|
145
173
|
}, {
|
|
146
174
|
type: 'separator'
|
|
147
|
-
}
|
|
175
|
+
});
|
|
148
176
|
if (options.allowAltTextOnImages) {
|
|
149
|
-
var _pluginInjectionApi$
|
|
150
|
-
inlineImageItems.push((0, _altText.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
177
|
+
var _pluginInjectionApi$a4;
|
|
178
|
+
inlineImageItems.push((0, _altText.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
|
|
151
179
|
type: 'separator'
|
|
152
180
|
});
|
|
153
181
|
}
|
|
@@ -165,10 +193,10 @@ var getMediaInlineImageToolbar = exports.getMediaInlineImageToolbar = function g
|
|
|
165
193
|
};
|
|
166
194
|
var openLink = function openLink() {
|
|
167
195
|
if (editorView) {
|
|
168
|
-
var _pluginInjectionApi$
|
|
196
|
+
var _pluginInjectionApi$a5;
|
|
169
197
|
var tr = editorView.state.tr,
|
|
170
198
|
dispatch = editorView.dispatch;
|
|
171
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
199
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
|
|
172
200
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
173
201
|
action: _analytics.ACTION.VISITED,
|
|
174
202
|
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.currentMediaOrInlineNodeBorderMark = exports.currentMediaNodeWithPos = exports.currentMediaNode = exports.currentMediaInlineNodeWithPos = exports.currentMediaInlineNode = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
8
|
var currentMediaNodeWithPos = exports.currentMediaNodeWithPos = function currentMediaNodeWithPos(editorState) {
|
|
9
9
|
var doc = editorState.doc,
|
|
@@ -47,8 +47,8 @@ var currentMediaInlineNode = exports.currentMediaInlineNode = function currentMe
|
|
|
47
47
|
var _currentMediaInlineNo;
|
|
48
48
|
return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
|
|
49
49
|
};
|
|
50
|
-
var
|
|
51
|
-
var node = currentMediaNode(editorState);
|
|
50
|
+
var currentMediaOrInlineNodeBorderMark = exports.currentMediaOrInlineNodeBorderMark = function currentMediaOrInlineNodeBorderMark(editorState) {
|
|
51
|
+
var node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
|
|
52
52
|
if (!node) {
|
|
53
53
|
return;
|
|
54
54
|
}
|
|
@@ -2,8 +2,8 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
6
|
-
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
5
|
+
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
6
|
+
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
7
7
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
8
8
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
9
9
|
export const DEFAULT_BORDER_COLOR = '#091e4224';
|
|
@@ -106,7 +106,7 @@ export const removeInlineCard = (state, dispatch) => {
|
|
|
106
106
|
return false;
|
|
107
107
|
};
|
|
108
108
|
export const toggleBorderMark = editorAnalyticsAPI => (state, dispatch) => {
|
|
109
|
-
const nodeWithPos = currentMediaNodeWithPos(state);
|
|
109
|
+
const nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
|
|
110
110
|
if (!nodeWithPos) {
|
|
111
111
|
return false;
|
|
112
112
|
}
|
|
@@ -156,7 +156,7 @@ export const toggleBorderMark = editorAnalyticsAPI => (state, dispatch) => {
|
|
|
156
156
|
};
|
|
157
157
|
export const setBorderMark = editorAnalyticsAPI => attrs => (state, dispatch) => {
|
|
158
158
|
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
159
|
-
const nodeWithPos = currentMediaNodeWithPos(state);
|
|
159
|
+
const nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
|
|
160
160
|
if (!nodeWithPos) {
|
|
161
161
|
return false;
|
|
162
162
|
}
|
|
@@ -242,9 +242,7 @@ export const changeMediaSingleToMediaInline = editorAnalyticsAPI => (state, disp
|
|
|
242
242
|
const mediaInlineNode = mediaInline.create({
|
|
243
243
|
...mediaNode.attrs,
|
|
244
244
|
type: 'image'
|
|
245
|
-
|
|
246
|
-
});
|
|
247
|
-
|
|
245
|
+
}, null, mediaNode.marks);
|
|
248
246
|
const space = state.schema.text(' ');
|
|
249
247
|
const content = Fragment.from([mediaInlineNode, space]);
|
|
250
248
|
const node = paragraph.createChecked({}, content);
|
|
@@ -257,6 +255,7 @@ export const changeMediaSingleToMediaInline = editorAnalyticsAPI => (state, disp
|
|
|
257
255
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
258
256
|
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
259
257
|
if (dispatch) {
|
|
258
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(ACTION_SUBJECT_ID.MEDIA_SINGLE, ACTION_SUBJECT_ID.MEDIA_INLINE, findChangeFromLocation(state.selection)))(tr);
|
|
260
259
|
dispatch(tr);
|
|
261
260
|
}
|
|
262
261
|
return true;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
1
|
+
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
2
2
|
export function shouldShowImageBorder(editorState) {
|
|
3
3
|
const border = editorState.schema.marks.border;
|
|
4
4
|
if (!border) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
const nodeWithPos = currentMediaNodeWithPos(editorState);
|
|
7
|
+
const nodeWithPos = currentMediaNodeWithPos(editorState) || currentMediaInlineNodeWithPos(editorState);
|
|
8
8
|
if (!nodeWithPos) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -19,7 +19,7 @@ import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
|
19
19
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
20
20
|
import ImageBorderItem from '../ui/ImageBorder';
|
|
21
21
|
import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
|
|
22
|
-
import {
|
|
22
|
+
import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
|
|
23
23
|
import { isVideo } from '../utils/media-single';
|
|
24
24
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
25
25
|
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
@@ -154,7 +154,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
154
154
|
dispatch,
|
|
155
155
|
state
|
|
156
156
|
} = editorView;
|
|
157
|
-
const borderMark =
|
|
157
|
+
const borderMark = currentMediaOrInlineNodeBorderMark(state);
|
|
158
158
|
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
159
159
|
toggleBorder: () => {
|
|
160
160
|
var _pluginInjectionApi$a;
|
|
@@ -8,10 +8,13 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
8
8
|
import { messages } from '@atlaskit/media-ui';
|
|
9
9
|
import { showLinkingToolbar } from '../commands/linking';
|
|
10
10
|
import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
11
|
+
import ImageBorderItem from '../ui/ImageBorder';
|
|
12
|
+
import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
|
|
11
13
|
import { isImage } from '../utils/is-type';
|
|
12
14
|
import { altTextButton } from './alt-text';
|
|
13
|
-
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
|
|
15
|
+
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
14
16
|
import { FilePreviewItem } from './filePreviewItem';
|
|
17
|
+
import { shouldShowImageBorder } from './imageBorder';
|
|
15
18
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
16
19
|
import { downloadMedia } from './utils';
|
|
17
20
|
export const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options = {}) => {
|
|
@@ -103,13 +106,40 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
|
|
|
103
106
|
} = state.schema.nodes;
|
|
104
107
|
const mediaInlineImageTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
105
108
|
const mediaSingleTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
106
|
-
|
|
107
|
-
// TODO: border marks, media single switcher, alt text, etc
|
|
108
109
|
const widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
const inlineImageItems = [];
|
|
111
|
+
if (shouldShowImageBorder(state)) {
|
|
112
|
+
inlineImageItems.push({
|
|
113
|
+
type: 'custom',
|
|
114
|
+
fallback: [],
|
|
115
|
+
render: editorView => {
|
|
116
|
+
if (!editorView) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const {
|
|
120
|
+
dispatch,
|
|
121
|
+
state
|
|
122
|
+
} = editorView;
|
|
123
|
+
const borderMark = currentMediaOrInlineNodeBorderMark(state);
|
|
124
|
+
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
125
|
+
toggleBorder: () => {
|
|
126
|
+
var _pluginInjectionApi$a2;
|
|
127
|
+
toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
|
|
128
|
+
},
|
|
129
|
+
setBorder: attrs => {
|
|
130
|
+
var _pluginInjectionApi$a3;
|
|
131
|
+
setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
|
|
132
|
+
},
|
|
133
|
+
borderMark: borderMark,
|
|
134
|
+
intl: intl
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
inlineImageItems.push({
|
|
139
|
+
type: 'separator'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
inlineImageItems.push({
|
|
113
143
|
id: 'editor.media.convert.mediainline',
|
|
114
144
|
type: 'button',
|
|
115
145
|
title: mediaInlineImageTitle,
|
|
@@ -132,10 +162,10 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
|
|
|
132
162
|
onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
|
|
133
163
|
}, {
|
|
134
164
|
type: 'separator'
|
|
135
|
-
}
|
|
165
|
+
});
|
|
136
166
|
if (options.allowAltTextOnImages) {
|
|
137
|
-
var _pluginInjectionApi$
|
|
138
|
-
inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
167
|
+
var _pluginInjectionApi$a4;
|
|
168
|
+
inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
|
|
139
169
|
type: 'separator'
|
|
140
170
|
});
|
|
141
171
|
}
|
|
@@ -155,14 +185,14 @@ export const getMediaInlineImageToolbar = (state, intl, mediaPluginState, hoverD
|
|
|
155
185
|
};
|
|
156
186
|
const openLink = () => {
|
|
157
187
|
if (editorView) {
|
|
158
|
-
var _pluginInjectionApi$
|
|
188
|
+
var _pluginInjectionApi$a5;
|
|
159
189
|
const {
|
|
160
190
|
state: {
|
|
161
191
|
tr
|
|
162
192
|
},
|
|
163
193
|
dispatch
|
|
164
194
|
} = editorView;
|
|
165
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
195
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
|
|
166
196
|
eventType: EVENT_TYPE.TRACK,
|
|
167
197
|
action: ACTION.VISITED,
|
|
168
198
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -45,8 +45,8 @@ export const currentMediaInlineNode = editorState => {
|
|
|
45
45
|
var _currentMediaInlineNo;
|
|
46
46
|
return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
|
|
47
47
|
};
|
|
48
|
-
export const
|
|
49
|
-
const node = currentMediaNode(editorState);
|
|
48
|
+
export const currentMediaOrInlineNodeBorderMark = editorState => {
|
|
49
|
+
const node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
|
|
50
50
|
if (!node) {
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
@@ -5,8 +5,8 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
-
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
9
|
-
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
8
|
+
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
9
|
+
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
10
10
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
11
11
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
12
12
|
export var DEFAULT_BORDER_COLOR = '#091e4224';
|
|
@@ -111,7 +111,7 @@ export var removeInlineCard = function removeInlineCard(state, dispatch) {
|
|
|
111
111
|
};
|
|
112
112
|
export var toggleBorderMark = function toggleBorderMark(editorAnalyticsAPI) {
|
|
113
113
|
return function (state, dispatch) {
|
|
114
|
-
var nodeWithPos = currentMediaNodeWithPos(state);
|
|
114
|
+
var nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
|
|
115
115
|
if (!nodeWithPos) {
|
|
116
116
|
return false;
|
|
117
117
|
}
|
|
@@ -166,7 +166,7 @@ export var setBorderMark = function setBorderMark(editorAnalyticsAPI) {
|
|
|
166
166
|
return function (attrs) {
|
|
167
167
|
return function (state, dispatch) {
|
|
168
168
|
var _node$marks$find, _ref, _attrs$color, _ref2, _attrs$size;
|
|
169
|
-
var nodeWithPos = currentMediaNodeWithPos(state);
|
|
169
|
+
var nodeWithPos = currentMediaNodeWithPos(state) || currentMediaInlineNodeWithPos(state);
|
|
170
170
|
if (!nodeWithPos) {
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
@@ -258,9 +258,7 @@ export var changeMediaSingleToMediaInline = function changeMediaSingleToMediaInl
|
|
|
258
258
|
}
|
|
259
259
|
var mediaInlineNode = mediaInline.create(_objectSpread(_objectSpread({}, mediaNode.attrs), {}, {
|
|
260
260
|
type: 'image'
|
|
261
|
-
|
|
262
|
-
}));
|
|
263
|
-
|
|
261
|
+
}), null, mediaNode.marks);
|
|
264
262
|
var space = state.schema.text(' ');
|
|
265
263
|
var content = Fragment.from([mediaInlineNode, space]);
|
|
266
264
|
var node = paragraph.createChecked({}, content);
|
|
@@ -271,6 +269,7 @@ export var changeMediaSingleToMediaInline = function changeMediaSingleToMediaInl
|
|
|
271
269
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
272
270
|
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
273
271
|
if (dispatch) {
|
|
272
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(ACTION_SUBJECT_ID.MEDIA_SINGLE, ACTION_SUBJECT_ID.MEDIA_INLINE, findChangeFromLocation(state.selection)))(tr);
|
|
274
273
|
dispatch(tr);
|
|
275
274
|
}
|
|
276
275
|
return true;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
1
|
+
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
2
2
|
export function shouldShowImageBorder(editorState) {
|
|
3
3
|
var border = editorState.schema.marks.border;
|
|
4
4
|
if (!border) {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
var nodeWithPos = currentMediaNodeWithPos(editorState);
|
|
7
|
+
var nodeWithPos = currentMediaNodeWithPos(editorState) || currentMediaInlineNodeWithPos(editorState);
|
|
8
8
|
if (!nodeWithPos) {
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
@@ -23,7 +23,7 @@ import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
|
23
23
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
24
24
|
import ImageBorderItem from '../ui/ImageBorder';
|
|
25
25
|
import { FullWidthDisplay, PixelEntry } from '../ui/PixelEntry';
|
|
26
|
-
import {
|
|
26
|
+
import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
|
|
27
27
|
import { isVideo } from '../utils/media-single';
|
|
28
28
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
29
29
|
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark, updateMediaSingleWidth } from './commands';
|
|
@@ -149,7 +149,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
149
149
|
}
|
|
150
150
|
var dispatch = editorView.dispatch,
|
|
151
151
|
state = editorView.state;
|
|
152
|
-
var borderMark =
|
|
152
|
+
var borderMark = currentMediaOrInlineNodeBorderMark(state);
|
|
153
153
|
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
154
154
|
toggleBorder: function toggleBorder() {
|
|
155
155
|
var _pluginInjectionApi$a;
|
|
@@ -8,10 +8,13 @@ import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
|
8
8
|
import { messages } from '@atlaskit/media-ui';
|
|
9
9
|
import { showLinkingToolbar } from '../commands/linking';
|
|
10
10
|
import { getMediaLinkingState } from '../pm-plugins/linking';
|
|
11
|
+
import ImageBorderItem from '../ui/ImageBorder';
|
|
12
|
+
import { currentMediaOrInlineNodeBorderMark } from '../utils/current-media-node';
|
|
11
13
|
import { isImage } from '../utils/is-type';
|
|
12
14
|
import { altTextButton } from './alt-text';
|
|
13
|
-
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard } from './commands';
|
|
15
|
+
import { changeInlineToMediaCard, changeMediaInlineToMediaSingle, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
14
16
|
import { FilePreviewItem } from './filePreviewItem';
|
|
17
|
+
import { shouldShowImageBorder } from './imageBorder';
|
|
15
18
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
16
19
|
import { downloadMedia } from './utils';
|
|
17
20
|
export var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi) {
|
|
@@ -101,13 +104,38 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
|
|
|
101
104
|
var mediaInline = state.schema.nodes.mediaInline;
|
|
102
105
|
var mediaInlineImageTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaInlineImage);
|
|
103
106
|
var mediaSingleTitle = intl.formatMessage(mediaAndEmbedToolbarMessages.changeToMediaSingle);
|
|
104
|
-
|
|
105
|
-
// TODO: border marks, media single switcher, alt text, etc
|
|
106
107
|
var widthPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$w = pluginInjectionApi.width) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.sharedState.currentState();
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
var inlineImageItems = [];
|
|
109
|
+
if (shouldShowImageBorder(state)) {
|
|
110
|
+
inlineImageItems.push({
|
|
111
|
+
type: 'custom',
|
|
112
|
+
fallback: [],
|
|
113
|
+
render: function render(editorView) {
|
|
114
|
+
if (!editorView) {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
var dispatch = editorView.dispatch,
|
|
118
|
+
state = editorView.state;
|
|
119
|
+
var borderMark = currentMediaOrInlineNodeBorderMark(state);
|
|
120
|
+
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
121
|
+
toggleBorder: function toggleBorder() {
|
|
122
|
+
var _pluginInjectionApi$a2;
|
|
123
|
+
toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(state, dispatch);
|
|
124
|
+
},
|
|
125
|
+
setBorder: function setBorder(attrs) {
|
|
126
|
+
var _pluginInjectionApi$a3;
|
|
127
|
+
setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions)(attrs)(state, dispatch);
|
|
128
|
+
},
|
|
129
|
+
borderMark: borderMark,
|
|
130
|
+
intl: intl
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
inlineImageItems.push({
|
|
135
|
+
type: 'separator'
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
inlineImageItems.push({
|
|
111
139
|
id: 'editor.media.convert.mediainline',
|
|
112
140
|
type: 'button',
|
|
113
141
|
title: mediaInlineImageTitle,
|
|
@@ -134,10 +162,10 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
|
|
|
134
162
|
onClick: changeMediaInlineToMediaSingle(editorAnalyticsAPI, widthPluginState)
|
|
135
163
|
}, {
|
|
136
164
|
type: 'separator'
|
|
137
|
-
}
|
|
165
|
+
});
|
|
138
166
|
if (options.allowAltTextOnImages) {
|
|
139
|
-
var _pluginInjectionApi$
|
|
140
|
-
inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
167
|
+
var _pluginInjectionApi$a4;
|
|
168
|
+
inlineImageItems.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions), {
|
|
141
169
|
type: 'separator'
|
|
142
170
|
});
|
|
143
171
|
}
|
|
@@ -155,10 +183,10 @@ export var getMediaInlineImageToolbar = function getMediaInlineImageToolbar(stat
|
|
|
155
183
|
};
|
|
156
184
|
var openLink = function openLink() {
|
|
157
185
|
if (editorView) {
|
|
158
|
-
var _pluginInjectionApi$
|
|
186
|
+
var _pluginInjectionApi$a5;
|
|
159
187
|
var tr = editorView.state.tr,
|
|
160
188
|
dispatch = editorView.dispatch;
|
|
161
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
189
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 || _pluginInjectionApi$a5.actions.attachAnalyticsEvent({
|
|
162
190
|
eventType: EVENT_TYPE.TRACK,
|
|
163
191
|
action: ACTION.VISITED,
|
|
164
192
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -41,8 +41,8 @@ export var currentMediaInlineNode = function currentMediaInlineNode(editorState)
|
|
|
41
41
|
var _currentMediaInlineNo;
|
|
42
42
|
return (_currentMediaInlineNo = currentMediaInlineNodeWithPos(editorState)) === null || _currentMediaInlineNo === void 0 ? void 0 : _currentMediaInlineNo.node;
|
|
43
43
|
};
|
|
44
|
-
export var
|
|
45
|
-
var node = currentMediaNode(editorState);
|
|
44
|
+
export var currentMediaOrInlineNodeBorderMark = function currentMediaOrInlineNodeBorderMark(editorState) {
|
|
45
|
+
var node = currentMediaNode(editorState) || currentMediaInlineNode(editorState);
|
|
46
46
|
if (!node) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
@@ -11,4 +11,4 @@ export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) =
|
|
|
11
11
|
} | undefined;
|
|
12
12
|
export declare const currentMediaNode: (editorState: EditorState) => PMNode | undefined;
|
|
13
13
|
export declare const currentMediaInlineNode: (editorState: EditorState) => PMNode | undefined;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const currentMediaOrInlineNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
|
|
@@ -11,4 +11,4 @@ export declare const currentMediaInlineNodeWithPos: (editorState: EditorState) =
|
|
|
11
11
|
} | undefined;
|
|
12
12
|
export declare const currentMediaNode: (editorState: EditorState) => PMNode | undefined;
|
|
13
13
|
export declare const currentMediaInlineNode: (editorState: EditorState) => PMNode | undefined;
|
|
14
|
-
export declare const
|
|
14
|
+
export declare const currentMediaOrInlineNodeBorderMark: (editorState: EditorState) => BorderMarkAttributes | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"./types": "./src/types.ts"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@atlaskit/adf-schema": "^35.
|
|
37
|
-
"@atlaskit/analytics-namespaced-context": "^6.
|
|
36
|
+
"@atlaskit/adf-schema": "^35.3.0",
|
|
37
|
+
"@atlaskit/analytics-namespaced-context": "^6.8.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
39
39
|
"@atlaskit/button": "^17.2.0",
|
|
40
|
-
"@atlaskit/editor-common": "^76.
|
|
40
|
+
"@atlaskit/editor-common": "^76.35.0",
|
|
41
41
|
"@atlaskit/editor-palette": "1.5.2",
|
|
42
42
|
"@atlaskit/editor-plugin-analytics": "^0.4.0",
|
|
43
43
|
"@atlaskit/editor-plugin-decorations": "^0.2.0",
|