@atlaskit/editor-plugin-hyperlink 0.5.3 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/Toolbar.js +4 -5
- package/dist/cjs/commands.js +11 -16
- package/dist/cjs/plugin.js +9 -10
- package/dist/cjs/pm-plugins/fake-curor-for-toolbar-plugin-key.js +1 -2
- package/dist/cjs/pm-plugins/fake-cursor-for-toolbar.js +1 -2
- package/dist/cjs/pm-plugins/input-rule.js +3 -4
- package/dist/cjs/pm-plugins/keymap.js +2 -3
- package/dist/cjs/pm-plugins/main.js +2 -4
- package/dist/cjs/pm-plugins/toolbar-buttons.js +4 -7
- package/dist/es2019/commands.js +1 -2
- package/dist/esm/Toolbar.js +2 -2
- package/dist/esm/commands.js +6 -7
- package/dist/esm/plugin.js +7 -7
- package/dist/esm/pm-plugins/input-rule.js +2 -2
- package/dist/esm/pm-plugins/keymap.js +1 -1
- package/package.json +5 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 0.5.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#42680](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42680) [`1174ff1745b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1174ff1745b) - Cleans up ff platform.linking-platform.editor.fix-link-insert-analytics. No expected functional changes.
|
|
8
|
+
|
|
9
|
+
## 0.5.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 0.5.3
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cjs/Toolbar.js
CHANGED
|
@@ -32,7 +32,7 @@ function isEditLink(linkMark) {
|
|
|
32
32
|
var dispatchAnalytics = function dispatchAnalytics(dispatch, state, analyticsBuilder, editorAnalyticsApi) {
|
|
33
33
|
if (dispatch) {
|
|
34
34
|
var tr = state.tr;
|
|
35
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
35
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(analyticsBuilder(_analytics.ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
36
36
|
dispatch(tr);
|
|
37
37
|
}
|
|
38
38
|
};
|
|
@@ -109,12 +109,12 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(state, intl, featur
|
|
|
109
109
|
target: '_blank'
|
|
110
110
|
}] : [];
|
|
111
111
|
};
|
|
112
|
-
var getToolbarConfig = function getToolbarConfig(options, featureFlags, pluginInjectionApi) {
|
|
112
|
+
var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(options, featureFlags, pluginInjectionApi) {
|
|
113
113
|
return function (state, intl, providerFactory) {
|
|
114
114
|
var _pluginInjectionApi$a;
|
|
115
115
|
var formatMessage = intl.formatMessage;
|
|
116
116
|
var linkState = _main.stateKey.getState(state);
|
|
117
|
-
var editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0
|
|
117
|
+
var editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
118
118
|
|
|
119
119
|
/**
|
|
120
120
|
* Enable focus trap only if feature flag is enabled AND for the new version of the picker
|
|
@@ -276,5 +276,4 @@ var getToolbarConfig = function getToolbarConfig(options, featureFlags, pluginIn
|
|
|
276
276
|
}
|
|
277
277
|
return;
|
|
278
278
|
};
|
|
279
|
-
};
|
|
280
|
-
exports.getToolbarConfig = getToolbarConfig;
|
|
279
|
+
};
|
package/dist/cjs/commands.js
CHANGED
|
@@ -20,7 +20,6 @@ var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
|
20
20
|
var _link = require("@atlaskit/editor-common/link");
|
|
21
21
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
22
22
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
23
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
24
23
|
var _main = require("./pm-plugins/main");
|
|
25
24
|
var _toolbarButtons = require("./pm-plugins/toolbar-buttons");
|
|
26
25
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
@@ -42,7 +41,7 @@ function setLinkHref(href, pos, editorAnalyticsApi, to, isTabPressed) {
|
|
|
42
41
|
href: url
|
|
43
42
|
})));
|
|
44
43
|
} else {
|
|
45
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
44
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.unlinkPayload)(_analytics.ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
46
45
|
}
|
|
47
46
|
if (!isTabPressed) {
|
|
48
47
|
tr.setMeta(_main.stateKey, {
|
|
@@ -117,7 +116,7 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
117
116
|
var _toolbarKey$getState;
|
|
118
117
|
var queueCardsFromChangedTr = (_toolbarKey$getState = _toolbarButtons.toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
119
118
|
if (queueCardsFromChangedTr) {
|
|
120
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0
|
|
119
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, _analytics.ACTION.INSERTED, false, sourceEvent);
|
|
121
120
|
} else {
|
|
122
121
|
(0, _card.addLinkMetadata)(state.selection, tr, {
|
|
123
122
|
action: _analytics.ACTION.INSERTED,
|
|
@@ -125,7 +124,7 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
125
124
|
sourceEvent: sourceEvent
|
|
126
125
|
});
|
|
127
126
|
}
|
|
128
|
-
} else
|
|
127
|
+
} else {
|
|
129
128
|
/**
|
|
130
129
|
* Add link metadata because queue cards would have otherwise handled this for us
|
|
131
130
|
*/
|
|
@@ -152,7 +151,7 @@ function insertLink(from, to, incomingHref, incomingTitle, displayText, source,
|
|
|
152
151
|
return false;
|
|
153
152
|
};
|
|
154
153
|
}
|
|
155
|
-
var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
154
|
+
var insertLinkWithAnalytics = exports.insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from, to, href, editorAnalyticsApi, title, displayText) {
|
|
156
155
|
var cardsAvailable = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
|
157
156
|
var sourceEvent = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : undefined;
|
|
158
157
|
// If smart cards are available, we send analytics for hyperlinks when a smart link is rejected.
|
|
@@ -161,7 +160,6 @@ var insertLinkWithAnalytics = function insertLinkWithAnalytics(inputMethod, from
|
|
|
161
160
|
}
|
|
162
161
|
return (0, _editorAnalytics.withAnalytics)(editorAnalyticsApi, (0, _utils.getLinkCreationAnalyticsEvent)(inputMethod, href))(insertLink(from, to, href, title, displayText, inputMethod, sourceEvent));
|
|
163
162
|
};
|
|
164
|
-
exports.insertLinkWithAnalytics = insertLinkWithAnalytics;
|
|
165
163
|
function removeLink(pos, editorAnalyticsApi) {
|
|
166
164
|
return (0, _card.commandWithMetadata)(setLinkHref('', pos, editorAnalyticsApi), {
|
|
167
165
|
action: _analytics.ACTION.UNLINK
|
|
@@ -175,7 +173,7 @@ function editInsertedLink(editorAnalyticsApi) {
|
|
|
175
173
|
type: _link.LinkAction.EDIT_INSERTED_TOOLBAR,
|
|
176
174
|
inputMethod: _analytics.INPUT_METHOD.FLOATING_TB
|
|
177
175
|
});
|
|
178
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
176
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _analytics.buildEditLinkPayload)(_analytics.ACTION_SUBJECT_ID.HYPERLINK))(_tr);
|
|
179
177
|
dispatch(_tr);
|
|
180
178
|
}
|
|
181
179
|
return true;
|
|
@@ -188,7 +186,7 @@ function showLinkToolbar(inputMethod, editorAnalyticsApi) {
|
|
|
188
186
|
type: _link.LinkAction.SHOW_INSERT_TOOLBAR,
|
|
189
187
|
inputMethod: inputMethod
|
|
190
188
|
});
|
|
191
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
189
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
192
190
|
action: _analytics.ACTION.INVOKED,
|
|
193
191
|
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
194
192
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
@@ -208,29 +206,26 @@ function hideLinkToolbar() {
|
|
|
208
206
|
return true;
|
|
209
207
|
};
|
|
210
208
|
}
|
|
211
|
-
var hideLinkToolbarSetMeta = function hideLinkToolbarSetMeta(tr) {
|
|
209
|
+
var hideLinkToolbarSetMeta = exports.hideLinkToolbarSetMeta = function hideLinkToolbarSetMeta(tr) {
|
|
212
210
|
return tr.setMeta(_main.stateKey, {
|
|
213
211
|
type: _link.LinkAction.HIDE_TOOLBAR
|
|
214
212
|
});
|
|
215
213
|
};
|
|
216
|
-
exports.
|
|
217
|
-
var onEscapeCallback = function onEscapeCallback(state, dispatch) {
|
|
214
|
+
var onEscapeCallback = exports.onEscapeCallback = function onEscapeCallback(state, dispatch) {
|
|
218
215
|
var _toolbarKey$getState2, _toolbarKey$getState3;
|
|
219
216
|
var tr = state.tr;
|
|
220
217
|
hideLinkToolbarSetMeta(tr);
|
|
221
|
-
(_toolbarKey$getState2 = _toolbarButtons.toolbarKey.getState(state)) === null || _toolbarKey$getState2 === void 0
|
|
218
|
+
(_toolbarKey$getState2 = _toolbarButtons.toolbarKey.getState(state)) === null || _toolbarKey$getState2 === void 0 || (_toolbarKey$getState3 = _toolbarKey$getState2.onEscapeCallback) === null || _toolbarKey$getState3 === void 0 || _toolbarKey$getState3.call(_toolbarKey$getState2, tr);
|
|
222
219
|
if (dispatch) {
|
|
223
220
|
dispatch(tr);
|
|
224
221
|
return true;
|
|
225
222
|
}
|
|
226
223
|
return false;
|
|
227
224
|
};
|
|
228
|
-
exports.
|
|
229
|
-
var onClickAwayCallback = function onClickAwayCallback(state, dispatch) {
|
|
225
|
+
var onClickAwayCallback = exports.onClickAwayCallback = function onClickAwayCallback(state, dispatch) {
|
|
230
226
|
if (dispatch) {
|
|
231
227
|
hideLinkToolbar()(state, dispatch);
|
|
232
228
|
return true;
|
|
233
229
|
}
|
|
234
230
|
return false;
|
|
235
|
-
};
|
|
236
|
-
exports.onClickAwayCallback = onClickAwayCallback;
|
|
231
|
+
};
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -23,12 +23,12 @@ var _Toolbar = require("./Toolbar");
|
|
|
23
23
|
* Hyperlink plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
24
24
|
* from `@atlaskit/editor-core`.
|
|
25
25
|
*/
|
|
26
|
-
var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
26
|
+
var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
27
27
|
var _api$featureFlags;
|
|
28
28
|
var _ref$config = _ref.config,
|
|
29
29
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
30
30
|
api = _ref.api;
|
|
31
|
-
var featureFlags = (api === null || api === void 0
|
|
31
|
+
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
32
32
|
return {
|
|
33
33
|
name: 'hyperlink',
|
|
34
34
|
marks: function marks() {
|
|
@@ -41,7 +41,7 @@ var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
41
41
|
showLinkToolbar: function showLinkToolbar() {
|
|
42
42
|
var _api$analytics;
|
|
43
43
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _analytics.INPUT_METHOD.TOOLBAR;
|
|
44
|
-
return (0, _commands.showLinkToolbar)(inputMethod, api === null || api === void 0
|
|
44
|
+
return (0, _commands.showLinkToolbar)(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
actions: {
|
|
@@ -51,7 +51,7 @@ var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
51
51
|
var _api$analytics2;
|
|
52
52
|
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
53
53
|
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
54
|
-
return (0, _commands.insertLinkWithAnalytics)(inputMethod, from, to, href, api === null || api === void 0
|
|
54
|
+
return (0, _commands.insertLinkWithAnalytics)(inputMethod, from, to, href, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
55
55
|
},
|
|
56
56
|
updateLink: _commands.updateLink
|
|
57
57
|
},
|
|
@@ -83,13 +83,13 @@ var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
83
83
|
var _api$analytics3;
|
|
84
84
|
var schema = _ref3.schema,
|
|
85
85
|
featureFlags = _ref3.featureFlags;
|
|
86
|
-
return (0, _inputRule.createInputRulePlugin)(schema, skipAnalytics, featureFlags, api === null || api === void 0
|
|
86
|
+
return (0, _inputRule.createInputRulePlugin)(schema, skipAnalytics, featureFlags, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
87
87
|
}
|
|
88
88
|
}, {
|
|
89
89
|
name: 'hyperlinkKeymap',
|
|
90
90
|
plugin: function plugin() {
|
|
91
91
|
var _api$analytics4;
|
|
92
|
-
return (0, _keymap.createKeymapPlugin)(skipAnalytics, api === null || api === void 0
|
|
92
|
+
return (0, _keymap.createKeymapPlugin)(skipAnalytics, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
93
93
|
}
|
|
94
94
|
}, {
|
|
95
95
|
name: 'hyperlinkToolbarButtons',
|
|
@@ -110,13 +110,13 @@ var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
110
110
|
return /*#__PURE__*/_react.default.createElement(_quickInsert.IconLink, null);
|
|
111
111
|
},
|
|
112
112
|
action: function action(insert, state) {
|
|
113
|
-
var _api$analytics5, _api$analytics5$
|
|
113
|
+
var _api$analytics5, _api$analytics5$attac;
|
|
114
114
|
var tr = insert(undefined);
|
|
115
115
|
tr.setMeta(_main.stateKey, {
|
|
116
116
|
type: _link.LinkAction.SHOW_INSERT_TOOLBAR,
|
|
117
117
|
inputMethod: _analytics.INPUT_METHOD.QUICK_INSERT
|
|
118
118
|
});
|
|
119
|
-
var analyticsAttached = api === null || api === void 0
|
|
119
|
+
var analyticsAttached = api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || (_api$analytics5 = _api$analytics5.actions) === null || _api$analytics5 === void 0 || (_api$analytics5$attac = _api$analytics5.attachAnalyticsEvent) === null || _api$analytics5$attac === void 0 ? void 0 : _api$analytics5$attac.call(_api$analytics5, {
|
|
120
120
|
action: _analytics.ACTION.INVOKED,
|
|
121
121
|
actionSubject: _analytics.ACTION_SUBJECT.TYPEAHEAD,
|
|
122
122
|
actionSubjectId: _analytics.ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
@@ -132,5 +132,4 @@ var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
132
132
|
floatingToolbar: (0, _Toolbar.getToolbarConfig)(options, featureFlags, api)
|
|
133
133
|
}
|
|
134
134
|
};
|
|
135
|
-
};
|
|
136
|
-
exports.hyperlinkPlugin = hyperlinkPlugin;
|
|
135
|
+
};
|
|
@@ -5,5 +5,4 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.fakeCursorForToolbarPluginKey = void 0;
|
|
7
7
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
8
|
-
var fakeCursorForToolbarPluginKey = new _state.PluginKey('fakeCursorToolbarPlugin');
|
|
9
|
-
exports.fakeCursorForToolbarPluginKey = fakeCursorForToolbarPluginKey;
|
|
8
|
+
var fakeCursorForToolbarPluginKey = exports.fakeCursorForToolbarPluginKey = new _state.PluginKey('fakeCursorToolbarPlugin');
|
|
@@ -55,7 +55,7 @@ function createLinkInputRule(regexp) {
|
|
|
55
55
|
if (skipAnalytics) {
|
|
56
56
|
return tr;
|
|
57
57
|
}
|
|
58
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
58
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _utils.getLinkCreationAnalyticsEvent)(_analytics.INPUT_METHOD.AUTO_DETECT, url))(tr);
|
|
59
59
|
return tr;
|
|
60
60
|
});
|
|
61
61
|
}
|
|
@@ -86,10 +86,9 @@ function createInputRulePlugin(schema) {
|
|
|
86
86
|
if (skipAnalytics) {
|
|
87
87
|
return tr;
|
|
88
88
|
}
|
|
89
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
89
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _utils.getLinkCreationAnalyticsEvent)(_analytics.INPUT_METHOD.FORMATTING, url))(tr);
|
|
90
90
|
return tr;
|
|
91
91
|
});
|
|
92
92
|
return (0, _prosemirrorInputRules.createPlugin)('hyperlink', [urlWithASpaceRule, markdownLinkRule]);
|
|
93
93
|
}
|
|
94
|
-
var _default = createInputRulePlugin;
|
|
95
|
-
exports.default = _default;
|
|
94
|
+
var _default = exports.default = createInputRulePlugin;
|
|
@@ -67,7 +67,7 @@ var mayConvertLastWordToHyperlink = function mayConvertLastWordToHyperlink(skipA
|
|
|
67
67
|
if (skipAnalytics) {
|
|
68
68
|
dispatch(tr);
|
|
69
69
|
} else {
|
|
70
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
70
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _utils.getLinkCreationAnalyticsEvent)(_analytics.INPUT_METHOD.AUTO_DETECT, url))(tr);
|
|
71
71
|
dispatch(tr);
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -75,5 +75,4 @@ var mayConvertLastWordToHyperlink = function mayConvertLastWordToHyperlink(skipA
|
|
|
75
75
|
return false;
|
|
76
76
|
};
|
|
77
77
|
};
|
|
78
|
-
var _default = createKeymapPlugin;
|
|
79
|
-
exports.default = _default;
|
|
78
|
+
var _default = exports.default = createKeymapPlugin;
|
|
@@ -153,9 +153,8 @@ var getActiveText = function getActiveText(selection) {
|
|
|
153
153
|
}
|
|
154
154
|
return;
|
|
155
155
|
};
|
|
156
|
-
var stateKey = new _state.PluginKey('hyperlinkPlugin');
|
|
157
|
-
exports.
|
|
158
|
-
var plugin = function plugin(dispatch, editorAppearance) {
|
|
156
|
+
var stateKey = exports.stateKey = new _state.PluginKey('hyperlinkPlugin');
|
|
157
|
+
var plugin = exports.plugin = function plugin(dispatch, editorAppearance) {
|
|
159
158
|
return new _safePlugin.SafePlugin({
|
|
160
159
|
state: {
|
|
161
160
|
init: function init(_, state) {
|
|
@@ -251,7 +250,6 @@ var plugin = function plugin(dispatch, editorAppearance) {
|
|
|
251
250
|
}
|
|
252
251
|
});
|
|
253
252
|
};
|
|
254
|
-
exports.plugin = plugin;
|
|
255
253
|
function isLinkDirectTarget(event) {
|
|
256
254
|
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target.tagName === 'A';
|
|
257
255
|
}
|
|
@@ -6,9 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.toolbarKey = exports.toolbarButtonsPlugin = exports.prependToolbarButtons = void 0;
|
|
7
7
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
8
8
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
9
|
-
var toolbarKey = new _state.PluginKey('hyperlinkToolbarItems');
|
|
10
|
-
exports.
|
|
11
|
-
var prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
9
|
+
var toolbarKey = exports.toolbarKey = new _state.PluginKey('hyperlinkToolbarItems');
|
|
10
|
+
var prependToolbarButtons = exports.prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
12
11
|
var items = _ref.items,
|
|
13
12
|
onEscapeCallback = _ref.onEscapeCallback,
|
|
14
13
|
onInsertLinkCallback = _ref.onInsertLinkCallback,
|
|
@@ -22,8 +21,7 @@ var prependToolbarButtons = function prependToolbarButtons(_ref) {
|
|
|
22
21
|
});
|
|
23
22
|
dispatch(tr);
|
|
24
23
|
};
|
|
25
|
-
exports.
|
|
26
|
-
var toolbarButtonsPlugin = function toolbarButtonsPlugin() {
|
|
24
|
+
var toolbarButtonsPlugin = exports.toolbarButtonsPlugin = function toolbarButtonsPlugin() {
|
|
27
25
|
return new _safePlugin.SafePlugin({
|
|
28
26
|
key: toolbarKey,
|
|
29
27
|
state: {
|
|
@@ -39,5 +37,4 @@ var toolbarButtonsPlugin = function toolbarButtonsPlugin() {
|
|
|
39
37
|
}
|
|
40
38
|
}
|
|
41
39
|
});
|
|
42
|
-
};
|
|
43
|
-
exports.toolbarButtonsPlugin = toolbarButtonsPlugin;
|
|
40
|
+
};
|
package/dist/es2019/commands.js
CHANGED
|
@@ -4,7 +4,6 @@ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
|
4
4
|
import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
|
|
5
5
|
import { filterCommand as filter, getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
8
7
|
import { stateKey } from './pm-plugins/main';
|
|
9
8
|
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
10
9
|
export function setLinkHref(href, pos, editorAnalyticsApi, to, isTabPressed) {
|
|
@@ -111,7 +110,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
111
110
|
sourceEvent
|
|
112
111
|
});
|
|
113
112
|
}
|
|
114
|
-
} else
|
|
113
|
+
} else {
|
|
115
114
|
/**
|
|
116
115
|
* Add link metadata because queue cards would have otherwise handled this for us
|
|
117
116
|
*/
|
package/dist/esm/Toolbar.js
CHANGED
|
@@ -24,7 +24,7 @@ function isEditLink(linkMark) {
|
|
|
24
24
|
var dispatchAnalytics = function dispatchAnalytics(dispatch, state, analyticsBuilder, editorAnalyticsApi) {
|
|
25
25
|
if (dispatch) {
|
|
26
26
|
var tr = state.tr;
|
|
27
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
27
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(analyticsBuilder(ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
28
28
|
dispatch(tr);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
@@ -106,7 +106,7 @@ export var getToolbarConfig = function getToolbarConfig(options, featureFlags, p
|
|
|
106
106
|
var _pluginInjectionApi$a;
|
|
107
107
|
var formatMessage = intl.formatMessage;
|
|
108
108
|
var linkState = stateKey.getState(state);
|
|
109
|
-
var editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0
|
|
109
|
+
var editorAnalyticsApi = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions;
|
|
110
110
|
|
|
111
111
|
/**
|
|
112
112
|
* Enable focus trap only if feature flag is enabled AND for the new version of the picker
|
package/dist/esm/commands.js
CHANGED
|
@@ -7,7 +7,6 @@ import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
|
7
7
|
import { isTextAtPos, LinkAction } from '@atlaskit/editor-common/link';
|
|
8
8
|
import { filterCommand as filter, getLinkCreationAnalyticsEvent, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
10
|
-
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
11
10
|
import { stateKey } from './pm-plugins/main';
|
|
12
11
|
import { toolbarKey } from './pm-plugins/toolbar-buttons';
|
|
13
12
|
export function setLinkHref(href, pos, editorAnalyticsApi, to, isTabPressed) {
|
|
@@ -27,7 +26,7 @@ export function setLinkHref(href, pos, editorAnalyticsApi, to, isTabPressed) {
|
|
|
27
26
|
href: url
|
|
28
27
|
})));
|
|
29
28
|
} else {
|
|
30
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
29
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(unlinkPayload(ACTION_SUBJECT_ID.HYPERLINK))(tr);
|
|
31
30
|
}
|
|
32
31
|
if (!isTabPressed) {
|
|
33
32
|
tr.setMeta(stateKey, {
|
|
@@ -102,7 +101,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
102
101
|
var _toolbarKey$getState;
|
|
103
102
|
var queueCardsFromChangedTr = (_toolbarKey$getState = toolbarKey.getState(state)) === null || _toolbarKey$getState === void 0 ? void 0 : _toolbarKey$getState.onInsertLinkCallback;
|
|
104
103
|
if (queueCardsFromChangedTr) {
|
|
105
|
-
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0
|
|
104
|
+
queueCardsFromChangedTr === null || queueCardsFromChangedTr === void 0 || queueCardsFromChangedTr(state, tr, source, ACTION.INSERTED, false, sourceEvent);
|
|
106
105
|
} else {
|
|
107
106
|
addLinkMetadata(state.selection, tr, {
|
|
108
107
|
action: ACTION.INSERTED,
|
|
@@ -110,7 +109,7 @@ export function insertLink(from, to, incomingHref, incomingTitle, displayText, s
|
|
|
110
109
|
sourceEvent: sourceEvent
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
|
-
} else
|
|
112
|
+
} else {
|
|
114
113
|
/**
|
|
115
114
|
* Add link metadata because queue cards would have otherwise handled this for us
|
|
116
115
|
*/
|
|
@@ -159,7 +158,7 @@ export function editInsertedLink(editorAnalyticsApi) {
|
|
|
159
158
|
type: LinkAction.EDIT_INSERTED_TOOLBAR,
|
|
160
159
|
inputMethod: INPUT_METHOD.FLOATING_TB
|
|
161
160
|
});
|
|
162
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
161
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(buildEditLinkPayload(ACTION_SUBJECT_ID.HYPERLINK))(_tr);
|
|
163
162
|
dispatch(_tr);
|
|
164
163
|
}
|
|
165
164
|
return true;
|
|
@@ -172,7 +171,7 @@ export function showLinkToolbar(inputMethod, editorAnalyticsApi) {
|
|
|
172
171
|
type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
173
172
|
inputMethod: inputMethod
|
|
174
173
|
});
|
|
175
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
174
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
176
175
|
action: ACTION.INVOKED,
|
|
177
176
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
178
177
|
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
@@ -201,7 +200,7 @@ export var onEscapeCallback = function onEscapeCallback(state, dispatch) {
|
|
|
201
200
|
var _toolbarKey$getState2, _toolbarKey$getState3;
|
|
202
201
|
var tr = state.tr;
|
|
203
202
|
hideLinkToolbarSetMeta(tr);
|
|
204
|
-
(_toolbarKey$getState2 = toolbarKey.getState(state)) === null || _toolbarKey$getState2 === void 0
|
|
203
|
+
(_toolbarKey$getState2 = toolbarKey.getState(state)) === null || _toolbarKey$getState2 === void 0 || (_toolbarKey$getState3 = _toolbarKey$getState2.onEscapeCallback) === null || _toolbarKey$getState3 === void 0 || _toolbarKey$getState3.call(_toolbarKey$getState2, tr);
|
|
205
204
|
if (dispatch) {
|
|
206
205
|
dispatch(tr);
|
|
207
206
|
return true;
|
package/dist/esm/plugin.js
CHANGED
|
@@ -21,7 +21,7 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
21
21
|
var _ref$config = _ref.config,
|
|
22
22
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
23
23
|
api = _ref.api;
|
|
24
|
-
var featureFlags = (api === null || api === void 0
|
|
24
|
+
var featureFlags = (api === null || api === void 0 || (_api$featureFlags = api.featureFlags) === null || _api$featureFlags === void 0 ? void 0 : _api$featureFlags.sharedState.currentState()) || {};
|
|
25
25
|
return {
|
|
26
26
|
name: 'hyperlink',
|
|
27
27
|
marks: function marks() {
|
|
@@ -34,7 +34,7 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
34
34
|
showLinkToolbar: function showLinkToolbar() {
|
|
35
35
|
var _api$analytics;
|
|
36
36
|
var inputMethod = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INPUT_METHOD.TOOLBAR;
|
|
37
|
-
return _showLinkToolbar(inputMethod, api === null || api === void 0
|
|
37
|
+
return _showLinkToolbar(inputMethod, api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions);
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
40
|
actions: {
|
|
@@ -44,7 +44,7 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
44
44
|
var _api$analytics2;
|
|
45
45
|
var cardsAvailable = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
|
|
46
46
|
var sourceEvent = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : undefined;
|
|
47
|
-
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0
|
|
47
|
+
return insertLinkWithAnalytics(inputMethod, from, to, href, api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, title, displayText, cardsAvailable, sourceEvent);
|
|
48
48
|
},
|
|
49
49
|
updateLink: updateLink
|
|
50
50
|
},
|
|
@@ -76,13 +76,13 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
76
76
|
var _api$analytics3;
|
|
77
77
|
var schema = _ref3.schema,
|
|
78
78
|
featureFlags = _ref3.featureFlags;
|
|
79
|
-
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0
|
|
79
|
+
return createInputRulePlugin(schema, skipAnalytics, featureFlags, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
80
80
|
}
|
|
81
81
|
}, {
|
|
82
82
|
name: 'hyperlinkKeymap',
|
|
83
83
|
plugin: function plugin() {
|
|
84
84
|
var _api$analytics4;
|
|
85
|
-
return createKeymapPlugin(skipAnalytics, api === null || api === void 0
|
|
85
|
+
return createKeymapPlugin(skipAnalytics, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
86
86
|
}
|
|
87
87
|
}, {
|
|
88
88
|
name: 'hyperlinkToolbarButtons',
|
|
@@ -103,13 +103,13 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
103
103
|
return /*#__PURE__*/React.createElement(IconLink, null);
|
|
104
104
|
},
|
|
105
105
|
action: function action(insert, state) {
|
|
106
|
-
var _api$analytics5, _api$analytics5$
|
|
106
|
+
var _api$analytics5, _api$analytics5$attac;
|
|
107
107
|
var tr = insert(undefined);
|
|
108
108
|
tr.setMeta(stateKey, {
|
|
109
109
|
type: LinkAction.SHOW_INSERT_TOOLBAR,
|
|
110
110
|
inputMethod: INPUT_METHOD.QUICK_INSERT
|
|
111
111
|
});
|
|
112
|
-
var analyticsAttached = api === null || api === void 0
|
|
112
|
+
var analyticsAttached = api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 || (_api$analytics5 = _api$analytics5.actions) === null || _api$analytics5 === void 0 || (_api$analytics5$attac = _api$analytics5.attachAnalyticsEvent) === null || _api$analytics5$attac === void 0 ? void 0 : _api$analytics5$attac.call(_api$analytics5, {
|
|
113
113
|
action: ACTION.INVOKED,
|
|
114
114
|
actionSubject: ACTION_SUBJECT.TYPEAHEAD,
|
|
115
115
|
actionSubjectId: ACTION_SUBJECT_ID.TYPEAHEAD_LINK,
|
|
@@ -46,7 +46,7 @@ export function createLinkInputRule(regexp) {
|
|
|
46
46
|
if (skipAnalytics) {
|
|
47
47
|
return tr;
|
|
48
48
|
}
|
|
49
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
49
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(INPUT_METHOD.AUTO_DETECT, url))(tr);
|
|
50
50
|
return tr;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -77,7 +77,7 @@ export function createInputRulePlugin(schema) {
|
|
|
77
77
|
if (skipAnalytics) {
|
|
78
78
|
return tr;
|
|
79
79
|
}
|
|
80
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
80
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(INPUT_METHOD.FORMATTING, url))(tr);
|
|
81
81
|
return tr;
|
|
82
82
|
});
|
|
83
83
|
return createPlugin('hyperlink', [urlWithASpaceRule, markdownLinkRule]);
|
|
@@ -60,7 +60,7 @@ var mayConvertLastWordToHyperlink = function mayConvertLastWordToHyperlink(skipA
|
|
|
60
60
|
if (skipAnalytics) {
|
|
61
61
|
dispatch(tr);
|
|
62
62
|
} else {
|
|
63
|
-
editorAnalyticsApi === null || editorAnalyticsApi === void 0
|
|
63
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(INPUT_METHOD.AUTO_DETECT, url))(tr);
|
|
64
64
|
dispatch(tr);
|
|
65
65
|
}
|
|
66
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,12 +33,11 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^32.0.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^9.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^76.
|
|
37
|
-
"@atlaskit/editor-plugin-analytics": "^0.
|
|
36
|
+
"@atlaskit/editor-common": "^76.18.0",
|
|
37
|
+
"@atlaskit/editor-plugin-analytics": "^0.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-feature-flags": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "1.1.0",
|
|
40
40
|
"@atlaskit/icon": "^21.12.0",
|
|
41
|
-
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
42
41
|
"@atlaskit/prosemirror-input-rules": "^2.4.0",
|
|
43
42
|
"@babel/runtime": "^7.0.0",
|
|
44
43
|
"uuid": "^3.1.0"
|
|
@@ -49,7 +48,7 @@
|
|
|
49
48
|
},
|
|
50
49
|
"devDependencies": {
|
|
51
50
|
"@atlaskit/activity-provider": "^2.4.0",
|
|
52
|
-
"@atlaskit/link-test-helpers": "^6.
|
|
51
|
+
"@atlaskit/link-test-helpers": "^6.2.0",
|
|
53
52
|
"@atlaskit/media-test-helpers": "^33.0.0",
|
|
54
53
|
"@atlaskit/ssr": "*",
|
|
55
54
|
"@atlaskit/util-data-test": "^17.8.0",
|
|
@@ -95,9 +94,5 @@
|
|
|
95
94
|
}
|
|
96
95
|
},
|
|
97
96
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.0",
|
|
98
|
-
"platform-feature-flags": {
|
|
99
|
-
"platform.linking-platform.editor.fix-link-insert-analytics": {
|
|
100
|
-
"type": "boolean"
|
|
101
|
-
}
|
|
102
|
-
}
|
|
97
|
+
"platform-feature-flags": {}
|
|
103
98
|
}
|