@atlaskit/editor-core 187.8.13 → 187.9.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 +10 -0
- package/dist/cjs/plugins/floating-toolbar/index.js +1 -3
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +33 -23
- package/dist/cjs/plugins/media/toolbar/index.js +16 -2
- package/dist/cjs/plugins/media/toolbar/utils.js +7 -2
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +574 -0
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/guidelines.js +117 -0
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +15 -0
- package/dist/cjs/ui/Resizer/ResizeLabel/index.js +20 -0
- package/dist/cjs/ui/Resizer/ResizeLabel/styles.js +17 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/floating-toolbar/index.js +1 -1
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +34 -23
- package/dist/es2019/plugins/media/toolbar/index.js +19 -3
- package/dist/es2019/plugins/media/toolbar/utils.js +7 -1
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +493 -0
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/guidelines.js +108 -0
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +8 -0
- package/dist/es2019/ui/Resizer/ResizeLabel/index.js +12 -0
- package/dist/es2019/ui/Resizer/ResizeLabel/styles.js +25 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/floating-toolbar/index.js +1 -3
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +33 -23
- package/dist/esm/plugins/media/toolbar/index.js +17 -3
- package/dist/esm/plugins/media/toolbar/utils.js +5 -1
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +564 -0
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/guidelines.js +108 -0
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.js +8 -0
- package/dist/esm/ui/Resizer/ResizeLabel/index.js +12 -0
- package/dist/esm/ui/Resizer/ResizeLabel/styles.js +7 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/universal.d.ts +1 -2
- package/dist/types/plugins/floating-toolbar/index.d.ts +3 -1
- package/dist/types/plugins/media/index.d.ts +2 -0
- package/dist/types/plugins/media/nodeviews/styles.d.ts +1 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/media/toolbar/utils.d.ts +1 -0
- package/dist/types/plugins/media/types.d.ts +1 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +61 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +4 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.d.ts +7 -0
- package/dist/types/plugins/media/ui/ResizableMediaSingle/types.d.ts +1 -0
- package/dist/types/ui/Resizer/ResizeLabel/index.d.ts +8 -0
- package/dist/types/ui/Resizer/ResizeLabel/styles.d.ts +3 -0
- package/dist/types-ts4.5/labs/next/presets/universal.d.ts +1 -2
- package/dist/types-ts4.5/plugins/floating-toolbar/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/index.d.ts +2 -0
- package/dist/types-ts4.5/plugins/media/nodeviews/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/plugins/media/toolbar/utils.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/types.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +61 -0
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/guidelines.d.ts +4 -0
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/resizable-media-single-messages.d.ts +7 -0
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/types.d.ts +1 -0
- package/dist/types-ts4.5/ui/Resizer/ResizeLabel/index.d.ts +8 -0
- package/dist/types-ts4.5/ui/Resizer/ResizeLabel/styles.d.ts +3 -0
- package/package.json +2 -2
- package/report.api.md +7 -4
- package/tmp/api-report-tmp.d.ts +5 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import _get from "@babel/runtime/helpers/get";
|
|
2
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
3
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
4
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
5
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
@@ -21,6 +20,7 @@ import { MediaSingle, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaski
|
|
|
21
20
|
import { browser, floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
22
21
|
import { isNodeSelectedOrInRange } from '../../../utils/nodes';
|
|
23
22
|
import { setNodeSelection, setTextSelection } from '../../../utils';
|
|
23
|
+
import ResizableMediaSingleNext from '../ui/ResizableMediaSingle/ResizableMediaSingleNext';
|
|
24
24
|
import ResizableMediaSingle from '../ui/ResizableMediaSingle';
|
|
25
25
|
import { MEDIA_CONTENT_WRAP_CLASS_NAME } from '../pm-plugins/main';
|
|
26
26
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
@@ -35,6 +35,8 @@ import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
|
35
35
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
36
36
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
37
37
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
38
|
+
import { getMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
|
|
39
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
38
40
|
var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
39
41
|
_inherits(MediaSingleNode, _Component);
|
|
40
42
|
var _super = _createSuper(MediaSingleNode);
|
|
@@ -199,7 +201,8 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
199
201
|
}
|
|
200
202
|
var tr = state.tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, _this.props.node.attrs), {}, {
|
|
201
203
|
layout: layout,
|
|
202
|
-
width: width
|
|
204
|
+
width: width,
|
|
205
|
+
widthType: 'pixel'
|
|
203
206
|
}));
|
|
204
207
|
tr.setMeta('scrollIntoView', false);
|
|
205
208
|
/**
|
|
@@ -311,12 +314,19 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
311
314
|
mediaOptions = _this$props2.mediaOptions,
|
|
312
315
|
fullWidthMode = _this$props2.fullWidthMode,
|
|
313
316
|
state = _this$props2.view.state,
|
|
314
|
-
view = _this$props2.view
|
|
317
|
+
view = _this$props2.view,
|
|
318
|
+
pluginInjectionApi = _this$props2.pluginInjectionApi,
|
|
319
|
+
containerWidth = _this$props2.width,
|
|
320
|
+
lineLength = _this$props2.lineLength,
|
|
321
|
+
dispatchAnalyticsEvent = _this$props2.dispatchAnalyticsEvent;
|
|
315
322
|
var _ref4 = node.attrs,
|
|
316
323
|
layout = _ref4.layout,
|
|
317
|
-
|
|
324
|
+
widthType = _ref4.widthType,
|
|
325
|
+
mediaSingleWidthAttribute = _ref4.width;
|
|
318
326
|
var childNode = node.firstChild;
|
|
319
327
|
var attrs = childNode.attrs;
|
|
328
|
+
|
|
329
|
+
// original width and height of child media node (scaled)
|
|
320
330
|
var width = attrs.width,
|
|
321
331
|
height = attrs.height;
|
|
322
332
|
if (attrs.type === 'external') {
|
|
@@ -343,16 +353,29 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
343
353
|
width = DEFAULT_IMAGE_WIDTH;
|
|
344
354
|
height = DEFAULT_IMAGE_HEIGHT;
|
|
345
355
|
}
|
|
356
|
+
var isSelected = selected();
|
|
346
357
|
var mediaSingleProps = {
|
|
347
358
|
layout: layout,
|
|
348
359
|
width: width,
|
|
349
360
|
height: height,
|
|
350
|
-
containerWidth:
|
|
351
|
-
lineLength: this.
|
|
352
|
-
pctWidth:
|
|
361
|
+
containerWidth: containerWidth,
|
|
362
|
+
lineLength: this.getLineLength(view, getPos()) || lineLength,
|
|
363
|
+
pctWidth: mediaSingleWidthAttribute,
|
|
353
364
|
fullWidthMode: fullWidthMode,
|
|
354
|
-
hasFallbackContainer: false
|
|
365
|
+
hasFallbackContainer: false,
|
|
366
|
+
mediaSingleWidth: mediaSingleWidthAttribute && getMediaSinglePixelWidth(mediaSingleWidthAttribute, lineLength, widthType)
|
|
355
367
|
};
|
|
368
|
+
var ResizableMediaSingleProps = _objectSpread({
|
|
369
|
+
view: view,
|
|
370
|
+
getPos: getPos,
|
|
371
|
+
updateSize: this.updateSize,
|
|
372
|
+
gridSize: 12,
|
|
373
|
+
viewMediaClientConfig: this.state.viewMediaClientConfig,
|
|
374
|
+
allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
|
|
375
|
+
selected: isSelected,
|
|
376
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
377
|
+
pluginInjectionApi: pluginInjectionApi
|
|
378
|
+
}, mediaSingleProps);
|
|
356
379
|
var canResize = !!this.props.mediaOptions.allowResizing;
|
|
357
380
|
if (!this.props.mediaOptions.allowResizingInTables) {
|
|
358
381
|
// If resizing not allowed in tables, check parents for tables
|
|
@@ -364,12 +387,10 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
364
387
|
canResize = canResize && !disabledNode;
|
|
365
388
|
}
|
|
366
389
|
}
|
|
367
|
-
var lineLength = this.getLineLength(view, getPos()) || this.props.lineLength;
|
|
368
|
-
var isSelected = selected();
|
|
369
390
|
var shouldShowPlaceholder = getMediaFeatureFlag('captions', mediaOptions.featureFlags) && node.childCount !== 2 && isSelected && state.selection instanceof NodeSelection;
|
|
370
391
|
var MediaChildren = jsx("figure", {
|
|
371
392
|
ref: this.mediaSingleWrapperRef,
|
|
372
|
-
css: figureWrapper,
|
|
393
|
+
css: [figureWrapper],
|
|
373
394
|
className: MediaSingleNodeSelector,
|
|
374
395
|
onClick: this.onMediaSingleClicked
|
|
375
396
|
}, jsx("div", {
|
|
@@ -378,18 +399,7 @@ var MediaSingleNode = /*#__PURE__*/function (_Component) {
|
|
|
378
399
|
ref: this.captionPlaceHolderRef,
|
|
379
400
|
onClick: this.clickPlaceholder
|
|
380
401
|
}));
|
|
381
|
-
return canResize ? jsx(ResizableMediaSingle,
|
|
382
|
-
lineLength: lineLength,
|
|
383
|
-
view: this.props.view,
|
|
384
|
-
getPos: getPos,
|
|
385
|
-
updateSize: this.updateSize,
|
|
386
|
-
gridSize: 12,
|
|
387
|
-
viewMediaClientConfig: this.state.viewMediaClientConfig,
|
|
388
|
-
allowBreakoutSnapPoints: mediaOptions && mediaOptions.allowBreakoutSnapPoints,
|
|
389
|
-
selected: isSelected,
|
|
390
|
-
dispatchAnalyticsEvent: this.props.dispatchAnalyticsEvent,
|
|
391
|
-
pluginInjectionApi: this.props.pluginInjectionApi
|
|
392
|
-
}), MediaChildren) : jsx(MediaSingle, mediaSingleProps, MediaChildren);
|
|
402
|
+
return canResize ? getBooleanFF('platform.editor.media.extended-resize-experience') ? jsx(ResizableMediaSingleNext, ResizableMediaSingleProps, MediaChildren) : jsx(ResizableMediaSingle, ResizableMediaSingleProps, MediaChildren) : jsx(MediaSingle, mediaSingleProps, MediaChildren);
|
|
393
403
|
}
|
|
394
404
|
}]);
|
|
395
405
|
return MediaSingleNode;
|
|
@@ -20,8 +20,9 @@ import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
|
20
20
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
21
21
|
import { messages } from '@atlaskit/media-ui';
|
|
22
22
|
import { cardMessages } from '@atlaskit/editor-common/messages';
|
|
23
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
23
24
|
import { FilePreviewItem } from './filePreviewItem';
|
|
24
|
-
import { downloadMedia, removeMediaGroupNode } from './utils';
|
|
25
|
+
import { downloadMedia, getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
25
26
|
import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
26
27
|
import { MediaInlineNodeSelector, MediaSingleNodeSelector } from '../nodeviews/styles';
|
|
27
28
|
import ImageBorderItem from '../ui/ImageBorder';
|
|
@@ -225,7 +226,20 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
225
226
|
}
|
|
226
227
|
if (allowAdvancedToolBarOptions) {
|
|
227
228
|
var _pluginInjectionApi$d;
|
|
228
|
-
var
|
|
229
|
+
var widthPlugin = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.width;
|
|
230
|
+
var isChangingLayoutDisabled = false;
|
|
231
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
232
|
+
var _widthPlugin$sharedSt;
|
|
233
|
+
var contentWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength;
|
|
234
|
+
var selectedNode = getSelectedMediaSingle(state);
|
|
235
|
+
if (selectedNode && contentWidth) {
|
|
236
|
+
var width = selectedNode.node.attrs.width;
|
|
237
|
+
if (width >= contentWidth) {
|
|
238
|
+
isChangingLayoutDisabled = true;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
var layoutButtons = buildLayoutButtons(state, intl, state.schema.nodes.mediaSingle, widthPlugin, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions, allowResizing, allowResizingInTables, true, true, isChangingLayoutDisabled);
|
|
229
243
|
toolbarButtons = [].concat(_toConsumableArray(toolbarButtons), _toConsumableArray(layoutButtons));
|
|
230
244
|
if (layoutButtons.length) {
|
|
231
245
|
toolbarButtons.push({
|
|
@@ -327,7 +341,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
327
341
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
328
342
|
var _ref2 = (_pluginInjectionApi$d4 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d4 !== void 0 ? _pluginInjectionApi$d4 : {},
|
|
329
343
|
hoverDecoration = _ref2.hoverDecoration;
|
|
330
|
-
if (!mediaPluginState) {
|
|
344
|
+
if (!mediaPluginState || mediaPluginState.isResizing) {
|
|
331
345
|
return;
|
|
332
346
|
}
|
|
333
347
|
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
3
3
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
4
|
-
import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
+
import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode, findSelectedNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
5
|
export var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
6
6
|
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
7
7
|
if (selectedNode && selectedNode.attrs) {
|
|
@@ -58,4 +58,8 @@ export var removeMediaGroupNode = function removeMediaGroupNode(state) {
|
|
|
58
58
|
tr = removeSelectedNode(tr);
|
|
59
59
|
}
|
|
60
60
|
return tr;
|
|
61
|
+
};
|
|
62
|
+
export var getSelectedMediaSingle = function getSelectedMediaSingle(state) {
|
|
63
|
+
var mediaSingle = state.schema.nodes.mediaSingle;
|
|
64
|
+
return findSelectedNodeOfType(mediaSingle)(state.selection) || findParentNodeOfType(mediaSingle)(state.selection);
|
|
61
65
|
};
|