@atlaskit/editor-plugin-media 0.5.0 → 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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#59047](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/59047) [`a792bec68ae3`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a792bec68ae3) - [ED-21288] Populate width and height ADF attributes on insertion for mediaInline node of image type.
|
|
8
|
+
|
|
3
9
|
## 0.5.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -5,10 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.insertMediaInlineNode = exports.insertMediaGroupNode = exports.getPosInList = exports.canInsertMediaInline = void 0;
|
|
7
7
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
8
|
+
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
8
9
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
9
10
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
10
11
|
var _model = require("@atlaskit/editor-prosemirror/model");
|
|
11
12
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
14
|
+
var _isType = require("./is-type");
|
|
12
15
|
var _mediaCommon = require("./media-common");
|
|
13
16
|
var canInsertMediaInline = exports.canInsertMediaInline = function canInsertMediaInline(state) {
|
|
14
17
|
var node = state.schema.nodes.mediaInline.create({});
|
|
@@ -88,11 +91,29 @@ var insertMediaInlineNode = exports.insertMediaInlineNode = function insertMedia
|
|
|
88
91
|
if (!mediaInline || !mediaState || collection === undefined) {
|
|
89
92
|
return false;
|
|
90
93
|
}
|
|
91
|
-
var id = mediaState.id
|
|
92
|
-
|
|
94
|
+
var id = mediaState.id,
|
|
95
|
+
dimensions = mediaState.dimensions,
|
|
96
|
+
_mediaState$scaleFact = mediaState.scaleFactor,
|
|
97
|
+
scaleFactor = _mediaState$scaleFact === void 0 ? 1 : _mediaState$scaleFact;
|
|
98
|
+
var mediaInlineAttrs = {
|
|
93
99
|
id: id,
|
|
94
100
|
collection: collection
|
|
95
|
-
}
|
|
101
|
+
};
|
|
102
|
+
if (
|
|
103
|
+
// TODO: replace it with new shouldShowInlineImage
|
|
104
|
+
(0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support') && (0, _isType.isImage)(mediaState.fileMimeType)) {
|
|
105
|
+
var _ref = dimensions || {
|
|
106
|
+
width: undefined,
|
|
107
|
+
height: undefined
|
|
108
|
+
},
|
|
109
|
+
width = _ref.width,
|
|
110
|
+
height = _ref.height;
|
|
111
|
+
var scaledWidth = width ? Math.round(width / scaleFactor) : _mediaInline.DEFAULT_IMAGE_WIDTH;
|
|
112
|
+
var scaledHeight = height ? Math.round(height / scaleFactor) : _mediaInline.DEFAULT_IMAGE_HEIGHT;
|
|
113
|
+
mediaInlineAttrs.width = scaledWidth;
|
|
114
|
+
mediaInlineAttrs.height = scaledHeight;
|
|
115
|
+
}
|
|
116
|
+
var mediaInlineNode = mediaInline.create(mediaInlineAttrs);
|
|
96
117
|
var space = state.schema.text(' ');
|
|
97
118
|
var pos = state.selection.$to.pos;
|
|
98
119
|
|
|
@@ -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 const canInsertMediaInline = state => {
|
|
8
11
|
const node = state.schema.nodes.mediaInline.create({});
|
|
@@ -96,12 +99,30 @@ export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, co
|
|
|
96
99
|
return false;
|
|
97
100
|
}
|
|
98
101
|
const {
|
|
99
|
-
id
|
|
102
|
+
id,
|
|
103
|
+
dimensions,
|
|
104
|
+
scaleFactor = 1
|
|
100
105
|
} = mediaState;
|
|
101
|
-
|
|
106
|
+
let mediaInlineAttrs = {
|
|
102
107
|
id,
|
|
103
108
|
collection
|
|
104
|
-
}
|
|
109
|
+
};
|
|
110
|
+
if (
|
|
111
|
+
// TODO: replace it with new shouldShowInlineImage
|
|
112
|
+
getBooleanFF('platform.editor.media.inline-image.base-support') && isImage(mediaState.fileMimeType)) {
|
|
113
|
+
const {
|
|
114
|
+
width,
|
|
115
|
+
height
|
|
116
|
+
} = dimensions || {
|
|
117
|
+
width: undefined,
|
|
118
|
+
height: undefined
|
|
119
|
+
};
|
|
120
|
+
const scaledWidth = width ? Math.round(width / scaleFactor) : DEFAULT_IMAGE_WIDTH;
|
|
121
|
+
const scaledHeight = height ? Math.round(height / scaleFactor) : DEFAULT_IMAGE_HEIGHT;
|
|
122
|
+
mediaInlineAttrs.width = scaledWidth;
|
|
123
|
+
mediaInlineAttrs.height = scaledHeight;
|
|
124
|
+
}
|
|
125
|
+
const mediaInlineNode = mediaInline.create(mediaInlineAttrs);
|
|
105
126
|
const space = state.schema.text(' ');
|
|
106
127
|
let pos = state.selection.$to.pos;
|
|
107
128
|
|
|
@@ -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
|
|