@atlaskit/editor-core 150.0.2 → 151.1.1
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 +69 -0
- package/dist/cjs/actions/index.js +5 -23
- package/dist/cjs/create-editor/ErrorBoundary.js +113 -79
- package/dist/cjs/create-editor/ReactEditorView.js +145 -31
- package/dist/cjs/create-editor/create-plugins-list.js +8 -2
- package/dist/cjs/editor.js +101 -40
- package/dist/cjs/labs/next/presets/cxhtml.js +2 -1
- package/dist/cjs/plugins/analytics/types/enums.js +3 -1
- package/dist/cjs/plugins/base/index.js +4 -3
- package/dist/cjs/plugins/base/pm-plugins/frozen-editor.js +66 -36
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/cjs/plugins/card/index.js +13 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/cjs/plugins/card/pm-plugins/main.js +7 -2
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +10 -3
- package/dist/cjs/plugins/code-bidi-warning/index.js +25 -0
- package/dist/cjs/plugins/code-bidi-warning/plugin-key.js +11 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/main.js +43 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +118 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/reducer.js +12 -0
- package/dist/cjs/plugins/code-bidi-warning/pm-plugins/types.js +5 -0
- package/dist/cjs/plugins/code-block/index.js +10 -6
- package/dist/cjs/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/cjs/plugins/code-block/pm-plugins/main.js +12 -3
- package/dist/cjs/plugins/code-block/toolbar.js +1 -1
- package/dist/cjs/plugins/emoji/styles.js +1 -1
- package/dist/cjs/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/cjs/plugins/extension/toolbar.js +28 -23
- package/dist/cjs/plugins/feature-flags-context/feature-flags-from-props.js +9 -3
- package/dist/cjs/plugins/find-replace/ui/Find.js +27 -7
- package/dist/cjs/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/cjs/plugins/hyperlink/pm-plugins/keymap.js +3 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/cjs/plugins/hyperlink/utils.js +6 -69
- package/dist/cjs/plugins/index.js +8 -0
- package/dist/cjs/plugins/media/index.js +14 -3
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +179 -0
- package/dist/cjs/plugins/media/pm-plugins/main.js +18 -9
- package/dist/cjs/plugins/media/toolbar/index.js +49 -17
- package/dist/cjs/plugins/media/toolbar/utils.js +20 -2
- package/dist/cjs/plugins/media/utils/media-files.js +67 -1
- package/dist/cjs/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/cjs/plugins/panel/index.js +2 -3
- package/dist/cjs/plugins/panel/message.js +47 -0
- package/dist/cjs/plugins/panel/toolbar.js +64 -84
- package/dist/cjs/plugins/panel/utils.js +2 -2
- package/dist/cjs/plugins/paste/linkify-md-plugin.js +3 -3
- package/dist/cjs/plugins/rank.js +1 -1
- package/dist/cjs/plugins/status/styles.js +1 -1
- package/dist/cjs/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/cjs/profiler/render-count.js +82 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/cjs/utils/react-hooks/use-component-renderer-tracking/index.js +55 -19
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +6 -28
- package/dist/es2019/create-editor/ErrorBoundary.js +73 -60
- package/dist/es2019/create-editor/ReactEditorView.js +130 -23
- package/dist/es2019/create-editor/create-plugins-list.js +9 -3
- package/dist/es2019/editor.js +74 -35
- package/dist/es2019/labs/next/presets/cxhtml.js +2 -1
- package/dist/es2019/plugins/analytics/types/enums.js +3 -1
- package/dist/es2019/plugins/base/index.js +4 -3
- package/dist/es2019/plugins/base/pm-plugins/frozen-editor.js +63 -35
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +2 -1
- package/dist/es2019/plugins/card/index.js +7 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/main.js +9 -2
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/es2019/plugins/code-bidi-warning/index.js +15 -0
- package/dist/es2019/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/main.js +31 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +88 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/es2019/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/es2019/plugins/code-block/index.js +6 -1
- package/dist/es2019/plugins/code-block/nodeviews/highlighting-code-block.js +16 -4
- package/dist/es2019/plugins/code-block/pm-plugins/main.js +50 -39
- package/dist/es2019/plugins/code-block/toolbar.js +1 -1
- package/dist/es2019/plugins/emoji/styles.js +2 -0
- package/dist/es2019/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/es2019/plugins/extension/toolbar.js +30 -25
- package/dist/es2019/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/es2019/plugins/find-replace/ui/Find.js +27 -6
- package/dist/es2019/plugins/hyperlink/HyperlinkToolbarAppearance.js +1 -1
- package/dist/es2019/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/es2019/plugins/hyperlink/utils.js +3 -59
- package/dist/es2019/plugins/index.js +2 -1
- package/dist/es2019/plugins/media/index.js +13 -4
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +16 -7
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +88 -0
- package/dist/es2019/plugins/media/pm-plugins/main.js +20 -11
- package/dist/es2019/plugins/media/toolbar/index.js +44 -15
- package/dist/es2019/plugins/media/toolbar/utils.js +16 -0
- package/dist/es2019/plugins/media/utils/media-files.js +68 -2
- package/dist/es2019/plugins/mentions/type-ahead/index.js +21 -2
- package/dist/es2019/plugins/panel/index.js +3 -4
- package/dist/es2019/plugins/panel/message.js +38 -0
- package/dist/es2019/plugins/panel/toolbar.js +52 -71
- package/dist/es2019/plugins/panel/utils.js +2 -2
- package/dist/es2019/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/es2019/plugins/rank.js +1 -1
- package/dist/es2019/plugins/status/styles.js +2 -0
- package/dist/es2019/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/es2019/profiler/render-count.js +60 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +4 -2
- package/dist/es2019/utils/react-hooks/use-component-renderer-tracking/index.js +51 -18
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +6 -24
- package/dist/esm/create-editor/ErrorBoundary.js +113 -78
- package/dist/esm/create-editor/ReactEditorView.js +146 -31
- package/dist/esm/create-editor/create-plugins-list.js +9 -3
- package/dist/esm/editor.js +100 -40
- package/dist/esm/labs/next/presets/cxhtml.js +2 -1
- package/dist/esm/plugins/analytics/types/enums.js +3 -1
- package/dist/esm/plugins/base/index.js +4 -3
- package/dist/esm/plugins/base/pm-plugins/frozen-editor.js +64 -36
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +3 -1
- package/dist/esm/plugins/card/index.js +13 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/main.js +7 -2
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +12 -5
- package/dist/esm/plugins/code-bidi-warning/index.js +17 -0
- package/dist/esm/plugins/code-bidi-warning/plugin-key.js +2 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/main.js +30 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/plugin-factory.js +96 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/reducer.js +3 -0
- package/dist/esm/plugins/code-bidi-warning/pm-plugins/types.js +1 -0
- package/dist/esm/plugins/code-block/index.js +10 -6
- package/dist/esm/plugins/code-block/nodeviews/highlighting-code-block.js +16 -5
- package/dist/esm/plugins/code-block/pm-plugins/main.js +11 -3
- package/dist/esm/plugins/code-block/toolbar.js +1 -1
- package/dist/esm/plugins/emoji/styles.js +1 -1
- package/dist/esm/plugins/extension/pm-plugins/main.js +1 -4
- package/dist/esm/plugins/extension/toolbar.js +28 -23
- package/dist/esm/plugins/feature-flags-context/feature-flags-from-props.js +9 -4
- package/dist/esm/plugins/find-replace/ui/Find.js +27 -7
- package/dist/esm/plugins/hyperlink/HyperlinkToolbarAppearance.js +2 -2
- package/dist/esm/plugins/hyperlink/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +7 -4
- package/dist/esm/plugins/hyperlink/utils.js +3 -59
- package/dist/esm/plugins/index.js +2 -1
- package/dist/esm/plugins/media/index.js +14 -4
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -10
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +147 -0
- package/dist/esm/plugins/media/pm-plugins/main.js +19 -11
- package/dist/esm/plugins/media/toolbar/index.js +47 -19
- package/dist/esm/plugins/media/toolbar/utils.js +15 -1
- package/dist/esm/plugins/media/utils/media-files.js +60 -2
- package/dist/esm/plugins/mentions/type-ahead/index.js +39 -3
- package/dist/esm/plugins/panel/index.js +3 -4
- package/dist/esm/plugins/panel/message.js +38 -0
- package/dist/esm/plugins/panel/toolbar.js +57 -77
- package/dist/esm/plugins/panel/utils.js +2 -2
- package/dist/esm/plugins/paste/linkify-md-plugin.js +2 -2
- package/dist/esm/plugins/rank.js +1 -1
- package/dist/esm/plugins/status/styles.js +1 -1
- package/dist/esm/plugins/table/pm-plugins/sticky-headers/nodeviews/tableRow.js +18 -2
- package/dist/esm/profiler/render-count.js +57 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +6 -5
- package/dist/esm/utils/react-hooks/use-component-renderer-tracking/index.js +53 -20
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ErrorBoundary.d.ts +6 -6
- package/dist/types/create-editor/ReactEditorView.d.ts +15 -3
- package/dist/types/editor.d.ts +2 -0
- package/dist/types/plugins/analytics/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/enums.d.ts +4 -2
- package/dist/types/plugins/analytics/types/events.d.ts +7 -2
- package/dist/types/plugins/analytics/types/general-events.d.ts +4 -1
- package/dist/types/plugins/analytics/types/index.d.ts +1 -1
- package/dist/types/plugins/analytics/types/insert-events.d.ts +6 -1
- package/dist/types/plugins/analytics/types/link-tool-bar-events.d.ts +1 -0
- package/dist/types/plugins/base/index.d.ts +1 -0
- package/dist/types/plugins/base/pm-plugins/frozen-editor.d.ts +3 -2
- package/dist/types/plugins/card/pm-plugins/main.d.ts +2 -3
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -1
- package/dist/types/plugins/card/types.d.ts +6 -0
- package/dist/types/plugins/code-bidi-warning/index.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/plugin-key.d.ts +2 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/main.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/plugin-factory.d.ts +7 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/reducer.d.ts +3 -0
- package/dist/types/plugins/code-bidi-warning/pm-plugins/types.d.ts +5 -0
- package/dist/types/plugins/code-block/nodeviews/highlighting-code-block.d.ts +11 -2
- package/dist/types/plugins/code-block/pm-plugins/main.d.ts +5 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/types.d.ts +1 -1
- package/dist/types/plugins/floating-toolbar/ui/Select.d.ts +1 -1
- package/dist/types/plugins/hyperlink/HyperlinkToolbarAppearance.d.ts +1 -1
- package/dist/types/plugins/hyperlink/utils.d.ts +0 -21
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +27 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/toolbar/utils.d.ts +2 -0
- package/dist/types/plugins/media/utils/media-files.d.ts +8 -0
- package/dist/types/plugins/panel/message.d.ts +37 -0
- package/dist/types/plugins/panel/toolbar.d.ts +4 -37
- package/dist/types/plugins/panel/types.d.ts +1 -0
- package/dist/types/profiler/render-count.d.ts +14 -0
- package/dist/types/types/feature-flags.d.ts +17 -0
- package/dist/types/ui/LinkSearch/types.d.ts +1 -0
- package/dist/types/utils/react-hooks/use-component-renderer-tracking/index.d.ts +17 -1
- package/package.json +21 -18
- package/dist/cjs/plugins/caption/nodeviews/index.test.js +0 -135
- package/dist/cjs/plugins/caption/pm-plugins/keymap.test.js +0 -203
- package/dist/cjs/plugins/caption/pm-plugins/main.test.js +0 -141
- package/dist/cjs/plugins/code-block/language-list.test.js +0 -74
- package/dist/cjs/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -101
- package/dist/cjs/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -98
- package/dist/cjs/plugins/media/commands/captions.test.js +0 -149
- package/dist/cjs/plugins/media/commands/linking.test.js +0 -296
- package/dist/cjs/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -50
- package/dist/cjs/plugins/panel/toolbar.test.js +0 -250
- package/dist/cjs/ui/ColorPickerButton/index.test.js +0 -123
- package/dist/cjs/ui/PortalProvider/index.test.js +0 -139
- package/dist/es2019/plugins/caption/nodeviews/index.test.js +0 -122
- package/dist/es2019/plugins/caption/pm-plugins/keymap.test.js +0 -193
- package/dist/es2019/plugins/caption/pm-plugins/main.test.js +0 -132
- package/dist/es2019/plugins/code-block/language-list.test.js +0 -69
- package/dist/es2019/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -83
- package/dist/es2019/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/es2019/plugins/media/commands/captions.test.js +0 -126
- package/dist/es2019/plugins/media/commands/linking.test.js +0 -208
- package/dist/es2019/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/es2019/plugins/panel/toolbar.test.js +0 -200
- package/dist/es2019/ui/ColorPickerButton/index.test.js +0 -88
- package/dist/es2019/ui/PortalProvider/index.test.js +0 -115
- package/dist/esm/plugins/caption/nodeviews/index.test.js +0 -125
- package/dist/esm/plugins/caption/pm-plugins/keymap.test.js +0 -195
- package/dist/esm/plugins/caption/pm-plugins/main.test.js +0 -124
- package/dist/esm/plugins/code-block/language-list.test.js +0 -71
- package/dist/esm/plugins/extension/ui/SaveIndicator/SaveIndicator.test.js +0 -92
- package/dist/esm/plugins/floating-toolbar/ui/EmojiPickerButton.test.js +0 -85
- package/dist/esm/plugins/media/commands/captions.test.js +0 -135
- package/dist/esm/plugins/media/commands/linking.test.js +0 -268
- package/dist/esm/plugins/media/ui/CaptionPlaceholder/index.test.js +0 -41
- package/dist/esm/plugins/panel/toolbar.test.js +0 -230
- package/dist/esm/ui/ColorPickerButton/index.test.js +0 -107
- package/dist/esm/ui/PortalProvider/index.test.js +0 -129
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { media, mediaGroup, mediaSingle, mediaSingleWithCaption } from '@atlaskit/adf-schema';
|
|
2
|
+
import { media, mediaGroup, mediaSingle, mediaSingleWithCaption, mediaInline } from '@atlaskit/adf-schema';
|
|
3
3
|
import { stateKey as pluginKey, createPlugin } from './pm-plugins/main';
|
|
4
4
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
5
5
|
import { createPlugin as createMediaEditorPlugin } from './pm-plugins/media-editor';
|
|
@@ -21,6 +21,7 @@ import MediaEditor from './ui/MediaEditor';
|
|
|
21
21
|
import { MediaPickerComponents } from './ui/MediaPicker';
|
|
22
22
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
23
23
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
24
|
+
import { ReactMediaInlineNode } from './nodeviews/mediaInline';
|
|
24
25
|
export { insertMediaSingleNode } from './utils/media-single';
|
|
25
26
|
|
|
26
27
|
const mediaPlugin = options => ({
|
|
@@ -30,6 +31,7 @@ const mediaPlugin = options => ({
|
|
|
30
31
|
const {
|
|
31
32
|
allowMediaGroup = true,
|
|
32
33
|
allowMediaSingle = false,
|
|
34
|
+
allowMediaInline = false,
|
|
33
35
|
featureFlags
|
|
34
36
|
} = options || {};
|
|
35
37
|
const captions = getMediaFeatureFlag('captions', featureFlags);
|
|
@@ -43,6 +45,9 @@ const mediaPlugin = options => ({
|
|
|
43
45
|
}, {
|
|
44
46
|
name: 'media',
|
|
45
47
|
node: media
|
|
48
|
+
}, {
|
|
49
|
+
name: 'mediaInline',
|
|
50
|
+
node: mediaInline
|
|
46
51
|
}].filter(node => {
|
|
47
52
|
if (node.name === 'mediaGroup') {
|
|
48
53
|
return allowMediaGroup;
|
|
@@ -52,6 +57,10 @@ const mediaPlugin = options => ({
|
|
|
52
57
|
return allowMediaSingle;
|
|
53
58
|
}
|
|
54
59
|
|
|
60
|
+
if (node.name === 'mediaInline') {
|
|
61
|
+
return allowMediaInline;
|
|
62
|
+
}
|
|
63
|
+
|
|
55
64
|
return true;
|
|
56
65
|
});
|
|
57
66
|
},
|
|
@@ -73,7 +82,8 @@ const mediaPlugin = options => ({
|
|
|
73
82
|
nodeViews: {
|
|
74
83
|
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
75
84
|
mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options),
|
|
76
|
-
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options)
|
|
85
|
+
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
86
|
+
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
|
|
77
87
|
},
|
|
78
88
|
errorReporter,
|
|
79
89
|
uploadErrorHandler: options && options.uploadErrorHandler,
|
|
@@ -197,8 +207,7 @@ const mediaPlugin = options => ({
|
|
|
197
207
|
action(insert, state) {
|
|
198
208
|
const pluginState = pluginKey.getState(state);
|
|
199
209
|
pluginState.showMediaPicker();
|
|
200
|
-
|
|
201
|
-
return addAnalytics(state, tr, {
|
|
210
|
+
return addAnalytics(state, insert(''), {
|
|
202
211
|
action: ACTION.OPENED,
|
|
203
212
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
204
213
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -111,6 +111,21 @@ export default class MediaGroup extends React.Component {
|
|
|
111
111
|
// We declared this to get a fresh position every time
|
|
112
112
|
const getNodePos = () => {
|
|
113
113
|
return getPos() + idx + 1;
|
|
114
|
+
}; // Media Inline creates a floating toolbar with the same options, excludes these options if enabled
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
const mediaInlineOptions = (allowMediaInline = false) => {
|
|
118
|
+
if (!allowMediaInline) {
|
|
119
|
+
return {
|
|
120
|
+
shouldEnableDownloadButton: mediaOptions.enableDownloadButton,
|
|
121
|
+
actions: [{
|
|
122
|
+
handler: disabled ? () => {} : this.mediaPluginState.handleMediaNodeRemoval.bind(null, undefined, getNodePos),
|
|
123
|
+
icon: /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
124
|
+
label: "delete"
|
|
125
|
+
})
|
|
126
|
+
}]
|
|
127
|
+
};
|
|
128
|
+
}
|
|
114
129
|
};
|
|
115
130
|
|
|
116
131
|
return {
|
|
@@ -120,13 +135,7 @@ export default class MediaGroup extends React.Component {
|
|
|
120
135
|
onClick: () => {
|
|
121
136
|
setNodeSelection(this.props.view, getNodePos());
|
|
122
137
|
},
|
|
123
|
-
|
|
124
|
-
actions: [{
|
|
125
|
-
handler: disabled ? () => {} : this.mediaPluginState.handleMediaNodeRemoval.bind(null, undefined, getNodePos),
|
|
126
|
-
icon: /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
127
|
-
label: "delete"
|
|
128
|
-
})
|
|
129
|
-
}]
|
|
138
|
+
...mediaInlineOptions(mediaOptions.allowMediaInline)
|
|
130
139
|
};
|
|
131
140
|
});
|
|
132
141
|
return /*#__PURE__*/React.createElement(Filmstrip, {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { ReactNodeView } from '../../../nodeviews/';
|
|
3
|
+
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
4
|
+
import { WithProviders } from '@atlaskit/editor-common';
|
|
5
|
+
export const MediaInline = props => {
|
|
6
|
+
const [viewMediaClientConfig, setViewMediaClientConfig] = useState({});
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
updateViewMediaClientConfig(props);
|
|
9
|
+
}, [props]);
|
|
10
|
+
|
|
11
|
+
const updateViewMediaClientConfig = async props => {
|
|
12
|
+
const mediaProvider = await props.mediaProvider;
|
|
13
|
+
|
|
14
|
+
if (mediaProvider) {
|
|
15
|
+
const viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
16
|
+
setViewMediaClientConfig(viewMediaClientConfig);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const {
|
|
21
|
+
id,
|
|
22
|
+
collection
|
|
23
|
+
} = props.node.attrs;
|
|
24
|
+
const identifier = {
|
|
25
|
+
id,
|
|
26
|
+
mediaItemType: 'file',
|
|
27
|
+
collectionName: collection
|
|
28
|
+
};
|
|
29
|
+
return /*#__PURE__*/React.createElement(MediaInlineCard, {
|
|
30
|
+
identifier: identifier,
|
|
31
|
+
mediaClientConfig: viewMediaClientConfig
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
export class MediaInlineNodeView extends ReactNodeView {
|
|
35
|
+
createDomRef() {
|
|
36
|
+
const domRef = document.createElement('span');
|
|
37
|
+
domRef.contentEditable = 'false';
|
|
38
|
+
return domRef;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
getContentDOM() {
|
|
42
|
+
const dom = document.createElement('span');
|
|
43
|
+
return {
|
|
44
|
+
dom
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ignoreMutation() {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
viewShouldUpdate(nextNode) {
|
|
53
|
+
if (this.node.attrs !== nextNode.attrs) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
render(props) {
|
|
61
|
+
const {
|
|
62
|
+
providerFactory
|
|
63
|
+
} = props;
|
|
64
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
65
|
+
providers: ['mediaProvider'],
|
|
66
|
+
providerFactory: providerFactory,
|
|
67
|
+
renderNode: ({
|
|
68
|
+
mediaProvider
|
|
69
|
+
}) => {
|
|
70
|
+
if (!mediaProvider) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return /*#__PURE__*/React.createElement(MediaInline, {
|
|
75
|
+
identifier: this.node.attrs.id,
|
|
76
|
+
mediaProvider: mediaProvider,
|
|
77
|
+
node: this.node
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
export const ReactMediaInlineNode = (portalProviderAPI, eventDispatcher, providerFactory) => (node, view, getPos) => {
|
|
85
|
+
return new MediaInlineNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
86
|
+
providerFactory
|
|
87
|
+
}).init();
|
|
88
|
+
};
|
|
@@ -9,14 +9,15 @@ import assert from 'assert';
|
|
|
9
9
|
import { findDomRefAtPos, isNodeSelection } from 'prosemirror-utils';
|
|
10
10
|
import { insertMediaSingleNode, isMediaSingle } from '../utils/media-single';
|
|
11
11
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
12
|
-
import { insertMediaGroupNode } from '../utils/media-files';
|
|
13
|
-
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
12
|
+
import { insertMediaGroupNode, insertMediaInlineNode, canInsertMediaInline } from '../utils/media-files';
|
|
13
|
+
import { isInsidePotentialEmptyParagraph, removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
14
14
|
import * as helpers from '../commands/helpers';
|
|
15
15
|
import { updateMediaNodeAttrs } from '../commands/helpers';
|
|
16
16
|
import { stateKey } from './plugin-key';
|
|
17
17
|
import PickerFacade from '../picker-facade';
|
|
18
18
|
import { INPUT_METHOD } from '../../analytics/types';
|
|
19
19
|
import { isImage } from '../utils/is-image';
|
|
20
|
+
import { isInEmptyLine } from '../../../utils/document';
|
|
20
21
|
export { stateKey } from './plugin-key';
|
|
21
22
|
|
|
22
23
|
const createDropPlaceholder = allowDropLine => {
|
|
@@ -60,7 +61,7 @@ export class MediaPluginStateImplementation {
|
|
|
60
61
|
|
|
61
62
|
_defineProperty(this, "removeOnCloseListener", () => {});
|
|
62
63
|
|
|
63
|
-
_defineProperty(this, "
|
|
64
|
+
_defineProperty(this, "onPopupToggleCallback", () => {});
|
|
64
65
|
|
|
65
66
|
_defineProperty(this, "pickers", []);
|
|
66
67
|
|
|
@@ -151,12 +152,13 @@ export class MediaPluginStateImplementation {
|
|
|
151
152
|
var _this$mediaOptions;
|
|
152
153
|
|
|
153
154
|
const {
|
|
155
|
+
mediaInline,
|
|
154
156
|
mediaSingle,
|
|
155
157
|
media
|
|
156
158
|
} = this.view.state.schema.nodes;
|
|
157
159
|
|
|
158
160
|
if ((_this$mediaOptions = this.mediaOptions) !== null && _this$mediaOptions !== void 0 && _this$mediaOptions.allowMediaInline) {
|
|
159
|
-
return type === mediaSingle || type === media;
|
|
161
|
+
return type === mediaSingle || type === media || type === mediaInline;
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
return type === mediaSingle;
|
|
@@ -165,6 +167,11 @@ export class MediaPluginStateImplementation {
|
|
|
165
167
|
_defineProperty(this, "hasUserAuthProvider", () => !!this.uploadMediaClientConfig && !!this.uploadMediaClientConfig.userAuthProvider);
|
|
166
168
|
|
|
167
169
|
_defineProperty(this, "insertFile", (mediaState, onMediaStateChanged, pickerType) => {
|
|
170
|
+
var _this$mediaOptions2;
|
|
171
|
+
|
|
172
|
+
const {
|
|
173
|
+
state
|
|
174
|
+
} = this.view;
|
|
168
175
|
const mediaStateWithContext = { ...mediaState,
|
|
169
176
|
contextId: this.contextIdentifierProvider ? this.contextIdentifierProvider.objectId : undefined
|
|
170
177
|
};
|
|
@@ -185,8 +192,10 @@ export class MediaPluginStateImplementation {
|
|
|
185
192
|
});
|
|
186
193
|
}
|
|
187
194
|
|
|
188
|
-
if (isMediaSingle(
|
|
195
|
+
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
189
196
|
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert);
|
|
197
|
+
} else if ((_this$mediaOptions2 = this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInline && !isInEmptyLine(state) && !isInsidePotentialEmptyParagraph(state) && canInsertMediaInline(state)) {
|
|
198
|
+
insertMediaInlineNode(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
190
199
|
} else {
|
|
191
200
|
insertMediaGroupNode(this.view, [mediaStateWithContext], collection, this.getInputMethod(pickerType));
|
|
192
201
|
} // do events when media state changes
|
|
@@ -234,7 +243,7 @@ export class MediaPluginStateImplementation {
|
|
|
234
243
|
_defineProperty(this, "splitMediaGroup", () => splitMediaGroup(this.view));
|
|
235
244
|
|
|
236
245
|
_defineProperty(this, "onPopupPickerClose", () => {
|
|
237
|
-
this.
|
|
246
|
+
this.onPopupToggleCallback(false);
|
|
238
247
|
});
|
|
239
248
|
|
|
240
249
|
_defineProperty(this, "shouldUseMediaPickerPopup", () => {
|
|
@@ -255,15 +264,15 @@ export class MediaPluginStateImplementation {
|
|
|
255
264
|
}
|
|
256
265
|
|
|
257
266
|
this.popupPicker.show();
|
|
258
|
-
this.
|
|
267
|
+
this.onPopupToggleCallback(true);
|
|
259
268
|
});
|
|
260
269
|
|
|
261
270
|
_defineProperty(this, "setBrowseFn", browseFn => {
|
|
262
271
|
this.openMediaPickerBrowser = browseFn;
|
|
263
272
|
});
|
|
264
273
|
|
|
265
|
-
_defineProperty(this, "onPopupToggle",
|
|
266
|
-
this.
|
|
274
|
+
_defineProperty(this, "onPopupToggle", onPopupToggleCallback => {
|
|
275
|
+
this.onPopupToggleCallback = onPopupToggleCallback;
|
|
267
276
|
});
|
|
268
277
|
|
|
269
278
|
_defineProperty(this, "waitForPendingTasks", (timeout, lastTask) => {
|
|
@@ -482,7 +491,7 @@ export class MediaPluginStateImplementation {
|
|
|
482
491
|
}
|
|
483
492
|
|
|
484
493
|
getDomElement(domAtPos) {
|
|
485
|
-
var _this$
|
|
494
|
+
var _this$mediaOptions3;
|
|
486
495
|
|
|
487
496
|
const {
|
|
488
497
|
selection
|
|
@@ -496,7 +505,7 @@ export class MediaPluginStateImplementation {
|
|
|
496
505
|
return;
|
|
497
506
|
}
|
|
498
507
|
|
|
499
|
-
const position = (_this$
|
|
508
|
+
const position = (_this$mediaOptions3 = this.mediaOptions) !== null && _this$mediaOptions3 !== void 0 && _this$mediaOptions3.allowMediaInline ? selection.from + 1 : selection.from;
|
|
500
509
|
const node = findDomRefAtPos(position, domAtPos);
|
|
501
510
|
|
|
502
511
|
if (node) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeSelection } from 'prosemirror-state';
|
|
3
|
+
import { findParentNodeOfType, removeSelectedNode, safeInsert } from 'prosemirror-utils';
|
|
3
4
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
4
5
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
5
6
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
@@ -18,7 +19,8 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE } f
|
|
|
18
19
|
import { messages } from '@atlaskit/media-ui';
|
|
19
20
|
import { messages as cardMessages } from '../../card/messages';
|
|
20
21
|
import { FilePreviewItem } from './filePreviewItem';
|
|
21
|
-
import { downloadMedia } from './utils';
|
|
22
|
+
import { downloadMedia, removeMediaGroupNode } from './utils';
|
|
23
|
+
import { Fragment } from 'prosemirror-model';
|
|
22
24
|
|
|
23
25
|
const remove = (state, dispatch) => {
|
|
24
26
|
if (dispatch) {
|
|
@@ -28,13 +30,43 @@ const remove = (state, dispatch) => {
|
|
|
28
30
|
return true;
|
|
29
31
|
};
|
|
30
32
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const handleRemoveMediaGroup = (state, dispatch) => {
|
|
34
|
+
const tr = removeMediaGroupNode(state);
|
|
35
|
+
|
|
36
|
+
if (dispatch) {
|
|
37
|
+
dispatch(tr);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const changeMediaCardToInline = (state, dispatch) => {
|
|
44
|
+
const {
|
|
45
|
+
media,
|
|
46
|
+
mediaInline,
|
|
47
|
+
paragraph
|
|
48
|
+
} = state.schema.nodes;
|
|
49
|
+
const selectedNode = state.selection instanceof NodeSelection && state.selection.node;
|
|
50
|
+
|
|
51
|
+
if (!selectedNode || !selectedNode.type === media) {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const mediaInlineNode = mediaInline.create({
|
|
56
|
+
id: selectedNode.attrs.id,
|
|
57
|
+
collection: selectedNode.attrs.collection
|
|
58
|
+
});
|
|
59
|
+
const space = state.schema.text(' ');
|
|
60
|
+
let content = Fragment.from([mediaInlineNode, space]);
|
|
61
|
+
const node = paragraph.createChecked({}, content);
|
|
62
|
+
const nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
63
|
+
let tr = removeMediaGroupNode(state);
|
|
64
|
+
tr = safeInsert(node, nodePos, true)(tr);
|
|
65
|
+
|
|
66
|
+
if (dispatch) {
|
|
67
|
+
dispatch(tr);
|
|
68
|
+
}
|
|
36
69
|
|
|
37
|
-
mediaPluginState.handleMediaNodeRemoval(undefined, getPos);
|
|
38
70
|
return true;
|
|
39
71
|
};
|
|
40
72
|
|
|
@@ -48,9 +80,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
|
48
80
|
options: [{
|
|
49
81
|
title: intl.formatMessage(cardMessages.inline),
|
|
50
82
|
selected: false,
|
|
51
|
-
onClick:
|
|
52
|
-
return true;
|
|
53
|
-
},
|
|
83
|
+
onClick: changeMediaCardToInline,
|
|
54
84
|
testId: 'inline-appearance'
|
|
55
85
|
}, {
|
|
56
86
|
title: intl.formatMessage(messages.displayThumbnail),
|
|
@@ -94,9 +124,7 @@ const generateMediaCardFloatingToolbar = (state, intl, mediaPluginState) => {
|
|
|
94
124
|
onFocus: hoverDecoration(mediaGroup, true),
|
|
95
125
|
onBlur: hoverDecoration(mediaGroup, false),
|
|
96
126
|
title: intl.formatMessage(commonMessages.remove),
|
|
97
|
-
onClick:
|
|
98
|
-
return removeMediaCard(state, mediaPluginState);
|
|
99
|
-
},
|
|
127
|
+
onClick: handleRemoveMediaGroup,
|
|
100
128
|
testId: 'media-toolbar-remove-button'
|
|
101
129
|
}];
|
|
102
130
|
return items;
|
|
@@ -210,6 +238,7 @@ const generateMediaSingleFloatingToolbar = (state, intl, options, pluginState, m
|
|
|
210
238
|
export const floatingToolbar = (state, intl, options = {}) => {
|
|
211
239
|
const {
|
|
212
240
|
media,
|
|
241
|
+
mediaInline,
|
|
213
242
|
mediaSingle,
|
|
214
243
|
mediaGroup
|
|
215
244
|
} = state.schema.nodes;
|
|
@@ -227,7 +256,7 @@ export const floatingToolbar = (state, intl, options = {}) => {
|
|
|
227
256
|
return;
|
|
228
257
|
}
|
|
229
258
|
|
|
230
|
-
const nodeType = allowMediaInline ? [mediaSingle, media] : [mediaSingle];
|
|
259
|
+
const nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
231
260
|
const baseToolbar = {
|
|
232
261
|
title: 'Media floating controls',
|
|
233
262
|
nodeType,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
2
|
+
import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from 'prosemirror-utils';
|
|
2
3
|
export const getSelectedMediaContainerNodeAttrs = mediaPluginState => {
|
|
3
4
|
const selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
4
5
|
|
|
@@ -29,4 +30,19 @@ export const downloadMedia = async mediaPluginState => {
|
|
|
29
30
|
} catch (err) {
|
|
30
31
|
return false;
|
|
31
32
|
}
|
|
33
|
+
};
|
|
34
|
+
export const removeMediaGroupNode = state => {
|
|
35
|
+
const {
|
|
36
|
+
mediaGroup
|
|
37
|
+
} = state.schema.nodes;
|
|
38
|
+
const mediaGroupParent = findParentNodeOfType(mediaGroup)(state.selection);
|
|
39
|
+
let tr = state.tr; // If it is the last media group in filmstrip, remove the entire filmstrip
|
|
40
|
+
|
|
41
|
+
if (mediaGroupParent && mediaGroupParent.node.childCount === 1) {
|
|
42
|
+
tr = removeParentNodeOfType(mediaGroup)(tr);
|
|
43
|
+
} else {
|
|
44
|
+
tr = removeSelectedNode(tr);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return tr;
|
|
32
48
|
};
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Fragment } from 'prosemirror-model';
|
|
2
2
|
import { setNodeSelection, setTextSelection, insideTableCell, isInListItem, findFarthestParentNode, isInLayoutColumn } from '../../../utils';
|
|
3
3
|
import { posOfPrecedingMediaGroup, posOfMediaGroupNearby, posOfParentMediaGroup, isSelectionNonMediaBlockNode, isInsidePotentialEmptyParagraph, copyOptionalAttrsFromMediaState } from './media-common';
|
|
4
|
-
import { safeInsert, hasParentNode } from 'prosemirror-utils';
|
|
4
|
+
import { canInsert, safeInsert, hasParentNode } from 'prosemirror-utils';
|
|
5
5
|
import { atTheBeginningOfBlock, atTheEndOfBlock, atTheEndOfDoc, endPositionOfParent, startPositionOfParent } from '../../../utils/prosemirror/position';
|
|
6
6
|
import { isSupportedInParent } from '../../../utils/nodes';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, addAnalytics } from '../../analytics';
|
|
8
|
+
export const canInsertMediaInline = state => {
|
|
9
|
+
const node = state.schema.nodes.mediaInline.create({});
|
|
10
|
+
return canInsert(state.selection.$to, Fragment.from(node));
|
|
11
|
+
};
|
|
8
12
|
|
|
9
13
|
const getInsertMediaGroupAnalytics = (mediaState, inputMethod) => {
|
|
10
14
|
let media = '';
|
|
@@ -27,6 +31,21 @@ const getInsertMediaGroupAnalytics = (mediaState, inputMethod) => {
|
|
|
27
31
|
eventType: EVENT_TYPE.TRACK
|
|
28
32
|
};
|
|
29
33
|
};
|
|
34
|
+
|
|
35
|
+
const getInsertMediaInlineAnalytics = (mediaState, inputMethod) => {
|
|
36
|
+
const media = mediaState.fileMimeType || 'unknown';
|
|
37
|
+
return {
|
|
38
|
+
action: ACTION.INSERTED,
|
|
39
|
+
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
40
|
+
actionSubjectId: ACTION_SUBJECT_ID.MEDIA,
|
|
41
|
+
attributes: {
|
|
42
|
+
type: ACTION_SUBJECT_ID.MEDIA_INLINE,
|
|
43
|
+
inputMethod,
|
|
44
|
+
fileExtension: media
|
|
45
|
+
},
|
|
46
|
+
eventType: EVENT_TYPE.TRACK
|
|
47
|
+
};
|
|
48
|
+
};
|
|
30
49
|
/**
|
|
31
50
|
* Check if current editor selections is a media group or not.
|
|
32
51
|
* @param state Editor state
|
|
@@ -59,6 +78,54 @@ function shouldAppendParagraph(state, node) {
|
|
|
59
78
|
const wasMediaNode = node && node.type === media;
|
|
60
79
|
return (insideTableCell(state) || isInListItem(state) || isInLayoutColumn(state) || atTheEndOfDoc(state) && (!posOfPrecedingMediaGroup(state) || isSelectionNonMediaBlockNode(state))) && !wasMediaNode;
|
|
61
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a new media inline to insert the new media.
|
|
83
|
+
* @param view Editor view
|
|
84
|
+
* @param mediaState Media file to be added to the editor
|
|
85
|
+
* @param collection Collection for the media to be added
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
export const insertMediaInlineNode = (view, mediaState, collection, inputMethod) => {
|
|
90
|
+
const {
|
|
91
|
+
state,
|
|
92
|
+
dispatch
|
|
93
|
+
} = view;
|
|
94
|
+
const {
|
|
95
|
+
schema,
|
|
96
|
+
tr
|
|
97
|
+
} = state;
|
|
98
|
+
const {
|
|
99
|
+
mediaInline
|
|
100
|
+
} = schema.nodes; // Do nothing if no media found
|
|
101
|
+
|
|
102
|
+
if (!mediaInline || !mediaState || collection === undefined) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const {
|
|
107
|
+
id
|
|
108
|
+
} = mediaState;
|
|
109
|
+
const mediaInlineNode = mediaInline.create({
|
|
110
|
+
id,
|
|
111
|
+
collection
|
|
112
|
+
});
|
|
113
|
+
const space = state.schema.text(' ');
|
|
114
|
+
const pos = state.selection.$to.pos;
|
|
115
|
+
let content = Fragment.from([mediaInlineNode, space]); // Delete the selection if a selection is made
|
|
116
|
+
|
|
117
|
+
const deleteRange = findDeleteRange(state);
|
|
118
|
+
|
|
119
|
+
if (!deleteRange) {
|
|
120
|
+
tr.insert(pos, content);
|
|
121
|
+
} else {
|
|
122
|
+
tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
addAnalytics(state, tr, getInsertMediaInlineAnalytics(mediaState, inputMethod));
|
|
126
|
+
dispatch(tr);
|
|
127
|
+
return true;
|
|
128
|
+
};
|
|
62
129
|
/**
|
|
63
130
|
* Insert a media into an existing media group
|
|
64
131
|
* or create a new media group to insert the new media.
|
|
@@ -67,7 +134,6 @@ function shouldAppendParagraph(state, node) {
|
|
|
67
134
|
* @param collection Collection for the media to be added
|
|
68
135
|
*/
|
|
69
136
|
|
|
70
|
-
|
|
71
137
|
export const insertMediaGroupNode = (view, mediaStates, collection, inputMethod) => {
|
|
72
138
|
const {
|
|
73
139
|
state,
|
|
@@ -188,6 +188,7 @@ export const createTypeAheadConfig = ({
|
|
|
188
188
|
}) => {
|
|
189
189
|
let sessionId = uuid();
|
|
190
190
|
let firstQueryWithoutResults = null;
|
|
191
|
+
const subscriptionKeys = new Set();
|
|
191
192
|
const typeAhead = {
|
|
192
193
|
id: TypeAheadAvailableNodes.MENTION,
|
|
193
194
|
trigger: '@',
|
|
@@ -235,8 +236,13 @@ export const createTypeAheadConfig = ({
|
|
|
235
236
|
return new Promise(resolve => {
|
|
236
237
|
const key = `loadingMentionsForTypeAhead_${uuid()}`;
|
|
237
238
|
|
|
238
|
-
const mentionsSubscribeCallback = (mentions,
|
|
239
|
+
const mentionsSubscribeCallback = (mentions, resultQuery = '', stats) => {
|
|
240
|
+
if (query !== resultQuery) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
|
|
239
244
|
mentionProvider.unsubscribe(key);
|
|
245
|
+
subscriptionKeys.delete(key);
|
|
240
246
|
const mentionItems = mentions.map(mention => memoizedToItem.call(mention));
|
|
241
247
|
buildAndSendElementsTypeAheadAnalytics(fireEvent)({
|
|
242
248
|
query,
|
|
@@ -272,6 +278,7 @@ export const createTypeAheadConfig = ({
|
|
|
272
278
|
}
|
|
273
279
|
};
|
|
274
280
|
|
|
281
|
+
subscriptionKeys.add(key);
|
|
275
282
|
mentionProvider.subscribe(key, mentionsSubscribeCallback);
|
|
276
283
|
mentionProvider.filter(query || '', { ...contextIdentifierProvider,
|
|
277
284
|
sessionId
|
|
@@ -279,7 +286,7 @@ export const createTypeAheadConfig = ({
|
|
|
279
286
|
});
|
|
280
287
|
},
|
|
281
288
|
|
|
282
|
-
onOpen:
|
|
289
|
+
onOpen: () => {
|
|
283
290
|
firstQueryWithoutResults = null;
|
|
284
291
|
},
|
|
285
292
|
|
|
@@ -355,12 +362,24 @@ export const createTypeAheadConfig = ({
|
|
|
355
362
|
},
|
|
356
363
|
|
|
357
364
|
dismiss({
|
|
365
|
+
editorState,
|
|
358
366
|
query,
|
|
359
367
|
stats
|
|
360
368
|
}) {
|
|
361
369
|
firstQueryWithoutResults = null;
|
|
362
370
|
const pickerElapsedTime = stats.startedAt ? Date.now() - stats.startedAt : 0;
|
|
363
371
|
fireEvent(buildTypeAheadCancelPayload(pickerElapsedTime, stats.keyCount.arrowUp, stats.keyCount.arrowDown, sessionId, query || ''));
|
|
372
|
+
const pluginState = getMentionPluginState(editorState);
|
|
373
|
+
|
|
374
|
+
if (pluginState !== null && pluginState !== void 0 && pluginState.mentionProvider) {
|
|
375
|
+
const mentionProvider = pluginState.mentionProvider;
|
|
376
|
+
|
|
377
|
+
for (let key of subscriptionKeys) {
|
|
378
|
+
mentionProvider.unsubscribe(key);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
subscriptionKeys.clear();
|
|
364
383
|
sessionId = uuid();
|
|
365
384
|
}
|
|
366
385
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { customPanel, PanelType } from '@atlaskit/adf-schema';
|
|
3
3
|
import { createPlugin } from './pm-plugins/main';
|
|
4
4
|
import { getToolbarConfig } from './toolbar';
|
|
5
5
|
import keymap from './pm-plugins/keymaps';
|
|
@@ -34,8 +34,7 @@ const panelPlugin = (options = {}) => ({
|
|
|
34
34
|
name: 'panel',
|
|
35
35
|
|
|
36
36
|
nodes() {
|
|
37
|
-
|
|
38
|
-
const panelNode = options.UNSAFE_allowCustomPanel ? customPanel : panel;
|
|
37
|
+
const panelNode = customPanel(!!options.UNSAFE_allowCustomPanel);
|
|
39
38
|
return [{
|
|
40
39
|
name: 'panel',
|
|
41
40
|
node: panelNode
|
|
@@ -128,7 +127,7 @@ const panelPlugin = (options = {}) => ({
|
|
|
128
127
|
|
|
129
128
|
}];
|
|
130
129
|
|
|
131
|
-
if (options.UNSAFE_allowCustomPanel) {
|
|
130
|
+
if (options.UNSAFE_allowCustomPanelEdit && options.UNSAFE_allowCustomPanel) {
|
|
132
131
|
quickInsertOptions.push({
|
|
133
132
|
id: 'custompanel',
|
|
134
133
|
title: formatMessage(messages.customPanel),
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineMessages } from 'react-intl';
|
|
2
|
+
export const messages = defineMessages({
|
|
3
|
+
info: {
|
|
4
|
+
id: 'fabric.editor.info',
|
|
5
|
+
defaultMessage: 'Info',
|
|
6
|
+
description: 'Panels provide a way to highlight text. The info panel has a blue background.'
|
|
7
|
+
},
|
|
8
|
+
note: {
|
|
9
|
+
id: 'fabric.editor.note',
|
|
10
|
+
defaultMessage: 'Note',
|
|
11
|
+
description: 'Panels provide a way to highlight text. The note panel has a purple background.'
|
|
12
|
+
},
|
|
13
|
+
success: {
|
|
14
|
+
id: 'fabric.editor.success',
|
|
15
|
+
defaultMessage: 'Success',
|
|
16
|
+
description: 'Panels provide a way to highlight text. The success panel has a green background.'
|
|
17
|
+
},
|
|
18
|
+
warning: {
|
|
19
|
+
id: 'fabric.editor.warning',
|
|
20
|
+
defaultMessage: 'Warning',
|
|
21
|
+
description: 'Panels provide a way to highlight text. The warning panel has a yellow background.'
|
|
22
|
+
},
|
|
23
|
+
error: {
|
|
24
|
+
id: 'fabric.editor.error',
|
|
25
|
+
defaultMessage: 'Error',
|
|
26
|
+
description: 'Panels provide a way to highlight text. The error panel has a red background.'
|
|
27
|
+
},
|
|
28
|
+
emoji: {
|
|
29
|
+
id: 'fabric.editor.panel.emoji',
|
|
30
|
+
defaultMessage: 'Add emoji',
|
|
31
|
+
description: 'Select the panel icon'
|
|
32
|
+
},
|
|
33
|
+
backgroundColor: {
|
|
34
|
+
id: 'fabric.editor.panel.backgroundColor',
|
|
35
|
+
defaultMessage: 'Background color',
|
|
36
|
+
description: 'Select the panel background color.'
|
|
37
|
+
}
|
|
38
|
+
});
|