@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
|
@@ -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,
|
|
@@ -372,73 +373,17 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
372
373
|
type: 'custom',
|
|
373
374
|
fallback: [],
|
|
374
375
|
render: editorView => {
|
|
375
|
-
var _widthPlugin$sharedSt2, _pluginInjectionApi$m, _pluginInjectionApi$m2;
|
|
376
376
|
if (!editorView || !selectedMediaSingleNode) {
|
|
377
377
|
return null;
|
|
378
378
|
}
|
|
379
|
-
const {
|
|
380
|
-
state,
|
|
381
|
-
dispatch
|
|
382
|
-
} = editorView;
|
|
383
|
-
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;
|
|
384
|
-
const selectedMediaNode = selectedMediaSingleNode.node.content.firstChild;
|
|
385
|
-
if (!selectedMediaNode) {
|
|
386
|
-
return null;
|
|
387
|
-
}
|
|
388
|
-
const {
|
|
389
|
-
width: mediaSingleWidth,
|
|
390
|
-
widthType,
|
|
391
|
-
layout
|
|
392
|
-
} = selectedMediaSingleNode.node.attrs;
|
|
393
|
-
const {
|
|
394
|
-
width: mediaWidth,
|
|
395
|
-
height: mediaHeight
|
|
396
|
-
} = selectedMediaNode.attrs;
|
|
397
|
-
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;
|
|
398
|
-
const maxWidth = maxWidthForNestedNode || akEditorFullWidthLayoutWidth;
|
|
399
|
-
const isVideoFile = isVideo(selectedMediaNode.attrs.__fileMimeType);
|
|
400
|
-
const minWidth = calcMinWidth(isVideoFile, maxWidthForNestedNode || contentWidth);
|
|
401
|
-
const hasPixelType = widthType === 'pixel';
|
|
402
|
-
const pixelWidthFromElement = getPixelWidthOfElement(editorView, selectedMediaSingleNode.pos + 1,
|
|
403
|
-
// get pos of media node
|
|
404
|
-
mediaWidth || DEFAULT_IMAGE_WIDTH);
|
|
405
|
-
const pixelWidth = hasPixelType ? mediaSingleWidth : pixelWidthFromElement;
|
|
406
|
-
|
|
407
|
-
//hasParentNode will return falsey value if selection depth === 0
|
|
408
|
-
const isNested = hasParentNode(n => n.type !== state.schema.nodes.doc)(state.selection);
|
|
409
379
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
380
|
+
editorView: editorView,
|
|
410
381
|
intl: intl,
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
maxWidth: maxWidth,
|
|
417
|
-
onChange: valid => {
|
|
418
|
-
if (valid) {
|
|
419
|
-
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, true, 'warning')(editorView.state, dispatch, editorView);
|
|
420
|
-
} else {
|
|
421
|
-
hoverDecoration === null || hoverDecoration === void 0 ? void 0 : hoverDecoration(mediaSingle, false)(editorView.state, dispatch, editorView);
|
|
422
|
-
}
|
|
423
|
-
},
|
|
424
|
-
onSubmit: ({
|
|
425
|
-
width,
|
|
426
|
-
validation
|
|
427
|
-
}) => {
|
|
428
|
-
var _pluginInjectionApi$a6;
|
|
429
|
-
const newLayout = calcNewLayout(width, layout, contentWidth, options.fullWidthEnabled, isNested);
|
|
430
|
-
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);
|
|
431
|
-
},
|
|
432
|
-
onMigrate: () => {
|
|
433
|
-
const tr = state.tr.setNodeMarkup(selectedMediaSingleNode.pos, undefined, {
|
|
434
|
-
...selectedMediaSingleNode.node.attrs,
|
|
435
|
-
width: pixelWidthFromElement,
|
|
436
|
-
widthType: 'pixel'
|
|
437
|
-
});
|
|
438
|
-
tr.setMeta('scrollIntoView', false);
|
|
439
|
-
tr.setSelection(NodeSelection.create(tr.doc, selectedMediaSingleNode.pos));
|
|
440
|
-
dispatch(tr);
|
|
441
|
-
}
|
|
382
|
+
selectedMediaSingleNode: selectedMediaSingleNode,
|
|
383
|
+
pluginInjectionApi: pluginInjectionApi,
|
|
384
|
+
pluginState: pluginState,
|
|
385
|
+
hoverDecoration: hoverDecoration,
|
|
386
|
+
isEditorFullWidthEnabled: options.fullWidthEnabled
|
|
442
387
|
});
|
|
443
388
|
}
|
|
444
389
|
};
|
|
@@ -496,14 +441,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
496
441
|
};
|
|
497
442
|
const openLink = () => {
|
|
498
443
|
if (editorView) {
|
|
499
|
-
var _pluginInjectionApi$
|
|
444
|
+
var _pluginInjectionApi$a6;
|
|
500
445
|
const {
|
|
501
446
|
state: {
|
|
502
447
|
tr
|
|
503
448
|
},
|
|
504
449
|
dispatch
|
|
505
450
|
} = editorView;
|
|
506
|
-
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({
|
|
507
452
|
eventType: EVENT_TYPE.TRACK,
|
|
508
453
|
action: ACTION.VISITED,
|
|
509
454
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
@@ -577,8 +522,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
577
522
|
});
|
|
578
523
|
}
|
|
579
524
|
if (allowAltTextOnImages && editorExperiment('platform_editor_controls', 'control')) {
|
|
580
|
-
var _pluginInjectionApi$
|
|
581
|
-
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), {
|
|
582
527
|
type: 'separator'
|
|
583
528
|
});
|
|
584
529
|
}
|
|
@@ -691,7 +636,9 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
691
636
|
providerFactory,
|
|
692
637
|
allowMediaInline,
|
|
693
638
|
allowResizing,
|
|
694
|
-
isViewOnly
|
|
639
|
+
isViewOnly,
|
|
640
|
+
allowResizingInTables,
|
|
641
|
+
allowAdvancedToolBarOptions
|
|
695
642
|
} = options;
|
|
696
643
|
const mediaPluginState = stateKey.getState(state);
|
|
697
644
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
@@ -723,6 +670,22 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
723
670
|
});
|
|
724
671
|
}
|
|
725
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
|
+
}
|
|
726
689
|
let items = [];
|
|
727
690
|
const parentMediaGroupNode = findParentNodeOfType(mediaGroup)(state.selection);
|
|
728
691
|
let selectedNodeType;
|
|
@@ -730,7 +693,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
730
693
|
selectedNodeType = state.selection.node.type;
|
|
731
694
|
}
|
|
732
695
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
733
|
-
var _pluginInjectionApi$
|
|
696
|
+
var _pluginInjectionApi$a8, _pluginInjectionApi$f3, _pluginInjectionApi$f4;
|
|
734
697
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
735
698
|
baseToolbar.getDomRef = () => {
|
|
736
699
|
var _mediaPluginState$ele;
|
|
@@ -739,7 +702,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
739
702
|
// eslint-disable-next-line @atlaskit/editor/no-as-casting
|
|
740
703
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
741
704
|
};
|
|
742
|
-
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);
|
|
743
706
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
744
707
|
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi, options);
|
|
745
708
|
} else {
|
|
@@ -753,7 +716,7 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
753
716
|
items = generateMediaSingleFloatingToolbar(state, intl, options, mediaPluginState, mediaLinkingState, pluginInjectionApi);
|
|
754
717
|
}
|
|
755
718
|
if (!mediaPluginState.isResizing && editorExperiment('platform_editor_controls', 'variant1')) {
|
|
756
|
-
var _pluginInjectionApi$
|
|
719
|
+
var _pluginInjectionApi$a9;
|
|
757
720
|
const lastItem = items.at(-1);
|
|
758
721
|
if ((lastItem === null || lastItem === void 0 ? void 0 : lastItem.type) === 'separator') {
|
|
759
722
|
lastItem.fullHeight = true;
|
|
@@ -768,21 +731,17 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
768
731
|
type: 'overflow-dropdown',
|
|
769
732
|
options: [...getLinkingDropdownOptions(state, intl, mediaLinkingState, allowMediaInline && selectedNodeType && selectedNodeType === mediaInline, allowLinking, isViewOnly), {
|
|
770
733
|
title: altTextTitle,
|
|
771
|
-
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),
|
|
772
735
|
icon: /*#__PURE__*/React.createElement(TextIcon, {
|
|
773
|
-
label:
|
|
736
|
+
label: ""
|
|
774
737
|
})
|
|
775
738
|
}, {
|
|
776
739
|
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
|
-
},
|
|
740
|
+
onClick: openPixelEditor(),
|
|
783
741
|
icon: /*#__PURE__*/React.createElement(GrowHorizontalIcon, {
|
|
784
|
-
label: "
|
|
785
|
-
})
|
|
742
|
+
label: ""
|
|
743
|
+
}),
|
|
744
|
+
testId: 'media-pixel-resizing-dropdown-option'
|
|
786
745
|
}, {
|
|
787
746
|
type: 'separator'
|
|
788
747
|
}, {
|
|
@@ -794,13 +753,13 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
794
753
|
return true;
|
|
795
754
|
},
|
|
796
755
|
icon: /*#__PURE__*/React.createElement(CopyIcon, {
|
|
797
|
-
label: "
|
|
756
|
+
label: ""
|
|
798
757
|
})
|
|
799
758
|
}, {
|
|
800
759
|
title: 'Delete',
|
|
801
760
|
onClick: remove,
|
|
802
761
|
icon: /*#__PURE__*/React.createElement(DeleteIcon, {
|
|
803
|
-
label: "
|
|
762
|
+
label: ""
|
|
804
763
|
})
|
|
805
764
|
}]
|
|
806
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() {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createCommand } from './index';
|
|
2
|
+
export var openPixelEditor = function openPixelEditor() {
|
|
3
|
+
return createCommand({
|
|
4
|
+
type: 'openPixelEditor'
|
|
5
|
+
});
|
|
6
|
+
};
|
|
7
|
+
export var closePixelEditor = function closePixelEditor() {
|
|
8
|
+
return createCommand({
|
|
9
|
+
type: 'closePixelEditor'
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export var closePixelEditorAndSave = function closePixelEditorAndSave(saveTransform) {
|
|
13
|
+
return createCommand({
|
|
14
|
+
type: 'closePixelEditor'
|
|
15
|
+
}, saveTransform);
|
|
16
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
var pluginKey = new PluginKey('mediaPixelResizingPlugin');
|
|
6
|
+
var _pluginFactory = pluginFactory(pluginKey, reducer, {
|
|
7
|
+
onSelectionChanged: function onSelectionChanged() {
|
|
8
|
+
return {
|
|
9
|
+
isPixelEditorOpen: false
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
}),
|
|
13
|
+
createPluginState = _pluginFactory.createPluginState,
|
|
14
|
+
createCommand = _pluginFactory.createCommand,
|
|
15
|
+
getPluginState = _pluginFactory.getPluginState;
|
|
16
|
+
export var createPlugin = function createPlugin(_ref) {
|
|
17
|
+
var dispatch = _ref.dispatch;
|
|
18
|
+
return new SafePlugin({
|
|
19
|
+
state: createPluginState(dispatch, {
|
|
20
|
+
isPixelEditorOpen: false
|
|
21
|
+
}),
|
|
22
|
+
key: pluginKey
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
export { createCommand, getPluginState };
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
export default (function (state, action) {
|
|
5
|
+
switch (action.type) {
|
|
6
|
+
case 'openPixelEditor':
|
|
7
|
+
{
|
|
8
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
9
|
+
isPixelEditorOpen: true
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
case 'closePixelEditor':
|
|
13
|
+
{
|
|
14
|
+
return _objectSpread(_objectSpread({}, state), {}, {
|
|
15
|
+
isPixelEditorOpen: false
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
default:
|
|
19
|
+
return state;
|
|
20
|
+
}
|
|
21
|
+
});
|