@atlaskit/editor-plugin-hyperlink 2.4.2 → 2.5.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/CHANGELOG.md +21 -0
- package/dist/cjs/plugin.js +3 -4
- package/dist/cjs/pm-plugins/main.js +37 -1
- package/dist/es2019/plugin.js +2 -2
- package/dist/es2019/pm-plugins/main.js +37 -1
- package/dist/esm/plugin.js +3 -4
- package/dist/esm/pm-plugins/main.js +37 -1
- package/dist/types/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/pm-plugins/main.d.ts +2 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 2.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 2.5.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#121606](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/121606)
|
|
14
|
+
[`fb55435295b55`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fb55435295b55) -
|
|
15
|
+
Add on click callback to hyperlink plugin for live page
|
|
16
|
+
- [#122895](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/122895)
|
|
17
|
+
[`49b8c7658f3b5`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/49b8c7658f3b5) -
|
|
18
|
+
[ED-24173] bump @atlaskit/adf-schema to 40.3.0 and @atlassian/adf-schema-json to 1.18.0
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 2.4.2
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -100,10 +100,9 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
100
100
|
plugin: function plugin(_ref2) {
|
|
101
101
|
var dispatch = _ref2.dispatch,
|
|
102
102
|
getIntl = _ref2.getIntl;
|
|
103
|
-
return (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
);
|
|
103
|
+
return (0, _main.plugin)(dispatch, getIntl(), options === null || options === void 0 ? void 0 : options.editorAppearance, api, options === null || options === void 0 ? void 0 : options.onClickCallback,
|
|
104
|
+
// @ts-ignore Temporary solution to check for Live Page editor.
|
|
105
|
+
options.__livePage);
|
|
107
106
|
}
|
|
108
107
|
}, {
|
|
109
108
|
name: 'fakeCursorToolbarPlugin',
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.stateKey = exports.plugin = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _uuid = _interopRequireDefault(require("uuid"));
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
10
11
|
var _link3 = require("@atlaskit/editor-common/link");
|
|
11
12
|
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
12
13
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
@@ -158,7 +159,7 @@ var getActiveText = function getActiveText(selection) {
|
|
|
158
159
|
return;
|
|
159
160
|
};
|
|
160
161
|
var stateKey = exports.stateKey = new _state.PluginKey('hyperlinkPlugin');
|
|
161
|
-
var plugin = exports.plugin = function plugin(dispatch, intl, editorAppearance, pluginInjectionApi, __livePage) {
|
|
162
|
+
var plugin = exports.plugin = function plugin(dispatch, intl, editorAppearance, pluginInjectionApi, onClickCallback, __livePage) {
|
|
162
163
|
return new _safePlugin.SafePlugin({
|
|
163
164
|
state: {
|
|
164
165
|
init: function init(_, state) {
|
|
@@ -337,6 +338,38 @@ var plugin = exports.plugin = function plugin(dispatch, intl, editorAppearance,
|
|
|
337
338
|
setTargetElementPos(undefined);
|
|
338
339
|
}
|
|
339
340
|
};
|
|
341
|
+
dom.onclick = function (event) {
|
|
342
|
+
if (isDirectTarget(event, dom)) {
|
|
343
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2;
|
|
344
|
+
var url = mark.attrs.href;
|
|
345
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a2 = _pluginInjectionApi$a.fireAnalyticsEvent) === null || _pluginInjectionApi$a2 === void 0 || _pluginInjectionApi$a2.call(_pluginInjectionApi$a, {
|
|
346
|
+
action: _analytics.ACTION.VISITED,
|
|
347
|
+
actionSubject: _analytics.ACTION_SUBJECT.LINK,
|
|
348
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
349
|
+
attributes: {
|
|
350
|
+
platform: _analytics.PLATFORMS.WEB,
|
|
351
|
+
mode: _analytics.MODE.EDITOR
|
|
352
|
+
}
|
|
353
|
+
});
|
|
354
|
+
if (url) {
|
|
355
|
+
try {
|
|
356
|
+
onClickCallback === null || onClickCallback === void 0 || onClickCallback({
|
|
357
|
+
event: event,
|
|
358
|
+
url: url
|
|
359
|
+
});
|
|
360
|
+
} catch (_unused) {}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Links should navigate by default in live pages if:
|
|
364
|
+
* - the link is the direct target of the click event
|
|
365
|
+
* - default handling wasn't prevented with `event.preventDefault()`
|
|
366
|
+
*/
|
|
367
|
+
if (!event.defaultPrevented) {
|
|
368
|
+
window.location.href = url;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
};
|
|
340
373
|
return {
|
|
341
374
|
dom: dom
|
|
342
375
|
};
|
|
@@ -347,4 +380,7 @@ var plugin = exports.plugin = function plugin(dispatch, intl, editorAppearance,
|
|
|
347
380
|
};
|
|
348
381
|
function isLinkDirectTarget(event) {
|
|
349
382
|
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target.tagName === 'A';
|
|
383
|
+
}
|
|
384
|
+
function isDirectTarget(event, element) {
|
|
385
|
+
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target === element;
|
|
350
386
|
}
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -85,9 +85,9 @@ export const hyperlinkPlugin = ({
|
|
|
85
85
|
plugin: ({
|
|
86
86
|
dispatch,
|
|
87
87
|
getIntl
|
|
88
|
-
}) =>
|
|
88
|
+
}) => plugin(dispatch, getIntl(), options === null || options === void 0 ? void 0 : options.editorAppearance, api, options === null || options === void 0 ? void 0 : options.onClickCallback,
|
|
89
89
|
// @ts-ignore Temporary solution to check for Live Page editor.
|
|
90
|
-
|
|
90
|
+
options.__livePage)
|
|
91
91
|
}, {
|
|
92
92
|
name: 'fakeCursorToolbarPlugin',
|
|
93
93
|
plugin: () => fakeCursorToolbarPlugin
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import uuid from 'uuid';
|
|
2
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
2
3
|
import { InsertStatus, LinkAction } from '@atlaskit/editor-common/link';
|
|
3
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
5
|
import { canLinkBeCreatedInRange, shallowEqual } from '@atlaskit/editor-common/utils';
|
|
@@ -159,7 +160,7 @@ const getActiveText = selection => {
|
|
|
159
160
|
return;
|
|
160
161
|
};
|
|
161
162
|
export const stateKey = new PluginKey('hyperlinkPlugin');
|
|
162
|
-
export const plugin = (dispatch, intl, editorAppearance, pluginInjectionApi, __livePage) => new SafePlugin({
|
|
163
|
+
export const plugin = (dispatch, intl, editorAppearance, pluginInjectionApi, onClickCallback, __livePage) => new SafePlugin({
|
|
163
164
|
state: {
|
|
164
165
|
init(_, state) {
|
|
165
166
|
const canInsertLink = canLinkBeCreatedInRange(state.selection.from, state.selection.to)(state);
|
|
@@ -351,6 +352,38 @@ export const plugin = (dispatch, intl, editorAppearance, pluginInjectionApi, __l
|
|
|
351
352
|
setTargetElementPos(undefined);
|
|
352
353
|
}
|
|
353
354
|
};
|
|
355
|
+
dom.onclick = event => {
|
|
356
|
+
if (isDirectTarget(event, dom)) {
|
|
357
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2, _pluginInjectionApi$a3;
|
|
358
|
+
const url = mark.attrs.href;
|
|
359
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : (_pluginInjectionApi$a2 = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : (_pluginInjectionApi$a3 = _pluginInjectionApi$a2.fireAnalyticsEvent) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.call(_pluginInjectionApi$a2, {
|
|
360
|
+
action: ACTION.VISITED,
|
|
361
|
+
actionSubject: ACTION_SUBJECT.LINK,
|
|
362
|
+
eventType: EVENT_TYPE.TRACK,
|
|
363
|
+
attributes: {
|
|
364
|
+
platform: PLATFORMS.WEB,
|
|
365
|
+
mode: MODE.EDITOR
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
if (url) {
|
|
369
|
+
try {
|
|
370
|
+
onClickCallback === null || onClickCallback === void 0 ? void 0 : onClickCallback({
|
|
371
|
+
event,
|
|
372
|
+
url
|
|
373
|
+
});
|
|
374
|
+
} catch {}
|
|
375
|
+
|
|
376
|
+
/**
|
|
377
|
+
* Links should navigate by default in live pages if:
|
|
378
|
+
* - the link is the direct target of the click event
|
|
379
|
+
* - default handling wasn't prevented with `event.preventDefault()`
|
|
380
|
+
*/
|
|
381
|
+
if (!event.defaultPrevented) {
|
|
382
|
+
window.location.href = url;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
};
|
|
354
387
|
return {
|
|
355
388
|
dom: dom
|
|
356
389
|
};
|
|
@@ -361,4 +394,7 @@ export const plugin = (dispatch, intl, editorAppearance, pluginInjectionApi, __l
|
|
|
361
394
|
});
|
|
362
395
|
function isLinkDirectTarget(event) {
|
|
363
396
|
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target.tagName === 'A';
|
|
397
|
+
}
|
|
398
|
+
function isDirectTarget(event, element) {
|
|
399
|
+
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target === element;
|
|
364
400
|
}
|
package/dist/esm/plugin.js
CHANGED
|
@@ -93,10 +93,9 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
93
93
|
plugin: function plugin(_ref2) {
|
|
94
94
|
var dispatch = _ref2.dispatch,
|
|
95
95
|
getIntl = _ref2.getIntl;
|
|
96
|
-
return (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
);
|
|
96
|
+
return _plugin(dispatch, getIntl(), options === null || options === void 0 ? void 0 : options.editorAppearance, api, options === null || options === void 0 ? void 0 : options.onClickCallback,
|
|
97
|
+
// @ts-ignore Temporary solution to check for Live Page editor.
|
|
98
|
+
options.__livePage);
|
|
100
99
|
}
|
|
101
100
|
}, {
|
|
102
101
|
name: 'fakeCursorToolbarPlugin',
|
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import uuid from 'uuid';
|
|
5
|
+
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, MODE, PLATFORMS } from '@atlaskit/editor-common/analytics';
|
|
5
6
|
import { InsertStatus, LinkAction } from '@atlaskit/editor-common/link';
|
|
6
7
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
7
8
|
import { canLinkBeCreatedInRange, shallowEqual } from '@atlaskit/editor-common/utils';
|
|
@@ -151,7 +152,7 @@ var getActiveText = function getActiveText(selection) {
|
|
|
151
152
|
return;
|
|
152
153
|
};
|
|
153
154
|
export var stateKey = new PluginKey('hyperlinkPlugin');
|
|
154
|
-
export var plugin = function plugin(dispatch, intl, editorAppearance, pluginInjectionApi, __livePage) {
|
|
155
|
+
export var plugin = function plugin(dispatch, intl, editorAppearance, pluginInjectionApi, onClickCallback, __livePage) {
|
|
155
156
|
return new SafePlugin({
|
|
156
157
|
state: {
|
|
157
158
|
init: function init(_, state) {
|
|
@@ -330,6 +331,38 @@ export var plugin = function plugin(dispatch, intl, editorAppearance, pluginInje
|
|
|
330
331
|
setTargetElementPos(undefined);
|
|
331
332
|
}
|
|
332
333
|
};
|
|
334
|
+
dom.onclick = function (event) {
|
|
335
|
+
if (isDirectTarget(event, dom)) {
|
|
336
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$a2;
|
|
337
|
+
var url = mark.attrs.href;
|
|
338
|
+
pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a = _pluginInjectionApi$a.actions) === null || _pluginInjectionApi$a === void 0 || (_pluginInjectionApi$a2 = _pluginInjectionApi$a.fireAnalyticsEvent) === null || _pluginInjectionApi$a2 === void 0 || _pluginInjectionApi$a2.call(_pluginInjectionApi$a, {
|
|
339
|
+
action: ACTION.VISITED,
|
|
340
|
+
actionSubject: ACTION_SUBJECT.LINK,
|
|
341
|
+
eventType: EVENT_TYPE.TRACK,
|
|
342
|
+
attributes: {
|
|
343
|
+
platform: PLATFORMS.WEB,
|
|
344
|
+
mode: MODE.EDITOR
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
if (url) {
|
|
348
|
+
try {
|
|
349
|
+
onClickCallback === null || onClickCallback === void 0 || onClickCallback({
|
|
350
|
+
event: event,
|
|
351
|
+
url: url
|
|
352
|
+
});
|
|
353
|
+
} catch (_unused) {}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Links should navigate by default in live pages if:
|
|
357
|
+
* - the link is the direct target of the click event
|
|
358
|
+
* - default handling wasn't prevented with `event.preventDefault()`
|
|
359
|
+
*/
|
|
360
|
+
if (!event.defaultPrevented) {
|
|
361
|
+
window.location.href = url;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
};
|
|
333
366
|
return {
|
|
334
367
|
dom: dom
|
|
335
368
|
};
|
|
@@ -340,4 +373,7 @@ export var plugin = function plugin(dispatch, intl, editorAppearance, pluginInje
|
|
|
340
373
|
};
|
|
341
374
|
function isLinkDirectTarget(event) {
|
|
342
375
|
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target.tagName === 'A';
|
|
376
|
+
}
|
|
377
|
+
function isDirectTarget(event, element) {
|
|
378
|
+
return (event === null || event === void 0 ? void 0 : event.target) instanceof HTMLElement && event.target === element;
|
|
343
379
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { OnClickCallback } from '@atlaskit/editor-common/card';
|
|
2
3
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
4
|
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
4
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -6,4 +7,4 @@ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-com
|
|
|
6
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import type { HyperlinkPlugin } from '../plugin';
|
|
8
9
|
export declare const stateKey: PluginKey<HyperlinkState>;
|
|
9
|
-
export declare const plugin: (dispatch: Dispatch, intl: IntlShape, editorAppearance?: EditorAppearance, pluginInjectionApi?: ExtractInjectionAPI<HyperlinkPlugin> | undefined, __livePage?: boolean) => SafePlugin<HyperlinkState>;
|
|
10
|
+
export declare const plugin: (dispatch: Dispatch, intl: IntlShape, editorAppearance?: EditorAppearance, pluginInjectionApi?: ExtractInjectionAPI<HyperlinkPlugin> | undefined, onClickCallback?: OnClickCallback, __livePage?: boolean) => SafePlugin<HyperlinkState>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type IntlShape } from 'react-intl-next';
|
|
2
|
+
import type { OnClickCallback } from '@atlaskit/editor-common/card';
|
|
2
3
|
import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
|
|
3
4
|
import type { HyperlinkState } from '@atlaskit/editor-common/link';
|
|
4
5
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
@@ -6,4 +7,4 @@ import type { EditorAppearance, ExtractInjectionAPI } from '@atlaskit/editor-com
|
|
|
6
7
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
8
|
import type { HyperlinkPlugin } from '../plugin';
|
|
8
9
|
export declare const stateKey: PluginKey<HyperlinkState>;
|
|
9
|
-
export declare const plugin: (dispatch: Dispatch, intl: IntlShape, editorAppearance?: EditorAppearance, pluginInjectionApi?: ExtractInjectionAPI<HyperlinkPlugin> | undefined, __livePage?: boolean) => SafePlugin<HyperlinkState>;
|
|
10
|
+
export declare const plugin: (dispatch: Dispatch, intl: IntlShape, editorAppearance?: EditorAppearance, pluginInjectionApi?: ExtractInjectionAPI<HyperlinkPlugin> | undefined, onClickCallback?: OnClickCallback, __livePage?: boolean) => SafePlugin<HyperlinkState>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -32,11 +32,11 @@
|
|
|
32
32
|
".": "./src/index.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@atlaskit/adf-schema": "^
|
|
35
|
+
"@atlaskit/adf-schema": "^40.3.0",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.3.0",
|
|
37
|
-
"@atlaskit/editor-common": "^86.
|
|
38
|
-
"@atlaskit/editor-plugin-analytics": "^1.
|
|
39
|
-
"@atlaskit/editor-plugin-card": "2.
|
|
37
|
+
"@atlaskit/editor-common": "^86.7.0",
|
|
38
|
+
"@atlaskit/editor-plugin-analytics": "^1.5.0",
|
|
39
|
+
"@atlaskit/editor-plugin-card": "2.7.1",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.0.0",
|
|
41
41
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
42
42
|
"@atlaskit/icon": "^22.7.0",
|