@atlaskit/editor-plugin-media 0.10.0 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/cjs/toolbar/commands.js +1 -0
- package/dist/cjs/utils/media-files.js +3 -2
- package/dist/cjs/utils/media-inline.js +6 -2
- package/dist/es2019/toolbar/commands.js +2 -1
- package/dist/es2019/utils/media-files.js +3 -2
- package/dist/es2019/utils/media-inline.js +6 -2
- package/dist/esm/toolbar/commands.js +2 -1
- package/dist/esm/utils/media-files.js +3 -2
- package/dist/esm/utils/media-inline.js +6 -2
- package/dist/types/utils/media-inline.d.ts +1 -0
- package/dist/types-ts4.5/utils/media-inline.d.ts +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.10.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#65194](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65194) [`b17492206adc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b17492206adc) - ED-21544 able to insert inline image in panel with empty paragraph.
|
|
8
|
+
|
|
9
|
+
## 0.10.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#65562](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/65562) [`857a5d841564`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/857a5d841564) - add analytics to track media single to media inline convert
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 0.10.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -276,6 +276,7 @@ var changeMediaSingleToMediaInline = exports.changeMediaSingleToMediaInline = fu
|
|
|
276
276
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
277
277
|
tr.setSelection(_state.TextSelection.create(tr.doc, from + 3));
|
|
278
278
|
if (dispatch) {
|
|
279
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent((0, _analytics2.getChangeMediaAnalytics)(_analytics.ACTION_SUBJECT_ID.MEDIA_SINGLE, _analytics.ACTION_SUBJECT_ID.MEDIA_INLINE, (0, _analytics2.findChangeFromLocation)(state.selection)))(tr);
|
|
279
280
|
dispatch(tr);
|
|
280
281
|
}
|
|
281
282
|
return true;
|
|
@@ -12,6 +12,7 @@ var _model = require("@atlaskit/editor-prosemirror/model");
|
|
|
12
12
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
13
13
|
var _isType = require("./is-type");
|
|
14
14
|
var _mediaCommon = require("./media-common");
|
|
15
|
+
var _mediaInline2 = require("./media-inline");
|
|
15
16
|
var canInsertMediaInline = exports.canInsertMediaInline = function canInsertMediaInline(state) {
|
|
16
17
|
var node = state.schema.nodes.mediaInline.create({});
|
|
17
18
|
return (0, _utils2.canInsert)(state.selection.$to, _model.Fragment.from(node));
|
|
@@ -116,8 +117,8 @@ var insertMediaInlineNode = exports.insertMediaInlineNode = function insertMedia
|
|
|
116
117
|
var space = state.schema.text(' ');
|
|
117
118
|
var pos = state.selection.$to.pos;
|
|
118
119
|
|
|
119
|
-
// If the selection is inside an empty list item set pos inside paragraph
|
|
120
|
-
if ((0,
|
|
120
|
+
// If the selection is inside an empty list item or panel set pos inside paragraph
|
|
121
|
+
if ((0, _mediaInline2.isInSupportedInlineImageParent)(state) && (0, _mediaCommon.isInsidePotentialEmptyParagraph)(state)) {
|
|
121
122
|
pos = pos + 1;
|
|
122
123
|
}
|
|
123
124
|
var content = _model.Fragment.from([mediaInlineNode, space]);
|
|
@@ -3,16 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getMediaNodeInsertionType = void 0;
|
|
6
|
+
exports.isInSupportedInlineImageParent = exports.getMediaNodeInsertionType = void 0;
|
|
7
7
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
8
|
+
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
8
9
|
var _mediaCommon = require("@atlaskit/media-common");
|
|
9
10
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
10
11
|
var _mediaFiles = require("../utils/media-files");
|
|
11
12
|
var _mediaSingle = require("../utils/media-single");
|
|
12
13
|
var _isType = require("./is-type");
|
|
13
14
|
var _mediaCommon2 = require("./media-common");
|
|
15
|
+
var isInSupportedInlineImageParent = exports.isInSupportedInlineImageParent = function isInSupportedInlineImageParent(state) {
|
|
16
|
+
return (0, _utils2.hasParentNodeOfType)([state.schema.nodes.listItem, state.schema.nodes.panel])(state.selection);
|
|
17
|
+
};
|
|
14
18
|
var getMediaNodeInsertionType = exports.getMediaNodeInsertionType = function getMediaNodeInsertionType(state, mediaFeatureFlags, fileMimeType) {
|
|
15
|
-
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || (
|
|
19
|
+
var canInsertInlineNode = (0, _mediaCommon.getMediaFeatureFlag)('mediaInline', mediaFeatureFlags) && !(0, _utils.isInEmptyLine)(state) && (!(0, _mediaCommon2.isInsidePotentialEmptyParagraph)(state) || isInSupportedInlineImageParent(state)) && (0, _mediaFiles.canInsertMediaInline)(state);
|
|
16
20
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.inline-image.base-support')) {
|
|
17
21
|
if (canInsertInlineNode && !(0, _isType.isVideo)(fileMimeType)) {
|
|
18
22
|
return 'inline';
|
|
@@ -2,7 +2,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
2
2
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
5
|
+
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
6
6
|
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
7
7
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
8
8
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
@@ -255,6 +255,7 @@ export const changeMediaSingleToMediaInline = editorAnalyticsAPI => (state, disp
|
|
|
255
255
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
256
256
|
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
257
257
|
if (dispatch) {
|
|
258
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(ACTION_SUBJECT_ID.MEDIA_SINGLE, ACTION_SUBJECT_ID.MEDIA_INLINE, findChangeFromLocation(state.selection)))(tr);
|
|
258
259
|
dispatch(tr);
|
|
259
260
|
}
|
|
260
261
|
return true;
|
|
@@ -6,6 +6,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
6
6
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { isImage } from './is-type';
|
|
8
8
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
9
|
+
import { isInSupportedInlineImageParent } from './media-inline';
|
|
9
10
|
export const canInsertMediaInline = state => {
|
|
10
11
|
const node = state.schema.nodes.mediaInline.create({});
|
|
11
12
|
return canInsert(state.selection.$to, Fragment.from(node));
|
|
@@ -125,8 +126,8 @@ export const insertMediaInlineNode = editorAnalyticsAPI => (view, mediaState, co
|
|
|
125
126
|
const space = state.schema.text(' ');
|
|
126
127
|
let pos = state.selection.$to.pos;
|
|
127
128
|
|
|
128
|
-
// If the selection is inside an empty list item set pos inside paragraph
|
|
129
|
-
if (
|
|
129
|
+
// If the selection is inside an empty list item or panel set pos inside paragraph
|
|
130
|
+
if (isInSupportedInlineImageParent(state) && isInsidePotentialEmptyParagraph(state)) {
|
|
130
131
|
pos = pos + 1;
|
|
131
132
|
}
|
|
132
133
|
let content = Fragment.from([mediaInlineNode, space]);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { isInEmptyLine
|
|
1
|
+
import { isInEmptyLine } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
3
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
3
4
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { canInsertMediaInline } from '../utils/media-files';
|
|
5
6
|
import { isMediaSingle } from '../utils/media-single';
|
|
6
7
|
import { isVideo } from './is-type';
|
|
7
8
|
import { isInsidePotentialEmptyParagraph } from './media-common';
|
|
9
|
+
export const isInSupportedInlineImageParent = state => {
|
|
10
|
+
return hasParentNodeOfType([state.schema.nodes.listItem, state.schema.nodes.panel])(state.selection);
|
|
11
|
+
};
|
|
8
12
|
export const getMediaNodeInsertionType = (state, mediaFeatureFlags, fileMimeType) => {
|
|
9
|
-
const canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) ||
|
|
13
|
+
const canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
10
14
|
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
11
15
|
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
12
16
|
return 'inline';
|
|
@@ -5,7 +5,7 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
5
5
|
import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
6
6
|
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { isNodeSelection, removeSelectedNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
8
|
-
import { getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
8
|
+
import { findChangeFromLocation, getChangeMediaAnalytics, getMediaInputResizeAnalyticsEvent } from '../utils/analytics';
|
|
9
9
|
import { currentMediaInlineNodeWithPos, currentMediaNodeWithPos } from '../utils/current-media-node';
|
|
10
10
|
import { changeFromMediaInlineToMediaSingleNode } from '../utils/media-single';
|
|
11
11
|
import { getSelectedMediaSingle, removeMediaGroupNode } from './utils';
|
|
@@ -269,6 +269,7 @@ export var changeMediaSingleToMediaInline = function changeMediaSingleToMediaInl
|
|
|
269
269
|
// 3 accounts for paragraph 1 + mediaInline size 1 + space 1
|
|
270
270
|
tr.setSelection(TextSelection.create(tr.doc, from + 3));
|
|
271
271
|
if (dispatch) {
|
|
272
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 || editorAnalyticsAPI.attachAnalyticsEvent(getChangeMediaAnalytics(ACTION_SUBJECT_ID.MEDIA_SINGLE, ACTION_SUBJECT_ID.MEDIA_INLINE, findChangeFromLocation(state.selection)))(tr);
|
|
272
273
|
dispatch(tr);
|
|
273
274
|
}
|
|
274
275
|
return true;
|
|
@@ -6,6 +6,7 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
6
6
|
import { canInsert, hasParentNode, safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
7
7
|
import { isImage } from './is-type';
|
|
8
8
|
import { copyOptionalAttrsFromMediaState, isInsidePotentialEmptyParagraph, isSelectionNonMediaBlockNode, posOfMediaGroupNearby, posOfParentMediaGroup, posOfPrecedingMediaGroup } from './media-common';
|
|
9
|
+
import { isInSupportedInlineImageParent } from './media-inline';
|
|
9
10
|
export var canInsertMediaInline = function canInsertMediaInline(state) {
|
|
10
11
|
var node = state.schema.nodes.mediaInline.create({});
|
|
11
12
|
return canInsert(state.selection.$to, Fragment.from(node));
|
|
@@ -110,8 +111,8 @@ export var insertMediaInlineNode = function insertMediaInlineNode(editorAnalytic
|
|
|
110
111
|
var space = state.schema.text(' ');
|
|
111
112
|
var pos = state.selection.$to.pos;
|
|
112
113
|
|
|
113
|
-
// If the selection is inside an empty list item set pos inside paragraph
|
|
114
|
-
if (
|
|
114
|
+
// If the selection is inside an empty list item or panel set pos inside paragraph
|
|
115
|
+
if (isInSupportedInlineImageParent(state) && isInsidePotentialEmptyParagraph(state)) {
|
|
115
116
|
pos = pos + 1;
|
|
116
117
|
}
|
|
117
118
|
var content = Fragment.from([mediaInlineNode, space]);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import { isInEmptyLine
|
|
1
|
+
import { isInEmptyLine } from '@atlaskit/editor-common/utils';
|
|
2
|
+
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
2
3
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
3
4
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import { canInsertMediaInline } from '../utils/media-files';
|
|
5
6
|
import { isMediaSingle } from '../utils/media-single';
|
|
6
7
|
import { isVideo } from './is-type';
|
|
7
8
|
import { isInsidePotentialEmptyParagraph } from './media-common';
|
|
9
|
+
export var isInSupportedInlineImageParent = function isInSupportedInlineImageParent(state) {
|
|
10
|
+
return hasParentNodeOfType([state.schema.nodes.listItem, state.schema.nodes.panel])(state.selection);
|
|
11
|
+
};
|
|
8
12
|
export var getMediaNodeInsertionType = function getMediaNodeInsertionType(state, mediaFeatureFlags, fileMimeType) {
|
|
9
|
-
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) ||
|
|
13
|
+
var canInsertInlineNode = getMediaFeatureFlag('mediaInline', mediaFeatureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInSupportedInlineImageParent(state)) && canInsertMediaInline(state);
|
|
10
14
|
if (getBooleanFF('platform.editor.media.inline-image.base-support')) {
|
|
11
15
|
if (canInsertInlineNode && !isVideo(fileMimeType)) {
|
|
12
16
|
return 'inline';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
3
|
export type MediaNodeType = 'inline' | 'block' | 'group';
|
|
4
|
+
export declare const isInSupportedInlineImageParent: (state: EditorState) => boolean;
|
|
4
5
|
export declare const getMediaNodeInsertionType: (state: EditorState, mediaFeatureFlags?: MediaFeatureFlags, fileMimeType?: string) => MediaNodeType;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
import type { MediaFeatureFlags } from '@atlaskit/media-common';
|
|
3
3
|
export type MediaNodeType = 'inline' | 'block' | 'group';
|
|
4
|
+
export declare const isInSupportedInlineImageParent: (state: EditorState) => boolean;
|
|
4
5
|
export declare const getMediaNodeInsertionType: (state: EditorState, mediaFeatureFlags?: MediaFeatureFlags, fileMimeType?: string) => MediaNodeType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@atlaskit/adf-schema": "^35.3.0",
|
|
37
|
-
"@atlaskit/analytics-namespaced-context": "^6.
|
|
37
|
+
"@atlaskit/analytics-namespaced-context": "^6.8.0",
|
|
38
38
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
39
39
|
"@atlaskit/button": "^17.2.0",
|
|
40
40
|
"@atlaskit/editor-common": "^76.35.0",
|