@atlaskit/editor-core 182.0.3 → 182.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/.eslintrc.js +2 -0
- package/CHANGELOG.md +47 -0
- package/README.md +20 -0
- package/architecture/0001-record-architecture-decisions.md +25 -0
- package/architecture/0002-deep-equality-check-for-getsharedstate.md +67 -0
- package/architecture/0003-explicit-plugin-dependencies.md +291 -0
- package/dist/cjs/actions/index.js +17 -6
- package/dist/cjs/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/cjs/create-editor/ErrorBoundary.js +1 -16
- package/dist/cjs/create-editor/ReactEditorViewInternal.js +3 -3
- package/dist/cjs/editor-next/editor-internal.js +2 -1
- package/dist/cjs/editor-next/index.js +5 -1
- package/dist/cjs/editor.js +9 -5
- package/dist/cjs/keymaps/index.js +12 -0
- package/dist/cjs/labs/next/internal/hooks/use-editor/index.js +5 -7
- package/dist/cjs/labs/next/presets/default.js +1 -2
- package/dist/cjs/plugins/card/index.js +16 -5
- package/dist/cjs/plugins/card/pm-plugins/actions.js +10 -1
- package/dist/cjs/plugins/card/pm-plugins/analytics/create-analytics-queue.js +48 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/events-from-tr.js +337 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/index.js +19 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/types.js +5 -0
- package/dist/cjs/plugins/card/pm-plugins/analytics/utils.js +139 -0
- package/dist/cjs/plugins/card/pm-plugins/doc.js +99 -22
- package/dist/cjs/plugins/card/pm-plugins/main.js +16 -10
- package/dist/cjs/plugins/card/pm-plugins/reducers.js +7 -0
- package/dist/cjs/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/cjs/plugins/card/toolbar.js +18 -8
- package/dist/cjs/plugins/card/ui/EditLinkToolbar.js +12 -8
- package/dist/cjs/plugins/card/ui/EditorSmartCardEventsNext.js +202 -0
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +12 -4
- package/dist/cjs/plugins/card/utils.js +4 -2
- package/dist/cjs/plugins/extension/context-panel.js +3 -2
- package/dist/cjs/plugins/extension/index.js +4 -1
- package/dist/cjs/plugins/help-dialog/ui/index.js +29 -8
- package/dist/cjs/plugins/hyperlink/Toolbar.js +12 -2
- package/dist/cjs/plugins/hyperlink/commands.js +9 -5
- package/dist/cjs/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/insert-block/index.js +5 -1
- package/dist/cjs/plugins/insert-block/ui/ToolbarInsertBlock/index.js +25 -23
- package/dist/cjs/plugins/media/index.js +9 -5
- package/dist/cjs/plugins/media/pm-plugins/main.js +5 -4
- package/dist/cjs/plugins/media/utils/media-single.js +1 -4
- package/dist/cjs/plugins/panel/pm-plugins/keymaps.js +2 -1
- package/dist/cjs/plugins/paste/handlers.js +5 -5
- package/dist/cjs/plugins/paste/index.js +4 -2
- package/dist/cjs/plugins/paste/pm-plugins/main.js +6 -4
- package/dist/cjs/plugins/rule/commands.js +2 -2
- package/dist/cjs/plugins/rule/index.js +5 -4
- package/dist/cjs/plugins/rule/pm-plugins/input-rule.js +6 -8
- package/dist/cjs/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/text-color/index.js +5 -2
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +3 -4
- package/dist/cjs/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/cjs/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/cjs/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/cjs/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/cjs/ui/ColorPalette/index.js +6 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +15 -10
- package/dist/cjs/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/cjs/ui/ConfigPanel/Fields/ColorPicker.js +248 -17
- package/dist/cjs/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/cjs/ui/ConfigPanel/utils.js +2 -12
- package/dist/cjs/ui/ContentStyles/index.js +2 -5
- package/dist/cjs/ui/MediaAndEmbedsToolbar/index.js +16 -8
- package/dist/cjs/utils/document.js +5 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/actions/index.js +10 -4
- package/dist/es2019/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/es2019/create-editor/ErrorBoundary.js +1 -13
- package/dist/es2019/create-editor/ReactEditorViewInternal.js +2 -2
- package/dist/es2019/editor-next/editor-internal.js +2 -1
- package/dist/es2019/editor-next/index.js +5 -1
- package/dist/es2019/editor.js +5 -2
- package/dist/es2019/keymaps/index.js +1 -1
- package/dist/es2019/labs/next/internal/hooks/use-editor/index.js +4 -6
- package/dist/es2019/labs/next/presets/default.js +1 -2
- package/dist/es2019/plugins/card/index.js +15 -5
- package/dist/es2019/plugins/card/pm-plugins/actions.js +4 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/create-analytics-queue.js +38 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/events-from-tr.js +316 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/index.js +2 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/types.js +1 -0
- package/dist/es2019/plugins/card/pm-plugins/analytics/utils.js +124 -0
- package/dist/es2019/plugins/card/pm-plugins/doc.js +94 -20
- package/dist/es2019/plugins/card/pm-plugins/main.js +17 -8
- package/dist/es2019/plugins/card/pm-plugins/reducers.js +8 -0
- package/dist/es2019/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/es2019/plugins/card/toolbar.js +16 -8
- package/dist/es2019/plugins/card/ui/EditLinkToolbar.js +13 -9
- package/dist/es2019/plugins/card/ui/EditorSmartCardEventsNext.js +180 -0
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +11 -2
- package/dist/es2019/plugins/card/utils.js +6 -2
- package/dist/es2019/plugins/extension/context-panel.js +3 -2
- package/dist/es2019/plugins/extension/index.js +45 -41
- package/dist/es2019/plugins/help-dialog/ui/index.js +17 -1
- package/dist/es2019/plugins/hyperlink/Toolbar.js +13 -4
- package/dist/es2019/plugins/hyperlink/commands.js +9 -6
- package/dist/es2019/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/insert-block/index.js +96 -91
- package/dist/es2019/plugins/insert-block/ui/ToolbarInsertBlock/index.js +3 -2
- package/dist/es2019/plugins/media/index.js +202 -198
- package/dist/es2019/plugins/media/pm-plugins/main.js +5 -4
- package/dist/es2019/plugins/media/utils/media-single.js +1 -5
- package/dist/es2019/plugins/panel/pm-plugins/keymaps.js +3 -2
- package/dist/es2019/plugins/paste/handlers.js +6 -6
- package/dist/es2019/plugins/paste/index.js +18 -14
- package/dist/es2019/plugins/paste/pm-plugins/main.js +7 -5
- package/dist/es2019/plugins/rule/commands.js +2 -2
- package/dist/es2019/plugins/rule/index.js +49 -46
- package/dist/es2019/plugins/rule/pm-plugins/input-rule.js +6 -7
- package/dist/es2019/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/es2019/plugins/text-color/index.js +49 -44
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +3 -3
- package/dist/es2019/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/es2019/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/es2019/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/es2019/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/es2019/ui/ColorPalette/index.js +2 -2
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +8 -4
- package/dist/es2019/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/es2019/ui/ConfigPanel/Fields/ColorPicker.js +238 -13
- package/dist/es2019/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/es2019/ui/ConfigPanel/utils.js +1 -11
- package/dist/es2019/ui/ContentStyles/index.js +2 -5
- package/dist/es2019/ui/MediaAndEmbedsToolbar/index.js +12 -10
- package/dist/es2019/utils/document.js +5 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/actions/index.js +17 -6
- package/dist/esm/analytics-api/attach-payload-into-transaction.js +2 -1
- package/dist/esm/create-editor/ErrorBoundary.js +1 -16
- package/dist/esm/create-editor/ReactEditorViewInternal.js +2 -2
- package/dist/esm/editor-next/editor-internal.js +2 -1
- package/dist/esm/editor-next/index.js +5 -1
- package/dist/esm/editor.js +9 -5
- package/dist/esm/keymaps/index.js +1 -1
- package/dist/esm/labs/next/internal/hooks/use-editor/index.js +4 -6
- package/dist/esm/labs/next/presets/default.js +1 -2
- package/dist/esm/plugins/card/index.js +13 -5
- package/dist/esm/plugins/card/pm-plugins/actions.js +8 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/create-analytics-queue.js +41 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/events-from-tr.js +328 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/index.js +2 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/types.js +1 -0
- package/dist/esm/plugins/card/pm-plugins/analytics/utils.js +124 -0
- package/dist/esm/plugins/card/pm-plugins/doc.js +98 -22
- package/dist/esm/plugins/card/pm-plugins/main.js +16 -10
- package/dist/esm/plugins/card/pm-plugins/reducers.js +7 -0
- package/dist/esm/plugins/card/pm-plugins/util/resolve.js +3 -7
- package/dist/esm/plugins/card/toolbar.js +18 -8
- package/dist/esm/plugins/card/ui/EditLinkToolbar.js +13 -9
- package/dist/esm/plugins/card/ui/EditorSmartCardEventsNext.js +191 -0
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +12 -4
- package/dist/esm/plugins/card/utils.js +4 -2
- package/dist/esm/plugins/extension/context-panel.js +3 -2
- package/dist/esm/plugins/extension/index.js +4 -1
- package/dist/esm/plugins/help-dialog/ui/index.js +29 -8
- package/dist/esm/plugins/hyperlink/Toolbar.js +13 -3
- package/dist/esm/plugins/hyperlink/commands.js +9 -5
- package/dist/esm/plugins/hyperlink/pm-plugins/input-rule.js +4 -0
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/index.js +2 -2
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/insert-block/index.js +5 -1
- package/dist/esm/plugins/insert-block/ui/ToolbarInsertBlock/index.js +25 -23
- package/dist/esm/plugins/media/index.js +9 -5
- package/dist/esm/plugins/media/pm-plugins/main.js +5 -4
- package/dist/esm/plugins/media/utils/media-single.js +1 -4
- package/dist/esm/plugins/panel/pm-plugins/keymaps.js +3 -2
- package/dist/esm/plugins/paste/handlers.js +6 -6
- package/dist/esm/plugins/paste/index.js +4 -2
- package/dist/esm/plugins/paste/pm-plugins/main.js +7 -5
- package/dist/esm/plugins/rule/commands.js +2 -2
- package/dist/esm/plugins/rule/index.js +5 -4
- package/dist/esm/plugins/rule/pm-plugins/input-rule.js +6 -8
- package/dist/esm/plugins/rule/pm-plugins/keymap.js +2 -2
- package/dist/esm/plugins/text-color/index.js +5 -2
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +3 -4
- package/dist/esm/plugins/text-formatting/ui/Toolbar/toolbar-messages.js +10 -0
- package/dist/esm/ui/Appearance/Comment/Comment.js +2 -0
- package/dist/esm/ui/Appearance/FullPage/FullPage.js +2 -4
- package/dist/esm/ui/Appearance/FullPage/FullPageToolbar.js +2 -0
- package/dist/esm/ui/ColorPalette/index.js +2 -2
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +15 -10
- package/dist/esm/ui/ConfigPanel/ConfigPanelFieldsLoader.js +3 -1
- package/dist/esm/ui/ConfigPanel/Fields/ColorPicker.js +244 -19
- package/dist/esm/ui/ConfigPanel/FormContent.js +12 -6
- package/dist/esm/ui/ConfigPanel/utils.js +0 -10
- package/dist/esm/ui/ContentStyles/index.js +2 -5
- package/dist/esm/ui/MediaAndEmbedsToolbar/index.js +16 -8
- package/dist/esm/utils/document.js +5 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/actions/index.d.ts +3 -2
- package/dist/types/create-editor/ErrorBoundary.d.ts +2 -2
- package/dist/types/editor-next/index.d.ts +1 -0
- package/dist/types/editor.d.ts +1 -0
- package/dist/types/keymaps/index.d.ts +1 -1
- package/dist/types/labs/next/internal/hooks/use-editor/index.d.ts +2 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +1 -5
- package/dist/types/labs/next/presets/default.d.ts +2 -10
- package/dist/types/labs/next/presets/mobile.d.ts +1 -5
- package/dist/types/plugins/card/pm-plugins/actions.d.ts +2 -1
- package/dist/types/plugins/card/pm-plugins/analytics/create-analytics-queue.d.ts +10 -0
- package/dist/types/plugins/card/pm-plugins/analytics/events-from-tr.d.ts +17 -0
- package/dist/types/plugins/card/pm-plugins/analytics/index.d.ts +2 -0
- package/dist/types/plugins/card/pm-plugins/analytics/types.d.ts +10 -0
- package/dist/types/plugins/card/pm-plugins/analytics/utils.d.ts +26 -0
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +8 -7
- package/dist/types/plugins/card/pm-plugins/main.d.ts +1 -1
- package/dist/types/plugins/card/pm-plugins/util/resolve.d.ts +2 -2
- package/dist/types/plugins/card/pm-plugins/util/state.d.ts +3 -0
- package/dist/types/plugins/card/types.d.ts +81 -7
- package/dist/types/plugins/card/ui/EditLinkToolbar.d.ts +2 -1
- package/dist/types/plugins/card/ui/EditorSmartCardEventsNext.d.ts +18 -0
- package/dist/types/plugins/card/utils.d.ts +1 -1
- package/dist/types/plugins/extension/context-panel.d.ts +2 -1
- package/dist/types/plugins/extension/index.d.ts +2 -0
- package/dist/types/plugins/hyperlink/commands.d.ts +3 -2
- package/dist/types/plugins/hyperlink/ui/HyperlinkAddToolbar/index.d.ts +2 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/insert-block/index.d.ts +2 -0
- package/dist/types/plugins/insert-block/ui/ToolbarInsertBlock/types.d.ts +2 -1
- package/dist/types/plugins/media/index.d.ts +2 -0
- package/dist/types/plugins/media/pm-plugins/main.d.ts +3 -2
- package/dist/types/plugins/media/utils/media-single.d.ts +1 -1
- package/dist/types/plugins/paste/index.d.ts +2 -0
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/rule/commands.d.ts +2 -1
- package/dist/types/plugins/rule/index.d.ts +5 -1
- package/dist/types/plugins/rule/pm-plugins/input-rule.d.ts +1 -1
- package/dist/types/plugins/rule/pm-plugins/keymap.d.ts +2 -1
- package/dist/types/plugins/text-color/index.d.ts +2 -0
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +2 -0
- package/dist/types/plugins/text-formatting/ui/Toolbar/toolbar-messages.d.ts +10 -0
- package/dist/types/types/editor-appearance-component.d.ts +1 -1
- package/dist/types/types/editor-props.d.ts +1 -0
- package/dist/types/ui/Appearance/FullPage/FullPage.d.ts +2 -0
- package/dist/types/ui/ColorPalette/index.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +3 -1
- package/dist/types/ui/ConfigPanel/ConfigPanelFieldsLoader.d.ts +3 -1
- package/dist/types/ui/ConfigPanel/Fields/ColorPicker.d.ts +12 -1
- package/dist/types/ui/ConfigPanel/FormContent.d.ts +2 -2
- package/dist/types/ui/ConfigPanel/types.d.ts +3 -0
- package/dist/types/ui/ConfigPanel/utils.d.ts +0 -1
- package/dist/types/ui/MediaAndEmbedsToolbar/index.d.ts +1 -1
- package/package.json +15 -14
- package/report.api.md +10 -0
- package/dist/cjs/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -12
- package/dist/cjs/plugins/feature-flags-context/get-feature-flags.js +0 -11
- package/dist/cjs/plugins/feature-flags-context/index.js +0 -50
- package/dist/cjs/plugins/feature-flags-context/plugin-key.js +0 -9
- package/dist/es2019/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -1
- package/dist/es2019/plugins/feature-flags-context/get-feature-flags.js +0 -2
- package/dist/es2019/plugins/feature-flags-context/index.js +0 -29
- package/dist/es2019/plugins/feature-flags-context/plugin-key.js +0 -2
- package/dist/esm/plugins/feature-flags-context/get-enabled-feature-flag-keys.js +0 -1
- package/dist/esm/plugins/feature-flags-context/get-feature-flags.js +0 -4
- package/dist/esm/plugins/feature-flags-context/index.js +0 -40
- package/dist/esm/plugins/feature-flags-context/plugin-key.js +0 -2
- package/dist/types/plugins/feature-flags-context/get-enabled-feature-flag-keys.d.ts +0 -1
- package/dist/types/plugins/feature-flags-context/get-feature-flags.d.ts +0 -3
- package/dist/types/plugins/feature-flags-context/index.d.ts +0 -9
- package/dist/types/plugins/feature-flags-context/plugin-key.d.ts +0 -2
|
@@ -22,211 +22,215 @@ import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
|
22
22
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
23
23
|
import { ReactMediaInlineNode } from './nodeviews/mediaInline';
|
|
24
24
|
export { insertMediaSingleNode } from './utils/media-single';
|
|
25
|
-
const mediaPlugin = options =>
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
reactContext,
|
|
73
|
-
dispatchAnalyticsEvent
|
|
74
|
-
}) => {
|
|
75
|
-
return createPlugin(schema, {
|
|
25
|
+
const mediaPlugin = (options = {}, api) => {
|
|
26
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
27
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
28
|
+
return {
|
|
29
|
+
name: 'media',
|
|
30
|
+
nodes() {
|
|
31
|
+
const {
|
|
32
|
+
allowMediaGroup = true,
|
|
33
|
+
allowMediaSingle = false,
|
|
34
|
+
featureFlags: mediaFeatureFlags
|
|
35
|
+
} = options || {};
|
|
36
|
+
const captions = getMediaFeatureFlag('captions', mediaFeatureFlags);
|
|
37
|
+
const allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
38
|
+
const mediaSingleNode = captions ? mediaSingleWithCaption : mediaSingle;
|
|
39
|
+
return [{
|
|
40
|
+
name: 'mediaGroup',
|
|
41
|
+
node: mediaGroup
|
|
42
|
+
}, {
|
|
43
|
+
name: 'mediaSingle',
|
|
44
|
+
node: mediaSingleNode
|
|
45
|
+
}, {
|
|
46
|
+
name: 'media',
|
|
47
|
+
node: media
|
|
48
|
+
}, {
|
|
49
|
+
name: 'mediaInline',
|
|
50
|
+
node: mediaInline
|
|
51
|
+
}].filter(node => {
|
|
52
|
+
if (node.name === 'mediaGroup') {
|
|
53
|
+
return allowMediaGroup;
|
|
54
|
+
}
|
|
55
|
+
if (node.name === 'mediaSingle') {
|
|
56
|
+
return allowMediaSingle;
|
|
57
|
+
}
|
|
58
|
+
if (node.name === 'mediaInline') {
|
|
59
|
+
return allowMediaInline;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
pmPlugins() {
|
|
65
|
+
const pmPlugins = [{
|
|
66
|
+
name: 'media',
|
|
67
|
+
plugin: ({
|
|
68
|
+
schema,
|
|
69
|
+
dispatch,
|
|
70
|
+
getIntl,
|
|
71
|
+
eventDispatcher,
|
|
76
72
|
providerFactory,
|
|
77
|
-
nodeViews: {
|
|
78
|
-
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
79
|
-
mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options),
|
|
80
|
-
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
81
|
-
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
|
|
82
|
-
},
|
|
83
73
|
errorReporter,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
74
|
+
portalProviderAPI,
|
|
75
|
+
reactContext,
|
|
76
|
+
dispatchAnalyticsEvent
|
|
77
|
+
}) => {
|
|
78
|
+
return createPlugin(schema, {
|
|
79
|
+
providerFactory,
|
|
80
|
+
nodeViews: {
|
|
81
|
+
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
82
|
+
mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options),
|
|
83
|
+
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
84
|
+
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
|
|
85
|
+
},
|
|
86
|
+
errorReporter,
|
|
87
|
+
uploadErrorHandler: options && options.uploadErrorHandler,
|
|
88
|
+
waitForMediaUpload: options && options.waitForMediaUpload,
|
|
89
|
+
customDropzoneContainer: options && options.customDropzoneContainer,
|
|
90
|
+
customMediaPicker: options && options.customMediaPicker,
|
|
91
|
+
allowResizing: !!(options && options.allowResizing)
|
|
92
|
+
}, reactContext, getIntl, dispatch, options, featureFlags.newInsertionBehaviour);
|
|
93
|
+
}
|
|
94
|
+
}, {
|
|
95
|
+
name: 'mediaKeymap',
|
|
96
|
+
plugin: () => keymapPlugin(options)
|
|
97
|
+
}];
|
|
98
|
+
if (options && options.allowMediaSingle) {
|
|
99
|
+
pmPlugins.push({
|
|
100
|
+
name: 'mediaSingleKeymap',
|
|
101
|
+
plugin: ({
|
|
102
|
+
schema
|
|
103
|
+
}) => keymapMediaSinglePlugin(schema)
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (options && options.allowAltTextOnImages) {
|
|
107
|
+
pmPlugins.push({
|
|
108
|
+
name: 'mediaAltText',
|
|
109
|
+
plugin: createMediaAltTextPlugin
|
|
110
|
+
});
|
|
111
|
+
pmPlugins.push({
|
|
112
|
+
name: 'mediaAltTextKeymap',
|
|
113
|
+
plugin: ({
|
|
114
|
+
schema
|
|
115
|
+
}) => keymapMediaAltTextPlugin(schema)
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
if (options && options.allowLinking) {
|
|
119
|
+
pmPlugins.push({
|
|
120
|
+
name: 'mediaLinking',
|
|
121
|
+
plugin: ({
|
|
122
|
+
dispatch
|
|
123
|
+
}) => linkingPlugin(dispatch)
|
|
124
|
+
});
|
|
125
|
+
pmPlugins.push({
|
|
126
|
+
name: 'mediaLinkingKeymap',
|
|
127
|
+
plugin: ({
|
|
128
|
+
schema
|
|
129
|
+
}) => keymapLinkingPlugin(schema)
|
|
130
|
+
});
|
|
90
131
|
}
|
|
91
|
-
}, {
|
|
92
|
-
name: 'mediaKeymap',
|
|
93
|
-
plugin: () => keymapPlugin(options)
|
|
94
|
-
}];
|
|
95
|
-
if (options && options.allowMediaSingle) {
|
|
96
|
-
pmPlugins.push({
|
|
97
|
-
name: 'mediaSingleKeymap',
|
|
98
|
-
plugin: ({
|
|
99
|
-
schema
|
|
100
|
-
}) => keymapMediaSinglePlugin(schema)
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
if (options && options.allowAltTextOnImages) {
|
|
104
|
-
pmPlugins.push({
|
|
105
|
-
name: 'mediaAltText',
|
|
106
|
-
plugin: createMediaAltTextPlugin
|
|
107
|
-
});
|
|
108
|
-
pmPlugins.push({
|
|
109
|
-
name: 'mediaAltTextKeymap',
|
|
110
|
-
plugin: ({
|
|
111
|
-
schema
|
|
112
|
-
}) => keymapMediaAltTextPlugin(schema)
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
if (options && options.allowLinking) {
|
|
116
|
-
pmPlugins.push({
|
|
117
|
-
name: 'mediaLinking',
|
|
118
|
-
plugin: ({
|
|
119
|
-
dispatch
|
|
120
|
-
}) => linkingPlugin(dispatch)
|
|
121
|
-
});
|
|
122
132
|
pmPlugins.push({
|
|
123
|
-
name: '
|
|
124
|
-
plugin: ({
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const {
|
|
137
|
-
state: {
|
|
138
|
-
selection
|
|
133
|
+
name: 'mediaSelectionHandler',
|
|
134
|
+
plugin: () => {
|
|
135
|
+
const mediaSelectionHandlerPlugin = new SafePlugin({
|
|
136
|
+
key: new PluginKey('mediaSelectionHandlerPlugin'),
|
|
137
|
+
props: {
|
|
138
|
+
handleScrollToSelection: view => {
|
|
139
|
+
const {
|
|
140
|
+
state: {
|
|
141
|
+
selection
|
|
142
|
+
}
|
|
143
|
+
} = view;
|
|
144
|
+
if (!(selection instanceof NodeSelection) || selection.node.type.name !== 'media') {
|
|
145
|
+
return false;
|
|
139
146
|
}
|
|
140
|
-
|
|
141
|
-
|
|
147
|
+
const {
|
|
148
|
+
node,
|
|
149
|
+
offset
|
|
150
|
+
} = view.domAtPos(selection.from);
|
|
151
|
+
if (
|
|
152
|
+
// Is the media element mounted already?
|
|
153
|
+
offset === node.childNodes.length) {
|
|
154
|
+
// Media is not ready, so stop the scroll request
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Media is ready, keep the scrolling request
|
|
142
159
|
return false;
|
|
143
160
|
}
|
|
144
|
-
const {
|
|
145
|
-
node,
|
|
146
|
-
offset
|
|
147
|
-
} = view.domAtPos(selection.from);
|
|
148
|
-
if (
|
|
149
|
-
// Is the media element mounted already?
|
|
150
|
-
offset === node.childNodes.length) {
|
|
151
|
-
// Media is not ready, so stop the scroll request
|
|
152
|
-
return true;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// Media is ready, keep the scrolling request
|
|
156
|
-
return false;
|
|
157
161
|
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
162
|
+
});
|
|
163
|
+
return mediaSelectionHandlerPlugin;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
return pmPlugins;
|
|
167
|
+
},
|
|
168
|
+
contentComponent({
|
|
169
|
+
editorView,
|
|
170
|
+
appearance
|
|
171
|
+
}) {
|
|
172
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WithPluginState, {
|
|
173
|
+
editorView: editorView,
|
|
174
|
+
plugins: {
|
|
175
|
+
mediaState: pluginKey
|
|
176
|
+
},
|
|
177
|
+
render: ({
|
|
178
|
+
mediaState
|
|
179
|
+
}) => /*#__PURE__*/React.createElement(MediaPickerComponents, {
|
|
180
|
+
editorDomElement: editorView.dom,
|
|
181
|
+
mediaState: mediaState,
|
|
182
|
+
appearance: appearance
|
|
183
|
+
})
|
|
184
|
+
}));
|
|
185
|
+
},
|
|
186
|
+
secondaryToolbarComponent({
|
|
187
|
+
editorView,
|
|
188
|
+
eventDispatcher,
|
|
189
|
+
disabled
|
|
190
|
+
}) {
|
|
191
|
+
return /*#__PURE__*/React.createElement(ToolbarMedia, {
|
|
192
|
+
editorView: editorView,
|
|
193
|
+
eventDispatcher: eventDispatcher,
|
|
194
|
+
pluginKey: pluginKey,
|
|
195
|
+
isDisabled: disabled,
|
|
196
|
+
isReducedSpacing: true
|
|
197
|
+
});
|
|
198
|
+
},
|
|
199
|
+
pluginsOptions: {
|
|
200
|
+
quickInsert: ({
|
|
201
|
+
formatMessage
|
|
202
|
+
}) => [{
|
|
203
|
+
id: 'media',
|
|
204
|
+
title: formatMessage(messages.mediaFiles),
|
|
205
|
+
description: formatMessage(messages.mediaFilesDescription),
|
|
206
|
+
priority: 400,
|
|
207
|
+
keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
|
|
208
|
+
icon: () => /*#__PURE__*/React.createElement(IconImages, null),
|
|
209
|
+
action(insert, state) {
|
|
210
|
+
const pluginState = pluginKey.getState(state);
|
|
211
|
+
pluginState.showMediaPicker();
|
|
212
|
+
return addAnalytics(state, insert(''), {
|
|
213
|
+
action: ACTION.OPENED,
|
|
214
|
+
actionSubject: ACTION_SUBJECT.PICKER,
|
|
215
|
+
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
216
|
+
attributes: {
|
|
217
|
+
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
218
|
+
},
|
|
219
|
+
eventType: EVENT_TYPE.UI
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}],
|
|
223
|
+
floatingToolbar: (state, intl, providerFactory) => floatingToolbar(state, intl, {
|
|
224
|
+
providerFactory,
|
|
225
|
+
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
226
|
+
allowResizing: options && options.allowResizing,
|
|
227
|
+
allowResizingInTables: options && options.allowResizingInTables,
|
|
228
|
+
allowLinking: options && options.allowLinking,
|
|
229
|
+
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
230
|
+
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
231
|
+
altTextValidator: options && options.altTextValidator
|
|
180
232
|
})
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
editorView,
|
|
185
|
-
eventDispatcher,
|
|
186
|
-
disabled
|
|
187
|
-
}) {
|
|
188
|
-
return /*#__PURE__*/React.createElement(ToolbarMedia, {
|
|
189
|
-
editorView: editorView,
|
|
190
|
-
eventDispatcher: eventDispatcher,
|
|
191
|
-
pluginKey: pluginKey,
|
|
192
|
-
isDisabled: disabled,
|
|
193
|
-
isReducedSpacing: true
|
|
194
|
-
});
|
|
195
|
-
},
|
|
196
|
-
pluginsOptions: {
|
|
197
|
-
quickInsert: ({
|
|
198
|
-
formatMessage
|
|
199
|
-
}) => [{
|
|
200
|
-
id: 'media',
|
|
201
|
-
title: formatMessage(messages.mediaFiles),
|
|
202
|
-
description: formatMessage(messages.mediaFilesDescription),
|
|
203
|
-
priority: 400,
|
|
204
|
-
keywords: ['attachment', 'gif', 'media', 'picture', 'image', 'video'],
|
|
205
|
-
icon: () => /*#__PURE__*/React.createElement(IconImages, null),
|
|
206
|
-
action(insert, state) {
|
|
207
|
-
const pluginState = pluginKey.getState(state);
|
|
208
|
-
pluginState.showMediaPicker();
|
|
209
|
-
return addAnalytics(state, insert(''), {
|
|
210
|
-
action: ACTION.OPENED,
|
|
211
|
-
actionSubject: ACTION_SUBJECT.PICKER,
|
|
212
|
-
actionSubjectId: ACTION_SUBJECT_ID.PICKER_CLOUD,
|
|
213
|
-
attributes: {
|
|
214
|
-
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
215
|
-
},
|
|
216
|
-
eventType: EVENT_TYPE.UI
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
}],
|
|
220
|
-
floatingToolbar: (state, intl, providerFactory) => floatingToolbar(state, intl, {
|
|
221
|
-
providerFactory,
|
|
222
|
-
allowMediaInline: options && getMediaFeatureFlag('mediaInline', options.featureFlags),
|
|
223
|
-
allowResizing: options && options.allowResizing,
|
|
224
|
-
allowResizingInTables: options && options.allowResizingInTables,
|
|
225
|
-
allowLinking: options && options.allowLinking,
|
|
226
|
-
allowAdvancedToolBarOptions: options && options.allowAdvancedToolBarOptions,
|
|
227
|
-
allowAltTextOnImages: options && options.allowAltTextOnImages,
|
|
228
|
-
altTextValidator: options && options.altTextValidator
|
|
229
|
-
})
|
|
230
|
-
}
|
|
231
|
-
});
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
};
|
|
232
236
|
export default mediaPlugin;
|
|
@@ -45,7 +45,7 @@ const MEDIA_RESOLVED_STATES = ['ready', 'error', 'cancelled'];
|
|
|
45
45
|
export class MediaPluginStateImplementation {
|
|
46
46
|
// @ts-ignore: private is OK
|
|
47
47
|
|
|
48
|
-
constructor(_state, options, mediaOptions, _dispatch) {
|
|
48
|
+
constructor(_state, options, mediaOptions, newInsertionBehaviour, _dispatch) {
|
|
49
49
|
_defineProperty(this, "allowsUploads", false);
|
|
50
50
|
_defineProperty(this, "ignoreLinks", false);
|
|
51
51
|
_defineProperty(this, "waitForMediaUpload", true);
|
|
@@ -164,7 +164,7 @@ export class MediaPluginStateImplementation {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
if (isMediaSingle(state.schema, mediaStateWithContext.fileMimeType)) {
|
|
167
|
-
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert);
|
|
167
|
+
insertMediaSingleNode(this.view, mediaStateWithContext, this.getInputMethod(pickerType), collection, this.mediaOptions && this.mediaOptions.alignLeftOnInsert, this.newInsertionBehaviour);
|
|
168
168
|
} 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)) {
|
|
169
169
|
insertMediaInlineNode(this.view, mediaStateWithContext, collection, this.getInputMethod(pickerType));
|
|
170
170
|
} else {
|
|
@@ -359,6 +359,7 @@ export class MediaPluginStateImplementation {
|
|
|
359
359
|
});
|
|
360
360
|
this.options = options;
|
|
361
361
|
this.mediaOptions = mediaOptions;
|
|
362
|
+
this.newInsertionBehaviour = newInsertionBehaviour;
|
|
362
363
|
this.dispatch = _dispatch;
|
|
363
364
|
this.waitForMediaUpload = options.waitForMediaUpload === undefined ? true : options.waitForMediaUpload;
|
|
364
365
|
const {
|
|
@@ -490,13 +491,13 @@ export class MediaPluginStateImplementation {
|
|
|
490
491
|
}
|
|
491
492
|
}
|
|
492
493
|
export const getMediaPluginState = state => stateKey.getState(state);
|
|
493
|
-
export const createPlugin = (_schema, options, reactContext, getIntl, dispatch, mediaOptions) => {
|
|
494
|
+
export const createPlugin = (_schema, options, reactContext, getIntl, dispatch, mediaOptions, newInsertionBehaviour) => {
|
|
494
495
|
const intl = getIntl();
|
|
495
496
|
const dropPlaceholder = createDropPlaceholder(intl, mediaOptions && mediaOptions.allowDropzoneDropLine);
|
|
496
497
|
return new SafePlugin({
|
|
497
498
|
state: {
|
|
498
499
|
init(_config, state) {
|
|
499
|
-
return new MediaPluginStateImplementation(state, options, mediaOptions, dispatch);
|
|
500
|
+
return new MediaPluginStateImplementation(state, options, mediaOptions, newInsertionBehaviour, dispatch);
|
|
500
501
|
},
|
|
501
502
|
apply(tr, pluginState) {
|
|
502
503
|
// remap editing media single position if we're in collab
|
|
@@ -7,7 +7,6 @@ import { copyOptionalAttrsFromMediaState } from '../utils/media-common';
|
|
|
7
7
|
import { mapSlice } from '../../../utils/slice';
|
|
8
8
|
import { addAnalytics, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '../../analytics';
|
|
9
9
|
import { safeInsert, shouldSplitSelectedNodeOnNodeInsertion } from '../../../utils/insert';
|
|
10
|
-
import { getFeatureFlags } from '../../feature-flags-context';
|
|
11
10
|
import { isImage } from './is-image';
|
|
12
11
|
import { atTheBeginningOfBlock } from '../../../utils/prosemirror/position';
|
|
13
12
|
import { getRandomHex } from '@atlaskit/media-common';
|
|
@@ -79,7 +78,7 @@ export const insertMediaAsMediaSingle = (view, node, inputMethod) => {
|
|
|
79
78
|
};
|
|
80
79
|
return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
|
|
81
80
|
};
|
|
82
|
-
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert) => {
|
|
81
|
+
export const insertMediaSingleNode = (view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour) => {
|
|
83
82
|
var _state$selection$$fro;
|
|
84
83
|
if (collection === undefined) {
|
|
85
84
|
return false;
|
|
@@ -108,9 +107,6 @@ export const insertMediaSingleNode = (view, mediaState, inputMethod, collection,
|
|
|
108
107
|
inputMethod
|
|
109
108
|
})(state, dispatch);
|
|
110
109
|
} else {
|
|
111
|
-
const {
|
|
112
|
-
newInsertionBehaviour
|
|
113
|
-
} = getFeatureFlags(view.state);
|
|
114
110
|
let tr = null;
|
|
115
111
|
if (newInsertionBehaviour) {
|
|
116
112
|
tr = safeInsert(node, state.selection.from)(state.tr);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { keymap } from 'prosemirror-keymap';
|
|
2
|
-
import { setTextSelection, findParentNodeOfType } from 'prosemirror-utils';
|
|
2
|
+
import { setTextSelection, findParentNodeOfType, hasParentNodeOfType } from 'prosemirror-utils';
|
|
3
3
|
import { isEmptyNode } from '../../../utils';
|
|
4
4
|
function findParentNode(selection, nodeType) {
|
|
5
5
|
const parentPosition = findParentNodeOfType(nodeType)(selection);
|
|
@@ -51,7 +51,8 @@ export function keymapPlugin() {
|
|
|
51
51
|
const isParentNodeAPanel = parentNodeType === panel;
|
|
52
52
|
|
|
53
53
|
// Stops merging panels when deleting empty paragraph in between
|
|
54
|
-
|
|
54
|
+
// Stops merging blockquotes with panels when deleting from start of blockquote
|
|
55
|
+
if (isPreviousNodeAPanel && !isParentNodeAPanel || isInsideAnEmptyNode(selection, panel, state.schema) || hasParentNodeOfType(blockquote)(selection)) {
|
|
55
56
|
const content = $from.node($from.depth).content;
|
|
56
57
|
const insertPos = previousPos.pos;
|
|
57
58
|
deleteCurrentItem($from, tr).insert(insertPos, content);
|
|
@@ -6,7 +6,7 @@ import uuid from 'uuid/v4';
|
|
|
6
6
|
import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
7
7
|
import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
|
|
8
8
|
import { mapSlice } from '../../utils/slice';
|
|
9
|
-
import { INPUT_METHOD } from '../analytics';
|
|
9
|
+
import { ACTION, INPUT_METHOD } from '../analytics';
|
|
10
10
|
import { queueCardsFromChangedTr } from '../card/pm-plugins/doc';
|
|
11
11
|
import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
|
|
12
12
|
import { linkifyContent } from '../hyperlink/utils';
|
|
@@ -105,7 +105,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice) {
|
|
|
105
105
|
// This maintains both the selection (destination) and the slice (paste content).
|
|
106
106
|
safeInsert(transformedSlice.content)(tr).scrollIntoView();
|
|
107
107
|
}
|
|
108
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
108
|
+
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD, ACTION.PASTED);
|
|
109
109
|
if (dispatch) {
|
|
110
110
|
dispatch(tr);
|
|
111
111
|
}
|
|
@@ -385,7 +385,7 @@ export function handlePastePreservingMarks(slice) {
|
|
|
385
385
|
// special case for plainTextSlice & linkMark: merge into existing link
|
|
386
386
|
if (isPlainTextSlice && linkMark.isInSet(selectionMarks) && selectionMarks.length === 1) {
|
|
387
387
|
const tr = closeHistory(state.tr).replaceSelectionWith(slice.content.firstChild.firstChild, true).setStoredMarks(selectionMarks).scrollIntoView();
|
|
388
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
388
|
+
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD, ACTION.PASTED);
|
|
389
389
|
if (dispatch) {
|
|
390
390
|
dispatch(tr);
|
|
391
391
|
}
|
|
@@ -397,7 +397,7 @@ export function handlePastePreservingMarks(slice) {
|
|
|
397
397
|
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem, paragraph, text, emoji, mention, orderedList)(slice)) {
|
|
398
398
|
const transformedSlice = applyTextMarksToSlice(schema, selectionMarks)(slice);
|
|
399
399
|
const tr = closeHistory(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
400
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
400
|
+
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD, ACTION.PASTED);
|
|
401
401
|
if (dispatch) {
|
|
402
402
|
dispatch(tr);
|
|
403
403
|
}
|
|
@@ -602,7 +602,7 @@ export function handleMarkdown(markdownSlice, from, to) {
|
|
|
602
602
|
tr.replaceSelection(markdownSlice);
|
|
603
603
|
}
|
|
604
604
|
tr.setSelection(TextSelection.near(tr.doc.resolve(pastesFrom + markdownSlice.size), -1));
|
|
605
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
605
|
+
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD, ACTION.PASTED);
|
|
606
606
|
if (dispatch) {
|
|
607
607
|
dispatch(tr.scrollIntoView());
|
|
608
608
|
}
|
|
@@ -819,7 +819,7 @@ export function handleRichText(slice) {
|
|
|
819
819
|
|
|
820
820
|
// queue link cards, ignoring any errors
|
|
821
821
|
if (dispatch) {
|
|
822
|
-
dispatch(queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD));
|
|
822
|
+
dispatch(queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD, ACTION.PASTED));
|
|
823
823
|
}
|
|
824
824
|
return true;
|
|
825
825
|
};
|
|
@@ -2,18 +2,22 @@ import { createPlugin } from './pm-plugins/main';
|
|
|
2
2
|
const pastePlugin = ({
|
|
3
3
|
cardOptions,
|
|
4
4
|
sanitizePrivateContent
|
|
5
|
-
}) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
})
|
|
5
|
+
}, api) => {
|
|
6
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
7
|
+
const featureFlags = (api === null || api === void 0 ? void 0 : (_api$dependencies = api.dependencies) === null || _api$dependencies === void 0 ? void 0 : (_api$dependencies$fea = _api$dependencies.featureFlags) === null || _api$dependencies$fea === void 0 ? void 0 : _api$dependencies$fea.sharedState.currentState()) || {};
|
|
8
|
+
return {
|
|
9
|
+
name: 'paste',
|
|
10
|
+
pmPlugins() {
|
|
11
|
+
return [{
|
|
12
|
+
name: 'paste',
|
|
13
|
+
plugin: ({
|
|
14
|
+
schema,
|
|
15
|
+
providerFactory,
|
|
16
|
+
dispatchAnalyticsEvent,
|
|
17
|
+
dispatch
|
|
18
|
+
}) => createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, cardOptions, sanitizePrivateContent, providerFactory)
|
|
19
|
+
}];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
};
|
|
19
23
|
export default pastePlugin;
|
|
@@ -2,9 +2,9 @@ import { Slice, Fragment } from 'prosemirror-model';
|
|
|
2
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
import uuid from 'uuid';
|
|
4
4
|
import { MarkdownTransformer } from '@atlaskit/editor-markdown-transformer';
|
|
5
|
+
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
5
6
|
import { mapChildren } from '../../../utils/slice';
|
|
6
7
|
import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
|
|
7
|
-
sendPasteAnalyticsEvent;
|
|
8
8
|
import * as clipboard from '../../../utils/clipboard';
|
|
9
9
|
import { transformSliceForMedia } from '../../media/utils/media-single';
|
|
10
10
|
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks } from '../util';
|
|
@@ -13,7 +13,7 @@ import { transformSliceNestedExpandToExpand } from '../../expand/utils';
|
|
|
13
13
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from '../handlers';
|
|
14
14
|
import { transformSliceToJoinAdjacentCodeBlocks, transformSingleLineCodeBlockToCodeMark } from '../../code-block/utils';
|
|
15
15
|
import { createPasteMeasurePayload, getContentNodeTypes, handlePasteAsPlainTextWithAnalytics, handlePasteIntoTaskAndDecisionWithAnalytics, handleCodeBlockWithAnalytics, handleMediaSingleWithAnalytics, handlePastePreservingMarksWithAnalytics, handleMarkdownWithAnalytics, handleRichTextWithAnalytics, handleExpandWithAnalytics, handleSelectedTableWithAnalytics, handlePasteLinkOnSelectedTextWithAnalytics, sendPasteAnalyticsEvent, handlePasteIntoCaptionWithAnalytics, handlePastePanelOrDecisionIntoListWithAnalytics, handlePasteNonNestableBlockNodesIntoListWithAnalytics } from './analytics';
|
|
16
|
-
import { analyticsPluginKey, PasteTypes } from '../../analytics';
|
|
16
|
+
import { ACTION, analyticsPluginKey, INPUT_METHOD, PasteTypes } from '../../analytics';
|
|
17
17
|
import { isInsideBlockQuote, insideTable, measurements } from '../../../utils';
|
|
18
18
|
import { measureRender } from '@atlaskit/editor-common/utils';
|
|
19
19
|
import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
|
|
@@ -30,8 +30,7 @@ import { extractSliceFromStep } from '../../../utils/step';
|
|
|
30
30
|
import { pluginKey as stateKey, createPluginState } from './plugin-factory';
|
|
31
31
|
export { pluginKey as stateKey } from './plugin-factory';
|
|
32
32
|
export { md } from '../md';
|
|
33
|
-
|
|
34
|
-
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
33
|
+
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
35
34
|
const atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
36
35
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
37
36
|
let textInput = text;
|
|
@@ -178,6 +177,10 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, cardOptio
|
|
|
178
177
|
if (!isPastingTextInsidePlaceholderText && !isPastingTable) {
|
|
179
178
|
tr.setMeta(betterTypePluginKey, true);
|
|
180
179
|
}
|
|
180
|
+
addLinkMetadata(view.state.selection, tr, {
|
|
181
|
+
action: isPlainText ? ACTION.PASTED_AS_PLAIN : ACTION.PASTED,
|
|
182
|
+
inputMethod: INPUT_METHOD.CLIPBOARD
|
|
183
|
+
});
|
|
181
184
|
view.dispatch(tr);
|
|
182
185
|
};
|
|
183
186
|
slice = handleParagraphBlockMarks(state, slice);
|
|
@@ -333,7 +336,6 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, cardOptio
|
|
|
333
336
|
if (handlePasteIntoCaptionWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
334
337
|
return true;
|
|
335
338
|
}
|
|
336
|
-
const featureFlags = getFeatureFlags(state);
|
|
337
339
|
if (handlePastePanelOrDecisionIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
338
340
|
return true;
|
|
339
341
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createHorizontalRule } from './pm-plugins/input-rule';
|
|
2
|
-
export const insertHorizontalRule = inputMethod => (state, dispatch) => {
|
|
3
|
-
const tr = createHorizontalRule(state, state.selection.from, state.selection.to, inputMethod);
|
|
2
|
+
export const insertHorizontalRule = (inputMethod, featureFlags) => (state, dispatch) => {
|
|
3
|
+
const tr = createHorizontalRule(state, featureFlags, state.selection.from, state.selection.to, inputMethod);
|
|
4
4
|
if (tr) {
|
|
5
5
|
if (dispatch) {
|
|
6
6
|
dispatch(tr);
|