@atlaskit/editor-core 150.0.1 → 151.1.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 +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/collab-edit/ui/to-avatar.js +4 -8
- 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/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/collab-edit/ui/to-avatar.js +2 -6
- 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/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/collab-edit/ui/to-avatar.js +4 -8
- 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/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 +3 -1
- package/dist/types/plugins/analytics/analytics-queue.d.ts +1 -1
- 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/collab-edit/ui/to-avatar.d.ts +1 -1
- package/dist/types/plugins/extension/types.d.ts +0 -2
- package/dist/types/plugins/extension/ui/Extension/ExtensionComponent.d.ts +2 -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/utils.d.ts +0 -21
- package/dist/types/plugins/index.d.ts +1 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/create-items.d.ts +1 -1
- 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/plugins/quick-insert/index.d.ts +1 -1
- 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 +22 -19
- 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
|
var mediaPlugin = function mediaPlugin(options) {
|
|
@@ -32,6 +33,8 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
32
33
|
allowMediaGroup = _ref$allowMediaGroup === void 0 ? true : _ref$allowMediaGroup,
|
|
33
34
|
_ref$allowMediaSingle = _ref.allowMediaSingle,
|
|
34
35
|
allowMediaSingle = _ref$allowMediaSingle === void 0 ? false : _ref$allowMediaSingle,
|
|
36
|
+
_ref$allowMediaInline = _ref.allowMediaInline,
|
|
37
|
+
allowMediaInline = _ref$allowMediaInline === void 0 ? false : _ref$allowMediaInline,
|
|
35
38
|
featureFlags = _ref.featureFlags;
|
|
36
39
|
|
|
37
40
|
var captions = getMediaFeatureFlag('captions', featureFlags);
|
|
@@ -45,6 +48,9 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
45
48
|
}, {
|
|
46
49
|
name: 'media',
|
|
47
50
|
node: media
|
|
51
|
+
}, {
|
|
52
|
+
name: 'mediaInline',
|
|
53
|
+
node: mediaInline
|
|
48
54
|
}].filter(function (node) {
|
|
49
55
|
if (node.name === 'mediaGroup') {
|
|
50
56
|
return allowMediaGroup;
|
|
@@ -54,6 +60,10 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
54
60
|
return allowMediaSingle;
|
|
55
61
|
}
|
|
56
62
|
|
|
63
|
+
if (node.name === 'mediaInline') {
|
|
64
|
+
return allowMediaInline;
|
|
65
|
+
}
|
|
66
|
+
|
|
57
67
|
return true;
|
|
58
68
|
});
|
|
59
69
|
},
|
|
@@ -74,7 +84,8 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
74
84
|
nodeViews: {
|
|
75
85
|
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
76
86
|
mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options),
|
|
77
|
-
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options)
|
|
87
|
+
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
88
|
+
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
|
|
78
89
|
},
|
|
79
90
|
errorReporter: errorReporter,
|
|
80
91
|
uploadErrorHandler: options && options.uploadErrorHandler,
|
|
@@ -203,8 +214,7 @@ var mediaPlugin = function mediaPlugin(options) {
|
|
|
203
214
|
action: function action(insert, state) {
|
|
204
215
|
var pluginState = pluginKey.getState(state);
|
|
205
216
|
pluginState.showMediaPicker();
|
|
206
|
-
|
|
207
|
-
return addAnalytics(state, tr, {
|
|
217
|
+
return addAnalytics(state, insert(''), {
|
|
208
218
|
action: ACTION.OPENED,
|
|
209
219
|
actionSubject: ACTION_SUBJECT.PICKER,
|
|
210
220
|
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
@@ -8,6 +8,10 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
10
|
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
|
+
|
|
11
15
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
16
|
|
|
13
17
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -130,23 +134,33 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
130
134
|
// We declared this to get a fresh position every time
|
|
131
135
|
var getNodePos = function getNodePos() {
|
|
132
136
|
return getPos() + idx + 1;
|
|
137
|
+
}; // Media Inline creates a floating toolbar with the same options, excludes these options if enabled
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
var mediaInlineOptions = function mediaInlineOptions() {
|
|
141
|
+
var allowMediaInline = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
142
|
+
|
|
143
|
+
if (!allowMediaInline) {
|
|
144
|
+
return {
|
|
145
|
+
shouldEnableDownloadButton: mediaOptions.enableDownloadButton,
|
|
146
|
+
actions: [{
|
|
147
|
+
handler: disabled ? function () {} : _this.mediaPluginState.handleMediaNodeRemoval.bind(null, undefined, getNodePos),
|
|
148
|
+
icon: /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
149
|
+
label: "delete"
|
|
150
|
+
})
|
|
151
|
+
}]
|
|
152
|
+
};
|
|
153
|
+
}
|
|
133
154
|
};
|
|
134
155
|
|
|
135
|
-
return {
|
|
156
|
+
return _objectSpread({
|
|
136
157
|
identifier: _this.getIdentifier(item),
|
|
137
158
|
isLazy: allowLazyLoading,
|
|
138
159
|
selected: _this.isNodeSelected(getNodePos()),
|
|
139
160
|
onClick: function onClick() {
|
|
140
161
|
setNodeSelection(_this.props.view, getNodePos());
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
actions: [{
|
|
144
|
-
handler: disabled ? function () {} : _this.mediaPluginState.handleMediaNodeRemoval.bind(null, undefined, getNodePos),
|
|
145
|
-
icon: /*#__PURE__*/React.createElement(EditorCloseIcon, {
|
|
146
|
-
label: "delete"
|
|
147
|
-
})
|
|
148
|
-
}]
|
|
149
|
-
};
|
|
162
|
+
}
|
|
163
|
+
}, mediaInlineOptions(mediaOptions.allowMediaInline));
|
|
150
164
|
});
|
|
151
165
|
|
|
152
166
|
return /*#__PURE__*/React.createElement(Filmstrip, {
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
4
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
5
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
6
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
7
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
8
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
9
|
+
|
|
10
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
+
|
|
12
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
13
|
+
|
|
14
|
+
import React, { useEffect, useState } from 'react';
|
|
15
|
+
import { ReactNodeView } from '../../../nodeviews/';
|
|
16
|
+
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
17
|
+
import { WithProviders } from '@atlaskit/editor-common';
|
|
18
|
+
export var MediaInline = function MediaInline(props) {
|
|
19
|
+
var _useState = useState({}),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
viewMediaClientConfig = _useState2[0],
|
|
22
|
+
setViewMediaClientConfig = _useState2[1];
|
|
23
|
+
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
updateViewMediaClientConfig(props);
|
|
26
|
+
}, [props]);
|
|
27
|
+
|
|
28
|
+
var updateViewMediaClientConfig = /*#__PURE__*/function () {
|
|
29
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(props) {
|
|
30
|
+
var mediaProvider, _viewMediaClientConfig;
|
|
31
|
+
|
|
32
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
33
|
+
while (1) {
|
|
34
|
+
switch (_context.prev = _context.next) {
|
|
35
|
+
case 0:
|
|
36
|
+
_context.next = 2;
|
|
37
|
+
return props.mediaProvider;
|
|
38
|
+
|
|
39
|
+
case 2:
|
|
40
|
+
mediaProvider = _context.sent;
|
|
41
|
+
|
|
42
|
+
if (mediaProvider) {
|
|
43
|
+
_viewMediaClientConfig = mediaProvider.viewMediaClientConfig;
|
|
44
|
+
setViewMediaClientConfig(_viewMediaClientConfig);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
case 4:
|
|
48
|
+
case "end":
|
|
49
|
+
return _context.stop();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}));
|
|
54
|
+
|
|
55
|
+
return function updateViewMediaClientConfig(_x) {
|
|
56
|
+
return _ref.apply(this, arguments);
|
|
57
|
+
};
|
|
58
|
+
}();
|
|
59
|
+
|
|
60
|
+
var _props$node$attrs = props.node.attrs,
|
|
61
|
+
id = _props$node$attrs.id,
|
|
62
|
+
collection = _props$node$attrs.collection;
|
|
63
|
+
var identifier = {
|
|
64
|
+
id: id,
|
|
65
|
+
mediaItemType: 'file',
|
|
66
|
+
collectionName: collection
|
|
67
|
+
};
|
|
68
|
+
return /*#__PURE__*/React.createElement(MediaInlineCard, {
|
|
69
|
+
identifier: identifier,
|
|
70
|
+
mediaClientConfig: viewMediaClientConfig
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
export var MediaInlineNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
74
|
+
_inherits(MediaInlineNodeView, _ReactNodeView);
|
|
75
|
+
|
|
76
|
+
var _super = _createSuper(MediaInlineNodeView);
|
|
77
|
+
|
|
78
|
+
function MediaInlineNodeView() {
|
|
79
|
+
_classCallCheck(this, MediaInlineNodeView);
|
|
80
|
+
|
|
81
|
+
return _super.apply(this, arguments);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
_createClass(MediaInlineNodeView, [{
|
|
85
|
+
key: "createDomRef",
|
|
86
|
+
value: function createDomRef() {
|
|
87
|
+
var domRef = document.createElement('span');
|
|
88
|
+
domRef.contentEditable = 'false';
|
|
89
|
+
return domRef;
|
|
90
|
+
}
|
|
91
|
+
}, {
|
|
92
|
+
key: "getContentDOM",
|
|
93
|
+
value: function getContentDOM() {
|
|
94
|
+
var dom = document.createElement('span');
|
|
95
|
+
return {
|
|
96
|
+
dom: dom
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}, {
|
|
100
|
+
key: "ignoreMutation",
|
|
101
|
+
value: function ignoreMutation() {
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
}, {
|
|
105
|
+
key: "viewShouldUpdate",
|
|
106
|
+
value: function viewShouldUpdate(nextNode) {
|
|
107
|
+
if (this.node.attrs !== nextNode.attrs) {
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
key: "render",
|
|
115
|
+
value: function render(props) {
|
|
116
|
+
var _this = this;
|
|
117
|
+
|
|
118
|
+
var providerFactory = props.providerFactory;
|
|
119
|
+
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
120
|
+
providers: ['mediaProvider'],
|
|
121
|
+
providerFactory: providerFactory,
|
|
122
|
+
renderNode: function renderNode(_ref2) {
|
|
123
|
+
var mediaProvider = _ref2.mediaProvider;
|
|
124
|
+
|
|
125
|
+
if (!mediaProvider) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return /*#__PURE__*/React.createElement(MediaInline, {
|
|
130
|
+
identifier: _this.node.attrs.id,
|
|
131
|
+
mediaProvider: mediaProvider,
|
|
132
|
+
node: _this.node
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}]);
|
|
138
|
+
|
|
139
|
+
return MediaInlineNodeView;
|
|
140
|
+
}(ReactNodeView);
|
|
141
|
+
export var ReactMediaInlineNode = function ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
142
|
+
return function (node, view, getPos) {
|
|
143
|
+
return new MediaInlineNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
144
|
+
providerFactory: providerFactory
|
|
145
|
+
}).init();
|
|
146
|
+
};
|
|
147
|
+
};
|
|
@@ -18,14 +18,15 @@ import assert from 'assert';
|
|
|
18
18
|
import { findDomRefAtPos, isNodeSelection } from 'prosemirror-utils';
|
|
19
19
|
import { insertMediaSingleNode, isMediaSingle } from '../utils/media-single';
|
|
20
20
|
import DropPlaceholder from '../ui/Media/DropPlaceholder';
|
|
21
|
-
import { insertMediaGroupNode } from '../utils/media-files';
|
|
22
|
-
import { removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
21
|
+
import { insertMediaGroupNode, insertMediaInlineNode, canInsertMediaInline } from '../utils/media-files';
|
|
22
|
+
import { isInsidePotentialEmptyParagraph, removeMediaNode, splitMediaGroup } from '../utils/media-common';
|
|
23
23
|
import * as helpers from '../commands/helpers';
|
|
24
24
|
import { updateMediaNodeAttrs } from '../commands/helpers';
|
|
25
25
|
import { stateKey } from './plugin-key';
|
|
26
26
|
import PickerFacade from '../picker-facade';
|
|
27
27
|
import { INPUT_METHOD } from '../../analytics/types';
|
|
28
28
|
import { isImage } from '../utils/is-image';
|
|
29
|
+
import { isInEmptyLine } from '../../../utils/document';
|
|
29
30
|
export { stateKey } from './plugin-key';
|
|
30
31
|
|
|
31
32
|
var createDropPlaceholder = function createDropPlaceholder(allowDropLine) {
|
|
@@ -73,7 +74,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
73
74
|
|
|
74
75
|
_defineProperty(this, "removeOnCloseListener", function () {});
|
|
75
76
|
|
|
76
|
-
_defineProperty(this, "
|
|
77
|
+
_defineProperty(this, "onPopupToggleCallback", function () {});
|
|
77
78
|
|
|
78
79
|
_defineProperty(this, "pickers", []);
|
|
79
80
|
|
|
@@ -238,11 +239,12 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
238
239
|
|
|
239
240
|
var type = _ref3.type;
|
|
240
241
|
var _this$view$state$sche = _this.view.state.schema.nodes,
|
|
242
|
+
mediaInline = _this$view$state$sche.mediaInline,
|
|
241
243
|
mediaSingle = _this$view$state$sche.mediaSingle,
|
|
242
244
|
media = _this$view$state$sche.media;
|
|
243
245
|
|
|
244
246
|
if ((_this$mediaOptions = _this.mediaOptions) !== null && _this$mediaOptions !== void 0 && _this$mediaOptions.allowMediaInline) {
|
|
245
|
-
return type === mediaSingle || type === media;
|
|
247
|
+
return type === mediaSingle || type === media || type === mediaInline;
|
|
246
248
|
}
|
|
247
249
|
|
|
248
250
|
return type === mediaSingle;
|
|
@@ -253,6 +255,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
253
255
|
});
|
|
254
256
|
|
|
255
257
|
_defineProperty(this, "insertFile", function (mediaState, onMediaStateChanged, pickerType) {
|
|
258
|
+
var _this$mediaOptions2;
|
|
259
|
+
|
|
260
|
+
var state = _this.view.state;
|
|
261
|
+
|
|
256
262
|
var mediaStateWithContext = _objectSpread(_objectSpread({}, mediaState), {}, {
|
|
257
263
|
contextId: _this.contextIdentifierProvider ? _this.contextIdentifierProvider.objectId : undefined
|
|
258
264
|
});
|
|
@@ -274,8 +280,10 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
274
280
|
});
|
|
275
281
|
}
|
|
276
282
|
|
|
277
|
-
if (isMediaSingle(
|
|
283
|
+
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
278
284
|
insertMediaSingleNode(_this.view, mediaStateWithContext, _this.getInputMethod(pickerType), collection, _this.mediaOptions && _this.mediaOptions.alignLeftOnInsert);
|
|
285
|
+
} else if ((_this$mediaOptions2 = _this.mediaOptions) !== null && _this$mediaOptions2 !== void 0 && _this$mediaOptions2.allowMediaInline && !isInEmptyLine(state) && !isInsidePotentialEmptyParagraph(state) && canInsertMediaInline(state)) {
|
|
286
|
+
insertMediaInlineNode(_this.view, mediaStateWithContext, collection, _this.getInputMethod(pickerType));
|
|
279
287
|
} else {
|
|
280
288
|
insertMediaGroupNode(_this.view, [mediaStateWithContext], collection, _this.getInputMethod(pickerType));
|
|
281
289
|
} // do events when media state changes
|
|
@@ -328,7 +336,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
328
336
|
});
|
|
329
337
|
|
|
330
338
|
_defineProperty(this, "onPopupPickerClose", function () {
|
|
331
|
-
_this.
|
|
339
|
+
_this.onPopupToggleCallback(false);
|
|
332
340
|
});
|
|
333
341
|
|
|
334
342
|
_defineProperty(this, "shouldUseMediaPickerPopup", function () {
|
|
@@ -350,15 +358,15 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
350
358
|
|
|
351
359
|
_this.popupPicker.show();
|
|
352
360
|
|
|
353
|
-
_this.
|
|
361
|
+
_this.onPopupToggleCallback(true);
|
|
354
362
|
});
|
|
355
363
|
|
|
356
364
|
_defineProperty(this, "setBrowseFn", function (browseFn) {
|
|
357
365
|
_this.openMediaPickerBrowser = browseFn;
|
|
358
366
|
});
|
|
359
367
|
|
|
360
|
-
_defineProperty(this, "onPopupToggle", function (
|
|
361
|
-
_this.
|
|
368
|
+
_defineProperty(this, "onPopupToggle", function (onPopupToggleCallback) {
|
|
369
|
+
_this.onPopupToggleCallback = onPopupToggleCallback;
|
|
362
370
|
});
|
|
363
371
|
|
|
364
372
|
_defineProperty(this, "waitForPendingTasks", function (timeout, lastTask) {
|
|
@@ -582,7 +590,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
582
590
|
}, {
|
|
583
591
|
key: "getDomElement",
|
|
584
592
|
value: function getDomElement(domAtPos) {
|
|
585
|
-
var _this$
|
|
593
|
+
var _this$mediaOptions3;
|
|
586
594
|
|
|
587
595
|
var selection = this.view.state.selection;
|
|
588
596
|
|
|
@@ -594,7 +602,7 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
|
|
|
594
602
|
return;
|
|
595
603
|
}
|
|
596
604
|
|
|
597
|
-
var position = (_this$
|
|
605
|
+
var position = (_this$mediaOptions3 = this.mediaOptions) !== null && _this$mediaOptions3 !== void 0 && _this$mediaOptions3.allowMediaInline ? selection.from + 1 : selection.from;
|
|
598
606
|
var node = findDomRefAtPos(position, domAtPos);
|
|
599
607
|
|
|
600
608
|
if (node) {
|
|
@@ -6,7 +6,8 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import {
|
|
9
|
+
import { NodeSelection } from 'prosemirror-state';
|
|
10
|
+
import { findParentNodeOfType, removeSelectedNode, safeInsert } from 'prosemirror-utils';
|
|
10
11
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
11
12
|
import DownloadIcon from '@atlaskit/icon/glyph/download';
|
|
12
13
|
import { mediaFilmstripItemDOMSelector } from '@atlaskit/media-filmstrip';
|
|
@@ -25,7 +26,8 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, addAnalytics, EVENT_TYPE } f
|
|
|
25
26
|
import { messages } from '@atlaskit/media-ui';
|
|
26
27
|
import { messages as cardMessages } from '../../card/messages';
|
|
27
28
|
import { FilePreviewItem } from './filePreviewItem';
|
|
28
|
-
import { downloadMedia } from './utils';
|
|
29
|
+
import { downloadMedia, removeMediaGroupNode } from './utils';
|
|
30
|
+
import { Fragment } from 'prosemirror-model';
|
|
29
31
|
|
|
30
32
|
var remove = function remove(state, dispatch) {
|
|
31
33
|
if (dispatch) {
|
|
@@ -35,13 +37,42 @@ var remove = function remove(state, dispatch) {
|
|
|
35
37
|
return true;
|
|
36
38
|
};
|
|
37
39
|
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
var handleRemoveMediaGroup = function handleRemoveMediaGroup(state, dispatch) {
|
|
41
|
+
var tr = removeMediaGroupNode(state);
|
|
42
|
+
|
|
43
|
+
if (dispatch) {
|
|
44
|
+
dispatch(tr);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return true;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var changeMediaCardToInline = function changeMediaCardToInline(state, dispatch) {
|
|
51
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
52
|
+
media = _state$schema$nodes.media,
|
|
53
|
+
mediaInline = _state$schema$nodes.mediaInline,
|
|
54
|
+
paragraph = _state$schema$nodes.paragraph;
|
|
55
|
+
var selectedNode = state.selection instanceof NodeSelection && state.selection.node;
|
|
56
|
+
|
|
57
|
+
if (!selectedNode || !selectedNode.type === media) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var mediaInlineNode = mediaInline.create({
|
|
62
|
+
id: selectedNode.attrs.id,
|
|
63
|
+
collection: selectedNode.attrs.collection
|
|
64
|
+
});
|
|
65
|
+
var space = state.schema.text(' ');
|
|
66
|
+
var content = Fragment.from([mediaInlineNode, space]);
|
|
67
|
+
var node = paragraph.createChecked({}, content);
|
|
68
|
+
var nodePos = state.tr.doc.resolve(state.selection.from).start() - 1;
|
|
69
|
+
var tr = removeMediaGroupNode(state);
|
|
70
|
+
tr = safeInsert(node, nodePos, true)(tr);
|
|
71
|
+
|
|
72
|
+
if (dispatch) {
|
|
73
|
+
dispatch(tr);
|
|
74
|
+
}
|
|
43
75
|
|
|
44
|
-
mediaPluginState.handleMediaNodeRemoval(undefined, getPos);
|
|
45
76
|
return true;
|
|
46
77
|
};
|
|
47
78
|
|
|
@@ -53,9 +84,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
53
84
|
options: [{
|
|
54
85
|
title: intl.formatMessage(cardMessages.inline),
|
|
55
86
|
selected: false,
|
|
56
|
-
onClick:
|
|
57
|
-
return true;
|
|
58
|
-
},
|
|
87
|
+
onClick: changeMediaCardToInline,
|
|
59
88
|
testId: 'inline-appearance'
|
|
60
89
|
}, {
|
|
61
90
|
title: intl.formatMessage(messages.displayThumbnail),
|
|
@@ -99,9 +128,7 @@ var generateMediaCardFloatingToolbar = function generateMediaCardFloatingToolbar
|
|
|
99
128
|
onFocus: hoverDecoration(mediaGroup, true),
|
|
100
129
|
onBlur: hoverDecoration(mediaGroup, false),
|
|
101
130
|
title: intl.formatMessage(commonMessages.remove),
|
|
102
|
-
onClick:
|
|
103
|
-
return removeMediaCard(state, mediaPluginState);
|
|
104
|
-
},
|
|
131
|
+
onClick: handleRemoveMediaGroup,
|
|
105
132
|
testId: 'media-toolbar-remove-button'
|
|
106
133
|
}];
|
|
107
134
|
return items;
|
|
@@ -206,10 +233,11 @@ var generateMediaSingleFloatingToolbar = function generateMediaSingleFloatingToo
|
|
|
206
233
|
|
|
207
234
|
export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
208
235
|
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
209
|
-
var _state$schema$
|
|
210
|
-
media = _state$schema$
|
|
211
|
-
|
|
212
|
-
|
|
236
|
+
var _state$schema$nodes2 = state.schema.nodes,
|
|
237
|
+
media = _state$schema$nodes2.media,
|
|
238
|
+
mediaInline = _state$schema$nodes2.mediaInline,
|
|
239
|
+
mediaSingle = _state$schema$nodes2.mediaSingle,
|
|
240
|
+
mediaGroup = _state$schema$nodes2.mediaGroup;
|
|
213
241
|
var altTextValidator = options.altTextValidator,
|
|
214
242
|
allowLinking = options.allowLinking,
|
|
215
243
|
allowAltTextOnImages = options.allowAltTextOnImages,
|
|
@@ -222,7 +250,7 @@ export var floatingToolbar = function floatingToolbar(state, intl) {
|
|
|
222
250
|
return;
|
|
223
251
|
}
|
|
224
252
|
|
|
225
|
-
var nodeType = allowMediaInline ? [mediaSingle, media] : [mediaSingle];
|
|
253
|
+
var nodeType = allowMediaInline ? [mediaInline, mediaSingle, media] : [mediaSingle];
|
|
226
254
|
var baseToolbar = {
|
|
227
255
|
title: 'Media floating controls',
|
|
228
256
|
nodeType: nodeType,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
3
|
import { getMediaClient } from '@atlaskit/media-client';
|
|
4
|
+
import { findParentNodeOfType, removeParentNodeOfType, removeSelectedNode } from 'prosemirror-utils';
|
|
4
5
|
export var getSelectedMediaContainerNodeAttrs = function getSelectedMediaContainerNodeAttrs(mediaPluginState) {
|
|
5
6
|
var selectedNode = mediaPluginState.selectedMediaContainerNode();
|
|
6
7
|
|
|
@@ -57,4 +58,17 @@ export var downloadMedia = /*#__PURE__*/function () {
|
|
|
57
58
|
return function downloadMedia(_x) {
|
|
58
59
|
return _ref.apply(this, arguments);
|
|
59
60
|
};
|
|
60
|
-
}();
|
|
61
|
+
}();
|
|
62
|
+
export var removeMediaGroupNode = function removeMediaGroupNode(state) {
|
|
63
|
+
var mediaGroup = state.schema.nodes.mediaGroup;
|
|
64
|
+
var mediaGroupParent = findParentNodeOfType(mediaGroup)(state.selection);
|
|
65
|
+
var tr = state.tr; // If it is the last media group in filmstrip, remove the entire filmstrip
|
|
66
|
+
|
|
67
|
+
if (mediaGroupParent && mediaGroupParent.node.childCount === 1) {
|
|
68
|
+
tr = removeParentNodeOfType(mediaGroup)(tr);
|
|
69
|
+
} else {
|
|
70
|
+
tr = removeSelectedNode(tr);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return tr;
|
|
74
|
+
};
|
|
@@ -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 var canInsertMediaInline = function canInsertMediaInline(state) {
|
|
9
|
+
var node = state.schema.nodes.mediaInline.create({});
|
|
10
|
+
return canInsert(state.selection.$to, Fragment.from(node));
|
|
11
|
+
};
|
|
8
12
|
|
|
9
13
|
var getInsertMediaGroupAnalytics = function getInsertMediaGroupAnalytics(mediaState, inputMethod) {
|
|
10
14
|
var media = '';
|
|
@@ -27,6 +31,21 @@ var getInsertMediaGroupAnalytics = function getInsertMediaGroupAnalytics(mediaSt
|
|
|
27
31
|
eventType: EVENT_TYPE.TRACK
|
|
28
32
|
};
|
|
29
33
|
};
|
|
34
|
+
|
|
35
|
+
var getInsertMediaInlineAnalytics = function getInsertMediaInlineAnalytics(mediaState, inputMethod) {
|
|
36
|
+
var 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: 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
|
|
@@ -51,6 +70,46 @@ function shouldAppendParagraph(state, node) {
|
|
|
51
70
|
var wasMediaNode = node && node.type === media;
|
|
52
71
|
return (insideTableCell(state) || isInListItem(state) || isInLayoutColumn(state) || atTheEndOfDoc(state) && (!posOfPrecedingMediaGroup(state) || isSelectionNonMediaBlockNode(state))) && !wasMediaNode;
|
|
53
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Create a new media inline to insert the new media.
|
|
75
|
+
* @param view Editor view
|
|
76
|
+
* @param mediaState Media file to be added to the editor
|
|
77
|
+
* @param collection Collection for the media to be added
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
export var insertMediaInlineNode = function insertMediaInlineNode(view, mediaState, collection, inputMethod) {
|
|
82
|
+
var state = view.state,
|
|
83
|
+
dispatch = view.dispatch;
|
|
84
|
+
var schema = state.schema,
|
|
85
|
+
tr = state.tr;
|
|
86
|
+
var mediaInline = schema.nodes.mediaInline; // Do nothing if no media found
|
|
87
|
+
|
|
88
|
+
if (!mediaInline || !mediaState || collection === undefined) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
var id = mediaState.id;
|
|
93
|
+
var mediaInlineNode = mediaInline.create({
|
|
94
|
+
id: id,
|
|
95
|
+
collection: collection
|
|
96
|
+
});
|
|
97
|
+
var space = state.schema.text(' ');
|
|
98
|
+
var pos = state.selection.$to.pos;
|
|
99
|
+
var content = Fragment.from([mediaInlineNode, space]); // Delete the selection if a selection is made
|
|
100
|
+
|
|
101
|
+
var deleteRange = findDeleteRange(state);
|
|
102
|
+
|
|
103
|
+
if (!deleteRange) {
|
|
104
|
+
tr.insert(pos, content);
|
|
105
|
+
} else {
|
|
106
|
+
tr.insert(pos, content).deleteRange(deleteRange.start, deleteRange.end);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
addAnalytics(state, tr, getInsertMediaInlineAnalytics(mediaState, inputMethod));
|
|
110
|
+
dispatch(tr);
|
|
111
|
+
return true;
|
|
112
|
+
};
|
|
54
113
|
/**
|
|
55
114
|
* Insert a media into an existing media group
|
|
56
115
|
* or create a new media group to insert the new media.
|
|
@@ -59,7 +118,6 @@ function shouldAppendParagraph(state, node) {
|
|
|
59
118
|
* @param collection Collection for the media to be added
|
|
60
119
|
*/
|
|
61
120
|
|
|
62
|
-
|
|
63
121
|
export var insertMediaGroupNode = function insertMediaGroupNode(view, mediaStates, collection, inputMethod) {
|
|
64
122
|
var state = view.state,
|
|
65
123
|
dispatch = view.dispatch;
|