@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
|
@@ -3,22 +3,25 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
* @jsxRuntime classic
|
|
4
4
|
* @jsx jsx
|
|
5
5
|
*/
|
|
6
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
6
|
+
import { useCallback, useEffect, useMemo, useState, useRef, Fragment } from 'react';
|
|
7
7
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
8
|
-
import { jsx } from '@emotion/react';
|
|
8
|
+
import { jsx, css } from '@emotion/react';
|
|
9
9
|
import Button from '@atlaskit/button';
|
|
10
|
+
import { IconButton } from '@atlaskit/button/new';
|
|
10
11
|
import { pixelEntryMessages as messages } from '@atlaskit/editor-common/media';
|
|
11
12
|
import Form, { Field } from '@atlaskit/form';
|
|
12
|
-
import
|
|
13
|
+
import CloseIcon from '@atlaskit/icon/core/close';
|
|
14
|
+
import { Inline, Box, Text, xcss } from '@atlaskit/primitives';
|
|
13
15
|
import Textfield from '@atlaskit/textfield';
|
|
16
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
14
17
|
import Tooltip from '@atlaskit/tooltip';
|
|
15
|
-
import { PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
|
|
16
|
-
import { pixelEntryForm, pixelEntryHiddenSubmit,
|
|
18
|
+
import { PIXEL_RESIZING_TOOLBAR_WIDTH, PIXEL_VIEW_MODE_TOOLBAR_WIDTH, PIXELENTRY_MIGRATION_BUTTON_TESTID } from './constants';
|
|
19
|
+
import { pixelEntryForm, pixelEntryHiddenSubmit, pixelSizingHeightInput, pixelSizingInput, pixelSizingWidthInput, pixelSizingWrapper } from './styles';
|
|
17
20
|
const pixelSizingLabel = xcss({
|
|
18
21
|
gridArea: 'label',
|
|
19
22
|
lineHeight: "var(--ds-space-300, 24px)"
|
|
20
23
|
});
|
|
21
|
-
export const
|
|
24
|
+
export const PixelEntryComponent = ({
|
|
22
25
|
width,
|
|
23
26
|
mediaWidth,
|
|
24
27
|
mediaHeight,
|
|
@@ -30,7 +33,9 @@ export const PixelEntry = ({
|
|
|
30
33
|
formatMessage
|
|
31
34
|
},
|
|
32
35
|
showMigration,
|
|
33
|
-
onMigrate
|
|
36
|
+
onMigrate,
|
|
37
|
+
onCloseAndSave,
|
|
38
|
+
isViewMode
|
|
34
39
|
}) => {
|
|
35
40
|
const ratioWidth = useMemo(() => {
|
|
36
41
|
return mediaHeight / mediaWidth;
|
|
@@ -78,6 +83,37 @@ export const PixelEntry = ({
|
|
|
78
83
|
}
|
|
79
84
|
};
|
|
80
85
|
|
|
86
|
+
// Handle submit when user presses enter or click close button in PixelEntryComponentNext
|
|
87
|
+
const handleCloseAndSave = useCallback(data => {
|
|
88
|
+
if (data.inputWidth === '' || data.inputHeight === '') {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (onCloseAndSave) {
|
|
92
|
+
let widthToBeSubmitted = data.inputWidth;
|
|
93
|
+
let validation = 'valid';
|
|
94
|
+
if (data.inputWidth < minWidth) {
|
|
95
|
+
widthToBeSubmitted = minWidth;
|
|
96
|
+
validation = 'less-than-min';
|
|
97
|
+
}
|
|
98
|
+
if (data.inputWidth > maxWidth) {
|
|
99
|
+
widthToBeSubmitted = maxWidth;
|
|
100
|
+
validation = 'greater-than-max';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// If user keeps submitting an invalid input, node width attribute will be updated with the same value
|
|
104
|
+
// and won't upadte the state in useEffect (since width is the same)
|
|
105
|
+
// Thus, we set the state here to always display the correct dimension
|
|
106
|
+
if (validation !== 'valid') {
|
|
107
|
+
setComputedWidth(widthToBeSubmitted);
|
|
108
|
+
setComputedHeight(Math.round(ratioWidth * widthToBeSubmitted));
|
|
109
|
+
}
|
|
110
|
+
onCloseAndSave({
|
|
111
|
+
width: widthToBeSubmitted,
|
|
112
|
+
validation
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}, [maxWidth, minWidth, onCloseAndSave, ratioWidth]);
|
|
116
|
+
|
|
81
117
|
// Handle updating computed fields based on
|
|
82
118
|
const handleOnChange = useCallback(type => event => {
|
|
83
119
|
const value = parseInt(event.currentTarget.value);
|
|
@@ -113,6 +149,17 @@ export const PixelEntry = ({
|
|
|
113
149
|
testId: PIXELENTRY_MIGRATION_BUTTON_TESTID
|
|
114
150
|
}, formatMessage(messages.migrationButtonText)));
|
|
115
151
|
}
|
|
152
|
+
if (editorExperiment('platform_editor_controls', 'variant1')) {
|
|
153
|
+
return jsx(PixelEntryComponentNext, {
|
|
154
|
+
maxWidth: maxWidth,
|
|
155
|
+
formatMessage: formatMessage,
|
|
156
|
+
handleFieldChange: handleOnChange,
|
|
157
|
+
computedWidth: computedWidth,
|
|
158
|
+
computedHeight: computedHeight,
|
|
159
|
+
handleCloseAndSave: handleCloseAndSave,
|
|
160
|
+
isViewMode: isViewMode
|
|
161
|
+
});
|
|
162
|
+
}
|
|
116
163
|
return (
|
|
117
164
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
|
|
118
165
|
jsx("div", {
|
|
@@ -143,7 +190,7 @@ export const PixelEntry = ({
|
|
|
143
190
|
// Ignored via go/ees005
|
|
144
191
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
145
192
|
, _extends({}, fieldProps, {
|
|
146
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
193
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
|
|
147
194
|
css: [pixelSizingWidthInput, pixelSizingInput],
|
|
148
195
|
appearance: "none",
|
|
149
196
|
isCompact: true,
|
|
@@ -169,7 +216,7 @@ export const PixelEntry = ({
|
|
|
169
216
|
// Ignored via go/ees005
|
|
170
217
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
171
218
|
, _extends({}, fieldProps, {
|
|
172
|
-
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
|
|
219
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/design-system/no-unsafe-style-overrides -- Ignored via go/DSP-18766
|
|
173
220
|
css: [pixelSizingHeightInput, pixelSizingInput],
|
|
174
221
|
appearance: "none",
|
|
175
222
|
isCompact: true,
|
|
@@ -184,15 +231,119 @@ export const PixelEntry = ({
|
|
|
184
231
|
}))
|
|
185
232
|
);
|
|
186
233
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
234
|
+
const pixelEntryWrapperStyles = xcss({
|
|
235
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
236
|
+
width: `${PIXEL_RESIZING_TOOLBAR_WIDTH}px`
|
|
237
|
+
});
|
|
238
|
+
const pixelEntryWrapperViewModeStyles = xcss({
|
|
239
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values
|
|
240
|
+
width: `${PIXEL_VIEW_MODE_TOOLBAR_WIDTH}px`
|
|
241
|
+
});
|
|
242
|
+
const fieldStyles = css({
|
|
243
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors
|
|
244
|
+
'[data-ds--text-field--input]': {
|
|
245
|
+
paddingBlock: "var(--ds-space-0, 0px)",
|
|
246
|
+
paddingInline: "var(--ds-space-100, 8px)"
|
|
247
|
+
},
|
|
248
|
+
flex: '1'
|
|
249
|
+
});
|
|
250
|
+
const dividerStyles = xcss({
|
|
251
|
+
width: '1px',
|
|
252
|
+
height: "var(--ds-space-500, 40px)",
|
|
253
|
+
background: "var(--ds-border, #091E4224)",
|
|
254
|
+
marginInlineEnd: 'space.050'
|
|
255
|
+
});
|
|
256
|
+
export const PixelEntryComponentNext = ({
|
|
257
|
+
maxWidth,
|
|
258
|
+
formatMessage,
|
|
259
|
+
handleFieldChange,
|
|
260
|
+
computedWidth,
|
|
261
|
+
computedHeight,
|
|
262
|
+
handleCloseAndSave,
|
|
263
|
+
isViewMode
|
|
191
264
|
}) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
265
|
+
const widthInputRef = useRef(null);
|
|
266
|
+
useEffect(() => {
|
|
267
|
+
if (widthInputRef.current) {
|
|
268
|
+
if (isViewMode) {
|
|
269
|
+
widthInputRef.current.blur();
|
|
270
|
+
} else {
|
|
271
|
+
widthInputRef.current.focus();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}, [isViewMode, widthInputRef]);
|
|
275
|
+
const handleKeyDown = useCallback(event => {
|
|
276
|
+
if (event.key === 'Enter') {
|
|
277
|
+
handleCloseAndSave({
|
|
278
|
+
inputWidth: computedWidth,
|
|
279
|
+
inputHeight: computedHeight
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
}, [computedWidth, computedHeight, handleCloseAndSave]);
|
|
283
|
+
return jsx(Box, {
|
|
284
|
+
xcss: [pixelEntryWrapperStyles, isViewMode && pixelEntryWrapperViewModeStyles]
|
|
285
|
+
}, jsx(Inline, {
|
|
286
|
+
alignBlock: "center",
|
|
287
|
+
spread: "space-between"
|
|
288
|
+
}, jsx(Box, {
|
|
289
|
+
paddingInlineStart: "space.100"
|
|
290
|
+
}, jsx(Text, {
|
|
291
|
+
color: "color.text.subtlest"
|
|
292
|
+
}, formatMessage(messages.inputWidthLabel))), jsx("div", {
|
|
293
|
+
css: fieldStyles
|
|
294
|
+
}, jsx(Tooltip, {
|
|
295
|
+
hideTooltipOnMouseDown: true,
|
|
296
|
+
hideTooltipOnClick: true,
|
|
297
|
+
position: "top",
|
|
298
|
+
content: formatMessage(messages.inputWidthTooltip, {
|
|
299
|
+
maxWidth
|
|
300
|
+
})
|
|
301
|
+
}, jsx(Textfield, {
|
|
302
|
+
name: "inputWidth",
|
|
303
|
+
value: computedWidth,
|
|
304
|
+
ref: widthInputRef,
|
|
305
|
+
height: "var(--ds-space-250, 20px)",
|
|
306
|
+
appearance: "none",
|
|
307
|
+
pattern: "\\d*",
|
|
308
|
+
"aria-label": formatMessage(messages.inputWidthAriaLabel, {
|
|
309
|
+
maxWidth
|
|
310
|
+
}),
|
|
311
|
+
onChange: handleFieldChange('inputWidth'),
|
|
312
|
+
onKeyDown: handleKeyDown
|
|
313
|
+
}))), jsx(Box, {
|
|
314
|
+
paddingInlineStart: "space.100"
|
|
315
|
+
}, jsx(Text, {
|
|
316
|
+
color: "color.text.subtlest"
|
|
317
|
+
}, formatMessage(messages.inputHeightTooltip))), jsx("div", {
|
|
318
|
+
css: fieldStyles
|
|
319
|
+
}, jsx(Tooltip, {
|
|
320
|
+
hideTooltipOnMouseDown: true,
|
|
321
|
+
hideTooltipOnClick: true,
|
|
322
|
+
content: formatMessage(messages.inputHeightTooltip),
|
|
323
|
+
position: "top"
|
|
324
|
+
}, jsx(Textfield, {
|
|
325
|
+
name: "inputHeight",
|
|
326
|
+
value: computedHeight,
|
|
327
|
+
height: "var(--ds-space-250, 20px)",
|
|
328
|
+
appearance: "none",
|
|
329
|
+
pattern: "\\d*",
|
|
330
|
+
"aria-label": formatMessage(messages.inputHeightAriaLabel),
|
|
331
|
+
onChange: handleFieldChange('inputHeight'),
|
|
332
|
+
onKeyDown: handleKeyDown
|
|
333
|
+
}))), !isViewMode && jsx(Fragment, null, jsx(Box, {
|
|
334
|
+
xcss: dividerStyles
|
|
335
|
+
}), jsx(IconButton, {
|
|
336
|
+
icon: () => jsx(CloseIcon, {
|
|
337
|
+
label: "",
|
|
338
|
+
color: "var(--ds-icon-subtlest, #626F86)"
|
|
339
|
+
}),
|
|
340
|
+
label: formatMessage(messages.closePixelEntry),
|
|
341
|
+
appearance: "subtle",
|
|
342
|
+
onClick: () => {
|
|
343
|
+
handleCloseAndSave({
|
|
344
|
+
inputWidth: computedWidth,
|
|
345
|
+
inputHeight: computedHeight
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}))));
|
|
198
349
|
};
|
|
@@ -239,10 +239,10 @@ export const setBorderMark = editorAnalyticsAPI => attrs => (state, dispatch) =>
|
|
|
239
239
|
}
|
|
240
240
|
return true;
|
|
241
241
|
};
|
|
242
|
-
export const
|
|
242
|
+
export const updateMediaSingleWidthTr = (editorAnalyticsAPI, state, width, validation, inputMethod, layout) => {
|
|
243
243
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
244
244
|
if (!selectedMediaSingleNode) {
|
|
245
|
-
return
|
|
245
|
+
return null;
|
|
246
246
|
}
|
|
247
247
|
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
248
248
|
...selectedMediaSingleNode.node.attrs,
|
|
@@ -264,6 +264,13 @@ export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation,
|
|
|
264
264
|
if (payload) {
|
|
265
265
|
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(payload)(tr);
|
|
266
266
|
}
|
|
267
|
+
return tr;
|
|
268
|
+
};
|
|
269
|
+
export const updateMediaSingleWidth = editorAnalyticsAPI => (width, validation, inputMethod, layout) => (state, dispatch) => {
|
|
270
|
+
const tr = updateMediaSingleWidthTr(editorAnalyticsAPI, state, width, validation, inputMethod, layout);
|
|
271
|
+
if (!tr) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
267
274
|
if (dispatch) {
|
|
268
275
|
dispatch(tr);
|
|
269
276
|
}
|
|
@@ -4,11 +4,9 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit
|
|
|
4
4
|
import { alignmentIcons, buildLayoutButtons, IconCard, IconEmbed, IconInline, layoutToMessages, wrappingIcons } from '@atlaskit/editor-common/card';
|
|
5
5
|
import { altTextMessages } from '@atlaskit/editor-common/media';
|
|
6
6
|
import { mediaInlineImagesEnabled } from '@atlaskit/editor-common/media-inline';
|
|
7
|
-
import { calcMinWidth, DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
8
7
|
import commonMessages, { cardMessages, mediaAndEmbedToolbarMessages } from '@atlaskit/editor-common/messages';
|
|
9
8
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { contains, findParentNodeOfType,
|
|
11
|
-
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
9
|
+
import { contains, findParentNodeOfType, hasParentNodeOfType, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
12
10
|
import CopyIcon from '@atlaskit/icon/core/copy';
|
|
13
11
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
14
12
|
import GrowDiagonalIcon from '@atlaskit/icon/core/grow-diagonal';
|
|
@@ -30,20 +28,23 @@ import { getPluginState as getMediaAltTextPluginState } from '../../pm-plugins/a
|
|
|
30
28
|
import { openMediaAltTextMenu } from '../../pm-plugins/alt-text/commands';
|
|
31
29
|
import { showLinkingToolbar } from '../../pm-plugins/commands/linking';
|
|
32
30
|
import { getMediaLinkingState } from '../../pm-plugins/linking';
|
|
31
|
+
import { getPluginState as getMediaPixelResizingPluginState } from '../../pm-plugins/pixel-resizing';
|
|
32
|
+
import { openPixelEditor } from '../../pm-plugins/pixel-resizing/commands';
|
|
33
|
+
import { FullWidthDisplay, PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
33
34
|
import { stateKey } from '../../pm-plugins/plugin-key';
|
|
34
35
|
import { currentMediaOrInlineNodeBorderMark } from '../../pm-plugins/utils/current-media-node';
|
|
35
36
|
import { isVideo } from '../../pm-plugins/utils/media-single';
|
|
36
37
|
import ImageBorderItem from '../../ui/ImageBorder';
|
|
37
|
-
import { FullWidthDisplay, PixelEntry } from '../../ui/PixelEntry';
|
|
38
38
|
import { altTextButton, getAltTextToolbar } from './alt-text';
|
|
39
|
-
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark
|
|
39
|
+
import { changeMediaCardToInline, changeMediaSingleToMediaInline, setBorderMark, toggleBorderMark } from './commands';
|
|
40
40
|
import { commentButton } from './comments';
|
|
41
41
|
import { shouldShowImageBorder } from './imageBorder';
|
|
42
42
|
import { LayoutGroup } from './layout-group';
|
|
43
43
|
import { getLinkingDropdownOptions, getLinkingToolbar, getOpenLinkToolbarButtonOption, shouldShowMediaLinkToolbar } from './linking';
|
|
44
44
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
45
45
|
import { generateMediaInlineFloatingToolbar } from './mediaInline';
|
|
46
|
-
import {
|
|
46
|
+
import { getPixelResizingToolbar } from './pixel-resizing';
|
|
47
|
+
import { canShowSwitchButtons, downloadMedia, getMaxToolbarWidth, getSelectedLayoutIcon, getSelectedMediaSingle, getSelectedNearestMediaContainerNodeAttrs, removeMediaGroupNode } from './utils';
|
|
47
48
|
const mediaTypeMessages = {
|
|
48
49
|
image: messages.file_image_is_selected,
|
|
49
50
|
video: messages.file_video_is_selected,
|
|
@@ -76,7 +77,7 @@ export const handleShowMediaViewer = ({
|
|
|
76
77
|
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.media.commands.showMediaViewer(selectedNodeAttrs));
|
|
77
78
|
};
|
|
78
79
|
const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, editorAnalyticsAPI, forceFocusSelector, isViewOnly) => {
|
|
79
|
-
var _mediaPluginState$med;
|
|
80
|
+
var _mediaPluginState$med, _pluginInjectionApi$c, _pluginInjectionApi$c2, _pluginInjectionApi$c3;
|
|
80
81
|
if (isViewOnly) {
|
|
81
82
|
return [];
|
|
82
83
|
}
|
|
@@ -125,6 +126,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState, hoverDe
|
|
|
125
126
|
api: pluginInjectionApi
|
|
126
127
|
})) !== null && _handleShowMediaViewe !== void 0 ? _handleShowMediaViewe : false;
|
|
127
128
|
},
|
|
129
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c === void 0 ? void 0 : (_pluginInjectionApi$c2 = _pluginInjectionApi$c.sharedState) === null || _pluginInjectionApi$c2 === void 0 ? void 0 : (_pluginInjectionApi$c3 = _pluginInjectionApi$c2.currentState()) === null || _pluginInjectionApi$c3 === void 0 ? void 0 : _pluginInjectionApi$c3.mode) === 'offline',
|
|
128
130
|
supportsViewMode: true
|
|
129
131
|
}, {
|
|
130
132
|
type: 'separator'
|
|
@@ -371,73 +373,17 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
371
373
|
type: 'custom',
|
|
372
374
|
fallback: [],
|
|
373
375
|
render: editorView => {
|
|
374
|
-
var _widthPlugin$sharedSt2, _pluginInjectionApi$m, _pluginInjectionApi$m2;
|
|
375
376
|
if (!editorView || !selectedMediaSingleNode) {
|
|
376
377
|
return null;
|
|
377
378
|
}
|
|
378
|
-
const {
|
|
379
|
-
state,
|
|
380
|
-
dispatch
|
|
381
|
-
} = editorView;
|
|
382
|
-
const contentWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt2 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt2 === void 0 ? void 0 : _widthPlugin$sharedSt2.lineLength) || akEditorDefaultLayoutWidth;
|
|
383
|
-
const selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
384
|
-
if (!selectedMediaNode) {
|
|
385
|
-
return null;
|
|
386
|
-
}
|
|
387
|
-
const {
|
|
388
|
-
width: mediaSingleWidth,
|
|
389
|
-
widthType,
|
|
390
|
-
layout
|
|
391
|
-
} = selectedMediaSingleNode.node.attrs;
|
|
392
|
-
const {
|
|
393
|
-
width: mediaWidth,
|
|
394
|
-
height: mediaHeight
|
|
395
|
-
} = selectedMediaNode.attrs;
|
|
396
|
-
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;
|
|
397
|
-
const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
398
|
-
const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
399
|
-
const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
400
|
-
const hasPixelType = widthType === 'pixel';
|
|
401
|
-
const pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
402
|
-
// get pos of media node
|
|
403
|
-
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
404
|
-
const pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
405
|
-
|
|
406
|
-
//hasParentNode will return falsey value if selection depth === 0
|
|
407
|
-
const isNested = hasParentNode(n => n.type !== state.schema.nodes.doc)(state.selection);
|
|
408
379
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
380
|
+
editorView: editorView,
|
|
409
381
|
intl: intl,
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
maxWidth: maxWidth,
|
|
416
|
-
onChange: valid => {
|
|
417
|
-
if (valid) {
|
|
418
|
-
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
419
|
-
} else {
|
|
420
|
-
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
421
|
-
}
|
|
422
|
-
},
|
|
423
|
-
onSubmit: ({
|
|
424
|
-
width,
|
|
425
|
-
validation
|
|
426
|
-
}) => {
|
|
427
|
-
var _pluginInjectionApi$a6;
|
|
428
|
-
const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
429
|
-
updateMediaSingleWidth(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions)(width, validation, 'floatingToolBar', newLayout)(state, dispatch);
|
|
430
|
-
},
|
|
431
|
-
onMigrate: () => {
|
|
432
|
-
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
433
|
-
...selectedMediaSingleNode.node.attrs,
|
|
434
|
-
width: pixelWidthFromElement,
|
|
435
|
-
widthType: 'pixel'
|
|
436
|
-
});
|
|
437
|
-
tr.setMeta('scrollIntoView', false);
|
|
438
|
-
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
439
|
-
dispatch(tr);
|
|
440
|
-
}
|
|
382
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
383
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
384
|
+
pluginState: pluginState,
|
|
385
|
+
hoverDecoration: hoverDecoration,
|
|
386
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
441
387
|
});
|
|
442
388
|
}
|
|
443
389
|
};
|
|
@@ -495,14 +441,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
495
441
|
};
|
|
496
442
|
const openLink = () => {
|
|
497
443
|
if (editorView) {
|
|
498
|
-
var _pluginInjectionApi$
|
|
444
|
+
var _pluginInjectionApi$a6;
|
|
499
445
|
const {
|
|
500
446
|
state: {
|
|
501
447
|
tr
|
|
502
448
|
},
|
|
503
449
|
dispatch
|
|
504
450
|
} = editorView;
|
|
505
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
451
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a6 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a6 === void 0 ? void 0 : _pluginInjectionApi$a6.actions.attachAnalyticsEvent({
|
|
506
452
|
eventType: EVENT_TYPE.TRACK,
|
|
507
453
|
action: ACTION.VISITED,
|
|
508
454
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -534,6 +480,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
534
480
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
535
481
|
const mediaNode = selectedMediaSingleNode === null || selectedMediaSingleNode === void 0 ? void 0 : selectedMediaSingleNode.node.content.firstChild;
|
|
536
482
|
if (!isVideo(mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$attrs = mediaNode.attrs) === null || _mediaNode$attrs === void 0 ? void 0 : _mediaNode$attrs.__fileMimeType)) {
|
|
483
|
+
var _pluginInjectionApi$c4, _pluginInjectionApi$c5, _pluginInjectionApi$c6;
|
|
537
484
|
toolbarButtons.push({
|
|
538
485
|
id: 'editor.media.viewer',
|
|
539
486
|
testId: 'file-preview-toolbar-button',
|
|
@@ -548,6 +495,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
548
495
|
mediaPluginState: pluginState
|
|
549
496
|
})) !== null && _handleShowMediaViewe2 !== void 0 ? _handleShowMediaViewe2 : false;
|
|
550
497
|
},
|
|
498
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c4 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c4 === void 0 ? void 0 : (_pluginInjectionApi$c5 = _pluginInjectionApi$c4.sharedState) === null || _pluginInjectionApi$c5 === void 0 ? void 0 : (_pluginInjectionApi$c6 = _pluginInjectionApi$c5.currentState()) === null || _pluginInjectionApi$c6 === void 0 ? void 0 : _pluginInjectionApi$c6.mode) === 'offline',
|
|
551
499
|
supportsViewMode: true
|
|
552
500
|
}, {
|
|
553
501
|
type: 'separator',
|
|
@@ -574,8 +522,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
574
522
|
});
|
|
575
523
|
}
|
|
576
524
|
if (allowAltTextOnImages && editorExperiment('platform_editor_controls', 'control')) {
|
|
577
|
-
var _pluginInjectionApi$
|
|
578
|
-
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
525
|
+
var _pluginInjectionApi$a7;
|
|
526
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a7 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a7 === void 0 ? void 0 : _pluginInjectionApi$a7.actions), {
|
|
579
527
|
type: 'separator'
|
|
580
528
|
});
|
|
581
529
|
}
|
|
@@ -602,6 +550,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
602
550
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
603
551
|
const mediaNode = selectedMediaSingleNode === null || selectedMediaSingleNode === void 0 ? void 0 : selectedMediaSingleNode.node.content.firstChild;
|
|
604
552
|
if (!isVideo(mediaNode === null || mediaNode === void 0 ? void 0 : (_mediaNode$attrs2 = mediaNode.attrs) === null || _mediaNode$attrs2 === void 0 ? void 0 : _mediaNode$attrs2.__fileMimeType)) {
|
|
553
|
+
var _pluginInjectionApi$c7, _pluginInjectionApi$c8, _pluginInjectionApi$c9;
|
|
605
554
|
toolbarButtons.push({
|
|
606
555
|
id: 'editor.media.viewer',
|
|
607
556
|
testId: 'file-preview-toolbar-button',
|
|
@@ -616,6 +565,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
616
565
|
mediaPluginState: pluginState
|
|
617
566
|
})) !== null && _handleShowMediaViewe3 !== void 0 ? _handleShowMediaViewe3 : false;
|
|
618
567
|
},
|
|
568
|
+
disabled: (pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c7 = pluginInjectionApi.connectivity) === null || _pluginInjectionApi$c7 === void 0 ? void 0 : (_pluginInjectionApi$c8 = _pluginInjectionApi$c7.sharedState) === null || _pluginInjectionApi$c8 === void 0 ? void 0 : (_pluginInjectionApi$c9 = _pluginInjectionApi$c8.currentState()) === null || _pluginInjectionApi$c9 === void 0 ? void 0 : _pluginInjectionApi$c9.mode) === 'offline',
|
|
619
569
|
supportsViewMode: true
|
|
620
570
|
}, {
|
|
621
571
|
type: 'separator',
|
|
@@ -686,7 +636,9 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
686
636
|
providerFactory,
|
|
687
637
|
allowMediaInline,
|
|
688
638
|
allowResizing,
|
|
689
|
-
isViewOnly
|
|
639
|
+
isViewOnly,
|
|
640
|
+
allowResizingInTables,
|
|
641
|
+
allowAdvancedToolBarOptions
|
|
690
642
|
} = options;
|
|
691
643
|
const mediaPluginState = stateKey.getState(state);
|
|
692
644
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
@@ -718,6 +670,22 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
718
670
|
});
|
|
719
671
|
}
|
|
720
672
|
}
|
|
673
|
+
const {
|
|
674
|
+
selection
|
|
675
|
+
} = state;
|
|
676
|
+
const isWithinTable = hasParentNodeOfType([state.schema.nodes.table])(selection);
|
|
677
|
+
if (allowAdvancedToolBarOptions && allowResizing && (!isWithinTable || allowResizingInTables === true) && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_media_extended_resize_experience')) {
|
|
678
|
+
const mediaPixelResizingPluginState = getMediaPixelResizingPluginState(state);
|
|
679
|
+
if (mediaPixelResizingPluginState !== null && mediaPixelResizingPluginState !== void 0 && mediaPixelResizingPluginState.isPixelEditorOpen) {
|
|
680
|
+
return getPixelResizingToolbar(baseToolbar, {
|
|
681
|
+
intl,
|
|
682
|
+
pluginInjectionApi,
|
|
683
|
+
pluginState: mediaPluginState,
|
|
684
|
+
hoverDecoration,
|
|
685
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
}
|
|
721
689
|
let items = [];
|
|
722
690
|
const parentMediaGroupNode = findParentNodeOfType(mediaGroup)(state.selection);
|
|
723
691
|
let selectedNodeType;
|
|
@@ -725,7 +693,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
725
693
|
selectedNodeType = state.selection.node.type;
|
|
726
694
|
}
|
|
727
695
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
728
|
-
var _pluginInjectionApi$
|
|
696
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f3, _pluginInjectionApi$f4;
|
|
729
697
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
730
698
|
baseToolbar.getDomRef = () => {
|
|
731
699
|
var _mediaPluginState$ele;
|
|
@@ -734,7 +702,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
734
702
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
735
703
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
736
704
|
};
|
|
737
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
705
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a8 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a8 === void 0 ? void 0 : _pluginInjectionApi$a8.actions, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f3 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f3 === void 0 ? void 0 : (_pluginInjectionApi$f4 = _pluginInjectionApi$f3.actions) === null || _pluginInjectionApi$f4 === void 0 ? void 0 : _pluginInjectionApi$f4.forceFocusSelector, isViewOnly);
|
|
738
706
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
739
707
|
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options);
|
|
740
708
|
} else {
|
|
@@ -748,7 +716,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
748
716
|
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi);
|
|
749
717
|
}
|
|
750
718
|
if (!mediaPluginState.isResizing && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
751
|
-
var _pluginInjectionApi$
|
|
719
|
+
var _pluginInjectionApi$a9;
|
|
752
720
|
const lastItem = items.at(-1);
|
|
753
721
|
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === 'separator') {
|
|
754
722
|
lastItem.fullHeight = true;
|
|
@@ -763,39 +731,35 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
763
731
|
type: 'overflow-dropdown',
|
|
764
732
|
options: [...getLinkingDropdownOptions(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly), {
|
|
765
733
|
title: altTextTitle,
|
|
766
|
-
onClick: openMediaAltTextMenu(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
734
|
+
onClick: openMediaAltTextMenu(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a9 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a9 === void 0 ? void 0 : _pluginInjectionApi$a9.actions),
|
|
767
735
|
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
768
|
-
label:
|
|
736
|
+
label: ""
|
|
769
737
|
})
|
|
770
738
|
}, {
|
|
771
739
|
title: 'Resize',
|
|
772
|
-
onClick: ()
|
|
773
|
-
// Ignored via go/ees007
|
|
774
|
-
// eslint-disable-next-line @atlaskit/editor/enforce-todo-comment-format
|
|
775
|
-
// TODO open resize dialog?
|
|
776
|
-
return true;
|
|
777
|
-
},
|
|
740
|
+
onClick: openPixelEditor(),
|
|
778
741
|
icon: /*#__PURE__*/React.createElement(GrowHorizontalIcon, {
|
|
779
|
-
label: "
|
|
780
|
-
})
|
|
742
|
+
label: ""
|
|
743
|
+
}),
|
|
744
|
+
testId: 'media-pixel-resizing-dropdown-option'
|
|
781
745
|
}, {
|
|
782
746
|
type: 'separator'
|
|
783
747
|
}, {
|
|
784
748
|
title: 'Copy',
|
|
785
749
|
onClick: () => {
|
|
786
|
-
var _pluginInjectionApi$
|
|
787
|
-
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
750
|
+
var _pluginInjectionApi$c10, _pluginInjectionApi$f5;
|
|
751
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$c10 = pluginInjectionApi.core) === null || _pluginInjectionApi$c10 === void 0 ? void 0 : _pluginInjectionApi$c10.actions.execute( // @ts-ignore
|
|
788
752
|
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$f5 = pluginInjectionApi.floatingToolbar) === null || _pluginInjectionApi$f5 === void 0 ? void 0 : _pluginInjectionApi$f5.commands.copyNode(nodeType));
|
|
789
753
|
return true;
|
|
790
754
|
},
|
|
791
755
|
icon: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
792
|
-
label: "
|
|
756
|
+
label: ""
|
|
793
757
|
})
|
|
794
758
|
}, {
|
|
795
759
|
title: 'Delete',
|
|
796
760
|
onClick: remove,
|
|
797
761
|
icon: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
798
|
-
label: "
|
|
762
|
+
label: ""
|
|
799
763
|
})
|
|
800
764
|
}]
|
|
801
765
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PixelEntry } from '../../pm-plugins/pixel-resizing/ui';
|
|
3
|
+
import { PIXEL_RESIZING_TOOLBAR_WIDTH } from '../../pm-plugins/pixel-resizing/ui/constants';
|
|
4
|
+
import { getSelectedMediaSingle } from './utils';
|
|
5
|
+
export const getPixelResizingToolbar = (toolbarBaseConfig, {
|
|
6
|
+
pluginInjectionApi,
|
|
7
|
+
intl,
|
|
8
|
+
pluginState,
|
|
9
|
+
hoverDecoration,
|
|
10
|
+
isEditorFullWidthEnabled
|
|
11
|
+
}) => ({
|
|
12
|
+
...toolbarBaseConfig,
|
|
13
|
+
width: PIXEL_RESIZING_TOOLBAR_WIDTH,
|
|
14
|
+
scrollable: true,
|
|
15
|
+
items: [{
|
|
16
|
+
type: 'custom',
|
|
17
|
+
fallback: [],
|
|
18
|
+
render: editorView => {
|
|
19
|
+
if (!editorView) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const selectedMediaSingleNode = getSelectedMediaSingle(editorView.state);
|
|
23
|
+
if (!editorView || !selectedMediaSingleNode) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
27
|
+
editorView: editorView,
|
|
28
|
+
intl: intl,
|
|
29
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
30
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
31
|
+
pluginState: pluginState,
|
|
32
|
+
hoverDecoration: hoverDecoration,
|
|
33
|
+
isEditorFullWidthEnabled: isEditorFullWidthEnabled
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
}]
|
|
37
|
+
});
|
package/dist/esm/mediaPlugin.js
CHANGED
|
@@ -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 as _insertMediaAsMediaSingle } from './pm-plugins/utils/media-single';
|
|
@@ -234,6 +235,12 @@ export var mediaPlugin = function mediaPlugin(_ref3) {
|
|
|
234
235
|
}
|
|
235
236
|
});
|
|
236
237
|
}
|
|
238
|
+
if (options && options.allowAdvancedToolBarOptions && options.allowResizing && editorExperiment('platform_editor_controls', 'variant1') && fg('platform_editor_media_extended_resize_experience')) {
|
|
239
|
+
pmPlugins.push({
|
|
240
|
+
name: 'mediaPixelResizing',
|
|
241
|
+
plugin: createMediaPixelResizingPlugin
|
|
242
|
+
});
|
|
243
|
+
}
|
|
237
244
|
pmPlugins.push({
|
|
238
245
|
name: 'mediaSelectionHandler',
|
|
239
246
|
plugin: function plugin() {
|