@atlaskit/editor-plugin-hyperlink 0.0.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 CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  rules: {
3
+ '@typescript-eslint/consistent-type-imports': 'warn',
3
4
  'no-duplicate-imports': 'off',
4
5
  '@typescript-eslint/no-duplicate-imports': 'error',
5
6
  },
package/CHANGELOG.md CHANGED
@@ -1 +1,59 @@
1
- # @atlaskit/editor-plugin-hyperlink
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).
@@ -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.insertLinkWithAnalyticsMobileNative = exports.insertLinkWithAnalytics = void 0;
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 text = displayText || incomingTitle || incomingHref;
103
+ var _text = displayText || incomingTitle || incomingHref;
104
104
  if (!displayText || displayText !== currentText) {
105
- tr.insertText(text, from, to);
105
+ tr.insertText(_text, from, to);
106
106
  if (!(0, _link.isTextAtPos)(from)(state)) {
107
- markEnd = from + text.length + 1;
107
+ markEnd = from + _text.length + 1;
108
108
  } else {
109
- markEnd = from + text.length;
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
@@ -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$ana2;
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$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
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$ana3;
78
- return (0, _keymap.createKeymapPlugin)(skipAnalytics, 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);
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',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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
@@ -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$ana2;
60
- return createInputRulePlugin(schema, skipAnalytics, featureFlags, 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);
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$ana3;
66
- return createKeymapPlugin(skipAnalytics, 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);
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',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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 text = displayText || incomingTitle || incomingHref;
88
+ var _text = displayText || incomingTitle || incomingHref;
89
89
  if (!displayText || displayText !== currentText) {
90
- tr.insertText(text, from, to);
90
+ tr.insertText(_text, from, to);
91
91
  if (!isTextAtPos(from)(state)) {
92
- markEnd = from + text.length + 1;
92
+ markEnd = from + _text.length + 1;
93
93
  } else {
94
- markEnd = from + text.length;
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
@@ -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$ana2;
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$ana2 = api.dependencies.analytics) === null || _api$dependencies$ana2 === void 0 ? void 0 : _api$dependencies$ana2.actions);
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$ana3;
71
- return createKeymapPlugin(skipAnalytics, 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);
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',
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-hyperlink",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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
  }>;
@@ -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.0.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,12 +33,12 @@
33
33
  "dependencies": {
34
34
  "@atlaskit/adf-schema": "^26.1.0",
35
35
  "@atlaskit/analytics-next": "^9.1.0",
36
- "@atlaskit/editor-common": "^74.17.0",
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",
40
40
  "@atlaskit/platform-feature-flags": "^0.2.0",
41
- "@atlaskit/prosemirror-input-rules": "^2.2.0",
41
+ "@atlaskit/prosemirror-input-rules": "^2.3.0",
42
42
  "@babel/runtime": "^7.0.0",
43
43
  "prosemirror-keymap": "1.1.4",
44
44
  "prosemirror-model": "1.16.0",
package/report.api.md ADDED
@@ -0,0 +1,129 @@
1
+ <!-- API Report Version: 2.3 -->
2
+
3
+ ## API Report File for "@atlaskit/editor-plugin-hyperlink"
4
+
5
+ > Do not edit this file. This report is auto-generated using [API Extractor](https://api-extractor.com/).
6
+ > [Learn more about API reports](https://hello.atlassian.net/wiki/spaces/UR/pages/1825484529/Package+API+Reports)
7
+
8
+ ### Table of contents
9
+
10
+ - [Main Entry Types](#main-entry-types)
11
+ - [Peer Dependencies](#peer-dependencies)
12
+
13
+ ### Main Entry Types
14
+
15
+ <!--SECTION START: Main Entry Types-->
16
+
17
+ ```ts
18
+ import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
19
+ import type { Command } from '@atlaskit/editor-common/types';
20
+ import { EditorState } from 'prosemirror-state';
21
+ import { EditorView } from 'prosemirror-view';
22
+ import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
23
+ import { FloatingToolbarItem } from '@atlaskit/editor-common/types';
24
+ import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
25
+ import type { HyperlinkState } from '@atlaskit/editor-common/link';
26
+ import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
27
+ import type { IntlShape } from 'react-intl-next';
28
+ import type { LinkInputType } from '@atlaskit/editor-common/types';
29
+ import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
30
+ import type { OptionalPlugin } from '@atlaskit/editor-common/types';
31
+ import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
32
+ import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
33
+ import { Transaction } from 'prosemirror-state';
34
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
35
+
36
+ // @public (undocumented)
37
+ type GetToolbarItems = (
38
+ state: EditorState,
39
+ intl: IntlShape,
40
+ providerFactory: ProviderFactory,
41
+ link: string,
42
+ ) => FloatingToolbarItem<any>[];
43
+
44
+ // @public (undocumented)
45
+ export type HideLinkToolbar = (tr: Transaction) => Transaction;
46
+
47
+ // @public (undocumented)
48
+ export const hyperlinkPlugin: NextEditorPlugin<
49
+ 'hyperlink',
50
+ {
51
+ pluginConfiguration: HyperlinkPluginOptions | undefined;
52
+ dependencies: [
53
+ typeof featureFlagsPlugin,
54
+ OptionalPlugin<typeof analyticsPlugin>,
55
+ ];
56
+ actions: {
57
+ prependToolbarButtons: PrependToolbarButtons;
58
+ showLinkToolbar: ShowLinkToolbar;
59
+ hideLinkToolbar: HideLinkToolbar;
60
+ insertLink: InsertLink;
61
+ updateLink: UpdateLink;
62
+ };
63
+ sharedState: HyperlinkState | undefined;
64
+ }
65
+ >;
66
+
67
+ // @public (undocumented)
68
+ type HyperlinkToolbarItemsState = {
69
+ items: GetToolbarItems;
70
+ onEscapeCallback: ((tr: Transaction) => Transaction) | undefined;
71
+ onInsertLinkCallback: QueueCardsFromTransactionAction | undefined;
72
+ };
73
+
74
+ // @public (undocumented)
75
+ type InputMethod =
76
+ | INPUT_METHOD.INSERT_MENU
77
+ | INPUT_METHOD.QUICK_INSERT
78
+ | INPUT_METHOD.SHORTCUT
79
+ | INPUT_METHOD.TOOLBAR;
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
+
93
+ // @public (undocumented)
94
+ export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
95
+
96
+ // @public (undocumented)
97
+ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
98
+ // (undocumented)
99
+ view: EditorView;
100
+ }
101
+
102
+ // @public (undocumented)
103
+ export type ShowLinkToolbar = (inputMethod: InputMethod) => Command;
104
+
105
+ // @public (undocumented)
106
+ export type UpdateLink = (
107
+ href: string,
108
+ text: string,
109
+ pos: number,
110
+ to?: number,
111
+ ) => Command;
112
+
113
+ // (No @packageDocumentation comment for this package)
114
+ ```
115
+
116
+ <!--SECTION END: Main Entry Types-->
117
+
118
+ ### Peer Dependencies
119
+
120
+ <!--SECTION START: Peer Dependencies-->
121
+
122
+ ```json
123
+ {
124
+ "react": "^16.8.0",
125
+ "react-intl-next": "npm:react-intl@^5.18.1"
126
+ }
127
+ ```
128
+
129
+ <!--SECTION END: Peer Dependencies-->
@@ -14,11 +14,13 @@ import type { HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
14
14
  import type { HyperlinkState } from '@atlaskit/editor-common/link';
15
15
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
16
16
  import type { IntlShape } from 'react-intl-next';
17
+ import type { LinkInputType } from '@atlaskit/editor-common/types';
17
18
  import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
18
19
  import type { OptionalPlugin } from '@atlaskit/editor-common/types';
19
20
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
20
21
  import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
21
22
  import { Transaction } from 'prosemirror-state';
23
+ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
22
24
 
23
25
  // @public (undocumented)
24
26
  type GetToolbarItems = (state: EditorState, intl: IntlShape, providerFactory: ProviderFactory, link: string) => FloatingToolbarItem<any>[];
@@ -37,6 +39,8 @@ export const hyperlinkPlugin: NextEditorPlugin<'hyperlink', {
37
39
  prependToolbarButtons: PrependToolbarButtons;
38
40
  showLinkToolbar: ShowLinkToolbar;
39
41
  hideLinkToolbar: HideLinkToolbar;
42
+ insertLink: InsertLink;
43
+ updateLink: UpdateLink;
40
44
  };
41
45
  sharedState: HyperlinkState | undefined;
42
46
  }>;
@@ -51,6 +55,9 @@ type HyperlinkToolbarItemsState = {
51
55
  // @public (undocumented)
52
56
  type InputMethod = INPUT_METHOD.INSERT_MENU | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.TOOLBAR;
53
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
+
54
61
  // @public (undocumented)
55
62
  export type PrependToolbarButtons = (props: PrependToolbarButtonsProps) => void;
56
63
 
@@ -63,6 +70,9 @@ interface PrependToolbarButtonsProps extends HyperlinkToolbarItemsState {
63
70
  // @public (undocumented)
64
71
  export type ShowLinkToolbar = (inputMethod: InputMethod) => Command;
65
72
 
73
+ // @public (undocumented)
74
+ export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
75
+
66
76
  // (No @packageDocumentation comment for this package)
67
77
 
68
78
  ```