@atlaskit/editor-plugin-media 0.4.10 → 0.5.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 +17 -0
- package/dist/cjs/nodeviews/mediaInline.js +17 -1
- package/dist/cjs/nodeviews/mediaSingle.js +11 -10
- package/dist/cjs/nodeviews/styles.js +5 -4
- package/dist/cjs/pm-plugins/alt-text/ui/AltTextEdit.js +15 -14
- package/dist/cjs/toolbar/index.js +28 -1
- package/dist/cjs/toolbar/layout-group.js +7 -5
- package/dist/cjs/toolbar/linking-toolbar-appearance.js +12 -11
- package/dist/cjs/ui/CaptionPlaceholder/index.js +3 -2
- package/dist/cjs/ui/ImageBorder/index.js +23 -20
- package/dist/cjs/ui/Media/DropPlaceholder.js +5 -4
- package/dist/cjs/ui/MediaLinkingToolbar.js +15 -13
- package/dist/cjs/ui/PixelEntry/index.js +18 -15
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +4 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +5 -4
- package/dist/cjs/ui/ResizableMediaSingle/index.js +5 -4
- package/dist/cjs/utils/media-files.js +24 -3
- package/dist/cjs/utils/media-single.js +6 -3
- package/dist/es2019/nodeviews/mediaInline.js +17 -1
- package/dist/es2019/nodeviews/mediaSingle.js +12 -9
- package/dist/es2019/nodeviews/styles.js +6 -5
- package/dist/es2019/pm-plugins/alt-text/ui/AltTextEdit.js +17 -15
- package/dist/es2019/toolbar/index.js +26 -1
- package/dist/es2019/toolbar/layout-group.js +7 -6
- package/dist/es2019/toolbar/linking-toolbar-appearance.js +13 -12
- package/dist/es2019/ui/CaptionPlaceholder/index.js +4 -3
- package/dist/es2019/ui/ImageBorder/index.js +22 -20
- package/dist/es2019/ui/Media/DropPlaceholder.js +6 -5
- package/dist/es2019/ui/MediaLinkingToolbar.js +14 -13
- package/dist/es2019/ui/PixelEntry/index.js +17 -15
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +3 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +5 -3
- package/dist/es2019/ui/ResizableMediaSingle/index.js +5 -3
- package/dist/es2019/utils/media-files.js +24 -3
- package/dist/es2019/utils/media-single.js +6 -2
- package/dist/esm/nodeviews/mediaInline.js +17 -1
- package/dist/esm/nodeviews/mediaSingle.js +12 -9
- package/dist/esm/nodeviews/styles.js +6 -5
- package/dist/esm/pm-plugins/alt-text/ui/AltTextEdit.js +17 -15
- package/dist/esm/toolbar/index.js +28 -1
- package/dist/esm/toolbar/layout-group.js +7 -6
- package/dist/esm/toolbar/linking-toolbar-appearance.js +13 -12
- package/dist/esm/ui/CaptionPlaceholder/index.js +4 -3
- package/dist/esm/ui/ImageBorder/index.js +22 -20
- package/dist/esm/ui/Media/DropPlaceholder.js +6 -5
- package/dist/esm/ui/MediaLinkingToolbar.js +14 -13
- package/dist/esm/ui/PixelEntry/index.js +17 -15
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaMigrationNotification.js +3 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +5 -3
- package/dist/esm/ui/ResizableMediaSingle/index.js +5 -3
- package/dist/esm/utils/media-files.js +24 -3
- package/dist/esm/utils/media-single.js +6 -3
- package/package.json +4 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
/** @jsx jsx */
|
|
3
4
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
4
6
|
import Button from '@atlaskit/button';
|
|
5
7
|
import Form, { Field } from '@atlaskit/form';
|
|
6
8
|
import Textfield from '@atlaskit/textfield';
|
|
@@ -99,36 +101,36 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
99
101
|
};
|
|
100
102
|
}, [minWidth, maxWidth, onChange, ratioWidth, ratioHeight]);
|
|
101
103
|
if (showMigration) {
|
|
102
|
-
return
|
|
104
|
+
return jsx(Tooltip, {
|
|
103
105
|
content: formatMessage(messages.migrationButtonTooltip)
|
|
104
|
-
},
|
|
106
|
+
}, jsx(Button, {
|
|
105
107
|
appearance: "warning",
|
|
106
108
|
spacing: "compact",
|
|
107
109
|
onClick: onMigrate,
|
|
108
110
|
testId: PIXELENTRY_MIGRATION_BUTTON_TESTID
|
|
109
111
|
}, formatMessage(messages.migrationButtonText)));
|
|
110
112
|
}
|
|
111
|
-
return
|
|
113
|
+
return jsx("div", {
|
|
112
114
|
css: pixelEntryForm
|
|
113
|
-
},
|
|
115
|
+
}, jsx(Form, {
|
|
114
116
|
onSubmit: handleOnSubmit
|
|
115
117
|
}, function (_ref2) {
|
|
116
118
|
var formProps = _ref2.formProps;
|
|
117
|
-
return
|
|
119
|
+
return jsx("form", formProps, jsx("div", {
|
|
118
120
|
css: pixelSizingWrapper
|
|
119
|
-
},
|
|
121
|
+
}, jsx(Field, {
|
|
120
122
|
key: "inputWidth",
|
|
121
123
|
name: "inputWidth",
|
|
122
124
|
defaultValue: computedWidth
|
|
123
125
|
}, function (_ref3) {
|
|
124
126
|
var fieldProps = _ref3.fieldProps;
|
|
125
|
-
return
|
|
127
|
+
return jsx(Tooltip, {
|
|
126
128
|
hideTooltipOnMouseDown: true,
|
|
127
129
|
content: formatMessage(messages.inputWidthTooltip, {
|
|
128
130
|
maxWidth: maxWidth
|
|
129
131
|
}),
|
|
130
132
|
position: "top"
|
|
131
|
-
},
|
|
133
|
+
}, jsx(Textfield, _extends({}, fieldProps, {
|
|
132
134
|
css: [pixelSizingWidthInput, pixelSizingInput],
|
|
133
135
|
appearance: "none",
|
|
134
136
|
isCompact: true,
|
|
@@ -138,19 +140,19 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
138
140
|
maxWidth: maxWidth
|
|
139
141
|
})
|
|
140
142
|
})));
|
|
141
|
-
}),
|
|
143
|
+
}), jsx("span", {
|
|
142
144
|
css: pixelSizingLabel
|
|
143
|
-
}, "x"),
|
|
145
|
+
}, "x"), jsx(Field, {
|
|
144
146
|
key: "inputHeight",
|
|
145
147
|
name: "inputHeight",
|
|
146
148
|
defaultValue: computedHeight
|
|
147
149
|
}, function (_ref4) {
|
|
148
150
|
var fieldProps = _ref4.fieldProps;
|
|
149
|
-
return
|
|
151
|
+
return jsx(Tooltip, {
|
|
150
152
|
hideTooltipOnMouseDown: true,
|
|
151
153
|
content: formatMessage(messages.inputHeightTooltip),
|
|
152
154
|
position: "top"
|
|
153
|
-
},
|
|
155
|
+
}, jsx(Textfield, _extends({}, fieldProps, {
|
|
154
156
|
css: [pixelSizingHeightInput, pixelSizingInput],
|
|
155
157
|
appearance: "none",
|
|
156
158
|
isCompact: true,
|
|
@@ -158,7 +160,7 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
158
160
|
pattern: "\\d*",
|
|
159
161
|
"aria-label": formatMessage(messages.inputHeightAriaLabel)
|
|
160
162
|
})));
|
|
161
|
-
}),
|
|
163
|
+
}), jsx(Button, {
|
|
162
164
|
css: pixelEntryHiddenSubmit,
|
|
163
165
|
type: "submit"
|
|
164
166
|
}, formatMessage(messages.submitButtonText))));
|
|
@@ -166,7 +168,7 @@ export var PixelEntry = function PixelEntry(_ref) {
|
|
|
166
168
|
};
|
|
167
169
|
export var FullWidthDisplay = function FullWidthDisplay(_ref5) {
|
|
168
170
|
var formatMessage = _ref5.intl.formatMessage;
|
|
169
|
-
return
|
|
171
|
+
return jsx("div", {
|
|
170
172
|
css: pixelSizingFullWidthLabelStyles
|
|
171
|
-
},
|
|
173
|
+
}, jsx("span", null, formatMessage(messages.fullWidthLabel)));
|
|
172
174
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx } from '@emotion/react';
|
|
1
3
|
import { resizableMediaMigrationNotificationStyle } from './styles';
|
|
2
4
|
export var ResizableMediaMigrationNotification = function ResizableMediaMigrationNotification() {
|
|
3
|
-
return
|
|
5
|
+
return jsx("div", {
|
|
4
6
|
"data-testid": "resizable-media-migration-notification",
|
|
5
7
|
css: [resizableMediaMigrationNotificationStyle]
|
|
6
8
|
});
|
|
@@ -10,7 +10,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
10
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
/** @jsx jsx */
|
|
13
14
|
import React from 'react';
|
|
15
|
+
import { jsx } from '@emotion/react';
|
|
14
16
|
import classnames from 'classnames';
|
|
15
17
|
import throttle from 'lodash/throttle';
|
|
16
18
|
import memoizeOne from 'memoize-one';
|
|
@@ -499,7 +501,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
499
501
|
|
|
500
502
|
// while is not resizing, we take 100% as min-width if the container width is less than the min-width
|
|
501
503
|
var minViewWidth = isResizing ? minWidth : "min(".concat(minWidth, "px, 100%)");
|
|
502
|
-
return
|
|
504
|
+
return jsx("div", {
|
|
503
505
|
css: wrapperStyle({
|
|
504
506
|
layout: layout,
|
|
505
507
|
containerWidth: containerWidth || origWidth,
|
|
@@ -508,7 +510,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
508
510
|
isNestedNode: isNestedNode,
|
|
509
511
|
isExtendedResizeExperienceOn: true
|
|
510
512
|
})
|
|
511
|
-
},
|
|
513
|
+
}, jsx(ResizerNext, {
|
|
512
514
|
minWidth: minViewWidth,
|
|
513
515
|
maxWidth: maxWidth,
|
|
514
516
|
className: resizerNextClassName,
|
|
@@ -524,7 +526,7 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
524
526
|
isHandleVisible: selected,
|
|
525
527
|
handlePositioning: isNestedNode ? 'adjacent' : undefined,
|
|
526
528
|
handleHighlight: "full-height"
|
|
527
|
-
}, children, showLegacyNotification &&
|
|
529
|
+
}, children, showLegacyNotification && jsx(ResizableMediaMigrationNotification, null)));
|
|
528
530
|
}
|
|
529
531
|
}]);
|
|
530
532
|
return ResizableMediaSingleNext;
|
|
@@ -10,7 +10,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
10
10
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
11
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
12
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
/** @jsx jsx */
|
|
13
14
|
import React from 'react';
|
|
15
|
+
import { jsx } from '@emotion/react';
|
|
14
16
|
import { calculateOffsetLeft } from '@atlaskit/editor-common/media-single';
|
|
15
17
|
import { calcColumnsFromPx, calcMediaPxWidth, calcPctFromPx, handleSides, imageAlignmentMap, Resizer, snapTo, wrappedLayouts } from '@atlaskit/editor-common/ui';
|
|
16
18
|
import { calculateSnapPoints } from '@atlaskit/editor-common/utils';
|
|
@@ -377,7 +379,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
|
|
|
377
379
|
}
|
|
378
380
|
};
|
|
379
381
|
};
|
|
380
|
-
return
|
|
382
|
+
return jsx("div", {
|
|
381
383
|
ref: this.saveWrapper,
|
|
382
384
|
css: wrapperStyle({
|
|
383
385
|
layout: layout,
|
|
@@ -385,7 +387,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
|
|
|
385
387
|
containerWidth: containerWidth || origWidth,
|
|
386
388
|
fullWidthMode: fullWidthMode
|
|
387
389
|
})
|
|
388
|
-
},
|
|
390
|
+
}, jsx(Resizer, _extends({}, this.props, {
|
|
389
391
|
displayGrid: this.displayGrid,
|
|
390
392
|
ratio: ratio,
|
|
391
393
|
width: initialWidth,
|
|
@@ -402,7 +404,7 @@ var ResizableMediaSingle = /*#__PURE__*/function (_React$Component) {
|
|
|
402
404
|
// This workaround adds an empty div inside the resize handler to prevent the issue.
|
|
403
405
|
,
|
|
404
406
|
handleComponentFunc: function handleComponentFunc() {
|
|
405
|
-
return
|
|
407
|
+
return jsx("div", {
|
|
406
408
|
contentEditable: false
|
|
407
409
|
});
|
|
408
410
|
},
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-inline';
|
|
2
3
|
import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { findFarthestParentNode, insideTableCell, isInLayoutColumn, isInListItem, isSupportedInParent, setNodeSelection, setTextSelection } from '@atlaskit/editor-common/utils';
|
|
4
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
5
6
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
|
+
import { isImage } from './is-type';
|
|
6
9
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
7
10
|
export var canInsertMediaInline = function canInsertMediaInline(state) {
|
|
8
11
|
var node = state.schema.nodes.mediaInline.create({});
|
|
@@ -82,11 +85,29 @@ export var insertMediaInlineNode = function insertMediaInlineNode(editorAnalytic
|
|
|
82
85
|
if (!mediaInline || !mediaState || collection === undefined) {
|
|
83
86
|
return false;
|
|
84
87
|
}
|
|
85
|
-
var id = mediaState.id
|
|
86
|
-
|
|
88
|
+
var id = mediaState.id,
|
|
89
|
+
dimensions = mediaState.dimensions,
|
|
90
|
+
_mediaState$scaleFact = mediaState.scaleFactor,
|
|
91
|
+
scaleFactor = _mediaState$scaleFact === void 0 ? 1 : _mediaState$scaleFact;
|
|
92
|
+
var mediaInlineAttrs = {
|
|
87
93
|
id: id,
|
|
88
94
|
collection: collection
|
|
89
|
-
}
|
|
95
|
+
};
|
|
96
|
+
if (
|
|
97
|
+
// TODO: replace it with new shouldShowInlineImage
|
|
98
|
+
getBooleanFF('platform.editor.media.inline-image.base-support') && isImage(mediaState.fileMimeType)) {
|
|
99
|
+
var _ref = dimensions || {
|
|
100
|
+
width: undefined,
|
|
101
|
+
height: undefined
|
|
102
|
+
},
|
|
103
|
+
width = _ref.width,
|
|
104
|
+
height = _ref.height;
|
|
105
|
+
var scaledWidth = width ? Math.round(width / scaleFactor) : DEFAULT_IMAGE_WIDTH;
|
|
106
|
+
var scaledHeight = height ? Math.round(height / scaleFactor) : DEFAULT_IMAGE_HEIGHT;
|
|
107
|
+
mediaInlineAttrs.width = scaledWidth;
|
|
108
|
+
mediaInlineAttrs.height = scaledHeight;
|
|
109
|
+
}
|
|
110
|
+
var mediaInlineNode = mediaInline.create(mediaInlineAttrs);
|
|
90
111
|
var space = state.schema.text(' ');
|
|
91
112
|
var pos = state.selection.$to.pos;
|
|
92
113
|
|
|
@@ -129,7 +129,8 @@ export var createMediaSingleNode = function createMediaSingleNode(schema, collec
|
|
|
129
129
|
dimensions = mediaState.dimensions,
|
|
130
130
|
contextId = mediaState.contextId,
|
|
131
131
|
_mediaState$scaleFact = mediaState.scaleFactor,
|
|
132
|
-
scaleFactor = _mediaState$scaleFact === void 0 ? 1 : _mediaState$scaleFact
|
|
132
|
+
scaleFactor = _mediaState$scaleFact === void 0 ? 1 : _mediaState$scaleFact,
|
|
133
|
+
fileName = mediaState.fileName;
|
|
133
134
|
var _ref = dimensions || {
|
|
134
135
|
height: undefined,
|
|
135
136
|
width: undefined
|
|
@@ -140,14 +141,16 @@ export var createMediaSingleNode = function createMediaSingleNode(schema, collec
|
|
|
140
141
|
media = _schema$nodes.media,
|
|
141
142
|
mediaSingle = _schema$nodes.mediaSingle;
|
|
142
143
|
var scaledWidth = width && Math.round(width / scaleFactor);
|
|
143
|
-
var mediaNode = media.create({
|
|
144
|
+
var mediaNode = media.create(_objectSpread({
|
|
144
145
|
id: id,
|
|
145
146
|
type: 'file',
|
|
146
147
|
collection: collection,
|
|
147
148
|
contextId: contextId,
|
|
148
149
|
width: scaledWidth,
|
|
149
150
|
height: height && Math.round(height / scaleFactor)
|
|
150
|
-
})
|
|
151
|
+
}, getBooleanFF('platform.editor.a11y-media_er96o') && fileName && {
|
|
152
|
+
alt: fileName
|
|
153
|
+
}));
|
|
151
154
|
var mediaSingleAttrs = alignLeftOnInsert ? {
|
|
152
155
|
layout: 'align-start'
|
|
153
156
|
} : {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -140,6 +140,9 @@
|
|
|
140
140
|
"platform.media-experience.media-viewer-v2_hgsii": {
|
|
141
141
|
"type": "boolean",
|
|
142
142
|
"referenceOnly": "true"
|
|
143
|
+
},
|
|
144
|
+
"platform.editor.a11y-media_er96o": {
|
|
145
|
+
"type": "boolean"
|
|
143
146
|
}
|
|
144
147
|
},
|
|
145
148
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|