@atlaskit/editor-plugin-hyperlink 0.2.4 → 0.3.1
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 +0 -2
- package/CHANGELOG.md +22 -0
- package/dist/cjs/commands.js +15 -17
- package/dist/cjs/plugin.js +5 -3
- package/dist/cjs/pm-plugins/keymap.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands.js +16 -17
- package/dist/es2019/plugin.js +5 -3
- package/dist/es2019/pm-plugins/keymap.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands.js +15 -17
- package/dist/esm/plugin.js +5 -3
- package/dist/esm/pm-plugins/keymap.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/commands.d.ts +3 -3
- package/dist/types/plugin.d.ts +10 -8
- package/dist/types/pm-plugins/toolbar-buttons.d.ts +1 -1
- package/dist/types-ts4.5/commands.d.ts +3 -3
- package/dist/types-ts4.5/plugin.d.ts +10 -8
- package/dist/types-ts4.5/pm-plugins/toolbar-buttons.d.ts +1 -1
- package/package.json +4 -4
- package/report.api.md +5 -2
- package/tmp/api-report-tmp.d.ts +5 -2
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 0.3.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`a675f834911`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a675f834911) - Introduce `commands` optional parameter to `NextEditorPlugin`. It can be used similarly to `actions` in `NextEditorPlugin` but `commands` must adhere to the type of `PluginCommand`:
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
type PluginCommand = ({ tr }: { tr: Transaction }) => Transaction | null;
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`PluginCommand`s are specifically used for code that is executed to modify a Transaction. They should be used in preference to the existing prosemirror `Command` type.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 0.2.4
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
package/dist/cjs/commands.js
CHANGED
|
@@ -182,24 +182,22 @@ function editInsertedLink(editorAnalyticsApi) {
|
|
|
182
182
|
};
|
|
183
183
|
}
|
|
184
184
|
function showLinkToolbar(inputMethod, editorAnalyticsApi) {
|
|
185
|
-
return function (
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
return function (_ref) {
|
|
186
|
+
var tr = _ref.tr;
|
|
187
|
+
var newTr = tr.setMeta(_main.stateKey, {
|
|
188
|
+
type: _link.LinkAction.SHOW_INSERT_TOOLBAR,
|
|
189
|
+
inputMethod: inputMethod
|
|
190
|
+
});
|
|
191
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
192
|
+
action: _analytics.ACTION.INVOKED,
|
|
193
|
+
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
194
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
195
|
+
attributes: {
|
|
189
196
|
inputMethod: inputMethod
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
195
|
-
attributes: {
|
|
196
|
-
inputMethod: inputMethod
|
|
197
|
-
},
|
|
198
|
-
eventType: _analytics.EVENT_TYPE.UI
|
|
199
|
-
})(_tr2);
|
|
200
|
-
dispatch(_tr2);
|
|
201
|
-
}
|
|
202
|
-
return true;
|
|
197
|
+
},
|
|
198
|
+
eventType: _analytics.EVENT_TYPE.UI
|
|
199
|
+
})(newTr);
|
|
200
|
+
return newTr;
|
|
203
201
|
};
|
|
204
202
|
}
|
|
205
203
|
function hideLinkToolbar() {
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -32,13 +32,15 @@ var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
32
32
|
mark: _adfSchema.link
|
|
33
33
|
}];
|
|
34
34
|
},
|
|
35
|
-
|
|
36
|
-
prependToolbarButtons: _toolbarButtons.prependToolbarButtons,
|
|
35
|
+
commands: {
|
|
37
36
|
showLinkToolbar: function showLinkToolbar() {
|
|
38
37
|
var _api$dependencies$ana;
|
|
39
38
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
40
39
|
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
|
-
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
actions: {
|
|
43
|
+
prependToolbarButtons: _toolbarButtons.prependToolbarButtons,
|
|
42
44
|
hideLinkToolbar: _commands.hideLinkToolbarSetMeta,
|
|
43
45
|
insertLink: function insertLink(inputMethod, from, to, href, title, displayText) {
|
|
44
46
|
var _api$dependencies$ana2;
|
|
@@ -16,7 +16,7 @@ function createKeymapPlugin() {
|
|
|
16
16
|
var skipAnalytics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
17
17
|
var editorAnalyticsApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
18
18
|
var list = {};
|
|
19
|
-
(0, _keymaps.
|
|
19
|
+
(0, _keymaps.bindKeymapWithPluginCommand)(_keymaps.addLink.common, (0, _commands.showLinkToolbar)(_analytics.INPUT_METHOD.SHORTCUT, editorAnalyticsApi), list);
|
|
20
20
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.enter.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
21
21
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.insertNewLine.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
22
22
|
(0, _keymaps.bindKeymapWithCommand)(_keymaps.escape.common, function (state, dispatch, view) {
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/commands.js
CHANGED
|
@@ -167,24 +167,23 @@ export function editInsertedLink(editorAnalyticsApi) {
|
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
169
|
export function showLinkToolbar(inputMethod, editorAnalyticsApi) {
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
170
|
+
return ({
|
|
171
|
+
tr
|
|
172
|
+
}) => {
|
|
173
|
+
const newTr = tr.setMeta(stateKey, {
|
|
174
|
+
type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
175
|
+
inputMethod
|
|
176
|
+
});
|
|
177
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
178
|
+
action: ACTION.INVOKED,
|
|
179
|
+
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
180
|
+
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
181
|
+
attributes: {
|
|
174
182
|
inputMethod
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
180
|
-
attributes: {
|
|
181
|
-
inputMethod
|
|
182
|
-
},
|
|
183
|
-
eventType: EVENT_TYPE.UI
|
|
184
|
-
})(tr);
|
|
185
|
-
dispatch(tr);
|
|
186
|
-
}
|
|
187
|
-
return true;
|
|
183
|
+
},
|
|
184
|
+
eventType: EVENT_TYPE.UI
|
|
185
|
+
})(newTr);
|
|
186
|
+
return newTr;
|
|
188
187
|
};
|
|
189
188
|
}
|
|
190
189
|
export function hideLinkToolbar() {
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -23,12 +23,14 @@ export const hyperlinkPlugin = (options = {}, api) => {
|
|
|
23
23
|
mark: link
|
|
24
24
|
}];
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
prependToolbarButtons,
|
|
26
|
+
commands: {
|
|
28
27
|
showLinkToolbar: (inputMethod = INPUT_METHOD.TOOLBAR) => {
|
|
29
28
|
var _api$dependencies$ana;
|
|
30
29
|
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
|
-
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
actions: {
|
|
33
|
+
prependToolbarButtons,
|
|
32
34
|
hideLinkToolbar: hideLinkToolbarSetMeta,
|
|
33
35
|
insertLink: (inputMethod, from, to, href, title, displayText, cardsAvailable = false, sourceEvent = undefined) => {
|
|
34
36
|
var _api$dependencies$ana2;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { addLink, bindKeymapWithCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import { addLink, bindKeymapWithCommand, bindKeymapWithPluginCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
6
|
import { hideLinkToolbar, showLinkToolbar } from '../commands';
|
|
7
7
|
import { stateKey } from '../pm-plugins/main';
|
|
8
8
|
export function createKeymapPlugin(skipAnalytics = false, editorAnalyticsApi) {
|
|
9
9
|
const list = {};
|
|
10
|
-
|
|
10
|
+
bindKeymapWithPluginCommand(addLink.common, showLinkToolbar(INPUT_METHOD.SHORTCUT, editorAnalyticsApi), list);
|
|
11
11
|
bindKeymapWithCommand(enter.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
12
12
|
bindKeymapWithCommand(insertNewLine.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
13
13
|
bindKeymapWithCommand(escape.common, (state, dispatch, view) => {
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/commands.js
CHANGED
|
@@ -166,24 +166,22 @@ export function editInsertedLink(editorAnalyticsApi) {
|
|
|
166
166
|
};
|
|
167
167
|
}
|
|
168
168
|
export function showLinkToolbar(inputMethod, editorAnalyticsApi) {
|
|
169
|
-
return function (
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
169
|
+
return function (_ref) {
|
|
170
|
+
var tr = _ref.tr;
|
|
171
|
+
var newTr = tr.setMeta(stateKey, {
|
|
172
|
+
type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
173
|
+
inputMethod: inputMethod
|
|
174
|
+
});
|
|
175
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
176
|
+
action: ACTION.INVOKED,
|
|
177
|
+
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
178
|
+
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
179
|
+
attributes: {
|
|
173
180
|
inputMethod: inputMethod
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
179
|
-
attributes: {
|
|
180
|
-
inputMethod: inputMethod
|
|
181
|
-
},
|
|
182
|
-
eventType: EVENT_TYPE.UI
|
|
183
|
-
})(_tr2);
|
|
184
|
-
dispatch(_tr2);
|
|
185
|
-
}
|
|
186
|
-
return true;
|
|
181
|
+
},
|
|
182
|
+
eventType: EVENT_TYPE.UI
|
|
183
|
+
})(newTr);
|
|
184
|
+
return newTr;
|
|
187
185
|
};
|
|
188
186
|
}
|
|
189
187
|
export function hideLinkToolbar() {
|
package/dist/esm/plugin.js
CHANGED
|
@@ -25,13 +25,15 @@ export var hyperlinkPlugin = function hyperlinkPlugin() {
|
|
|
25
25
|
mark: link
|
|
26
26
|
}];
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
prependToolbarButtons: prependToolbarButtons,
|
|
28
|
+
commands: {
|
|
30
29
|
showLinkToolbar: function showLinkToolbar() {
|
|
31
30
|
var _api$dependencies$ana;
|
|
32
31
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.TOOLBAR;
|
|
33
32
|
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
|
-
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
actions: {
|
|
36
|
+
prependToolbarButtons: prependToolbarButtons,
|
|
35
37
|
hideLinkToolbar: hideLinkToolbarSetMeta,
|
|
36
38
|
insertLink: function insertLink(inputMethod, from, to, href, title, displayText) {
|
|
37
39
|
var _api$dependencies$ana2;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
|
-
import { addLink, bindKeymapWithCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
3
|
+
import { addLink, bindKeymapWithCommand, bindKeymapWithPluginCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
4
4
|
import { findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
6
6
|
import { hideLinkToolbar, showLinkToolbar } from '../commands';
|
|
@@ -9,7 +9,7 @@ export function createKeymapPlugin() {
|
|
|
9
9
|
var skipAnalytics = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
10
10
|
var editorAnalyticsApi = arguments.length > 1 ? arguments[1] : undefined;
|
|
11
11
|
var list = {};
|
|
12
|
-
|
|
12
|
+
bindKeymapWithPluginCommand(addLink.common, showLinkToolbar(INPUT_METHOD.SHORTCUT, editorAnalyticsApi), list);
|
|
13
13
|
bindKeymapWithCommand(enter.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
14
14
|
bindKeymapWithCommand(insertNewLine.common, mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi), list);
|
|
15
15
|
bindKeymapWithCommand(escape.common, function (state, dispatch, view) {
|
package/dist/esm/version.json
CHANGED
package/dist/types/commands.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Command, LinkInputType, PluginCommand } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
7
|
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
@@ -12,8 +12,8 @@ export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from:
|
|
|
12
12
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
13
13
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
14
14
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
15
|
-
export type ShowLinkToolbar = (inputMethod: InputMethod) =>
|
|
16
|
-
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined):
|
|
15
|
+
export type ShowLinkToolbar = (inputMethod: InputMethod) => PluginCommand;
|
|
16
|
+
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): PluginCommand;
|
|
17
17
|
export declare function hideLinkToolbar(): Command;
|
|
18
18
|
export type HideLinkToolbar = (tr: Transaction) => Transaction;
|
|
19
19
|
export declare const hideLinkToolbarSetMeta: HideLinkToolbar;
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ 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, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
|
-
import { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
5
|
+
import type { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
|
+
import type { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
7
7
|
export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
8
8
|
pluginConfiguration: HyperlinkPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -20,21 +20,23 @@ export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
|
20
20
|
* - onInsertLinkCallback (optional): To be called when a link is inserted and it can be changed into a card.
|
|
21
21
|
*/
|
|
22
22
|
prependToolbarButtons: PrependToolbarButtons;
|
|
23
|
+
hideLinkToolbar: HideLinkToolbar;
|
|
24
|
+
insertLink: InsertLink;
|
|
25
|
+
updateLink: UpdateLink;
|
|
26
|
+
};
|
|
27
|
+
commands: {
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* PluginCommand to show link toolbar.
|
|
25
30
|
*
|
|
26
31
|
* Example:
|
|
27
32
|
*
|
|
28
33
|
* ```
|
|
29
|
-
* pluginInjectionApi?.dependencies.hyperlink.
|
|
34
|
+
* const newTr = pluginInjectionApi?.dependencies.hyperlink.commands.showLinkToolbar(
|
|
30
35
|
* inputMethod
|
|
31
|
-
* )(
|
|
36
|
+
* )({ tr })
|
|
32
37
|
* ```
|
|
33
38
|
*/
|
|
34
39
|
showLinkToolbar: ShowLinkToolbar;
|
|
35
|
-
hideLinkToolbar: HideLinkToolbar;
|
|
36
|
-
insertLink: InsertLink;
|
|
37
|
-
updateLink: UpdateLink;
|
|
38
40
|
};
|
|
39
41
|
sharedState: HyperlinkState | undefined;
|
|
40
42
|
}>;
|
|
@@ -18,5 +18,5 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
|
18
18
|
}
|
|
19
19
|
export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
|
|
20
20
|
export declare const prependToolbarButtons: ({ items, onEscapeCallback, onInsertLinkCallback, view, }: PrependToolbarButtonsProps) => void;
|
|
21
|
-
export declare const toolbarButtonsPlugin: () => SafePlugin<
|
|
21
|
+
export declare const toolbarButtonsPlugin: () => SafePlugin<undefined>;
|
|
22
22
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Command, LinkInputType, PluginCommand } from '@atlaskit/editor-common/types';
|
|
5
5
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
7
|
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
@@ -12,8 +12,8 @@ export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from:
|
|
|
12
12
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
13
13
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
14
14
|
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
15
|
-
export type ShowLinkToolbar = (inputMethod: InputMethod) =>
|
|
16
|
-
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined):
|
|
15
|
+
export type ShowLinkToolbar = (inputMethod: InputMethod) => PluginCommand;
|
|
16
|
+
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): PluginCommand;
|
|
17
17
|
export declare function hideLinkToolbar(): Command;
|
|
18
18
|
export type HideLinkToolbar = (tr: Transaction) => Transaction;
|
|
19
19
|
export declare const hideLinkToolbarSetMeta: HideLinkToolbar;
|
|
@@ -2,8 +2,8 @@ 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, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
|
-
import { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
5
|
+
import type { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './commands';
|
|
6
|
+
import type { PrependToolbarButtons } from './pm-plugins/toolbar-buttons';
|
|
7
7
|
export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
8
8
|
pluginConfiguration: HyperlinkPluginOptions | undefined;
|
|
9
9
|
dependencies: [
|
|
@@ -20,21 +20,23 @@ export declare const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
|
20
20
|
* - onInsertLinkCallback (optional): To be called when a link is inserted and it can be changed into a card.
|
|
21
21
|
*/
|
|
22
22
|
prependToolbarButtons: PrependToolbarButtons;
|
|
23
|
+
hideLinkToolbar: HideLinkToolbar;
|
|
24
|
+
insertLink: InsertLink;
|
|
25
|
+
updateLink: UpdateLink;
|
|
26
|
+
};
|
|
27
|
+
commands: {
|
|
23
28
|
/**
|
|
24
|
-
*
|
|
29
|
+
* PluginCommand to show link toolbar.
|
|
25
30
|
*
|
|
26
31
|
* Example:
|
|
27
32
|
*
|
|
28
33
|
* ```
|
|
29
|
-
* pluginInjectionApi?.dependencies.hyperlink.
|
|
34
|
+
* const newTr = pluginInjectionApi?.dependencies.hyperlink.commands.showLinkToolbar(
|
|
30
35
|
* inputMethod
|
|
31
|
-
* )(
|
|
36
|
+
* )({ tr })
|
|
32
37
|
* ```
|
|
33
38
|
*/
|
|
34
39
|
showLinkToolbar: ShowLinkToolbar;
|
|
35
|
-
hideLinkToolbar: HideLinkToolbar;
|
|
36
|
-
insertLink: InsertLink;
|
|
37
|
-
updateLink: UpdateLink;
|
|
38
40
|
};
|
|
39
41
|
sharedState: HyperlinkState | undefined;
|
|
40
42
|
}>;
|
|
@@ -18,5 +18,5 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
|
18
18
|
}
|
|
19
19
|
export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
|
|
20
20
|
export declare const prependToolbarButtons: ({ items, onEscapeCallback, onInsertLinkCallback, view, }: PrependToolbarButtonsProps) => void;
|
|
21
|
-
export declare const toolbarButtonsPlugin: () => SafePlugin<
|
|
21
|
+
export declare const toolbarButtonsPlugin: () => SafePlugin<undefined>;
|
|
22
22
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^28.
|
|
34
|
+
"@atlaskit/adf-schema": "^28.1.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^74.
|
|
36
|
+
"@atlaskit/editor-common": "^74.42.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^0.1.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^0.1.0",
|
|
39
|
-
"@atlaskit/editor-prosemirror": "1.0
|
|
39
|
+
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
40
40
|
"@atlaskit/icon": "^21.12.0",
|
|
41
41
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
42
42
|
"@atlaskit/prosemirror-input-rules": "^2.4.0",
|
package/report.api.md
CHANGED
|
@@ -28,6 +28,7 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
28
28
|
import type { LinkInputType } from '@atlaskit/editor-common/types';
|
|
29
29
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
30
30
|
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
31
|
+
import type { PluginCommand } from '@atlaskit/editor-common/types';
|
|
31
32
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
32
33
|
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
33
34
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -55,11 +56,13 @@ export const hyperlinkPlugin: NextEditorPlugin<
|
|
|
55
56
|
];
|
|
56
57
|
actions: {
|
|
57
58
|
prependToolbarButtons: PrependToolbarButtons;
|
|
58
|
-
showLinkToolbar: ShowLinkToolbar;
|
|
59
59
|
hideLinkToolbar: HideLinkToolbar;
|
|
60
60
|
insertLink: InsertLink;
|
|
61
61
|
updateLink: UpdateLink;
|
|
62
62
|
};
|
|
63
|
+
commands: {
|
|
64
|
+
showLinkToolbar: ShowLinkToolbar;
|
|
65
|
+
};
|
|
63
66
|
sharedState: HyperlinkState | undefined;
|
|
64
67
|
}
|
|
65
68
|
>;
|
|
@@ -100,7 +103,7 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
|
100
103
|
}
|
|
101
104
|
|
|
102
105
|
// @public (undocumented)
|
|
103
|
-
export type ShowLinkToolbar = (inputMethod: InputMethod) =>
|
|
106
|
+
export type ShowLinkToolbar = (inputMethod: InputMethod) => PluginCommand;
|
|
104
107
|
|
|
105
108
|
// @public (undocumented)
|
|
106
109
|
export type UpdateLink = (
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ import type { IntlShape } from 'react-intl-next';
|
|
|
17
17
|
import type { LinkInputType } from '@atlaskit/editor-common/types';
|
|
18
18
|
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
19
19
|
import type { OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
20
|
+
import type { PluginCommand } from '@atlaskit/editor-common/types';
|
|
20
21
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
21
22
|
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
22
23
|
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
@@ -37,11 +38,13 @@ export const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
|
|
|
37
38
|
];
|
|
38
39
|
actions: {
|
|
39
40
|
prependToolbarButtons: PrependToolbarButtons;
|
|
40
|
-
showLinkToolbar: ShowLinkToolbar;
|
|
41
41
|
hideLinkToolbar: HideLinkToolbar;
|
|
42
42
|
insertLink: InsertLink;
|
|
43
43
|
updateLink: UpdateLink;
|
|
44
44
|
};
|
|
45
|
+
commands: {
|
|
46
|
+
showLinkToolbar: ShowLinkToolbar;
|
|
47
|
+
};
|
|
45
48
|
sharedState: HyperlinkState | undefined;
|
|
46
49
|
}>;
|
|
47
50
|
|
|
@@ -68,7 +71,7 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
|
|
|
68
71
|
}
|
|
69
72
|
|
|
70
73
|
// @public (undocumented)
|
|
71
|
-
export type ShowLinkToolbar = (inputMethod: InputMethod) =>
|
|
74
|
+
export type ShowLinkToolbar = (inputMethod: InputMethod) => PluginCommand;
|
|
72
75
|
|
|
73
76
|
// @public (undocumented)
|
|
74
77
|
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|