@atlaskit/editor-plugin-media 0.5.1 → 0.6.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 +6 -0
- package/dist/cjs/plugin.js +20 -19
- package/dist/cjs/pm-plugins/keymap.js +108 -1
- package/dist/cjs/pm-plugins/mediaResizeAnnouncerMess.js +34 -0
- package/dist/cjs/toolbar/commands.js +2 -1
- package/dist/cjs/toolbar/index.js +1 -1
- package/dist/cjs/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/cjs/utils/analytics.js +8 -4
- package/dist/es2019/plugin.js +4 -2
- package/dist/es2019/pm-plugins/keymap.js +106 -2
- package/dist/es2019/pm-plugins/mediaResizeAnnouncerMess.js +28 -0
- package/dist/es2019/toolbar/commands.js +2 -1
- package/dist/es2019/toolbar/index.js +1 -1
- package/dist/es2019/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/es2019/utils/analytics.js +8 -4
- package/dist/esm/plugin.js +20 -19
- package/dist/esm/pm-plugins/keymap.js +109 -2
- package/dist/esm/pm-plugins/mediaResizeAnnouncerMess.js +28 -0
- package/dist/esm/toolbar/commands.js +2 -1
- package/dist/esm/toolbar/index.js +1 -1
- package/dist/esm/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +2 -1
- package/dist/esm/utils/analytics.js +8 -4
- package/dist/types/pm-plugins/keymap.d.ts +5 -1
- package/dist/types/pm-plugins/mediaResizeAnnouncerMess.d.ts +27 -0
- package/dist/types/pm-plugins/types.d.ts +1 -0
- package/dist/types/toolbar/commands.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +5 -1
- package/dist/types-ts4.5/pm-plugins/mediaResizeAnnouncerMess.d.ts +27 -0
- package/dist/types-ts4.5/pm-plugins/types.d.ts +1 -0
- package/dist/types-ts4.5/toolbar/commands.d.ts +2 -1
- package/package.json +5 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-media
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#56827](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/56827) [`9966463429c6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9966463429c6) - ECA11Y-86: Added ability to resize media via keyboard and added announcer
|
|
8
|
+
|
|
3
9
|
## 0.5.1
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -145,16 +145,17 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
145
145
|
}
|
|
146
146
|
}, {
|
|
147
147
|
name: 'mediaKeymap',
|
|
148
|
-
plugin: function plugin() {
|
|
148
|
+
plugin: function plugin(_ref5) {
|
|
149
149
|
var _api$analytics2;
|
|
150
|
-
|
|
150
|
+
var getIntl = _ref5.getIntl;
|
|
151
|
+
return (0, _keymap2.default)(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
|
|
151
152
|
}
|
|
152
153
|
}];
|
|
153
154
|
if (options && options.allowMediaSingle) {
|
|
154
155
|
pmPlugins.push({
|
|
155
156
|
name: 'mediaSingleKeymap',
|
|
156
|
-
plugin: function plugin(
|
|
157
|
-
var schema =
|
|
157
|
+
plugin: function plugin(_ref6) {
|
|
158
|
+
var schema = _ref6.schema;
|
|
158
159
|
return (0, _keymapMediaSingle.default)(schema);
|
|
159
160
|
}
|
|
160
161
|
});
|
|
@@ -166,9 +167,9 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
166
167
|
});
|
|
167
168
|
pmPlugins.push({
|
|
168
169
|
name: 'mediaAltTextKeymap',
|
|
169
|
-
plugin: function plugin(
|
|
170
|
+
plugin: function plugin(_ref7) {
|
|
170
171
|
var _api$analytics3;
|
|
171
|
-
var schema =
|
|
172
|
+
var schema = _ref7.schema;
|
|
172
173
|
return (0, _keymap.default)(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
173
174
|
}
|
|
174
175
|
});
|
|
@@ -176,15 +177,15 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
176
177
|
if (options && options.allowLinking) {
|
|
177
178
|
pmPlugins.push({
|
|
178
179
|
name: 'mediaLinking',
|
|
179
|
-
plugin: function plugin(
|
|
180
|
-
var dispatch =
|
|
180
|
+
plugin: function plugin(_ref8) {
|
|
181
|
+
var dispatch = _ref8.dispatch;
|
|
181
182
|
return (0, _linking.default)(dispatch);
|
|
182
183
|
}
|
|
183
184
|
});
|
|
184
185
|
pmPlugins.push({
|
|
185
186
|
name: 'mediaLinkingKeymap',
|
|
186
|
-
plugin: function plugin(
|
|
187
|
-
var schema =
|
|
187
|
+
plugin: function plugin(_ref9) {
|
|
188
|
+
var schema = _ref9.schema;
|
|
188
189
|
return (0, _keymap3.default)(schema);
|
|
189
190
|
}
|
|
190
191
|
});
|
|
@@ -220,19 +221,19 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
220
221
|
});
|
|
221
222
|
return pmPlugins;
|
|
222
223
|
},
|
|
223
|
-
contentComponent: function contentComponent(
|
|
224
|
-
var editorView =
|
|
225
|
-
appearance =
|
|
224
|
+
contentComponent: function contentComponent(_ref10) {
|
|
225
|
+
var editorView = _ref10.editorView,
|
|
226
|
+
appearance = _ref10.appearance;
|
|
226
227
|
return /*#__PURE__*/_react.default.createElement(MediaPickerFunctionalComponent, {
|
|
227
228
|
editorDomElement: editorView.dom,
|
|
228
229
|
appearance: appearance,
|
|
229
230
|
api: api
|
|
230
231
|
});
|
|
231
232
|
},
|
|
232
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
233
|
-
var editorView =
|
|
234
|
-
eventDispatcher =
|
|
235
|
-
disabled =
|
|
233
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
|
|
234
|
+
var editorView = _ref11.editorView,
|
|
235
|
+
eventDispatcher = _ref11.eventDispatcher,
|
|
236
|
+
disabled = _ref11.disabled;
|
|
236
237
|
return /*#__PURE__*/_react.default.createElement(_ToolbarMedia.default, {
|
|
237
238
|
isDisabled: disabled,
|
|
238
239
|
isReducedSpacing: true,
|
|
@@ -240,8 +241,8 @@ var mediaPlugin = exports.mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
240
241
|
});
|
|
241
242
|
},
|
|
242
243
|
pluginsOptions: {
|
|
243
|
-
quickInsert: function quickInsert(
|
|
244
|
-
var formatMessage =
|
|
244
|
+
quickInsert: function quickInsert(_ref12) {
|
|
245
|
+
var formatMessage = _ref12.formatMessage;
|
|
245
246
|
return [{
|
|
246
247
|
id: 'media',
|
|
247
248
|
title: formatMessage(_messages.toolbarInsertBlockMessages.mediaFiles),
|
|
@@ -6,12 +6,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.keymapPlugin = keymapPlugin;
|
|
8
8
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
9
|
+
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
9
10
|
var _selection = require("@atlaskit/editor-common/selection");
|
|
10
11
|
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
11
12
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
14
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
15
|
var _captions = require("../commands/captions");
|
|
13
16
|
var _pluginKey = require("../pm-plugins/plugin-key");
|
|
14
|
-
|
|
17
|
+
var _commands = require("../toolbar/commands");
|
|
18
|
+
var _utils = require("../toolbar/utils");
|
|
19
|
+
var _mediaResizeAnnouncerMess = require("./mediaResizeAnnouncerMess");
|
|
20
|
+
function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlugin, getIntl) {
|
|
15
21
|
var list = {};
|
|
16
22
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.undo.common, ignoreLinksInSteps, list);
|
|
17
23
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, splitMediaGroup, list);
|
|
@@ -22,6 +28,12 @@ function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
|
22
28
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
23
29
|
}
|
|
24
30
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, splitMediaGroup, list);
|
|
31
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.media.extended-resize-experience')) {
|
|
32
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.a11y-media-resizing_b5v0o')) {
|
|
33
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.increaseMediaSize.common, handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
34
|
+
(0, _keymaps.bindKeymapWithCommand)(_keymaps.decreaseMediaSize.common, handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
25
37
|
return (0, _keymap.keymap)(list);
|
|
26
38
|
}
|
|
27
39
|
var ignoreLinksInSteps = function ignoreLinksInSteps(state) {
|
|
@@ -33,6 +45,101 @@ var splitMediaGroup = function splitMediaGroup(state) {
|
|
|
33
45
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
34
46
|
return mediaPluginState.splitMediaGroup();
|
|
35
47
|
};
|
|
48
|
+
var validationMaxMin = function validationMaxMin(newWidth, maxWidth, minWidth, validation) {
|
|
49
|
+
var newWidthValidated;
|
|
50
|
+
if (newWidth > maxWidth) {
|
|
51
|
+
newWidthValidated = maxWidth;
|
|
52
|
+
validation = 'greater-than-max';
|
|
53
|
+
} else if (newWidth < minWidth) {
|
|
54
|
+
newWidthValidated = minWidth;
|
|
55
|
+
validation = 'less-than-min';
|
|
56
|
+
} else {
|
|
57
|
+
newWidthValidated = newWidth;
|
|
58
|
+
validation = 'valid';
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
newWidthValidated: newWidthValidated,
|
|
62
|
+
validation: validation
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
var createAnnouncer = function createAnnouncer(action, mediaWidth, changeAmount, validation, getIntl) {
|
|
66
|
+
var announcerContainer = document.getElementById('media-announcer') || document.createElement('div');
|
|
67
|
+
var intl = getIntl();
|
|
68
|
+
if (!announcerContainer.id) {
|
|
69
|
+
announcerContainer.id = 'media-announcer';
|
|
70
|
+
announcerContainer.setAttribute('role', 'status');
|
|
71
|
+
announcerContainer.setAttribute('aria-live', 'polite');
|
|
72
|
+
announcerContainer.setAttribute('aria-atomic', 'true');
|
|
73
|
+
var style = announcerContainer.style;
|
|
74
|
+
style.position = 'absolute';
|
|
75
|
+
style.width = '1px';
|
|
76
|
+
style.height = '1px';
|
|
77
|
+
style.marginTop = '-1px';
|
|
78
|
+
style.opacity = '0';
|
|
79
|
+
style.overflow = 'hidden';
|
|
80
|
+
document.body.appendChild(announcerContainer);
|
|
81
|
+
} else {
|
|
82
|
+
var newMediaWidth = mediaWidth + changeAmount;
|
|
83
|
+
if (validation === 'greater-than-max') {
|
|
84
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.MediaWidthIsMax);
|
|
85
|
+
} else if (validation === 'less-than-min') {
|
|
86
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.MediaWidthIsMin);
|
|
87
|
+
} else {
|
|
88
|
+
announcerContainer.textContent = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.DefaultMediaWidth, {
|
|
89
|
+
action: action,
|
|
90
|
+
newMediaWidth: newMediaWidth
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
var handleMediaSizeChange = function handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, changeAmount, action, getIntl) {
|
|
96
|
+
return function (state, dispatch) {
|
|
97
|
+
var _getSelectedMediaSing, _widthPlugin$sharedSt, _widthPlugin$sharedSt2, _getSelectedMediaSing2;
|
|
98
|
+
var selection = state.selection;
|
|
99
|
+
if (!(selection instanceof _state.NodeSelection && selection.node.type.name === 'mediaSingle')) {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
var mediaWidth = (_getSelectedMediaSing = (0, _utils.getSelectedMediaSingle)(state)) === null || _getSelectedMediaSing === void 0 || (_getSelectedMediaSing = _getSelectedMediaSing.node) === null || _getSelectedMediaSing === void 0 || (_getSelectedMediaSing = _getSelectedMediaSing.attrs) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.width;
|
|
103
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
104
|
+
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
105
|
+
var maxWidthForNestedNode = mediaPluginState.currentMaxWidth;
|
|
106
|
+
var minWidth = _mediaSingle.MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
|
|
107
|
+
var maxWidth = maxWidthForNestedNode;
|
|
108
|
+
var currentMaxWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.width) || maxWidth;
|
|
109
|
+
if (maxWidth === undefined && maxWidthForNestedNode === undefined) {
|
|
110
|
+
var _widthPlugin$sharedSt3;
|
|
111
|
+
maxWidth = options !== null && options !== void 0 && options.fullWidthEnabled ? widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.lineLength : (0, _mediaSingle.calcMediaSingleMaxWidth)(currentMaxWidth);
|
|
112
|
+
}
|
|
113
|
+
var validation = 'valid';
|
|
114
|
+
var newWidth = mediaWidth + changeAmount;
|
|
115
|
+
var intl = getIntl();
|
|
116
|
+
if (options !== null && options !== void 0 && options.fullWidthEnabled) {
|
|
117
|
+
var _widthPlugin$sharedSt4;
|
|
118
|
+
maxWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt4 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt4 === void 0 ? void 0 : _widthPlugin$sharedSt4.lineLength;
|
|
119
|
+
} else if (maxWidthForNestedNode === undefined) {
|
|
120
|
+
maxWidth = (0, _mediaSingle.calcMediaSingleMaxWidth)(currentMaxWidth);
|
|
121
|
+
}
|
|
122
|
+
var _validationMaxMin = validationMaxMin(newWidth, maxWidth, minWidth, validation),
|
|
123
|
+
newWidthValidated = _validationMaxMin.newWidthValidated,
|
|
124
|
+
validationResult = _validationMaxMin.validation;
|
|
125
|
+
var formattedAction = action;
|
|
126
|
+
if (action === 'increased') {
|
|
127
|
+
formattedAction = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.IncreasedAction);
|
|
128
|
+
} else if (action === 'decreased') {
|
|
129
|
+
formattedAction = intl.formatMessage(_mediaResizeAnnouncerMess.mediaResizeAnnouncerMess.DecreasedAction);
|
|
130
|
+
}
|
|
131
|
+
var newLayout = (0, _utils.calcNewLayout)(newWidthValidated, (_getSelectedMediaSing2 = (0, _utils.getSelectedMediaSingle)(state)) === null || _getSelectedMediaSing2 === void 0 || (_getSelectedMediaSing2 = _getSelectedMediaSing2.node) === null || _getSelectedMediaSing2 === void 0 || (_getSelectedMediaSing2 = _getSelectedMediaSing2.attrs) === null || _getSelectedMediaSing2 === void 0 ? void 0 : _getSelectedMediaSing2.layout, contentWidth, options === null || options === void 0 ? void 0 : options.fullWidthEnabled);
|
|
132
|
+
(0, _commands.updateMediaSingleWidth)(editorAnalyticsAPI)(newWidthValidated, validationResult, 'keyboard', newLayout)(state, dispatch);
|
|
133
|
+
createAnnouncer(formattedAction, mediaWidth, changeAmount, validationResult, getIntl);
|
|
134
|
+
return true;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
var handleMediaIncrease = function handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
138
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 1, 'increased', getIntl);
|
|
139
|
+
};
|
|
140
|
+
var handleMediaDecrease = function handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
141
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -1, 'decreased', getIntl);
|
|
142
|
+
};
|
|
36
143
|
var insertAndSelectCaption = function insertAndSelectCaption(editorAnalyticsAPI) {
|
|
37
144
|
return function (state, dispatch) {
|
|
38
145
|
var selection = state.selection,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.mediaResizeAnnouncerMess = void 0;
|
|
7
|
+
var _reactIntlNext = require("react-intl-next");
|
|
8
|
+
var mediaResizeAnnouncerMess = exports.mediaResizeAnnouncerMess = (0, _reactIntlNext.defineMessages)({
|
|
9
|
+
MediaWidthIsMax: {
|
|
10
|
+
id: 'fabric.editor.media.pixelEntry.MediaWidthIsMax',
|
|
11
|
+
defaultMessage: 'Media increased to the maximum size',
|
|
12
|
+
description: 'The media has the maximum allowed width'
|
|
13
|
+
},
|
|
14
|
+
MediaWidthIsMin: {
|
|
15
|
+
id: 'fabric.editor.media.MediaWidthIsMin',
|
|
16
|
+
defaultMessage: 'Media decreased to the minimum size',
|
|
17
|
+
description: 'The media has the minimum allowed width'
|
|
18
|
+
},
|
|
19
|
+
DefaultMediaWidth: {
|
|
20
|
+
id: 'fabric.editor.media.DefaultMediaWidth',
|
|
21
|
+
defaultMessage: 'Media width {action} to {newMediaWidth} pixels.',
|
|
22
|
+
description: 'Media width {action} to {newMediaWidth} pixels.'
|
|
23
|
+
},
|
|
24
|
+
IncreasedAction: {
|
|
25
|
+
id: 'fabric.editor.media.decreased',
|
|
26
|
+
defaultMessage: 'increased',
|
|
27
|
+
description: 'Increased action'
|
|
28
|
+
},
|
|
29
|
+
DecreasedAction: {
|
|
30
|
+
id: 'fabric.editor.media.decreased',
|
|
31
|
+
defaultMessage: 'decreased',
|
|
32
|
+
description: 'Decreased action'
|
|
33
|
+
}
|
|
34
|
+
});
|
|
@@ -203,7 +203,7 @@ var setBorderMark = exports.setBorderMark = function setBorderMark(editorAnalyti
|
|
|
203
203
|
};
|
|
204
204
|
};
|
|
205
205
|
var updateMediaSingleWidth = exports.updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyticsAPI) {
|
|
206
|
-
return function (width, validation, layout) {
|
|
206
|
+
return function (width, validation, inputMethod, layout) {
|
|
207
207
|
return function (state, dispatch) {
|
|
208
208
|
var selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
209
209
|
if (!selectedMediaSingleNode) {
|
|
@@ -222,6 +222,7 @@ var updateMediaSingleWidth = exports.updateMediaSingleWidth = function updateMed
|
|
|
222
222
|
width: width,
|
|
223
223
|
layout: layout,
|
|
224
224
|
validation: validation,
|
|
225
|
+
inputMethod: inputMethod,
|
|
225
226
|
parentNode: parentNodeType
|
|
226
227
|
});
|
|
227
228
|
if (payload) {
|
|
@@ -286,7 +286,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
286
286
|
var width = _ref2.width,
|
|
287
287
|
validation = _ref2.validation;
|
|
288
288
|
var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
289
|
-
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
|
|
289
|
+
(0, _commands.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
290
290
|
},
|
|
291
291
|
onMigrate: function onMigrate() {
|
|
292
292
|
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
@@ -252,7 +252,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
252
252
|
layout: newLayout,
|
|
253
253
|
widthType: 'pixel',
|
|
254
254
|
snapType: (0, _guideline.getGuidelineTypeFromKey)(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
|
|
255
|
-
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
255
|
+
parentNode: $pos ? $pos.parent.type.name : undefined,
|
|
256
|
+
inputMethod: 'mouse'
|
|
256
257
|
});
|
|
257
258
|
if (event) {
|
|
258
259
|
dispatchAnalyticsEvent(event);
|
|
@@ -13,7 +13,8 @@ var getMediaResizeAnalyticsEvent = exports.getMediaResizeAnalyticsEvent = functi
|
|
|
13
13
|
widthType = attributes.widthType,
|
|
14
14
|
layout = attributes.layout,
|
|
15
15
|
snapType = attributes.snapType,
|
|
16
|
-
parentNode = attributes.parentNode
|
|
16
|
+
parentNode = attributes.parentNode,
|
|
17
|
+
inputMethod = attributes.inputMethod;
|
|
17
18
|
var actionSubject = type === 'embed' ? _analytics.ACTION_SUBJECT.EMBEDS : _analytics.ACTION_SUBJECT.MEDIA_SINGLE;
|
|
18
19
|
return {
|
|
19
20
|
action: _analytics.ACTION.EDITED,
|
|
@@ -24,7 +25,8 @@ var getMediaResizeAnalyticsEvent = exports.getMediaResizeAnalyticsEvent = functi
|
|
|
24
25
|
layout: layout,
|
|
25
26
|
widthType: widthType,
|
|
26
27
|
snapType: snapType,
|
|
27
|
-
parentNode: parentNode
|
|
28
|
+
parentNode: parentNode,
|
|
29
|
+
inputMethod: inputMethod
|
|
28
30
|
},
|
|
29
31
|
eventType: _analytics.EVENT_TYPE.UI
|
|
30
32
|
};
|
|
@@ -36,7 +38,8 @@ var getMediaInputResizeAnalyticsEvent = exports.getMediaInputResizeAnalyticsEven
|
|
|
36
38
|
var width = attributes.width,
|
|
37
39
|
layout = attributes.layout,
|
|
38
40
|
validation = attributes.validation,
|
|
39
|
-
parentNode = attributes.parentNode
|
|
41
|
+
parentNode = attributes.parentNode,
|
|
42
|
+
inputMethod = attributes.inputMethod;
|
|
40
43
|
var actionSubject = type === 'embed' ? _analytics.ACTION_SUBJECT.EMBEDS : _analytics.ACTION_SUBJECT.MEDIA_SINGLE;
|
|
41
44
|
return {
|
|
42
45
|
action: _analytics.ACTION.EDITED,
|
|
@@ -46,7 +49,8 @@ var getMediaInputResizeAnalyticsEvent = exports.getMediaInputResizeAnalyticsEven
|
|
|
46
49
|
width: width,
|
|
47
50
|
layout: layout,
|
|
48
51
|
validation: validation,
|
|
49
|
-
parentNode: parentNode
|
|
52
|
+
parentNode: parentNode,
|
|
53
|
+
inputMethod: inputMethod
|
|
50
54
|
},
|
|
51
55
|
eventType: _analytics.EVENT_TYPE.UI
|
|
52
56
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -136,9 +136,11 @@ export const mediaPlugin = ({
|
|
|
136
136
|
}
|
|
137
137
|
}, {
|
|
138
138
|
name: 'mediaKeymap',
|
|
139
|
-
plugin: (
|
|
139
|
+
plugin: ({
|
|
140
|
+
getIntl
|
|
141
|
+
}) => {
|
|
140
142
|
var _api$analytics2;
|
|
141
|
-
return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions);
|
|
143
|
+
return keymapPlugin(options, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
|
|
142
144
|
}
|
|
143
145
|
}];
|
|
144
146
|
if (options && options.allowMediaSingle) {
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, enter, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
1
|
+
import { bindKeymapWithCommand, decreaseMediaSize, enter, increaseMediaSize, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { calcMediaSingleMaxWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
2
3
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
8
|
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
6
9
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
7
|
-
|
|
10
|
+
import { updateMediaSingleWidth } from '../toolbar/commands';
|
|
11
|
+
import { calcNewLayout, getSelectedMediaSingle } from '../toolbar/utils';
|
|
12
|
+
import { mediaResizeAnnouncerMess } from './mediaResizeAnnouncerMess';
|
|
13
|
+
export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlugin, getIntl) {
|
|
8
14
|
const list = {};
|
|
9
15
|
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
10
16
|
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
@@ -15,6 +21,12 @@ export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
|
15
21
|
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
16
22
|
}
|
|
17
23
|
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
24
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
25
|
+
if (getBooleanFF('platform.editor.a11y-media-resizing_b5v0o')) {
|
|
26
|
+
bindKeymapWithCommand(increaseMediaSize.common, handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
27
|
+
bindKeymapWithCommand(decreaseMediaSize.common, handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
return keymap(list);
|
|
19
31
|
}
|
|
20
32
|
const ignoreLinksInSteps = state => {
|
|
@@ -26,6 +38,98 @@ const splitMediaGroup = state => {
|
|
|
26
38
|
const mediaPluginState = stateKey.getState(state);
|
|
27
39
|
return mediaPluginState.splitMediaGroup();
|
|
28
40
|
};
|
|
41
|
+
const validationMaxMin = (newWidth, maxWidth, minWidth, validation) => {
|
|
42
|
+
let newWidthValidated;
|
|
43
|
+
if (newWidth > maxWidth) {
|
|
44
|
+
newWidthValidated = maxWidth;
|
|
45
|
+
validation = 'greater-than-max';
|
|
46
|
+
} else if (newWidth < minWidth) {
|
|
47
|
+
newWidthValidated = minWidth;
|
|
48
|
+
validation = 'less-than-min';
|
|
49
|
+
} else {
|
|
50
|
+
newWidthValidated = newWidth;
|
|
51
|
+
validation = 'valid';
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
newWidthValidated,
|
|
55
|
+
validation
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const createAnnouncer = (action, mediaWidth, changeAmount, validation, getIntl) => {
|
|
59
|
+
let announcerContainer = document.getElementById('media-announcer') || document.createElement('div');
|
|
60
|
+
const intl = getIntl();
|
|
61
|
+
if (!announcerContainer.id) {
|
|
62
|
+
announcerContainer.id = 'media-announcer';
|
|
63
|
+
announcerContainer.setAttribute('role', 'status');
|
|
64
|
+
announcerContainer.setAttribute('aria-live', 'polite');
|
|
65
|
+
announcerContainer.setAttribute('aria-atomic', 'true');
|
|
66
|
+
const style = announcerContainer.style;
|
|
67
|
+
style.position = 'absolute';
|
|
68
|
+
style.width = '1px';
|
|
69
|
+
style.height = '1px';
|
|
70
|
+
style.marginTop = '-1px';
|
|
71
|
+
style.opacity = '0';
|
|
72
|
+
style.overflow = 'hidden';
|
|
73
|
+
document.body.appendChild(announcerContainer);
|
|
74
|
+
} else {
|
|
75
|
+
const newMediaWidth = mediaWidth + changeAmount;
|
|
76
|
+
if (validation === 'greater-than-max') {
|
|
77
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMax);
|
|
78
|
+
} else if (validation === 'less-than-min') {
|
|
79
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMin);
|
|
80
|
+
} else {
|
|
81
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.DefaultMediaWidth, {
|
|
82
|
+
action: action,
|
|
83
|
+
newMediaWidth: newMediaWidth
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const handleMediaSizeChange = (editorAnalyticsAPI, widthPlugin, options, changeAmount, action, getIntl) => (state, dispatch) => {
|
|
89
|
+
var _getSelectedMediaSing, _getSelectedMediaSing2, _getSelectedMediaSing3, _widthPlugin$sharedSt, _widthPlugin$sharedSt2, _getSelectedMediaSing4, _getSelectedMediaSing5, _getSelectedMediaSing6;
|
|
90
|
+
const {
|
|
91
|
+
selection
|
|
92
|
+
} = state;
|
|
93
|
+
if (!(selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle')) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const mediaWidth = (_getSelectedMediaSing = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing === void 0 ? void 0 : (_getSelectedMediaSing2 = _getSelectedMediaSing.node) === null || _getSelectedMediaSing2 === void 0 ? void 0 : (_getSelectedMediaSing3 = _getSelectedMediaSing2.attrs) === null || _getSelectedMediaSing3 === void 0 ? void 0 : _getSelectedMediaSing3.width;
|
|
97
|
+
const contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength) || akEditorDefaultLayoutWidth;
|
|
98
|
+
const mediaPluginState = stateKey.getState(state);
|
|
99
|
+
const maxWidthForNestedNode = mediaPluginState.currentMaxWidth;
|
|
100
|
+
const minWidth = MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
|
|
101
|
+
let maxWidth = maxWidthForNestedNode;
|
|
102
|
+
const currentMaxWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.width) || maxWidth;
|
|
103
|
+
if (maxWidth === undefined && maxWidthForNestedNode === undefined) {
|
|
104
|
+
var _widthPlugin$sharedSt3;
|
|
105
|
+
maxWidth = options !== null && options !== void 0 && options.fullWidthEnabled ? widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.lineLength : calcMediaSingleMaxWidth(currentMaxWidth);
|
|
106
|
+
}
|
|
107
|
+
let validation = 'valid';
|
|
108
|
+
let newWidth = mediaWidth + changeAmount;
|
|
109
|
+
const intl = getIntl();
|
|
110
|
+
if (options !== null && options !== void 0 && options.fullWidthEnabled) {
|
|
111
|
+
var _widthPlugin$sharedSt4;
|
|
112
|
+
maxWidth = widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt4 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt4 === void 0 ? void 0 : _widthPlugin$sharedSt4.lineLength;
|
|
113
|
+
} else if (maxWidthForNestedNode === undefined) {
|
|
114
|
+
maxWidth = calcMediaSingleMaxWidth(currentMaxWidth);
|
|
115
|
+
}
|
|
116
|
+
const {
|
|
117
|
+
newWidthValidated,
|
|
118
|
+
validation: validationResult
|
|
119
|
+
} = validationMaxMin(newWidth, maxWidth, minWidth, validation);
|
|
120
|
+
let formattedAction = action;
|
|
121
|
+
if (action === 'increased') {
|
|
122
|
+
formattedAction = intl.formatMessage(mediaResizeAnnouncerMess.IncreasedAction);
|
|
123
|
+
} else if (action === 'decreased') {
|
|
124
|
+
formattedAction = intl.formatMessage(mediaResizeAnnouncerMess.DecreasedAction);
|
|
125
|
+
}
|
|
126
|
+
const newLayout = calcNewLayout(newWidthValidated, (_getSelectedMediaSing4 = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing4 === void 0 ? void 0 : (_getSelectedMediaSing5 = _getSelectedMediaSing4.node) === null || _getSelectedMediaSing5 === void 0 ? void 0 : (_getSelectedMediaSing6 = _getSelectedMediaSing5.attrs) === null || _getSelectedMediaSing6 === void 0 ? void 0 : _getSelectedMediaSing6.layout, contentWidth, options === null || options === void 0 ? void 0 : options.fullWidthEnabled);
|
|
127
|
+
updateMediaSingleWidth(editorAnalyticsAPI)(newWidthValidated, validationResult, 'keyboard', newLayout)(state, dispatch);
|
|
128
|
+
createAnnouncer(formattedAction, mediaWidth, changeAmount, validationResult, getIntl);
|
|
129
|
+
return true;
|
|
130
|
+
};
|
|
131
|
+
const handleMediaIncrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 1, 'increased', getIntl);
|
|
132
|
+
const handleMediaDecrease = (editorAnalyticsAPI, widthPlugin, options, getIntl) => handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -1, 'decreased', getIntl);
|
|
29
133
|
const insertAndSelectCaption = editorAnalyticsAPI => (state, dispatch) => {
|
|
30
134
|
const {
|
|
31
135
|
selection,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export const mediaResizeAnnouncerMess = defineMessages({
|
|
3
|
+
MediaWidthIsMax: {
|
|
4
|
+
id: 'fabric.editor.media.pixelEntry.MediaWidthIsMax',
|
|
5
|
+
defaultMessage: 'Media increased to the maximum size',
|
|
6
|
+
description: 'The media has the maximum allowed width'
|
|
7
|
+
},
|
|
8
|
+
MediaWidthIsMin: {
|
|
9
|
+
id: 'fabric.editor.media.MediaWidthIsMin',
|
|
10
|
+
defaultMessage: 'Media decreased to the minimum size',
|
|
11
|
+
description: 'The media has the minimum allowed width'
|
|
12
|
+
},
|
|
13
|
+
DefaultMediaWidth: {
|
|
14
|
+
id: 'fabric.editor.media.DefaultMediaWidth',
|
|
15
|
+
defaultMessage: 'Media width {action} to {newMediaWidth} pixels.',
|
|
16
|
+
description: 'Media width {action} to {newMediaWidth} pixels.'
|
|
17
|
+
},
|
|
18
|
+
IncreasedAction: {
|
|
19
|
+
id: 'fabric.editor.media.decreased',
|
|
20
|
+
defaultMessage: 'increased',
|
|
21
|
+
description: 'Increased action'
|
|
22
|
+
},
|
|
23
|
+
DecreasedAction: {
|
|
24
|
+
id: 'fabric.editor.media.decreased',
|
|
25
|
+
defaultMessage: 'decreased',
|
|
26
|
+
description: 'Decreased action'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -181,7 +181,7 @@ export const setBorderMark = editorAnalyticsAPI => attrs => (state, dispatch) =>
|
|
|
181
181
|
}
|
|
182
182
|
return true;
|
|
183
183
|
};
|
|
184
|
-
export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation, layout) => (state, dispatch) => {
|
|
184
|
+
export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation, inputMethod, layout) => (state, dispatch) => {
|
|
185
185
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
186
186
|
if (!selectedMediaSingleNode) {
|
|
187
187
|
return false;
|
|
@@ -200,6 +200,7 @@ export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation,
|
|
|
200
200
|
width,
|
|
201
201
|
layout,
|
|
202
202
|
validation,
|
|
203
|
+
inputMethod,
|
|
203
204
|
parentNode: parentNodeType
|
|
204
205
|
});
|
|
205
206
|
if (payload) {
|
|
@@ -286,7 +286,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
286
286
|
}) => {
|
|
287
287
|
var _pluginInjectionApi$a4;
|
|
288
288
|
const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
289
|
-
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
|
|
289
|
+
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
290
290
|
},
|
|
291
291
|
onMigrate: () => {
|
|
292
292
|
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
@@ -236,7 +236,8 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
236
236
|
layout: newLayout,
|
|
237
237
|
widthType: 'pixel',
|
|
238
238
|
snapType: getGuidelineTypeFromKey(this.lastSnappedGuidelineKeys, this.state.guidelines),
|
|
239
|
-
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
239
|
+
parentNode: $pos ? $pos.parent.type.name : undefined,
|
|
240
|
+
inputMethod: 'mouse'
|
|
240
241
|
});
|
|
241
242
|
if (event) {
|
|
242
243
|
dispatchAnalyticsEvent(event);
|
|
@@ -8,7 +8,8 @@ export const getMediaResizeAnalyticsEvent = (type, attributes) => {
|
|
|
8
8
|
widthType,
|
|
9
9
|
layout,
|
|
10
10
|
snapType,
|
|
11
|
-
parentNode
|
|
11
|
+
parentNode,
|
|
12
|
+
inputMethod
|
|
12
13
|
} = attributes;
|
|
13
14
|
const actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
|
|
14
15
|
return {
|
|
@@ -20,7 +21,8 @@ export const getMediaResizeAnalyticsEvent = (type, attributes) => {
|
|
|
20
21
|
layout,
|
|
21
22
|
widthType,
|
|
22
23
|
snapType,
|
|
23
|
-
parentNode
|
|
24
|
+
parentNode,
|
|
25
|
+
inputMethod
|
|
24
26
|
},
|
|
25
27
|
eventType: EVENT_TYPE.UI
|
|
26
28
|
};
|
|
@@ -33,7 +35,8 @@ export const getMediaInputResizeAnalyticsEvent = (type, attributes) => {
|
|
|
33
35
|
width,
|
|
34
36
|
layout,
|
|
35
37
|
validation,
|
|
36
|
-
parentNode
|
|
38
|
+
parentNode,
|
|
39
|
+
inputMethod
|
|
37
40
|
} = attributes;
|
|
38
41
|
const actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
|
|
39
42
|
return {
|
|
@@ -44,7 +47,8 @@ export const getMediaInputResizeAnalyticsEvent = (type, attributes) => {
|
|
|
44
47
|
width,
|
|
45
48
|
layout,
|
|
46
49
|
validation,
|
|
47
|
-
parentNode
|
|
50
|
+
parentNode,
|
|
51
|
+
inputMethod
|
|
48
52
|
},
|
|
49
53
|
eventType: EVENT_TYPE.UI
|
|
50
54
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -134,16 +134,17 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
134
134
|
}
|
|
135
135
|
}, {
|
|
136
136
|
name: 'mediaKeymap',
|
|
137
|
-
plugin: function plugin() {
|
|
137
|
+
plugin: function plugin(_ref5) {
|
|
138
138
|
var _api$analytics2;
|
|
139
|
-
|
|
139
|
+
var getIntl = _ref5.getIntl;
|
|
140
|
+
return keymapPlugin(options, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, api === null || api === void 0 ? void 0 : api.selection.actions, api === null || api === void 0 ? void 0 : api.width, getIntl);
|
|
140
141
|
}
|
|
141
142
|
}];
|
|
142
143
|
if (options && options.allowMediaSingle) {
|
|
143
144
|
pmPlugins.push({
|
|
144
145
|
name: 'mediaSingleKeymap',
|
|
145
|
-
plugin: function plugin(
|
|
146
|
-
var schema =
|
|
146
|
+
plugin: function plugin(_ref6) {
|
|
147
|
+
var schema = _ref6.schema;
|
|
147
148
|
return keymapMediaSinglePlugin(schema);
|
|
148
149
|
}
|
|
149
150
|
});
|
|
@@ -155,9 +156,9 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
155
156
|
});
|
|
156
157
|
pmPlugins.push({
|
|
157
158
|
name: 'mediaAltTextKeymap',
|
|
158
|
-
plugin: function plugin(
|
|
159
|
+
plugin: function plugin(_ref7) {
|
|
159
160
|
var _api$analytics3;
|
|
160
|
-
var schema =
|
|
161
|
+
var schema = _ref7.schema;
|
|
161
162
|
return keymapMediaAltTextPlugin(schema, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
162
163
|
}
|
|
163
164
|
});
|
|
@@ -165,15 +166,15 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
165
166
|
if (options && options.allowLinking) {
|
|
166
167
|
pmPlugins.push({
|
|
167
168
|
name: 'mediaLinking',
|
|
168
|
-
plugin: function plugin(
|
|
169
|
-
var dispatch =
|
|
169
|
+
plugin: function plugin(_ref8) {
|
|
170
|
+
var dispatch = _ref8.dispatch;
|
|
170
171
|
return linkingPlugin(dispatch);
|
|
171
172
|
}
|
|
172
173
|
});
|
|
173
174
|
pmPlugins.push({
|
|
174
175
|
name: 'mediaLinkingKeymap',
|
|
175
|
-
plugin: function plugin(
|
|
176
|
-
var schema =
|
|
176
|
+
plugin: function plugin(_ref9) {
|
|
177
|
+
var schema = _ref9.schema;
|
|
177
178
|
return keymapLinkingPlugin(schema);
|
|
178
179
|
}
|
|
179
180
|
});
|
|
@@ -209,19 +210,19 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
209
210
|
});
|
|
210
211
|
return pmPlugins;
|
|
211
212
|
},
|
|
212
|
-
contentComponent: function contentComponent(
|
|
213
|
-
var editorView =
|
|
214
|
-
appearance =
|
|
213
|
+
contentComponent: function contentComponent(_ref10) {
|
|
214
|
+
var editorView = _ref10.editorView,
|
|
215
|
+
appearance = _ref10.appearance;
|
|
215
216
|
return /*#__PURE__*/React.createElement(MediaPickerFunctionalComponent, {
|
|
216
217
|
editorDomElement: editorView.dom,
|
|
217
218
|
appearance: appearance,
|
|
218
219
|
api: api
|
|
219
220
|
});
|
|
220
221
|
},
|
|
221
|
-
secondaryToolbarComponent: function secondaryToolbarComponent(
|
|
222
|
-
var editorView =
|
|
223
|
-
eventDispatcher =
|
|
224
|
-
disabled =
|
|
222
|
+
secondaryToolbarComponent: function secondaryToolbarComponent(_ref11) {
|
|
223
|
+
var editorView = _ref11.editorView,
|
|
224
|
+
eventDispatcher = _ref11.eventDispatcher,
|
|
225
|
+
disabled = _ref11.disabled;
|
|
225
226
|
return /*#__PURE__*/React.createElement(ToolbarMedia, {
|
|
226
227
|
isDisabled: disabled,
|
|
227
228
|
isReducedSpacing: true,
|
|
@@ -229,8 +230,8 @@ export var mediaPlugin = function mediaPlugin(_ref2) {
|
|
|
229
230
|
});
|
|
230
231
|
},
|
|
231
232
|
pluginsOptions: {
|
|
232
|
-
quickInsert: function quickInsert(
|
|
233
|
-
var formatMessage =
|
|
233
|
+
quickInsert: function quickInsert(_ref12) {
|
|
234
|
+
var formatMessage = _ref12.formatMessage;
|
|
234
235
|
return [{
|
|
235
236
|
id: 'media',
|
|
236
237
|
title: formatMessage(messages.mediaFiles),
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import { bindKeymapWithCommand, enter, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
1
|
+
import { bindKeymapWithCommand, decreaseMediaSize, enter, increaseMediaSize, insertNewLine, moveDown, moveLeft, moveRight, tab, undo } from '@atlaskit/editor-common/keymaps';
|
|
2
|
+
import { calcMediaSingleMaxWidth, MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
2
3
|
import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
|
|
3
4
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
4
5
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import { akEditorDefaultLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
7
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
5
8
|
import { insertAndSelectCaptionFromMediaSinglePos, selectCaptionFromMediaSinglePos } from '../commands/captions';
|
|
6
9
|
import { stateKey } from '../pm-plugins/plugin-key';
|
|
7
|
-
|
|
10
|
+
import { updateMediaSingleWidth } from '../toolbar/commands';
|
|
11
|
+
import { calcNewLayout, getSelectedMediaSingle } from '../toolbar/utils';
|
|
12
|
+
import { mediaResizeAnnouncerMess } from './mediaResizeAnnouncerMess';
|
|
13
|
+
export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI, widthPlugin, getIntl) {
|
|
8
14
|
var list = {};
|
|
9
15
|
bindKeymapWithCommand(undo.common, ignoreLinksInSteps, list);
|
|
10
16
|
bindKeymapWithCommand(enter.common, splitMediaGroup, list);
|
|
@@ -15,6 +21,12 @@ export function keymapPlugin(options, editorAnalyticsAPI, editorSelectionAPI) {
|
|
|
15
21
|
bindKeymapWithCommand(moveRight.common, arrowRightFromMediaSingle(editorSelectionAPI), list);
|
|
16
22
|
}
|
|
17
23
|
bindKeymapWithCommand(insertNewLine.common, splitMediaGroup, list);
|
|
24
|
+
if (getBooleanFF('platform.editor.media.extended-resize-experience')) {
|
|
25
|
+
if (getBooleanFF('platform.editor.a11y-media-resizing_b5v0o')) {
|
|
26
|
+
bindKeymapWithCommand(increaseMediaSize.common, handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
27
|
+
bindKeymapWithCommand(decreaseMediaSize.common, handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl), list);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
18
30
|
return keymap(list);
|
|
19
31
|
}
|
|
20
32
|
var ignoreLinksInSteps = function ignoreLinksInSteps(state) {
|
|
@@ -26,6 +38,101 @@ var splitMediaGroup = function splitMediaGroup(state) {
|
|
|
26
38
|
var mediaPluginState = stateKey.getState(state);
|
|
27
39
|
return mediaPluginState.splitMediaGroup();
|
|
28
40
|
};
|
|
41
|
+
var validationMaxMin = function validationMaxMin(newWidth, maxWidth, minWidth, validation) {
|
|
42
|
+
var newWidthValidated;
|
|
43
|
+
if (newWidth > maxWidth) {
|
|
44
|
+
newWidthValidated = maxWidth;
|
|
45
|
+
validation = 'greater-than-max';
|
|
46
|
+
} else if (newWidth < minWidth) {
|
|
47
|
+
newWidthValidated = minWidth;
|
|
48
|
+
validation = 'less-than-min';
|
|
49
|
+
} else {
|
|
50
|
+
newWidthValidated = newWidth;
|
|
51
|
+
validation = 'valid';
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
newWidthValidated: newWidthValidated,
|
|
55
|
+
validation: validation
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
var createAnnouncer = function createAnnouncer(action, mediaWidth, changeAmount, validation, getIntl) {
|
|
59
|
+
var announcerContainer = document.getElementById('media-announcer') || document.createElement('div');
|
|
60
|
+
var intl = getIntl();
|
|
61
|
+
if (!announcerContainer.id) {
|
|
62
|
+
announcerContainer.id = 'media-announcer';
|
|
63
|
+
announcerContainer.setAttribute('role', 'status');
|
|
64
|
+
announcerContainer.setAttribute('aria-live', 'polite');
|
|
65
|
+
announcerContainer.setAttribute('aria-atomic', 'true');
|
|
66
|
+
var style = announcerContainer.style;
|
|
67
|
+
style.position = 'absolute';
|
|
68
|
+
style.width = '1px';
|
|
69
|
+
style.height = '1px';
|
|
70
|
+
style.marginTop = '-1px';
|
|
71
|
+
style.opacity = '0';
|
|
72
|
+
style.overflow = 'hidden';
|
|
73
|
+
document.body.appendChild(announcerContainer);
|
|
74
|
+
} else {
|
|
75
|
+
var newMediaWidth = mediaWidth + changeAmount;
|
|
76
|
+
if (validation === 'greater-than-max') {
|
|
77
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMax);
|
|
78
|
+
} else if (validation === 'less-than-min') {
|
|
79
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.MediaWidthIsMin);
|
|
80
|
+
} else {
|
|
81
|
+
announcerContainer.textContent = intl.formatMessage(mediaResizeAnnouncerMess.DefaultMediaWidth, {
|
|
82
|
+
action: action,
|
|
83
|
+
newMediaWidth: newMediaWidth
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
var handleMediaSizeChange = function handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, changeAmount, action, getIntl) {
|
|
89
|
+
return function (state, dispatch) {
|
|
90
|
+
var _getSelectedMediaSing, _widthPlugin$sharedSt, _widthPlugin$sharedSt2, _getSelectedMediaSing2;
|
|
91
|
+
var selection = state.selection;
|
|
92
|
+
if (!(selection instanceof NodeSelection && selection.node.type.name === 'mediaSingle')) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
var mediaWidth = (_getSelectedMediaSing = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing === void 0 || (_getSelectedMediaSing = _getSelectedMediaSing.node) === null || _getSelectedMediaSing === void 0 || (_getSelectedMediaSing = _getSelectedMediaSing.attrs) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.width;
|
|
96
|
+
var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt === void 0 ? void 0 : _widthPlugin$sharedSt.lineLength) || akEditorDefaultLayoutWidth;
|
|
97
|
+
var mediaPluginState = stateKey.getState(state);
|
|
98
|
+
var maxWidthForNestedNode = mediaPluginState.currentMaxWidth;
|
|
99
|
+
var minWidth = MEDIA_SINGLE_DEFAULT_MIN_PIXEL_WIDTH;
|
|
100
|
+
var maxWidth = maxWidthForNestedNode;
|
|
101
|
+
var currentMaxWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.width) || maxWidth;
|
|
102
|
+
if (maxWidth === undefined && maxWidthForNestedNode === undefined) {
|
|
103
|
+
var _widthPlugin$sharedSt3;
|
|
104
|
+
maxWidth = options !== null && options !== void 0 && options.fullWidthEnabled ? widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.lineLength : calcMediaSingleMaxWidth(currentMaxWidth);
|
|
105
|
+
}
|
|
106
|
+
var validation = 'valid';
|
|
107
|
+
var newWidth = mediaWidth + changeAmount;
|
|
108
|
+
var intl = getIntl();
|
|
109
|
+
if (options !== null && options !== void 0 && options.fullWidthEnabled) {
|
|
110
|
+
var _widthPlugin$sharedSt4;
|
|
111
|
+
maxWidth = widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt4 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt4 === void 0 ? void 0 : _widthPlugin$sharedSt4.lineLength;
|
|
112
|
+
} else if (maxWidthForNestedNode === undefined) {
|
|
113
|
+
maxWidth = calcMediaSingleMaxWidth(currentMaxWidth);
|
|
114
|
+
}
|
|
115
|
+
var _validationMaxMin = validationMaxMin(newWidth, maxWidth, minWidth, validation),
|
|
116
|
+
newWidthValidated = _validationMaxMin.newWidthValidated,
|
|
117
|
+
validationResult = _validationMaxMin.validation;
|
|
118
|
+
var formattedAction = action;
|
|
119
|
+
if (action === 'increased') {
|
|
120
|
+
formattedAction = intl.formatMessage(mediaResizeAnnouncerMess.IncreasedAction);
|
|
121
|
+
} else if (action === 'decreased') {
|
|
122
|
+
formattedAction = intl.formatMessage(mediaResizeAnnouncerMess.DecreasedAction);
|
|
123
|
+
}
|
|
124
|
+
var newLayout = calcNewLayout(newWidthValidated, (_getSelectedMediaSing2 = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing2 === void 0 || (_getSelectedMediaSing2 = _getSelectedMediaSing2.node) === null || _getSelectedMediaSing2 === void 0 || (_getSelectedMediaSing2 = _getSelectedMediaSing2.attrs) === null || _getSelectedMediaSing2 === void 0 ? void 0 : _getSelectedMediaSing2.layout, contentWidth, options === null || options === void 0 ? void 0 : options.fullWidthEnabled);
|
|
125
|
+
updateMediaSingleWidth(editorAnalyticsAPI)(newWidthValidated, validationResult, 'keyboard', newLayout)(state, dispatch);
|
|
126
|
+
createAnnouncer(formattedAction, mediaWidth, changeAmount, validationResult, getIntl);
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
var handleMediaIncrease = function handleMediaIncrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
131
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, 1, 'increased', getIntl);
|
|
132
|
+
};
|
|
133
|
+
var handleMediaDecrease = function handleMediaDecrease(editorAnalyticsAPI, widthPlugin, options, getIntl) {
|
|
134
|
+
return handleMediaSizeChange(editorAnalyticsAPI, widthPlugin, options, -1, 'decreased', getIntl);
|
|
135
|
+
};
|
|
29
136
|
var insertAndSelectCaption = function insertAndSelectCaption(editorAnalyticsAPI) {
|
|
30
137
|
return function (state, dispatch) {
|
|
31
138
|
var selection = state.selection,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl-next';
|
|
2
|
+
export var mediaResizeAnnouncerMess = defineMessages({
|
|
3
|
+
MediaWidthIsMax: {
|
|
4
|
+
id: 'fabric.editor.media.pixelEntry.MediaWidthIsMax',
|
|
5
|
+
defaultMessage: 'Media increased to the maximum size',
|
|
6
|
+
description: 'The media has the maximum allowed width'
|
|
7
|
+
},
|
|
8
|
+
MediaWidthIsMin: {
|
|
9
|
+
id: 'fabric.editor.media.MediaWidthIsMin',
|
|
10
|
+
defaultMessage: 'Media decreased to the minimum size',
|
|
11
|
+
description: 'The media has the minimum allowed width'
|
|
12
|
+
},
|
|
13
|
+
DefaultMediaWidth: {
|
|
14
|
+
id: 'fabric.editor.media.DefaultMediaWidth',
|
|
15
|
+
defaultMessage: 'Media width {action} to {newMediaWidth} pixels.',
|
|
16
|
+
description: 'Media width {action} to {newMediaWidth} pixels.'
|
|
17
|
+
},
|
|
18
|
+
IncreasedAction: {
|
|
19
|
+
id: 'fabric.editor.media.decreased',
|
|
20
|
+
defaultMessage: 'increased',
|
|
21
|
+
description: 'Increased action'
|
|
22
|
+
},
|
|
23
|
+
DecreasedAction: {
|
|
24
|
+
id: 'fabric.editor.media.decreased',
|
|
25
|
+
defaultMessage: 'decreased',
|
|
26
|
+
description: 'Decreased action'
|
|
27
|
+
}
|
|
28
|
+
});
|
|
@@ -196,7 +196,7 @@ export var setBorderMark = function setBorderMark(editorAnalyticsAPI) {
|
|
|
196
196
|
};
|
|
197
197
|
};
|
|
198
198
|
export var updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyticsAPI) {
|
|
199
|
-
return function (width, validation, layout) {
|
|
199
|
+
return function (width, validation, inputMethod, layout) {
|
|
200
200
|
return function (state, dispatch) {
|
|
201
201
|
var selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
202
202
|
if (!selectedMediaSingleNode) {
|
|
@@ -215,6 +215,7 @@ export var updateMediaSingleWidth = function updateMediaSingleWidth(editorAnalyt
|
|
|
215
215
|
width: width,
|
|
216
216
|
layout: layout,
|
|
217
217
|
validation: validation,
|
|
218
|
+
inputMethod: inputMethod,
|
|
218
219
|
parentNode: parentNodeType
|
|
219
220
|
});
|
|
220
221
|
if (payload) {
|
|
@@ -276,7 +276,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
276
276
|
var width = _ref2.width,
|
|
277
277
|
validation = _ref2.validation;
|
|
278
278
|
var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
279
|
-
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, newLayout)(state, dispatch);
|
|
279
|
+
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
280
280
|
},
|
|
281
281
|
onMigrate: function onMigrate() {
|
|
282
282
|
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
@@ -246,7 +246,8 @@ var ResizableMediaSingleNext = /*#__PURE__*/function (_React$Component) {
|
|
|
246
246
|
layout: newLayout,
|
|
247
247
|
widthType: 'pixel',
|
|
248
248
|
snapType: getGuidelineTypeFromKey(_this.lastSnappedGuidelineKeys, _this.state.guidelines),
|
|
249
|
-
parentNode: $pos ? $pos.parent.type.name : undefined
|
|
249
|
+
parentNode: $pos ? $pos.parent.type.name : undefined,
|
|
250
|
+
inputMethod: 'mouse'
|
|
250
251
|
});
|
|
251
252
|
if (event) {
|
|
252
253
|
dispatchAnalyticsEvent(event);
|
|
@@ -7,7 +7,8 @@ export var getMediaResizeAnalyticsEvent = function getMediaResizeAnalyticsEvent(
|
|
|
7
7
|
widthType = attributes.widthType,
|
|
8
8
|
layout = attributes.layout,
|
|
9
9
|
snapType = attributes.snapType,
|
|
10
|
-
parentNode = attributes.parentNode
|
|
10
|
+
parentNode = attributes.parentNode,
|
|
11
|
+
inputMethod = attributes.inputMethod;
|
|
11
12
|
var actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
|
|
12
13
|
return {
|
|
13
14
|
action: ACTION.EDITED,
|
|
@@ -18,7 +19,8 @@ export var getMediaResizeAnalyticsEvent = function getMediaResizeAnalyticsEvent(
|
|
|
18
19
|
layout: layout,
|
|
19
20
|
widthType: widthType,
|
|
20
21
|
snapType: snapType,
|
|
21
|
-
parentNode: parentNode
|
|
22
|
+
parentNode: parentNode,
|
|
23
|
+
inputMethod: inputMethod
|
|
22
24
|
},
|
|
23
25
|
eventType: EVENT_TYPE.UI
|
|
24
26
|
};
|
|
@@ -30,7 +32,8 @@ export var getMediaInputResizeAnalyticsEvent = function getMediaInputResizeAnaly
|
|
|
30
32
|
var width = attributes.width,
|
|
31
33
|
layout = attributes.layout,
|
|
32
34
|
validation = attributes.validation,
|
|
33
|
-
parentNode = attributes.parentNode
|
|
35
|
+
parentNode = attributes.parentNode,
|
|
36
|
+
inputMethod = attributes.inputMethod;
|
|
34
37
|
var actionSubject = type === 'embed' ? ACTION_SUBJECT.EMBEDS : ACTION_SUBJECT.MEDIA_SINGLE;
|
|
35
38
|
return {
|
|
36
39
|
action: ACTION.EDITED,
|
|
@@ -40,7 +43,8 @@ export var getMediaInputResizeAnalyticsEvent = function getMediaInputResizeAnaly
|
|
|
40
43
|
width: width,
|
|
41
44
|
layout: layout,
|
|
42
45
|
validation: validation,
|
|
43
|
-
parentNode: parentNode
|
|
46
|
+
parentNode: parentNode,
|
|
47
|
+
inputMethod: inputMethod
|
|
44
48
|
},
|
|
45
49
|
eventType: EVENT_TYPE.UI
|
|
46
50
|
};
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
5
|
import type { EditorSelectionAPI } from '@atlaskit/editor-plugin-selection';
|
|
6
|
+
import type { MediaNextEditorPluginType } from '../next-plugin-type';
|
|
4
7
|
import type { MediaOptions } from '../types';
|
|
5
|
-
|
|
8
|
+
type WidthPlugin = ExtractInjectionAPI<MediaNextEditorPluginType>['width'];
|
|
9
|
+
export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorSelectionAPI: EditorSelectionAPI | undefined, widthPlugin: WidthPlugin | undefined, getIntl: () => IntlShape): SafePlugin;
|
|
6
10
|
export default keymapPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const mediaResizeAnnouncerMess: {
|
|
2
|
+
MediaWidthIsMax: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
MediaWidthIsMin: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
DefaultMediaWidth: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
IncreasedAction: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
DecreasedAction: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BorderMarkAttributes, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EventInput } from '../pm-plugins/types';
|
|
4
5
|
import type { PixelEntryValidation } from '../ui/PixelEntry/types';
|
|
5
6
|
export declare const DEFAULT_BORDER_COLOR = "#091e4224";
|
|
6
7
|
export declare const DEFAULT_BORDER_SIZE = 2;
|
|
@@ -9,4 +10,4 @@ export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyti
|
|
|
9
10
|
export declare const removeInlineCard: Command;
|
|
10
11
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
12
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
12
|
-
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, layout: RichMediaLayout) => Command;
|
|
13
|
+
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
+
import type { IntlShape } from 'react-intl-next';
|
|
1
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
5
|
import type { EditorSelectionAPI } from '@atlaskit/editor-plugin-selection';
|
|
6
|
+
import type { MediaNextEditorPluginType } from '../next-plugin-type';
|
|
4
7
|
import type { MediaOptions } from '../types';
|
|
5
|
-
|
|
8
|
+
type WidthPlugin = ExtractInjectionAPI<MediaNextEditorPluginType>['width'];
|
|
9
|
+
export declare function keymapPlugin(options: MediaOptions | undefined, editorAnalyticsAPI: EditorAnalyticsAPI | undefined, editorSelectionAPI: EditorSelectionAPI | undefined, widthPlugin: WidthPlugin | undefined, getIntl: () => IntlShape): SafePlugin;
|
|
6
10
|
export default keymapPlugin;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const mediaResizeAnnouncerMess: {
|
|
2
|
+
MediaWidthIsMax: {
|
|
3
|
+
id: string;
|
|
4
|
+
defaultMessage: string;
|
|
5
|
+
description: string;
|
|
6
|
+
};
|
|
7
|
+
MediaWidthIsMin: {
|
|
8
|
+
id: string;
|
|
9
|
+
defaultMessage: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
DefaultMediaWidth: {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultMessage: string;
|
|
15
|
+
description: string;
|
|
16
|
+
};
|
|
17
|
+
IncreasedAction: {
|
|
18
|
+
id: string;
|
|
19
|
+
defaultMessage: string;
|
|
20
|
+
description: string;
|
|
21
|
+
};
|
|
22
|
+
DecreasedAction: {
|
|
23
|
+
id: string;
|
|
24
|
+
defaultMessage: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { BorderMarkAttributes, RichMediaLayout } from '@atlaskit/adf-schema';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EventInput } from '../pm-plugins/types';
|
|
4
5
|
import type { PixelEntryValidation } from '../ui/PixelEntry/types';
|
|
5
6
|
export declare const DEFAULT_BORDER_COLOR = "#091e4224";
|
|
6
7
|
export declare const DEFAULT_BORDER_SIZE = 2;
|
|
@@ -9,4 +10,4 @@ export declare const changeMediaCardToInline: (editorAnalyticsAPI: EditorAnalyti
|
|
|
9
10
|
export declare const removeInlineCard: Command;
|
|
10
11
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
11
12
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
12
|
-
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, layout: RichMediaLayout) => Command;
|
|
13
|
+
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-media",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Media plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^35.0.0",
|
|
36
36
|
"@atlaskit/analytics-namespaced-context": "^6.7.0",
|
|
37
37
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
38
|
-
"@atlaskit/button": "^16.
|
|
38
|
+
"@atlaskit/button": "^16.18.0",
|
|
39
39
|
"@atlaskit/editor-common": "^76.25.0",
|
|
40
40
|
"@atlaskit/editor-palette": "1.5.2",
|
|
41
41
|
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
@@ -143,6 +143,9 @@
|
|
|
143
143
|
},
|
|
144
144
|
"platform.editor.a11y-media_er96o": {
|
|
145
145
|
"type": "boolean"
|
|
146
|
+
},
|
|
147
|
+
"platform.editor.a11y-media-resizing_b5v0o": {
|
|
148
|
+
"type": "boolean"
|
|
146
149
|
}
|
|
147
150
|
},
|
|
148
151
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0"
|