@atlaskit/editor-plugin-media 2.3.7 → 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 +15 -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 +63 -97
- 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 +55 -91
- 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 +55 -89
- 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 +8 -8
- 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
|
@@ -8,11 +8,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
8
8
|
import { alignmentIcons, buildLayoutButtons, IconCard, IconEmbed, IconInline, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
9
9
|
import { altTextMessages } from '@atlaskit/editor-common/media';
|
|
10
10
|
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
11
|
-
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
12
11
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
13
12
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
14
|
-
import { contains, findParentNodeOfType,
|
|
15
|
-
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
13
|
+
import { contains, findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
16
14
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
17
15
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
18
16
|
import GrowDiagonalIcon from '@atlaskit/icon/core/grow-diagonal';
|
|
@@ -34,20 +32,23 @@ import { getPluginState as getMediaAltTextPluginState } from '../../pm-plugins/a
|
|
|
34
32
|
import { openMediaAltTextMenu } from '../../pm-plugins/alt-text/commands';
|
|
35
33
|
import { showLinkingToolbar } from '../../pm-plugins/commands/linking';
|
|
36
34
|
import { getMediaLinkingState } from '../../pm-plugins/linking';
|
|
35
|
+
import { getPluginState as getMediaPixelResizingPluginState } from '../../pm-plugins/pixel-resizing';
|
|
36
|
+
import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
|
|
37
|
+
import { FullWidthDisplay, PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
37
38
|
import { stateKey } from '../../pm-plugins/plugin-key';
|
|
38
39
|
import { currentMediaOrInlineNodeBorderMark } from '../../pm-plugins/utils/current-media-node';
|
|
39
40
|
import { isVideo } from '../../pm-plugins/utils/media-single';
|
|
40
41
|
import ImageBorderItem from '../../ui/ImageBorder';
|
|
41
|
-
import { FullWidthDisplay, PixelEntry } from '../../ui/PixelEntry';
|
|
42
42
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
43
|
-
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark
|
|
43
|
+
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark } from './commands';
|
|
44
44
|
import { commentButton } from './comments';
|
|
45
45
|
import { shouldShowImageBorder } from './imageBorder';
|
|
46
46
|
import { LayoutGroup } from './layout-group';
|
|
47
47
|
import { getLinkingDropdownOptions, getLinkingToolbar, getOpenLinkToolbarButtonOption, shouldShowMediaLinkToolbar } from './linking';
|
|
48
48
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
49
49
|
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
50
|
-
import {
|
|
50
|
+
import { getPixelResizingToolbar } from './pixel-resizing';
|
|
51
|
+
import { canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getSelectedLayoutIcon, getSelectedMediaSingle, getSelectedNearestMediaContainerNodeAttrs, removeMediaGroupNode } from './utils';
|
|
51
52
|
var mediaTypeMessages = {
|
|
52
53
|
image: messages.file_image_is_selected,
|
|
53
54
|
video: messages.file_video_is_selected,
|
|
@@ -79,7 +80,7 @@ export var handleShowMediaViewer = function handleShowMediaViewer(_ref) {
|
|
|
79
80
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
|
|
80
81
|
};
|
|
81
82
|
var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) {
|
|
82
|
-
var _mediaPluginState$med;
|
|
83
|
+
var _mediaPluginState$med, _pluginInjectionApi$c;
|
|
83
84
|
if (isViewOnly) {
|
|
84
85
|
return [];
|
|
85
86
|
}
|
|
@@ -128,6 +129,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
128
129
|
api: pluginInjectionApi
|
|
129
130
|
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
130
131
|
},
|
|
132
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c === void 0 || (_pluginInjectionApi$c = _pluginInjectionApi$c.currentState()) === null || _pluginInjectionApi$c === void 0 ? void 0 : _pluginInjectionApi$c.mode) === 'offline',
|
|
131
133
|
supportsViewMode: true
|
|
132
134
|
}, {
|
|
133
135
|
type: 'separator'
|
|
@@ -371,69 +373,17 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
371
373
|
type: 'custom',
|
|
372
374
|
fallback: [],
|
|
373
375
|
render: function render(editorView) {
|
|
374
|
-
var _widthPlugin$sharedSt2, _pluginInjectionApi$m;
|
|
375
376
|
if (!editorView || !selectedMediaSingleNode) {
|
|
376
377
|
return null;
|
|
377
378
|
}
|
|
378
|
-
var state = editorView.state,
|
|
379
|
-
dispatch = editorView.dispatch;
|
|
380
|
-
var contentWidth = (widthPlugin === null || widthPlugin === void 0 || (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
|
|
381
|
-
var selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
382
|
-
if (!selectedMediaNode) {
|
|
383
|
-
return null;
|
|
384
|
-
}
|
|
385
|
-
var _selectedMediaSingleN = selectedMediaSingleNode.node.attrs,
|
|
386
|
-
mediaSingleWidth = _selectedMediaSingleN.width,
|
|
387
|
-
widthType = _selectedMediaSingleN.widthType,
|
|
388
|
-
layout = _selectedMediaSingleN.layout;
|
|
389
|
-
var _selectedMediaNode$at = selectedMediaNode.attrs,
|
|
390
|
-
mediaWidth = _selectedMediaNode$at.width,
|
|
391
|
-
mediaHeight = _selectedMediaNode$at.height;
|
|
392
|
-
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;
|
|
393
|
-
var maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
394
|
-
var isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
395
|
-
var minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
396
|
-
var hasPixelType = widthType === 'pixel';
|
|
397
|
-
var pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
398
|
-
// get pos of media node
|
|
399
|
-
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
400
|
-
var pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
401
|
-
|
|
402
|
-
//hasParentNode will return falsey value if selection depth === 0
|
|
403
|
-
var isNested = hasParentNode(function (n) {
|
|
404
|
-
return n.type !== state.schema.nodes.doc;
|
|
405
|
-
})(state.selection);
|
|
406
379
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
380
|
+
editorView: editorView,
|
|
407
381
|
intl: intl,
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
maxWidth: maxWidth,
|
|
414
|
-
onChange: function onChange(valid) {
|
|
415
|
-
if (valid) {
|
|
416
|
-
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
417
|
-
} else {
|
|
418
|
-
hoverDecoration === null || hoverDecoration === void 0 || hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
419
|
-
}
|
|
420
|
-
},
|
|
421
|
-
onSubmit: function onSubmit(_ref3) {
|
|
422
|
-
var _pluginInjectionApi$a6;
|
|
423
|
-
var width = _ref3.width,
|
|
424
|
-
validation = _ref3.validation;
|
|
425
|
-
var newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
426
|
-
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);
|
|
427
|
-
},
|
|
428
|
-
onMigrate: function onMigrate() {
|
|
429
|
-
var tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, _objectSpread(_objectSpread({}, selectedMediaSingleNode.node.attrs), {}, {
|
|
430
|
-
width: pixelWidthFromElement,
|
|
431
|
-
widthType: 'pixel'
|
|
432
|
-
}));
|
|
433
|
-
tr.setMeta('scrollIntoView', false);
|
|
434
|
-
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
435
|
-
dispatch(tr);
|
|
436
|
-
}
|
|
382
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
383
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
384
|
+
pluginState: pluginState,
|
|
385
|
+
hoverDecoration: hoverDecoration,
|
|
386
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
437
387
|
});
|
|
438
388
|
}
|
|
439
389
|
};
|
|
@@ -487,10 +437,10 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
487
437
|
};
|
|
488
438
|
var openLink = function openLink() {
|
|
489
439
|
if (editorView) {
|
|
490
|
-
var _pluginInjectionApi$
|
|
440
|
+
var _pluginInjectionApi$a6;
|
|
491
441
|
var tr = editorView.state.tr,
|
|
492
442
|
dispatch = editorView.dispatch;
|
|
493
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
443
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 || _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
494
444
|
eventType: EVENT_TYPE.TRACK,
|
|
495
445
|
action: ACTION.VISITED,
|
|
496
446
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -522,6 +472,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
522
472
|
var _selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
523
473
|
var mediaNode = _selectedMediaSingleNode === null || _selectedMediaSingleNode === void 0 ? void 0 : _selectedMediaSingleNode.node.content.firstChild;
|
|
524
474
|
if (!isVideo(mediaNode === null || mediaNode === void 0 || (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
475
|
+
var _pluginInjectionApi$c2;
|
|
525
476
|
toolbarButtons.push({
|
|
526
477
|
id: 'editor.media.viewer',
|
|
527
478
|
testId: 'file-preview-toolbar-button',
|
|
@@ -536,6 +487,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
536
487
|
mediaPluginState: pluginState
|
|
537
488
|
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
538
489
|
},
|
|
490
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c2 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.sharedState) === null || _pluginInjectionApi$c2 === void 0 || (_pluginInjectionApi$c2 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : _pluginInjectionApi$c2.mode) === 'offline',
|
|
539
491
|
supportsViewMode: true
|
|
540
492
|
}, {
|
|
541
493
|
type: 'separator',
|
|
@@ -562,8 +514,8 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
562
514
|
});
|
|
563
515
|
}
|
|
564
516
|
if (allowAltTextOnImages && editorExperiment('platform_editor_controls', 'control')) {
|
|
565
|
-
var _pluginInjectionApi$
|
|
566
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
517
|
+
var _pluginInjectionApi$a7;
|
|
518
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
567
519
|
type: 'separator'
|
|
568
520
|
});
|
|
569
521
|
}
|
|
@@ -590,6 +542,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
590
542
|
var _selectedMediaSingleNode2 = getSelectedMediaSingle(state);
|
|
591
543
|
var _mediaNode = _selectedMediaSingleNode2 === null || _selectedMediaSingleNode2 === void 0 ? void 0 : _selectedMediaSingleNode2.node.content.firstChild;
|
|
592
544
|
if (!isVideo(_mediaNode === null || _mediaNode === void 0 || (_mediaNode$attrs2 = _mediaNode.attrs) === null || _mediaNode$attrs2 === void 0 ? void 0 : _mediaNode$attrs2.__fileMimeType)) {
|
|
545
|
+
var _pluginInjectionApi$c3;
|
|
593
546
|
toolbarButtons.push({
|
|
594
547
|
id: 'editor.media.viewer',
|
|
595
548
|
testId: 'file-preview-toolbar-button',
|
|
@@ -604,6 +557,7 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
604
557
|
mediaPluginState: pluginState
|
|
605
558
|
})) !== null && _handleShowMediaViewe3 !== void 0 ? _handleShowMediaViewe3 : false;
|
|
606
559
|
},
|
|
560
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c3 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.sharedState) === null || _pluginInjectionApi$c3 === void 0 || (_pluginInjectionApi$c3 = _pluginInjectionApi$c3.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode) === 'offline',
|
|
607
561
|
supportsViewMode: true
|
|
608
562
|
}, {
|
|
609
563
|
type: 'separator',
|
|
@@ -676,11 +630,13 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
676
630
|
providerFactory = options.providerFactory,
|
|
677
631
|
allowMediaInline = options.allowMediaInline,
|
|
678
632
|
allowResizing = options.allowResizing,
|
|
679
|
-
isViewOnly = options.isViewOnly
|
|
633
|
+
isViewOnly = options.isViewOnly,
|
|
634
|
+
allowResizingInTables = options.allowResizingInTables,
|
|
635
|
+
allowAdvancedToolBarOptions = options.allowAdvancedToolBarOptions;
|
|
680
636
|
var mediaPluginState = stateKey.getState(state);
|
|
681
637
|
var mediaLinkingState = getMediaLinkingState(state);
|
|
682
|
-
var
|
|
683
|
-
hoverDecoration =
|
|
638
|
+
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 : {},
|
|
639
|
+
hoverDecoration = _ref3.hoverDecoration;
|
|
684
640
|
if (!mediaPluginState) {
|
|
685
641
|
return;
|
|
686
642
|
}
|
|
@@ -708,6 +664,20 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
708
664
|
});
|
|
709
665
|
}
|
|
710
666
|
}
|
|
667
|
+
var selection = state.selection;
|
|
668
|
+
var isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
669
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_media_extended_resize_experience')) {
|
|
670
|
+
var mediaPixelResizingPluginState = getMediaPixelResizingPluginState(state);
|
|
671
|
+
if (mediaPixelResizingPluginState !== null && mediaPixelResizingPluginState !== void 0 && mediaPixelResizingPluginState.isPixelEditorOpen) {
|
|
672
|
+
return getPixelResizingToolbar(baseToolbar, {
|
|
673
|
+
intl: intl,
|
|
674
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
675
|
+
pluginState: mediaPluginState,
|
|
676
|
+
hoverDecoration: hoverDecoration,
|
|
677
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
678
|
+
});
|
|
679
|
+
}
|
|
680
|
+
}
|
|
711
681
|
var items = [];
|
|
712
682
|
var parentMediaGroupNode = findParentNodeOfType(mediaGroup)(state.selection);
|
|
713
683
|
var selectedNodeType;
|
|
@@ -715,7 +685,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
715
685
|
selectedNodeType = state.selection.node.type;
|
|
716
686
|
}
|
|
717
687
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
718
|
-
var _pluginInjectionApi$
|
|
688
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f2;
|
|
719
689
|
var mediaOffset = state.selection.$from.parentOffset + 1;
|
|
720
690
|
baseToolbar.getDomRef = function () {
|
|
721
691
|
var _mediaPluginState$ele;
|
|
@@ -724,7 +694,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
724
694
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
725
695
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
726
696
|
};
|
|
727
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
697
|
+
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);
|
|
728
698
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
729
699
|
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options);
|
|
730
700
|
} else {
|
|
@@ -738,7 +708,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
738
708
|
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi);
|
|
739
709
|
}
|
|
740
710
|
if (!mediaPluginState.isResizing && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
741
|
-
var _pluginInjectionApi$
|
|
711
|
+
var _pluginInjectionApi$a9;
|
|
742
712
|
var lastItem = items.at(-1);
|
|
743
713
|
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === 'separator') {
|
|
744
714
|
lastItem.fullHeight = true;
|
|
@@ -753,39 +723,35 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
753
723
|
type: 'overflow-dropdown',
|
|
754
724
|
options: [].concat(_toConsumableArray(getLinkingDropdownOptions(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly)), [{
|
|
755
725
|
title: altTextTitle,
|
|
756
|
-
onClick: openMediaAltTextMenu(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
726
|
+
onClick: openMediaAltTextMenu(pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions),
|
|
757
727
|
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
758
|
-
label:
|
|
728
|
+
label: ""
|
|
759
729
|
})
|
|
760
730
|
}, {
|
|
761
731
|
title: 'Resize',
|
|
762
|
-
onClick:
|
|
763
|
-
// Ignored via go/ees007
|
|
764
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
765
|
-
// TODO open resize dialog?
|
|
766
|
-
return true;
|
|
767
|
-
},
|
|
732
|
+
onClick: openPixelEditor(),
|
|
768
733
|
icon: /*#__PURE__*/React.createElement(GrowHorizontalIcon, {
|
|
769
|
-
label: "
|
|
770
|
-
})
|
|
734
|
+
label: ""
|
|
735
|
+
}),
|
|
736
|
+
testId: 'media-pixel-resizing-dropdown-option'
|
|
771
737
|
}, {
|
|
772
738
|
type: 'separator'
|
|
773
739
|
}, {
|
|
774
740
|
title: 'Copy',
|
|
775
741
|
onClick: function onClick() {
|
|
776
|
-
var _pluginInjectionApi$
|
|
777
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
742
|
+
var _pluginInjectionApi$c4, _pluginInjectionApi$f3;
|
|
743
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$c4 = pluginInjectionApi.core) === null || _pluginInjectionApi$c4 === void 0 || _pluginInjectionApi$c4.actions.execute( // @ts-ignore
|
|
778
744
|
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : _pluginInjectionApi$f3.commands.copyNode(nodeType));
|
|
779
745
|
return true;
|
|
780
746
|
},
|
|
781
747
|
icon: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
782
|
-
label: "
|
|
748
|
+
label: ""
|
|
783
749
|
})
|
|
784
750
|
}, {
|
|
785
751
|
title: 'Delete',
|
|
786
752
|
onClick: remove,
|
|
787
753
|
icon: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
788
|
-
label: "
|
|
754
|
+
label: ""
|
|
789
755
|
})
|
|
790
756
|
}])
|
|
791
757
|
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
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; }
|
|
3
|
+
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) { _defineProperty(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; }
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
6
|
+
import { PIXEL_RESIZING_TOOLBAR_WIDTH } from '../../pm-plugins/pixel-resizing/ui/constants';
|
|
7
|
+
import { getSelectedMediaSingle } from './utils';
|
|
8
|
+
export var getPixelResizingToolbar = function getPixelResizingToolbar(toolbarBaseConfig, _ref) {
|
|
9
|
+
var pluginInjectionApi = _ref.pluginInjectionApi,
|
|
10
|
+
intl = _ref.intl,
|
|
11
|
+
pluginState = _ref.pluginState,
|
|
12
|
+
hoverDecoration = _ref.hoverDecoration,
|
|
13
|
+
isEditorFullWidthEnabled = _ref.isEditorFullWidthEnabled;
|
|
14
|
+
return _objectSpread(_objectSpread({}, toolbarBaseConfig), {}, {
|
|
15
|
+
width: PIXEL_RESIZING_TOOLBAR_WIDTH,
|
|
16
|
+
scrollable: true,
|
|
17
|
+
items: [{
|
|
18
|
+
type: 'custom',
|
|
19
|
+
fallback: [],
|
|
20
|
+
render: function render(editorView) {
|
|
21
|
+
if (!editorView) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
var selectedMediaSingleNode = getSelectedMediaSingle(editorView.state);
|
|
25
|
+
if (!editorView || !selectedMediaSingleNode) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
29
|
+
editorView: editorView,
|
|
30
|
+
intl: intl,
|
|
31
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
32
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
33
|
+
pluginState: pluginState,
|
|
34
|
+
hoverDecoration: hoverDecoration,
|
|
35
|
+
isEditorFullWidthEnabled: isEditorFullWidthEnabled
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}]
|
|
39
|
+
});
|
|
40
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Transaction, EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const openPixelEditor: () => import("@atlaskit/editor-common/types").Command;
|
|
3
|
+
export declare const closePixelEditor: () => import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const closePixelEditorAndSave: (saveTransform: (tr: Transaction, state: EditorState) => Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
+
declare const createCommand: <A = {
|
|
4
|
+
type: "openPixelEditor";
|
|
5
|
+
} | {
|
|
6
|
+
type: "closePixelEditor";
|
|
7
|
+
}>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => {
|
|
8
|
+
isPixelEditorOpen: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const createPlugin: ({ dispatch }: PMPluginFactoryParams) => SafePlugin<{
|
|
11
|
+
isPixelEditorOpen: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export { createCommand, getPluginState };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type mediaPixelResizingState = {
|
|
2
|
+
isPixelEditorOpen: boolean;
|
|
3
|
+
};
|
|
4
|
+
type OpenPixelEditor = {
|
|
5
|
+
type: 'openPixelEditor';
|
|
6
|
+
};
|
|
7
|
+
type ClosePixelEditor = {
|
|
8
|
+
type: 'closePixelEditor';
|
|
9
|
+
};
|
|
10
|
+
type MediaPixelResizingAction = OpenPixelEditor | ClosePixelEditor;
|
|
11
|
+
declare const _default: (state: mediaPixelResizingState, action: MediaPixelResizingAction) => mediaPixelResizingState;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { MediaNextEditorPluginType } from '../../../mediaPluginType';
|
|
8
|
+
import { MediaPluginState } from '../../../types';
|
|
9
|
+
export type Props = {
|
|
10
|
+
editorView: EditorView;
|
|
11
|
+
selectedMediaSingleNode: ContentNodeWithPos;
|
|
12
|
+
pluginInjectionApi?: ExtractInjectionAPI<MediaNextEditorPluginType>;
|
|
13
|
+
intl: IntlShape;
|
|
14
|
+
pluginState: MediaPluginState;
|
|
15
|
+
hoverDecoration: HoverDecorationHandler | undefined;
|
|
16
|
+
isEditorFullWidthEnabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const PixelEntry: ({ editorView, selectedMediaSingleNode, pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Props) => jsx.JSX.Element | null;
|
|
19
|
+
export declare const FullWidthDisplay: ({ intl: { formatMessage } }: {
|
|
20
|
+
intl: IntlShape;
|
|
21
|
+
}) => jsx.JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { PixelEntryComponentNextProps, PixelEntryProps } from './types';
|
|
3
|
+
export declare const PixelEntryComponent: ({ width, mediaWidth, mediaHeight, onSubmit, minWidth, maxWidth, onChange, intl: { formatMessage }, showMigration, onMigrate, onCloseAndSave, isViewMode, }: PixelEntryProps) => jsx.JSX.Element;
|
|
4
|
+
export declare const PixelEntryComponentNext: ({ maxWidth, formatMessage, handleFieldChange, computedWidth, computedHeight, handleCloseAndSave, isViewMode, }: PixelEntryComponentNextProps) => jsx.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
1
2
|
import type { IntlShape } from 'react-intl-next';
|
|
2
3
|
export type PixelEntryProps = {
|
|
3
4
|
/**
|
|
@@ -46,6 +47,14 @@ export type PixelEntryProps = {
|
|
|
46
47
|
* Migration handler called when the CTA button is clicked
|
|
47
48
|
*/
|
|
48
49
|
onMigrate?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Called when the Enter key is pressed or close button is clicked
|
|
52
|
+
*/
|
|
53
|
+
onCloseAndSave?: (data: PixelEntryFormData) => void;
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
isViewMode?: boolean;
|
|
49
58
|
};
|
|
50
59
|
export type PixelEntryFormValues = {
|
|
51
60
|
inputWidth: number | '';
|
|
@@ -56,4 +65,13 @@ type PixelEntryFormData = {
|
|
|
56
65
|
width: number;
|
|
57
66
|
validation: PixelEntryValidation;
|
|
58
67
|
};
|
|
68
|
+
export type PixelEntryComponentNextProps = {
|
|
69
|
+
maxWidth: number;
|
|
70
|
+
computedWidth: number | '';
|
|
71
|
+
computedHeight: number | '';
|
|
72
|
+
handleFieldChange: (type: string) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
73
|
+
formatMessage: IntlShape['formatMessage'];
|
|
74
|
+
handleCloseAndSave: (data: PixelEntryFormValues) => void;
|
|
75
|
+
isViewMode?: boolean;
|
|
76
|
+
};
|
|
59
77
|
export {};
|
|
@@ -3,8 +3,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { PixelEntryValidation } from '../../pm-plugins/pixel-resizing/ui/types';
|
|
6
7
|
import type { EventInput } from '../../pm-plugins/types';
|
|
7
|
-
import type { PixelEntryValidation } from '../../ui/PixelEntry/types';
|
|
8
8
|
export declare const DEFAULT_BORDER_COLOR = "#091e4224";
|
|
9
9
|
export declare const DEFAULT_BORDER_SIZE = 2;
|
|
10
10
|
export declare const getNodeType: (state: EditorState) => "mediaSingle" | "mediaInline";
|
|
@@ -14,5 +14,6 @@ export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: Editor
|
|
|
14
14
|
export declare const removeInlineCard: Command;
|
|
15
15
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
16
16
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
17
|
+
export declare const updateMediaSingleWidthTr: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, state: EditorState, width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => import("prosemirror-state").Transaction | null;
|
|
17
18
|
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
|
18
19
|
export declare const changeMediaSingleToMediaInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { Props } from '../../pm-plugins/pixel-resizing/ui';
|
|
3
|
+
import { MediaToolbarBaseConfig } from '../../types';
|
|
4
|
+
export declare const getPixelResizingToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, { pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Omit<Props, 'editorView' | 'selectedMediaSingleNode'>) => FloatingToolbarConfig;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Transaction, EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
+
export declare const openPixelEditor: () => import("@atlaskit/editor-common/types").Command;
|
|
3
|
+
export declare const closePixelEditor: () => import("@atlaskit/editor-common/types").Command;
|
|
4
|
+
export declare const closePixelEditorAndSave: (saveTransform: (tr: Transaction, state: EditorState) => Transaction) => import("@atlaskit/editor-common/types").Command;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PMPluginFactoryParams } from '@atlaskit/editor-common/types';
|
|
3
|
+
declare const createCommand: <A = {
|
|
4
|
+
type: "openPixelEditor";
|
|
5
|
+
} | {
|
|
6
|
+
type: "closePixelEditor";
|
|
7
|
+
}>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: ((tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) | undefined) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => {
|
|
8
|
+
isPixelEditorOpen: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const createPlugin: ({ dispatch }: PMPluginFactoryParams) => SafePlugin<{
|
|
11
|
+
isPixelEditorOpen: boolean;
|
|
12
|
+
}>;
|
|
13
|
+
export { createCommand, getPluginState };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type mediaPixelResizingState = {
|
|
2
|
+
isPixelEditorOpen: boolean;
|
|
3
|
+
};
|
|
4
|
+
type OpenPixelEditor = {
|
|
5
|
+
type: 'openPixelEditor';
|
|
6
|
+
};
|
|
7
|
+
type ClosePixelEditor = {
|
|
8
|
+
type: 'closePixelEditor';
|
|
9
|
+
};
|
|
10
|
+
type MediaPixelResizingAction = OpenPixelEditor | ClosePixelEditor;
|
|
11
|
+
declare const _default: (state: mediaPixelResizingState, action: MediaPixelResizingAction) => mediaPixelResizingState;
|
|
12
|
+
export default _default;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { IntlShape } from 'react-intl-next';
|
|
3
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { HoverDecorationHandler } from '@atlaskit/editor-plugin-decorations';
|
|
5
|
+
import { type ContentNodeWithPos } from '@atlaskit/editor-prosemirror/utils';
|
|
6
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
7
|
+
import { MediaNextEditorPluginType } from '../../../mediaPluginType';
|
|
8
|
+
import { MediaPluginState } from '../../../types';
|
|
9
|
+
export type Props = {
|
|
10
|
+
editorView: EditorView;
|
|
11
|
+
selectedMediaSingleNode: ContentNodeWithPos;
|
|
12
|
+
pluginInjectionApi?: ExtractInjectionAPI<MediaNextEditorPluginType>;
|
|
13
|
+
intl: IntlShape;
|
|
14
|
+
pluginState: MediaPluginState;
|
|
15
|
+
hoverDecoration: HoverDecorationHandler | undefined;
|
|
16
|
+
isEditorFullWidthEnabled?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare const PixelEntry: ({ editorView, selectedMediaSingleNode, pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Props) => jsx.JSX.Element | null;
|
|
19
|
+
export declare const FullWidthDisplay: ({ intl: { formatMessage } }: {
|
|
20
|
+
intl: IntlShape;
|
|
21
|
+
}) => jsx.JSX.Element;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import type { PixelEntryComponentNextProps, PixelEntryProps } from './types';
|
|
3
|
+
export declare const PixelEntryComponent: ({ width, mediaWidth, mediaHeight, onSubmit, minWidth, maxWidth, onChange, intl: { formatMessage }, showMigration, onMigrate, onCloseAndSave, isViewMode, }: PixelEntryProps) => jsx.JSX.Element;
|
|
4
|
+
export declare const PixelEntryComponentNext: ({ maxWidth, formatMessage, handleFieldChange, computedWidth, computedHeight, handleCloseAndSave, isViewMode, }: PixelEntryComponentNextProps) => jsx.JSX.Element;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
1
2
|
import type { IntlShape } from 'react-intl-next';
|
|
2
3
|
export type PixelEntryProps = {
|
|
3
4
|
/**
|
|
@@ -46,6 +47,14 @@ export type PixelEntryProps = {
|
|
|
46
47
|
* Migration handler called when the CTA button is clicked
|
|
47
48
|
*/
|
|
48
49
|
onMigrate?: () => void;
|
|
50
|
+
/**
|
|
51
|
+
* Called when the Enter key is pressed or close button is clicked
|
|
52
|
+
*/
|
|
53
|
+
onCloseAndSave?: (data: PixelEntryFormData) => void;
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
*/
|
|
57
|
+
isViewMode?: boolean;
|
|
49
58
|
};
|
|
50
59
|
export type PixelEntryFormValues = {
|
|
51
60
|
inputWidth: number | '';
|
|
@@ -56,4 +65,13 @@ type PixelEntryFormData = {
|
|
|
56
65
|
width: number;
|
|
57
66
|
validation: PixelEntryValidation;
|
|
58
67
|
};
|
|
68
|
+
export type PixelEntryComponentNextProps = {
|
|
69
|
+
maxWidth: number;
|
|
70
|
+
computedWidth: number | '';
|
|
71
|
+
computedHeight: number | '';
|
|
72
|
+
handleFieldChange: (type: string) => (event: ChangeEvent<HTMLInputElement>) => void;
|
|
73
|
+
formatMessage: IntlShape['formatMessage'];
|
|
74
|
+
handleCloseAndSave: (data: PixelEntryFormValues) => void;
|
|
75
|
+
isViewMode?: boolean;
|
|
76
|
+
};
|
|
59
77
|
export {};
|
|
@@ -3,8 +3,8 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
|
3
3
|
import type { Command, EditorContainerWidth as WidthPluginState } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { ForceFocusSelector } from '@atlaskit/editor-plugin-floating-toolbar';
|
|
5
5
|
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
6
|
+
import type { PixelEntryValidation } from '../../pm-plugins/pixel-resizing/ui/types';
|
|
6
7
|
import type { EventInput } from '../../pm-plugins/types';
|
|
7
|
-
import type { PixelEntryValidation } from '../../ui/PixelEntry/types';
|
|
8
8
|
export declare const DEFAULT_BORDER_COLOR = "#091e4224";
|
|
9
9
|
export declare const DEFAULT_BORDER_SIZE = 2;
|
|
10
10
|
export declare const getNodeType: (state: EditorState) => "mediaSingle" | "mediaInline";
|
|
@@ -14,5 +14,6 @@ export declare const changeMediaInlineToMediaSingle: (editorAnalyticsAPI: Editor
|
|
|
14
14
|
export declare const removeInlineCard: Command;
|
|
15
15
|
export declare const toggleBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
16
16
|
export declare const setBorderMark: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (attrs: Partial<BorderMarkAttributes>) => Command;
|
|
17
|
+
export declare const updateMediaSingleWidthTr: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined, state: EditorState, width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => import("prosemirror-state").Transaction | null;
|
|
17
18
|
export declare const updateMediaSingleWidth: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => (width: number, validation: PixelEntryValidation, inputMethod: EventInput, layout: RichMediaLayout) => Command;
|
|
18
19
|
export declare const changeMediaSingleToMediaInline: (editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => Command;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { FloatingToolbarConfig } from '@atlaskit/editor-common/types';
|
|
2
|
+
import { Props } from '../../pm-plugins/pixel-resizing/ui';
|
|
3
|
+
import { MediaToolbarBaseConfig } from '../../types';
|
|
4
|
+
export declare const getPixelResizingToolbar: (toolbarBaseConfig: MediaToolbarBaseConfig, { pluginInjectionApi, intl, pluginState, hoverDecoration, isEditorFullWidthEnabled, }: Omit<Props, 'editorView' | 'selectedMediaSingleNode'>) => FloatingToolbarConfig;
|