@atlaskit/editor-core 185.6.3 → 185.7.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 +17 -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/toolbar/index.js +3 -3
- package/dist/cjs/plugins/media/ui/ImageBorder/index.js +13 -2
- 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/toolbar/index.js +1 -1
- package/dist/es2019/plugins/media/ui/ImageBorder/index.js +13 -2
- 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/toolbar/index.js +1 -1
- package/dist/esm/plugins/media/ui/ImageBorder/index.js +13 -2
- 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 +10 -2
- 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
|
@@ -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 var appearanceForNodeType = function appearanceForNodeType(spec) {
|
|
6
4
|
if (spec.name === 'inlineCard') {
|
|
7
5
|
return 'inline';
|
|
@@ -44,29 +42,4 @@ export var findCardInfo = function findCardInfo(state) {
|
|
|
44
42
|
return pluginState.cards.find(function (cardInfo) {
|
|
45
43
|
return cardInfo.pos === state.selection.from;
|
|
46
44
|
});
|
|
47
|
-
};
|
|
48
|
-
export var transformUnsupportedBlockCardToInline = function transformUnsupportedBlockCardToInline(slice, state, cardOptions) {
|
|
49
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
50
|
-
blockCard = _state$schema$nodes.blockCard,
|
|
51
|
-
inlineCard = _state$schema$nodes.inlineCard;
|
|
52
|
-
var children = [];
|
|
53
|
-
mapChildren(slice.content, function (node, i, frag) {
|
|
54
|
-
var _cardOptions$allowBlo;
|
|
55
|
-
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)) {
|
|
56
|
-
children.push(inlineCard.createChecked(node.attrs, node.content, node.marks));
|
|
57
|
-
} else {
|
|
58
|
-
children.push(node);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return new Slice(Fragment.fromArray(children), slice.openStart, slice.openEnd);
|
|
62
|
-
};
|
|
63
|
-
/**
|
|
64
|
-
* Function to determine if a block card is supported by the editor
|
|
65
|
-
* @param state
|
|
66
|
-
* @param frag
|
|
67
|
-
* @param allowBlockCards
|
|
68
|
-
* @returns
|
|
69
|
-
*/
|
|
70
|
-
var isBlockCardSupported = function isBlockCardSupported(state, frag, allowBlockCards) {
|
|
71
|
-
return allowBlockCards && isSupportedInParent(state, frag);
|
|
72
45
|
};
|
|
@@ -14,27 +14,29 @@ import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
|
14
14
|
import { linkToolbarMessages as linkToolbarCommonMessages, linkMessages } from '../../messages';
|
|
15
15
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
16
16
|
import { LINKPICKER_HEIGHT_IN_PX, RECENT_SEARCH_HEIGHT_IN_PX, RECENT_SEARCH_WIDTH_IN_PX } from '@atlaskit/editor-common/ui';
|
|
17
|
-
import { HyperlinkToolbarAppearance } from './HyperlinkToolbarAppearance';
|
|
18
17
|
import { ACTION_SUBJECT_ID, ACTION, INPUT_METHOD, buildVisitedLinkPayload, buildOpenedSettingsPayload } from '@atlaskit/editor-common/analytics';
|
|
19
|
-
import {
|
|
18
|
+
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
19
|
+
|
|
20
20
|
/* type guard for edit links */
|
|
21
21
|
function isEditLink(linkMark) {
|
|
22
22
|
return linkMark.pos !== undefined;
|
|
23
23
|
}
|
|
24
|
-
var dispatchAnalytics = function dispatchAnalytics(dispatch, state, analyticsBuilder) {
|
|
24
|
+
var dispatchAnalytics = function dispatchAnalytics(dispatch, state, analyticsBuilder, editorAnalyticsApi) {
|
|
25
25
|
if (dispatch) {
|
|
26
|
-
|
|
26
|
+
var tr = state.tr;
|
|
27
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(analyticsBuilder(ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
28
|
+
dispatch(tr);
|
|
27
29
|
}
|
|
28
30
|
};
|
|
29
|
-
var visitHyperlink = function visitHyperlink() {
|
|
31
|
+
var visitHyperlink = function visitHyperlink(editorAnalyticsApi) {
|
|
30
32
|
return function (state, dispatch) {
|
|
31
|
-
dispatchAnalytics(dispatch, state, buildVisitedLinkPayload);
|
|
33
|
+
dispatchAnalytics(dispatch, state, buildVisitedLinkPayload, editorAnalyticsApi);
|
|
32
34
|
return true;
|
|
33
35
|
};
|
|
34
36
|
};
|
|
35
|
-
var openLinkSettings = function openLinkSettings() {
|
|
37
|
+
var openLinkSettings = function openLinkSettings(editorAnalyticsApi) {
|
|
36
38
|
return function (state, dispatch) {
|
|
37
|
-
dispatchAnalytics(dispatch, state, buildOpenedSettingsPayload);
|
|
39
|
+
dispatchAnalytics(dispatch, state, buildOpenedSettingsPayload, editorAnalyticsApi);
|
|
38
40
|
return true;
|
|
39
41
|
};
|
|
40
42
|
};
|
|
@@ -52,7 +54,7 @@ function getLinkText(activeLinkMark, state) {
|
|
|
52
54
|
}
|
|
53
55
|
return activeLinkMark.node.text;
|
|
54
56
|
}
|
|
55
|
-
var getSettingsButtonGroup = function getSettingsButtonGroup(state, intl, featureFlags) {
|
|
57
|
+
var getSettingsButtonGroup = function getSettingsButtonGroup(state, intl, featureFlags, editorAnalyticsApi) {
|
|
56
58
|
var floatingToolbarLinkSettingsButton = featureFlags.floatingToolbarLinkSettingsButton;
|
|
57
59
|
return floatingToolbarLinkSettingsButton === 'true' ? [{
|
|
58
60
|
type: 'separator'
|
|
@@ -61,15 +63,17 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(state, intl, featur
|
|
|
61
63
|
type: 'button',
|
|
62
64
|
icon: CogIcon,
|
|
63
65
|
title: intl.formatMessage(linkToolbarCommonMessages.settingsLink),
|
|
64
|
-
onClick: openLinkSettings(),
|
|
66
|
+
onClick: openLinkSettings(editorAnalyticsApi),
|
|
65
67
|
href: 'https://id.atlassian.com/manage-profile/link-preferences',
|
|
66
68
|
target: '_blank'
|
|
67
69
|
}] : [];
|
|
68
70
|
};
|
|
69
|
-
export var getToolbarConfig = function getToolbarConfig(options, featureFlags,
|
|
71
|
+
export var getToolbarConfig = function getToolbarConfig(options, featureFlags, pluginInjectionApi) {
|
|
70
72
|
return function (state, intl, providerFactory) {
|
|
73
|
+
var _pluginInjectionApi$d;
|
|
71
74
|
var formatMessage = intl.formatMessage;
|
|
72
75
|
var linkState = stateKey.getState(state);
|
|
76
|
+
var editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.analytics) === null || _pluginInjectionApi$d === void 0 ? void 0 : _pluginInjectionApi$d.actions;
|
|
73
77
|
|
|
74
78
|
/**
|
|
75
79
|
* Enable focus trap only if feature flag is enabled AND for the new version of the picker
|
|
@@ -92,6 +96,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
|
|
|
92
96
|
switch (activeLinkMark.type) {
|
|
93
97
|
case 'EDIT':
|
|
94
98
|
{
|
|
99
|
+
var _toolbarKey$getState$, _toolbarKey$getState;
|
|
95
100
|
var pos = activeLinkMark.pos,
|
|
96
101
|
node = activeLinkMark.node;
|
|
97
102
|
var linkMark = node.marks.filter(function (mark) {
|
|
@@ -113,23 +118,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
|
|
|
113
118
|
return _objectSpread(_objectSpread({}, hyperLinkToolbar), {}, {
|
|
114
119
|
height: 32,
|
|
115
120
|
width: 250,
|
|
116
|
-
items: [{
|
|
117
|
-
type: 'custom',
|
|
118
|
-
fallback: [],
|
|
119
|
-
render: function render(editorView) {
|
|
120
|
-
return /*#__PURE__*/React.createElement(HyperlinkToolbarAppearance, {
|
|
121
|
-
key: "link-appearance",
|
|
122
|
-
url: link,
|
|
123
|
-
intl: intl,
|
|
124
|
-
editorView: editorView,
|
|
125
|
-
editorState: state,
|
|
126
|
-
cardOptions: options === null || options === void 0 ? void 0 : options.cardOptions,
|
|
127
|
-
providerFactory: providerFactory,
|
|
128
|
-
platform: options === null || options === void 0 ? void 0 : options.platform,
|
|
129
|
-
editorAnalyticsApi: editorAnalyticsApi
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
}, {
|
|
121
|
+
items: [].concat(_toConsumableArray((_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$ : []), [{
|
|
133
122
|
id: 'editor.link.edit',
|
|
134
123
|
type: 'button',
|
|
135
124
|
onClick: editInsertedLink(),
|
|
@@ -145,7 +134,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
|
|
|
145
134
|
disabled: !isValidUrl,
|
|
146
135
|
target: '_blank',
|
|
147
136
|
href: isValidUrl ? link : undefined,
|
|
148
|
-
onClick: visitHyperlink(),
|
|
137
|
+
onClick: visitHyperlink(editorAnalyticsApi),
|
|
149
138
|
selected: false,
|
|
150
139
|
title: labelOpenLink,
|
|
151
140
|
icon: OpenIcon,
|
|
@@ -173,7 +162,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, e
|
|
|
173
162
|
formatMessage: formatMessage,
|
|
174
163
|
markType: state.schema.marks.link
|
|
175
164
|
}]
|
|
176
|
-
}]
|
|
165
|
+
}], _toConsumableArray(getSettingsButtonGroup(state, intl, featureFlags, editorAnalyticsApi))),
|
|
177
166
|
scrollable: true
|
|
178
167
|
});
|
|
179
168
|
}
|
|
@@ -191,10 +191,13 @@ export function showLinkToolbar() {
|
|
|
191
191
|
export function hideLinkToolbar() {
|
|
192
192
|
return function (state, dispatch) {
|
|
193
193
|
if (dispatch) {
|
|
194
|
-
dispatch(state.tr
|
|
195
|
-
type: LinkAction.HIDE_TOOLBAR
|
|
196
|
-
}));
|
|
194
|
+
dispatch(hideLinkToolbarSetMeta(state.tr));
|
|
197
195
|
}
|
|
198
196
|
return true;
|
|
199
197
|
};
|
|
198
|
+
}
|
|
199
|
+
export function hideLinkToolbarSetMeta(tr) {
|
|
200
|
+
return tr.setMeta(stateKey, {
|
|
201
|
+
type: LinkAction.HIDE_TOOLBAR
|
|
202
|
+
});
|
|
200
203
|
}
|
|
@@ -4,13 +4,14 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
|
4
4
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
5
5
|
import { plugin as _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
|
var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
13
|
-
var _api$dependencies, _api$dependencies$fea
|
|
14
|
+
var _api$dependencies, _api$dependencies$fea;
|
|
14
15
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
15
16
|
var api = arguments.length > 1 ? arguments[1] : undefined;
|
|
16
17
|
var 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()) || {};
|
|
@@ -22,6 +23,9 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
22
23
|
mark: link
|
|
23
24
|
}];
|
|
24
25
|
},
|
|
26
|
+
actions: {
|
|
27
|
+
prependToolbarButtons: prependToolbarButtons
|
|
28
|
+
},
|
|
25
29
|
pmPlugins: function pmPlugins() {
|
|
26
30
|
var _options$cardOptions;
|
|
27
31
|
// Skip analytics if card provider is available, as they will be
|
|
@@ -50,6 +54,9 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
50
54
|
plugin: function plugin() {
|
|
51
55
|
return createKeymapPlugin(skipAnalytics);
|
|
52
56
|
}
|
|
57
|
+
}, {
|
|
58
|
+
name: 'hyperlinkToolbarButtons',
|
|
59
|
+
plugin: toolbarButtonsPlugin
|
|
53
60
|
}];
|
|
54
61
|
},
|
|
55
62
|
pluginsOptions: {
|
|
@@ -85,7 +92,7 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
85
92
|
}
|
|
86
93
|
}];
|
|
87
94
|
},
|
|
88
|
-
floatingToolbar: getToolbarConfig(options, featureFlags, api
|
|
95
|
+
floatingToolbar: getToolbarConfig(options, featureFlags, api)
|
|
89
96
|
}
|
|
90
97
|
};
|
|
91
98
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PluginKey } from 'prosemirror-state';
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
export var toolbarKey = new PluginKey('hyperlinkToolbarItems');
|
|
4
|
+
export var prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
5
|
+
var items = _ref.items,
|
|
6
|
+
onEscapeCallback = _ref.onEscapeCallback,
|
|
7
|
+
view = _ref.view;
|
|
8
|
+
var tr = view.state.tr,
|
|
9
|
+
dispatch = view.dispatch;
|
|
10
|
+
tr.setMeta(toolbarKey, {
|
|
11
|
+
items: items,
|
|
12
|
+
onEscapeCallback: onEscapeCallback
|
|
13
|
+
});
|
|
14
|
+
dispatch(tr);
|
|
15
|
+
};
|
|
16
|
+
export var toolbarButtonsPlugin = function toolbarButtonsPlugin() {
|
|
17
|
+
return new SafePlugin({
|
|
18
|
+
key: toolbarKey,
|
|
19
|
+
state: {
|
|
20
|
+
init: function init(_, state) {
|
|
21
|
+
return undefined;
|
|
22
|
+
},
|
|
23
|
+
apply: function apply(tr, pluginState) {
|
|
24
|
+
var metaState = tr.getMeta(toolbarKey);
|
|
25
|
+
if (metaState) {
|
|
26
|
+
return metaState;
|
|
27
|
+
}
|
|
28
|
+
return pluginState;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
@@ -3,8 +3,8 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
3
3
|
var _excluded = ["view", "onCancel", "invokeMethod", "editorAppearance", "onClose"];
|
|
4
4
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
5
5
|
import { LinkPicker } from '@atlaskit/link-picker';
|
|
6
|
-
import { hideLinkToolbar
|
|
7
|
-
import {
|
|
6
|
+
import { hideLinkToolbarSetMeta, hideLinkToolbar } from '../../commands';
|
|
7
|
+
import { toolbarKey } from '../../pm-plugins/toolbar-buttons';
|
|
8
8
|
import { useEscapeClickaway } from './useEscapeClickaway';
|
|
9
9
|
import { AnalyticsContext } from '@atlaskit/analytics-next';
|
|
10
10
|
import { getAnalyticsEditorAppearance } from '@atlaskit/editor-common/utils';
|
|
@@ -43,8 +43,11 @@ export var EditorLinkPicker = function EditorLinkPicker(_ref) {
|
|
|
43
43
|
};
|
|
44
44
|
}, []);
|
|
45
45
|
var onEscape = useCallback(function () {
|
|
46
|
-
|
|
47
|
-
view.
|
|
46
|
+
var _toolbarKey$getState, _toolbarKey$getState$;
|
|
47
|
+
var tr = view.state.tr;
|
|
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);
|
|
48
51
|
onCancel === null || onCancel === void 0 ? void 0 : onCancel();
|
|
49
52
|
}, [view, onCancel]);
|
|
50
53
|
var onClickAway = useCallback(function () {
|
|
@@ -26,7 +26,7 @@ import Tooltip from '@atlaskit/tooltip';
|
|
|
26
26
|
import { PureComponent } from 'react';
|
|
27
27
|
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
28
28
|
import { withAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
29
|
-
import { linkToolbarMessages as linkToolbarCommonMessages } from '
|
|
29
|
+
import { linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
|
|
30
30
|
import PanelTextInput from '../../../../ui/PanelTextInput';
|
|
31
31
|
import LinkSearchList from '../../../../ui/LinkSearch/LinkSearchList';
|
|
32
32
|
import { container, containerWithProvider, inputWrapper } from '../../../../ui/LinkSearch/ToolbarComponents';
|
|
@@ -35,12 +35,12 @@ import { normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
|
35
35
|
import { filterUniqueItems } from '../../../../utils/array';
|
|
36
36
|
import debounce from 'lodash/debounce';
|
|
37
37
|
import { mapContentTypeToIcon, sha1, wordCount } from './utils';
|
|
38
|
-
import { hideLinkToolbar } from '../../commands';
|
|
39
|
-
import { hideLinkToolbar as cardHideLinkToolbar } from '../../../card/pm-plugins/actions';
|
|
38
|
+
import { hideLinkToolbar, hideLinkToolbarSetMeta } from '../../commands';
|
|
40
39
|
import { visuallyHiddenStyles } from '../../styles';
|
|
41
40
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
42
41
|
import { transformTimeStamp } from '../../../../ui/LinkSearch/transformTimeStamp';
|
|
43
42
|
import Announcer from '../../../../utils/announcer/announcer';
|
|
43
|
+
import { toolbarKey } from '../../pm-plugins/toolbar-buttons';
|
|
44
44
|
export var RECENT_SEARCH_LIST_SIZE = 5;
|
|
45
45
|
var clearText = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n padding: 0;\n margin-right: 8px;\n color: ", ";\n background: transparent;\n border: none;\n"])), "var(--ds-icon-subtle, ".concat(N90, ")"));
|
|
46
46
|
var textInputWrapper = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", ";\n border-top: 1px solid ", ";\n border-bottom: 1px solid ", ";\n"])), inputWrapper, "var(--ds-border, ".concat(N30, ")"), "var(--ds-border, ".concat(N30, ")"));
|
|
@@ -499,10 +499,14 @@ export var HyperlinkLinkAddToolbar = /*#__PURE__*/function (_PureComponent) {
|
|
|
499
499
|
var KEY_CODE_ARROW_DOWN = 40;
|
|
500
500
|
var KEY_CODE_ARROW_UP = 38;
|
|
501
501
|
if (keyCode === KEY_CODE_ESCAPE) {
|
|
502
|
+
var _toolbarKey$getState, _toolbarKey$getState$;
|
|
502
503
|
// escape
|
|
503
504
|
event.preventDefault();
|
|
504
|
-
|
|
505
|
-
|
|
505
|
+
var tr = view.state.tr,
|
|
506
|
+
dispatch = view.dispatch;
|
|
507
|
+
hideLinkToolbarSetMeta(tr);
|
|
508
|
+
(_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);
|
|
509
|
+
dispatch(tr);
|
|
506
510
|
return;
|
|
507
511
|
}
|
|
508
512
|
if (!items || !items.length) {
|
|
@@ -19,7 +19,7 @@ import { showLinkingToolbar } from '../commands/linking';
|
|
|
19
19
|
import { LinkToolbarAppearance } from './linking-toolbar-appearance';
|
|
20
20
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
21
21
|
import { messages } from '@atlaskit/media-ui';
|
|
22
|
-
import {
|
|
22
|
+
import { cardMessages } from '@atlaskit/editor-common/messages';
|
|
23
23
|
import { FilePreviewItem } from './filePreviewItem';
|
|
24
24
|
import { downloadMedia, removeMediaGroupNode } from './utils';
|
|
25
25
|
import { changeInlineToMediaCard, changeMediaCardToInline, removeInlineCard, setBorderMark, toggleBorderMark } from './commands';
|
|
@@ -36,6 +36,15 @@ var ImageBorder = function ImageBorder(_ref) {
|
|
|
36
36
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
37
37
|
isSizeSubmenuOpen = _useState6[0],
|
|
38
38
|
setIsSizeSubmenuOpen = _useState6[1];
|
|
39
|
+
var handleSubMenuRef = function handleSubMenuRef(ref) {
|
|
40
|
+
if (!ref) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
var rect = ref.getBoundingClientRect();
|
|
44
|
+
if (rect.left + rect.width > window.innerWidth) {
|
|
45
|
+
ref.style.left = "-".concat(rect.width, "px");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
39
48
|
var borderSizeOptions = [{
|
|
40
49
|
name: formatMessage(messages.borderSizeSubtle),
|
|
41
50
|
value: 1
|
|
@@ -56,7 +65,8 @@ var ImageBorder = function ImageBorder(_ref) {
|
|
|
56
65
|
}, jsx("div", {
|
|
57
66
|
css: contextualMenuColorIcon(color && hexToEditorBorderPaletteColor(color))
|
|
58
67
|
}), isColorSubmenuOpen && jsx("div", {
|
|
59
|
-
css: contextualSubMenu(0)
|
|
68
|
+
css: contextualSubMenu(0),
|
|
69
|
+
ref: handleSubMenuRef
|
|
60
70
|
}, jsx(ColorPalette, {
|
|
61
71
|
onClick: function onClick(color) {
|
|
62
72
|
setBorder({
|
|
@@ -82,7 +92,8 @@ var ImageBorder = function ImageBorder(_ref) {
|
|
|
82
92
|
}, jsx("div", {
|
|
83
93
|
css: contextualMenuArrow
|
|
84
94
|
}), isSizeSubmenuOpen && jsx("div", {
|
|
85
|
-
css: contextualSubMenu(1)
|
|
95
|
+
css: contextualSubMenu(1),
|
|
96
|
+
ref: handleSubMenuRef
|
|
86
97
|
}, borderSizeOptions.map(function (_ref2, idx) {
|
|
87
98
|
var name = _ref2.name,
|
|
88
99
|
value = _ref2.value;
|
|
@@ -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 var isMediaBlobUrlFromAttrs = function isMediaBlobUrlFromAttrs(attrs) {
|
|
13
13
|
return !!(attrs && attrs.type === 'external' && isMediaBlobUrl(attrs.url));
|
|
@@ -15,7 +15,6 @@ import { replaceSelectedTable } from '@atlaskit/editor-tables/utils';
|
|
|
15
15
|
import { compose, insideTable, isParagraph, isText, isLinkMark, insideTableCell, isInListItem } from '../../utils';
|
|
16
16
|
import { mapSlice } from '../../utils/slice';
|
|
17
17
|
import { INPUT_METHOD } from '../analytics';
|
|
18
|
-
import { queueCardsFromChangedTr } from '../card/pm-plugins/doc';
|
|
19
18
|
import { GapCursorSelection, Side } from '../selection/gap-cursor-selection';
|
|
20
19
|
import { linkifyContent } from '@atlaskit/editor-common/utils';
|
|
21
20
|
import { runMacroAutoConvert } from '../macro';
|
|
@@ -28,7 +27,6 @@ import { insertSliceForLists } from './edge-cases';
|
|
|
28
27
|
import { startTrackingPastedMacroPositions, stopTrackingPastedMacroPositions } from './commands';
|
|
29
28
|
import { getPluginState as getPastePluginState } from './pm-plugins/plugin-factory';
|
|
30
29
|
import { doesSelectionWhichStartsOrEndsInListContainEntireList } from '../../utils/lists';
|
|
31
|
-
|
|
32
30
|
// remove text attribute from mention for copy/paste (GDPR)
|
|
33
31
|
export function handleMention(slice, schema) {
|
|
34
32
|
return mapSlice(slice, function (node) {
|
|
@@ -42,7 +40,7 @@ export function handleMention(slice, schema) {
|
|
|
42
40
|
return node;
|
|
43
41
|
});
|
|
44
42
|
}
|
|
45
|
-
export function handlePasteIntoTaskOrDecisionOrPanel(slice) {
|
|
43
|
+
export function handlePasteIntoTaskOrDecisionOrPanel(slice, queueCardsFromChangedTr) {
|
|
46
44
|
return function (state, dispatch) {
|
|
47
45
|
var _slice$content$firstC, _transformedSlice$con;
|
|
48
46
|
var schema = state.schema,
|
|
@@ -107,7 +105,7 @@ export function handlePasteIntoTaskOrDecisionOrPanel(slice) {
|
|
|
107
105
|
// This maintains both the selection (destination) and the slice (paste content).
|
|
108
106
|
safeInsert(transformedSlice.content)(tr).scrollIntoView();
|
|
109
107
|
}
|
|
110
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
108
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
111
109
|
if (dispatch) {
|
|
112
110
|
dispatch(tr);
|
|
113
111
|
}
|
|
@@ -329,7 +327,7 @@ export function handlePasteAsPlainText(slice, _event) {
|
|
|
329
327
|
return false;
|
|
330
328
|
};
|
|
331
329
|
}
|
|
332
|
-
export function handlePastePreservingMarks(slice) {
|
|
330
|
+
export function handlePastePreservingMarks(slice, queueCardsFromChangedTr) {
|
|
333
331
|
return function (state, dispatch) {
|
|
334
332
|
var schema = state.schema,
|
|
335
333
|
selection = state.tr.selection;
|
|
@@ -365,7 +363,7 @@ export function handlePastePreservingMarks(slice) {
|
|
|
365
363
|
// special case for plainTextSlice & linkMark: merge into existing link
|
|
366
364
|
if (isPlainTextSlice && linkMark.isInSet(selectionMarks) && selectionMarks.length === 1) {
|
|
367
365
|
var tr = closeHistory(state.tr).replaceSelectionWith(slice.content.firstChild.firstChild, true).setStoredMarks(selectionMarks).scrollIntoView();
|
|
368
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
366
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
369
367
|
if (dispatch) {
|
|
370
368
|
dispatch(tr);
|
|
371
369
|
}
|
|
@@ -377,7 +375,7 @@ export function handlePastePreservingMarks(slice) {
|
|
|
377
375
|
if (hasOnlyNodesOfType(bulletList, hardBreak, heading, listItem, paragraph, text, emoji, mention, orderedList)(slice)) {
|
|
378
376
|
var transformedSlice = applyTextMarksToSlice(schema, selectionMarks)(slice);
|
|
379
377
|
var _tr2 = closeHistory(state.tr).replaceSelection(transformedSlice).setStoredMarks(selectionMarks).scrollIntoView();
|
|
380
|
-
queueCardsFromChangedTr(state, _tr2, INPUT_METHOD.CLIPBOARD);
|
|
378
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, _tr2, INPUT_METHOD.CLIPBOARD);
|
|
381
379
|
if (dispatch) {
|
|
382
380
|
dispatch(_tr2);
|
|
383
381
|
}
|
|
@@ -439,7 +437,7 @@ function insertAutoMacro(slice, macro, view, from, to) {
|
|
|
439
437
|
}
|
|
440
438
|
return false;
|
|
441
439
|
}
|
|
442
|
-
export function handleMacroAutoConvert(text, slice, cardsOptions, extensionAutoConverter) {
|
|
440
|
+
export function handleMacroAutoConvert(text, slice, queueCardsFromChangedTr, cardsOptions, extensionAutoConverter) {
|
|
443
441
|
return function (state, dispatch, view) {
|
|
444
442
|
var macro = null;
|
|
445
443
|
|
|
@@ -477,7 +475,7 @@ export function handleMacroAutoConvert(text, slice, cardsOptions, extensionAutoC
|
|
|
477
475
|
var _getPastePluginState = getPastePluginState(view.state),
|
|
478
476
|
pastedMacroPositions = _getPastePluginState.pastedMacroPositions;
|
|
479
477
|
if (dispatch) {
|
|
480
|
-
handleMarkdown(slice, pastedMacroPositions[trackingFrom], pastedMacroPositions[trackingTo])(view.state, dispatch);
|
|
478
|
+
handleMarkdown(slice, queueCardsFromChangedTr, pastedMacroPositions[trackingFrom], pastedMacroPositions[trackingTo])(view.state, dispatch);
|
|
481
479
|
}
|
|
482
480
|
}).catch(function () {
|
|
483
481
|
var _getPastePluginState2 = getPastePluginState(view.state),
|
|
@@ -583,7 +581,7 @@ export function handleExpandPasteInTable(slice) {
|
|
|
583
581
|
return false;
|
|
584
582
|
};
|
|
585
583
|
}
|
|
586
|
-
export function handleMarkdown(markdownSlice, from, to) {
|
|
584
|
+
export function handleMarkdown(markdownSlice, queueCardsFromChangedTr, from, to) {
|
|
587
585
|
return function (state, dispatch) {
|
|
588
586
|
var tr = closeHistory(state.tr);
|
|
589
587
|
var pastesFrom = typeof from === 'number' ? from : tr.selection.from;
|
|
@@ -593,7 +591,7 @@ export function handleMarkdown(markdownSlice, from, to) {
|
|
|
593
591
|
tr.replaceSelection(markdownSlice);
|
|
594
592
|
}
|
|
595
593
|
tr.setSelection(TextSelection.near(tr.doc.resolve(pastesFrom + markdownSlice.size), -1));
|
|
596
|
-
queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
594
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
597
595
|
if (dispatch) {
|
|
598
596
|
dispatch(tr.scrollIntoView());
|
|
599
597
|
}
|
|
@@ -745,7 +743,7 @@ export function flattenNestedListInSlice(slice) {
|
|
|
745
743
|
var contentWithFlattenedList = slice.content.replaceChild(0, listToFlatten.type.createChecked(listToFlatten.attrs, leafListItems));
|
|
746
744
|
return new Slice(contentWithFlattenedList, slice.openEnd, slice.openEnd);
|
|
747
745
|
}
|
|
748
|
-
export function handleRichText(slice) {
|
|
746
|
+
export function handleRichText(slice, queueCardsFromChangedTr) {
|
|
749
747
|
return function (state, dispatch) {
|
|
750
748
|
var _slice$content, _slice$content2, _firstChildOfSlice$ty, _lastChildOfSlice$typ, _panelParentOverCurre;
|
|
751
749
|
var _state$schema$nodes3 = state.schema.nodes,
|
|
@@ -819,8 +817,9 @@ export function handleRichText(slice) {
|
|
|
819
817
|
tr.scrollIntoView();
|
|
820
818
|
|
|
821
819
|
// queue link cards, ignoring any errors
|
|
820
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, INPUT_METHOD.CLIPBOARD);
|
|
822
821
|
if (dispatch) {
|
|
823
|
-
dispatch(
|
|
822
|
+
dispatch(tr);
|
|
824
823
|
}
|
|
825
824
|
return true;
|
|
826
825
|
};
|
|
@@ -14,7 +14,7 @@ var pastePlugin = function pastePlugin(_ref, api) {
|
|
|
14
14
|
providerFactory = _ref2.providerFactory,
|
|
15
15
|
dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent,
|
|
16
16
|
dispatch = _ref2.dispatch;
|
|
17
|
-
return createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, cardOptions, sanitizePrivateContent, providerFactory);
|
|
17
|
+
return createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, api, cardOptions, sanitizePrivateContent, providerFactory);
|
|
18
18
|
}
|
|
19
19
|
}];
|
|
20
20
|
}
|
|
@@ -223,10 +223,11 @@ export var handlePasteAsPlainTextWithAnalytics = function handlePasteAsPlainText
|
|
|
223
223
|
asPlain: true
|
|
224
224
|
}))(handlePasteAsPlainText(slice, event));
|
|
225
225
|
};
|
|
226
|
-
export var handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type) {
|
|
226
|
+
export var handlePasteIntoTaskAndDecisionWithAnalytics = function handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
227
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
227
228
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
228
229
|
type: type
|
|
229
|
-
}))(handlePasteIntoTaskOrDecisionOrPanel(slice));
|
|
230
|
+
}))(handlePasteIntoTaskOrDecisionOrPanel(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.actions) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.queueCardsFromChangedTr));
|
|
230
231
|
};
|
|
231
232
|
export var handlePasteIntoCaptionWithAnalytics = function handlePasteIntoCaptionWithAnalytics(view, event, slice, type) {
|
|
232
233
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
@@ -243,20 +244,23 @@ export var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalyt
|
|
|
243
244
|
type: type
|
|
244
245
|
}))(handleMediaSingle(INPUT_METHOD.CLIPBOARD)(slice));
|
|
245
246
|
};
|
|
246
|
-
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type) {
|
|
247
|
+
export var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
|
|
248
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
247
249
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
248
250
|
type: type
|
|
249
|
-
}))(handlePastePreservingMarks(slice));
|
|
251
|
+
}))(handlePastePreservingMarks(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.actions) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.queueCardsFromChangedTr));
|
|
250
252
|
};
|
|
251
|
-
export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice) {
|
|
253
|
+
export var handleMarkdownWithAnalytics = function handleMarkdownWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
254
|
+
var _pluginInjectionApi$d5, _pluginInjectionApi$d6;
|
|
252
255
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
253
256
|
type: PasteTypes.markdown
|
|
254
|
-
}))(handleMarkdown(slice));
|
|
257
|
+
}))(handleMarkdown(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d5 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : (_pluginInjectionApi$d6 = _pluginInjectionApi$d5.actions) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : _pluginInjectionApi$d6.queueCardsFromChangedTr));
|
|
255
258
|
};
|
|
256
|
-
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice) {
|
|
259
|
+
export var handleRichTextWithAnalytics = function handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi) {
|
|
260
|
+
var _pluginInjectionApi$d7, _pluginInjectionApi$d8;
|
|
257
261
|
return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
|
|
258
262
|
type: PasteTypes.richText
|
|
259
|
-
}))(handleRichText(slice));
|
|
263
|
+
}))(handleRichText(slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d7 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : (_pluginInjectionApi$d8 = _pluginInjectionApi$d7.actions) === null || _pluginInjectionApi$d8 === void 0 ? void 0 : _pluginInjectionApi$d8.queueCardsFromChangedTr));
|
|
260
264
|
};
|
|
261
265
|
function injectAnalyticsPayloadBeforeCommand(createPayloadByTransaction) {
|
|
262
266
|
return function (mainCommand) {
|
|
@@ -9,7 +9,7 @@ import { mapChildren } from '../../../utils/slice';
|
|
|
9
9
|
import { getExtensionAutoConvertersFromProvider } from '@atlaskit/editor-common/extensions';
|
|
10
10
|
import * as clipboard from '../../../utils/clipboard';
|
|
11
11
|
import { transformSliceForMedia } from '../../media/utils/media-single';
|
|
12
|
-
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks } from '../util';
|
|
12
|
+
import { escapeLinks, htmlContainsSingleFile, isPastedFromWord, isPastedFromExcel, htmlHasInvalidLinkTags, removeDuplicateInvalidLinks, transformUnsupportedBlockCardToInline } from '../util';
|
|
13
13
|
import { linkifyContent } from '@atlaskit/editor-common/utils';
|
|
14
14
|
import { transformSliceNestedExpandToExpand } from '../../expand/utils';
|
|
15
15
|
import { handleMacroAutoConvert, handleMention, handleParagraphBlockMarks } from '../handlers';
|
|
@@ -21,7 +21,6 @@ import { measureRender } from '@atlaskit/editor-common/utils';
|
|
|
21
21
|
import { transformSliceToCorrectMediaWrapper, unwrapNestedMediaElements } from '../../media/utils/media-common';
|
|
22
22
|
import { upgradeTextToLists, splitParagraphs } from '../../list/transforms';
|
|
23
23
|
import { md } from '@atlaskit/editor-common/paste';
|
|
24
|
-
import { transformUnsupportedBlockCardToInline } from '../../card/utils';
|
|
25
24
|
import { transformSliceToDecisionList } from '../../tasks-and-decisions/utils';
|
|
26
25
|
import { containsAnyAnnotations, stripNonExistingAnnotations } from '../../annotation/utils';
|
|
27
26
|
import { pluginKey as betterTypePluginKey } from '../../base/pm-plugins/better-type-history';
|
|
@@ -32,7 +31,7 @@ import { extractSliceFromStep } from '../../../utils/step';
|
|
|
32
31
|
import { pluginKey as stateKey, createPluginState } from './plugin-factory';
|
|
33
32
|
export { pluginKey as stateKey } from './plugin-factory';
|
|
34
33
|
import { hasParentNodeOfType } from 'prosemirror-utils';
|
|
35
|
-
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
34
|
+
export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pluginInjectionApi, cardOptions, sanitizePrivateContent, providerFactory) {
|
|
36
35
|
var atlassianMarkDownParser = new MarkdownTransformer(schema, md);
|
|
37
36
|
function getMarkdownSlice(text, openStart, openEnd) {
|
|
38
37
|
var textInput = text;
|
|
@@ -228,13 +227,14 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
228
227
|
// force a "paste as plain text" action by clearing the markdownSlice.
|
|
229
228
|
markdownSlice = !((_markdownSlice = markdownSlice) !== null && _markdownSlice !== void 0 && _markdownSlice.size) ? undefined : markdownSlice;
|
|
230
229
|
if (markdownSlice) {
|
|
230
|
+
var _pluginInjectionApi$d, _pluginInjectionApi$d2;
|
|
231
231
|
// linkify text prior to converting to macro
|
|
232
232
|
if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, markdownSlice, PasteTypes.markdown)(state, dispatch)) {
|
|
233
233
|
return true;
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
// run macro autoconvert prior to other conversions
|
|
237
|
-
if (handleMacroAutoConvert(text, markdownSlice, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
|
|
237
|
+
if (handleMacroAutoConvert(text, markdownSlice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d === void 0 ? void 0 : (_pluginInjectionApi$d2 = _pluginInjectionApi$d.actions) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
|
|
238
238
|
// TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
239
239
|
sendPasteAnalyticsEvent(view, event, markdownSlice, {
|
|
240
240
|
type: PasteTypes.markdown
|
|
@@ -257,7 +257,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
257
257
|
if (slice.openStart === 0 && selectionParentNode && edgeCaseNodeTypes.includes(selectionParentType)) {
|
|
258
258
|
slice.openStart = 1;
|
|
259
259
|
}
|
|
260
|
-
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText)(state, dispatch)) {
|
|
260
|
+
if (handlePasteIntoTaskAndDecisionWithAnalytics(view, event, slice, isPlainText ? PasteTypes.plain : PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
261
261
|
return true;
|
|
262
262
|
}
|
|
263
263
|
|
|
@@ -274,10 +274,10 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
274
274
|
|
|
275
275
|
// If the clipboard only contains plain text, attempt to parse it as Markdown
|
|
276
276
|
if (isPlainText && markdownSlice) {
|
|
277
|
-
if (handlePastePreservingMarksWithAnalytics(view, event, markdownSlice, PasteTypes.markdown)(state, dispatch)) {
|
|
277
|
+
if (handlePastePreservingMarksWithAnalytics(view, event, markdownSlice, PasteTypes.markdown, pluginInjectionApi)(state, dispatch)) {
|
|
278
278
|
return true;
|
|
279
279
|
}
|
|
280
|
-
return handleMarkdownWithAnalytics(view, event, markdownSlice)(state, dispatch);
|
|
280
|
+
return handleMarkdownWithAnalytics(view, event, markdownSlice, pluginInjectionApi)(state, dispatch);
|
|
281
281
|
}
|
|
282
282
|
if (isRichText && isInsideBlockQuote(state)) {
|
|
283
283
|
//If pasting inside blockquote
|
|
@@ -298,6 +298,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
298
298
|
|
|
299
299
|
// finally, handle rich-text copy-paste
|
|
300
300
|
if (isRichText) {
|
|
301
|
+
var _pluginInjectionApi$d3, _pluginInjectionApi$d4;
|
|
301
302
|
// linkify the text where possible
|
|
302
303
|
slice = linkifyContent(state.schema)(slice);
|
|
303
304
|
if (handlePasteLinkOnSelectedTextWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
@@ -305,7 +306,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
// run macro autoconvert prior to other conversions
|
|
308
|
-
if (handleMacroAutoConvert(text, slice, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
|
|
309
|
+
if (handleMacroAutoConvert(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d3 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d3 === void 0 ? void 0 : (_pluginInjectionApi$d4 = _pluginInjectionApi$d3.actions) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : _pluginInjectionApi$d4.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
|
|
309
310
|
// TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
|
|
310
311
|
sendPasteAnalyticsEvent(view, event, slice, {
|
|
311
312
|
type: PasteTypes.richText
|
|
@@ -329,7 +330,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
329
330
|
}
|
|
330
331
|
|
|
331
332
|
// ED-4732
|
|
332
|
-
if (handlePastePreservingMarksWithAnalytics(view, event, slice, PasteTypes.richText)(state, dispatch)) {
|
|
333
|
+
if (handlePastePreservingMarksWithAnalytics(view, event, slice, PasteTypes.richText, pluginInjectionApi)(state, dispatch)) {
|
|
333
334
|
return true;
|
|
334
335
|
}
|
|
335
336
|
|
|
@@ -367,7 +368,7 @@ export function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFl
|
|
|
367
368
|
if (featureFlags !== null && featureFlags !== void 0 && featureFlags.restartNumberedLists && handlePasteNonNestableBlockNodesIntoListWithAnalytics(view, event, slice)(state, dispatch)) {
|
|
368
369
|
return true;
|
|
369
370
|
}
|
|
370
|
-
return handleRichTextWithAnalytics(view, event, slice)(state, dispatch);
|
|
371
|
+
return handleRichTextWithAnalytics(view, event, slice, pluginInjectionApi)(state, dispatch);
|
|
371
372
|
}
|
|
372
373
|
return false;
|
|
373
374
|
},
|