@atlaskit/editor-core 187.18.2 → 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 +13 -0
- package/dist/cjs/labs/next/presets/default.js +2 -1
- package/dist/cjs/plugins/base/index.js +0 -7
- package/dist/cjs/plugins/code-block/index.js +1 -1
- package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +98 -95
- package/dist/cjs/plugins/composition/index.js +33 -0
- package/dist/cjs/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +8 -14
- package/dist/cjs/plugins/composition/pm-plugins/plugin-key.js +9 -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/placeholder/index.js +2 -2
- 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/labs/next/presets/default.js +2 -1
- package/dist/es2019/plugins/base/index.js +0 -5
- package/dist/es2019/plugins/code-block/index.js +1 -1
- package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +107 -104
- package/dist/es2019/plugins/composition/index.js +23 -0
- package/dist/es2019/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
- package/dist/es2019/plugins/composition/pm-plugins/plugin-key.js +2 -0
- 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/placeholder/index.js +2 -2
- 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/labs/next/presets/default.js +2 -1
- package/dist/esm/plugins/base/index.js +0 -7
- package/dist/esm/plugins/code-block/index.js +1 -1
- package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +98 -95
- package/dist/esm/plugins/composition/index.js +25 -0
- package/dist/esm/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
- package/dist/esm/plugins/composition/pm-plugins/plugin-key.js +2 -0
- 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/placeholder/index.js +2 -2
- 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/labs/next/presets/default.d.ts +16 -0
- package/dist/types/plugins/code-block/index.d.ts +6 -4
- package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
- package/dist/types/plugins/composition/index.d.ts +8 -0
- package/dist/types/plugins/composition/pm-plugins/main.d.ts +4 -0
- package/dist/types/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
- 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/placeholder/index.d.ts +2 -1
- package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +20 -0
- package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -4
- package/dist/types-ts4.5/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
- package/dist/types-ts4.5/plugins/composition/index.d.ts +8 -0
- package/dist/types-ts4.5/plugins/composition/pm-plugins/main.d.ts +4 -0
- package/dist/types-ts4.5/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
- 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/placeholder/index.d.ts +3 -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
- package/dist/types/plugins/base/pm-plugins/composition.d.ts +0 -9
- package/dist/types-ts4.5/plugins/base/pm-plugins/composition.d.ts +0 -9
|
@@ -130,7 +130,10 @@ const mediaPlugin = (options = {}, api) => {
|
|
|
130
130
|
name: 'mediaAltTextKeymap',
|
|
131
131
|
plugin: ({
|
|
132
132
|
schema
|
|
133
|
-
}) =>
|
|
133
|
+
}) => {
|
|
134
|
+
var _api$dependencies$ana2;
|
|
135
|
+
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);
|
|
136
|
+
}
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
if (options && options.allowLinking) {
|
|
@@ -226,11 +229,11 @@ const mediaPlugin = (options = {}, api) => {
|
|
|
226
229
|
keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
|
|
227
230
|
icon: () => /*#__PURE__*/React.createElement(IconImages, null),
|
|
228
231
|
action(insert, state) {
|
|
229
|
-
var _api$dependencies$
|
|
232
|
+
var _api$dependencies$ana3;
|
|
230
233
|
const pluginState = pluginKey.getState(state);
|
|
231
234
|
pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
|
|
232
235
|
const tr = insert('');
|
|
233
|
-
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({
|
|
234
237
|
action: ACTION.OPENED,
|
|
235
238
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
236
239
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createCommand } from '.';
|
|
2
2
|
import { isSelectionMediaSingleNode, getMediaNodeFromSelection } from '../../utils/media-common';
|
|
3
|
-
import { ACTION_SUBJECT, EVENT_TYPE,
|
|
3
|
+
import { ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
5
|
const createCommandWithAnalytics = (actionType, action, transform) => {
|
|
5
|
-
return withAnalytics({
|
|
6
|
+
return editorAnalyticsAPI => withAnalytics(editorAnalyticsAPI, {
|
|
6
7
|
action: actionType,
|
|
7
8
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
8
9
|
actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
|
|
@@ -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
|
const 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
|
}
|
|
@@ -16,7 +16,7 @@ import * as helpers from '../commands/helpers';
|
|
|
16
16
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
17
17
|
import { stateKey } from './plugin-key';
|
|
18
18
|
import PickerFacade from '../picker-facade';
|
|
19
|
-
import { INPUT_METHOD } from '
|
|
19
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
20
20
|
import { isInEmptyLine } from '../../../utils/document';
|
|
21
21
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
22
22
|
import { isInListItem } from '../../../utils';
|
|
@@ -170,16 +170,16 @@ export class MediaPluginStateImplementation {
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
173
|
-
var _this$pluginInjection;
|
|
173
|
+
var _this$pluginInjection, _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
174
174
|
// read width state right before inserting to get up-to-date and define values
|
|
175
175
|
const widthPluginState = (_this$pluginInjection = this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
|
|
176
|
-
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState);
|
|
176
|
+
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);
|
|
177
177
|
} 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)) {
|
|
178
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
179
|
-
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));
|
|
180
|
-
} else {
|
|
181
178
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
182
|
-
|
|
179
|
+
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));
|
|
180
|
+
} else {
|
|
181
|
+
var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
|
|
182
|
+
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));
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
// do events when media state changes
|
|
@@ -6,7 +6,7 @@ import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/Al
|
|
|
6
6
|
import { getMediaNodeFromSelection } from '../utils/media-common';
|
|
7
7
|
import { ClassNames } from '../pm-plugins/alt-text/style';
|
|
8
8
|
const testId = 'alt-text-edit-button';
|
|
9
|
-
export const altTextButton = (intl, state) => {
|
|
9
|
+
export const altTextButton = (intl, state, editorAnalyticsAPI) => {
|
|
10
10
|
const mediaNode = getMediaNodeFromSelection(state);
|
|
11
11
|
const message = mediaNode && mediaNode.attrs.alt ? messages.editAltText : messages.altText;
|
|
12
12
|
const title = intl.formatMessage(message);
|
|
@@ -14,7 +14,7 @@ export const altTextButton = (intl, state) => {
|
|
|
14
14
|
title,
|
|
15
15
|
id: 'editor.media.altText',
|
|
16
16
|
type: 'button',
|
|
17
|
-
onClick: openMediaAltTextMenu,
|
|
17
|
+
onClick: openMediaAltTextMenu(editorAnalyticsAPI),
|
|
18
18
|
showTitle: true,
|
|
19
19
|
testId,
|
|
20
20
|
tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
@@ -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
|
|
@@ -4,7 +4,6 @@ import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
4
4
|
import { DecorationSet, Decoration } from '@atlaskit/editor-prosemirror/view';
|
|
5
5
|
export const pluginKey = new PluginKey('placeholderPlugin');
|
|
6
6
|
import { isTypeAheadOpen } from '../type-ahead/utils';
|
|
7
|
-
import { isComposing } from '../base/pm-plugins/composition';
|
|
8
7
|
function getPlaceholderState(editorState) {
|
|
9
8
|
return pluginKey.getState(editorState);
|
|
10
9
|
}
|
|
@@ -100,7 +99,8 @@ export function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api
|
|
|
100
99
|
placeholderText,
|
|
101
100
|
pos
|
|
102
101
|
} = getPlaceholderState(editorState);
|
|
103
|
-
|
|
102
|
+
const compositionPluginState = api === null || api === void 0 ? void 0 : api.dependencies.composition.sharedState.currentState();
|
|
103
|
+
if (hasPlaceholder && placeholderText && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
|
|
104
104
|
return createPlaceholderDecoration(editorState, placeholderText, pos);
|
|
105
105
|
}
|
|
106
106
|
return;
|
|
@@ -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
|
@@ -20,6 +20,7 @@ import { analyticsPlugin as deprecatedAnalyticsPlugin } from '../../../plugins';
|
|
|
20
20
|
import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
21
21
|
import placeholderPlugin from '../../../plugins/placeholder';
|
|
22
22
|
import annotationPlugin from '../../../plugins/annotation';
|
|
23
|
+
import compositionPlugin from '../../../plugins/composition';
|
|
23
24
|
import quickInsertPlugin from '../../../plugins/quick-insert';
|
|
24
25
|
import selectionPlugin from '../../../plugins/selection';
|
|
25
26
|
import codeBlockPlugin from '../../../plugins/code-block';
|
|
@@ -53,7 +54,7 @@ export function createDefaultPreset(options) {
|
|
|
53
54
|
}]);
|
|
54
55
|
}
|
|
55
56
|
return builder;
|
|
56
|
-
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
57
|
+
}).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, function (p, builder) {
|
|
57
58
|
var _options$featureFlags;
|
|
58
59
|
// The undo redo plugin needs to be add before the blockTypePlugin
|
|
59
60
|
if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
|
|
@@ -14,7 +14,6 @@ import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
|
14
14
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
15
15
|
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
16
16
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
17
|
-
import compositionPlugin from './pm-plugins/composition';
|
|
18
17
|
// Chrome >= 88
|
|
19
18
|
export var isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
|
|
20
19
|
var basePlugin = function basePlugin(options, api) {
|
|
@@ -104,12 +103,6 @@ var basePlugin = function basePlugin(options, api) {
|
|
|
104
103
|
return disableSpellcheckingPlugin(featureFlags);
|
|
105
104
|
}
|
|
106
105
|
});
|
|
107
|
-
plugins.push({
|
|
108
|
-
name: 'compositionPlugin',
|
|
109
|
-
plugin: function plugin() {
|
|
110
|
-
return compositionPlugin();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
106
|
return plugins;
|
|
114
107
|
},
|
|
115
108
|
nodes: function nodes() {
|