@atlaskit/editor-core 185.17.0 → 186.0.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/dist/cjs/index.js +6 -56
  3. package/dist/cjs/version-wrapper.js +1 -1
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/es2019/index.js +0 -13
  6. package/dist/es2019/version-wrapper.js +1 -1
  7. package/dist/es2019/version.json +1 -1
  8. package/dist/esm/index.js +0 -13
  9. package/dist/esm/version-wrapper.js +1 -1
  10. package/dist/esm/version.json +1 -1
  11. package/dist/types/index.d.ts +0 -14
  12. package/dist/types/labs/next/presets/cxhtml.d.ts +4 -0
  13. package/dist/types/labs/next/presets/default.d.ts +8 -0
  14. package/dist/types/labs/next/presets/mobile.d.ts +4 -0
  15. package/dist/types-ts4.5/index.d.ts +0 -14
  16. package/dist/types-ts4.5/labs/next/presets/cxhtml.d.ts +4 -0
  17. package/dist/types-ts4.5/labs/next/presets/default.d.ts +8 -0
  18. package/dist/types-ts4.5/labs/next/presets/mobile.d.ts +4 -0
  19. package/package.json +3 -3
  20. package/report.api.md +0 -58
  21. package/tmp/api-report-tmp.d.ts +0 -29
  22. package/dist/cjs/plugins/deprecated-card/doc.js +0 -111
  23. package/dist/cjs/plugins/deprecated-hyperlink/commands.js +0 -164
  24. package/dist/es2019/plugins/deprecated-card/doc.js +0 -97
  25. package/dist/es2019/plugins/deprecated-hyperlink/commands.js +0 -150
  26. package/dist/esm/plugins/deprecated-card/doc.js +0 -105
  27. package/dist/esm/plugins/deprecated-hyperlink/commands.js +0 -152
  28. package/dist/types/plugins/deprecated-card/doc.d.ts +0 -20
  29. package/dist/types/plugins/deprecated-hyperlink/commands.d.ts +0 -38
  30. package/dist/types-ts4.5/plugins/deprecated-card/doc.d.ts +0 -20
  31. package/dist/types-ts4.5/plugins/deprecated-hyperlink/commands.d.ts +0 -38
package/report.api.md CHANGED
@@ -88,20 +88,15 @@ import { Side as GapCursorSide } from '@atlaskit/editor-common/selection';
88
88
  import { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
89
89
  import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
90
90
  import { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
91
- import { InsertStatus as HyperlinkInsertStatus } from '@atlaskit/editor-common/link';
92
91
  import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
93
- import { HyperlinkState } from '@atlaskit/editor-common/link';
94
92
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
95
93
  import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
96
94
  import { InputTracking } from '@atlaskit/editor-common/types';
97
95
  import { IntlShape } from 'react-intl-next';
98
- import { isLinkAtPos } from '@atlaskit/editor-common/link';
99
- import { isTextAtPos } from '@atlaskit/editor-common/link';
100
96
  import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
101
97
  import { jsx } from '@emotion/react';
102
98
  import { lightModeStatusColorPalette } from '@atlaskit/editor-common/ui-color';
103
99
  import type { LinkingOptions } from '@atlaskit/editor-common/types';
104
- import type { LinkInputType } from '@atlaskit/editor-common/types';
105
100
  import { MacroAttributes } from '@atlaskit/editor-common/provider-factory';
106
101
  import { MacroProvider } from '@atlaskit/editor-common/provider-factory';
107
102
  import { MarkConfig } from '@atlaskit/editor-common/types';
@@ -164,7 +159,6 @@ import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
164
159
  import type { TypeAheadItem } from '@atlaskit/editor-common/types';
165
160
  import type { TypeAheadItem as TypeAheadItem_2 } from '@atlaskit/editor-common/provider-factory';
166
161
  import type { TypeAheadStats } from '@atlaskit/editor-common/types';
167
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
168
162
  import { UIComponentFactory } from '@atlaskit/editor-common/types';
169
163
  import { UploadEndEventPayload } from '@atlaskit/media-picker/types';
170
164
  import { UploadErrorEventPayload } from '@atlaskit/media-picker/types';
@@ -1216,13 +1210,6 @@ export interface HistoryPluginState {
1216
1210
  canUndo: boolean;
1217
1211
  }
1218
1212
 
1219
- export { HyperlinkInsertStatus };
1220
-
1221
- export { HyperlinkState };
1222
-
1223
- // @public @deprecated (undocumented)
1224
- export const hyperlinkStateKey: PluginKey<any>;
1225
-
1226
1213
  // @public (undocumented)
1227
1214
  function indentList(inputMethod?: InputMethod): Command;
1228
1215
 
@@ -1305,39 +1292,6 @@ type InsertItemProps = {
1305
1292
  sourceListItem: TypeAheadItem_2[];
1306
1293
  };
1307
1294
 
1308
- // @public @deprecated (undocumented)
1309
- export function insertLink(
1310
- from: number,
1311
- to: number,
1312
- incomingHref: string,
1313
- incomingTitle?: string,
1314
- displayText?: string,
1315
- source?: LinkInputType,
1316
- sourceEvent?: UIAnalyticsEvent | null | undefined,
1317
- ): Command_2;
1318
-
1319
- // @public @deprecated (undocumented)
1320
- export const insertLinkWithAnalytics: (
1321
- inputMethod: LinkInputType,
1322
- from: number,
1323
- to: number,
1324
- href: string,
1325
- title?: string,
1326
- displayText?: string,
1327
- cardsAvailable?: boolean,
1328
- sourceEvent?: UIAnalyticsEvent | null | undefined,
1329
- ) => Command_2;
1330
-
1331
- // @public @deprecated (undocumented)
1332
- export const insertLinkWithAnalyticsMobileNative: (
1333
- inputMethod: LinkInputType,
1334
- from: number,
1335
- to: number,
1336
- href: string,
1337
- title?: string,
1338
- displayText?: string,
1339
- ) => Command;
1340
-
1341
1295
  // @public (undocumented)
1342
1296
  export const insertMediaSingleNode: (
1343
1297
  view: EditorView,
@@ -1371,10 +1325,6 @@ type InviteToEditComponentProps = {
1371
1325
  children: ReactElement<InviteToEditButtonProps>;
1372
1326
  };
1373
1327
 
1374
- export { isLinkAtPos };
1375
-
1376
- export { isTextAtPos };
1377
-
1378
1328
  // @public (undocumented)
1379
1329
  interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
1380
1330
  // (undocumented)
@@ -2531,14 +2481,6 @@ interface TypeAheadStatsSerializable extends TypeAheadStats {
2531
2481
  // @public (undocumented)
2532
2482
  export type UpdateEvent = 'create' | 'delete' | 'resolve' | 'unresolve';
2533
2483
 
2534
- // @public @deprecated (undocumented)
2535
- export function updateLink(
2536
- href: string,
2537
- text: string,
2538
- pos: number,
2539
- to?: number,
2540
- ): Command_2;
2541
-
2542
2484
  // @public (undocumented)
2543
2485
  export const updateStatus: (status?: StatusType) => Command;
2544
2486
 
@@ -77,20 +77,15 @@ import { Side as GapCursorSide } from '@atlaskit/editor-common/selection';
77
77
  import { GetEditorFeatureFlags } from '@atlaskit/editor-common/types';
78
78
  import type { gridPlugin } from '@atlaskit/editor-plugin-grid';
79
79
  import { HeadingLevelsAndNormalText } from '@atlaskit/editor-common/types';
80
- import { InsertStatus as HyperlinkInsertStatus } from '@atlaskit/editor-common/link';
81
80
  import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
82
- import { HyperlinkState } from '@atlaskit/editor-common/link';
83
81
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
84
82
  import { InputMethodInsertMedia } from '@atlaskit/editor-common/analytics';
85
83
  import { InputTracking } from '@atlaskit/editor-common/types';
86
84
  import { IntlShape } from 'react-intl-next';
87
- import { isLinkAtPos } from '@atlaskit/editor-common/link';
88
- import { isTextAtPos } from '@atlaskit/editor-common/link';
89
85
  import { JSONDocNode } from '@atlaskit/editor-json-transformer/types';
90
86
  import { jsx } from '@emotion/react';
91
87
  import { lightModeStatusColorPalette } from '@atlaskit/editor-common/ui-color';
92
88
  import type { LinkingOptions } from '@atlaskit/editor-common/types';
93
- import type { LinkInputType } from '@atlaskit/editor-common/types';
94
89
  import { MacroAttributes } from '@atlaskit/editor-common/provider-factory';
95
90
  import { MacroProvider } from '@atlaskit/editor-common/provider-factory';
96
91
  import { MarkConfig } from '@atlaskit/editor-common/types';
@@ -153,7 +148,6 @@ import type { TypeAheadHandler } from '@atlaskit/editor-common/types';
153
148
  import type { TypeAheadItem } from '@atlaskit/editor-common/types';
154
149
  import type { TypeAheadItem as TypeAheadItem_2 } from '@atlaskit/editor-common/provider-factory';
155
150
  import type { TypeAheadStats } from '@atlaskit/editor-common/types';
156
- import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
157
151
  import { UIComponentFactory } from '@atlaskit/editor-common/types';
158
152
  import { UploadEndEventPayload } from '@atlaskit/media-picker/types';
159
153
  import { UploadErrorEventPayload } from '@atlaskit/media-picker/types';
@@ -1120,13 +1114,6 @@ export interface HistoryPluginState {
1120
1114
  canUndo: boolean;
1121
1115
  }
1122
1116
 
1123
- export { HyperlinkInsertStatus }
1124
-
1125
- export { HyperlinkState }
1126
-
1127
- // @public @deprecated (undocumented)
1128
- export const hyperlinkStateKey: PluginKey<any>;
1129
-
1130
1117
  // @public (undocumented)
1131
1118
  function indentList(inputMethod?: InputMethod): Command;
1132
1119
 
@@ -1187,15 +1174,6 @@ type InsertItemProps = {
1187
1174
  sourceListItem: TypeAheadItem_2[];
1188
1175
  };
1189
1176
 
1190
- // @public @deprecated (undocumented)
1191
- export function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command_2;
1192
-
1193
- // @public @deprecated (undocumented)
1194
- export const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command_2;
1195
-
1196
- // @public @deprecated (undocumented)
1197
- export const insertLinkWithAnalyticsMobileNative: (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string) => Command;
1198
-
1199
1177
  // @public (undocumented)
1200
1178
  export const insertMediaSingleNode: (view: EditorView, mediaState: MediaState, inputMethod?: InputMethodInsertMedia, collection?: string, alignLeftOnInsert?: boolean, newInsertionBehaviour?: boolean) => boolean;
1201
1179
 
@@ -1213,10 +1191,6 @@ type InviteToEditComponentProps = {
1213
1191
  children: ReactElement<InviteToEditButtonProps>;
1214
1192
  };
1215
1193
 
1216
- export { isLinkAtPos }
1217
-
1218
- export { isTextAtPos }
1219
-
1220
1194
  // @public (undocumented)
1221
1195
  interface LayoutPluginOptions extends LongPressSelectionPluginOptions {
1222
1196
  // (undocumented)
@@ -2242,9 +2216,6 @@ interface TypeAheadStatsSerializable extends TypeAheadStats {
2242
2216
  // @public (undocumented)
2243
2217
  export type UpdateEvent = 'create' | 'delete' | 'resolve' | 'unresolve';
2244
2218
 
2245
- // @public @deprecated (undocumented)
2246
- export function updateLink(href: string, text: string, pos: number, to?: number): Command_2;
2247
-
2248
2219
  // @public (undocumented)
2249
2220
  export const updateStatus: (status?: StatusType) => Command;
2250
2221
 
@@ -1,111 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.queueCardsFromChangedTr = void 0;
7
- var _card = require("@atlaskit/editor-common/card");
8
- var _utils = require("@atlaskit/editor-common/utils");
9
- var _adfSchema = require("@atlaskit/adf-schema");
10
- var _paste = require("@atlaskit/editor-common/paste");
11
- /**
12
- * WARNING!!!
13
- * Copied from `editor-plugin-card`.
14
- *
15
- * This workaround is used since we extracted the hyperlink + card plugins.
16
- * It is only used in `deprecated-hyperlink`. It should not be used internally or externally.
17
- *
18
- */
19
-
20
- // TODO: ED-15663
21
- // Please, do not copy or use this kind of code below
22
- // @ts-ignore
23
- var pluginKey = {
24
- key: 'cardPlugin$',
25
- getState: function getState(state) {
26
- return state['cardPlugin$'];
27
- }
28
- };
29
- function shouldReplaceLink(node) {
30
- var compareLinkText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
31
- var compareToUrl = arguments.length > 2 ? arguments[2] : undefined;
32
- var linkMark = node.marks.find(function (mark) {
33
- return mark.type.name === 'link';
34
- });
35
- if (!linkMark) {
36
- // not a link anymore
37
- return false;
38
- }
39
-
40
- // ED-6041: compare normalised link text after linkfy from Markdown transformer
41
- // instead, since it always decodes URL ('%20' -> ' ') on the link text
42
-
43
- var normalisedHref = (0, _adfSchema.normalizeUrl)(_paste.md.normalizeLinkText(linkMark.attrs.href));
44
- var normalizedLinkText = (0, _adfSchema.normalizeUrl)(_paste.md.normalizeLinkText(node.text || ''));
45
- if (compareLinkText && normalisedHref !== normalizedLinkText) {
46
- return false;
47
- }
48
- if (compareToUrl) {
49
- var normalizedUrl = (0, _adfSchema.normalizeUrl)(_paste.md.normalizeLinkText(compareToUrl));
50
- if (normalizedUrl !== normalisedHref) {
51
- return false;
52
- }
53
- }
54
- return true;
55
- }
56
- var cardAction = function cardAction(tr, action) {
57
- return tr.setMeta(pluginKey, action);
58
- };
59
- var queueCards = function queueCards(requests) {
60
- return function (tr) {
61
- return cardAction(tr, {
62
- type: 'QUEUE',
63
- requests: requests
64
- });
65
- };
66
- };
67
-
68
- /**
69
- * @private
70
- * @deprecated
71
- *
72
- * DO NOT USE THIS
73
- * It is only used internally for `deprecated-hyperlink`.
74
- */
75
- var queueCardsFromChangedTr = function queueCardsFromChangedTr(state, tr, source, analyticsAction) {
76
- var normalizeLinkText = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
77
- var sourceEvent = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : undefined;
78
- var schema = state.schema;
79
- var link = schema.marks.link;
80
- var requests = [];
81
- (0, _utils.nodesBetweenChanged)(tr, function (node, pos) {
82
- if (!node.isText) {
83
- return true;
84
- }
85
- var linkMark = node.marks.find(function (mark) {
86
- return mark.type === link;
87
- });
88
- if (linkMark) {
89
- if (!shouldReplaceLink(node, normalizeLinkText)) {
90
- return false;
91
- }
92
- requests.push({
93
- url: linkMark.attrs.href,
94
- pos: pos,
95
- appearance: 'inline',
96
- compareLinkText: normalizeLinkText,
97
- source: source,
98
- analyticsAction: analyticsAction,
99
- sourceEvent: sourceEvent
100
- });
101
- }
102
- return false;
103
- });
104
- if (analyticsAction) {
105
- (0, _card.addLinkMetadata)(state.selection, tr, {
106
- action: analyticsAction
107
- });
108
- }
109
- return queueCards(requests)(tr);
110
- };
111
- exports.queueCardsFromChangedTr = queueCardsFromChangedTr;
@@ -1,164 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.insertLink = insertLink;
8
- exports.stateKey = exports.insertLinkWithAnalyticsMobileNative = exports.insertLinkWithAnalytics = void 0;
9
- exports.updateLink = updateLink;
10
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var _card = require("@atlaskit/editor-common/card");
12
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
- var _link = require("@atlaskit/editor-common/link");
14
- var _utils = require("@atlaskit/editor-common/utils");
15
- var _prosemirrorState = require("prosemirror-state");
16
- var _analytics = require("@atlaskit/editor-common/analytics");
17
- var _analytics2 = require("../analytics");
18
- var _doc = require("../deprecated-card/doc");
19
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
- // TODO: ED-17836 This workaround is used since we extracted the hyperlink plugin.
22
- // As soon as we deprecate the plugin we can delete this code.
23
- /**
24
- * @deprecated
25
- * Please do not use this key anymore it will be removed soon.
26
- * Using plugin keys is a deprecated approach and if you need
27
- * to access state use the Preset API in EditorNext.
28
- */
29
- var stateKey = {
30
- key: 'hyperlinkPlugin$',
31
- getState: function getState(state) {
32
- return state['hyperlinkPlugin$'];
33
- }
34
- };
35
-
36
- /**
37
- * @deprecated
38
- * Please do not use this function anymore it will be removed soon.
39
- * If you need to update the link please do it through the Preset
40
- * API in EditorNext.
41
- */
42
- exports.stateKey = stateKey;
43
- function updateLink(href, text, pos, to) {
44
- return function (state, dispatch) {
45
- var $pos = state.doc.resolve(pos);
46
- var node = state.doc.nodeAt(pos);
47
- if (!node) {
48
- return false;
49
- }
50
- var url = (0, _utils.normalizeUrl)(href);
51
- var mark = state.schema.marks.link.isInSet(node.marks);
52
- var linkMark = state.schema.marks.link;
53
- var rightBound = to && pos !== to ? to : pos - $pos.textOffset + node.nodeSize;
54
- var tr = state.tr;
55
- if (!url && text) {
56
- tr.removeMark(pos, rightBound, linkMark);
57
- tr.insertText(text, pos, rightBound);
58
- } else if (!url) {
59
- return false;
60
- } else {
61
- tr.insertText(text, pos, rightBound);
62
- // Casting to LinkAttributes to prevent wrong attributes been passed (Example ED-7951)
63
- var linkAttrs = _objectSpread(_objectSpread({}, mark && mark.attrs || {}), {}, {
64
- href: url
65
- });
66
- tr.addMark(pos, pos + text.length, linkMark.create(linkAttrs));
67
- tr.setMeta(stateKey, {
68
- type: _link.LinkAction.HIDE_TOOLBAR
69
- });
70
- }
71
- if (dispatch) {
72
- dispatch(tr);
73
- }
74
- return true;
75
- };
76
- }
77
-
78
- /**
79
- * @deprecated
80
- * Please do not use this function anymore it will be removed soon.
81
- * If you need to insert link please do it through the Preset
82
- * API in EditorNext.
83
- */
84
- function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent) {
85
- return function (state, dispatch) {
86
- var link = state.schema.marks.link;
87
- var tr = state.tr;
88
- if (incomingHref.trim()) {
89
- var _stateKey$getState;
90
- var normalizedUrl = (0, _utils.normalizeUrl)(incomingHref);
91
- // NB: in this context, `currentText` represents text which has been
92
- // highlighted in the Editor, upon which a link is is being added.
93
- var currentText = (_stateKey$getState = stateKey.getState(state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.activeText;
94
- var markEnd = to;
95
- var text = displayText || incomingTitle || incomingHref;
96
- if (!displayText || displayText !== currentText) {
97
- tr.insertText(text, from, to);
98
- if (!(0, _link.isTextAtPos)(from)(state)) {
99
- markEnd = from + text.length + 1;
100
- } else {
101
- markEnd = from + text.length;
102
- }
103
- }
104
- tr.addMark(from, markEnd, link.create({
105
- href: normalizedUrl
106
- }));
107
- tr.setSelection(_prosemirrorState.Selection.near(tr.doc.resolve(markEnd)));
108
- if (!displayText || displayText === incomingHref) {
109
- (0, _doc.queueCardsFromChangedTr)(state, tr, source, _analytics.ACTION.INSERTED, false, sourceEvent);
110
- } else if ((0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.editor.fix-link-insert-analytics')) {
111
- /**
112
- * Add link metadata because queue cards would have otherwise handled this for us
113
- */
114
- (0, _card.addLinkMetadata)(state.selection, tr, {
115
- action: _analytics.ACTION.INSERTED,
116
- inputMethod: source,
117
- sourceEvent: sourceEvent
118
- });
119
- }
120
- tr.setMeta(stateKey, {
121
- type: _link.LinkAction.HIDE_TOOLBAR
122
- });
123
- if (dispatch) {
124
- dispatch(tr);
125
- }
126
- return true;
127
- }
128
- tr.setMeta(stateKey, {
129
- type: _link.LinkAction.HIDE_TOOLBAR
130
- });
131
- if (dispatch) {
132
- dispatch(tr);
133
- }
134
- return false;
135
- };
136
- }
137
-
138
- /**
139
- * @deprecated
140
- * Please do not use this function anymore it will be removed soon.
141
- * If you need to insert link please do it through the Preset
142
- * API in EditorNext.
143
- */
144
- var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, title, displayText) {
145
- var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
146
- var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
147
- // If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
148
- if (cardsAvailable && !title && !displayText) {
149
- return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent);
150
- }
151
- return (0, _analytics2.withAnalytics)((0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
152
- };
153
-
154
- /**
155
- * @deprecated
156
- * Please do not use this function anymore it will be removed soon.
157
- * If you need to insert link please do it through the Preset
158
- * API in EditorNext.
159
- */
160
- exports.insertLinkWithAnalytics = insertLinkWithAnalytics;
161
- var insertLinkWithAnalyticsMobileNative = function insertLinkWithAnalyticsMobileNative(inputMethod, from, to, href, title, displayText) {
162
- return (0, _analytics2.withAnalytics)((0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
163
- };
164
- exports.insertLinkWithAnalyticsMobileNative = insertLinkWithAnalyticsMobileNative;
@@ -1,97 +0,0 @@
1
- /**
2
- * WARNING!!!
3
- * Copied from `editor-plugin-card`.
4
- *
5
- * This workaround is used since we extracted the hyperlink + card plugins.
6
- * It is only used in `deprecated-hyperlink`. It should not be used internally or externally.
7
- *
8
- */
9
-
10
- import { addLinkMetadata } from '@atlaskit/editor-common/card';
11
- import { nodesBetweenChanged } from '@atlaskit/editor-common/utils';
12
- import { normalizeUrl } from '@atlaskit/adf-schema';
13
- import { md } from '@atlaskit/editor-common/paste';
14
-
15
- // TODO: ED-15663
16
- // Please, do not copy or use this kind of code below
17
- // @ts-ignore
18
- const pluginKey = {
19
- key: 'cardPlugin$',
20
- getState: state => {
21
- return state['cardPlugin$'];
22
- }
23
- };
24
- function shouldReplaceLink(node, compareLinkText = true, compareToUrl) {
25
- const linkMark = node.marks.find(mark => mark.type.name === 'link');
26
- if (!linkMark) {
27
- // not a link anymore
28
- return false;
29
- }
30
-
31
- // ED-6041: compare normalised link text after linkfy from Markdown transformer
32
- // instead, since it always decodes URL ('%20' -> ' ') on the link text
33
-
34
- const normalisedHref = normalizeUrl(md.normalizeLinkText(linkMark.attrs.href));
35
- const normalizedLinkText = normalizeUrl(md.normalizeLinkText(node.text || ''));
36
- if (compareLinkText && normalisedHref !== normalizedLinkText) {
37
- return false;
38
- }
39
- if (compareToUrl) {
40
- const normalizedUrl = normalizeUrl(md.normalizeLinkText(compareToUrl));
41
- if (normalizedUrl !== normalisedHref) {
42
- return false;
43
- }
44
- }
45
- return true;
46
- }
47
- const cardAction = (tr, action) => {
48
- return tr.setMeta(pluginKey, action);
49
- };
50
- const queueCards = requests => tr => cardAction(tr, {
51
- type: 'QUEUE',
52
- requests: requests
53
- });
54
-
55
- /**
56
- * @private
57
- * @deprecated
58
- *
59
- * DO NOT USE THIS
60
- * It is only used internally for `deprecated-hyperlink`.
61
- */
62
- export const queueCardsFromChangedTr = (state, tr, source, analyticsAction, normalizeLinkText = true, sourceEvent = undefined) => {
63
- const {
64
- schema
65
- } = state;
66
- const {
67
- link
68
- } = schema.marks;
69
- const requests = [];
70
- nodesBetweenChanged(tr, (node, pos) => {
71
- if (!node.isText) {
72
- return true;
73
- }
74
- const linkMark = node.marks.find(mark => mark.type === link);
75
- if (linkMark) {
76
- if (!shouldReplaceLink(node, normalizeLinkText)) {
77
- return false;
78
- }
79
- requests.push({
80
- url: linkMark.attrs.href,
81
- pos,
82
- appearance: 'inline',
83
- compareLinkText: normalizeLinkText,
84
- source,
85
- analyticsAction,
86
- sourceEvent
87
- });
88
- }
89
- return false;
90
- });
91
- if (analyticsAction) {
92
- addLinkMetadata(state.selection, tr, {
93
- action: analyticsAction
94
- });
95
- }
96
- return queueCards(requests)(tr);
97
- };