@atlaskit/editor-core 187.19.0 → 187.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/cjs/plugins/emoji/index.js +16 -5
- package/dist/cjs/plugins/index.js +2 -2
- package/dist/cjs/plugins/insert-block/index.js +3 -7
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/cjs/plugins/media/index.js +4 -3
- package/dist/cjs/plugins/media/pm-plugins/alt-text/commands.js +10 -7
- package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/cjs/plugins/media/pm-plugins/main.js +22 -10
- package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/cjs/plugins/media/toolbar/index.js +33 -19
- package/dist/cjs/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +15 -3
- package/dist/cjs/plugins/media/utils/media-single.js +13 -13
- package/dist/cjs/plugins/paste/handlers.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/cjs/plugins/selection/gap-cursor/styles.js +1 -1
- package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +3 -3
- package/dist/cjs/plugins/selection/gap-cursor/utils.js +6 -3
- package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +3 -3
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/cjs/utils/document.js +6 -24
- package/dist/cjs/utils/index.js +33 -105
- package/dist/cjs/utils/prosemirror/position.js +33 -41
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/emoji/commands/insert-emoji.js +24 -20
- package/dist/es2019/plugins/emoji/index.js +14 -4
- package/dist/es2019/plugins/index.js +1 -1
- package/dist/es2019/plugins/insert-block/index.js +3 -7
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +6 -3
- package/dist/es2019/plugins/media/index.js +6 -3
- package/dist/es2019/plugins/media/pm-plugins/alt-text/commands.js +3 -2
- package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/es2019/plugins/media/pm-plugins/main.js +16 -7
- package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/es2019/plugins/media/toolbar/index.js +34 -21
- package/dist/es2019/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +17 -4
- package/dist/es2019/plugins/media/utils/media-single.js +7 -8
- package/dist/es2019/plugins/paste/handlers.js +2 -3
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/es2019/plugins/selection/gap-cursor/styles.js +2 -1
- package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
- package/dist/es2019/plugins/selection/gap-cursor/utils.js +5 -2
- package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/es2019/utils/document.js +1 -20
- package/dist/es2019/utils/index.js +1 -99
- package/dist/es2019/utils/prosemirror/position.js +1 -51
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/emoji/commands/insert-emoji.js +21 -20
- package/dist/esm/plugins/emoji/index.js +14 -4
- package/dist/esm/plugins/index.js +1 -1
- package/dist/esm/plugins/insert-block/index.js +3 -7
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +4 -3
- package/dist/esm/plugins/media/index.js +4 -3
- package/dist/esm/plugins/media/pm-plugins/alt-text/commands.js +10 -7
- package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
- package/dist/esm/plugins/media/pm-plugins/main.js +18 -7
- package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
- package/dist/esm/plugins/media/toolbar/index.js +35 -21
- package/dist/esm/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.js +16 -4
- package/dist/esm/plugins/media/utils/media-single.js +7 -7
- package/dist/esm/plugins/paste/handlers.js +2 -3
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
- package/dist/esm/plugins/selection/gap-cursor/styles.js +1 -1
- package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
- package/dist/esm/plugins/selection/gap-cursor/utils.js +5 -2
- package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
- package/dist/esm/plugins/text-color/commands/toggle-color.js +3 -2
- package/dist/esm/utils/document.js +1 -22
- package/dist/esm/utils/index.js +1 -97
- package/dist/esm/utils/prosemirror/position.js +1 -39
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/default.d.ts +32 -32
- package/dist/types/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types/plugins/emoji/index.d.ts +9 -4
- package/dist/types/plugins/index.d.ts +1 -1
- package/dist/types/plugins/insert-block/index.d.ts +3 -1
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
- package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
- package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- package/dist/types/plugins/media/utils/media-single.d.ts +3 -3
- package/dist/types/plugins/paste/handlers.d.ts +2 -1
- package/dist/types/plugins/paste/index.d.ts +3 -1
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/utils/document.d.ts +2 -7
- package/dist/types/utils/index.d.ts +2 -6
- package/dist/types/utils/prosemirror/position.d.ts +1 -8
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +32 -32
- package/dist/types-ts4.5/plugins/emoji/commands/insert-emoji.d.ts +2 -2
- package/dist/types-ts4.5/plugins/emoji/index.d.ts +9 -4
- package/dist/types-ts4.5/plugins/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/insert-block/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/insert-block/ui/ToolbarInsertBlock/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/pm-plugins/main.d.ts +3 -0
- package/dist/types-ts4.5/plugins/media/pm-plugins/types.d.ts +2 -0
- package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
- package/dist/types-ts4.5/plugins/media/toolbar/index.d.ts +1 -2
- package/dist/types-ts4.5/plugins/media/ui/ResizableMediaSingle/ResizableMediaSingleNext.d.ts +1 -0
- package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +3 -3
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
- package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
- package/dist/types-ts4.5/plugins/selection/gap-cursor/utils.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/utils/document.d.ts +2 -7
- package/dist/types-ts4.5/utils/index.d.ts +2 -6
- package/dist/types-ts4.5/utils/prosemirror/position.d.ts +1 -8
- package/package.json +4 -4
- package/report.api.md +5 -0
- package/tmp/api-report-tmp.d.ts +5 -1
|
@@ -3,34 +3,38 @@ import { Fragment } from '@atlaskit/editor-prosemirror/model';
|
|
|
3
3
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
4
4
|
import { EVENT_TYPE, ACTION_SUBJECT_ID, ACTION_SUBJECT, ACTION } from '@atlaskit/editor-common/analytics';
|
|
5
5
|
export const insertEmoji = editorAnalyticsAPI => (emojiId, inputMethod) => {
|
|
6
|
-
return (
|
|
6
|
+
return ({
|
|
7
|
+
tr
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
doc,
|
|
11
|
+
selection
|
|
12
|
+
} = tr;
|
|
7
13
|
const {
|
|
8
14
|
emoji
|
|
9
|
-
} =
|
|
15
|
+
} = tr.doc.type.schema.nodes;
|
|
10
16
|
if (emoji && emojiId) {
|
|
11
17
|
const node = emoji.createChecked({
|
|
12
18
|
...emojiId,
|
|
13
19
|
text: emojiId.fallback || emojiId.shortName
|
|
14
20
|
});
|
|
15
|
-
const textNode =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})(tr);
|
|
29
|
-
}
|
|
30
|
-
dispatch(tr.setSelection(Selection.near(tr.doc.resolve(state.selection.$from.pos + fragment.size))));
|
|
21
|
+
const textNode = doc.type.schema.text(' ');
|
|
22
|
+
const fragment = Fragment.fromArray([node, textNode]);
|
|
23
|
+
const newTr = safeInsert(fragment)(tr);
|
|
24
|
+
if (inputMethod) {
|
|
25
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent({
|
|
26
|
+
action: ACTION.INSERTED,
|
|
27
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
28
|
+
actionSubjectId: ACTION_SUBJECT_ID.EMOJI,
|
|
29
|
+
attributes: {
|
|
30
|
+
inputMethod
|
|
31
|
+
},
|
|
32
|
+
eventType: EVENT_TYPE.TRACK
|
|
33
|
+
})(newTr);
|
|
31
34
|
}
|
|
32
|
-
|
|
35
|
+
newTr.setSelection(Selection.near(newTr.doc.resolve(selection.$from.pos + fragment.size)));
|
|
36
|
+
return newTr;
|
|
33
37
|
}
|
|
34
|
-
return
|
|
38
|
+
return null;
|
|
35
39
|
};
|
|
36
40
|
};
|
|
@@ -12,6 +12,7 @@ import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
|
|
|
12
12
|
import { EmojiNodeView } from './nodeviews/emoji';
|
|
13
13
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
14
14
|
import { openTypeAheadAtCursor } from '../type-ahead/transforms/open-typeahead-at-cursor';
|
|
15
|
+
import { insertEmoji } from './commands/insert-emoji';
|
|
15
16
|
export const emojiToTypeaheadItem = (emoji, emojiProvider) => ({
|
|
16
17
|
title: emoji.shortName || '',
|
|
17
18
|
key: emoji.id || emoji.shortName,
|
|
@@ -54,7 +55,8 @@ const memoizedToItem = memoize(emojiToTypeaheadItem);
|
|
|
54
55
|
export const defaultListLimit = 50;
|
|
55
56
|
const isFullShortName = query => query && query.length > 1 && query.charAt(0) === ':' && query.charAt(query.length - 1) === ':';
|
|
56
57
|
const TRIGGER = ':';
|
|
57
|
-
const emojiPlugin = (options, api) => {
|
|
58
|
+
export const emojiPlugin = (options, api) => {
|
|
59
|
+
var _api$dependencies$ana9;
|
|
58
60
|
const typeAhead = {
|
|
59
61
|
id: TypeAheadAvailableNodes.EMOJI,
|
|
60
62
|
trigger: TRIGGER,
|
|
@@ -175,6 +177,15 @@ const emojiPlugin = (options, api) => {
|
|
|
175
177
|
}
|
|
176
178
|
}];
|
|
177
179
|
},
|
|
180
|
+
getSharedState(editorState) {
|
|
181
|
+
if (!editorState) {
|
|
182
|
+
return undefined;
|
|
183
|
+
}
|
|
184
|
+
return emojiPluginKey.getState(editorState);
|
|
185
|
+
},
|
|
186
|
+
commands: {
|
|
187
|
+
insertEmoji: insertEmoji(api === null || api === void 0 ? void 0 : (_api$dependencies$ana9 = api.dependencies.analytics) === null || _api$dependencies$ana9 === void 0 ? void 0 : _api$dependencies$ana9.actions)
|
|
188
|
+
},
|
|
178
189
|
pluginsOptions: {
|
|
179
190
|
quickInsert: ({
|
|
180
191
|
formatMessage
|
|
@@ -186,13 +197,13 @@ const emojiPlugin = (options, api) => {
|
|
|
186
197
|
keyshortcut: ':',
|
|
187
198
|
icon: () => /*#__PURE__*/React.createElement(IconEmoji, null),
|
|
188
199
|
action(insert, state) {
|
|
189
|
-
var _api$dependencies$
|
|
200
|
+
var _api$dependencies$ana10;
|
|
190
201
|
const tr = insert(undefined);
|
|
191
202
|
openTypeAheadAtCursor({
|
|
192
203
|
triggerHandler: typeAhead,
|
|
193
204
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
194
205
|
})(tr);
|
|
195
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
206
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana10 = api.dependencies.analytics) === null || _api$dependencies$ana10 === void 0 ? void 0 : _api$dependencies$ana10.actions.attachAnalyticsEvent({
|
|
196
207
|
action: ACTION.INVOKED,
|
|
197
208
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
198
209
|
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_EMOJI,
|
|
@@ -208,7 +219,6 @@ const emojiPlugin = (options, api) => {
|
|
|
208
219
|
}
|
|
209
220
|
};
|
|
210
221
|
};
|
|
211
|
-
export default emojiPlugin;
|
|
212
222
|
|
|
213
223
|
/**
|
|
214
224
|
* Actions
|
|
@@ -6,7 +6,7 @@ export { default as clearMarksOnChangeToEmptyDocumentPlugin } from './clear-mark
|
|
|
6
6
|
export { default as codeBlockPlugin } from './code-block';
|
|
7
7
|
export { default as collabEditPlugin } from './collab-edit';
|
|
8
8
|
export { default as datePlugin } from './date';
|
|
9
|
-
export {
|
|
9
|
+
export { emojiPlugin } from './emoji';
|
|
10
10
|
export { default as extensionPlugin } from './extension';
|
|
11
11
|
export { default as fakeTextCursorPlugin } from './fake-text-cursor';
|
|
12
12
|
export { default as helpDialogPlugin } from './help-dialog';
|
|
@@ -5,7 +5,6 @@ import { stateKey as mediaStateKey } from '../media/pm-plugins/plugin-key';
|
|
|
5
5
|
import { isTypeAheadAllowed } from '../type-ahead/utils';
|
|
6
6
|
import { pluginKey as layoutStateKey } from '../layout';
|
|
7
7
|
import { insertMacroFromMacroBrowser } from '../macro';
|
|
8
|
-
import { emojiPluginKey } from '../emoji';
|
|
9
8
|
import WithPluginState from '../../ui/WithPluginState';
|
|
10
9
|
import ToolbarInsertBlock from './ui/ToolbarInsertBlock';
|
|
11
10
|
import { pluginKey as typeAheadPluginKey } from '../type-ahead/pm-plugins/key';
|
|
@@ -62,7 +61,6 @@ const insertBlockPlugin = (options = {}, api) => {
|
|
|
62
61
|
blockTypeState: blockTypeStateKey,
|
|
63
62
|
mediaState: mediaStateKey,
|
|
64
63
|
macroState: macroStateKey,
|
|
65
|
-
emojiState: emojiPluginKey,
|
|
66
64
|
placeholderTextState: placeholderTextStateKey,
|
|
67
65
|
layoutState: layoutStateKey
|
|
68
66
|
},
|
|
@@ -70,7 +68,6 @@ const insertBlockPlugin = (options = {}, api) => {
|
|
|
70
68
|
blockTypeState,
|
|
71
69
|
mediaState,
|
|
72
70
|
macroState = {},
|
|
73
|
-
emojiState,
|
|
74
71
|
placeholderTextState,
|
|
75
72
|
layoutState
|
|
76
73
|
}) => /*#__PURE__*/React.createElement(ToolbarInsertBlockWithInjectionApi, {
|
|
@@ -90,7 +87,6 @@ const insertBlockPlugin = (options = {}, api) => {
|
|
|
90
87
|
blockTypeState: blockTypeState,
|
|
91
88
|
mediaState: mediaState,
|
|
92
89
|
macroState: macroState,
|
|
93
|
-
emojiState: emojiState,
|
|
94
90
|
placeholderTextState: placeholderTextState,
|
|
95
91
|
layoutState: layoutState,
|
|
96
92
|
providers: providers,
|
|
@@ -124,7 +120,6 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
124
120
|
blockTypeState,
|
|
125
121
|
mediaState,
|
|
126
122
|
macroState,
|
|
127
|
-
emojiState,
|
|
128
123
|
placeholderTextState,
|
|
129
124
|
layoutState,
|
|
130
125
|
featureFlags
|
|
@@ -135,8 +130,9 @@ function ToolbarInsertBlockWithInjectionApi({
|
|
|
135
130
|
dateState,
|
|
136
131
|
hyperlinkState,
|
|
137
132
|
imageUploadState,
|
|
138
|
-
mentionState
|
|
139
|
-
|
|
133
|
+
mentionState,
|
|
134
|
+
emojiState
|
|
135
|
+
} = useSharedPluginState(pluginInjectionApi, ['hyperlink', 'date', 'imageUpload', 'mention', 'emoji']);
|
|
140
136
|
return /*#__PURE__*/React.createElement(ToolbarInsertBlock, {
|
|
141
137
|
pluginInjectionApi: pluginInjectionApi,
|
|
142
138
|
buttons: buttons,
|
|
@@ -16,8 +16,7 @@ import { insertTaskDecisionCommand } from '../../../tasks-and-decisions/commands
|
|
|
16
16
|
import { insertExpand } from '../../../expand/commands';
|
|
17
17
|
import { createTypeAheadTools } from '../../../type-ahead/api';
|
|
18
18
|
import { updateStatusWithAnalytics } from '../../../status/actions';
|
|
19
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '
|
|
20
|
-
import { insertEmoji } from '../../../emoji/commands/insert-emoji';
|
|
19
|
+
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
21
20
|
import { messages } from './messages';
|
|
22
21
|
import { createItems } from './create-items';
|
|
23
22
|
import { BlockInsertMenu } from './block-insert-menu';
|
|
@@ -283,8 +282,12 @@ export class ToolbarInsertBlock extends React.PureComponent {
|
|
|
283
282
|
return true;
|
|
284
283
|
});
|
|
285
284
|
_defineProperty(this, "handleSelectedEmoji", emojiId => {
|
|
285
|
+
var _pluginInjectionApi$d8;
|
|
286
|
+
const {
|
|
287
|
+
pluginInjectionApi
|
|
288
|
+
} = this.props;
|
|
286
289
|
this.props.editorView.focus();
|
|
287
|
-
|
|
290
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.executeCommand((_pluginInjectionApi$d8 = pluginInjectionApi.dependencies.emoji) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.commands.insertEmoji(emojiId, INPUT_METHOD.PICKER));
|
|
288
291
|
this.toggleEmojiPicker();
|
|
289
292
|
return true;
|
|
290
293
|
});
|
|
@@ -130,7 +130,10 @@ const mediaPlugin = (options = {}, api) => {
|
|
|
130
130
|
name: 'mediaAltTextKeymap',
|
|
131
131
|
plugin: ({
|
|
132
132
|
schema
|
|
133
|
-
}) =>
|
|
133
|
+
}) => {
|
|
134
|
+
var _api$dependencies$ana2;
|
|
135
|
+
return keymapMediaAltTextPlugin(schema, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
|
|
136
|
+
}
|
|
134
137
|
});
|
|
135
138
|
}
|
|
136
139
|
if (options && options.allowLinking) {
|
|
@@ -226,11 +229,11 @@ const mediaPlugin = (options = {}, api) => {
|
|
|
226
229
|
keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
|
|
227
230
|
icon: () => /*#__PURE__*/React.createElement(IconImages, null),
|
|
228
231
|
action(insert, state) {
|
|
229
|
-
var _api$dependencies$
|
|
232
|
+
var _api$dependencies$ana3;
|
|
230
233
|
const pluginState = pluginKey.getState(state);
|
|
231
234
|
pluginState === null || pluginState === void 0 ? void 0 : pluginState.showMediaPicker();
|
|
232
235
|
const tr = insert('');
|
|
233
|
-
api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
236
|
+
api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions.attachAnalyticsEvent({
|
|
234
237
|
action: ACTION.OPENED,
|
|
235
238
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
236
239
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { createCommand } from '.';
|
|
2
2
|
import { isSelectionMediaSingleNode, getMediaNodeFromSelection } from '../../utils/media-common';
|
|
3
|
-
import { ACTION_SUBJECT, EVENT_TYPE,
|
|
3
|
+
import { ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID, ACTION } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
5
|
const createCommandWithAnalytics = (actionType, action, transform) => {
|
|
5
|
-
return withAnalytics({
|
|
6
|
+
return editorAnalyticsAPI => withAnalytics(editorAnalyticsAPI, {
|
|
6
7
|
action: actionType,
|
|
7
8
|
actionSubject: ACTION_SUBJECT.MEDIA,
|
|
8
9
|
actionSubjectId: ACTION_SUBJECT_ID.ALT_TEXT,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
2
2
|
import * as keymaps from '../../../../keymaps';
|
|
3
3
|
import { openMediaAltTextMenu, closeMediaAltTextMenu } from './commands';
|
|
4
|
-
export default function keymapPlugin(schema) {
|
|
4
|
+
export default function keymapPlugin(schema, editorAnalyticsAPI) {
|
|
5
5
|
const list = {};
|
|
6
|
-
keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu, list);
|
|
6
|
+
keymaps.bindKeymapWithCommand(keymaps.addAltText.common, openMediaAltTextMenu(editorAnalyticsAPI), list);
|
|
7
7
|
keymaps.bindKeymapWithCommand(keymaps.escape.common, closeMediaAltTextMenu, list);
|
|
8
8
|
return keymap(list);
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ import * as helpers from '../commands/helpers';
|
|
|
16
16
|
import { updateMediaSingleNodeAttrs } from '../commands/helpers';
|
|
17
17
|
import { stateKey } from './plugin-key';
|
|
18
18
|
import PickerFacade from '../picker-facade';
|
|
19
|
-
import { INPUT_METHOD } from '
|
|
19
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
20
20
|
import { isInEmptyLine } from '../../../utils/document';
|
|
21
21
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
22
22
|
import { isInListItem } from '../../../utils';
|
|
@@ -27,6 +27,7 @@ import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
|
27
27
|
export { stateKey } from './plugin-key';
|
|
28
28
|
export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
29
29
|
export const MEDIA_PLUGIN_IS_RESIZING_KEY = 'mediaSinglePlugin.isResizing';
|
|
30
|
+
export const MEDIA_PLUGIN_RESIZING_WIDTH_KEY = 'mediaSinglePlugin.resizing-width';
|
|
30
31
|
const createDropPlaceholder = (intl, allowDropLine) => {
|
|
31
32
|
const dropPlaceholder = document.createElement('div');
|
|
32
33
|
const createElement = React.createElement;
|
|
@@ -55,6 +56,7 @@ export class MediaPluginStateImplementation {
|
|
|
55
56
|
_defineProperty(this, "layout", 'center');
|
|
56
57
|
_defineProperty(this, "mediaNodes", []);
|
|
57
58
|
_defineProperty(this, "isResizing", false);
|
|
59
|
+
_defineProperty(this, "resizingWidth", 0);
|
|
58
60
|
_defineProperty(this, "destroyed", false);
|
|
59
61
|
_defineProperty(this, "removeOnCloseListener", () => {});
|
|
60
62
|
_defineProperty(this, "onPopupToggleCallback", () => {});
|
|
@@ -170,16 +172,16 @@ export class MediaPluginStateImplementation {
|
|
|
170
172
|
});
|
|
171
173
|
}
|
|
172
174
|
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
173
|
-
var _this$pluginInjection;
|
|
175
|
+
var _this$pluginInjection, _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
174
176
|
// read width state right before inserting to get up-to-date and define values
|
|
175
177
|
const widthPluginState = (_this$pluginInjection = this.pluginInjectionApi) === null || _this$pluginInjection === void 0 ? void 0 : _this$pluginInjection.dependencies.width.sharedState.currentState();
|
|
176
|
-
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState);
|
|
178
|
+
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour, widthPluginState, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions);
|
|
177
179
|
} else if (getMediaFeatureFlag('mediaInline', (_this$mediaOptions2 = this.mediaOptions) === null || _this$mediaOptions2 === void 0 ? void 0 : _this$mediaOptions2.featureFlags) && !isInEmptyLine(state) && (!isInsidePotentialEmptyParagraph(state) || isInListItem(state)) && canInsertMediaInline(state)) {
|
|
178
|
-
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
179
|
-
insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.analytics) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
180
|
-
} else {
|
|
181
180
|
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
182
|
-
|
|
181
|
+
insertMediaInlineNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.analytics) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions)(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
182
|
+
} else {
|
|
183
|
+
var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
|
|
184
|
+
insertMediaGroupNode(pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : (_pluginInjectionApi$d6 = _pluginInjectionApi$d5.analytics) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.actions)(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
// do events when media state changes
|
|
@@ -428,6 +430,9 @@ export class MediaPluginStateImplementation {
|
|
|
428
430
|
setIsResizing(isResizing) {
|
|
429
431
|
this.isResizing = isResizing;
|
|
430
432
|
}
|
|
433
|
+
setResizingWidth(width) {
|
|
434
|
+
this.resizingWidth = width;
|
|
435
|
+
}
|
|
431
436
|
updateElement() {
|
|
432
437
|
let newElement;
|
|
433
438
|
const selectedContainer = this.selectedMediaContainerNode();
|
|
@@ -530,9 +535,13 @@ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch,
|
|
|
530
535
|
},
|
|
531
536
|
apply(tr, pluginState) {
|
|
532
537
|
const isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
|
|
538
|
+
const resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
|
|
533
539
|
if (isResizing !== undefined) {
|
|
534
540
|
pluginState.setIsResizing(isResizing);
|
|
535
541
|
}
|
|
542
|
+
if (resizingWidth) {
|
|
543
|
+
pluginState.setResizingWidth(resizingWidth);
|
|
544
|
+
}
|
|
536
545
|
|
|
537
546
|
// remap editing media single position if we're in collab
|
|
538
547
|
if (typeof pluginState.editingMediaSinglePos === 'number') {
|
|
@@ -6,7 +6,7 @@ import AltTextEdit, { CONTAINER_WIDTH_IN_PX } from '../pm-plugins/alt-text/ui/Al
|
|
|
6
6
|
import { getMediaNodeFromSelection } from '../utils/media-common';
|
|
7
7
|
import { ClassNames } from '../pm-plugins/alt-text/style';
|
|
8
8
|
const testId = 'alt-text-edit-button';
|
|
9
|
-
export const altTextButton = (intl, state) => {
|
|
9
|
+
export const altTextButton = (intl, state, editorAnalyticsAPI) => {
|
|
10
10
|
const mediaNode = getMediaNodeFromSelection(state);
|
|
11
11
|
const message = mediaNode && mediaNode.attrs.alt ? messages.editAltText : messages.altText;
|
|
12
12
|
const title = intl.formatMessage(message);
|
|
@@ -14,7 +14,7 @@ export const altTextButton = (intl, state) => {
|
|
|
14
14
|
title,
|
|
15
15
|
id: 'editor.media.altText',
|
|
16
16
|
type: 'button',
|
|
17
|
-
onClick: openMediaAltTextMenu,
|
|
17
|
+
onClick: openMediaAltTextMenu(editorAnalyticsAPI),
|
|
18
18
|
showTitle: true,
|
|
19
19
|
testId,
|
|
20
20
|
tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
@@ -25,8 +25,8 @@ import ImageBorderItem from '../ui/ImageBorder';
|
|
|
25
25
|
import { currentMediaNodeBorderMark } from '../utils/current-media-node';
|
|
26
26
|
import { shouldShowImageBorder } from './imageBorder';
|
|
27
27
|
import { PixelEntry } from '../ui/PixelEntry';
|
|
28
|
-
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH } from '@atlaskit/editor-common/media-single';
|
|
29
|
-
import { akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
28
|
+
import { DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_GUTTER_SIZE, calcMediaSinglePixelWidth } from '@atlaskit/editor-common/media-single';
|
|
29
|
+
import { akEditorDefaultLayoutWidth, akEditorFullWidthLayoutWidth } from '@atlaskit/editor-shared-styles';
|
|
30
30
|
const remove = (state, dispatch) => {
|
|
31
31
|
if (dispatch) {
|
|
32
32
|
dispatch(removeSelectedNode(state.tr));
|
|
@@ -191,7 +191,7 @@ const generateMediaInlineFloatingToolbar = (state, intl, mediaPluginState, hover
|
|
|
191
191
|
return items;
|
|
192
192
|
};
|
|
193
193
|
const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, mediaLinkingState, pluginInjectionApi, getEditorFeatureFlags) => {
|
|
194
|
-
var _pluginInjectionApi$
|
|
194
|
+
var _pluginInjectionApi$d8;
|
|
195
195
|
const {
|
|
196
196
|
mediaSingle
|
|
197
197
|
} = state.schema.nodes;
|
|
@@ -266,6 +266,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
266
266
|
type: 'custom',
|
|
267
267
|
fallback: [],
|
|
268
268
|
render: editorView => {
|
|
269
|
+
var _widthPlugin$sharedSt2, _widthPlugin$sharedSt3;
|
|
269
270
|
if (!editorView) {
|
|
270
271
|
return null;
|
|
271
272
|
}
|
|
@@ -274,6 +275,8 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
274
275
|
dispatch
|
|
275
276
|
} = editorView;
|
|
276
277
|
const selectedMediaSingleNode = getSelectedMediaSingle(state);
|
|
278
|
+
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;
|
|
279
|
+
const containerWidth = (widthPlugin === null || widthPlugin === void 0 ? void 0 : (_widthPlugin$sharedSt3 = widthPlugin.sharedState.currentState()) === null || _widthPlugin$sharedSt3 === void 0 ? void 0 : _widthPlugin$sharedSt3.width) || akEditorFullWidthLayoutWidth;
|
|
277
280
|
if (!selectedMediaSingleNode) {
|
|
278
281
|
return null;
|
|
279
282
|
}
|
|
@@ -282,15 +285,26 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
282
285
|
return null;
|
|
283
286
|
}
|
|
284
287
|
const {
|
|
285
|
-
width: singleMediaWidth
|
|
288
|
+
width: singleMediaWidth,
|
|
289
|
+
widthType,
|
|
290
|
+
layout
|
|
286
291
|
} = selectedMediaSingleNode.node.attrs;
|
|
287
292
|
const {
|
|
288
293
|
width: mediaWidth,
|
|
289
294
|
height: mediaHeight
|
|
290
295
|
} = selectedMediaNode.attrs;
|
|
296
|
+
const pixelWidth = calcMediaSinglePixelWidth({
|
|
297
|
+
width: singleMediaWidth,
|
|
298
|
+
widthType,
|
|
299
|
+
origWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
300
|
+
layout,
|
|
301
|
+
contentWidth,
|
|
302
|
+
containerWidth,
|
|
303
|
+
gutterOffset: MEDIA_SINGLE_GUTTER_SIZE
|
|
304
|
+
});
|
|
291
305
|
return /*#__PURE__*/React.createElement(PixelEntry, {
|
|
292
306
|
intl: intl,
|
|
293
|
-
width:
|
|
307
|
+
width: pluginState.isResizing ? pluginState.resizingWidth : pixelWidth,
|
|
294
308
|
mediaWidth: mediaWidth || DEFAULT_IMAGE_WIDTH,
|
|
295
309
|
mediaHeight: mediaHeight || DEFAULT_IMAGE_HEIGHT,
|
|
296
310
|
validate: value => {
|
|
@@ -312,11 +326,9 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
312
326
|
});
|
|
313
327
|
}
|
|
314
328
|
});
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
});
|
|
319
|
-
}
|
|
329
|
+
toolbarButtons.push({
|
|
330
|
+
type: 'separator'
|
|
331
|
+
});
|
|
320
332
|
}
|
|
321
333
|
if (allowLinking && shouldShowMediaLinkToolbar(state)) {
|
|
322
334
|
toolbarButtons.push({
|
|
@@ -368,13 +380,14 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
368
380
|
}
|
|
369
381
|
}
|
|
370
382
|
if (allowAltTextOnImages) {
|
|
371
|
-
|
|
383
|
+
var _pluginInjectionApi$d7;
|
|
384
|
+
toolbarButtons.push(altTextButton(intl, state, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.actions), {
|
|
372
385
|
type: 'separator'
|
|
373
386
|
});
|
|
374
387
|
}
|
|
375
388
|
const {
|
|
376
389
|
hoverDecoration
|
|
377
|
-
} = (_pluginInjectionApi$
|
|
390
|
+
} = (_pluginInjectionApi$d8 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d8 !== void 0 ? _pluginInjectionApi$d8 : {};
|
|
378
391
|
const removeButton = {
|
|
379
392
|
id: 'editor.media.delete',
|
|
380
393
|
type: 'button',
|
|
@@ -402,7 +415,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
402
415
|
return items;
|
|
403
416
|
};
|
|
404
417
|
export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) => {
|
|
405
|
-
var _pluginInjectionApi$
|
|
418
|
+
var _pluginInjectionApi$d9;
|
|
406
419
|
const {
|
|
407
420
|
media,
|
|
408
421
|
mediaInline,
|
|
@@ -421,8 +434,8 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
421
434
|
const mediaLinkingState = getMediaLinkingState(state);
|
|
422
435
|
const {
|
|
423
436
|
hoverDecoration
|
|
424
|
-
} = (_pluginInjectionApi$
|
|
425
|
-
if (!mediaPluginState
|
|
437
|
+
} = (_pluginInjectionApi$d9 = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.decorations.actions) !== null && _pluginInjectionApi$d9 !== void 0 ? _pluginInjectionApi$d9 : {};
|
|
438
|
+
if (!mediaPluginState) {
|
|
426
439
|
return;
|
|
427
440
|
}
|
|
428
441
|
const nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
@@ -440,10 +453,10 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
440
453
|
if (allowAltTextOnImages) {
|
|
441
454
|
const mediaAltTextPluginState = getMediaAltTextPluginState(state);
|
|
442
455
|
if (mediaAltTextPluginState.isAltTextEditorOpen) {
|
|
443
|
-
var _pluginInjectionApi$
|
|
456
|
+
var _pluginInjectionApi$d10;
|
|
444
457
|
return getAltTextToolbar(baseToolbar, {
|
|
445
458
|
altTextValidator,
|
|
446
|
-
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
459
|
+
forceFocusSelector: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d10 = pluginInjectionApi.dependencies.floatingToolbar.actions) === null || _pluginInjectionApi$d10 === void 0 ? void 0 : _pluginInjectionApi$d10.forceFocusSelector
|
|
447
460
|
});
|
|
448
461
|
}
|
|
449
462
|
}
|
|
@@ -454,22 +467,22 @@ export const floatingToolbar = (state, intl, options = {}, pluginInjectionApi) =
|
|
|
454
467
|
selectedNodeType = state.selection.node.type;
|
|
455
468
|
}
|
|
456
469
|
if (allowMediaInline && (parentMediaGroupNode === null || parentMediaGroupNode === void 0 ? void 0 : parentMediaGroupNode.node.type) === mediaGroup) {
|
|
457
|
-
var _pluginInjectionApi$
|
|
470
|
+
var _pluginInjectionApi$d11, _pluginInjectionApi$d12;
|
|
458
471
|
const mediaOffset = state.selection.$from.parentOffset + 1;
|
|
459
472
|
baseToolbar.getDomRef = () => {
|
|
460
473
|
var _mediaPluginState$ele;
|
|
461
474
|
const selector = mediaFilmstripItemDOMSelector(mediaOffset);
|
|
462
475
|
return (_mediaPluginState$ele = mediaPluginState.element) === null || _mediaPluginState$ele === void 0 ? void 0 : _mediaPluginState$ele.querySelector(selector);
|
|
463
476
|
};
|
|
464
|
-
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
477
|
+
items = generateMediaCardFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d11 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d11 === void 0 ? void 0 : (_pluginInjectionApi$d12 = _pluginInjectionApi$d11.analytics) === null || _pluginInjectionApi$d12 === void 0 ? void 0 : _pluginInjectionApi$d12.actions);
|
|
465
478
|
} else if (allowMediaInline && selectedNodeType && selectedNodeType === mediaInline) {
|
|
466
|
-
var _pluginInjectionApi$
|
|
479
|
+
var _pluginInjectionApi$d13, _pluginInjectionApi$d14;
|
|
467
480
|
baseToolbar.getDomRef = () => {
|
|
468
481
|
var _mediaPluginState$ele2;
|
|
469
482
|
const element = (_mediaPluginState$ele2 = mediaPluginState.element) === null || _mediaPluginState$ele2 === void 0 ? void 0 : _mediaPluginState$ele2.querySelector(`.${MediaInlineNodeSelector}`);
|
|
470
483
|
return element || mediaPluginState.element;
|
|
471
484
|
};
|
|
472
|
-
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
485
|
+
items = generateMediaInlineFloatingToolbar(state, intl, mediaPluginState, hoverDecoration, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d13 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d13 === void 0 ? void 0 : (_pluginInjectionApi$d14 = _pluginInjectionApi$d13.analytics) === null || _pluginInjectionApi$d14 === void 0 ? void 0 : _pluginInjectionApi$d14.actions);
|
|
473
486
|
} else {
|
|
474
487
|
baseToolbar.getDomRef = () => {
|
|
475
488
|
var _mediaPluginState$ele3;
|
|
@@ -12,9 +12,11 @@ import { ResizerNext } from '@atlaskit/editor-common/resizer';
|
|
|
12
12
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import { richMediaClassName, resizerStyles } from '@atlaskit/editor-common/styles';
|
|
15
|
-
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
15
|
+
import { MEDIA_SINGLE_MIN_PIXEL_WIDTH, MEDIA_SINGLE_SNAP_GAP, MEDIA_SINGLE_RESIZE_THROTTLE_TIME, calculateOffsetLeft, DEFAULT_IMAGE_WIDTH, calcMediaSingleMaxWidth } from '@atlaskit/editor-common/media-single';
|
|
16
16
|
import { findClosestSnap, getGuidelinesWithHighlights, generateDefaultGuidelines, generateDynamicGuidelines, getGuidelineSnaps } from '@atlaskit/editor-common/guideline';
|
|
17
17
|
import memoizeOne from 'memoize-one';
|
|
18
|
+
import throttle from 'lodash/throttle';
|
|
19
|
+
import { MEDIA_PLUGIN_IS_RESIZING_KEY, MEDIA_PLUGIN_RESIZING_WIDTH_KEY } from '../../pm-plugins/main';
|
|
18
20
|
export const resizerNextTestId = 'mediaSingle.resizerNext.testid';
|
|
19
21
|
|
|
20
22
|
// TODO: Create new fixed image size event
|
|
@@ -122,7 +124,16 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
122
124
|
dispatch
|
|
123
125
|
} = this.props.view;
|
|
124
126
|
const tr = state.tr;
|
|
125
|
-
tr.setMeta(
|
|
127
|
+
tr.setMeta(MEDIA_PLUGIN_IS_RESIZING_KEY, isResizing);
|
|
128
|
+
return dispatch(tr);
|
|
129
|
+
});
|
|
130
|
+
_defineProperty(this, "updateSizeInPluginState", width => {
|
|
131
|
+
const {
|
|
132
|
+
state,
|
|
133
|
+
dispatch
|
|
134
|
+
} = this.props.view;
|
|
135
|
+
const tr = state.tr;
|
|
136
|
+
tr.setMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY, width);
|
|
126
137
|
return dispatch(tr);
|
|
127
138
|
});
|
|
128
139
|
_defineProperty(this, "calcMaxWidth", memoizeOne((contentWidth, containerWidth, fullWidthMode) => {
|
|
@@ -167,11 +178,12 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
167
178
|
});
|
|
168
179
|
this.selectCurrentMediaNode();
|
|
169
180
|
this.setIsResizing(true);
|
|
181
|
+
this.updateSizeInPluginState(this.state.size.width);
|
|
170
182
|
// re-calucate guidelines
|
|
171
183
|
this.guidelines = this.getAllGuidelines();
|
|
172
184
|
return 0;
|
|
173
185
|
});
|
|
174
|
-
_defineProperty(this, "handleResize", (size, delta) => {
|
|
186
|
+
_defineProperty(this, "handleResize", throttle((size, delta) => {
|
|
175
187
|
const {
|
|
176
188
|
width: originalWidth,
|
|
177
189
|
height: originalHeight,
|
|
@@ -193,10 +205,11 @@ class ResizableMediaSingleNext extends React.Component {
|
|
|
193
205
|
},
|
|
194
206
|
snaps: guidelineSnaps.snaps
|
|
195
207
|
});
|
|
208
|
+
this.updateSizeInPluginState(width);
|
|
196
209
|
if (calculatedWidthWithLayout.layout !== layout) {
|
|
197
210
|
updateSize(width, calculatedWidthWithLayout.layout);
|
|
198
211
|
}
|
|
199
|
-
});
|
|
212
|
+
}, MEDIA_SINGLE_RESIZE_THROTTLE_TIME));
|
|
200
213
|
_defineProperty(this, "handleResizeStop", (size, delta) => {
|
|
201
214
|
const {
|
|
202
215
|
width: originalWidth,
|
|
@@ -5,7 +5,6 @@ import { isEmptyParagraph } from '@atlaskit/editor-common/utils';
|
|
|
5
5
|
import { getMediaSingleInitialWidth } from '@atlaskit/editor-common/media-single';
|
|
6
6
|
import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
7
7
|
import { mapSlice } from '../../../utils/slice';
|
|
8
|
-
import { addAnalytics } from '../../analytics';
|
|
9
8
|
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
10
9
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '@atlaskit/editor-common/insert';
|
|
11
10
|
import { isImage } from './is-image';
|
|
@@ -26,7 +25,7 @@ const getInsertMediaAnalytics = (inputMethod, fileExtension) => ({
|
|
|
26
25
|
function shouldAddParagraph(state) {
|
|
27
26
|
return atTheBeginningOfBlock(state) && !checkNodeDown(state.selection, state.doc, isEmptyParagraph);
|
|
28
27
|
}
|
|
29
|
-
function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
28
|
+
function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}, editorAnalyticsAPI) {
|
|
30
29
|
return function (state, dispatch) {
|
|
31
30
|
const {
|
|
32
31
|
tr,
|
|
@@ -46,7 +45,7 @@ function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
|
46
45
|
}
|
|
47
46
|
tr.replaceSelection(new Slice(Fragment.from(nodes), 0, openEnd));
|
|
48
47
|
if (inputMethod) {
|
|
49
|
-
|
|
48
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
50
49
|
}
|
|
51
50
|
if (dispatch) {
|
|
52
51
|
dispatch(tr);
|
|
@@ -55,7 +54,7 @@ function insertNodesWithOptionalParagraph(nodes, analyticsAttributes = {}) {
|
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
56
|
export const isMediaSingle = (schema, fileMimeType) => !!schema.nodes.mediaSingle && isImage(fileMimeType);
|
|
58
|
-
export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
|
|
57
|
+
export const insertMediaAsMediaSingle = (view, node, inputMethod, editorAnalyticsAPI) => {
|
|
59
58
|
const {
|
|
60
59
|
state,
|
|
61
60
|
dispatch
|
|
@@ -78,9 +77,9 @@ export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
|
|
|
78
77
|
inputMethod,
|
|
79
78
|
fileExtension: node.attrs.__fileMimeType
|
|
80
79
|
};
|
|
81
|
-
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
|
|
80
|
+
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
|
|
82
81
|
};
|
|
83
|
-
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) => {
|
|
82
|
+
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) => {
|
|
84
83
|
var _state$selection$$fro;
|
|
85
84
|
if (collection === undefined) {
|
|
86
85
|
return false;
|
|
@@ -113,7 +112,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
113
112
|
insertNodesWithOptionalParagraph([node], {
|
|
114
113
|
fileExtension,
|
|
115
114
|
inputMethod
|
|
116
|
-
})(state, dispatch);
|
|
115
|
+
}, editorAnalyticsAPI)(state, dispatch);
|
|
117
116
|
} else {
|
|
118
117
|
let tr = null;
|
|
119
118
|
if (newInsertionBehaviour) {
|
|
@@ -124,7 +123,7 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
124
123
|
tr = pmSafeInsert(content, undefined, true)(state.tr);
|
|
125
124
|
}
|
|
126
125
|
if (inputMethod) {
|
|
127
|
-
|
|
126
|
+
editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
|
|
128
127
|
}
|
|
129
128
|
dispatch(tr);
|
|
130
129
|
}
|