@atlaskit/editor-plugin-hyperlink 0.1.0 → 0.2.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 +1 -0
- package/CHANGELOG.md +64 -0
- package/dist/cjs/commands.js +7 -11
- package/dist/cjs/plugin.js +12 -5
- package/dist/cjs/pm-plugins/fake-curor-for-toolbar-plugin-key.js +2 -2
- package/dist/cjs/pm-plugins/fake-cursor-for-toolbar.js +6 -6
- package/dist/cjs/pm-plugins/keymap.js +2 -2
- package/dist/cjs/pm-plugins/main.js +4 -4
- package/dist/cjs/pm-plugins/toolbar-buttons.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands.js +1 -4
- package/dist/es2019/plugin.js +11 -6
- package/dist/es2019/pm-plugins/fake-curor-for-toolbar-plugin-key.js +1 -1
- package/dist/es2019/pm-plugins/fake-cursor-for-toolbar.js +1 -1
- package/dist/es2019/pm-plugins/keymap.js +1 -1
- package/dist/es2019/pm-plugins/main.js +1 -1
- package/dist/es2019/pm-plugins/toolbar-buttons.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands.js +5 -8
- package/dist/esm/plugin.js +13 -6
- package/dist/esm/pm-plugins/fake-curor-for-toolbar-plugin-key.js +1 -1
- package/dist/esm/pm-plugins/fake-cursor-for-toolbar.js +1 -1
- package/dist/esm/pm-plugins/keymap.js +1 -1
- package/dist/esm/pm-plugins/main.js +1 -1
- package/dist/esm/pm-plugins/toolbar-buttons.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/Toolbar.d.ts +1 -1
- package/dist/types/commands.d.ts +6 -4
- package/dist/types/index.d.ts +1 -1
- package/dist/types/plugin.d.ts +3 -1
- package/dist/types/pm-plugins/fake-curor-for-toolbar-plugin-key.d.ts +1 -1
- package/dist/types/pm-plugins/input-rule.d.ts +3 -3
- package/dist/types/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/pm-plugins/main.d.ts +4 -4
- package/dist/types/pm-plugins/toolbar-buttons.d.ts +4 -3
- package/dist/types-ts4.5/Toolbar.d.ts +1 -1
- package/dist/types-ts4.5/commands.d.ts +6 -4
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/plugin.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/fake-curor-for-toolbar-plugin-key.d.ts +1 -1
- package/dist/types-ts4.5/pm-plugins/input-rule.d.ts +3 -3
- package/dist/types-ts4.5/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/main.d.ts +4 -4
- package/dist/types-ts4.5/pm-plugins/toolbar-buttons.d.ts +4 -3
- package/package.json +5 -8
- package/report.api.md +28 -4
- package/tmp/api-report-tmp.d.ts +78 -0
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,65 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
|
+
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4e6f1bf8511`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4e6f1bf8511) - [ED-19233] Import prosemirror libraries from internal facade package
|
|
8
|
+
|
|
9
|
+
## 0.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [`8e084d87da5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8e084d87da5) - Remove deprecated hyperlink commands and plugin key including:
|
|
14
|
+
|
|
15
|
+
- isTextAtPos
|
|
16
|
+
- isLinkAtPos
|
|
17
|
+
- insertLink
|
|
18
|
+
- insertLinkWithAnalyticsMobileNative
|
|
19
|
+
- insertLinkWithAnalytics
|
|
20
|
+
- updateLink
|
|
21
|
+
- hyperlinkStateKey
|
|
22
|
+
|
|
23
|
+
If you require `isTextAtPos` or `isLinkAtPos` these can be accessed via `editor-common`:
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { isTextAtPos, isLinkAtPos } from '@atlaskit/editor-common/link`;
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
If you require `insertLink`, `updateLink`, or `hyperlinkStateKey` you can access these via the new composable editor using a custom plugin. Here is an example:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { Editor } from '@atlaskit/editor-core/composable-editor';
|
|
33
|
+
import { EditorProps } from '@atlaskit/editor-core';
|
|
34
|
+
import { useUniversalPreset } from '@atlaskit/editor-core/preset-universal';
|
|
35
|
+
import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
|
|
36
|
+
import type { hyperlinkPlugin } from '@atlaskit/editor-plugin-hyperlink';
|
|
37
|
+
|
|
38
|
+
const customPlugin: NextEditorPlugin<'custom', {
|
|
39
|
+
dependencies: [typeof hyperlinkPlugin]
|
|
40
|
+
}> = (_, api) => {
|
|
41
|
+
// Can access insertLink and updateLink here
|
|
42
|
+
api?.dependencies.hyperlink.actions.insertLink( ... )
|
|
43
|
+
api?.dependencies.hyperlink.actions.updateLink( ... )
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// Rather than using the `hyperlinkStateKey` you can access via `sharedState`
|
|
47
|
+
api?.dependencies.hyperlink.sharedState.onChange(({ nextSharedState }) => {
|
|
48
|
+
// subscribe to changes
|
|
49
|
+
})
|
|
50
|
+
// OR for current value
|
|
51
|
+
api?.dependencies.hyperlink.sharedState.currentState()
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
name: 'custom'
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// This function is the equivalent of `Editor` from `editor-core`
|
|
59
|
+
function EditorWrapped(props: EditorProps) {
|
|
60
|
+
const preset = useUniversalPreset(props).add(customPlugin)
|
|
61
|
+
return <Editor preset={preset} ... />
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
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,18 +8,18 @@ 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;
|
|
15
15
|
exports.updateLink = updateLink;
|
|
16
16
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
18
17
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
19
18
|
var _card = require("@atlaskit/editor-common/card");
|
|
20
19
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
21
20
|
var _link = require("@atlaskit/editor-common/link");
|
|
22
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
23
23
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
24
|
var _main = require("./pm-plugins/main");
|
|
25
25
|
var _toolbarButtons = require("./pm-plugins/toolbar-buttons");
|
|
@@ -100,19 +100,19 @@ 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({
|
|
113
113
|
href: normalizedUrl
|
|
114
114
|
}));
|
|
115
|
-
tr.setSelection(
|
|
115
|
+
tr.setSelection(_state.Selection.near(tr.doc.resolve(markEnd)));
|
|
116
116
|
if (!displayText || displayText === incomingHref) {
|
|
117
117
|
var _toolbarKey$getState;
|
|
118
118
|
var queueCardsFromChangedTr = (_toolbarKey$getState = _toolbarButtons.toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
@@ -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',
|
|
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.fakeCursorForToolbarPluginKey = void 0;
|
|
7
|
-
var
|
|
8
|
-
var fakeCursorForToolbarPluginKey = new
|
|
7
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
+
var fakeCursorForToolbarPluginKey = new _state.PluginKey('fakeCursorToolbarPlugin');
|
|
9
9
|
exports.fakeCursorForToolbarPluginKey = fakeCursorForToolbarPluginKey;
|
|
@@ -4,20 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _prosemirrorView = require("prosemirror-view");
|
|
8
7
|
var _link = require("@atlaskit/editor-common/link");
|
|
9
8
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
+
var _view = require("@atlaskit/editor-prosemirror/view");
|
|
10
10
|
var _fakeCurorForToolbarPluginKey = require("./fake-curor-for-toolbar-plugin-key");
|
|
11
11
|
var _main = require("./main");
|
|
12
12
|
var createTextCursor = function createTextCursor(pos) {
|
|
13
13
|
var node = document.createElement('div');
|
|
14
14
|
node.className = 'ProseMirror-fake-text-cursor';
|
|
15
|
-
return
|
|
15
|
+
return _view.Decoration.widget(pos, node, {
|
|
16
16
|
key: 'hyperlink-text-cursor'
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
19
|
var createTextSelection = function createTextSelection(from, to) {
|
|
20
|
-
return
|
|
20
|
+
return _view.Decoration.inline(from, to, {
|
|
21
21
|
class: 'ProseMirror-fake-text-selection'
|
|
22
22
|
});
|
|
23
23
|
};
|
|
@@ -34,7 +34,7 @@ var fakeCursorToolbarPlugin = new _safePlugin.SafePlugin({
|
|
|
34
34
|
key: _fakeCurorForToolbarPluginKey.fakeCursorForToolbarPluginKey,
|
|
35
35
|
state: {
|
|
36
36
|
init: function init() {
|
|
37
|
-
return
|
|
37
|
+
return _view.DecorationSet.empty;
|
|
38
38
|
},
|
|
39
39
|
apply: function apply(tr, pluginState, oldState, newState) {
|
|
40
40
|
var oldInsertToolbarState = getInsertLinkToolbarState(oldState);
|
|
@@ -53,9 +53,9 @@ var fakeCursorToolbarPlugin = new _safePlugin.SafePlugin({
|
|
|
53
53
|
if (insertToolbarState) {
|
|
54
54
|
var _from = insertToolbarState.from,
|
|
55
55
|
_to = insertToolbarState.to;
|
|
56
|
-
return
|
|
56
|
+
return _view.DecorationSet.create(tr.doc, [_from === _to ? createTextCursor(_from) : createTextSelection(_from, _to)]);
|
|
57
57
|
}
|
|
58
|
-
return
|
|
58
|
+
return _view.DecorationSet.empty;
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
61
|
props: {
|
|
@@ -5,11 +5,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createKeymapPlugin = createKeymapPlugin;
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _prosemirrorKeymap = require("prosemirror-keymap");
|
|
9
8
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
9
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
10
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
11
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
12
|
+
var _keymap = require("@atlaskit/editor-prosemirror/keymap");
|
|
13
13
|
var _commands = require("../commands");
|
|
14
14
|
var _main = require("../pm-plugins/main");
|
|
15
15
|
function createKeymapPlugin() {
|
|
@@ -30,7 +30,7 @@ function createKeymapPlugin() {
|
|
|
30
30
|
}
|
|
31
31
|
return false;
|
|
32
32
|
}, list);
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, _keymap.keymap)(list);
|
|
34
34
|
}
|
|
35
35
|
var mayConvertLastWordToHyperlink = function mayConvertLastWordToHyperlink(skipAnalytics, editorAnalyticsApi) {
|
|
36
36
|
return function (state, dispatch) {
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.stateKey = exports.plugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
10
9
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
11
10
|
var _link3 = require("@atlaskit/editor-common/link");
|
|
12
11
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
12
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
13
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
14
14
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
16
|
var isSelectionInsideLink = function isSelectionInsideLink(state) {
|
|
@@ -148,12 +148,12 @@ var getActiveText = function getActiveText(selection) {
|
|
|
148
148
|
if (currentSlice.size === 0) {
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
if (currentSlice.content.childCount === 1 && currentSlice.content.firstChild && selection instanceof
|
|
151
|
+
if (currentSlice.content.childCount === 1 && currentSlice.content.firstChild && selection instanceof _state.TextSelection) {
|
|
152
152
|
return currentSlice.content.firstChild.textContent;
|
|
153
153
|
}
|
|
154
154
|
return;
|
|
155
155
|
};
|
|
156
|
-
var stateKey = new
|
|
156
|
+
var stateKey = new _state.PluginKey('hyperlinkPlugin');
|
|
157
157
|
exports.stateKey = stateKey;
|
|
158
158
|
var plugin = function plugin(dispatch, editorAppearance) {
|
|
159
159
|
return new _safePlugin.SafePlugin({
|
|
@@ -241,7 +241,7 @@ var plugin = function plugin(dispatch, editorAppearance) {
|
|
|
241
241
|
top: event.clientY
|
|
242
242
|
});
|
|
243
243
|
if ((newPosition === null || newPosition === void 0 ? void 0 : newPosition.pos) != null && newPosition.pos !== $anchor.pos) {
|
|
244
|
-
var tr = state.tr.setSelection(
|
|
244
|
+
var tr = state.tr.setSelection(_state.TextSelection.create(state.doc, $anchor.pos, newPosition.pos));
|
|
245
245
|
view.dispatch(tr);
|
|
246
246
|
return true;
|
|
247
247
|
}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.toolbarKey = exports.toolbarButtonsPlugin = exports.prependToolbarButtons = void 0;
|
|
7
|
-
var _prosemirrorState = require("prosemirror-state");
|
|
8
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
9
|
-
var
|
|
8
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
+
var toolbarKey = new _state.PluginKey('hyperlinkToolbarItems');
|
|
10
10
|
exports.toolbarKey = toolbarKey;
|
|
11
11
|
var prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
12
12
|
var items = _ref.items,
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/commands.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Selection } from 'prosemirror-state';
|
|
2
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, buildEditLinkPayload, EVENT_TYPE, INPUT_METHOD, unlinkPayload } from '@atlaskit/editor-common/analytics';
|
|
3
2
|
import { addLinkMetadata, commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
4
3
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
5
4
|
import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
|
|
6
5
|
import { filterCommands as filter, getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
7
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
8
|
import { stateKey } from './pm-plugins/main';
|
|
9
9
|
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
@@ -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',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export const fakeCursorForToolbarPluginKey = new PluginKey('fakeCursorToolbarPlugin');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
2
1
|
import { InsertStatus } from '@atlaskit/editor-common/link';
|
|
3
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { fakeCursorForToolbarPluginKey } from './fake-curor-for-toolbar-plugin-key';
|
|
5
5
|
import { stateKey as hyperlinkStateKey } from './main';
|
|
6
6
|
const createTextCursor = pos => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { keymap } from 'prosemirror-keymap';
|
|
2
1
|
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
3
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { addLink, bindKeymapWithCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
5
4
|
import { findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches } from '@atlaskit/editor-common/utils';
|
|
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) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
2
1
|
import uuid from 'uuid';
|
|
3
2
|
import { InsertStatus, LinkAction } from '@atlaskit/editor-common/link';
|
|
4
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
4
|
import { canLinkBeCreatedInRange, shallowEqual } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
const isSelectionInsideLink = state => !!state.doc.type.schema.marks.link.isInSet(state.selection.$from.marks());
|
|
7
7
|
const isSelectionAroundLink = state => {
|
|
8
8
|
const {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror-state';
|
|
2
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export const toolbarKey = new PluginKey('hyperlinkToolbarItems');
|
|
4
4
|
export const prependToolbarButtons = ({
|
|
5
5
|
items,
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/commands.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { Selection } from 'prosemirror-state';
|
|
5
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, buildEditLinkPayload, EVENT_TYPE, INPUT_METHOD, unlinkPayload } from '@atlaskit/editor-common/analytics';
|
|
6
5
|
import { addLinkMetadata, commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
7
6
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
8
7
|
import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
|
|
9
8
|
import { filterCommands as filter, getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
9
|
+
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
11
|
import { stateKey } from './pm-plugins/main';
|
|
12
12
|
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
@@ -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',
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export var fakeCursorForToolbarPluginKey = new PluginKey('fakeCursorToolbarPlugin');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Decoration, DecorationSet } from 'prosemirror-view';
|
|
2
1
|
import { InsertStatus } from '@atlaskit/editor-common/link';
|
|
3
2
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
4
4
|
import { fakeCursorForToolbarPluginKey } from './fake-curor-for-toolbar-plugin-key';
|
|
5
5
|
import { stateKey as hyperlinkStateKey } from './main';
|
|
6
6
|
var createTextCursor = function createTextCursor(pos) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { keymap } from 'prosemirror-keymap';
|
|
2
1
|
import { getLinkMatch } from '@atlaskit/adf-schema';
|
|
3
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
3
|
import { addLink, bindKeymapWithCommand, enter, escape, insertNewLine } from '@atlaskit/editor-common/keymaps';
|
|
5
4
|
import { findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches } from '@atlaskit/editor-common/utils';
|
|
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() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
3
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { PluginKey, TextSelection } from 'prosemirror-state';
|
|
5
4
|
import uuid from 'uuid';
|
|
6
5
|
import { InsertStatus, LinkAction } from '@atlaskit/editor-common/link';
|
|
7
6
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
8
7
|
import { canLinkBeCreatedInRange, shallowEqual } from '@atlaskit/editor-common/utils';
|
|
8
|
+
import { PluginKey, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
9
9
|
var isSelectionInsideLink = function isSelectionInsideLink(state) {
|
|
10
10
|
return !!state.doc.type.schema.marks.link.isInSet(state.selection.$from.marks());
|
|
11
11
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror-state';
|
|
2
1
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
2
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
export var toolbarKey = new PluginKey('hyperlinkToolbarItems');
|
|
4
4
|
export var prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
5
5
|
var items = _ref.items,
|
package/dist/esm/version.json
CHANGED
package/dist/types/Toolbar.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HyperlinkAddToolbarProps } from '@atlaskit/editor-common/link';
|
|
2
|
+
import type { HyperlinkAddToolbarProps } from '@atlaskit/editor-common/link';
|
|
3
3
|
import type { ExtractInjectionAPI, FeatureFlags, FloatingToolbarHandler, HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { hyperlinkPlugin } from './index';
|
|
5
5
|
export declare function HyperlinkAddToolbarWithState({ linkPickerOptions, onSubmit, displayText, displayUrl, providerFactory, view, onCancel, invokeMethod, featureFlags, onClose, onEscapeCallback, onClickAwayCallback, pluginInjectionApi, }: HyperlinkAddToolbarProps & {
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
|
+
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
6
8
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
7
9
|
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
10
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
8
11
|
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
9
|
-
export declare const insertLinkWithAnalyticsMobileNative: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string) => Command;
|
|
10
12
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
11
13
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
12
14
|
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
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const fakeCursorForToolbarPluginKey: PluginKey<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
6
6
|
export declare function createLinkInputRule(regexp: RegExp, skipAnalytics: boolean | undefined, editorAnalyticsApi: EditorAnalyticsAPI | undefined): InputRuleWrapper;
|
|
7
7
|
export declare function createInputRulePlugin(schema: Schema, skipAnalytics: boolean | undefined, featureFlags: FeatureFlags, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
export declare function createKeymapPlugin(skipAnalytics: boolean | undefined, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
4
4
|
export default createKeymapPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
4
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
export declare const stateKey: PluginKey<HyperlinkState>;
|
|
7
7
|
export declare const plugin: (dispatch: Dispatch, editorAppearance?: EditorAppearance) => SafePlugin<HyperlinkState>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { EditorState, PluginKey, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { EditorView } from 'prosemirror-view';
|
|
3
1
|
import type { IntlShape } from 'react-intl-next';
|
|
4
2
|
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
5
3
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
6
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
-
import { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
6
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
9
|
type HyperlinkToolbarItemsState = {
|
|
9
10
|
items: GetToolbarItems;
|
|
10
11
|
onEscapeCallback: ((tr: Transaction) => Transaction) | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HyperlinkAddToolbarProps } from '@atlaskit/editor-common/link';
|
|
2
|
+
import type { HyperlinkAddToolbarProps } from '@atlaskit/editor-common/link';
|
|
3
3
|
import type { ExtractInjectionAPI, FeatureFlags, FloatingToolbarHandler, HyperlinkPluginOptions } from '@atlaskit/editor-common/types';
|
|
4
4
|
import type { hyperlinkPlugin } from './index';
|
|
5
5
|
export declare function HyperlinkAddToolbarWithState({ linkPickerOptions, onSubmit, displayText, displayUrl, providerFactory, view, onCancel, invokeMethod, featureFlags, onClose, onEscapeCallback, onClickAwayCallback, pluginInjectionApi, }: HyperlinkAddToolbarProps & {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
2
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import type { Command, LinkInputType } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
6
|
export declare function setLinkHref(href: string, pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined, to?: number, isTabPressed?: boolean): Command;
|
|
7
|
+
export type UpdateLink = (href: string, text: string, pos: number, to?: number) => Command;
|
|
6
8
|
export declare function updateLink(href: string, text: string, pos: number, to?: number): Command;
|
|
7
9
|
export declare function insertLink(from: number, to: number, incomingHref: string, incomingTitle?: string, displayText?: string, source?: LinkInputType, sourceEvent?: UIAnalyticsEvent | null | undefined): Command;
|
|
10
|
+
export type InsertLink = (inputMethod: LinkInputType, from: number, to: number, href: string, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
8
11
|
export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string, cardsAvailable?: boolean, sourceEvent?: UIAnalyticsEvent | null | undefined) => Command;
|
|
9
|
-
export declare const insertLinkWithAnalyticsMobileNative: (inputMethod: LinkInputType, from: number, to: number, href: string, editorAnalyticsApi: EditorAnalyticsAPI | undefined, title?: string, displayText?: string) => Command;
|
|
10
12
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
11
13
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
12
14
|
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
|
}>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PluginKey } from 'prosemirror
|
|
1
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
2
2
|
export declare const fakeCursorForToolbarPluginKey: PluginKey<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
3
|
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
5
5
|
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
6
6
|
export declare function createLinkInputRule(regexp: RegExp, skipAnalytics: boolean | undefined, editorAnalyticsApi: EditorAnalyticsAPI | undefined): InputRuleWrapper;
|
|
7
7
|
export declare function createInputRulePlugin(schema: Schema, skipAnalytics: boolean | undefined, featureFlags: FeatureFlags, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
1
|
+
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
+
import type { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
3
|
export declare function createKeymapPlugin(skipAnalytics: boolean | undefined, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
4
4
|
export default createKeymapPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
1
|
+
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
2
|
+
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
4
3
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
-
import { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { EditorAppearance } from '@atlaskit/editor-common/types';
|
|
5
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
export declare const stateKey: PluginKey<HyperlinkState>;
|
|
7
7
|
export declare const plugin: (dispatch: Dispatch, editorAppearance?: EditorAppearance) => SafePlugin<HyperlinkState>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { EditorState, PluginKey, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { EditorView } from 'prosemirror-view';
|
|
3
1
|
import type { IntlShape } from 'react-intl-next';
|
|
4
2
|
import type { QueueCardsFromTransactionAction } from '@atlaskit/editor-common/card';
|
|
5
3
|
import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
|
|
6
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
|
-
import { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
5
|
+
import type { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
6
|
+
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
8
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
8
9
|
type HyperlinkToolbarItemsState = {
|
|
9
10
|
items: GetToolbarItems;
|
|
10
11
|
onEscapeCallback: ((tr: Transaction) => Transaction) | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -31,19 +31,16 @@
|
|
|
31
31
|
".": "./src/index.ts"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@atlaskit/adf-schema": "^26.
|
|
34
|
+
"@atlaskit/adf-schema": "^26.4.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^74.
|
|
36
|
+
"@atlaskit/editor-common": "^74.29.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.2",
|
|
39
40
|
"@atlaskit/icon": "^21.12.0",
|
|
40
41
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
41
42
|
"@atlaskit/prosemirror-input-rules": "^2.3.0",
|
|
42
43
|
"@babel/runtime": "^7.0.0",
|
|
43
|
-
"prosemirror-keymap": "1.1.4",
|
|
44
|
-
"prosemirror-model": "1.16.0",
|
|
45
|
-
"prosemirror-state": "1.3.4",
|
|
46
|
-
"prosemirror-view": "1.23.7",
|
|
47
44
|
"uuid": "^3.1.0"
|
|
48
45
|
},
|
|
49
46
|
"peerDependencies": {
|
|
@@ -53,7 +50,7 @@
|
|
|
53
50
|
"devDependencies": {
|
|
54
51
|
"@atlaskit/activity-provider": "^2.4.0",
|
|
55
52
|
"@atlaskit/editor-test-helpers": "^18.9.0",
|
|
56
|
-
"@atlaskit/link-test-helpers": "^
|
|
53
|
+
"@atlaskit/link-test-helpers": "^6.0.0",
|
|
57
54
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
58
55
|
"@atlaskit/ssr": "*",
|
|
59
56
|
"@atlaskit/util-data-test": "^17.8.0",
|
package/report.api.md
CHANGED
|
@@ -17,19 +17,21 @@
|
|
|
17
17
|
```ts
|
|
18
18
|
import type { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
19
19
|
import type { Command } from '@atlaskit/editor-common/types';
|
|
20
|
-
import { EditorState } from 'prosemirror
|
|
21
|
-
import { EditorView } from 'prosemirror
|
|
20
|
+
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
21
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
22
22
|
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
23
|
-
import { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
23
|
+
import type { FloatingToolbarItem } from '@atlaskit/editor-common/types';
|
|
24
24
|
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
|
-
import { Transaction } from 'prosemirror
|
|
33
|
+
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
34
|
+
import type { 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 type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
+
import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
11
|
+
import type featureFlagsPlugin from '@atlaskit/editor-plugin-feature-flags';
|
|
12
|
+
import type { 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 type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
23
|
+
import type { 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
|
+
```
|