@atlaskit/editor-plugin-hyperlink 0.6.3 → 0.6.5
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 +13 -0
- package/dist/cjs/commands.js +5 -3
- package/dist/cjs/plugin.js +2 -1
- package/dist/es2019/commands.js +5 -5
- package/dist/es2019/plugin.js +2 -2
- package/dist/esm/commands.js +5 -3
- package/dist/esm/plugin.js +2 -1
- package/dist/types/commands.d.ts +4 -3
- package/dist/types-ts4.5/commands.d.ts +4 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 0.6.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#58193](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58193) [`4bf69e3255f8`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4bf69e3255f8) - NO-ISSUE Added the capability to override the default card type of inline when inserting links, so we can have Loom links convert to embed cards
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 0.6.4
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [#58763](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/58763) [`0fdbd64522bf`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0fdbd64522bf) - update ADF schema
|
|
15
|
+
|
|
3
16
|
## 0.6.3
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -89,6 +89,7 @@ function updateLink(href, text, pos, to) {
|
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent) {
|
|
92
|
+
var appearance = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'inline';
|
|
92
93
|
return function (state, dispatch) {
|
|
93
94
|
var link = state.schema.marks.link;
|
|
94
95
|
var tr = state.tr;
|
|
@@ -116,7 +117,7 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
116
117
|
var _toolbarKey$getState;
|
|
117
118
|
var queueCardsFromChangedTr = (_toolbarKey$getState = _toolbarButtons.toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
118
119
|
if (queueCardsFromChangedTr) {
|
|
119
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, _analytics.ACTION.INSERTED, false, sourceEvent);
|
|
120
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, _analytics.ACTION.INSERTED, false, sourceEvent, appearance);
|
|
120
121
|
} else {
|
|
121
122
|
(0, _card.addLinkMetadata)(state.selection, tr, {
|
|
122
123
|
action: _analytics.ACTION.INSERTED,
|
|
@@ -154,11 +155,12 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
154
155
|
var insertLinkWithAnalytics = exports.insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
155
156
|
var cardsAvailable = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
156
157
|
var sourceEvent = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : undefined;
|
|
158
|
+
var appearance = arguments.length > 9 ? arguments[9] : undefined;
|
|
157
159
|
// If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
|
|
158
160
|
if (cardsAvailable && !title && !displayText) {
|
|
159
|
-
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent);
|
|
161
|
+
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance);
|
|
160
162
|
}
|
|
161
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, (0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
163
|
+
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, (0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance));
|
|
162
164
|
};
|
|
163
165
|
function removeLink(pos, editorAnalyticsApi) {
|
|
164
166
|
return (0, _card.commandWithMetadata)(setLinkHref('', pos, editorAnalyticsApi), {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -51,7 +51,8 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
51
51
|
var _api$analytics2;
|
|
52
52
|
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
53
53
|
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
54
|
-
|
|
54
|
+
var appearance = arguments.length > 8 ? arguments[8] : undefined;
|
|
55
|
+
return (0, _commands.insertLinkWithAnalytics)(inputMethod, from, to, href, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent, appearance);
|
|
55
56
|
},
|
|
56
57
|
updateLink: _commands.updateLink
|
|
57
58
|
},
|
package/dist/es2019/commands.js
CHANGED
|
@@ -72,7 +72,7 @@ export function updateLink(href, text, pos, to) {
|
|
|
72
72
|
return true;
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
|
-
export function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent) {
|
|
75
|
+
export function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent, appearance = 'inline') {
|
|
76
76
|
return (state, dispatch) => {
|
|
77
77
|
const link = state.schema.marks.link;
|
|
78
78
|
const {
|
|
@@ -102,7 +102,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
102
102
|
var _toolbarKey$getState;
|
|
103
103
|
const queueCardsFromChangedTr = (_toolbarKey$getState = toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
104
104
|
if (queueCardsFromChangedTr) {
|
|
105
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent);
|
|
105
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 ? void 0 : queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent, appearance);
|
|
106
106
|
} else {
|
|
107
107
|
addLinkMetadata(state.selection, tr, {
|
|
108
108
|
action: ACTION.INSERTED,
|
|
@@ -137,12 +137,12 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
137
137
|
return false;
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
export const insertLinkWithAnalytics = (inputMethod, from, to, href, editorAnalyticsApi, title, displayText, cardsAvailable = false, sourceEvent = undefined) => {
|
|
140
|
+
export const insertLinkWithAnalytics = (inputMethod, from, to, href, editorAnalyticsApi, title, displayText, cardsAvailable = false, sourceEvent = undefined, appearance) => {
|
|
141
141
|
// If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
|
|
142
142
|
if (cardsAvailable && !title && !displayText) {
|
|
143
|
-
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent);
|
|
143
|
+
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance);
|
|
144
144
|
}
|
|
145
|
-
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
145
|
+
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance));
|
|
146
146
|
};
|
|
147
147
|
export function removeLink(pos, editorAnalyticsApi) {
|
|
148
148
|
return commandWithMetadata(setLinkHref('', pos, editorAnalyticsApi), {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -39,9 +39,9 @@ export const hyperlinkPlugin = ({
|
|
|
39
39
|
actions: {
|
|
40
40
|
prependToolbarButtons,
|
|
41
41
|
hideLinkToolbar: hideLinkToolbarSetMeta,
|
|
42
|
-
insertLink: (inputMethod, from, to, href, title, displayText, cardsAvailable = false, sourceEvent = undefined) => {
|
|
42
|
+
insertLink: (inputMethod, from, to, href, title, displayText, cardsAvailable = false, sourceEvent = undefined, appearance) => {
|
|
43
43
|
var _api$analytics2;
|
|
44
|
-
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
44
|
+
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent, appearance);
|
|
45
45
|
},
|
|
46
46
|
updateLink: updateLink
|
|
47
47
|
},
|
package/dist/esm/commands.js
CHANGED
|
@@ -74,6 +74,7 @@ export function updateLink(href, text, pos, to) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
export function insertLink(from, to, incomingHref, incomingTitle, displayText, source, sourceEvent) {
|
|
77
|
+
var appearance = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : 'inline';
|
|
77
78
|
return function (state, dispatch) {
|
|
78
79
|
var link = state.schema.marks.link;
|
|
79
80
|
var tr = state.tr;
|
|
@@ -101,7 +102,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
101
102
|
var _toolbarKey$getState;
|
|
102
103
|
var queueCardsFromChangedTr = (_toolbarKey$getState = toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
103
104
|
if (queueCardsFromChangedTr) {
|
|
104
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent);
|
|
105
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent, appearance);
|
|
105
106
|
} else {
|
|
106
107
|
addLinkMetadata(state.selection, tr, {
|
|
107
108
|
action: ACTION.INSERTED,
|
|
@@ -139,11 +140,12 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
139
140
|
export var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
140
141
|
var cardsAvailable = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
141
142
|
var sourceEvent = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : undefined;
|
|
143
|
+
var appearance = arguments.length > 9 ? arguments[9] : undefined;
|
|
142
144
|
// If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
|
|
143
145
|
if (cardsAvailable && !title && !displayText) {
|
|
144
|
-
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent);
|
|
146
|
+
return insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance);
|
|
145
147
|
}
|
|
146
|
-
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
148
|
+
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent, appearance));
|
|
147
149
|
};
|
|
148
150
|
export function removeLink(pos, editorAnalyticsApi) {
|
|
149
151
|
return commandWithMetadata(setLinkHref('', pos, editorAnalyticsApi), {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -44,7 +44,8 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
44
44
|
var _api$analytics2;
|
|
45
45
|
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
46
46
|
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
47
|
-
|
|
47
|
+
var appearance = arguments.length > 8 ? arguments[8] : undefined;
|
|
48
|
+
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent, appearance);
|
|
48
49
|
},
|
|
49
50
|
updateLink: updateLink
|
|
50
51
|
},
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
4
5
|
import type { Command, EditorCommand, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
8
|
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
8
9
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
9
|
-
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
10
|
-
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
11
|
-
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
10
|
+
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance): Command;
|
|
11
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Command;
|
|
12
|
+
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Command;
|
|
12
13
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
13
14
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
14
15
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
2
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import type { CardAppearance } from '@atlaskit/editor-common/provider-factory';
|
|
4
5
|
import type { Command, EditorCommand, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
6
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
7
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
8
|
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
8
9
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
9
|
-
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
10
|
-
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
11
|
-
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
10
|
+
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance): Command;
|
|
11
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Command;
|
|
12
|
+
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined, appearance?: CardAppearance) => Command;
|
|
12
13
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
13
14
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
14
15
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,9 +31,9 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^
|
|
34
|
+
"@atlaskit/adf-schema": "^35.0.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^76.
|
|
36
|
+
"@atlaskit/editor-common": "^76.25.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "1.1.0",
|