@atlaskit/editor-plugin-media 2.3.8 → 2.3.9
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 +9 -0
- package/dist/cjs/mediaPlugin.js +7 -0
- package/dist/cjs/pm-plugins/pixel-resizing/commands.js +22 -0
- package/dist/cjs/pm-plugins/pixel-resizing/index.js +31 -0
- package/dist/cjs/pm-plugins/pixel-resizing/reducer.js +28 -0
- package/dist/cjs/pm-plugins/pixel-resizing/ui/constants.js +11 -0
- package/dist/cjs/pm-plugins/pixel-resizing/ui/index.js +124 -0
- package/dist/cjs/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +168 -13
- package/dist/cjs/ui/toolbar/commands.js +29 -22
- package/dist/cjs/ui/toolbar/index.js +55 -94
- package/dist/cjs/ui/toolbar/linking.js +1 -1
- package/dist/cjs/ui/toolbar/pixel-resizing.js +47 -0
- package/dist/es2019/mediaPlugin.js +7 -0
- package/dist/es2019/pm-plugins/pixel-resizing/commands.js +16 -0
- package/dist/es2019/pm-plugins/pixel-resizing/index.js +27 -0
- package/dist/es2019/pm-plugins/pixel-resizing/reducer.js +20 -0
- package/dist/es2019/pm-plugins/pixel-resizing/ui/constants.js +5 -0
- package/dist/es2019/pm-plugins/pixel-resizing/ui/index.js +126 -0
- package/dist/es2019/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +170 -19
- package/dist/es2019/ui/toolbar/commands.js +9 -2
- package/dist/es2019/ui/toolbar/index.js +47 -88
- package/dist/es2019/ui/toolbar/linking.js +1 -1
- package/dist/es2019/ui/toolbar/pixel-resizing.js +37 -0
- package/dist/esm/mediaPlugin.js +7 -0
- package/dist/esm/pm-plugins/pixel-resizing/commands.js +16 -0
- package/dist/esm/pm-plugins/pixel-resizing/index.js +25 -0
- package/dist/esm/pm-plugins/pixel-resizing/reducer.js +21 -0
- package/dist/esm/pm-plugins/pixel-resizing/ui/constants.js +5 -0
- package/dist/esm/pm-plugins/pixel-resizing/ui/index.js +120 -0
- package/dist/esm/{ui/PixelEntry/index.js → pm-plugins/pixel-resizing/ui/pixel-entry.js} +172 -17
- package/dist/esm/ui/toolbar/commands.js +28 -21
- package/dist/esm/ui/toolbar/index.js +47 -86
- package/dist/esm/ui/toolbar/linking.js +1 -1
- package/dist/esm/ui/toolbar/pixel-resizing.js +40 -0
- package/dist/types/pm-plugins/pixel-resizing/commands.d.ts +4 -0
- package/dist/types/pm-plugins/pixel-resizing/index.d.ts +13 -0
- package/dist/types/pm-plugins/pixel-resizing/reducer.d.ts +12 -0
- package/dist/types/pm-plugins/pixel-resizing/ui/constants.d.ts +3 -0
- package/dist/types/pm-plugins/pixel-resizing/ui/index.d.ts +21 -0
- package/dist/types/pm-plugins/pixel-resizing/ui/pixel-entry.d.ts +4 -0
- package/dist/types/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.d.ts +18 -0
- package/dist/types/ui/toolbar/commands.d.ts +2 -1
- package/dist/types/ui/toolbar/pixel-resizing.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/commands.d.ts +4 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/index.d.ts +13 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/reducer.d.ts +12 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/constants.d.ts +3 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/index.d.ts +21 -0
- package/dist/types-ts4.5/pm-plugins/pixel-resizing/ui/pixel-entry.d.ts +4 -0
- package/dist/types-ts4.5/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.d.ts +18 -0
- package/dist/types-ts4.5/ui/toolbar/commands.d.ts +2 -1
- package/dist/types-ts4.5/ui/toolbar/pixel-resizing.d.ts +4 -0
- package/package.json +5 -5
- package/dist/cjs/ui/PixelEntry/constants.js +0 -7
- package/dist/es2019/ui/PixelEntry/constants.js +0 -1
- package/dist/esm/ui/PixelEntry/constants.js +0 -1
- package/dist/types/ui/PixelEntry/constants.d.ts +0 -1
- package/dist/types/ui/PixelEntry/index.d.ts +0 -7
- package/dist/types-ts4.5/ui/PixelEntry/constants.d.ts +0 -1
- package/dist/types-ts4.5/ui/PixelEntry/index.d.ts +0 -7
- /package/dist/cjs/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
- /package/dist/cjs/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
- /package/dist/es2019/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
- /package/dist/es2019/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
- /package/dist/esm/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.js +0 -0
- /package/dist/esm/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/types.js +0 -0
- /package/dist/types/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.d.ts +0 -0
- /package/dist/types-ts4.5/{ui/PixelEntry → pm-plugins/pixel-resizing/ui}/styles.d.ts +0 -0
|
@@ -14,11 +14,9 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
14
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
15
15
|
var _media = require("@atlaskit/editor-common/media");
|
|
16
16
|
var _mediaInline = require("@atlaskit/editor-common/media-inline");
|
|
17
|
-
var _mediaSingle = require("@atlaskit/editor-common/media-single");
|
|
18
17
|
var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
|
|
19
18
|
var _state2 = require("@atlaskit/editor-prosemirror/state");
|
|
20
19
|
var _utils = require("@atlaskit/editor-prosemirror/utils");
|
|
21
|
-
var _editorSharedStyles = require("@atlaskit/editor-shared-styles");
|
|
22
20
|
var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
|
|
23
21
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
24
22
|
var _growDiagonal = _interopRequireDefault(require("@atlaskit/icon/core/grow-diagonal"));
|
|
@@ -40,19 +38,22 @@ var _altText = require("../../pm-plugins/alt-text");
|
|
|
40
38
|
var _commands = require("../../pm-plugins/alt-text/commands");
|
|
41
39
|
var _linking = require("../../pm-plugins/commands/linking");
|
|
42
40
|
var _linking2 = require("../../pm-plugins/linking");
|
|
41
|
+
var _pixelResizing = require("../../pm-plugins/pixel-resizing");
|
|
42
|
+
var _commands2 = require("../../pm-plugins/pixel-resizing/commands");
|
|
43
|
+
var _ui = require("../../pm-plugins/pixel-resizing/ui");
|
|
43
44
|
var _pluginKey = require("../../pm-plugins/plugin-key");
|
|
44
45
|
var _currentMediaNode = require("../../pm-plugins/utils/current-media-node");
|
|
45
|
-
var
|
|
46
|
+
var _mediaSingle = require("../../pm-plugins/utils/media-single");
|
|
46
47
|
var _ImageBorder = _interopRequireDefault(require("../../ui/ImageBorder"));
|
|
47
|
-
var _PixelEntry = require("../../ui/PixelEntry");
|
|
48
48
|
var _altText2 = require("./alt-text");
|
|
49
|
-
var
|
|
49
|
+
var _commands3 = require("./commands");
|
|
50
50
|
var _comments = require("./comments");
|
|
51
51
|
var _imageBorder = require("./imageBorder");
|
|
52
52
|
var _layoutGroup = require("./layout-group");
|
|
53
53
|
var _linking3 = require("./linking");
|
|
54
54
|
var _linkingToolbarAppearance = require("./linking-toolbar-appearance");
|
|
55
55
|
var _mediaInline2 = require("./mediaInline");
|
|
56
|
+
var _pixelResizing2 = require("./pixel-resizing");
|
|
56
57
|
var _utils2 = require("./utils");
|
|
57
58
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
58
59
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -104,7 +105,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
104
105
|
selected: false,
|
|
105
106
|
focusEditoronEnter: true,
|
|
106
107
|
disabled: false,
|
|
107
|
-
onClick: (0,
|
|
108
|
+
onClick: (0, _commands3.changeMediaCardToInline)(editorAnalyticsAPI, forceFocusSelector),
|
|
108
109
|
title: intl.formatMessage(_messages.cardMessages.inlineTitle),
|
|
109
110
|
testId: 'inline-appearance',
|
|
110
111
|
className: 'inline-appearance' // a11y. uses to force focus on item
|
|
@@ -211,11 +212,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
211
212
|
return /*#__PURE__*/_react.default.createElement(_ImageBorder.default, {
|
|
212
213
|
toggleBorder: function toggleBorder() {
|
|
213
214
|
var _pluginInjectionApi$a;
|
|
214
|
-
(0,
|
|
215
|
+
(0, _commands3.toggleBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions)(state, dispatch);
|
|
215
216
|
},
|
|
216
217
|
setBorder: function setBorder(attrs) {
|
|
217
218
|
var _pluginInjectionApi$a2;
|
|
218
|
-
(0,
|
|
219
|
+
(0, _commands3.setBorderMark)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.actions)(attrs)(state, dispatch);
|
|
219
220
|
},
|
|
220
221
|
borderMark: borderMark,
|
|
221
222
|
intl: intl
|
|
@@ -298,7 +299,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
298
299
|
LEGACY_fallbackIcon: _card.IconInline
|
|
299
300
|
});
|
|
300
301
|
},
|
|
301
|
-
onClick: (0,
|
|
302
|
+
onClick: (0, _commands3.changeMediaSingleToMediaInline)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a4 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a4 === void 0 ? void 0 : _pluginInjectionApi$a4.actions),
|
|
302
303
|
testId: 'image-inline-appearance'
|
|
303
304
|
}, {
|
|
304
305
|
type: 'button',
|
|
@@ -326,7 +327,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
326
327
|
var _options2 = [{
|
|
327
328
|
id: 'editor.media.convert.mediainline',
|
|
328
329
|
title: inlineSwitcherTitle,
|
|
329
|
-
onClick: (0,
|
|
330
|
+
onClick: (0, _commands3.changeMediaSingleToMediaInline)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a5 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a5 === void 0 ? void 0 : _pluginInjectionApi$a5.actions),
|
|
330
331
|
icon: /*#__PURE__*/_react.default.createElement(_imageInline.default, {
|
|
331
332
|
color: "currentColor",
|
|
332
333
|
spacing: "spacious",
|
|
@@ -382,69 +383,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
382
383
|
type: 'custom',
|
|
383
384
|
fallback: [],
|
|
384
385
|
render: function render(editorView) {
|
|
385
|
-
var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
|
|
386
386
|
if (!editorView || !selectedMediaSingleNode) {
|
|
387
387
|
return null;
|
|
388
388
|
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || _editorSharedStyles.akEditorDefaultLayoutWidth;
|
|
392
|
-
var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
393
|
-
if (!selectedMediaNode) {
|
|
394
|
-
return null;
|
|
395
|
-
}
|
|
396
|
-
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
397
|
-
mediaSingleWidth = _selectedMediaSingleN.width,
|
|
398
|
-
widthType = _selectedMediaSingleN.widthType,
|
|
399
|
-
layout = _selectedMediaSingleN.layout;
|
|
400
|
-
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
401
|
-
mediaWidth = _selectedMediaNode$at.width,
|
|
402
|
-
mediaHeight = _selectedMediaNode$at.height;
|
|
403
|
-
var maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 || (_pluginInjectionApi$m = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m === void 0 ? void 0 : _pluginInjectionApi$m.currentMaxWidth;
|
|
404
|
-
var maxWidth = maxWidthForNestedNode || _editorSharedStyles.akEditorFullWidthLayoutWidth;
|
|
405
|
-
var isVideoFile = (0, _mediaSingle2.isVideo)(selectedMediaNode.attrs.__fileMimeType);
|
|
406
|
-
var minWidth = (0, _mediaSingle.calcMinWidth)(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
407
|
-
var hasPixelType = widthType === 'pixel';
|
|
408
|
-
var pixelWidthFromElement = (0, _utils2.getPixelWidthOfElement)(editorView, selectedMediaSingleNode.pos + 1,
|
|
409
|
-
// get pos of media node
|
|
410
|
-
mediaWidth || _mediaSingle.DEFAULT_IMAGE_WIDTH);
|
|
411
|
-
var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
412
|
-
|
|
413
|
-
//hasParentNode will return falsey value if selection depth === 0
|
|
414
|
-
var isNested = (0, _utils.hasParentNode)(function (n) {
|
|
415
|
-
return n.type !== state.schema.nodes.doc;
|
|
416
|
-
})(state.selection);
|
|
417
|
-
return /*#__PURE__*/_react.default.createElement(_PixelEntry.PixelEntry, {
|
|
389
|
+
return /*#__PURE__*/_react.default.createElement(_ui.PixelEntry, {
|
|
390
|
+
editorView: editorView,
|
|
418
391
|
intl: intl,
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
maxWidth: maxWidth,
|
|
425
|
-
onChange: function onChange(valid) {
|
|
426
|
-
if (valid) {
|
|
427
|
-
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
428
|
-
} else {
|
|
429
|
-
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
430
|
-
}
|
|
431
|
-
},
|
|
432
|
-
onSubmit: function onSubmit(_ref3) {
|
|
433
|
-
var _pluginInjectionApi$a6;
|
|
434
|
-
var width = _ref3.width,
|
|
435
|
-
validation = _ref3.validation;
|
|
436
|
-
var newLayout = (0, _utils2.calcNewLayout)(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
437
|
-
(0, _commands2.updateMediaSingleWidth)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
438
|
-
},
|
|
439
|
-
onMigrate: function onMigrate() {
|
|
440
|
-
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
441
|
-
width: pixelWidthFromElement,
|
|
442
|
-
widthType: 'pixel'
|
|
443
|
-
}));
|
|
444
|
-
tr.setMeta('scrollIntoView', false);
|
|
445
|
-
tr.setSelection(_state2.NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
446
|
-
dispatch(tr);
|
|
447
|
-
}
|
|
392
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
393
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
394
|
+
pluginState: pluginState,
|
|
395
|
+
hoverDecoration: hoverDecoration,
|
|
396
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
448
397
|
});
|
|
449
398
|
}
|
|
450
399
|
};
|
|
@@ -460,7 +409,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
460
409
|
type: 'custom',
|
|
461
410
|
fallback: [],
|
|
462
411
|
render: function render() {
|
|
463
|
-
return /*#__PURE__*/_react.default.createElement(
|
|
412
|
+
return /*#__PURE__*/_react.default.createElement(_ui.FullWidthDisplay, {
|
|
464
413
|
intl: intl
|
|
465
414
|
});
|
|
466
415
|
}
|
|
@@ -498,10 +447,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
498
447
|
};
|
|
499
448
|
var openLink = function openLink() {
|
|
500
449
|
if (editorView) {
|
|
501
|
-
var _pluginInjectionApi$
|
|
450
|
+
var _pluginInjectionApi$a6;
|
|
502
451
|
var tr = editorView.state.tr,
|
|
503
452
|
dispatch = editorView.dispatch;
|
|
504
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
453
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
505
454
|
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
506
455
|
action: _analytics.ACTION.VISITED,
|
|
507
456
|
actionSubject: _analytics.ACTION_SUBJECT.MEDIA,
|
|
@@ -532,7 +481,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
532
481
|
var _mediaNode$attrs;
|
|
533
482
|
var _selectedMediaSingleNode = (0, _utils2.getSelectedMediaSingle)(state);
|
|
534
483
|
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
535
|
-
if (!(0,
|
|
484
|
+
if (!(0, _mediaSingle.isVideo)(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
536
485
|
var _pluginInjectionApi$c2;
|
|
537
486
|
toolbarButtons.push({
|
|
538
487
|
id: 'editor.media.viewer',
|
|
@@ -575,8 +524,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
575
524
|
});
|
|
576
525
|
}
|
|
577
526
|
if (allowAltTextOnImages && (0, _experiments.editorExperiment)('platform_editor_controls', 'control')) {
|
|
578
|
-
var _pluginInjectionApi$
|
|
579
|
-
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
527
|
+
var _pluginInjectionApi$a7;
|
|
528
|
+
toolbarButtons.push((0, _altText2.altTextButton)(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
580
529
|
type: 'separator'
|
|
581
530
|
});
|
|
582
531
|
}
|
|
@@ -602,7 +551,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
602
551
|
var _mediaNode$attrs2;
|
|
603
552
|
var _selectedMediaSingleNode2 = (0, _utils2.getSelectedMediaSingle)(state);
|
|
604
553
|
var _mediaNode = _selectedMediaSingleNode2 === null || _selectedMediaSingleNode2 === void 0 ? void 0 : _selectedMediaSingleNode2.node.content.firstChild;
|
|
605
|
-
if (!(0,
|
|
554
|
+
if (!(0, _mediaSingle.isVideo)(_mediaNode === null || _mediaNode === void 0 || (_mediaNode$attrs2 = _mediaNode.attrs) === null || _mediaNode$attrs2 === void 0 ? void 0 : _mediaNode$attrs2.__fileMimeType)) {
|
|
606
555
|
var _pluginInjectionApi$c3;
|
|
607
556
|
toolbarButtons.push({
|
|
608
557
|
id: 'editor.media.viewer',
|
|
@@ -691,11 +640,13 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
691
640
|
providerFactory = options.providerFactory,
|
|
692
641
|
allowMediaInline = options.allowMediaInline,
|
|
693
642
|
allowResizing = options.allowResizing,
|
|
694
|
-
isViewOnly = options.isViewOnly
|
|
643
|
+
isViewOnly = options.isViewOnly,
|
|
644
|
+
allowResizingInTables = options.allowResizingInTables,
|
|
645
|
+
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions;
|
|
695
646
|
var mediaPluginState = _pluginKey.stateKey.getState(state);
|
|
696
647
|
var mediaLinkingState = (0, _linking2.getMediaLinkingState)(state);
|
|
697
|
-
var
|
|
698
|
-
hoverDecoration =
|
|
648
|
+
var _ref3 = (_pluginInjectionApi$d3 = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$d4 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions) !== null && _pluginInjectionApi$d3 !== void 0 ? _pluginInjectionApi$d3 : {},
|
|
649
|
+
hoverDecoration = _ref3.hoverDecoration;
|
|
699
650
|
if (!mediaPluginState) {
|
|
700
651
|
return;
|
|
701
652
|
}
|
|
@@ -723,6 +674,20 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
723
674
|
});
|
|
724
675
|
}
|
|
725
676
|
}
|
|
677
|
+
var selection = state.selection;
|
|
678
|
+
var isWithinTable = (0, _utils.hasParentNodeOfType)([state.schema.nodes.table])(selection);
|
|
679
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1') && (0, _platformFeatureFlags.fg)('platform_editor_media_extended_resize_experience')) {
|
|
680
|
+
var mediaPixelResizingPluginState = (0, _pixelResizing.getPluginState)(state);
|
|
681
|
+
if (mediaPixelResizingPluginState !== null && mediaPixelResizingPluginState !== void 0 && mediaPixelResizingPluginState.isPixelEditorOpen) {
|
|
682
|
+
return (0, _pixelResizing2.getPixelResizingToolbar)(baseToolbar, {
|
|
683
|
+
intl: intl,
|
|
684
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
685
|
+
pluginState: mediaPluginState,
|
|
686
|
+
hoverDecoration: hoverDecoration,
|
|
687
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
688
|
+
});
|
|
689
|
+
}
|
|
690
|
+
}
|
|
726
691
|
var items = [];
|
|
727
692
|
var parentMediaGroupNode = (0, _utils.findParentNodeOfType)(mediaGroup)(state.selection);
|
|
728
693
|
var selectedNodeType;
|
|
@@ -730,7 +695,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
730
695
|
selectedNodeType = state.selection.node.type;
|
|
731
696
|
}
|
|
732
697
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
733
|
-
var _pluginInjectionApi$
|
|
698
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f2;
|
|
734
699
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
735
700
|
baseToolbar.getDomRef = function () {
|
|
736
701
|
var _mediaPluginState$ele;
|
|
@@ -739,7 +704,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
739
704
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
740
705
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
741
706
|
};
|
|
742
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
707
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f2 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f2 === void 0 || (_pluginInjectionApi$f2 = _pluginInjectionApi$f2.actions) === null || _pluginInjectionApi$f2 === void 0 ? void 0 : _pluginInjectionApi$f2.forceFocusSelector, isViewOnly);
|
|
743
708
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
744
709
|
items = (0, _mediaInline2.generateMediaInlineFloatingToolbar)(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options);
|
|
745
710
|
} else {
|
|
@@ -753,7 +718,7 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
753
718
|
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi);
|
|
754
719
|
}
|
|
755
720
|
if (!mediaPluginState.isResizing && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1')) {
|
|
756
|
-
var _pluginInjectionApi$
|
|
721
|
+
var _pluginInjectionApi$a9;
|
|
757
722
|
var lastItem = items.at(-1);
|
|
758
723
|
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === 'separator') {
|
|
759
724
|
lastItem.fullHeight = true;
|
|
@@ -768,21 +733,17 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
768
733
|
type: 'overflow-dropdown',
|
|
769
734
|
options: [].concat((0, _toConsumableArray2.default)((0, _linking3.getLinkingDropdownOptions)(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly)), [{
|
|
770
735
|
title: altTextTitle,
|
|
771
|
-
onClick: (0, _commands.openMediaAltTextMenu)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
736
|
+
onClick: (0, _commands.openMediaAltTextMenu)(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions),
|
|
772
737
|
icon: /*#__PURE__*/_react.default.createElement(_text.default, {
|
|
773
|
-
label:
|
|
738
|
+
label: ""
|
|
774
739
|
})
|
|
775
740
|
}, {
|
|
776
741
|
title: 'Resize',
|
|
777
|
-
onClick:
|
|
778
|
-
// Ignored via go/ees007
|
|
779
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
780
|
-
// TODO open resize dialog?
|
|
781
|
-
return true;
|
|
782
|
-
},
|
|
742
|
+
onClick: (0, _commands2.openPixelEditor)(),
|
|
783
743
|
icon: /*#__PURE__*/_react.default.createElement(_growHorizontal.default, {
|
|
784
|
-
label: "
|
|
785
|
-
})
|
|
744
|
+
label: ""
|
|
745
|
+
}),
|
|
746
|
+
testId: 'media-pixel-resizing-dropdown-option'
|
|
786
747
|
}, {
|
|
787
748
|
type: 'separator'
|
|
788
749
|
}, {
|
|
@@ -794,13 +755,13 @@ var floatingToolbar = exports.floatingToolbar = function floatingToolbar(state,
|
|
|
794
755
|
return true;
|
|
795
756
|
},
|
|
796
757
|
icon: /*#__PURE__*/_react.default.createElement(_copy.default, {
|
|
797
|
-
label: "
|
|
758
|
+
label: ""
|
|
798
759
|
})
|
|
799
760
|
}, {
|
|
800
761
|
title: 'Delete',
|
|
801
762
|
onClick: remove,
|
|
802
763
|
icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
|
|
803
|
-
label: "
|
|
764
|
+
label: ""
|
|
804
765
|
})
|
|
805
766
|
}])
|
|
806
767
|
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getPixelResizingToolbar = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _ui = require("../../pm-plugins/pixel-resizing/ui");
|
|
11
|
+
var _constants = require("../../pm-plugins/pixel-resizing/ui/constants");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
+
var getPixelResizingToolbar = exports.getPixelResizingToolbar = function getPixelResizingToolbar(toolbarBaseConfig, _ref) {
|
|
16
|
+
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
17
|
+
intl = _ref.intl,
|
|
18
|
+
pluginState = _ref.pluginState,
|
|
19
|
+
hoverDecoration = _ref.hoverDecoration,
|
|
20
|
+
isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled;
|
|
21
|
+
return _objectSpread(_objectSpread({}, toolbarBaseConfig), {}, {
|
|
22
|
+
width: _constants.PIXEL_RESIZING_TOOLBAR_WIDTH,
|
|
23
|
+
scrollable: true,
|
|
24
|
+
items: [{
|
|
25
|
+
type: 'custom',
|
|
26
|
+
fallback: [],
|
|
27
|
+
render: function render(editorView) {
|
|
28
|
+
if (!editorView) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
var selectedMediaSingleNode = (0, _utils.getSelectedMediaSingle)(editorView.state);
|
|
32
|
+
if (!editorView || !selectedMediaSingleNode) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement(_ui.PixelEntry, {
|
|
36
|
+
editorView: editorView,
|
|
37
|
+
intl: intl,
|
|
38
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
39
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
40
|
+
pluginState: pluginState,
|
|
41
|
+
hoverDecoration: hoverDecoration,
|
|
42
|
+
isEditorFullWidthEnabled: isEditorFullWidthEnabled
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
@@ -24,6 +24,7 @@ import keymapMediaSinglePlugin from './pm-plugins/keymap-media';
|
|
|
24
24
|
import linkingPlugin from './pm-plugins/linking';
|
|
25
25
|
import keymapLinkingPlugin from './pm-plugins/linking/keymap';
|
|
26
26
|
import { createPlugin } from './pm-plugins/main';
|
|
27
|
+
import { createPlugin as createMediaPixelResizingPlugin } from './pm-plugins/pixel-resizing';
|
|
27
28
|
import { stateKey } from './pm-plugins/plugin-key';
|
|
28
29
|
import { createMediaIdentifierArray, extractMediaNodes } from './pm-plugins/utils/media-common';
|
|
29
30
|
import { insertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
|
|
@@ -236,6 +237,12 @@ export const mediaPlugin = ({
|
|
|
236
237
|
}) => keymapLinkingPlugin(schema)
|
|
237
238
|
});
|
|
238
239
|
}
|
|
240
|
+
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_media_extended_resize_experience')) {
|
|
241
|
+
pmPlugins.push({
|
|
242
|
+
name: 'mediaPixelResizing',
|
|
243
|
+
plugin: createMediaPixelResizingPlugin
|
|
244
|
+
});
|
|
245
|
+
}
|
|
239
246
|
pmPlugins.push({
|
|
240
247
|
name: 'mediaSelectionHandler',
|
|
241
248
|
plugin: () => {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createCommand } from './index';
|
|
2
|
+
export const openPixelEditor = () => {
|
|
3
|
+
return createCommand({
|
|
4
|
+
type: 'openPixelEditor'
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export const closePixelEditor = () => {
|
|
8
|
+
return createCommand({
|
|
9
|
+
type: 'closePixelEditor'
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export const closePixelEditorAndSave = saveTransform => {
|
|
13
|
+
return createCommand({
|
|
14
|
+
type: 'closePixelEditor'
|
|
15
|
+
}, saveTransform);
|
|
16
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { pluginFactory } from '@atlaskit/editor-common/utils';
|
|
3
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
+
import reducer from './reducer';
|
|
5
|
+
const pluginKey = new PluginKey('mediaPixelResizingPlugin');
|
|
6
|
+
const {
|
|
7
|
+
createPluginState,
|
|
8
|
+
createCommand,
|
|
9
|
+
getPluginState
|
|
10
|
+
} = pluginFactory(pluginKey, reducer, {
|
|
11
|
+
onSelectionChanged() {
|
|
12
|
+
return {
|
|
13
|
+
isPixelEditorOpen: false
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
export const createPlugin = ({
|
|
18
|
+
dispatch
|
|
19
|
+
}) => {
|
|
20
|
+
return new SafePlugin({
|
|
21
|
+
state: createPluginState(dispatch, {
|
|
22
|
+
isPixelEditorOpen: false
|
|
23
|
+
}),
|
|
24
|
+
key: pluginKey
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
export { createCommand, getPluginState };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default ((state, action) => {
|
|
2
|
+
switch (action.type) {
|
|
3
|
+
case 'openPixelEditor':
|
|
4
|
+
{
|
|
5
|
+
return {
|
|
6
|
+
...state,
|
|
7
|
+
isPixelEditorOpen: true
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
case 'closePixelEditor':
|
|
11
|
+
{
|
|
12
|
+
return {
|
|
13
|
+
...state,
|
|
14
|
+
isPixelEditorOpen: false
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
default:
|
|
18
|
+
return state;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { useCallback } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
+
import { jsx } from '@emotion/react';
|
|
9
|
+
import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
|
|
10
|
+
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
11
|
+
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
12
|
+
import { hasParentNode } from '@atlaskit/editor-prosemirror/utils';
|
|
13
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
14
|
+
import { Text } from '@atlaskit/primitives';
|
|
15
|
+
import { updateMediaSingleWidthTr } from '../../../ui/toolbar/commands';
|
|
16
|
+
import { getPixelWidthOfElement, calcNewLayout } from '../../../ui/toolbar/utils';
|
|
17
|
+
import { isVideo } from '../../utils/media-single';
|
|
18
|
+
import { closePixelEditorAndSave } from '../commands';
|
|
19
|
+
import { PixelEntryComponent } from './pixel-entry';
|
|
20
|
+
import { pixelSizingFullWidthLabelStyles } from './styles';
|
|
21
|
+
export const PixelEntry = ({
|
|
22
|
+
editorView,
|
|
23
|
+
selectedMediaSingleNode,
|
|
24
|
+
pluginInjectionApi,
|
|
25
|
+
intl,
|
|
26
|
+
pluginState,
|
|
27
|
+
hoverDecoration,
|
|
28
|
+
isEditorFullWidthEnabled
|
|
29
|
+
}) => {
|
|
30
|
+
var _pluginInjectionApi$w, _pluginInjectionApi$m, _pluginInjectionApi$m2;
|
|
31
|
+
const {
|
|
32
|
+
state,
|
|
33
|
+
dispatch
|
|
34
|
+
} = editorView;
|
|
35
|
+
const {
|
|
36
|
+
mediaSingle
|
|
37
|
+
} = state.schema.nodes;
|
|
38
|
+
const contentWidth = (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$w = pluginInjectionApi.width.sharedState.currentState()) === null || _pluginInjectionApi$w === void 0 ? void 0 : _pluginInjectionApi$w.lineLength) || akEditorDefaultLayoutWidth;
|
|
39
|
+
const {
|
|
40
|
+
width: mediaSingleWidth,
|
|
41
|
+
widthType,
|
|
42
|
+
layout
|
|
43
|
+
} = selectedMediaSingleNode.node.attrs;
|
|
44
|
+
|
|
45
|
+
// hasParentNode will return falsey value if selection depth === 0
|
|
46
|
+
const isNested = hasParentNode(n => n.type !== state.schema.nodes.doc)(state.selection);
|
|
47
|
+
const updateNodeWithTr = useCallback((width, validation) => {
|
|
48
|
+
var _pluginInjectionApi$a;
|
|
49
|
+
const newLayout = calcNewLayout(width, layout, contentWidth, isEditorFullWidthEnabled, isNested);
|
|
50
|
+
return updateMediaSingleWidthTr(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, state, width, validation, 'floatingToolBar', newLayout);
|
|
51
|
+
}, [layout, contentWidth, isEditorFullWidthEnabled, isNested, state, pluginInjectionApi]);
|
|
52
|
+
const selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
53
|
+
if (!selectedMediaNode) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const {
|
|
57
|
+
width: mediaWidth,
|
|
58
|
+
height: mediaHeight
|
|
59
|
+
} = selectedMediaNode.attrs;
|
|
60
|
+
const maxWidthForNestedNode = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$m = pluginInjectionApi.media) === null || _pluginInjectionApi$m === void 0 ? void 0 : (_pluginInjectionApi$m2 = _pluginInjectionApi$m.sharedState.currentState()) === null || _pluginInjectionApi$m2 === void 0 ? void 0 : _pluginInjectionApi$m2.currentMaxWidth;
|
|
61
|
+
const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
62
|
+
const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
63
|
+
const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
64
|
+
const hasPixelType = widthType === 'pixel';
|
|
65
|
+
const pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
66
|
+
// get pos of media node
|
|
67
|
+
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
68
|
+
const pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
69
|
+
return jsx(PixelEntryComponent, {
|
|
70
|
+
intl: intl,
|
|
71
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
72
|
+
showMigration: !pluginState.isResizing && !hasPixelType,
|
|
73
|
+
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
74
|
+
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
75
|
+
minWidth: minWidth,
|
|
76
|
+
maxWidth: maxWidth,
|
|
77
|
+
onChange: valid => {
|
|
78
|
+
if (valid) {
|
|
79
|
+
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
80
|
+
} else {
|
|
81
|
+
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
onSubmit: ({
|
|
85
|
+
width,
|
|
86
|
+
validation
|
|
87
|
+
}) => {
|
|
88
|
+
const tr = updateNodeWithTr(width, validation);
|
|
89
|
+
if (tr) {
|
|
90
|
+
dispatch(tr);
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onMigrate: () => {
|
|
94
|
+
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
95
|
+
...selectedMediaSingleNode.node.attrs,
|
|
96
|
+
width: pixelWidthFromElement,
|
|
97
|
+
widthType: 'pixel'
|
|
98
|
+
});
|
|
99
|
+
tr.setMeta('scrollIntoView', false);
|
|
100
|
+
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
101
|
+
dispatch(tr);
|
|
102
|
+
},
|
|
103
|
+
onCloseAndSave: ({
|
|
104
|
+
width,
|
|
105
|
+
validation
|
|
106
|
+
}) => {
|
|
107
|
+
const tr = updateNodeWithTr(width, validation);
|
|
108
|
+
if (tr) {
|
|
109
|
+
return closePixelEditorAndSave(() => tr)(state, dispatch);
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
isViewMode: pluginState.isResizing
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
export const FullWidthDisplay = ({
|
|
116
|
+
intl: {
|
|
117
|
+
formatMessage
|
|
118
|
+
}
|
|
119
|
+
}) => {
|
|
120
|
+
return (
|
|
121
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
122
|
+
jsx("div", {
|
|
123
|
+
css: pixelSizingFullWidthLabelStyles
|
|
124
|
+
}, jsx(Text, null, formatMessage(messages.fullWidthLabel)))
|
|
125
|
+
);
|
|
126
|
+
};
|