@atlaskit/editor-plugin-hyperlink 0.1.0 → 0.2.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/.eslintrc.js +1 -0
- package/CHANGELOG.md +58 -0
- package/dist/cjs/commands.js +5 -9
- package/dist/cjs/plugin.js +12 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands.js +0 -3
- package/dist/es2019/plugin.js +11 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands.js +4 -7
- package/dist/esm/plugin.js +13 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/commands.d.ts +2 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types-ts4.5/commands.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +3 -1
- package/package.json +2 -2
- package/report.api.md +24 -0
- package/tmp/api-report-tmp.d.ts +78 -0
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,59 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`8e084d87da5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8e084d87da5) - Remove deprecated hyperlink commands and plugin key including:
|
|
8
|
+
|
|
9
|
+
- isTextAtPos
|
|
10
|
+
- isLinkAtPos
|
|
11
|
+
- insertLink
|
|
12
|
+
- insertLinkWithAnalyticsMobileNative
|
|
13
|
+
- insertLinkWithAnalytics
|
|
14
|
+
- updateLink
|
|
15
|
+
- hyperlinkStateKey
|
|
16
|
+
|
|
17
|
+
If you require `isTextAtPos` or `isLinkAtPos` these can be accessed via `editor-common`:
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { isTextAtPos, isLinkAtPos } from '@atlaskit/editor-common/link`;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
If you require `insertLink`, `updateLink`, or `hyperlinkStateKey` you can access these via the new composable editor using a custom plugin. Here is an example:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { Editor } from '@atlaskit/editor-core/composable-editor';
|
|
27
|
+
import { EditorProps } from '@atlaskit/editor-core';
|
|
28
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
29
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
30
|
+
import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
31
|
+
|
|
32
|
+
const customPlugin: NextEditorPlugin<'custom', {
|
|
33
|
+
dependencies: [typeof hyperlinkPlugin]
|
|
34
|
+
}> = (_, api) => {
|
|
35
|
+
// Can access insertLink and updateLink here
|
|
36
|
+
api?.dependencies.hyperlink.actions.insertLink( ... )
|
|
37
|
+
api?.dependencies.hyperlink.actions.updateLink( ... )
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
// Rather than using the `hyperlinkStateKey` you can access via `sharedState`
|
|
41
|
+
api?.dependencies.hyperlink.sharedState.onChange(({ nextSharedState }) => {
|
|
42
|
+
// subscribe to changes
|
|
43
|
+
})
|
|
44
|
+
// OR for current value
|
|
45
|
+
api?.dependencies.hyperlink.sharedState.currentState()
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
name: 'custom'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// This function is the equivalent of `Editor` from `editor-core`
|
|
53
|
+
function EditorWrapped(props: EditorProps) {
|
|
54
|
+
const preset = useUniversalPreset(props).add(customPlugin)
|
|
55
|
+
return <Editor preset={preset} ... />
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Note: By default `insertLink` via this interface is `insertLinkWithAnalytics`, however if you want to disable analytics disable them via the `EditorProps` and if you want to run `insertLinkWithAnalyticsMobileNative` pass `cardsAvailable` parameter as `false` (default).
|
package/dist/cjs/commands.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.editInsertedLink = editInsertedLink;
|
|
|
8
8
|
exports.hideLinkToolbar = hideLinkToolbar;
|
|
9
9
|
exports.hideLinkToolbarSetMeta = void 0;
|
|
10
10
|
exports.insertLink = insertLink;
|
|
11
|
-
exports.onEscapeCallback = exports.onClickAwayCallback = exports.
|
|
11
|
+
exports.onEscapeCallback = exports.onClickAwayCallback = exports.insertLinkWithAnalytics = void 0;
|
|
12
12
|
exports.removeLink = removeLink;
|
|
13
13
|
exports.setLinkHref = setLinkHref;
|
|
14
14
|
exports.showLinkToolbar = showLinkToolbar;
|
|
@@ -100,13 +100,13 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
100
100
|
// highlighted in the Editor, upon which a link is is being added.
|
|
101
101
|
var currentText = (_stateKey$getState = _main.stateKey.getState(state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.activeText;
|
|
102
102
|
var markEnd = to;
|
|
103
|
-
var
|
|
103
|
+
var _text = displayText || incomingTitle || incomingHref;
|
|
104
104
|
if (!displayText || displayText !== currentText) {
|
|
105
|
-
tr.insertText(
|
|
105
|
+
tr.insertText(_text, from, to);
|
|
106
106
|
if (!(0, _link.isTextAtPos)(from)(state)) {
|
|
107
|
-
markEnd = from +
|
|
107
|
+
markEnd = from + _text.length + 1;
|
|
108
108
|
} else {
|
|
109
|
-
markEnd = from +
|
|
109
|
+
markEnd = from + _text.length;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
tr.addMark(from, markEnd, link.create({
|
|
@@ -162,10 +162,6 @@ var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from
|
|
|
162
162
|
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, (0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
163
163
|
};
|
|
164
164
|
exports.insertLinkWithAnalytics = insertLinkWithAnalytics;
|
|
165
|
-
var insertLinkWithAnalyticsMobileNative = function insertLinkWithAnalyticsMobileNative(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
166
|
-
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, (0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
|
|
167
|
-
};
|
|
168
|
-
exports.insertLinkWithAnalyticsMobileNative = insertLinkWithAnalyticsMobileNative;
|
|
169
165
|
function removeLink(pos, editorAnalyticsApi) {
|
|
170
166
|
return (0, _card.commandWithMetadata)(setLinkHref('', pos, editorAnalyticsApi), {
|
|
171
167
|
action: _analytics.ACTION.UNLINK
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -39,7 +39,14 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
39
39
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
40
40
|
return (0, _commands.showLinkToolbar)(inputMethod, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
41
41
|
},
|
|
42
|
-
hideLinkToolbar: _commands.hideLinkToolbarSetMeta
|
|
42
|
+
hideLinkToolbar: _commands.hideLinkToolbarSetMeta,
|
|
43
|
+
insertLink: function insertLink(inputMethod, from, to, href, title, displayText) {
|
|
44
|
+
var _api$dependencies$ana2;
|
|
45
|
+
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
46
|
+
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
47
|
+
return (0, _commands.insertLinkWithAnalytics)(inputMethod, from, to, href, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
48
|
+
},
|
|
49
|
+
updateLink: _commands.updateLink
|
|
43
50
|
},
|
|
44
51
|
getSharedState: function getSharedState(editorState) {
|
|
45
52
|
if (!editorState) {
|
|
@@ -66,16 +73,16 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
66
73
|
}, {
|
|
67
74
|
name: 'hyperlinkInputRule',
|
|
68
75
|
plugin: function plugin(_ref2) {
|
|
69
|
-
var _api$dependencies$
|
|
76
|
+
var _api$dependencies$ana3;
|
|
70
77
|
var schema = _ref2.schema,
|
|
71
78
|
featureFlags = _ref2.featureFlags;
|
|
72
|
-
return (0, _inputRule.createInputRulePlugin)(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
79
|
+
return (0, _inputRule.createInputRulePlugin)(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions);
|
|
73
80
|
}
|
|
74
81
|
}, {
|
|
75
82
|
name: 'hyperlinkKeymap',
|
|
76
83
|
plugin: function plugin() {
|
|
77
|
-
var _api$dependencies$
|
|
78
|
-
return (0, _keymap.createKeymapPlugin)(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
84
|
+
var _api$dependencies$ana4;
|
|
85
|
+
return (0, _keymap.createKeymapPlugin)(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
|
|
79
86
|
}
|
|
80
87
|
}, {
|
|
81
88
|
name: 'hyperlinkToolbarButtons',
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/commands.js
CHANGED
|
@@ -145,9 +145,6 @@ export const insertLinkWithAnalytics = (inputMethod, from, to, href, editorAnaly
|
|
|
145
145
|
}
|
|
146
146
|
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
147
147
|
};
|
|
148
|
-
export const insertLinkWithAnalyticsMobileNative = (inputMethod, from, to, href, editorAnalyticsApi, title, displayText) => {
|
|
149
|
-
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
|
|
150
|
-
};
|
|
151
148
|
export function removeLink(pos, editorAnalyticsApi) {
|
|
152
149
|
return commandWithMetadata(setLinkHref('', pos, editorAnalyticsApi), {
|
|
153
150
|
action: ACTION.UNLINK
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ import { addLink, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
|
5
5
|
import { LinkAction } from '@atlaskit/editor-common/link';
|
|
6
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import { hideLinkToolbarSetMeta, showLinkToolbar } from './commands';
|
|
8
|
+
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, showLinkToolbar, updateLink } from './commands';
|
|
9
9
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
10
10
|
import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
11
11
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
@@ -29,7 +29,12 @@ export const hyperlinkPlugin = (options = {}, api) => {
|
|
|
29
29
|
var _api$dependencies$ana;
|
|
30
30
|
return showLinkToolbar(inputMethod, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
31
31
|
},
|
|
32
|
-
hideLinkToolbar: hideLinkToolbarSetMeta
|
|
32
|
+
hideLinkToolbar: hideLinkToolbarSetMeta,
|
|
33
|
+
insertLink: (inputMethod, from, to, href, title, displayText, cardsAvailable = false, sourceEvent = undefined) => {
|
|
34
|
+
var _api$dependencies$ana2;
|
|
35
|
+
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
36
|
+
},
|
|
37
|
+
updateLink: updateLink
|
|
33
38
|
},
|
|
34
39
|
getSharedState(editorState) {
|
|
35
40
|
if (!editorState) {
|
|
@@ -56,14 +61,14 @@ export const hyperlinkPlugin = (options = {}, api) => {
|
|
|
56
61
|
schema,
|
|
57
62
|
featureFlags
|
|
58
63
|
}) => {
|
|
59
|
-
var _api$dependencies$
|
|
60
|
-
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
64
|
+
var _api$dependencies$ana3;
|
|
65
|
+
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions);
|
|
61
66
|
}
|
|
62
67
|
}, {
|
|
63
68
|
name: 'hyperlinkKeymap',
|
|
64
69
|
plugin: () => {
|
|
65
|
-
var _api$dependencies$
|
|
66
|
-
return createKeymapPlugin(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
70
|
+
var _api$dependencies$ana4;
|
|
71
|
+
return createKeymapPlugin(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
|
|
67
72
|
}
|
|
68
73
|
}, {
|
|
69
74
|
name: 'hyperlinkToolbarButtons',
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/commands.js
CHANGED
|
@@ -85,13 +85,13 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
85
85
|
// highlighted in the Editor, upon which a link is is being added.
|
|
86
86
|
var currentText = (_stateKey$getState = stateKey.getState(state)) === null || _stateKey$getState === void 0 ? void 0 : _stateKey$getState.activeText;
|
|
87
87
|
var markEnd = to;
|
|
88
|
-
var
|
|
88
|
+
var _text = displayText || incomingTitle || incomingHref;
|
|
89
89
|
if (!displayText || displayText !== currentText) {
|
|
90
|
-
tr.insertText(
|
|
90
|
+
tr.insertText(_text, from, to);
|
|
91
91
|
if (!isTextAtPos(from)(state)) {
|
|
92
|
-
markEnd = from +
|
|
92
|
+
markEnd = from + _text.length + 1;
|
|
93
93
|
} else {
|
|
94
|
-
markEnd = from +
|
|
94
|
+
markEnd = from + _text.length;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
tr.addMark(from, markEnd, link.create({
|
|
@@ -146,9 +146,6 @@ export var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMetho
|
|
|
146
146
|
}
|
|
147
147
|
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
148
148
|
};
|
|
149
|
-
export var insertLinkWithAnalyticsMobileNative = function insertLinkWithAnalyticsMobileNative(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
150
|
-
return withAnalytics(editorAnalyticsApi, getLinkCreationAnalyticsEvent(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod));
|
|
151
|
-
};
|
|
152
149
|
export function removeLink(pos, editorAnalyticsApi) {
|
|
153
150
|
return commandWithMetadata(setLinkHref('', pos, editorAnalyticsApi), {
|
|
154
151
|
action: ACTION.UNLINK
|
package/dist/esm/plugin.js
CHANGED
|
@@ -5,7 +5,7 @@ import { addLink, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
|
5
5
|
import { LinkAction } from '@atlaskit/editor-common/link';
|
|
6
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
8
|
-
import { hideLinkToolbarSetMeta, showLinkToolbar as _showLinkToolbar } from './commands';
|
|
8
|
+
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, showLinkToolbar as _showLinkToolbar, updateLink } from './commands';
|
|
9
9
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
10
10
|
import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
11
11
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
@@ -32,7 +32,14 @@ export var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
32
32
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.TOOLBAR;
|
|
33
33
|
return _showLinkToolbar(inputMethod, api === null || api === void 0 ? void 0 : (_api$dependencies$ana = api.dependencies.analytics) === null || _api$dependencies$ana === void 0 ? void 0 : _api$dependencies$ana.actions);
|
|
34
34
|
},
|
|
35
|
-
hideLinkToolbar: hideLinkToolbarSetMeta
|
|
35
|
+
hideLinkToolbar: hideLinkToolbarSetMeta,
|
|
36
|
+
insertLink: function insertLink(inputMethod, from, to, href, title, displayText) {
|
|
37
|
+
var _api$dependencies$ana2;
|
|
38
|
+
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
39
|
+
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
40
|
+
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 ? void 0 : (_api$dependencies$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
41
|
+
},
|
|
42
|
+
updateLink: updateLink
|
|
36
43
|
},
|
|
37
44
|
getSharedState: function getSharedState(editorState) {
|
|
38
45
|
if (!editorState) {
|
|
@@ -59,16 +66,16 @@ export var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
59
66
|
}, {
|
|
60
67
|
name: 'hyperlinkInputRule',
|
|
61
68
|
plugin: function plugin(_ref2) {
|
|
62
|
-
var _api$dependencies$
|
|
69
|
+
var _api$dependencies$ana3;
|
|
63
70
|
var schema = _ref2.schema,
|
|
64
71
|
featureFlags = _ref2.featureFlags;
|
|
65
|
-
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
72
|
+
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0 ? void 0 : (_api$dependencies$ana3 = api.dependencies.analytics) === null || _api$dependencies$ana3 === void 0 ? void 0 : _api$dependencies$ana3.actions);
|
|
66
73
|
}
|
|
67
74
|
}, {
|
|
68
75
|
name: 'hyperlinkKeymap',
|
|
69
76
|
plugin: function plugin() {
|
|
70
|
-
var _api$dependencies$
|
|
71
|
-
return createKeymapPlugin(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$
|
|
77
|
+
var _api$dependencies$ana4;
|
|
78
|
+
return createKeymapPlugin(skipAnalytics, api === null || api === void 0 ? void 0 : (_api$dependencies$ana4 = api.dependencies.analytics) === null || _api$dependencies$ana4 === void 0 ? void 0 : _api$dependencies$ana4.actions);
|
|
72
79
|
}
|
|
73
80
|
}, {
|
|
74
81
|
name: 'hyperlinkToolbarButtons',
|
package/dist/esm/version.json
CHANGED
package/dist/types/commands.d.ts
CHANGED
|
@@ -3,10 +3,11 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
|
3
3
|
import { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
5
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
6
|
+
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
6
7
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
7
8
|
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
9
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
8
10
|
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;
|
|
9
|
-
export declare const insertLinkWithAnalyticsMobileNative: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string) => Command;
|
|
10
11
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
11
12
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
12
13
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { hyperlinkPlugin } from './plugin';
|
|
2
|
-
export type { HideLinkToolbar, ShowLinkToolbar } from './commands';
|
|
2
|
+
export type { HideLinkToolbar, ShowLinkToolbar, InsertLink, UpdateLink, } from './commands';
|
|
3
3
|
export type { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
|
2
2
|
import type { HyperlinkPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
5
|
-
import { HideLinkToolbar, ShowLinkToolbar } from './commands';
|
|
5
|
+
import { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
6
|
import { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
7
7
|
export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
8
8
|
pluginConfiguration: HyperlinkPluginOptions | undefined;
|
|
@@ -33,6 +33,8 @@ export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
|
33
33
|
*/
|
|
34
34
|
showLinkToolbar: ShowLinkToolbar;
|
|
35
35
|
hideLinkToolbar: HideLinkToolbar;
|
|
36
|
+
insertLink: InsertLink;
|
|
37
|
+
updateLink: UpdateLink;
|
|
36
38
|
};
|
|
37
39
|
sharedState: HyperlinkState | undefined;
|
|
38
40
|
}>;
|
|
@@ -3,10 +3,11 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
|
3
3
|
import { EditorAnalyticsAPI, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
5
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
6
|
+
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
6
7
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
7
8
|
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
9
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
8
10
|
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;
|
|
9
|
-
export declare const insertLinkWithAnalyticsMobileNative: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string) => Command;
|
|
10
11
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
11
12
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
12
13
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { hyperlinkPlugin } from './plugin';
|
|
2
|
-
export type { HideLinkToolbar, ShowLinkToolbar } from './commands';
|
|
2
|
+
export type { HideLinkToolbar, ShowLinkToolbar, InsertLink, UpdateLink, } from './commands';
|
|
3
3
|
export type { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
@@ -2,7 +2,7 @@ import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
|
2
2
|
import type { HyperlinkPluginOptions, NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
3
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
4
4
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
5
|
-
import { HideLinkToolbar, ShowLinkToolbar } from './commands';
|
|
5
|
+
import { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
6
|
import { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
7
7
|
export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
8
8
|
pluginConfiguration: HyperlinkPluginOptions | undefined;
|
|
@@ -33,6 +33,8 @@ export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
|
33
33
|
*/
|
|
34
34
|
showLinkToolbar: ShowLinkToolbar;
|
|
35
35
|
hideLinkToolbar: HideLinkToolbar;
|
|
36
|
+
insertLink: InsertLink;
|
|
37
|
+
updateLink: UpdateLink;
|
|
36
38
|
};
|
|
37
39
|
sharedState: HyperlinkState | undefined;
|
|
38
40
|
}>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^26.1.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^74.
|
|
36
|
+
"@atlaskit/editor-common": "^74.22.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
39
39
|
"@atlaskit/icon": "^21.12.0",
|
package/report.api.md
CHANGED
|
@@ -25,11 +25,13 @@ import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
|
|
|
25
25
|
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
26
26
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
27
27
|
import type { IntlShape } from 'react-intl-next';
|
|
28
|
+
import type { LinkInputType } from '@atlaskit/editor-common/types';
|
|
28
29
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
29
30
|
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
30
31
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
31
32
|
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
32
33
|
import { Transaction } from 'prosemirror-state';
|
|
34
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
33
35
|
|
|
34
36
|
// @public (undocumented)
|
|
35
37
|
type GetToolbarItems = (
|
|
@@ -55,6 +57,8 @@ export const hyperlinkPlugin: NextEditorPlugin<
|
|
|
55
57
|
prependToolbarButtons: PrependToolbarButtons;
|
|
56
58
|
showLinkToolbar: ShowLinkToolbar;
|
|
57
59
|
hideLinkToolbar: HideLinkToolbar;
|
|
60
|
+
insertLink: InsertLink;
|
|
61
|
+
updateLink: UpdateLink;
|
|
58
62
|
};
|
|
59
63
|
sharedState: HyperlinkState | undefined;
|
|
60
64
|
}
|
|
@@ -74,6 +78,18 @@ type InputMethod =
|
|
|
74
78
|
| INPUT_METHOD.SHORTCUT
|
|
75
79
|
| INPUT_METHOD.TOOLBAR;
|
|
76
80
|
|
|
81
|
+
// @public (undocumented)
|
|
82
|
+
export type InsertLink = (
|
|
83
|
+
inputMethod: LinkInputType,
|
|
84
|
+
from: number,
|
|
85
|
+
to: number,
|
|
86
|
+
href: string,
|
|
87
|
+
title?: string,
|
|
88
|
+
displayText?: string,
|
|
89
|
+
cardsAvailable?: boolean,
|
|
90
|
+
sourceEvent?: UIAnalyticsEvent | null | undefined,
|
|
91
|
+
) => Command;
|
|
92
|
+
|
|
77
93
|
// @public (undocumented)
|
|
78
94
|
export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
|
|
79
95
|
|
|
@@ -86,6 +102,14 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
|
86
102
|
// @public (undocumented)
|
|
87
103
|
export type ShowLinkToolbar = (inputMethod: InputMethod) => Command;
|
|
88
104
|
|
|
105
|
+
// @public (undocumented)
|
|
106
|
+
export type UpdateLink = (
|
|
107
|
+
href: string,
|
|
108
|
+
text: string,
|
|
109
|
+
pos: number,
|
|
110
|
+
to?: number,
|
|
111
|
+
) => Command;
|
|
112
|
+
|
|
89
113
|
// (No @packageDocumentation comment for this package)
|
|
90
114
|
```
|
|
91
115
|
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/editor-plugin-hyperlink"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
8
|
+
import type { Command } from '@atlaskit/editor-common/types';
|
|
9
|
+
import { EditorState } from 'prosemirror-state';
|
|
10
|
+
import { EditorView } from 'prosemirror-view';
|
|
11
|
+
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
12
|
+
import { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
13
|
+
import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
|
|
14
|
+
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
15
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
16
|
+
import type { IntlShape } from 'react-intl-next';
|
|
17
|
+
import type { LinkInputType } from '@atlaskit/editor-common/types';
|
|
18
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
19
|
+
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
20
|
+
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
21
|
+
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
22
|
+
import { Transaction } from 'prosemirror-state';
|
|
23
|
+
import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
24
|
+
|
|
25
|
+
// @public (undocumented)
|
|
26
|
+
type GetToolbarItems = (state: EditorState, intl: IntlShape, providerFactory: ProviderFactory, link: string) => FloatingToolbarItem<any>[];
|
|
27
|
+
|
|
28
|
+
// @public (undocumented)
|
|
29
|
+
export type HideLinkToolbar = (tr: Transaction) => Transaction;
|
|
30
|
+
|
|
31
|
+
// @public (undocumented)
|
|
32
|
+
export const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
33
|
+
pluginConfiguration: HyperlinkPluginOptions | undefined;
|
|
34
|
+
dependencies: [
|
|
35
|
+
typeof featureFlagsPlugin,
|
|
36
|
+
OptionalPlugin<typeof analyticsPlugin>
|
|
37
|
+
];
|
|
38
|
+
actions: {
|
|
39
|
+
prependToolbarButtons: PrependToolbarButtons;
|
|
40
|
+
showLinkToolbar: ShowLinkToolbar;
|
|
41
|
+
hideLinkToolbar: HideLinkToolbar;
|
|
42
|
+
insertLink: InsertLink;
|
|
43
|
+
updateLink: UpdateLink;
|
|
44
|
+
};
|
|
45
|
+
sharedState: HyperlinkState | undefined;
|
|
46
|
+
}>;
|
|
47
|
+
|
|
48
|
+
// @public (undocumented)
|
|
49
|
+
type HyperlinkToolbarItemsState = {
|
|
50
|
+
items: GetToolbarItems;
|
|
51
|
+
onEscapeCallback: ((tr: Transaction) => Transaction) | undefined;
|
|
52
|
+
onInsertLinkCallback: QueueCardsFromTransactionAction | undefined;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// @public (undocumented)
|
|
56
|
+
type InputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR;
|
|
57
|
+
|
|
58
|
+
// @public (undocumented)
|
|
59
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
60
|
+
|
|
61
|
+
// @public (undocumented)
|
|
62
|
+
export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
|
|
63
|
+
|
|
64
|
+
// @public (undocumented)
|
|
65
|
+
interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
66
|
+
// (undocumented)
|
|
67
|
+
view: EditorView;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// @public (undocumented)
|
|
71
|
+
export type ShowLinkToolbar = (inputMethod: InputMethod) => Command;
|
|
72
|
+
|
|
73
|
+
// @public (undocumented)
|
|
74
|
+
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
75
|
+
|
|
76
|
+
// (No @packageDocumentation comment for this package)
|
|
77
|
+
|
|
78
|
+
```
|