@atlaskit/editor-core 185.6.5 → 185.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/cjs/plugins/card/index.js +14 -0
- package/dist/cjs/plugins/card/nodeviews/datasource.js +2 -4
- package/dist/cjs/plugins/card/pm-plugins/main.js +2 -1
- package/dist/cjs/plugins/card/pm-plugins/mountHyperlink.js +46 -0
- package/dist/cjs/plugins/card/toolbar.js +4 -5
- package/dist/cjs/plugins/{hyperlink → card/ui}/HyperlinkToolbarAppearance.js +5 -3
- package/dist/cjs/plugins/card/ui/LinkToolbarAppearance.js +24 -20
- package/dist/cjs/plugins/card/ui/ResizableEmbedCard.js +2 -2
- package/dist/cjs/plugins/card/ui/SmallerEditIcon.js +2 -2
- package/dist/cjs/plugins/card/utils.js +2 -30
- package/dist/cjs/plugins/hyperlink/Toolbar.js +18 -30
- package/dist/cjs/plugins/hyperlink/commands.js +7 -3
- package/dist/cjs/plugins/hyperlink/index.js +9 -2
- package/dist/cjs/plugins/hyperlink/pm-plugins/toolbar-buttons.js +41 -0
- package/dist/cjs/plugins/hyperlink/ui/EditorLinkPicker/index.js +6 -3
- package/dist/cjs/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +8 -4
- package/dist/cjs/plugins/media/index.js +9 -1
- package/dist/cjs/plugins/media/toolbar/index.js +3 -3
- package/dist/cjs/plugins/media/utils/media-common.js +1 -1
- package/dist/cjs/plugins/paste/handlers.js +12 -12
- package/dist/cjs/plugins/paste/index.js +1 -1
- package/dist/cjs/plugins/paste/pm-plugins/analytics.js +12 -8
- package/dist/cjs/plugins/paste/pm-plugins/main.js +18 -17
- package/dist/cjs/plugins/paste/util/index.js +29 -2
- package/dist/cjs/ui/ContentStyles/index.js +2 -4
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/plugins/card/index.js +12 -0
- package/dist/es2019/plugins/card/nodeviews/datasource.js +1 -2
- package/dist/es2019/plugins/card/pm-plugins/main.js +2 -1
- package/dist/es2019/plugins/card/pm-plugins/mountHyperlink.js +36 -0
- package/dist/es2019/plugins/card/toolbar.js +4 -3
- package/dist/es2019/plugins/{hyperlink → card/ui}/HyperlinkToolbarAppearance.js +5 -3
- package/dist/es2019/plugins/card/ui/LinkToolbarAppearance.js +12 -13
- package/dist/es2019/plugins/card/ui/ResizableEmbedCard.js +1 -1
- package/dist/es2019/plugins/card/ui/SmallerEditIcon.js +1 -1
- package/dist/es2019/plugins/card/utils.js +0 -28
- package/dist/es2019/plugins/hyperlink/Toolbar.js +21 -30
- package/dist/es2019/plugins/hyperlink/commands.js +6 -3
- package/dist/es2019/plugins/hyperlink/index.js +9 -2
- package/dist/es2019/plugins/hyperlink/pm-plugins/toolbar-buttons.js +37 -0
- package/dist/es2019/plugins/hyperlink/ui/EditorLinkPicker/index.js +11 -4
- package/dist/es2019/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +13 -5
- package/dist/es2019/plugins/media/index.js +10 -2
- package/dist/es2019/plugins/media/toolbar/index.js +1 -1
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/paste/handlers.js +12 -13
- package/dist/es2019/plugins/paste/index.js +1 -1
- package/dist/es2019/plugins/paste/pm-plugins/analytics.js +24 -12
- package/dist/es2019/plugins/paste/pm-plugins/main.js +11 -10
- package/dist/es2019/plugins/paste/util/index.js +28 -1
- package/dist/es2019/ui/ContentStyles/index.js +1 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/plugins/card/index.js +14 -0
- package/dist/esm/plugins/card/nodeviews/datasource.js +1 -2
- package/dist/esm/plugins/card/pm-plugins/main.js +2 -1
- package/dist/esm/plugins/card/pm-plugins/mountHyperlink.js +38 -0
- package/dist/esm/plugins/card/toolbar.js +4 -3
- package/dist/esm/plugins/{hyperlink → card/ui}/HyperlinkToolbarAppearance.js +5 -3
- package/dist/esm/plugins/card/ui/LinkToolbarAppearance.js +14 -13
- package/dist/esm/plugins/card/ui/ResizableEmbedCard.js +1 -1
- package/dist/esm/plugins/card/ui/SmallerEditIcon.js +1 -1
- package/dist/esm/plugins/card/utils.js +0 -27
- package/dist/esm/plugins/hyperlink/Toolbar.js +19 -30
- package/dist/esm/plugins/hyperlink/commands.js +6 -3
- package/dist/esm/plugins/hyperlink/index.js +9 -2
- package/dist/esm/plugins/hyperlink/pm-plugins/toolbar-buttons.js +32 -0
- package/dist/esm/plugins/hyperlink/ui/EditorLinkPicker/index.js +7 -4
- package/dist/esm/plugins/hyperlink/ui/HyperlinkAddToolbar/HyperlinkAddToolbar.js +9 -5
- package/dist/esm/plugins/media/index.js +10 -2
- package/dist/esm/plugins/media/toolbar/index.js +1 -1
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/paste/handlers.js +12 -13
- package/dist/esm/plugins/paste/index.js +1 -1
- package/dist/esm/plugins/paste/pm-plugins/analytics.js +12 -8
- package/dist/esm/plugins/paste/pm-plugins/main.js +11 -10
- package/dist/esm/plugins/paste/util/index.js +27 -1
- package/dist/esm/ui/ContentStyles/index.js +1 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/labs/next/presets/cxhtml.d.ts +6 -0
- package/dist/types/labs/next/presets/default.d.ts +12 -0
- package/dist/types/labs/next/presets/mobile.d.ts +6 -0
- package/dist/types/plugins/card/index.d.ts +5 -1
- package/dist/types/plugins/card/nodeviews/datasource.d.ts +0 -1
- package/dist/types/plugins/card/pm-plugins/doc.d.ts +2 -1
- package/dist/types/plugins/card/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types/plugins/card/pm-plugins/util/state.d.ts +1 -1
- package/dist/types/plugins/card/types.d.ts +2 -3
- package/dist/types/plugins/{hyperlink → card/ui}/HyperlinkToolbarAppearance.d.ts +2 -0
- package/dist/types/plugins/card/ui/LinkToolbarAppearance.d.ts +7 -5
- package/dist/types/plugins/card/utils.d.ts +1 -3
- package/dist/types/plugins/hyperlink/Toolbar.d.ts +3 -2
- package/dist/types/plugins/hyperlink/commands.d.ts +2 -0
- package/dist/types/plugins/hyperlink/index.d.ts +11 -0
- package/dist/types/plugins/hyperlink/pm-plugins/toolbar-buttons.d.ts +19 -0
- package/dist/types/plugins/paste/handlers.d.ts +6 -5
- package/dist/types/plugins/paste/index.d.ts +6 -2
- package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +6 -5
- package/dist/types/plugins/paste/pm-plugins/main.d.ts +3 -2
- package/dist/types/plugins/paste/util/index.d.ts +2 -0
- package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +6 -0
- package/dist/types-ts4.5/labs/next/presets/default.d.ts +12 -0
- package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +6 -0
- package/dist/types-ts4.5/plugins/card/index.d.ts +5 -1
- package/dist/types-ts4.5/plugins/card/nodeviews/datasource.d.ts +0 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/doc.d.ts +2 -1
- package/dist/types-ts4.5/plugins/card/pm-plugins/mountHyperlink.d.ts +5 -0
- package/dist/types-ts4.5/plugins/card/pm-plugins/util/state.d.ts +1 -1
- package/dist/types-ts4.5/plugins/card/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/{hyperlink → card/ui}/HyperlinkToolbarAppearance.d.ts +2 -0
- package/dist/types-ts4.5/plugins/card/ui/LinkToolbarAppearance.d.ts +7 -5
- package/dist/types-ts4.5/plugins/card/utils.d.ts +1 -3
- package/dist/types-ts4.5/plugins/hyperlink/Toolbar.d.ts +3 -2
- package/dist/types-ts4.5/plugins/hyperlink/commands.d.ts +2 -0
- package/dist/types-ts4.5/plugins/hyperlink/index.d.ts +11 -0
- package/dist/types-ts4.5/plugins/hyperlink/pm-plugins/toolbar-buttons.d.ts +19 -0
- package/dist/types-ts4.5/plugins/paste/handlers.d.ts +6 -5
- package/dist/types-ts4.5/plugins/paste/index.d.ts +4 -2
- package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +6 -5
- package/dist/types-ts4.5/plugins/paste/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/plugins/paste/util/index.d.ts +2 -0
- package/package.json +12 -9
- package/dist/cjs/plugins/card/messages.js +0 -90
- package/dist/cjs/plugins/card/styles.js +0 -18
- package/dist/cjs/plugins/card/ui/LinkToolbarButtonGroup.js +0 -63
- package/dist/cjs/plugins/card/ui/assets/card.js +0 -30
- package/dist/cjs/plugins/card/ui/assets/embed.js +0 -30
- package/dist/cjs/plugins/card/ui/assets/inline.js +0 -30
- package/dist/cjs/plugins/card/ui/assets/url.js +0 -32
- package/dist/cjs/plugins/card/ui/link-toolbar-button-group-options.js +0 -52
- package/dist/cjs/plugins/card/ui/styled.js +0 -16
- package/dist/cjs/plugins/card/ui/types.js +0 -5
- package/dist/es2019/plugins/card/messages.js +0 -83
- package/dist/es2019/plugins/card/styles.js +0 -132
- package/dist/es2019/plugins/card/ui/LinkToolbarButtonGroup.js +0 -61
- package/dist/es2019/plugins/card/ui/assets/card.js +0 -22
- package/dist/es2019/plugins/card/ui/assets/embed.js +0 -22
- package/dist/es2019/plugins/card/ui/assets/inline.js +0 -22
- package/dist/es2019/plugins/card/ui/assets/url.js +0 -24
- package/dist/es2019/plugins/card/ui/link-toolbar-button-group-options.js +0 -45
- package/dist/es2019/plugins/card/ui/styled.js +0 -27
- package/dist/es2019/plugins/card/ui/types.js +0 -1
- package/dist/esm/plugins/card/messages.js +0 -83
- package/dist/esm/plugins/card/styles.js +0 -10
- package/dist/esm/plugins/card/ui/LinkToolbarButtonGroup.js +0 -56
- package/dist/esm/plugins/card/ui/assets/card.js +0 -22
- package/dist/esm/plugins/card/ui/assets/embed.js +0 -22
- package/dist/esm/plugins/card/ui/assets/inline.js +0 -22
- package/dist/esm/plugins/card/ui/assets/url.js +0 -24
- package/dist/esm/plugins/card/ui/link-toolbar-button-group-options.js +0 -45
- package/dist/esm/plugins/card/ui/styled.js +0 -6
- package/dist/esm/plugins/card/ui/types.js +0 -1
- package/dist/types/plugins/card/messages.d.ts +0 -82
- package/dist/types/plugins/card/styles.d.ts +0 -2
- package/dist/types/plugins/card/ui/LinkToolbarButtonGroup.d.ts +0 -16
- package/dist/types/plugins/card/ui/assets/card.d.ts +0 -3
- package/dist/types/plugins/card/ui/assets/embed.d.ts +0 -3
- package/dist/types/plugins/card/ui/assets/inline.d.ts +0 -3
- package/dist/types/plugins/card/ui/assets/url.d.ts +0 -3
- package/dist/types/plugins/card/ui/link-toolbar-button-group-options.d.ts +0 -5
- package/dist/types/plugins/card/ui/styled.d.ts +0 -3
- package/dist/types/plugins/card/ui/types.d.ts +0 -12
- package/dist/types-ts4.5/plugins/card/messages.d.ts +0 -82
- package/dist/types-ts4.5/plugins/card/styles.d.ts +0 -2
- package/dist/types-ts4.5/plugins/card/ui/LinkToolbarButtonGroup.d.ts +0 -16
- package/dist/types-ts4.5/plugins/card/ui/assets/card.d.ts +0 -3
- package/dist/types-ts4.5/plugins/card/ui/assets/embed.d.ts +0 -3
- package/dist/types-ts4.5/plugins/card/ui/assets/inline.d.ts +0 -3
- package/dist/types-ts4.5/plugins/card/ui/assets/url.d.ts +0 -3
- package/dist/types-ts4.5/plugins/card/ui/link-toolbar-button-group-options.d.ts +0 -5
- package/dist/types-ts4.5/plugins/card/ui/styled.d.ts +0 -3
- package/dist/types-ts4.5/plugins/card/ui/types.d.ts +0 -12
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { HyperlinkToolbarAppearance } from '../ui/HyperlinkToolbarAppearance';
|
|
4
|
+
export const mountHyperlinkPlugin = (pluginInjectionApi, options) => {
|
|
5
|
+
return new SafePlugin({
|
|
6
|
+
view(editorView) {
|
|
7
|
+
requestAnimationFrame(() => {
|
|
8
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
9
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.hyperlink) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.actions) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.prependToolbarButtons({
|
|
10
|
+
items: (state, intl, providerFactory, link) => [{
|
|
11
|
+
type: 'custom',
|
|
12
|
+
fallback: [],
|
|
13
|
+
render: editorView => {
|
|
14
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
15
|
+
return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearance, {
|
|
16
|
+
key: "link-appearance",
|
|
17
|
+
url: link,
|
|
18
|
+
intl: intl,
|
|
19
|
+
editorView: editorView,
|
|
20
|
+
editorState: state,
|
|
21
|
+
cardOptions: options,
|
|
22
|
+
providerFactory: providerFactory,
|
|
23
|
+
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
24
|
+
editorAnalyticsApi: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : _pluginInjectionApi$d3.actions,
|
|
25
|
+
cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.actions
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}],
|
|
29
|
+
onEscapeCallback: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.card.actions.hideLinkToolbar,
|
|
30
|
+
view: editorView
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return {};
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
};
|
|
@@ -15,8 +15,8 @@ import { editDatasource, buildEditLinkToolbar, editLink, editLinkToolbarConfig,
|
|
|
15
15
|
import { displayInfoForCard, findCardInfo, titleUrlPairFromNode, appearanceForNodeType } from './utils';
|
|
16
16
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
17
17
|
import { LinkToolbarAppearance } from './ui/LinkToolbarAppearance';
|
|
18
|
-
import { messages } from '
|
|
19
|
-
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from '
|
|
18
|
+
import { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
19
|
+
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME } from '@atlaskit/editor-common/styles';
|
|
20
20
|
import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, buildOpenedSettingsPayload, buildVisitedLinkPayload } from '@atlaskit/editor-common/analytics';
|
|
21
21
|
import { SmallerEditIcon } from './ui/SmallerEditIcon';
|
|
22
22
|
export const removeCard = editorAnalyticsApi => commandWithMetadata((state, dispatch) => {
|
|
@@ -286,7 +286,8 @@ const generateToolbarItems = (state, featureFlags, intl, providerFactory, cardOp
|
|
|
286
286
|
allowEmbeds: allowEmbeds,
|
|
287
287
|
allowBlockCards: allowBlockCards,
|
|
288
288
|
platform: platform,
|
|
289
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
289
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
290
|
+
cardActions: pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.card.actions
|
|
290
291
|
})
|
|
291
292
|
}, {
|
|
292
293
|
type: 'separator'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { Component } from 'react';
|
|
4
|
-
import { LinkToolbarAppearance } from '
|
|
4
|
+
import { LinkToolbarAppearance } from './LinkToolbarAppearance';
|
|
5
5
|
export class HyperlinkToolbarAppearance extends Component {
|
|
6
6
|
constructor(...args) {
|
|
7
7
|
super(...args);
|
|
@@ -61,7 +61,8 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
61
61
|
editorState,
|
|
62
62
|
cardOptions,
|
|
63
63
|
platform,
|
|
64
|
-
editorAnalyticsApi
|
|
64
|
+
editorAnalyticsApi,
|
|
65
|
+
cardActions
|
|
65
66
|
} = this.props;
|
|
66
67
|
const {
|
|
67
68
|
supportedUrlsMap
|
|
@@ -78,7 +79,8 @@ export class HyperlinkToolbarAppearance extends Component {
|
|
|
78
79
|
allowEmbeds: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowEmbeds,
|
|
79
80
|
allowBlockCards: cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards,
|
|
80
81
|
platform: platform,
|
|
81
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
82
|
+
editorAnalyticsApi: editorAnalyticsApi,
|
|
83
|
+
cardActions: cardActions
|
|
82
84
|
});
|
|
83
85
|
}
|
|
84
86
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { Fragment } from 'prosemirror-model';
|
|
5
|
-
import
|
|
6
|
-
import nodeNames from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { ACTION, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
6
|
+
import nodeNames, { cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { isSupportedInParent } from '@atlaskit/editor-common/utils';
|
|
8
|
-
import {
|
|
9
|
-
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
10
|
-
import { changeSelectedCardToLink, setSelectedCardAppearance } from '../pm-plugins/doc';
|
|
11
|
-
import { getButtonGroupOption } from './link-toolbar-button-group-options';
|
|
12
|
-
import { LinkToolbarButtonGroup } from './LinkToolbarButtonGroup';
|
|
8
|
+
import { getButtonGroupOption, LinkToolbarButtonGroup, commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
13
9
|
export class LinkToolbarAppearance extends React.Component {
|
|
14
10
|
constructor(...args) {
|
|
15
11
|
super(...args);
|
|
16
12
|
_defineProperty(this, "renderDropdown", (view, cardContext) => {
|
|
13
|
+
var _cardActions$setSelec, _cardActions$setSelec2, _cardActions$changeSe, _cardActions$setSelec3;
|
|
17
14
|
const {
|
|
18
15
|
url,
|
|
19
16
|
intl,
|
|
@@ -22,9 +19,11 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
22
19
|
allowEmbeds,
|
|
23
20
|
allowBlockCards = true,
|
|
24
21
|
platform,
|
|
25
|
-
editorAnalyticsApi
|
|
22
|
+
editorAnalyticsApi,
|
|
23
|
+
cardActions
|
|
26
24
|
} = this.props;
|
|
27
25
|
const preview = allowEmbeds && cardContext && url && cardContext.extractors.getPreview(url, platform);
|
|
26
|
+
const defaultCommand = () => false;
|
|
28
27
|
if (url) {
|
|
29
28
|
var _cardContext$store, _urlState$error;
|
|
30
29
|
const urlState = cardContext === null || cardContext === void 0 ? void 0 : (_cardContext$store = cardContext.store) === null || _cardContext$store === void 0 ? void 0 : _cardContext$store.getState()[url];
|
|
@@ -37,7 +36,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
37
36
|
const embedOption = allowEmbeds && preview && {
|
|
38
37
|
appearance: 'embed',
|
|
39
38
|
title: intl.formatMessage(messages.embed),
|
|
40
|
-
onClick: setSelectedCardAppearance('embed', editorAnalyticsApi),
|
|
39
|
+
onClick: (_cardActions$setSelec = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('embed', editorAnalyticsApi)) !== null && _cardActions$setSelec !== void 0 ? _cardActions$setSelec : defaultCommand,
|
|
41
40
|
selected: currentAppearance === 'embed',
|
|
42
41
|
hidden: false,
|
|
43
42
|
testId: 'embed-appearance',
|
|
@@ -47,7 +46,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
47
46
|
const blockCardOption = allowBlockCards && {
|
|
48
47
|
appearance: 'block',
|
|
49
48
|
title: intl.formatMessage(messages.block),
|
|
50
|
-
onClick: setSelectedCardAppearance('block', editorAnalyticsApi),
|
|
49
|
+
onClick: (_cardActions$setSelec2 = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('block', editorAnalyticsApi)) !== null && _cardActions$setSelec2 !== void 0 ? _cardActions$setSelec2 : defaultCommand,
|
|
51
50
|
selected: currentAppearance === 'block',
|
|
52
51
|
testId: 'block-appearance',
|
|
53
52
|
disabled: !isBlockCardLinkSupportedInParent,
|
|
@@ -55,7 +54,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
55
54
|
};
|
|
56
55
|
const options = [{
|
|
57
56
|
title: intl.formatMessage(messages.url),
|
|
58
|
-
onClick: commandWithMetadata(changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi), {
|
|
57
|
+
onClick: commandWithMetadata((_cardActions$changeSe = cardActions === null || cardActions === void 0 ? void 0 : cardActions.changeSelectedCardToLink(url, url, true, undefined, undefined, editorAnalyticsApi)) !== null && _cardActions$changeSe !== void 0 ? _cardActions$changeSe : defaultCommand, {
|
|
59
58
|
action: ACTION.CHANGED_TYPE
|
|
60
59
|
}),
|
|
61
60
|
selected: !currentAppearance,
|
|
@@ -63,7 +62,7 @@ export class LinkToolbarAppearance extends React.Component {
|
|
|
63
62
|
}, {
|
|
64
63
|
appearance: 'inline',
|
|
65
64
|
title: intl.formatMessage(messages.inline),
|
|
66
|
-
onClick: setSelectedCardAppearance('inline', editorAnalyticsApi),
|
|
65
|
+
onClick: (_cardActions$setSelec3 = cardActions === null || cardActions === void 0 ? void 0 : cardActions.setSelectedCardAppearance('inline', editorAnalyticsApi)) !== null && _cardActions$setSelec3 !== void 0 ? _cardActions$setSelec3 : defaultCommand,
|
|
67
66
|
selected: currentAppearance === 'inline',
|
|
68
67
|
testId: 'inline-appearance'
|
|
69
68
|
}];
|
|
@@ -8,7 +8,7 @@ import { calcColumnsFromPx, calcPctFromPx, calcPxFromColumns, wrappedLayouts } f
|
|
|
8
8
|
import { akEditorMediaResizeHandlerPaddingWide, akEditorBreakoutPadding, akEditorWideLayoutWidth, breakoutWideScaleRatio, DEFAULT_EMBED_CARD_HEIGHT, DEFAULT_EMBED_CARD_WIDTH } from '@atlaskit/editor-shared-styles';
|
|
9
9
|
import { embedHeaderHeight } from '@atlaskit/smart-card';
|
|
10
10
|
import { wrapperStyle, Resizer, handleSides, imageAlignmentMap, snapTo, calcMediaPxWidth } from '@atlaskit/editor-common/ui';
|
|
11
|
-
import { embedSpacingStyles } from '
|
|
11
|
+
import { embedSpacingStyles } from '@atlaskit/editor-common/styles';
|
|
12
12
|
export default class ResizableEmbedCard extends React.Component {
|
|
13
13
|
constructor(...args) {
|
|
14
14
|
super(...args);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { jsx } from '@emotion/react';
|
|
3
3
|
import EditIcon from '@atlaskit/icon/glyph/edit';
|
|
4
|
-
import { editIconStyles } from '
|
|
4
|
+
import { editIconStyles } from '@atlaskit/editor-common/styles';
|
|
5
5
|
export const SmallerEditIcon = () => {
|
|
6
6
|
return jsx("div", {
|
|
7
7
|
css: editIconStyles
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { NodeSelection } from 'prosemirror-state';
|
|
2
|
-
import { Slice, Fragment } from 'prosemirror-model';
|
|
3
2
|
import { pluginKey } from './pm-plugins/plugin-key';
|
|
4
|
-
import { isSupportedInParent, mapChildren } from '@atlaskit/editor-common/utils';
|
|
5
3
|
export const appearanceForNodeType = spec => {
|
|
6
4
|
if (spec.name === 'inlineCard') {
|
|
7
5
|
return 'inline';
|
|
@@ -42,30 +40,4 @@ export const displayInfoForCard = (node, info) => mergeCardInfo(titleUrlPairFrom
|
|
|
42
40
|
export const findCardInfo = state => {
|
|
43
41
|
const pluginState = pluginKey.getState(state);
|
|
44
42
|
return pluginState.cards.find(cardInfo => cardInfo.pos === state.selection.from);
|
|
45
|
-
};
|
|
46
|
-
export const transformUnsupportedBlockCardToInline = (slice, state, cardOptions) => {
|
|
47
|
-
const {
|
|
48
|
-
blockCard,
|
|
49
|
-
inlineCard
|
|
50
|
-
} = state.schema.nodes;
|
|
51
|
-
const children = [];
|
|
52
|
-
mapChildren(slice.content, (node, i, frag) => {
|
|
53
|
-
var _cardOptions$allowBlo;
|
|
54
|
-
if (node.type === blockCard && !isBlockCardSupported(state, frag, (_cardOptions$allowBlo = cardOptions === null || cardOptions === void 0 ? void 0 : cardOptions.allowBlockCards) !== null && _cardOptions$allowBlo !== void 0 ? _cardOptions$allowBlo : false)) {
|
|
55
|
-
children.push(inlineCard.createChecked(node.attrs, node.content, node.marks));
|
|
56
|
-
} else {
|
|
57
|
-
children.push(node);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Function to determine if a block card is supported by the editor
|
|
64
|
-
* @param state
|
|
65
|
-
* @param frag
|
|
66
|
-
* @param allowBlockCards
|
|
67
|
-
* @returns
|
|
68
|
-
*/
|
|
69
|
-
const isBlockCardSupported = (state, frag, allowBlockCards) => {
|
|
70
|
-
return allowBlockCards && isSupportedInParent(state, frag);
|
|
71
43
|
};
|
|
@@ -10,24 +10,28 @@ import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
|
10
10
|
import { linkToolbarMessages as linkToolbarCommonMessages, linkMessages } from '../../messages';
|
|
11
11
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
12
12
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
13
|
-
import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
|
|
14
13
|
import { ACTION_SUBJECT_ID, ACTION, INPUT_METHOD, buildVisitedLinkPayload, buildOpenedSettingsPayload } from '@atlaskit/editor-common/analytics';
|
|
15
|
-
import {
|
|
14
|
+
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
15
|
+
|
|
16
16
|
/* type guard for edit links */
|
|
17
17
|
function isEditLink(linkMark) {
|
|
18
18
|
return linkMark.pos !== undefined;
|
|
19
19
|
}
|
|
20
|
-
const dispatchAnalytics = (dispatch, state, analyticsBuilder) => {
|
|
20
|
+
const dispatchAnalytics = (dispatch, state, analyticsBuilder, editorAnalyticsApi) => {
|
|
21
21
|
if (dispatch) {
|
|
22
|
-
|
|
22
|
+
const {
|
|
23
|
+
tr
|
|
24
|
+
} = state;
|
|
25
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(analyticsBuilder(ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
26
|
+
dispatch(tr);
|
|
23
27
|
}
|
|
24
28
|
};
|
|
25
|
-
const visitHyperlink =
|
|
26
|
-
dispatchAnalytics(dispatch, state, buildVisitedLinkPayload);
|
|
29
|
+
const visitHyperlink = editorAnalyticsApi => (state, dispatch) => {
|
|
30
|
+
dispatchAnalytics(dispatch, state, buildVisitedLinkPayload, editorAnalyticsApi);
|
|
27
31
|
return true;
|
|
28
32
|
};
|
|
29
|
-
const openLinkSettings =
|
|
30
|
-
dispatchAnalytics(dispatch, state, buildOpenedSettingsPayload);
|
|
33
|
+
const openLinkSettings = editorAnalyticsApi => (state, dispatch) => {
|
|
34
|
+
dispatchAnalytics(dispatch, state, buildOpenedSettingsPayload, editorAnalyticsApi);
|
|
31
35
|
return true;
|
|
32
36
|
};
|
|
33
37
|
function getLinkText(activeLinkMark, state) {
|
|
@@ -42,7 +46,7 @@ function getLinkText(activeLinkMark, state) {
|
|
|
42
46
|
}
|
|
43
47
|
return activeLinkMark.node.text;
|
|
44
48
|
}
|
|
45
|
-
const getSettingsButtonGroup = (state, intl, featureFlags) => {
|
|
49
|
+
const getSettingsButtonGroup = (state, intl, featureFlags, editorAnalyticsApi) => {
|
|
46
50
|
const {
|
|
47
51
|
floatingToolbarLinkSettingsButton
|
|
48
52
|
} = featureFlags;
|
|
@@ -53,16 +57,18 @@ const getSettingsButtonGroup = (state, intl, featureFlags) => {
|
|
|
53
57
|
type: 'button',
|
|
54
58
|
icon: CogIcon,
|
|
55
59
|
title: intl.formatMessage(linkToolbarCommonMessages.settingsLink),
|
|
56
|
-
onClick: openLinkSettings(),
|
|
60
|
+
onClick: openLinkSettings(editorAnalyticsApi),
|
|
57
61
|
href: 'https://id.atlassian.com/manage-profile/link-preferences',
|
|
58
62
|
target: '_blank'
|
|
59
63
|
}] : [];
|
|
60
64
|
};
|
|
61
|
-
export const getToolbarConfig = (options, featureFlags,
|
|
65
|
+
export const getToolbarConfig = (options, featureFlags, pluginInjectionApi) => (state, intl, providerFactory) => {
|
|
66
|
+
var _pluginInjectionApi$d;
|
|
62
67
|
const {
|
|
63
68
|
formatMessage
|
|
64
69
|
} = intl;
|
|
65
70
|
const linkState = stateKey.getState(state);
|
|
71
|
+
const editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions;
|
|
66
72
|
|
|
67
73
|
/**
|
|
68
74
|
* Enable focus trap only if feature flag is enabled AND for the new version of the picker
|
|
@@ -87,6 +93,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
|
|
|
87
93
|
switch (activeLinkMark.type) {
|
|
88
94
|
case 'EDIT':
|
|
89
95
|
{
|
|
96
|
+
var _toolbarKey$getState$, _toolbarKey$getState;
|
|
90
97
|
const {
|
|
91
98
|
pos,
|
|
92
99
|
node
|
|
@@ -109,23 +116,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
|
|
|
109
116
|
...hyperLinkToolbar,
|
|
110
117
|
height: 32,
|
|
111
118
|
width: 250,
|
|
112
|
-
items: [{
|
|
113
|
-
type: 'custom',
|
|
114
|
-
fallback: [],
|
|
115
|
-
render: editorView => {
|
|
116
|
-
return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearance, {
|
|
117
|
-
key: "link-appearance",
|
|
118
|
-
url: link,
|
|
119
|
-
intl: intl,
|
|
120
|
-
editorView: editorView,
|
|
121
|
-
editorState: state,
|
|
122
|
-
cardOptions: options === null || options === void 0 ? void 0 : options.cardOptions,
|
|
123
|
-
providerFactory: providerFactory,
|
|
124
|
-
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
125
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
}, {
|
|
119
|
+
items: [...((_toolbarKey$getState$ = (_toolbarKey$getState = toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.items(state, intl, providerFactory, link)) !== null && _toolbarKey$getState$ !== void 0 ? _toolbarKey$getState$ : []), {
|
|
129
120
|
id: 'editor.link.edit',
|
|
130
121
|
type: 'button',
|
|
131
122
|
onClick: editInsertedLink(),
|
|
@@ -141,7 +132,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
|
|
|
141
132
|
disabled: !isValidUrl,
|
|
142
133
|
target: '_blank',
|
|
143
134
|
href: isValidUrl ? link : undefined,
|
|
144
|
-
onClick: visitHyperlink(),
|
|
135
|
+
onClick: visitHyperlink(editorAnalyticsApi),
|
|
145
136
|
selected: false,
|
|
146
137
|
title: labelOpenLink,
|
|
147
138
|
icon: OpenIcon,
|
|
@@ -169,7 +160,7 @@ export const getToolbarConfig = (options, featureFlags, editorAnalyticsApi) => (
|
|
|
169
160
|
formatMessage: formatMessage,
|
|
170
161
|
markType: state.schema.marks.link
|
|
171
162
|
}]
|
|
172
|
-
}, ...getSettingsButtonGroup(state, intl, featureFlags)],
|
|
163
|
+
}, ...getSettingsButtonGroup(state, intl, featureFlags, editorAnalyticsApi)],
|
|
173
164
|
scrollable: true
|
|
174
165
|
};
|
|
175
166
|
}
|
|
@@ -189,10 +189,13 @@ export function showLinkToolbar(inputMethod = INPUT_METHOD.TOOLBAR) {
|
|
|
189
189
|
export function hideLinkToolbar() {
|
|
190
190
|
return function (state, dispatch) {
|
|
191
191
|
if (dispatch) {
|
|
192
|
-
dispatch(state.tr
|
|
193
|
-
type: LinkAction.HIDE_TOOLBAR
|
|
194
|
-
}));
|
|
192
|
+
dispatch(hideLinkToolbarSetMeta(state.tr));
|
|
195
193
|
}
|
|
196
194
|
return true;
|
|
197
195
|
};
|
|
196
|
+
}
|
|
197
|
+
export function hideLinkToolbarSetMeta(tr) {
|
|
198
|
+
return tr.setMeta(stateKey, {
|
|
199
|
+
type: LinkAction.HIDE_TOOLBAR
|
|
200
|
+
});
|
|
198
201
|
}
|
|
@@ -4,13 +4,14 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
|
4
4
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
5
5
|
import { plugin, stateKey, LinkAction } from './pm-plugins/main';
|
|
6
6
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
7
|
+
import { toolbarButtonsPlugin, prependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
7
8
|
import { ACTION, ACTION_SUBJECT, INPUT_METHOD, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
8
9
|
import { getToolbarConfig } from './Toolbar';
|
|
9
10
|
import { tooltip, addLink } from '../../keymaps';
|
|
10
11
|
import { IconLink } from '../quick-insert/assets';
|
|
11
12
|
import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
12
13
|
const hyperlinkPlugin = (options = {}, api) => {
|
|
13
|
-
var _api$dependencies, _api$dependencies$fea
|
|
14
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
14
15
|
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()) || {};
|
|
15
16
|
return {
|
|
16
17
|
name: 'hyperlink',
|
|
@@ -20,6 +21,9 @@ const hyperlinkPlugin = (options = {}, api) => {
|
|
|
20
21
|
mark: link
|
|
21
22
|
}];
|
|
22
23
|
},
|
|
24
|
+
actions: {
|
|
25
|
+
prependToolbarButtons
|
|
26
|
+
},
|
|
23
27
|
pmPlugins() {
|
|
24
28
|
var _options$cardOptions;
|
|
25
29
|
// Skip analytics if card provider is available, as they will be
|
|
@@ -42,6 +46,9 @@ const hyperlinkPlugin = (options = {}, api) => {
|
|
|
42
46
|
}, {
|
|
43
47
|
name: 'hyperlinkKeymap',
|
|
44
48
|
plugin: () => createKeymapPlugin(skipAnalytics)
|
|
49
|
+
}, {
|
|
50
|
+
name: 'hyperlinkToolbarButtons',
|
|
51
|
+
plugin: toolbarButtonsPlugin
|
|
45
52
|
}];
|
|
46
53
|
},
|
|
47
54
|
pluginsOptions: {
|
|
@@ -74,7 +81,7 @@ const hyperlinkPlugin = (options = {}, api) => {
|
|
|
74
81
|
return analyticsAttached !== false ? tr : false;
|
|
75
82
|
}
|
|
76
83
|
}],
|
|
77
|
-
floatingToolbar: getToolbarConfig(options, featureFlags, api
|
|
84
|
+
floatingToolbar: getToolbarConfig(options, featureFlags, api)
|
|
78
85
|
}
|
|
79
86
|
};
|
|
80
87
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
export const toolbarKey = new PluginKey('hyperlinkToolbarItems');
|
|
4
|
+
export const prependToolbarButtons = ({
|
|
5
|
+
items,
|
|
6
|
+
onEscapeCallback,
|
|
7
|
+
view
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
state: {
|
|
11
|
+
tr
|
|
12
|
+
},
|
|
13
|
+
dispatch
|
|
14
|
+
} = view;
|
|
15
|
+
tr.setMeta(toolbarKey, {
|
|
16
|
+
items,
|
|
17
|
+
onEscapeCallback
|
|
18
|
+
});
|
|
19
|
+
dispatch(tr);
|
|
20
|
+
};
|
|
21
|
+
export const toolbarButtonsPlugin = () => {
|
|
22
|
+
return new SafePlugin({
|
|
23
|
+
key: toolbarKey,
|
|
24
|
+
state: {
|
|
25
|
+
init: (_, state) => {
|
|
26
|
+
return undefined;
|
|
27
|
+
},
|
|
28
|
+
apply: (tr, pluginState) => {
|
|
29
|
+
const metaState = tr.getMeta(toolbarKey);
|
|
30
|
+
if (metaState) {
|
|
31
|
+
return metaState;
|
|
32
|
+
}
|
|
33
|
+
return pluginState;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
3
3
|
import { LinkPicker } from '@atlaskit/link-picker';
|
|
4
|
-
import { hideLinkToolbar
|
|
5
|
-
import {
|
|
4
|
+
import { hideLinkToolbarSetMeta, hideLinkToolbar } from '../../commands';
|
|
5
|
+
import { toolbarKey } from '../../pm-plugins/toolbar-buttons';
|
|
6
6
|
import { useEscapeClickaway } from './useEscapeClickaway';
|
|
7
7
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
8
8
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
@@ -39,8 +39,15 @@ export const EditorLinkPicker = ({
|
|
|
39
39
|
return (_onCloseRef$current = onCloseRef.current) === null || _onCloseRef$current === void 0 ? void 0 : _onCloseRef$current.call(onCloseRef);
|
|
40
40
|
}, []);
|
|
41
41
|
const onEscape = useCallback(() => {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
var _toolbarKey$getState, _toolbarKey$getState$;
|
|
43
|
+
const {
|
|
44
|
+
state: {
|
|
45
|
+
tr
|
|
46
|
+
}
|
|
47
|
+
} = view;
|
|
48
|
+
hideLinkToolbarSetMeta(tr);
|
|
49
|
+
(_toolbarKey$getState = toolbarKey.getState(view.state)) === null || _toolbarKey$getState === void 0 ? void 0 : (_toolbarKey$getState$ = _toolbarKey$getState.onEscapeCallback) === null || _toolbarKey$getState$ === void 0 ? void 0 : _toolbarKey$getState$.call(_toolbarKey$getState, tr);
|
|
50
|
+
view.dispatch(tr);
|
|
44
51
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
45
52
|
}, [view, onCancel]);
|
|
46
53
|
const onClickAway = useCallback(() => {
|
|
@@ -12,7 +12,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
12
12
|
import { PureComponent } from 'react';
|
|
13
13
|
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
14
14
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
15
|
-
import { linkToolbarMessages as linkToolbarCommonMessages } from '
|
|
15
|
+
import { linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
|
|
16
16
|
import PanelTextInput from '../../../../ui/PanelTextInput';
|
|
17
17
|
import LinkSearchList from '../../../../ui/LinkSearch/LinkSearchList';
|
|
18
18
|
import { container, containerWithProvider, inputWrapper } from '../../../../ui/LinkSearch/ToolbarComponents';
|
|
@@ -21,12 +21,12 @@ import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
|
21
21
|
import { filterUniqueItems } from '../../../../utils/array';
|
|
22
22
|
import debounce from 'lodash/debounce';
|
|
23
23
|
import { mapContentTypeToIcon, sha1, wordCount } from './utils';
|
|
24
|
-
import { hideLinkToolbar } from '../../commands';
|
|
25
|
-
import { hideLinkToolbar as cardHideLinkToolbar } from '../../../card/pm-plugins/actions';
|
|
24
|
+
import { hideLinkToolbar, hideLinkToolbarSetMeta } from '../../commands';
|
|
26
25
|
import { visuallyHiddenStyles } from '../../styles';
|
|
27
26
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
28
27
|
import { transformTimeStamp } from '../../../../ui/LinkSearch/transformTimeStamp';
|
|
29
28
|
import Announcer from '../../../../utils/announcer/announcer';
|
|
29
|
+
import { toolbarKey } from '../../pm-plugins/toolbar-buttons';
|
|
30
30
|
export const RECENT_SEARCH_LIST_SIZE = 5;
|
|
31
31
|
const clearText = css`
|
|
32
32
|
cursor: pointer;
|
|
@@ -434,10 +434,18 @@ export class HyperlinkLinkAddToolbar extends PureComponent {
|
|
|
434
434
|
const KEY_CODE_ARROW_DOWN = 40;
|
|
435
435
|
const KEY_CODE_ARROW_UP = 38;
|
|
436
436
|
if (keyCode === KEY_CODE_ESCAPE) {
|
|
437
|
+
var _toolbarKey$getState, _toolbarKey$getState$;
|
|
437
438
|
// escape
|
|
438
439
|
event.preventDefault();
|
|
439
|
-
|
|
440
|
-
|
|
440
|
+
const {
|
|
441
|
+
state: {
|
|
442
|
+
tr
|
|
443
|
+
},
|
|
444
|
+
dispatch
|
|
445
|
+
} = view;
|
|
446
|
+
hideLinkToolbarSetMeta(tr);
|
|
447
|
+
(_toolbarKey$getState = toolbarKey.getState(view.state)) === null || _toolbarKey$getState === void 0 ? void 0 : (_toolbarKey$getState$ = _toolbarKey$getState.onEscapeCallback) === null || _toolbarKey$getState$ === void 0 ? void 0 : _toolbarKey$getState$.call(_toolbarKey$getState, tr);
|
|
448
|
+
dispatch(tr);
|
|
441
449
|
return;
|
|
442
450
|
}
|
|
443
451
|
if (!items || !items.length) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { PluginKey, NodeSelection } from 'prosemirror-state';
|
|
3
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
-
import { media, mediaGroup,
|
|
4
|
+
import { media, mediaGroup, mediaInline, mediaSingleSpec } from '@atlaskit/adf-schema';
|
|
5
5
|
import { stateKey as pluginKey, createPlugin } from './pm-plugins/main';
|
|
6
6
|
import { getMediaFeatureFlag } from '@atlaskit/media-common';
|
|
7
7
|
import { createPlugin as createMediaAltTextPlugin } from './pm-plugins/alt-text';
|
|
@@ -22,6 +22,7 @@ import { messages } from '../insert-block/ui/ToolbarInsertBlock/messages';
|
|
|
22
22
|
import { ReactMediaNode } from './nodeviews/mediaNodeView';
|
|
23
23
|
import { ReactMediaInlineNode } from './nodeviews/mediaInline';
|
|
24
24
|
import { stateKey } from './pm-plugins/plugin-key';
|
|
25
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
25
26
|
export { insertMediaSingleNode } from './utils/media-single';
|
|
26
27
|
const mediaPlugin = (options = {}, api) => {
|
|
27
28
|
var _api$dependencies, _api$dependencies$fea;
|
|
@@ -42,7 +43,14 @@ const mediaPlugin = (options = {}, api) => {
|
|
|
42
43
|
} = options || {};
|
|
43
44
|
const captions = getMediaFeatureFlag('captions', mediaFeatureFlags);
|
|
44
45
|
const allowMediaInline = getMediaFeatureFlag('mediaInline', mediaFeatureFlags);
|
|
45
|
-
const
|
|
46
|
+
const mediaSingleOption = getBooleanFF('platform.editor.media.extended-resize-experience') ? {
|
|
47
|
+
withCaption: captions,
|
|
48
|
+
withExtendedWidthTypes: true
|
|
49
|
+
} : {
|
|
50
|
+
withCaption: captions,
|
|
51
|
+
withExtendedWidthTypes: false
|
|
52
|
+
};
|
|
53
|
+
const mediaSingleNode = mediaSingleSpec(mediaSingleOption);
|
|
46
54
|
return [{
|
|
47
55
|
name: 'mediaGroup',
|
|
48
56
|
node: mediaGroup
|
|
@@ -15,7 +15,7 @@ import { showLinkingToolbar } from '../commands/linking';
|
|
|
15
15
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
16
16
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
17
17
|
import { messages } from '@atlaskit/media-ui';
|
|
18
|
-
import {
|
|
18
|
+
import { cardMessages } from '@atlaskit/editor-common/messages';
|
|
19
19
|
import { FilePreviewItem } from './filePreviewItem';
|
|
20
20
|
import { downloadMedia, removeMediaGroupNode } from './utils';
|
|
21
21
|
import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
@@ -7,7 +7,7 @@ import { mapSlice } from '../../../utils/slice';
|
|
|
7
7
|
import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '../../../utils/dom';
|
|
8
8
|
import { isImage } from './is-image';
|
|
9
9
|
import { atTheBeginningOfBlock, atTheBeginningOfDoc, atTheEndOfBlock, endPositionOfParent, startPositionOfParent } from '../../../utils/prosemirror/position';
|
|
10
|
-
import { GapCursorSelection } from '
|
|
10
|
+
import { GapCursorSelection } from '@atlaskit/editor-common/selection';
|
|
11
11
|
import { isMediaBlobUrl } from '@atlaskit/media-client';
|
|
12
12
|
export const isMediaBlobUrlFromAttrs = attrs => {
|
|
13
13
|
return !!(attrs && attrs.type === 'external' && isMediaBlobUrl(attrs.url));
|