@atlaskit/editor-core 185.2.25 → 185.2.26
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 +7 -0
- package/dist/cjs/editor-next/editor-internal.js +3 -3
- package/dist/cjs/index.js +4 -4
- package/dist/cjs/labs/next/Editor.js +3 -3
- package/dist/cjs/nodeviews/index.js +1 -16
- package/dist/cjs/plugins/annotation/index.js +31 -21
- package/dist/cjs/plugins/annotation/nodeviews/index.js +2 -2
- package/dist/cjs/plugins/base/index.js +0 -6
- package/dist/cjs/plugins/caption/index.js +1 -2
- package/dist/cjs/plugins/caption/nodeviews/index.js +3 -3
- package/dist/cjs/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/cjs/plugins/card/nodeviews/embedCard.js +4 -4
- package/dist/cjs/plugins/extension/nodeviews/extension.js +2 -2
- package/dist/cjs/plugins/jira-issue/index.js +2 -2
- package/dist/cjs/plugins/media/index.js +2 -2
- package/dist/cjs/plugins/media/nodeviews/mediaGroup.js +25 -19
- package/dist/cjs/plugins/media/nodeviews/mediaInline.js +3 -3
- package/dist/cjs/plugins/media/nodeviews/mediaNodeView/index.js +16 -10
- package/dist/cjs/plugins/media/nodeviews/mediaSingle.js +2 -2
- package/dist/cjs/plugins/media/pm-plugins/main.js +25 -8
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +2 -2
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +2 -2
- package/dist/cjs/plugins/unsupported-content/index.js +6 -4
- package/dist/cjs/test-utils.js +0 -7
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/editor-next/editor-internal.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/labs/next/Editor.js +1 -1
- package/dist/es2019/nodeviews/index.js +1 -2
- package/dist/es2019/plugins/annotation/index.js +34 -23
- package/dist/es2019/plugins/annotation/nodeviews/index.js +1 -1
- package/dist/es2019/plugins/base/index.js +0 -4
- package/dist/es2019/plugins/caption/index.js +1 -4
- package/dist/es2019/plugins/caption/nodeviews/index.js +2 -2
- package/dist/es2019/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/es2019/plugins/card/nodeviews/embedCard.js +2 -2
- package/dist/es2019/plugins/extension/nodeviews/extension.js +1 -1
- package/dist/es2019/plugins/jira-issue/index.js +1 -1
- package/dist/es2019/plugins/media/index.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaGroup.js +21 -14
- package/dist/es2019/plugins/media/nodeviews/mediaInline.js +2 -2
- package/dist/es2019/plugins/media/nodeviews/mediaNodeView/index.js +13 -9
- package/dist/es2019/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/es2019/plugins/media/pm-plugins/main.js +28 -11
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/es2019/plugins/unsupported-content/index.js +1 -1
- package/dist/es2019/test-utils.js +0 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/editor-next/editor-internal.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/labs/next/Editor.js +1 -1
- package/dist/esm/nodeviews/index.js +1 -2
- package/dist/esm/plugins/annotation/index.js +32 -22
- package/dist/esm/plugins/annotation/nodeviews/index.js +1 -1
- package/dist/esm/plugins/base/index.js +0 -6
- package/dist/esm/plugins/caption/index.js +1 -2
- package/dist/esm/plugins/caption/nodeviews/index.js +2 -2
- package/dist/esm/plugins/caption/pm-plugins/main.js +4 -2
- package/dist/esm/plugins/card/nodeviews/embedCard.js +4 -4
- package/dist/esm/plugins/extension/nodeviews/extension.js +1 -1
- package/dist/esm/plugins/jira-issue/index.js +1 -1
- package/dist/esm/plugins/media/index.js +2 -2
- package/dist/esm/plugins/media/nodeviews/mediaGroup.js +24 -18
- package/dist/esm/plugins/media/nodeviews/mediaInline.js +2 -2
- package/dist/esm/plugins/media/nodeviews/mediaNodeView/index.js +15 -9
- package/dist/esm/plugins/media/nodeviews/mediaSingle.js +1 -1
- package/dist/esm/plugins/media/pm-plugins/main.js +26 -9
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +1 -1
- package/dist/esm/plugins/unsupported-content/index.js +1 -1
- package/dist/esm/test-utils.js +0 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/create-editor/ReactEditorViewInternal.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/labs/next/internal/components/EditorInternal.d.ts +2 -2
- package/dist/types/labs/next/internal/editor-props-type.d.ts +1 -1
- package/dist/types/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
- package/dist/types/nodeviews/index.d.ts +0 -2
- package/dist/types/plugins/annotation/index.d.ts +3 -1
- package/dist/types/plugins/annotation/nodeviews/index.d.ts +2 -1
- package/dist/types/plugins/annotation/pm-plugins/types.d.ts +2 -2
- package/dist/types/plugins/caption/index.d.ts +1 -1
- package/dist/types/plugins/caption/nodeviews/index.d.ts +7 -4
- package/dist/types/plugins/caption/pm-plugins/main.d.ts +5 -4
- package/dist/types/plugins/card/nodeviews/embedCard.d.ts +2 -2
- package/dist/types/plugins/extension/nodeviews/extension.d.ts +3 -2
- package/dist/types/plugins/extension/pm-plugins/main.d.ts +2 -2
- package/dist/types/plugins/media/index.d.ts +3 -1
- package/dist/types/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
- package/dist/types/plugins/media/nodeviews/mediaInline.d.ts +6 -3
- package/dist/types/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
- package/dist/types/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
- package/dist/types/plugins/media/types.d.ts +4 -0
- package/dist/types/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
- package/dist/types/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
- package/dist/types/test-utils.d.ts +0 -1
- package/dist/types-ts4.5/create-editor/ReactEditorViewInternal.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/internal/components/EditorInternal.d.ts +2 -2
- package/dist/types-ts4.5/labs/next/internal/editor-props-type.d.ts +1 -1
- package/dist/types-ts4.5/labs/next/internal/hooks/use-editor/create-editor.d.ts +1 -1
- package/dist/types-ts4.5/nodeviews/index.d.ts +0 -2
- package/dist/types-ts4.5/plugins/annotation/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/annotation/nodeviews/index.d.ts +2 -1
- package/dist/types-ts4.5/plugins/annotation/pm-plugins/types.d.ts +2 -2
- package/dist/types-ts4.5/plugins/caption/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/caption/nodeviews/index.d.ts +7 -4
- package/dist/types-ts4.5/plugins/caption/pm-plugins/main.d.ts +5 -4
- package/dist/types-ts4.5/plugins/card/nodeviews/embedCard.d.ts +2 -2
- package/dist/types-ts4.5/plugins/extension/nodeviews/extension.d.ts +3 -2
- package/dist/types-ts4.5/plugins/extension/pm-plugins/main.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/index.d.ts +3 -1
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaGroup.d.ts +5 -3
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaInline.d.ts +6 -3
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaNodeView/index.d.ts +6 -4
- package/dist/types-ts4.5/plugins/media/nodeviews/mediaSingle.d.ts +2 -2
- package/dist/types-ts4.5/plugins/media/types.d.ts +4 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/decisionItem.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/taskItem.d.ts +1 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/pm-plugins/main.d.ts +1 -1
- package/dist/types-ts4.5/test-utils.d.ts +0 -1
- package/package.json +2 -2
- package/report.api.md +20 -85
- package/tmp/api-report-tmp.d.ts +18 -68
- package/dist/cjs/nodeviews/ReactNodeView.js +0 -224
- package/dist/cjs/nodeviews/SelectionBasedNodeView.js +0 -169
- package/dist/cjs/plugins/base/pm-plugins/react-nodeview.js +0 -72
- package/dist/cjs/ui/PortalProvider/PortalProviderThemesProvider.js +0 -43
- package/dist/cjs/ui/PortalProvider/index.js +0 -252
- package/dist/es2019/nodeviews/ReactNodeView.js +0 -170
- package/dist/es2019/nodeviews/SelectionBasedNodeView.js +0 -158
- package/dist/es2019/plugins/base/pm-plugins/react-nodeview.js +0 -48
- package/dist/es2019/ui/PortalProvider/PortalProviderThemesProvider.js +0 -37
- package/dist/es2019/ui/PortalProvider/index.js +0 -184
- package/dist/esm/nodeviews/ReactNodeView.js +0 -217
- package/dist/esm/nodeviews/SelectionBasedNodeView.js +0 -163
- package/dist/esm/plugins/base/pm-plugins/react-nodeview.js +0 -62
- package/dist/esm/ui/PortalProvider/PortalProviderThemesProvider.js +0 -36
- package/dist/esm/ui/PortalProvider/index.js +0 -242
- package/dist/types/nodeviews/ReactNodeView.d.ts +0 -52
- package/dist/types/nodeviews/SelectionBasedNodeView.d.ts +0 -53
- package/dist/types/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
- package/dist/types/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
- package/dist/types/ui/PortalProvider/index.d.ts +0 -51
- package/dist/types-ts4.5/nodeviews/ReactNodeView.d.ts +0 -52
- package/dist/types-ts4.5/nodeviews/SelectionBasedNodeView.d.ts +0 -53
- package/dist/types-ts4.5/plugins/base/pm-plugins/react-nodeview.d.ts +0 -13
- package/dist/types-ts4.5/ui/PortalProvider/PortalProviderThemesProvider.d.ts +0 -6
- package/dist/types-ts4.5/ui/PortalProvider/index.d.ts +0 -51
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
5
|
+
import { NodeSelection, TextSelection, AllSelection } from 'prosemirror-state';
|
|
6
6
|
import { insertPoint } from 'prosemirror-transform';
|
|
7
7
|
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
8
8
|
import { ErrorReporter, browser } from '@atlaskit/editor-common/utils';
|
|
@@ -23,6 +23,7 @@ import { isInListItem } from '../../../utils';
|
|
|
23
23
|
import { CAPTION_PLACEHOLDER_ID } from '../ui/CaptionPlaceholder';
|
|
24
24
|
import { RawIntlProvider } from 'react-intl-next';
|
|
25
25
|
import { MediaTaskManager } from './mediaTaskManager';
|
|
26
|
+
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
26
27
|
export { stateKey } from './plugin-key';
|
|
27
28
|
export const MEDIA_CONTENT_WRAP_CLASS_NAME = 'media-content-wrap';
|
|
28
29
|
const createDropPlaceholder = (intl, allowDropLine) => {
|
|
@@ -522,7 +523,6 @@ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch,
|
|
|
522
523
|
// we shift it to the media single parent as other code is opinionated about
|
|
523
524
|
// the selection landing there. In particular the caption insertion and selection
|
|
524
525
|
// action.
|
|
525
|
-
|
|
526
526
|
return newState.tr.setSelection(NodeSelection.create(newState.doc, transaction.selection.$from.pos - 1));
|
|
527
527
|
}
|
|
528
528
|
}
|
|
@@ -541,17 +541,34 @@ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch,
|
|
|
541
541
|
},
|
|
542
542
|
props: {
|
|
543
543
|
decorations: state => {
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
544
|
+
// Use this to indicate that the media node is selected
|
|
545
|
+
const mediaNodes = [];
|
|
548
546
|
const {
|
|
549
547
|
schema,
|
|
550
548
|
selection: {
|
|
551
549
|
$anchor
|
|
552
|
-
}
|
|
550
|
+
},
|
|
551
|
+
doc
|
|
553
552
|
} = state;
|
|
554
553
|
|
|
554
|
+
// Find any media nodes in the current selection
|
|
555
|
+
if (state.selection instanceof TextSelection || state.selection instanceof AllSelection || state.selection instanceof NodeSelection || state.selection instanceof CellSelection) {
|
|
556
|
+
doc.nodesBetween(state.selection.from, state.selection.to, (node, pos) => {
|
|
557
|
+
if (node.type === schema.nodes.media) {
|
|
558
|
+
mediaNodes.push(Decoration.node(pos, pos + node.nodeSize, {}, {
|
|
559
|
+
type: 'media',
|
|
560
|
+
selected: true
|
|
561
|
+
}));
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
return true;
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
const pluginState = getMediaPluginState(state);
|
|
568
|
+
if (!pluginState.showDropzone) {
|
|
569
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
570
|
+
}
|
|
571
|
+
|
|
555
572
|
// When a media is already selected
|
|
556
573
|
if (state.selection instanceof NodeSelection) {
|
|
557
574
|
const node = state.selection.node;
|
|
@@ -559,20 +576,20 @@ export const createPlugin = (_schema, options, reactContext, getIntl, dispatch,
|
|
|
559
576
|
const deco = Decoration.node(state.selection.from, state.selection.to, {
|
|
560
577
|
class: 'richMedia-selected'
|
|
561
578
|
});
|
|
562
|
-
return DecorationSet.create(state.doc, [deco]);
|
|
579
|
+
return DecorationSet.create(state.doc, [deco, ...mediaNodes]);
|
|
563
580
|
}
|
|
564
|
-
return;
|
|
581
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
565
582
|
}
|
|
566
583
|
let pos = $anchor.pos;
|
|
567
584
|
if ($anchor.parent.type !== schema.nodes.paragraph && $anchor.parent.type !== schema.nodes.codeBlock) {
|
|
568
585
|
pos = insertPoint(state.doc, pos, schema.nodes.mediaGroup);
|
|
569
586
|
}
|
|
570
587
|
if (pos === null || pos === undefined) {
|
|
571
|
-
return;
|
|
588
|
+
return DecorationSet.create(state.doc, mediaNodes);
|
|
572
589
|
}
|
|
573
590
|
const dropPlaceholders = [Decoration.widget(pos, dropPlaceholder, {
|
|
574
591
|
key: 'drop-placeholder'
|
|
575
|
-
})];
|
|
592
|
+
}), ...mediaNodes];
|
|
576
593
|
return DecorationSet.create(state.doc, dropPlaceholders);
|
|
577
594
|
},
|
|
578
595
|
nodeViews: options.nodeViews,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
2
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
3
3
|
import DecisionItem from '../ui/Decision';
|
|
4
4
|
import { isTypeAheadOpen } from '../../type-ahead/utils';
|
|
5
5
|
class Decision extends ReactNodeView {
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { AnalyticsListener } from '@atlaskit/analytics-next';
|
|
4
4
|
import { SetAttrsStep } from '@atlaskit/adf-schema/steps';
|
|
5
|
-
import
|
|
5
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
6
6
|
import WithPluginState from '../../../ui/WithPluginState';
|
|
7
7
|
import { stateKey as taskPluginKey } from '../pm-plugins/plugin-key';
|
|
8
8
|
import TaskItem from '../ui/Task';
|
|
@@ -3,7 +3,7 @@ import { PluginKey } from 'prosemirror-state';
|
|
|
3
3
|
import { confluenceUnsupportedBlock, confluenceUnsupportedInline, unsupportedBlock, unsupportedInline, unsupportedMark, unsupportedNodeAttribute } from '@atlaskit/adf-schema';
|
|
4
4
|
import { UnsupportedBlock } from '@atlaskit/editor-common/ui';
|
|
5
5
|
import { UnsupportedInlineNodeView } from './unsupported-inline-node-view';
|
|
6
|
-
import
|
|
6
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
7
7
|
import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
|
|
8
8
|
export const pluginKey = new PluginKey('unsupportedContentPlugin');
|
|
9
9
|
const createPlugin = pmPluginFactoryParams => {
|
|
@@ -78,7 +78,6 @@ export const createPMSchemaAndPlugins = (inputPreset = new EditorPresetBuilder()
|
|
|
78
78
|
editorConfig
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
|
-
export { PortalProviderAPI } from './ui/PortalProvider';
|
|
82
81
|
export { EventDispatcher } from './event-dispatcher';
|
|
83
82
|
export { GapCursorSelection, Side as GapCursorSide } from './plugins/selection/gap-cursor/selection';
|
|
84
83
|
export function setTextSelection(view, anchor, head) {
|
package/dist/es2019/version.json
CHANGED
|
@@ -13,7 +13,7 @@ import { createFeatureFlagsFromProps } from '../create-editor/feature-flags-from
|
|
|
13
13
|
import { ContextAdapter } from '../nodeviews/context-adapter';
|
|
14
14
|
import { ACTION, ACTION_SUBJECT } from '@atlaskit/editor-common/analytics';
|
|
15
15
|
import EditorContext from '../ui/EditorContext';
|
|
16
|
-
import { PortalProviderWithThemeProviders, PortalRenderer } from '
|
|
16
|
+
import { PortalProviderWithThemeProviders, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
|
|
17
17
|
import { RenderTracking } from '../utils/performance/components/RenderTracking';
|
|
18
18
|
import { getBaseFontSize } from './utils/getBaseFontSize';
|
|
19
19
|
import useMeasureEditorMountTime from './hooks/useMeasureEditorMountTime';
|
package/dist/esm/index.js
CHANGED
|
@@ -51,7 +51,7 @@ export { getDefaultPresetOptionsFromEditorProps } from './create-editor';
|
|
|
51
51
|
export { default as EditorActions } from './actions';
|
|
52
52
|
// Re-export from provider factory to not cause a breaking change
|
|
53
53
|
|
|
54
|
-
export { PortalProvider, PortalProviderAPI, PortalRenderer } from '
|
|
54
|
+
export { PortalProvider, PortalProviderAPI, PortalRenderer } from '@atlaskit/editor-common/portal-provider';
|
|
55
55
|
export { GapCursorSelection, Side as GapCursorSide } from './plugins/selection/gap-cursor-selection';
|
|
56
56
|
export { selectionPluginKey } from './plugins/mobile-selection';
|
|
57
57
|
export { insertExpand } from './plugins/expand/commands';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { IntlProvider } from 'react-intl-next';
|
|
4
|
-
import { PortalRenderer, PortalProvider } from '
|
|
4
|
+
import { PortalRenderer, PortalProvider } from '@atlaskit/editor-common/portal-provider';
|
|
5
5
|
import { EditorInternal } from './internal/components/EditorInternal';
|
|
6
6
|
import { usePresetContext, PresetProvider } from './internal/context/preset-context';
|
|
7
7
|
import { EditorSharedConfigConsumer, useEditorSharedConfig } from './internal/context/shared-config';
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { SelectionBasedNodeView } from './SelectionBasedNodeView';
|
|
1
|
+
export {};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { annotation } from '@atlaskit/adf-schema';
|
|
3
|
-
import WithPluginState from '../../ui/WithPluginState';
|
|
4
|
-
import { stateKey as reactPluginKey } from '../../plugins/base/pm-plugins/react-nodeview';
|
|
5
3
|
import { keymapPlugin } from './pm-plugins/keymap';
|
|
6
4
|
import { inlineCommentPlugin } from './pm-plugins/inline-comment';
|
|
7
5
|
import { AnnotationUpdateEmitter } from './update-provider';
|
|
8
|
-
import { getPluginState
|
|
6
|
+
import { getPluginState } from './utils';
|
|
9
7
|
import { buildToolbar } from './toolbar';
|
|
10
8
|
import { InlineCommentView } from './ui/InlineCommentView';
|
|
11
|
-
|
|
9
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
|
+
var annotationPlugin = function annotationPlugin(annotationProviders, api) {
|
|
12
11
|
return {
|
|
13
12
|
name: 'annotation',
|
|
14
13
|
marks: function marks() {
|
|
@@ -17,6 +16,12 @@ var annotationPlugin = function annotationPlugin(annotationProviders) {
|
|
|
17
16
|
mark: annotation
|
|
18
17
|
}];
|
|
19
18
|
},
|
|
19
|
+
getSharedState: function getSharedState(editorState) {
|
|
20
|
+
if (!editorState) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
return getPluginState(editorState);
|
|
24
|
+
},
|
|
20
25
|
pmPlugins: function pmPlugins() {
|
|
21
26
|
return [{
|
|
22
27
|
name: 'annotation',
|
|
@@ -62,27 +67,32 @@ var annotationPlugin = function annotationPlugin(annotationProviders) {
|
|
|
62
67
|
if (!annotationProviders) {
|
|
63
68
|
return null;
|
|
64
69
|
}
|
|
65
|
-
return /*#__PURE__*/React.createElement(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
render: function render(_ref3) {
|
|
71
|
-
var inlineCommentState = _ref3.inlineCommentState;
|
|
72
|
-
if (inlineCommentState && !inlineCommentState.isVisible) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
76
|
-
"data-editor-popup": "true"
|
|
77
|
-
}, /*#__PURE__*/React.createElement(InlineCommentView, {
|
|
78
|
-
providers: annotationProviders,
|
|
79
|
-
editorView: editorView,
|
|
80
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
70
|
+
return /*#__PURE__*/React.createElement(AnnotationContentComponent, {
|
|
71
|
+
api: api,
|
|
72
|
+
editorView: editorView,
|
|
73
|
+
annotationProviders: annotationProviders,
|
|
74
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
83
75
|
});
|
|
84
76
|
}
|
|
85
77
|
};
|
|
86
78
|
};
|
|
79
|
+
function AnnotationContentComponent(_ref3) {
|
|
80
|
+
var api = _ref3.api,
|
|
81
|
+
editorView = _ref3.editorView,
|
|
82
|
+
annotationProviders = _ref3.annotationProviders,
|
|
83
|
+
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
|
|
84
|
+
var _useSharedPluginState = useSharedPluginState(api, ['annotation']),
|
|
85
|
+
inlineCommentState = _useSharedPluginState.annotationState;
|
|
86
|
+
if (inlineCommentState && !inlineCommentState.isVisible) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
90
|
+
"data-editor-popup": "true"
|
|
91
|
+
}, /*#__PURE__*/React.createElement(InlineCommentView, {
|
|
92
|
+
providers: annotationProviders,
|
|
93
|
+
editorView: editorView,
|
|
94
|
+
dispatchAnalyticsEvent: dispatchAnalyticsEvent
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
87
97
|
export default annotationPlugin;
|
|
88
98
|
export { AnnotationUpdateEmitter };
|
|
@@ -7,7 +7,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
7
7
|
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; } }
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { AnnotationSharedClassNames } from '@atlaskit/editor-common/styles';
|
|
10
|
-
import
|
|
10
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
11
11
|
export var AnnotationNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
12
12
|
_inherits(AnnotationNodeView, _ReactNodeView);
|
|
13
13
|
var _super = _createSuper(AnnotationNodeView);
|
|
@@ -13,7 +13,6 @@ import contextIdentifierPlugin from './pm-plugins/context-identifier';
|
|
|
13
13
|
import newlinePreserveMarksPlugin from './pm-plugins/newline-preserve-marks';
|
|
14
14
|
import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
|
|
15
15
|
import betterTypeHistoryPlugin from './pm-plugins/better-type-history';
|
|
16
|
-
import { plugin as reactNodeView } from './pm-plugins/react-nodeview';
|
|
17
16
|
import scrollGutter from './pm-plugins/scroll-gutter';
|
|
18
17
|
import { keymap } from '../../utils/keymap';
|
|
19
18
|
import frozenEditor from './pm-plugins/frozen-editor';
|
|
@@ -57,11 +56,6 @@ var basePlugin = function basePlugin(options, api) {
|
|
|
57
56
|
}, {
|
|
58
57
|
name: 'newlinePreserveMarksPlugin',
|
|
59
58
|
plugin: newlinePreserveMarksPlugin
|
|
60
|
-
}, {
|
|
61
|
-
name: 'reactNodeView',
|
|
62
|
-
plugin: function plugin() {
|
|
63
|
-
return reactNodeView;
|
|
64
|
-
}
|
|
65
59
|
}, {
|
|
66
60
|
name: 'frozenEditor',
|
|
67
61
|
plugin: function plugin(_ref3) {
|
|
@@ -14,12 +14,11 @@ var captionPlugin = function captionPlugin(_, api) {
|
|
|
14
14
|
return [{
|
|
15
15
|
name: 'caption',
|
|
16
16
|
plugin: function plugin(_ref) {
|
|
17
|
-
var _api$dependencies$ana;
|
|
18
17
|
var portalProviderAPI = _ref.portalProviderAPI,
|
|
19
18
|
providerFactory = _ref.providerFactory,
|
|
20
19
|
eventDispatcher = _ref.eventDispatcher,
|
|
21
20
|
dispatch = _ref.dispatch;
|
|
22
|
-
return createCaptionPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api
|
|
21
|
+
return createCaptionPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api);
|
|
23
22
|
}
|
|
24
23
|
}, {
|
|
25
24
|
name: 'captionKeymap',
|
|
@@ -9,7 +9,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
9
9
|
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; } }
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { Caption } from '@atlaskit/editor-common/ui';
|
|
12
|
-
import { SelectionBasedNodeView } from '
|
|
12
|
+
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
13
13
|
export var CaptionNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
14
14
|
_inherits(CaptionNodeView, _SelectionBasedNodeVi);
|
|
15
15
|
var _super = _createSuper(CaptionNodeView);
|
|
@@ -65,7 +65,7 @@ export var CaptionNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
65
65
|
}]);
|
|
66
66
|
return CaptionNodeView;
|
|
67
67
|
}(SelectionBasedNodeView);
|
|
68
|
-
export default function captionNodeView(portalProviderAPI, eventDispatcher) {
|
|
68
|
+
export default function captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi) {
|
|
69
69
|
return function (node, view, getPos) {
|
|
70
70
|
var hasIntlContext = true;
|
|
71
71
|
return new CaptionNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {}, undefined, undefined, undefined, hasIntlContext).init();
|
|
@@ -11,7 +11,9 @@ var fireAnalytics = function fireAnalytics(tr, action, analyticsApi) {
|
|
|
11
11
|
actionSubjectId: ACTION_SUBJECT_ID.CAPTION
|
|
12
12
|
})(tr);
|
|
13
13
|
};
|
|
14
|
-
export default (function (portalProviderAPI, eventDispatcher, providerFactory, dispatch,
|
|
14
|
+
export default (function (portalProviderAPI, eventDispatcher, providerFactory, dispatch, pluginInjectionApi) {
|
|
15
|
+
var _pluginInjectionApi$d;
|
|
16
|
+
var analyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions;
|
|
15
17
|
return new SafePlugin({
|
|
16
18
|
appendTransaction: function appendTransaction(transactions, oldState, newState) {
|
|
17
19
|
// only run for transactions that change selection
|
|
@@ -41,7 +43,7 @@ export default (function (portalProviderAPI, eventDispatcher, providerFactory, d
|
|
|
41
43
|
key: pluginKey,
|
|
42
44
|
props: {
|
|
43
45
|
nodeViews: {
|
|
44
|
-
caption: captionNodeView(portalProviderAPI, eventDispatcher)
|
|
46
|
+
caption: captionNodeView(portalProviderAPI, eventDispatcher, pluginInjectionApi)
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
});
|
|
@@ -18,7 +18,7 @@ import rafSchedule from 'raf-schd';
|
|
|
18
18
|
import { Card } from './genericCard';
|
|
19
19
|
import { UnsupportedBlock, MediaSingle as RichMediaWrapper, findOverflowScrollParent } from '@atlaskit/editor-common/ui';
|
|
20
20
|
import { DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
21
|
-
import
|
|
21
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
22
22
|
import { registerCard } from '../pm-plugins/actions';
|
|
23
23
|
import ResizableEmbedCard from '../ui/ResizableEmbedCard';
|
|
24
24
|
import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-common/utils';
|
|
@@ -333,8 +333,8 @@ _defineProperty(EmbedCardComponent, "contextTypes", {
|
|
|
333
333
|
contextAdapter: PropTypes.object
|
|
334
334
|
});
|
|
335
335
|
var WrappedBlockCard = Card(EmbedCardComponent, UnsupportedBlock);
|
|
336
|
-
export var EmbedCard = /*#__PURE__*/function (
|
|
337
|
-
_inherits(EmbedCard,
|
|
336
|
+
export var EmbedCard = /*#__PURE__*/function (_ReactNodeView) {
|
|
337
|
+
_inherits(EmbedCard, _ReactNodeView);
|
|
338
338
|
var _super2 = _createSuper(EmbedCard);
|
|
339
339
|
function EmbedCard() {
|
|
340
340
|
_classCallCheck(this, EmbedCard);
|
|
@@ -384,4 +384,4 @@ export var EmbedCard = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
384
384
|
}
|
|
385
385
|
}]);
|
|
386
386
|
return EmbedCard;
|
|
387
|
-
}(
|
|
387
|
+
}(ReactNodeView);
|
|
@@ -6,7 +6,7 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
|
6
6
|
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); }; }
|
|
7
7
|
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; } }
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import
|
|
9
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
10
10
|
import Extension from '../ui/Extension';
|
|
11
11
|
import ExtensionNodeWrapper from '../ui/Extension/ExtensionNodeWrapper';
|
|
12
12
|
// getInlineNodeViewProducer is a new api to use instead of ReactNodeView
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
2
|
import { PluginKey } from 'prosemirror-state';
|
|
3
3
|
import { confluenceJiraIssue } from '@atlaskit/adf-schema';
|
|
4
|
-
import
|
|
4
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
5
5
|
import ReactJIRAIssueNode from './nodeviews/jira-issue';
|
|
6
6
|
export var pluginKey = new PluginKey('jiraIssuePlugin');
|
|
7
7
|
var createPlugin = function createPlugin(_ref) {
|
|
@@ -87,10 +87,10 @@ var mediaPlugin = function mediaPlugin() {
|
|
|
87
87
|
return createPlugin(schema, {
|
|
88
88
|
providerFactory: providerFactory,
|
|
89
89
|
nodeViews: {
|
|
90
|
-
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options),
|
|
90
|
+
mediaGroup: ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
|
|
91
91
|
mediaSingle: ReactMediaSingleNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent, options, api),
|
|
92
92
|
media: ReactMediaNode(portalProviderAPI, eventDispatcher, providerFactory, options, api),
|
|
93
|
-
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory)
|
|
93
|
+
mediaInline: ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, api)
|
|
94
94
|
},
|
|
95
95
|
errorReporter: errorReporter,
|
|
96
96
|
uploadErrorHandler: options && options.uploadErrorHandler,
|
|
@@ -15,17 +15,15 @@ import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
|
15
15
|
import EditorCloseIcon from '@atlaskit/icon/glyph/editor/close';
|
|
16
16
|
import { Filmstrip } from '@atlaskit/media-filmstrip';
|
|
17
17
|
import React from 'react';
|
|
18
|
-
import ReactNodeView from '
|
|
19
|
-
import { stateKey as reactNodeViewStateKey } from '../../../plugins/base/pm-plugins/react-nodeview';
|
|
20
|
-
import WithPluginState from '../../../ui/WithPluginState';
|
|
18
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
21
19
|
import { setNodeSelection } from '../../../utils';
|
|
22
20
|
import { isNodeSelectedOrInRange, SelectedState } from '../../../utils/nodes';
|
|
23
|
-
import { pluginKey as editorDisabledPluginKey } from '../../editor-disabled';
|
|
24
21
|
import { stateKey as mediaStateKey } from '../pm-plugins/plugin-key';
|
|
25
22
|
import { MediaNodeUpdater } from './mediaNodeUpdater';
|
|
26
23
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
27
24
|
import { injectIntl } from 'react-intl-next';
|
|
28
25
|
import { messages } from './messages';
|
|
26
|
+
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
29
27
|
var isMediaGroupSelectedFromProps = function isMediaGroupSelectedFromProps(props) {
|
|
30
28
|
return isNodeSelectedOrInRange(props.anchorPos, props.headPos, props.getPos(), props.node.nodeSize);
|
|
31
29
|
};
|
|
@@ -251,6 +249,15 @@ var MediaGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
251
249
|
_defineProperty(MediaGroup, "displayName", 'MediaGroup');
|
|
252
250
|
var IntlMediaGroup = injectIntl(MediaGroup);
|
|
253
251
|
export default IntlMediaGroup;
|
|
252
|
+
function MediaGroupNodeViewInternal(_ref2) {
|
|
253
|
+
var renderFn = _ref2.renderFn,
|
|
254
|
+
pluginInjectionApi = _ref2.pluginInjectionApi;
|
|
255
|
+
var _useSharedPluginState = useSharedPluginState(pluginInjectionApi, ['editorDisabled']),
|
|
256
|
+
editorDisabledPlugin = _useSharedPluginState.editorDisabledState;
|
|
257
|
+
return renderFn({
|
|
258
|
+
editorDisabledPlugin: editorDisabledPlugin
|
|
259
|
+
});
|
|
260
|
+
}
|
|
254
261
|
var MediaGroupNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
255
262
|
_inherits(MediaGroupNodeView, _ReactNodeView);
|
|
256
263
|
var _super2 = _createSuper(MediaGroupNodeView);
|
|
@@ -263,16 +270,17 @@ var MediaGroupNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
263
270
|
value: function render(props, forwardRef) {
|
|
264
271
|
var _this3 = this;
|
|
265
272
|
var providerFactory = props.providerFactory,
|
|
266
|
-
mediaOptions = props.mediaOptions
|
|
273
|
+
mediaOptions = props.mediaOptions,
|
|
274
|
+
pluginInjectionApi = props.pluginInjectionApi;
|
|
267
275
|
var getPos = this.getPos;
|
|
268
276
|
return /*#__PURE__*/React.createElement(WithProviders, {
|
|
269
277
|
providers: ['mediaProvider', 'contextIdentifierProvider'],
|
|
270
278
|
providerFactory: providerFactory,
|
|
271
|
-
renderNode: function renderNode(
|
|
272
|
-
var mediaProvider =
|
|
273
|
-
contextIdentifierProvider =
|
|
274
|
-
var renderFn = function renderFn(
|
|
275
|
-
var editorDisabledPlugin =
|
|
279
|
+
renderNode: function renderNode(_ref3) {
|
|
280
|
+
var mediaProvider = _ref3.mediaProvider,
|
|
281
|
+
contextIdentifierProvider = _ref3.contextIdentifierProvider;
|
|
282
|
+
var renderFn = function renderFn(_ref4) {
|
|
283
|
+
var editorDisabledPlugin = _ref4.editorDisabledPlugin;
|
|
276
284
|
if (!mediaProvider) {
|
|
277
285
|
return null;
|
|
278
286
|
}
|
|
@@ -291,13 +299,9 @@ var MediaGroupNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
291
299
|
mediaOptions: mediaOptions
|
|
292
300
|
});
|
|
293
301
|
};
|
|
294
|
-
return /*#__PURE__*/React.createElement(
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
reactNodeViewState: reactNodeViewStateKey,
|
|
298
|
-
editorDisabledPlugin: editorDisabledPluginKey
|
|
299
|
-
},
|
|
300
|
-
render: renderFn
|
|
302
|
+
return /*#__PURE__*/React.createElement(MediaGroupNodeViewInternal, {
|
|
303
|
+
renderFn: renderFn,
|
|
304
|
+
pluginInjectionApi: pluginInjectionApi
|
|
301
305
|
});
|
|
302
306
|
}
|
|
303
307
|
});
|
|
@@ -307,11 +311,13 @@ var MediaGroupNodeView = /*#__PURE__*/function (_ReactNodeView) {
|
|
|
307
311
|
}(ReactNodeView);
|
|
308
312
|
export var ReactMediaGroupNode = function ReactMediaGroupNode(portalProviderAPI, eventDispatcher, providerFactory) {
|
|
309
313
|
var mediaOptions = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
314
|
+
var pluginInjectionApi = arguments.length > 4 ? arguments[4] : undefined;
|
|
310
315
|
return function (node, view, getPos) {
|
|
311
316
|
var hasIntlContext = true;
|
|
312
317
|
return new MediaGroupNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
313
318
|
providerFactory: providerFactory,
|
|
314
|
-
mediaOptions: mediaOptions
|
|
319
|
+
mediaOptions: mediaOptions,
|
|
320
|
+
pluginInjectionApi: pluginInjectionApi
|
|
315
321
|
}, undefined, undefined, undefined, hasIntlContext).init();
|
|
316
322
|
};
|
|
317
323
|
};
|
|
@@ -13,7 +13,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
13
13
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
14
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
15
|
import React, { useEffect, useState } from 'react';
|
|
16
|
-
import { SelectionBasedNodeView } from '
|
|
16
|
+
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
17
17
|
import WithPluginState from '../../../ui/WithPluginState';
|
|
18
18
|
import { MediaInlineCard } from '@atlaskit/media-card';
|
|
19
19
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
@@ -253,7 +253,7 @@ export var MediaInlineNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
253
253
|
}]);
|
|
254
254
|
return MediaInlineNodeView;
|
|
255
255
|
}(SelectionBasedNodeView);
|
|
256
|
-
export var ReactMediaInlineNode = function ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, dispatchAnalyticsEvent) {
|
|
256
|
+
export var ReactMediaInlineNode = function ReactMediaInlineNode(portalProviderAPI, eventDispatcher, providerFactory, pluginInjectionApi, dispatchAnalyticsEvent) {
|
|
257
257
|
return function (node, view, getPos) {
|
|
258
258
|
return new MediaInlineNodeView(node, view, getPos, portalProviderAPI, eventDispatcher, {
|
|
259
259
|
providerFactory: providerFactory,
|
|
@@ -10,9 +10,8 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
10
10
|
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; } }
|
|
11
11
|
import { WithProviders } from '@atlaskit/editor-common/provider-factory';
|
|
12
12
|
import { DEFAULT_IMAGE_HEIGHT, DEFAULT_IMAGE_WIDTH } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { NodeSelection } from 'prosemirror-state';
|
|
14
13
|
import React from 'react';
|
|
15
|
-
import { SelectionBasedNodeView } from '
|
|
14
|
+
import { SelectionBasedNodeView } from '@atlaskit/editor-common/selection-based-node-view';
|
|
16
15
|
import MediaNode from './media';
|
|
17
16
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
18
17
|
import { isMediaBlobUrlFromAttrs } from '../../utils/media-common';
|
|
@@ -26,6 +25,9 @@ var MediaNodeWithProviders = function MediaNodeWithProviders(_ref) {
|
|
|
26
25
|
width: widthState
|
|
27
26
|
});
|
|
28
27
|
};
|
|
28
|
+
function isMediaDecorationSpec(decoration) {
|
|
29
|
+
return decoration.spec.type !== undefined && decoration.spec.selected !== undefined;
|
|
30
|
+
}
|
|
29
31
|
var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
30
32
|
_inherits(MediaNodeView, _SelectionBasedNodeVi);
|
|
31
33
|
var _super = _createSuper(MediaNodeView);
|
|
@@ -36,15 +38,12 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
36
38
|
args[_key] = arguments[_key];
|
|
37
39
|
}
|
|
38
40
|
_this = _super.call.apply(_super, [this].concat(args));
|
|
41
|
+
_defineProperty(_assertThisInitialized(_this), "isSelected", false);
|
|
39
42
|
_defineProperty(_assertThisInitialized(_this), "renderMediaNodeWithState", function (mediaProvider, contextIdentifierProvider) {
|
|
40
43
|
return function (_ref2) {
|
|
41
44
|
var editorWidth = _ref2.width;
|
|
42
45
|
var getPos = _this.getPos;
|
|
43
46
|
var mediaOptions = _this.reactComponentProps.mediaOptions;
|
|
44
|
-
var selection = _this.view.state.selection;
|
|
45
|
-
var isSelected = function isSelected() {
|
|
46
|
-
return _this.isNodeInsideSelection(selection.from, selection.to) || selection instanceof NodeSelection && selection.from === getPos();
|
|
47
|
-
};
|
|
48
47
|
var attrs = _this.getAttrs();
|
|
49
48
|
var url = attrs.type === 'external' ? attrs.url : '';
|
|
50
49
|
var width = attrs.width,
|
|
@@ -72,7 +71,7 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
72
71
|
view: _this.view,
|
|
73
72
|
node: _this.node,
|
|
74
73
|
getPos: getPos,
|
|
75
|
-
selected:
|
|
74
|
+
selected: _this.nodeInsideSelection(),
|
|
76
75
|
originalDimensions: originalDimensions,
|
|
77
76
|
maxDimensions: maxDimensions,
|
|
78
77
|
url: url,
|
|
@@ -106,11 +105,18 @@ var MediaNodeView = /*#__PURE__*/function (_SelectionBasedNodeVi) {
|
|
|
106
105
|
}
|
|
107
106
|
}, {
|
|
108
107
|
key: "viewShouldUpdate",
|
|
109
|
-
value: function viewShouldUpdate(nextNode) {
|
|
108
|
+
value: function viewShouldUpdate(nextNode, decorations) {
|
|
109
|
+
var hasMediaNodeSelectedDecoration = decorations.some(function (decoration) {
|
|
110
|
+
return isMediaDecorationSpec(decoration) && decoration.spec.type === 'media' && decoration.spec.selected;
|
|
111
|
+
});
|
|
112
|
+
if (this.isSelected !== hasMediaNodeSelectedDecoration) {
|
|
113
|
+
this.isSelected = hasMediaNodeSelectedDecoration;
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
110
116
|
if (this.node.attrs !== nextNode.attrs) {
|
|
111
117
|
return true;
|
|
112
118
|
}
|
|
113
|
-
return _get(_getPrototypeOf(MediaNodeView.prototype), "viewShouldUpdate", this).call(this, nextNode);
|
|
119
|
+
return _get(_getPrototypeOf(MediaNodeView.prototype), "viewShouldUpdate", this).call(this, nextNode, decorations);
|
|
114
120
|
}
|
|
115
121
|
}, {
|
|
116
122
|
key: "stopEvent",
|
|
@@ -31,7 +31,7 @@ import { floatingLayouts, isRichMediaInsideOfBlockNode } from '@atlaskit/editor-
|
|
|
31
31
|
import { getAttrsFromUrl } from '@atlaskit/media-client';
|
|
32
32
|
import { isMediaBlobUrlFromAttrs } from '../utils/media-common';
|
|
33
33
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
34
|
-
import ReactNodeView from '
|
|
34
|
+
import ReactNodeView from '@atlaskit/editor-common/react-node-view';
|
|
35
35
|
import CaptionPlaceholder from '../ui/CaptionPlaceholder';
|
|
36
36
|
import { NodeSelection } from 'prosemirror-state';
|
|
37
37
|
import { insertAndSelectCaptionFromMediaSinglePos } from '../commands/captions';
|