@atlaskit/editor-core 187.19.0 → 187.20.0
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 +20 -0
- package/dist/cjs/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/cjs/plugins/emoji/index.js +16 -5
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/insert-block/index.js +3 -7
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- 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 +22 -10
- package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/cjs/plugins/media/toolbar/index.js +33 -19
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +15 -3
- 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/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/cjs/utils/document.js +6 -24
- package/dist/cjs/utils/index.js +33 -105
- package/dist/cjs/utils/prosemirror/position.js +33 -41
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
- package/dist/es2019/plugins/emoji/index.js +14 -4
- package/dist/es2019/plugins/index.js +1 -1
- package/dist/es2019/plugins/insert-block/index.js +3 -7
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
- 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 +16 -7
- package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/es2019/plugins/media/toolbar/index.js +34 -21
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -4
- 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/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/es2019/utils/document.js +1 -20
- package/dist/es2019/utils/index.js +1 -99
- package/dist/es2019/utils/prosemirror/position.js +1 -51
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/esm/plugins/emoji/index.js +14 -4
- package/dist/esm/plugins/index.js +1 -1
- package/dist/esm/plugins/insert-block/index.js +3 -7
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- 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 +18 -7
- package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/esm/plugins/media/toolbar/index.js +35 -21
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -4
- 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/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/esm/utils/document.js +1 -22
- package/dist/esm/utils/index.js +1 -97
- package/dist/esm/utils/prosemirror/position.js +1 -39
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +32 -32
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/index.d.ts +9 -4
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/index.d.ts +3 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -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/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- 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/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/document.d.ts +2 -7
- package/dist/types/utils/index.d.ts +2 -6
- package/dist/types/utils/prosemirror/position.d.ts +1 -8
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
- package/dist/types-ts4.5/plugins/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -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/pm-plugins/main.d.ts +3 -0
- package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- 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/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/document.d.ts +2 -7
- package/dist/types-ts4.5/utils/index.d.ts +2 -6
- package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
- package/package.json +4 -4
- package/report.api.md +5 -0
- package/tmp/api-report-tmp.d.ts +5 -1
|
@@ -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';
|
|
@@ -36,6 +36,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
36
36
|
export { stateKey } from './plugin-key';
|
|
37
37
|
export var MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
38
38
|
export var MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
|
|
39
|
+
export var MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
|
|
39
40
|
var createDropPlaceholder = function createDropPlaceholder(intl, allowDropLine) {
|
|
40
41
|
var dropPlaceholder = document.createElement('div');
|
|
41
42
|
var createElement = React.createElement;
|
|
@@ -66,6 +67,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
66
67
|
_defineProperty(this, "layout", 'center');
|
|
67
68
|
_defineProperty(this, "mediaNodes", []);
|
|
68
69
|
_defineProperty(this, "isResizing", false);
|
|
70
|
+
_defineProperty(this, "resizingWidth", 0);
|
|
69
71
|
_defineProperty(this, "destroyed", false);
|
|
70
72
|
_defineProperty(this, "removeOnCloseListener", function () {});
|
|
71
73
|
_defineProperty(this, "onPopupToggleCallback", function () {});
|
|
@@ -224,16 +226,16 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
224
226
|
});
|
|
225
227
|
}
|
|
226
228
|
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
227
|
-
var _this$pluginInjection;
|
|
229
|
+
var _this$pluginInjection, _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
228
230
|
// read width state right before inserting to get up-to-date and define values
|
|
229
231
|
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);
|
|
232
|
+
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
233
|
} 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
234
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
236
|
-
|
|
235
|
+
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));
|
|
236
|
+
} else {
|
|
237
|
+
var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
|
|
238
|
+
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
239
|
}
|
|
238
240
|
|
|
239
241
|
// do events when media state changes
|
|
@@ -485,6 +487,11 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
485
487
|
value: function setIsResizing(isResizing) {
|
|
486
488
|
this.isResizing = isResizing;
|
|
487
489
|
}
|
|
490
|
+
}, {
|
|
491
|
+
key: "setResizingWidth",
|
|
492
|
+
value: function setResizingWidth(width) {
|
|
493
|
+
this.resizingWidth = width;
|
|
494
|
+
}
|
|
488
495
|
}, {
|
|
489
496
|
key: "updateElement",
|
|
490
497
|
value: function updateElement() {
|
|
@@ -626,9 +633,13 @@ export var createPlugin = function createPlugin(_schema, options, reactContext,
|
|
|
626
633
|
},
|
|
627
634
|
apply: function apply(tr, pluginState) {
|
|
628
635
|
var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
636
|
+
var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
629
637
|
if (isResizing !== undefined) {
|
|
630
638
|
pluginState.setIsResizing(isResizing);
|
|
631
639
|
}
|
|
640
|
+
if (resizingWidth) {
|
|
641
|
+
pluginState.setResizingWidth(resizingWidth);
|
|
642
|
+
}
|
|
632
643
|
|
|
633
644
|
// remap editing media single position if we're in collab
|
|
634
645
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
@@ -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, {
|
|
@@ -29,8 +29,8 @@ import ImageBorderItem from '../ui/ImageBorder';
|
|
|
29
29
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
30
30
|
import { shouldShowImageBorder } from './imageBorder';
|
|
31
31
|
import { PixelEntry } from '../ui/PixelEntry';
|
|
32
|
-
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
33
|
-
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
32
|
+
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
|
|
33
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
34
34
|
var remove = function remove(state, dispatch) {
|
|
35
35
|
if (dispatch) {
|
|
36
36
|
dispatch(removeSelectedNode(state.tr));
|
|
@@ -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,
|
|
@@ -258,12 +258,15 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
258
258
|
type: 'custom',
|
|
259
259
|
fallback: [],
|
|
260
260
|
render: function render(editorView) {
|
|
261
|
+
var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
|
|
261
262
|
if (!editorView) {
|
|
262
263
|
return null;
|
|
263
264
|
}
|
|
264
265
|
var state = editorView.state,
|
|
265
266
|
dispatch = editorView.dispatch;
|
|
266
267
|
var selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
268
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
|
|
269
|
+
var containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
|
|
267
270
|
if (!selectedMediaSingleNode) {
|
|
268
271
|
return null;
|
|
269
272
|
}
|
|
@@ -271,13 +274,25 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
271
274
|
if (!selectedMediaNode) {
|
|
272
275
|
return null;
|
|
273
276
|
}
|
|
274
|
-
var
|
|
277
|
+
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
278
|
+
singleMediaWidth = _selectedMediaSingleN.width,
|
|
279
|
+
widthType = _selectedMediaSingleN.widthType,
|
|
280
|
+
layout = _selectedMediaSingleN.layout;
|
|
275
281
|
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
276
282
|
mediaWidth = _selectedMediaNode$at.width,
|
|
277
283
|
mediaHeight = _selectedMediaNode$at.height;
|
|
284
|
+
var pixelWidth = calcMediaSinglePixelWidth({
|
|
285
|
+
width: singleMediaWidth,
|
|
286
|
+
widthType: widthType,
|
|
287
|
+
origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
288
|
+
layout: layout,
|
|
289
|
+
contentWidth: contentWidth,
|
|
290
|
+
containerWidth: containerWidth,
|
|
291
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
292
|
+
});
|
|
278
293
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
279
294
|
intl: intl,
|
|
280
|
-
width:
|
|
295
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
281
296
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
282
297
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
283
298
|
validate: function validate(value) {
|
|
@@ -297,11 +312,9 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
297
312
|
});
|
|
298
313
|
}
|
|
299
314
|
});
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
});
|
|
304
|
-
}
|
|
315
|
+
toolbarButtons.push({
|
|
316
|
+
type: 'separator'
|
|
317
|
+
});
|
|
305
318
|
}
|
|
306
319
|
if (allowLinking && shouldShowMediaLinkToolbar(state)) {
|
|
307
320
|
toolbarButtons.push({
|
|
@@ -347,11 +360,12 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
347
360
|
}
|
|
348
361
|
}
|
|
349
362
|
if (allowAltTextOnImages) {
|
|
350
|
-
|
|
363
|
+
var _pluginInjectionApi$d7;
|
|
364
|
+
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
365
|
type: 'separator'
|
|
352
366
|
});
|
|
353
367
|
}
|
|
354
|
-
var _ref2 = (_pluginInjectionApi$
|
|
368
|
+
var _ref2 = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {},
|
|
355
369
|
hoverDecoration = _ref2.hoverDecoration;
|
|
356
370
|
var removeButton = {
|
|
357
371
|
id: 'editor.media.delete',
|
|
@@ -380,7 +394,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
380
394
|
return items;
|
|
381
395
|
};
|
|
382
396
|
export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
383
|
-
var _pluginInjectionApi$
|
|
397
|
+
var _pluginInjectionApi$d9;
|
|
384
398
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
385
399
|
var pluginInjectionApi = arguments.length > 3 ? arguments[3] : undefined;
|
|
386
400
|
var _state$schema$nodes = state.schema.nodes,
|
|
@@ -396,9 +410,9 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
396
410
|
getEditorFeatureFlags = options.getEditorFeatureFlags;
|
|
397
411
|
var mediaPluginState = stateKey.getState(state);
|
|
398
412
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
399
|
-
var _ref3 = (_pluginInjectionApi$
|
|
413
|
+
var _ref3 = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {},
|
|
400
414
|
hoverDecoration = _ref3.hoverDecoration;
|
|
401
|
-
if (!mediaPluginState
|
|
415
|
+
if (!mediaPluginState) {
|
|
402
416
|
return;
|
|
403
417
|
}
|
|
404
418
|
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
@@ -418,10 +432,10 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
418
432
|
if (allowAltTextOnImages) {
|
|
419
433
|
var mediaAltTextPluginState = getMediaAltTextPluginState(state);
|
|
420
434
|
if (mediaAltTextPluginState.isAltTextEditorOpen) {
|
|
421
|
-
var _pluginInjectionApi$
|
|
435
|
+
var _pluginInjectionApi$d10;
|
|
422
436
|
return getAltTextToolbar(baseToolbar, {
|
|
423
437
|
altTextValidator: altTextValidator,
|
|
424
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
438
|
+
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
439
|
});
|
|
426
440
|
}
|
|
427
441
|
}
|
|
@@ -432,22 +446,22 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
432
446
|
selectedNodeType = state.selection.node.type;
|
|
433
447
|
}
|
|
434
448
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
435
|
-
var _pluginInjectionApi$
|
|
449
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
436
450
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
437
451
|
baseToolbar.getDomRef = function () {
|
|
438
452
|
var _mediaPluginState$ele;
|
|
439
453
|
var selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
440
454
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
441
455
|
};
|
|
442
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
456
|
+
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
457
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
444
|
-
var _pluginInjectionApi$
|
|
458
|
+
var _pluginInjectionApi$d13, _pluginInjectionApi$d14;
|
|
445
459
|
baseToolbar.getDomRef = function () {
|
|
446
460
|
var _mediaPluginState$ele2;
|
|
447
461
|
var element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(".".concat(MediaInlineNodeSelector));
|
|
448
462
|
return element || mediaPluginState.element;
|
|
449
463
|
};
|
|
450
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
464
|
+
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
465
|
} else {
|
|
452
466
|
baseToolbar.getDomRef = function () {
|
|
453
467
|
var _mediaPluginState$ele3;
|
|
@@ -23,9 +23,11 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
|
23
23
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
24
24
|
import classnames from 'classnames';
|
|
25
25
|
import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
|
|
26
|
-
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
26
|
+
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
27
27
|
import { findClosestSnap, getGuidelinesWithHighlights, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps } from '@atlaskit/editor-common/guideline';
|
|
28
28
|
import memoizeOne from 'memoize-one';
|
|
29
|
+
import throttle from 'lodash/throttle';
|
|
30
|
+
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
29
31
|
export var resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
30
32
|
|
|
31
33
|
// TODO: Create new fixed image size event
|
|
@@ -130,7 +132,15 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
130
132
|
state = _this$props$view.state,
|
|
131
133
|
dispatch = _this$props$view.dispatch;
|
|
132
134
|
var tr = state.tr;
|
|
133
|
-
tr.setMeta(
|
|
135
|
+
tr.setMeta(MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
|
|
136
|
+
return dispatch(tr);
|
|
137
|
+
});
|
|
138
|
+
_defineProperty(_assertThisInitialized(_this), "updateSizeInPluginState", function (width) {
|
|
139
|
+
var _this$props$view2 = _this.props.view,
|
|
140
|
+
state = _this$props$view2.state,
|
|
141
|
+
dispatch = _this$props$view2.dispatch;
|
|
142
|
+
var tr = state.tr;
|
|
143
|
+
tr.setMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
|
|
134
144
|
return dispatch(tr);
|
|
135
145
|
});
|
|
136
146
|
_defineProperty(_assertThisInitialized(_this), "calcMaxWidth", memoizeOne(function (contentWidth, containerWidth, fullWidthMode) {
|
|
@@ -184,11 +194,12 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
184
194
|
});
|
|
185
195
|
_this.selectCurrentMediaNode();
|
|
186
196
|
_this.setIsResizing(true);
|
|
197
|
+
_this.updateSizeInPluginState(_this.state.size.width);
|
|
187
198
|
// re-calucate guidelines
|
|
188
199
|
_this.guidelines = _this.getAllGuidelines();
|
|
189
200
|
return 0;
|
|
190
201
|
});
|
|
191
|
-
_defineProperty(_assertThisInitialized(_this), "handleResize", function (size, delta) {
|
|
202
|
+
_defineProperty(_assertThisInitialized(_this), "handleResize", throttle(function (size, delta) {
|
|
192
203
|
var _this$props4 = _this.props,
|
|
193
204
|
originalWidth = _this$props4.width,
|
|
194
205
|
originalHeight = _this$props4.height,
|
|
@@ -208,10 +219,11 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
208
219
|
},
|
|
209
220
|
snaps: guidelineSnaps.snaps
|
|
210
221
|
});
|
|
222
|
+
_this.updateSizeInPluginState(width);
|
|
211
223
|
if (calculatedWidthWithLayout.layout !== layout) {
|
|
212
224
|
updateSize(width, calculatedWidthWithLayout.layout);
|
|
213
225
|
}
|
|
214
|
-
});
|
|
226
|
+
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
215
227
|
_defineProperty(_assertThisInitialized(_this), "handleResizeStop", function (size, delta) {
|
|
216
228
|
var _this$props5 = _this.props,
|
|
217
229
|
originalWidth = _this$props5.width,
|
|
@@ -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;
|
|
@@ -102,7 +102,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
102
102
|
}
|
|
103
103
|
},
|
|
104
104
|
handlePaste: function handlePaste(view, rawEvent, slice) {
|
|
105
|
-
var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3;
|
|
105
|
+
var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
|
|
106
106
|
var event = rawEvent;
|
|
107
107
|
if (!event.clipboardData) {
|
|
108
108
|
return false;
|
|
@@ -266,7 +266,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
266
266
|
if (handleCodeBlockWithAnalytics(view, event, slice, text)(state, dispatch)) {
|
|
267
267
|
return true;
|
|
268
268
|
}
|
|
269
|
-
if (handleMediaSingleWithAnalytics(view, event, slice, isPastedFile ? PasteTypes.binary : PasteTypes.richText)(state, dispatch, view)) {
|
|
269
|
+
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)) {
|
|
270
270
|
return true;
|
|
271
271
|
}
|
|
272
272
|
if (handleSelectedTableWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
@@ -299,7 +299,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
299
299
|
|
|
300
300
|
// finally, handle rich-text copy-paste
|
|
301
301
|
if (isRichText) {
|
|
302
|
-
var _pluginInjectionApi$
|
|
302
|
+
var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
|
|
303
303
|
// linkify the text where possible
|
|
304
304
|
slice = linkifyContent(state.schema)(slice);
|
|
305
305
|
if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -307,7 +307,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
307
307
|
}
|
|
308
308
|
|
|
309
309
|
// run macro autoconvert prior to other conversions
|
|
310
|
-
if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
310
|
+
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)) {
|
|
311
311
|
// TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
312
312
|
sendPasteAnalyticsEvent(view, event, slice, {
|
|
313
313
|
type: PasteTypes.richText
|
|
@@ -7,4 +7,4 @@ var gapCursor = '.ProseMirror-gapcursor';
|
|
|
7
7
|
var prosemirrorwidget = '.ProseMirror-widget';
|
|
8
8
|
var wrapLeft = '[layout="wrap-left"]';
|
|
9
9
|
var wrapRight = '[layout="wrap-right"]';
|
|
10
|
-
export var gapCursorStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
|
|
10
|
+
export var gapCursorStyles = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'],\n & span[layout='fixed-width'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _toArray from "@babel/runtime/helpers/toArray";
|
|
2
|
-
import {
|
|
2
|
+
import { getLayoutModeFromTargetNode, isLeftCursor } from '../utils';
|
|
3
3
|
import { Side } from '../selection';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -79,9 +79,9 @@ export var toDOM = function toDOM(view, getPos) {
|
|
|
79
79
|
if (nodeStart !== 0 || node && node.type.name === 'table') {
|
|
80
80
|
gapCursor.style.marginTop = style.getPropertyValue('margin-top');
|
|
81
81
|
}
|
|
82
|
-
var
|
|
83
|
-
if (
|
|
84
|
-
gapCursor.setAttribute('layout',
|
|
82
|
+
var layoutMode = node && getLayoutModeFromTargetNode(node);
|
|
83
|
+
if (layoutMode) {
|
|
84
|
+
gapCursor.setAttribute('layout', layoutMode);
|
|
85
85
|
gapCursor.style.width = "".concat(measureWidth(style), "px");
|
|
86
86
|
} else {
|
|
87
87
|
mutateElementStyle(gapCursor, style, selection.side);
|
|
@@ -58,7 +58,7 @@ export var isTextBlockNearPos = function isTextBlockNearPos(doc, schema, $pos, d
|
|
|
58
58
|
}
|
|
59
59
|
return false;
|
|
60
60
|
};
|
|
61
|
-
export function
|
|
61
|
+
export function getLayoutModeFromTargetNode(node) {
|
|
62
62
|
var layout;
|
|
63
63
|
if (node.attrs.layout) {
|
|
64
64
|
layout = node.attrs.layout;
|
|
@@ -72,7 +72,10 @@ export function getBreakoutModeFromTargetNode(node) {
|
|
|
72
72
|
}
|
|
73
73
|
}).attrs.mode;
|
|
74
74
|
}
|
|
75
|
-
if (
|
|
75
|
+
if (node.type.name === 'table' && node.attrs.width) {
|
|
76
|
+
layout = 'fixed-width';
|
|
77
|
+
}
|
|
78
|
+
if (['wide', 'full-width', 'fixed-width'].indexOf(layout) === -1) {
|
|
76
79
|
return '';
|
|
77
80
|
}
|
|
78
81
|
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';
|
|
@@ -69,10 +69,10 @@ var plugin = new SafePlugin({
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
var node = isRightCursor ? $from.nodeBefore : $from.nodeAfter;
|
|
72
|
-
var
|
|
72
|
+
var layoutMode = node && getLayoutModeFromTargetNode(node);
|
|
73
73
|
return DecorationSet.create(doc, [Decoration.widget(position, toDOM, {
|
|
74
|
-
key: "".concat(JSON_ID, "-").concat(side, "-").concat(
|
|
75
|
-
side:
|
|
74
|
+
key: "".concat(JSON_ID, "-").concat(side, "-").concat(layoutMode),
|
|
75
|
+
side: layoutMode ? -1 : 0
|
|
76
76
|
})]);
|
|
77
77
|
}
|
|
78
78
|
return null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
2
|
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
3
3
|
import { getDisabledState } from '../utils/disabled';
|
|
4
|
+
import { pluginCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
4
5
|
export var toggleColor = function toggleColor(color) {
|
|
5
6
|
return function (state, dispatch) {
|
|
6
7
|
var textColor = state.schema.marks.textColor;
|
|
@@ -20,9 +21,9 @@ export var toggleColor = function toggleColor(color) {
|
|
|
20
21
|
color: color
|
|
21
22
|
});
|
|
22
23
|
state.tr.scrollIntoView();
|
|
23
|
-
toggleMark(textColor, {
|
|
24
|
+
pluginCommandToPMCommand(toggleMark(textColor, {
|
|
24
25
|
color: color
|
|
25
|
-
})(state, dispatch);
|
|
26
|
+
}))(state, dispatch);
|
|
26
27
|
}
|
|
27
28
|
return true;
|
|
28
29
|
};
|
|
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { getBreakoutMode } from './node-width';
|
|
4
4
|
import { processRawValue, hasDocAsParent, getStepRange, isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
5
|
+
export { findFarthestParentNode } from '@atlaskit/editor-common/utils';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Checks if a node has any content. Ignores node that only contain empty block nodes.
|
|
@@ -50,28 +51,6 @@ export function processRawFragmentValue(schema, value, providerFactory, sanitize
|
|
|
50
51
|
}
|
|
51
52
|
return Fragment.from(adfEntities);
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Find the farthest node given a condition
|
|
56
|
-
* @param predicate Function to check the node
|
|
57
|
-
*/
|
|
58
|
-
export var findFarthestParentNode = function findFarthestParentNode(predicate) {
|
|
59
|
-
return function ($pos) {
|
|
60
|
-
var candidate = null;
|
|
61
|
-
for (var i = $pos.depth; i > 0; i--) {
|
|
62
|
-
var _node = $pos.node(i);
|
|
63
|
-
if (predicate(_node)) {
|
|
64
|
-
candidate = {
|
|
65
|
-
pos: i > 0 ? $pos.before(i) : 0,
|
|
66
|
-
start: $pos.start(i),
|
|
67
|
-
depth: i,
|
|
68
|
-
node: _node
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return candidate;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
54
|
export var isSelectionEndOfParagraph = function isSelectionEndOfParagraph(state) {
|
|
76
55
|
return state.selection.$to.parent.type === state.schema.nodes.paragraph && state.selection.$to.pos === state.doc.resolve(state.selection.$to.pos).end();
|
|
77
56
|
};
|