@atlaskit/editor-core 187.14.9 → 187.14.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/plugins/floating-toolbar/ui/Separator.js +2 -13
- package/dist/cjs/plugins/media/commands/captions.js +29 -27
- package/dist/cjs/plugins/media/commands/linking.js +21 -17
- package/dist/cjs/plugins/media/index.js +4 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/cjs/plugins/media/pm-plugins/keymap.js +17 -15
- package/dist/cjs/plugins/media/pm-plugins/main.js +7 -5
- package/dist/cjs/plugins/media/toolbar/commands.js +149 -141
- package/dist/cjs/plugins/media/toolbar/index.js +20 -16
- package/dist/cjs/plugins/media/toolbar/linking.js +4 -3
- package/dist/cjs/plugins/media/utils/media-files.js +78 -75
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/floating-toolbar/ui/Separator.js +2 -14
- package/dist/es2019/plugins/media/commands/captions.js +4 -4
- package/dist/es2019/plugins/media/commands/linking.js +12 -11
- package/dist/es2019/plugins/media/index.js +6 -3
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/es2019/plugins/media/pm-plugins/keymap.js +5 -5
- package/dist/es2019/plugins/media/pm-plugins/main.js +7 -5
- package/dist/es2019/plugins/media/toolbar/commands.js +15 -15
- package/dist/es2019/plugins/media/toolbar/index.js +20 -16
- package/dist/es2019/plugins/media/toolbar/linking.js +6 -3
- package/dist/es2019/plugins/media/utils/media-files.js +5 -6
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/floating-toolbar/ui/Separator.js +2 -12
- package/dist/esm/plugins/media/commands/captions.js +29 -27
- package/dist/esm/plugins/media/commands/linking.js +21 -17
- package/dist/esm/plugins/media/index.js +4 -3
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +4 -2
- package/dist/esm/plugins/media/pm-plugins/keymap.js +17 -15
- package/dist/esm/plugins/media/pm-plugins/main.js +7 -5
- package/dist/esm/plugins/media/toolbar/commands.js +148 -140
- package/dist/esm/plugins/media/toolbar/index.js +20 -16
- package/dist/esm/plugins/media/toolbar/linking.js +4 -3
- package/dist/esm/plugins/media/utils/media-files.js +78 -75
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
- package/dist/types/plugins/media/commands/captions.d.ts +2 -1
- package/dist/types/plugins/media/commands/linking.d.ts +3 -3
- package/dist/types/plugins/media/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/media/toolbar/commands.d.ts +5 -4
- package/dist/types/plugins/media/utils/media-files.d.ts +3 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/ui/Separator.d.ts +2 -4
- package/dist/types-ts4.5/plugins/media/commands/captions.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/commands/linking.d.ts +3 -3
- package/dist/types-ts4.5/plugins/media/pm-plugins/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/toolbar/commands.d.ts +5 -4
- package/dist/types-ts4.5/plugins/media/utils/media-files.d.ts +3 -2
- package/package.json +4 -4
|
@@ -37,7 +37,7 @@ const handleRemoveMediaGroup = (state, dispatch) => {
|
|
|
37
37
|
}
|
|
38
38
|
return true;
|
|
39
39
|
};
|
|
40
|
-
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration) => {
|
|
40
|
+
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) => {
|
|
41
41
|
const {
|
|
42
42
|
mediaGroup
|
|
43
43
|
} = state.schema.nodes;
|
|
@@ -50,7 +50,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
50
50
|
title: intl.formatMessage(cardMessages.inline),
|
|
51
51
|
selected: false,
|
|
52
52
|
disabled: false,
|
|
53
|
-
onClick: changeMediaCardToInline,
|
|
53
|
+
onClick: changeMediaCardToInline(editorAnalyticsAPI),
|
|
54
54
|
testId: 'inline-appearance'
|
|
55
55
|
}, {
|
|
56
56
|
id: 'editor.media.view.switcher.thumbnail',
|
|
@@ -112,7 +112,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
112
112
|
}];
|
|
113
113
|
return items;
|
|
114
114
|
};
|
|
115
|
-
const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration) => {
|
|
115
|
+
const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, editorAnalyticsAPI) => {
|
|
116
116
|
const {
|
|
117
117
|
mediaInline
|
|
118
118
|
} = state.schema.nodes;
|
|
@@ -134,7 +134,7 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hover
|
|
|
134
134
|
title: intl.formatMessage(messages.displayThumbnail),
|
|
135
135
|
selected: false,
|
|
136
136
|
disabled: false,
|
|
137
|
-
onClick: changeInlineToMediaCard,
|
|
137
|
+
onClick: changeInlineToMediaCard(editorAnalyticsAPI),
|
|
138
138
|
testId: 'thumbnail-appearance'
|
|
139
139
|
}]
|
|
140
140
|
}, {
|
|
@@ -188,7 +188,7 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hover
|
|
|
188
188
|
return items;
|
|
189
189
|
};
|
|
190
190
|
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
|
|
191
|
-
var _pluginInjectionApi$
|
|
191
|
+
var _pluginInjectionApi$d7;
|
|
192
192
|
const {
|
|
193
193
|
mediaSingle
|
|
194
194
|
} = state.schema.nodes;
|
|
@@ -215,10 +215,12 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
215
215
|
const borderMark = currentMediaNodeBorderMark(state);
|
|
216
216
|
return /*#__PURE__*/React.createElement(ImageBorderItem, {
|
|
217
217
|
toggleBorder: () => {
|
|
218
|
-
|
|
218
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
219
|
+
toggleBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(state, dispatch);
|
|
219
220
|
},
|
|
220
221
|
setBorder: attrs => {
|
|
221
|
-
|
|
222
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
223
|
+
setBorderMark(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(attrs)(state, dispatch);
|
|
222
224
|
},
|
|
223
225
|
showSomewhatSemanticTooltips: getEditorFeatureFlags === null || getEditorFeatureFlags === void 0 ? void 0 : getEditorFeatureFlags().useSomewhatSemanticTextColorNames,
|
|
224
226
|
borderMark: borderMark,
|
|
@@ -231,7 +233,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
231
233
|
});
|
|
232
234
|
}
|
|
233
235
|
if (allowAdvancedToolBarOptions) {
|
|
234
|
-
var _pluginInjectionApi$
|
|
236
|
+
var _pluginInjectionApi$d5;
|
|
235
237
|
const widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
|
|
236
238
|
let isChangingLayoutDisabled = false;
|
|
237
239
|
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
@@ -247,7 +249,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
247
249
|
}
|
|
248
250
|
}
|
|
249
251
|
}
|
|
250
|
-
const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
252
|
+
const layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
|
|
251
253
|
toolbarButtons = [...toolbarButtons, ...layoutButtons];
|
|
252
254
|
if (layoutButtons.length) {
|
|
253
255
|
toolbarButtons.push({
|
|
@@ -271,14 +273,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
271
273
|
};
|
|
272
274
|
const openLink = () => {
|
|
273
275
|
if (editorView) {
|
|
274
|
-
var _pluginInjectionApi$
|
|
276
|
+
var _pluginInjectionApi$d6;
|
|
275
277
|
const {
|
|
276
278
|
state: {
|
|
277
279
|
tr
|
|
278
280
|
},
|
|
279
281
|
dispatch
|
|
280
282
|
} = editorView;
|
|
281
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
283
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions.attachAnalyticsEvent({
|
|
282
284
|
eventType: EVENT_TYPE.TRACK,
|
|
283
285
|
action: ACTION.VISITED,
|
|
284
286
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -310,7 +312,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
310
312
|
}
|
|
311
313
|
const {
|
|
312
314
|
hoverDecoration
|
|
313
|
-
} = (_pluginInjectionApi$
|
|
315
|
+
} = (_pluginInjectionApi$d7 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d7 !== void 0 ? _pluginInjectionApi$d7 : {};
|
|
314
316
|
const removeButton = {
|
|
315
317
|
id: 'editor.media.delete',
|
|
316
318
|
type: 'button',
|
|
@@ -338,7 +340,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
338
340
|
return items;
|
|
339
341
|
};
|
|
340
342
|
export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) => {
|
|
341
|
-
var _pluginInjectionApi$
|
|
343
|
+
var _pluginInjectionApi$d8;
|
|
342
344
|
const {
|
|
343
345
|
media,
|
|
344
346
|
mediaInline,
|
|
@@ -357,7 +359,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
357
359
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
358
360
|
const {
|
|
359
361
|
hoverDecoration
|
|
360
|
-
} = (_pluginInjectionApi$
|
|
362
|
+
} = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {};
|
|
361
363
|
if (!mediaPluginState || mediaPluginState.isResizing) {
|
|
362
364
|
return;
|
|
363
365
|
}
|
|
@@ -388,20 +390,22 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
388
390
|
selectedNodeType = state.selection.node.type;
|
|
389
391
|
}
|
|
390
392
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
393
|
+
var _pluginInjectionApi$d9, _pluginInjectionApi$d10;
|
|
391
394
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
392
395
|
baseToolbar.getDomRef = () => {
|
|
393
396
|
var _mediaPluginState$ele;
|
|
394
397
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
395
398
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
396
399
|
};
|
|
397
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
400
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d9 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d9 === void 0 ? void 0 : (_pluginInjectionApi$d10 = _pluginInjectionApi$d9.analytics) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.actions);
|
|
398
401
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
402
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
399
403
|
baseToolbar.getDomRef = () => {
|
|
400
404
|
var _mediaPluginState$ele2;
|
|
401
405
|
const element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(`.${MediaInlineNodeSelector}`);
|
|
402
406
|
return element || mediaPluginState.element;
|
|
403
407
|
};
|
|
404
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration);
|
|
408
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d11 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : (_pluginInjectionApi$d12 = _pluginInjectionApi$d11.analytics) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : _pluginInjectionApi$d12.actions);
|
|
405
409
|
} else {
|
|
406
410
|
baseToolbar.getDomRef = () => {
|
|
407
411
|
var _mediaPluginState$ele3;
|
|
@@ -55,7 +55,10 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
|
|
|
55
55
|
providerFactory: providerFactory,
|
|
56
56
|
intl: intl,
|
|
57
57
|
editing: editing,
|
|
58
|
-
onUnlink: () =>
|
|
58
|
+
onUnlink: () => {
|
|
59
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
60
|
+
return unlink(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(view.state, view.dispatch, view);
|
|
61
|
+
},
|
|
59
62
|
onBack: (href, meta) => {
|
|
60
63
|
if (href.trim() && meta.inputMethod) {
|
|
61
64
|
setUrlToMedia(href, meta.inputMethod)(view.state, view.dispatch, view);
|
|
@@ -63,7 +66,7 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
|
|
|
63
66
|
hideLinkingToolbar(view.state, view.dispatch, view);
|
|
64
67
|
},
|
|
65
68
|
onCancel: () => {
|
|
66
|
-
var _pluginInjectionApi$
|
|
69
|
+
var _pluginInjectionApi$d3;
|
|
67
70
|
hideLinkingToolbar(view.state, view.dispatch, view, true);
|
|
68
71
|
/** Focus should move to the 'Add link' button when the toolbar closes
|
|
69
72
|
* and not close the floating toolbar.
|
|
@@ -74,7 +77,7 @@ export const getLinkingToolbar = (toolbarBaseConfig, mediaLinkingState, state, i
|
|
|
74
77
|
},
|
|
75
78
|
dispatch
|
|
76
79
|
} = view;
|
|
77
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
80
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.forceFocusSelector(FORCE_FOCUS_SELECTOR)(tr);
|
|
78
81
|
dispatch(tr);
|
|
79
82
|
},
|
|
80
83
|
onSubmit: (href, meta) => {
|
|
@@ -5,7 +5,6 @@ import { posOfPrecedingMediaGroup, posOfMediaGroupNearby, posOfParentMediaGroup,
|
|
|
5
5
|
import { canInsert, safeInsert, hasParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
6
6
|
import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '../../../utils/prosemirror/position';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
8
|
-
import { addAnalytics } from '../../analytics';
|
|
9
8
|
export const canInsertMediaInline = state => {
|
|
10
9
|
const node = state.schema.nodes.mediaInline.create({});
|
|
11
10
|
return canInsert(state.selection.$to, Fragment.from(node));
|
|
@@ -80,7 +79,7 @@ function shouldAppendParagraph(state, node) {
|
|
|
80
79
|
* @param mediaState Media file to be added to the editor
|
|
81
80
|
* @param collection Collection for the media to be added
|
|
82
81
|
*/
|
|
83
|
-
export const insertMediaInlineNode = (view, mediaState, collection, inputMethod) => {
|
|
82
|
+
export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, collection, inputMethod) => {
|
|
84
83
|
const {
|
|
85
84
|
state,
|
|
86
85
|
dispatch
|
|
@@ -120,7 +119,7 @@ export const insertMediaInlineNode = (view, mediaState, collection, inputMethod)
|
|
|
120
119
|
} else {
|
|
121
120
|
tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
122
121
|
}
|
|
123
|
-
|
|
122
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaInlineAnalytics(mediaState, inputMethod))(tr);
|
|
124
123
|
dispatch(tr);
|
|
125
124
|
return true;
|
|
126
125
|
};
|
|
@@ -132,7 +131,7 @@ export const insertMediaInlineNode = (view, mediaState, collection, inputMethod)
|
|
|
132
131
|
* @param mediaStates Media files to be added to the editor
|
|
133
132
|
* @param collection Collection for the media to be added
|
|
134
133
|
*/
|
|
135
|
-
export const insertMediaGroupNode = (view, mediaStates, collection, inputMethod) => {
|
|
134
|
+
export const insertMediaGroupNode = editorAnalyticsAPI => (view, mediaStates, collection, inputMethod) => {
|
|
136
135
|
const {
|
|
137
136
|
state,
|
|
138
137
|
dispatch
|
|
@@ -170,7 +169,7 @@ export const insertMediaGroupNode = (view, mediaStates, collection, inputMethod)
|
|
|
170
169
|
} else {
|
|
171
170
|
tr.insert(mediaInsertPos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
172
171
|
}
|
|
173
|
-
|
|
172
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaGroupAnalytics(mediaStates, inputMethod))(tr);
|
|
174
173
|
dispatch(tr);
|
|
175
174
|
setSelectionAfterMediaInsertion(view);
|
|
176
175
|
return;
|
|
@@ -180,7 +179,7 @@ export const insertMediaGroupNode = (view, mediaStates, collection, inputMethod)
|
|
|
180
179
|
if (withParagraph && parent.type !== schema.nodes.mediaGroup) {
|
|
181
180
|
content.push(paragraph.create());
|
|
182
181
|
}
|
|
183
|
-
|
|
182
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaGroupAnalytics(mediaStates, inputMethod))(tr);
|
|
184
183
|
dispatch(safeInsert(Fragment.fromArray(content), mediaInsertPos)(tr));
|
|
185
184
|
};
|
|
186
185
|
const createMediaFileNodes = (mediaStates, collection, media) => {
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
/** @jsx jsx */
|
|
4
|
-
import { css, jsx } from '@emotion/react';
|
|
5
|
-
import { N30 } from '@atlaskit/theme/colors';
|
|
6
|
-
var separator = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background: ", ";\n width: 1px;\n height: 20px;\n margin: 0 4px;\n align-self: center;\n"])), "var(--ds-border, ".concat(N30, ")"));
|
|
7
|
-
export default (function () {
|
|
8
|
-
return jsx("div", {
|
|
9
|
-
css: separator,
|
|
10
|
-
className: "separator"
|
|
11
|
-
});
|
|
12
|
-
});
|
|
1
|
+
import { FloatingToolbarSeparator } from '@atlaskit/editor-common/ui';
|
|
2
|
+
export default FloatingToolbarSeparator;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setTextSelection } from '@atlaskit/editor-prosemirror/utils';
|
|
2
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID,
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
export var selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSinglePos(mediaSingleNodePos, mediaSingleNode) {
|
|
4
4
|
return function (state, dispatch) {
|
|
5
5
|
// node should have two children, media and caption
|
|
@@ -17,33 +17,35 @@ export var selectCaptionFromMediaSinglePos = function selectCaptionFromMediaSing
|
|
|
17
17
|
return true;
|
|
18
18
|
};
|
|
19
19
|
};
|
|
20
|
-
export var insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(
|
|
21
|
-
return function (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
export var insertAndSelectCaptionFromMediaSinglePos = function insertAndSelectCaptionFromMediaSinglePos(editorAnalyticsAPI) {
|
|
21
|
+
return function (mediaSingleNodePos, mediaSingleNode) {
|
|
22
|
+
return function (state, dispatch) {
|
|
23
|
+
if (typeof mediaSingleNodePos !== 'number') {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
var tr = state.tr;
|
|
26
27
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
28
|
+
// node should have one child, media
|
|
29
|
+
if (mediaSingleNode.childCount !== 1) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
if (dispatch) {
|
|
33
|
+
var schema = state.schema;
|
|
34
|
+
var media = mediaSingleNode.child(0);
|
|
35
|
+
var caption = schema.nodes.caption.create();
|
|
36
|
+
tr = state.tr.insert(mediaSingleNodePos + media.nodeSize + 1, caption);
|
|
37
|
+
tr = setSelectionAtEndOfCaption(tr, mediaSingleNodePos, media.nodeSize, caption.nodeSize);
|
|
38
|
+
tr.setMeta('scrollIntoView', false);
|
|
39
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
40
|
+
action: ACTION.ADDED,
|
|
41
|
+
eventType: EVENT_TYPE.TRACK,
|
|
42
|
+
actionSubject: ACTION_SUBJECT.MEDIA_SINGLE,
|
|
43
|
+
actionSubjectId: ACTION_SUBJECT_ID.CAPTION
|
|
44
|
+
})(tr);
|
|
45
|
+
dispatch(tr);
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
47
49
|
};
|
|
48
50
|
};
|
|
49
51
|
var setSelectionAtEndOfCaption = function setSelectionAtEndOfCaption(tr, mediaSingleNodePos, mediaNodeSize, captionNodeSize) {
|
|
@@ -5,7 +5,7 @@ import { createMediaLinkingCommand, getMediaLinkingState, mediaLinkingPluginKey
|
|
|
5
5
|
import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { createToggleBlockMarkOnRange } from '../../../commands';
|
|
7
7
|
import { MediaLinkingActionsTypes } from '../pm-plugins/linking/actions';
|
|
8
|
-
import {
|
|
8
|
+
import { EVENT_TYPE, ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
9
9
|
import { currentMediaNode } from '../utils/current-media-node';
|
|
10
10
|
import { checkMediaType } from '../utils/check-media-type';
|
|
11
11
|
import { getMediaPluginState } from '../pm-plugins/main';
|
|
@@ -116,24 +116,28 @@ function toggleLinkMark(tr, state, _ref) {
|
|
|
116
116
|
toggleBlockLinkMark($pos.pos, $pos.pos + node.nodeSize, tr, state);
|
|
117
117
|
return tr;
|
|
118
118
|
}
|
|
119
|
-
var fireAnalyticForMediaLink = function fireAnalyticForMediaLink(tr,
|
|
120
|
-
var attributes = arguments.length >
|
|
121
|
-
|
|
119
|
+
var fireAnalyticForMediaLink = function fireAnalyticForMediaLink(tr, action) {
|
|
120
|
+
var attributes = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
|
|
121
|
+
var editorAnalyticsAPI = arguments.length > 3 ? arguments[3] : undefined;
|
|
122
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
122
123
|
action: action,
|
|
123
124
|
eventType: EVENT_TYPE.TRACK,
|
|
124
125
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
125
126
|
actionSubjectId: ACTION_SUBJECT_ID.LINK,
|
|
126
127
|
attributes: attributes
|
|
127
|
-
});
|
|
128
|
+
})(tr);
|
|
129
|
+
return tr;
|
|
128
130
|
};
|
|
129
|
-
export var unlink =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
export var unlink = function unlink(editorAnalyticsAPI) {
|
|
132
|
+
return createMediaLinkingCommand({
|
|
133
|
+
type: MediaLinkingActionsTypes.unlink
|
|
134
|
+
}, function (tr, state) {
|
|
135
|
+
var transaction = toggleLinkMark(tr, state, {
|
|
136
|
+
forceRemove: true
|
|
137
|
+
});
|
|
138
|
+
return fireAnalyticForMediaLink(transaction, ACTION.DELETED, undefined, editorAnalyticsAPI);
|
|
134
139
|
});
|
|
135
|
-
|
|
136
|
-
});
|
|
140
|
+
};
|
|
137
141
|
var getAction = function getAction(newUrl, state) {
|
|
138
142
|
var currentUrl = getCurrentUrl(state);
|
|
139
143
|
if (!currentUrl) {
|
|
@@ -143,7 +147,7 @@ var getAction = function getAction(newUrl, state) {
|
|
|
143
147
|
}
|
|
144
148
|
return undefined;
|
|
145
149
|
};
|
|
146
|
-
export var setUrlToMedia = function setUrlToMedia(url, inputMethod) {
|
|
150
|
+
export var setUrlToMedia = function setUrlToMedia(url, inputMethod, editorAnalyticsAPI) {
|
|
147
151
|
return createMediaLinkingCommand({
|
|
148
152
|
type: MediaLinkingActionsTypes.setUrl,
|
|
149
153
|
payload: normalizeUrl(url)
|
|
@@ -156,14 +160,14 @@ export var setUrlToMedia = function setUrlToMedia(url, inputMethod) {
|
|
|
156
160
|
var toggleLinkMarkResult = toggleLinkMark(tr, state, {
|
|
157
161
|
url: url
|
|
158
162
|
});
|
|
159
|
-
fireAnalyticForMediaLink(tr,
|
|
163
|
+
fireAnalyticForMediaLink(tr, action, action === ACTION.ADDED ? {
|
|
160
164
|
inputMethod: inputMethod
|
|
161
|
-
} : undefined);
|
|
165
|
+
} : undefined, editorAnalyticsAPI);
|
|
162
166
|
return toggleLinkMarkResult;
|
|
163
167
|
} catch (e) {
|
|
164
|
-
fireAnalyticForMediaLink(tr,
|
|
168
|
+
fireAnalyticForMediaLink(tr, ACTION.ERRORED, {
|
|
165
169
|
action: action
|
|
166
|
-
});
|
|
170
|
+
}, editorAnalyticsAPI);
|
|
167
171
|
throw e;
|
|
168
172
|
}
|
|
169
173
|
});
|
|
@@ -111,7 +111,8 @@ var mediaPlugin = function mediaPlugin() {
|
|
|
111
111
|
}, {
|
|
112
112
|
name: 'mediaKeymap',
|
|
113
113
|
plugin: function plugin() {
|
|
114
|
-
|
|
114
|
+
var _api$dependencies$ana;
|
|
115
|
+
return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
115
116
|
}
|
|
116
117
|
}];
|
|
117
118
|
if (options && options.allowMediaSingle) {
|
|
@@ -226,11 +227,11 @@ var mediaPlugin = function mediaPlugin() {
|
|
|
226
227
|
return /*#__PURE__*/React.createElement(IconImages, null);
|
|
227
228
|
},
|
|
228
229
|
action: function action(insert, state) {
|
|
229
|
-
var _api$dependencies$
|
|
230
|
+
var _api$dependencies$ana2;
|
|
230
231
|
var pluginState = pluginKey.getState(state);
|
|
231
232
|
pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
|
|
232
233
|
var tr = insert('');
|
|
233
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
234
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions.attachAnalyticsEvent({
|
|
234
235
|
action: ACTION.OPENED,
|
|
235
236
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
236
237
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -230,14 +230,16 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
230
230
|
(_this$captionPlaceHol = _this.captionPlaceHolderRef.current) === null || _this$captionPlaceHol === void 0 ? void 0 : _this$captionPlaceHol.click();
|
|
231
231
|
});
|
|
232
232
|
_defineProperty(_assertThisInitialized(_this), "clickPlaceholder", function () {
|
|
233
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
233
234
|
var _this$props = _this.props,
|
|
234
235
|
view = _this$props.view,
|
|
235
236
|
getPos = _this$props.getPos,
|
|
236
|
-
node = _this$props.node
|
|
237
|
+
node = _this$props.node,
|
|
238
|
+
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
237
239
|
if (typeof getPos === 'boolean') {
|
|
238
240
|
return;
|
|
239
241
|
}
|
|
240
|
-
insertAndSelectCaptionFromMediaSinglePos(getPos(), node)(view.state, view.dispatch);
|
|
242
|
+
insertAndSelectCaptionFromMediaSinglePos(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(getPos(), node)(view.state, view.dispatch);
|
|
241
243
|
});
|
|
242
244
|
/**
|
|
243
245
|
* Get parent width for a nested media single node
|
|
@@ -5,15 +5,15 @@ import { stateKey } from '../pm-plugins/plugin-key';
|
|
|
5
5
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
6
6
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
7
7
|
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
8
|
-
export function keymapPlugin(options) {
|
|
8
|
+
export function keymapPlugin(options, editorAnalyticsAPI) {
|
|
9
9
|
var list = {};
|
|
10
10
|
var _ref = options || {},
|
|
11
11
|
featureFlags = _ref.featureFlags;
|
|
12
12
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, ignoreLinksInSteps, list);
|
|
13
13
|
keymaps.bindKeymapWithCommand(keymaps.enter.common, splitMediaGroup, list);
|
|
14
14
|
if (getMediaFeatureFlag('captions', featureFlags)) {
|
|
15
|
-
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, insertAndSelectCaption, list);
|
|
16
|
-
keymaps.bindKeymapWithCommand(keymaps.tab.common, insertAndSelectCaption, list);
|
|
15
|
+
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
16
|
+
keymaps.bindKeymapWithCommand(keymaps.tab.common, insertAndSelectCaption(editorAnalyticsAPI), list);
|
|
17
17
|
keymaps.bindKeymapWithCommand(keymaps.moveLeft.common, arrowLeftFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
18
18
|
keymaps.bindKeymapWithCommand(keymaps.moveRight.common, arrowRightFromMediaSingle(options === null || options === void 0 ? void 0 : options.editorSelectionAPI), list);
|
|
19
19
|
}
|
|
@@ -29,20 +29,22 @@ var splitMediaGroup = function splitMediaGroup(state) {
|
|
|
29
29
|
var mediaPluginState = stateKey.getState(state);
|
|
30
30
|
return mediaPluginState.splitMediaGroup();
|
|
31
31
|
};
|
|
32
|
-
var insertAndSelectCaption = function insertAndSelectCaption(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
32
|
+
var insertAndSelectCaption = function insertAndSelectCaption(editorAnalyticsAPI) {
|
|
33
|
+
return function (state, dispatch) {
|
|
34
|
+
var selection = state.selection,
|
|
35
|
+
schema = state.schema;
|
|
36
|
+
if (selection instanceof NodeSelection && selection.node.type === schema.nodes.mediaSingle && schema.nodes.caption) {
|
|
37
|
+
if (dispatch) {
|
|
38
|
+
var from = selection.from,
|
|
39
|
+
node = selection.node;
|
|
40
|
+
if (!insertAndSelectCaptionFromMediaSinglePos(editorAnalyticsAPI)(from, node)(state, dispatch)) {
|
|
41
|
+
selectCaptionFromMediaSinglePos(from, node)(state, dispatch);
|
|
42
|
+
}
|
|
41
43
|
}
|
|
44
|
+
return true;
|
|
42
45
|
}
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
return false;
|
|
46
|
+
return false;
|
|
47
|
+
};
|
|
46
48
|
};
|
|
47
49
|
var arrowLeftFromMediaSingle = function arrowLeftFromMediaSingle(editorSelectionAPI) {
|
|
48
50
|
return function (state, dispatch) {
|
|
@@ -54,7 +54,7 @@ var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine)
|
|
|
54
54
|
};
|
|
55
55
|
var MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
56
56
|
export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
57
|
-
function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch,
|
|
57
|
+
function MediaPluginStateImplementation(_state, options, mediaOptions, newInsertionBehaviour, _dispatch, _pluginInjectionApi) {
|
|
58
58
|
var _this = this;
|
|
59
59
|
_classCallCheck(this, MediaPluginStateImplementation);
|
|
60
60
|
_defineProperty(this, "allowsUploads", false);
|
|
@@ -206,7 +206,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
206
206
|
*
|
|
207
207
|
* called when we insert a new file via the picker (connected via pickerfacade)
|
|
208
208
|
*/
|
|
209
|
-
_defineProperty(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
209
|
+
_defineProperty(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType, pluginInjectionApi) {
|
|
210
210
|
var _mediaState$collectio, _this$mediaOptions2;
|
|
211
211
|
var state = _this.view.state;
|
|
212
212
|
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
@@ -229,9 +229,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
229
229
|
var widthPluginState = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
|
|
230
230
|
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState);
|
|
231
231
|
} else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = _this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
|
|
232
|
-
|
|
232
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
233
|
+
insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
233
234
|
} else {
|
|
234
|
-
|
|
235
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
236
|
+
insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
// do events when media state changes
|
|
@@ -468,7 +470,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
468
470
|
this.mediaOptions = mediaOptions;
|
|
469
471
|
this.newInsertionBehaviour = newInsertionBehaviour;
|
|
470
472
|
this.dispatch = _dispatch;
|
|
471
|
-
this.pluginInjectionApi =
|
|
473
|
+
this.pluginInjectionApi = _pluginInjectionApi;
|
|
472
474
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
473
475
|
var nodes = _state.schema.nodes;
|
|
474
476
|
assert(nodes.media && (nodes.mediaGroup || nodes.mediaSingle), 'Editor: unable to init media plugin - media or mediaGroup/mediaSingle node absent in schema');
|