@atlaskit/editor-core 187.19.0 → 187.19.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 +7 -0
- package/dist/cjs/plugins/media/index.js +4 -3
- package/dist/cjs/plugins/media/pm-plugins/alt-text/commands.js +10 -7
- package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/cjs/plugins/media/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/cjs/plugins/media/toolbar/index.js +12 -11
- package/dist/cjs/plugins/media/utils/media-single.js +13 -13
- package/dist/cjs/plugins/paste/handlers.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/selection/gap-cursor/styles.js +1 -1
- package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +3 -3
- package/dist/cjs/plugins/selection/gap-cursor/utils.js +6 -3
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +3 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/media/index.js +6 -3
- package/dist/es2019/plugins/media/pm-plugins/alt-text/commands.js +3 -2
- package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/es2019/plugins/media/pm-plugins/main.js +7 -7
- package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/es2019/plugins/media/toolbar/index.js +12 -11
- package/dist/es2019/plugins/media/utils/media-single.js +7 -8
- package/dist/es2019/plugins/paste/handlers.js +2 -3
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/selection/gap-cursor/styles.js +2 -1
- package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
- package/dist/es2019/plugins/selection/gap-cursor/utils.js +5 -2
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/media/index.js +4 -3
- package/dist/esm/plugins/media/pm-plugins/alt-text/commands.js +10 -7
- package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/esm/plugins/media/pm-plugins/main.js +7 -7
- package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/esm/plugins/media/toolbar/index.js +12 -11
- package/dist/esm/plugins/media/utils/media-single.js +7 -7
- package/dist/esm/plugins/paste/handlers.js +2 -3
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/esm/plugins/selection/gap-cursor/styles.js +1 -1
- package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
- package/dist/esm/plugins/selection/gap-cursor/utils.js +5 -2
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
- package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types/plugins/media/utils/media-single.d.ts +3 -3
- package/dist/types/plugins/paste/handlers.d.ts +2 -1
- package/dist/types/plugins/paste/index.d.ts +3 -1
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +3 -3
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
- package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types-ts4.5/plugins/selection/gap-cursor/utils.d.ts +1 -1
- package/package.json +1 -1
- package/report.api.md +1 -0
- package/tmp/api-report-tmp.d.ts +1 -1
|
@@ -191,7 +191,7 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hover
|
|
|
191
191
|
return items;
|
|
192
192
|
};
|
|
193
193
|
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
|
|
194
|
-
var _pluginInjectionApi$
|
|
194
|
+
var _pluginInjectionApi$d8;
|
|
195
195
|
const {
|
|
196
196
|
mediaSingle
|
|
197
197
|
} = state.schema.nodes;
|
|
@@ -368,13 +368,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
if (allowAltTextOnImages) {
|
|
371
|
-
|
|
371
|
+
var _pluginInjectionApi$d7;
|
|
372
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
|
|
372
373
|
type: 'separator'
|
|
373
374
|
});
|
|
374
375
|
}
|
|
375
376
|
const {
|
|
376
377
|
hoverDecoration
|
|
377
|
-
} = (_pluginInjectionApi$
|
|
378
|
+
} = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {};
|
|
378
379
|
const removeButton = {
|
|
379
380
|
id: 'editor.media.delete',
|
|
380
381
|
type: 'button',
|
|
@@ -402,7 +403,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
402
403
|
return items;
|
|
403
404
|
};
|
|
404
405
|
export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) => {
|
|
405
|
-
var _pluginInjectionApi$
|
|
406
|
+
var _pluginInjectionApi$d9;
|
|
406
407
|
const {
|
|
407
408
|
media,
|
|
408
409
|
mediaInline,
|
|
@@ -421,7 +422,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
421
422
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
422
423
|
const {
|
|
423
424
|
hoverDecoration
|
|
424
|
-
} = (_pluginInjectionApi$
|
|
425
|
+
} = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {};
|
|
425
426
|
if (!mediaPluginState || mediaPluginState.isResizing) {
|
|
426
427
|
return;
|
|
427
428
|
}
|
|
@@ -440,10 +441,10 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
440
441
|
if (allowAltTextOnImages) {
|
|
441
442
|
const mediaAltTextPluginState = getMediaAltTextPluginState(state);
|
|
442
443
|
if (mediaAltTextPluginState.isAltTextEditorOpen) {
|
|
443
|
-
var _pluginInjectionApi$
|
|
444
|
+
var _pluginInjectionApi$d10;
|
|
444
445
|
return getAltTextToolbar(baseToolbar, {
|
|
445
446
|
altTextValidator,
|
|
446
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
447
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.forceFocusSelector
|
|
447
448
|
});
|
|
448
449
|
}
|
|
449
450
|
}
|
|
@@ -454,22 +455,22 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
454
455
|
selectedNodeType = state.selection.node.type;
|
|
455
456
|
}
|
|
456
457
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
457
|
-
var _pluginInjectionApi$
|
|
458
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
458
459
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
459
460
|
baseToolbar.getDomRef = () => {
|
|
460
461
|
var _mediaPluginState$ele;
|
|
461
462
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
462
463
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
463
464
|
};
|
|
464
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
465
|
+
items = generateMediaCardFloatingToolbar(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);
|
|
465
466
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
466
|
-
var _pluginInjectionApi$
|
|
467
|
+
var _pluginInjectionApi$d13, _pluginInjectionApi$d14;
|
|
467
468
|
baseToolbar.getDomRef = () => {
|
|
468
469
|
var _mediaPluginState$ele2;
|
|
469
470
|
const element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(`.${MediaInlineNodeSelector}`);
|
|
470
471
|
return element || mediaPluginState.element;
|
|
471
472
|
};
|
|
472
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
473
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d13 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : (_pluginInjectionApi$d14 = _pluginInjectionApi$d13.analytics) === null || _pluginInjectionApi$d14 === void 0 ? void 0 : _pluginInjectionApi$d14.actions);
|
|
473
474
|
} else {
|
|
474
475
|
baseToolbar.getDomRef = () => {
|
|
475
476
|
var _mediaPluginState$ele3;
|
|
@@ -5,7 +5,6 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
|
|
6
6
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
7
7
|
import { mapSlice } from '../../../utils/slice';
|
|
8
|
-
import { addAnalytics } from '../../analytics';
|
|
9
8
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
10
9
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
11
10
|
import { isImage } from './is-image';
|
|
@@ -26,7 +25,7 @@ const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
|
|
|
26
25
|
function shouldAddParagraph(state) {
|
|
27
26
|
return atTheBeginningOfBlock(state) && !checkNodeDown(state.selection, state.doc, isEmptyParagraph);
|
|
28
27
|
}
|
|
29
|
-
function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
28
|
+
function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}, editorAnalyticsAPI) {
|
|
30
29
|
return function (state, dispatch) {
|
|
31
30
|
const {
|
|
32
31
|
tr,
|
|
@@ -46,7 +45,7 @@ function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
|
46
45
|
}
|
|
47
46
|
tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
|
|
48
47
|
if (inputMethod) {
|
|
49
|
-
|
|
48
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
50
49
|
}
|
|
51
50
|
if (dispatch) {
|
|
52
51
|
dispatch(tr);
|
|
@@ -55,7 +54,7 @@ function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
export const isMediaSingle = (schema, fileMimeType) => !!schema.nodes.mediaSingle && isImage(fileMimeType);
|
|
58
|
-
export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
|
|
57
|
+
export const insertMediaAsMediaSingle = (view, node, inputMethod, editorAnalyticsAPI) => {
|
|
59
58
|
const {
|
|
60
59
|
state,
|
|
61
60
|
dispatch
|
|
@@ -78,9 +77,9 @@ export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
|
|
|
78
77
|
inputMethod,
|
|
79
78
|
fileExtension: node.attrs.__fileMimeType
|
|
80
79
|
};
|
|
81
|
-
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
|
|
80
|
+
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
|
|
82
81
|
};
|
|
83
|
-
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) => {
|
|
82
|
+
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) => {
|
|
84
83
|
var _state$selection$$fro;
|
|
85
84
|
if (collection === undefined) {
|
|
86
85
|
return false;
|
|
@@ -113,7 +112,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
113
112
|
insertNodesWithOptionalParagraph([node], {
|
|
114
113
|
fileExtension,
|
|
115
114
|
inputMethod
|
|
116
|
-
})(state, dispatch);
|
|
115
|
+
}, editorAnalyticsAPI)(state, dispatch);
|
|
117
116
|
} else {
|
|
118
117
|
let tr = null;
|
|
119
118
|
if (newInsertionBehaviour) {
|
|
@@ -124,7 +123,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
124
123
|
tr = pmSafeInsert(content, undefined, true)(state.tr);
|
|
125
124
|
}
|
|
126
125
|
if (inputMethod) {
|
|
127
|
-
|
|
126
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
128
127
|
}
|
|
129
128
|
dispatch(tr);
|
|
130
129
|
}
|
|
@@ -17,7 +17,6 @@ import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } f
|
|
|
17
17
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
18
18
|
import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
|
|
19
19
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
20
|
-
|
|
21
20
|
// remove text attribute from mention for copy/paste (GDPR)
|
|
22
21
|
export function handleMention(slice, schema) {
|
|
23
22
|
return mapSlice(slice, node => {
|
|
@@ -532,12 +531,12 @@ function isOnlyMediaSingle(state, slice) {
|
|
|
532
531
|
} = state.schema.nodes;
|
|
533
532
|
return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
|
|
534
533
|
}
|
|
535
|
-
export function handleMediaSingle(inputMethod) {
|
|
534
|
+
export function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
|
|
536
535
|
return function (slice) {
|
|
537
536
|
return (state, dispatch, view) => {
|
|
538
537
|
if (view) {
|
|
539
538
|
if (isOnlyMedia(state, slice)) {
|
|
540
|
-
return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod);
|
|
539
|
+
return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
|
|
541
540
|
}
|
|
542
541
|
if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
|
|
543
542
|
const tr = state.tr.replaceSelection(slice);
|
|
@@ -238,9 +238,9 @@ export const handlePasteIntoCaptionWithAnalytics = (view, event, slice, type) =>
|
|
|
238
238
|
export const handleCodeBlockWithAnalytics = (view, event, slice, text) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
239
239
|
type: PasteTypes.plain
|
|
240
240
|
}))(handleCodeBlock(text));
|
|
241
|
-
export const handleMediaSingleWithAnalytics = (view, event, slice, type) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
241
|
+
export const handleMediaSingleWithAnalytics = (view, event, slice, type, editorAnalyticsAPI) => injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
242
242
|
type
|
|
243
|
-
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD)(slice));
|
|
243
|
+
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, editorAnalyticsAPI)(slice));
|
|
244
244
|
export const handlePastePreservingMarksWithAnalytics = (view, event, slice, type, pluginInjectionApi) => {
|
|
245
245
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
246
246
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
@@ -77,7 +77,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
handlePaste(view, rawEvent, slice) {
|
|
80
|
-
var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3;
|
|
80
|
+
var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
81
81
|
const event = rawEvent;
|
|
82
82
|
if (!event.clipboardData) {
|
|
83
83
|
return false;
|
|
@@ -246,7 +246,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
246
246
|
if (handleCodeBlockWithAnalytics(view, event, slice, text)(state, dispatch)) {
|
|
247
247
|
return true;
|
|
248
248
|
}
|
|
249
|
-
if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText)(state, dispatch, view)) {
|
|
249
|
+
if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(state, dispatch, view)) {
|
|
250
250
|
return true;
|
|
251
251
|
}
|
|
252
252
|
if (handleSelectedTableWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
@@ -281,7 +281,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
281
281
|
|
|
282
282
|
// finally, handle rich-text copy-paste
|
|
283
283
|
if (isRichText) {
|
|
284
|
-
var _pluginInjectionApi$
|
|
284
|
+
var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
|
|
285
285
|
// linkify the text where possible
|
|
286
286
|
slice = linkifyContent(state.schema)(slice);
|
|
287
287
|
if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -289,7 +289,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
289
289
|
}
|
|
290
290
|
|
|
291
291
|
// run macro autoconvert prior to other conversions
|
|
292
|
-
if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
292
|
+
if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : (_pluginInjectionApi$d7 = _pluginInjectionApi$d6.actions) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
|
|
293
293
|
// TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
294
294
|
sendPasteAnalyticsEvent(view, event, slice, {
|
|
295
295
|
type: PasteTypes.richText
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getLayoutModeFromTargetNode, isLeftCursor } from '../utils';
|
|
2
2
|
import { Side } from '../selection';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -76,9 +76,9 @@ export const toDOM = (view, getPos) => {
|
|
|
76
76
|
if (nodeStart !== 0 || node && node.type.name === 'table') {
|
|
77
77
|
gapCursor.style.marginTop = style.getPropertyValue('margin-top');
|
|
78
78
|
}
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
81
|
-
gapCursor.setAttribute('layout',
|
|
79
|
+
const layoutMode = node && getLayoutModeFromTargetNode(node);
|
|
80
|
+
if (layoutMode) {
|
|
81
|
+
gapCursor.setAttribute('layout', layoutMode);
|
|
82
82
|
gapCursor.style.width = `${measureWidth(style)}px`;
|
|
83
83
|
} else {
|
|
84
84
|
mutateElementStyle(gapCursor, style, selection.side);
|
|
@@ -56,7 +56,7 @@ export const isTextBlockNearPos = (doc, schema, $pos, dir) => {
|
|
|
56
56
|
}
|
|
57
57
|
return false;
|
|
58
58
|
};
|
|
59
|
-
export function
|
|
59
|
+
export function getLayoutModeFromTargetNode(node) {
|
|
60
60
|
let layout;
|
|
61
61
|
if (node.attrs.layout) {
|
|
62
62
|
layout = node.attrs.layout;
|
|
@@ -68,7 +68,10 @@ export function getBreakoutModeFromTargetNode(node) {
|
|
|
68
68
|
}
|
|
69
69
|
}).attrs.mode;
|
|
70
70
|
}
|
|
71
|
-
if (
|
|
71
|
+
if (node.type.name === 'table' && node.attrs.width) {
|
|
72
|
+
layout = 'fixed-width';
|
|
73
|
+
}
|
|
74
|
+
if (['wide', 'full-width', 'fixed-width'].indexOf(layout) === -1) {
|
|
72
75
|
return '';
|
|
73
76
|
}
|
|
74
77
|
return layout;
|
|
@@ -5,7 +5,7 @@ import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
|
5
5
|
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
6
|
import { hideCaretModifier } from '../gap-cursor/styles';
|
|
7
7
|
import { GapCursorSelection, JSON_ID, Side as GapCursorSide, Side } from '../gap-cursor/selection';
|
|
8
|
-
import {
|
|
8
|
+
import { getLayoutModeFromTargetNode, isIgnoredClick } from '../gap-cursor/utils';
|
|
9
9
|
import { toDOM } from '../gap-cursor/utils/place-gap-cursor';
|
|
10
10
|
import { deleteNode, setGapCursorAtPos } from '../gap-cursor/actions';
|
|
11
11
|
import { Direction } from '../gap-cursor/direction';
|
|
@@ -70,10 +70,10 @@ const plugin = new SafePlugin({
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
const node = isRightCursor ? $from.nodeBefore : $from.nodeAfter;
|
|
73
|
-
const
|
|
73
|
+
const layoutMode = node && getLayoutModeFromTargetNode(node);
|
|
74
74
|
return DecorationSet.create(doc, [Decoration.widget(position, toDOM, {
|
|
75
|
-
key: `${JSON_ID}-${side}-${
|
|
76
|
-
side:
|
|
75
|
+
key: `${JSON_ID}-${side}-${layoutMode}`,
|
|
76
|
+
side: layoutMode ? -1 : 0
|
|
77
77
|
})]);
|
|
78
78
|
}
|
|
79
79
|
return null;
|
package/dist/es2019/version.json
CHANGED
|
@@ -132,8 +132,9 @@ var mediaPlugin = function mediaPlugin() {
|
|
|
132
132
|
pmPlugins.push({
|
|
133
133
|
name: 'mediaAltTextKeymap',
|
|
134
134
|
plugin: function plugin(_ref4) {
|
|
135
|
+
var _api$dependencies$ana2;
|
|
135
136
|
var schema = _ref4.schema;
|
|
136
|
-
return keymapMediaAltTextPlugin(schema);
|
|
137
|
+
return keymapMediaAltTextPlugin(schema, 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);
|
|
137
138
|
}
|
|
138
139
|
});
|
|
139
140
|
}
|
|
@@ -228,11 +229,11 @@ var mediaPlugin = function mediaPlugin() {
|
|
|
228
229
|
return /*#__PURE__*/React.createElement(IconImages, null);
|
|
229
230
|
},
|
|
230
231
|
action: function action(insert, state) {
|
|
231
|
-
var _api$dependencies$
|
|
232
|
+
var _api$dependencies$ana3;
|
|
232
233
|
var pluginState = pluginKey.getState(state);
|
|
233
234
|
pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
|
|
234
235
|
var tr = insert('');
|
|
235
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
236
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions.attachAnalyticsEvent({
|
|
236
237
|
action: ACTION.OPENED,
|
|
237
238
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
238
239
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -3,14 +3,17 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
import { createCommand } from '.';
|
|
5
5
|
import { isSelectionMediaSingleNode, getMediaNodeFromSelection } from '../../utils/media-common';
|
|
6
|
-
import { ACTION_SUBJECT, EVENT_TYPE,
|
|
6
|
+
import { ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION } from '@atlaskit/editor-common/analytics';
|
|
7
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
7
8
|
var createCommandWithAnalytics = function createCommandWithAnalytics(actionType, action, transform) {
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
return function (editorAnalyticsAPI) {
|
|
10
|
+
return withAnalytics(editorAnalyticsAPI, {
|
|
11
|
+
action: actionType,
|
|
12
|
+
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
13
|
+
actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
|
|
14
|
+
eventType: EVENT_TYPE.TRACK
|
|
15
|
+
})(createCommand(action, transform));
|
|
16
|
+
};
|
|
14
17
|
};
|
|
15
18
|
export var closeMediaAltTextMenu = createCommand(function (state) {
|
|
16
19
|
if (isSelectionMediaSingleNode(state)) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import * as keymaps from '../../../../keymaps';
|
|
3
3
|
import { openMediaAltTextMenu, closeMediaAltTextMenu } from './commands';
|
|
4
|
-
export default function keymapPlugin(schema) {
|
|
4
|
+
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
5
5
|
var list = {};
|
|
6
|
-
keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu, list);
|
|
6
|
+
keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
|
|
7
7
|
keymaps.bindKeymapWithCommand(keymaps.escape.common, closeMediaAltTextMenu, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
@@ -25,7 +25,7 @@ import * as helpers from '../commands/helpers';
|
|
|
25
25
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
26
26
|
import { stateKey } from './plugin-key';
|
|
27
27
|
import PickerFacade from '../picker-facade';
|
|
28
|
-
import { INPUT_METHOD } from '
|
|
28
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
29
29
|
import { isInEmptyLine } from '../../../utils/document';
|
|
30
30
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
31
31
|
import { isInListItem } from '../../../utils';
|
|
@@ -224,16 +224,16 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
224
224
|
});
|
|
225
225
|
}
|
|
226
226
|
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
227
|
-
var _this$pluginInjection;
|
|
227
|
+
var _this$pluginInjection, _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
228
228
|
// read width state right before inserting to get up-to-date and define values
|
|
229
229
|
var widthPluginState = (_this$pluginInjection = _this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
|
|
230
|
-
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState);
|
|
230
|
+
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert, _this.newInsertionBehaviour, widthPluginState, 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);
|
|
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
|
-
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));
|
|
234
|
-
} else {
|
|
235
232
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
236
|
-
|
|
233
|
+
insertMediaInlineNode(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));
|
|
234
|
+
} else {
|
|
235
|
+
var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
|
|
236
|
+
insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : (_pluginInjectionApi$d6 = _pluginInjectionApi$d5.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions)(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
// do events when media state changes
|
|
@@ -9,7 +9,7 @@ import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/Al
|
|
|
9
9
|
import { getMediaNodeFromSelection } from '../utils/media-common';
|
|
10
10
|
import { ClassNames } from '../pm-plugins/alt-text/style';
|
|
11
11
|
var testId = 'alt-text-edit-button';
|
|
12
|
-
export var altTextButton = function altTextButton(intl, state) {
|
|
12
|
+
export var altTextButton = function altTextButton(intl, state, editorAnalyticsAPI) {
|
|
13
13
|
var mediaNode = getMediaNodeFromSelection(state);
|
|
14
14
|
var message = mediaNode && mediaNode.attrs.alt ? messages.editAltText : messages.altText;
|
|
15
15
|
var title = intl.formatMessage(message);
|
|
@@ -17,7 +17,7 @@ export var altTextButton = function altTextButton(intl, state) {
|
|
|
17
17
|
title: title,
|
|
18
18
|
id: 'editor.media.altText',
|
|
19
19
|
type: 'button',
|
|
20
|
-
onClick: openMediaAltTextMenu,
|
|
20
|
+
onClick: openMediaAltTextMenu(editorAnalyticsAPI),
|
|
21
21
|
showTitle: true,
|
|
22
22
|
testId: testId,
|
|
23
23
|
tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
@@ -191,7 +191,7 @@ var generateMediaInlineFloatingToolbar = function generateMediaInlineFloatingToo
|
|
|
191
191
|
return items;
|
|
192
192
|
};
|
|
193
193
|
var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToolbar(state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) {
|
|
194
|
-
var _pluginInjectionApi$
|
|
194
|
+
var _pluginInjectionApi$d8;
|
|
195
195
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
196
196
|
var allowResizing = options.allowResizing,
|
|
197
197
|
allowLinking = options.allowLinking,
|
|
@@ -347,11 +347,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
349
|
if (allowAltTextOnImages) {
|
|
350
|
-
|
|
350
|
+
var _pluginInjectionApi$d7;
|
|
351
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
|
|
351
352
|
type: 'separator'
|
|
352
353
|
});
|
|
353
354
|
}
|
|
354
|
-
var _ref2 = (_pluginInjectionApi$
|
|
355
|
+
var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
|
|
355
356
|
hoverDecoration = _ref2.hoverDecoration;
|
|
356
357
|
var removeButton = {
|
|
357
358
|
id: 'editor.media.delete',
|
|
@@ -380,7 +381,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
380
381
|
return items;
|
|
381
382
|
};
|
|
382
383
|
export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
383
|
-
var _pluginInjectionApi$
|
|
384
|
+
var _pluginInjectionApi$d9;
|
|
384
385
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
385
386
|
var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
|
|
386
387
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -396,7 +397,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
396
397
|
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
397
398
|
var mediaPluginState = stateKey.getState(state);
|
|
398
399
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
399
|
-
var _ref3 = (_pluginInjectionApi$
|
|
400
|
+
var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
|
|
400
401
|
hoverDecoration = _ref3.hoverDecoration;
|
|
401
402
|
if (!mediaPluginState || mediaPluginState.isResizing) {
|
|
402
403
|
return;
|
|
@@ -418,10 +419,10 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
418
419
|
if (allowAltTextOnImages) {
|
|
419
420
|
var mediaAltTextPluginState = getMediaAltTextPluginState(state);
|
|
420
421
|
if (mediaAltTextPluginState.isAltTextEditorOpen) {
|
|
421
|
-
var _pluginInjectionApi$
|
|
422
|
+
var _pluginInjectionApi$d10;
|
|
422
423
|
return getAltTextToolbar(baseToolbar, {
|
|
423
424
|
altTextValidator: altTextValidator,
|
|
424
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
425
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.forceFocusSelector
|
|
425
426
|
});
|
|
426
427
|
}
|
|
427
428
|
}
|
|
@@ -432,22 +433,22 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
432
433
|
selectedNodeType = state.selection.node.type;
|
|
433
434
|
}
|
|
434
435
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
435
|
-
var _pluginInjectionApi$
|
|
436
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
436
437
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
437
438
|
baseToolbar.getDomRef = function () {
|
|
438
439
|
var _mediaPluginState$ele;
|
|
439
440
|
var selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
440
441
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
441
442
|
};
|
|
442
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
443
|
+
items = generateMediaCardFloatingToolbar(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);
|
|
443
444
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
444
|
-
var _pluginInjectionApi$
|
|
445
|
+
var _pluginInjectionApi$d13, _pluginInjectionApi$d14;
|
|
445
446
|
baseToolbar.getDomRef = function () {
|
|
446
447
|
var _mediaPluginState$ele2;
|
|
447
448
|
var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(MediaInlineNodeSelector));
|
|
448
449
|
return element || mediaPluginState.element;
|
|
449
450
|
};
|
|
450
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
451
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d13 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : (_pluginInjectionApi$d14 = _pluginInjectionApi$d13.analytics) === null || _pluginInjectionApi$d14 === void 0 ? void 0 : _pluginInjectionApi$d14.actions);
|
|
451
452
|
} else {
|
|
452
453
|
baseToolbar.getDomRef = function () {
|
|
453
454
|
var _mediaPluginState$ele3;
|
|
@@ -8,7 +8,6 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
8
8
|
import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
|
|
9
9
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
10
10
|
import { mapSlice } from '../../../utils/slice';
|
|
11
|
-
import { addAnalytics } from '../../analytics';
|
|
12
11
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
13
12
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
14
13
|
import { isImage } from './is-image';
|
|
@@ -33,6 +32,7 @@ function shouldAddParagraph(state) {
|
|
|
33
32
|
}
|
|
34
33
|
function insertNodesWithOptionalParagraph(nodes) {
|
|
35
34
|
var analyticsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
35
|
+
var editorAnalyticsAPI = arguments.length > 2 ? arguments[2] : undefined;
|
|
36
36
|
return function (state, dispatch) {
|
|
37
37
|
var tr = state.tr,
|
|
38
38
|
schema = state.schema;
|
|
@@ -46,7 +46,7 @@ function insertNodesWithOptionalParagraph(nodes) {
|
|
|
46
46
|
}
|
|
47
47
|
tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
|
|
48
48
|
if (inputMethod) {
|
|
49
|
-
|
|
49
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
50
50
|
}
|
|
51
51
|
if (dispatch) {
|
|
52
52
|
dispatch(tr);
|
|
@@ -57,7 +57,7 @@ function insertNodesWithOptionalParagraph(nodes) {
|
|
|
57
57
|
export var isMediaSingle = function isMediaSingle(schema, fileMimeType) {
|
|
58
58
|
return !!schema.nodes.mediaSingle && isImage(fileMimeType);
|
|
59
59
|
};
|
|
60
|
-
export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod) {
|
|
60
|
+
export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
|
|
61
61
|
var state = view.state,
|
|
62
62
|
dispatch = view.dispatch;
|
|
63
63
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -77,9 +77,9 @@ export var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, no
|
|
|
77
77
|
inputMethod: inputMethod,
|
|
78
78
|
fileExtension: node.attrs.__fileMimeType
|
|
79
79
|
};
|
|
80
|
-
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
|
|
80
|
+
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
|
|
81
81
|
};
|
|
82
|
-
export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) {
|
|
82
|
+
export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) {
|
|
83
83
|
var _state$selection$$fro;
|
|
84
84
|
if (collection === undefined) {
|
|
85
85
|
return false;
|
|
@@ -110,7 +110,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
110
110
|
insertNodesWithOptionalParagraph([node], {
|
|
111
111
|
fileExtension: fileExtension,
|
|
112
112
|
inputMethod: inputMethod
|
|
113
|
-
})(state, dispatch);
|
|
113
|
+
}, editorAnalyticsAPI)(state, dispatch);
|
|
114
114
|
} else {
|
|
115
115
|
var tr = null;
|
|
116
116
|
if (newInsertionBehaviour) {
|
|
@@ -121,7 +121,7 @@ export var insertMediaSingleNode = function insertMediaSingleNode(view, mediaSta
|
|
|
121
121
|
tr = pmSafeInsert(content, undefined, true)(state.tr);
|
|
122
122
|
}
|
|
123
123
|
if (inputMethod) {
|
|
124
|
-
|
|
124
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
125
125
|
}
|
|
126
126
|
dispatch(tr);
|
|
127
127
|
}
|
|
@@ -25,7 +25,6 @@ import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } f
|
|
|
25
25
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
26
26
|
import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
|
|
27
27
|
import { anyMarkActive } from '@atlaskit/editor-common/mark';
|
|
28
|
-
|
|
29
28
|
// remove text attribute from mention for copy/paste (GDPR)
|
|
30
29
|
export function handleMention(slice, schema) {
|
|
31
30
|
return mapSlice(slice, function (node) {
|
|
@@ -522,12 +521,12 @@ function isOnlyMediaSingle(state, slice) {
|
|
|
522
521
|
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
523
522
|
return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
|
|
524
523
|
}
|
|
525
|
-
export function handleMediaSingle(inputMethod) {
|
|
524
|
+
export function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
|
|
526
525
|
return function (slice) {
|
|
527
526
|
return function (state, dispatch, view) {
|
|
528
527
|
if (view) {
|
|
529
528
|
if (isOnlyMedia(state, slice)) {
|
|
530
|
-
return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod);
|
|
529
|
+
return insertMediaAsMediaSingle(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
|
|
531
530
|
}
|
|
532
531
|
if (insideTable(state) && isOnlyMediaSingle(state, slice)) {
|
|
533
532
|
var tr = state.tr.replaceSelection(slice);
|
|
@@ -239,10 +239,10 @@ export var handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(
|
|
|
239
239
|
type: PasteTypes.plain
|
|
240
240
|
}))(handleCodeBlock(text));
|
|
241
241
|
};
|
|
242
|
-
export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type) {
|
|
242
|
+
export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type, editorAnalyticsAPI) {
|
|
243
243
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
244
244
|
type: type
|
|
245
|
-
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD)(slice));
|
|
245
|
+
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD, editorAnalyticsAPI)(slice));
|
|
246
246
|
};
|
|
247
247
|
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
248
248
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|