@atlaskit/editor-plugin-hyperlink 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/cjs/Toolbar.js +2 -1
- package/dist/cjs/pm-plugins/input-rule.js +4 -3
- package/dist/es2019/Toolbar.js +2 -1
- package/dist/es2019/pm-plugins/input-rule.js +4 -3
- package/dist/esm/Toolbar.js +2 -1
- package/dist/esm/pm-plugins/input-rule.js +4 -3
- package/dist/types/pm-plugins/input-rule.d.ts +2 -2
- package/dist/types-ts4.5/pm-plugins/input-rule.d.ts +2 -2
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#76379](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/76379) [`1550bb6f5bde`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/1550bb6f5bde) - Updating links for link-preferences to be dependent on staging environment
|
|
8
|
+
|
|
9
|
+
## 1.0.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#75482](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/75482) [`18b5a6fb910a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/18b5a6fb910a) - # MAJOR CHANGE to `@atlaskit/prosemirror-input-rules` package.
|
|
14
|
+
|
|
15
|
+
## WHY?
|
|
16
|
+
|
|
17
|
+
Removing editor-common dependencies from prosemirror-input-rules package.
|
|
18
|
+
|
|
19
|
+
This makes it easier for editor updates because it simplifies our dependency graph.
|
|
20
|
+
|
|
21
|
+
## WHAT and HOW?
|
|
22
|
+
|
|
23
|
+
These are no longer available via `@atlaskit/prosemirror-input-rules` but are available from `@atlaskit/editor-common/types`:
|
|
24
|
+
|
|
25
|
+
- InputRuleWrapper
|
|
26
|
+
- InputRuleHandler
|
|
27
|
+
- OnHandlerApply
|
|
28
|
+
- createRule
|
|
29
|
+
|
|
30
|
+
These have changed from a `SafePlugin` to a `SafePluginSpec`. In order to update your code you need to instantiate a `SafePlugin` (ie. `new SafePlugin(createPlugin( ... ))`).
|
|
31
|
+
|
|
32
|
+
`SafePlugin` exists in `@atlaskit/editor-common/safe-plugin`.
|
|
33
|
+
|
|
34
|
+
- createPlugin
|
|
35
|
+
- createInputRulePlugin
|
|
36
|
+
|
|
37
|
+
- Updated dependencies
|
|
38
|
+
|
|
3
39
|
## 1.0.1
|
|
4
40
|
|
|
5
41
|
### Patch Changes
|
package/dist/cjs/Toolbar.js
CHANGED
|
@@ -12,6 +12,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
12
12
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
13
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
14
14
|
var _card = require("@atlaskit/editor-common/card");
|
|
15
|
+
var _constants = require("@atlaskit/editor-common/constants");
|
|
15
16
|
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
16
17
|
var _link2 = require("@atlaskit/editor-common/link");
|
|
17
18
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
@@ -104,7 +105,7 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
|
|
|
104
105
|
icon: _settings.default,
|
|
105
106
|
title: intl.formatMessage(_messages.linkToolbarMessages.settingsLink),
|
|
106
107
|
onClick: openLinkSettings(editorAnalyticsApi),
|
|
107
|
-
href: '
|
|
108
|
+
href: process.env.NODE_ENV === 'production' ? _constants.productionLinkPreferencesUrl : _constants.stagingLinkPreferencesUrl,
|
|
108
109
|
target: '_blank'
|
|
109
110
|
}];
|
|
110
111
|
};
|
|
@@ -10,12 +10,13 @@ exports.default = void 0;
|
|
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
12
12
|
var _card = require("@atlaskit/editor-common/card");
|
|
13
|
+
var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
|
|
13
14
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
15
|
var _prosemirrorInputRules = require("@atlaskit/prosemirror-input-rules");
|
|
15
16
|
var _toolbarButtons = require("./toolbar-buttons");
|
|
16
17
|
function createLinkInputRule(regexp, editorAnalyticsApi) {
|
|
17
18
|
// Plain typed text (eg, typing 'www.google.com') should convert to a hyperlink
|
|
18
|
-
return (0,
|
|
19
|
+
return (0, _utils.createRule)(regexp, function (state, match, start, end) {
|
|
19
20
|
var _toolbarKey$getState$, _toolbarKey$getState;
|
|
20
21
|
var schema = state.schema;
|
|
21
22
|
if (state.doc.rangeHasMark(start, end, schema.marks.link)) {
|
|
@@ -67,7 +68,7 @@ function createInputRulePlugin(schema, editorAnalyticsApi) {
|
|
|
67
68
|
var urlWithASpaceRule = createLinkInputRule(_utils.LinkMatcher.create(), editorAnalyticsApi);
|
|
68
69
|
|
|
69
70
|
// [something](link) should convert to a hyperlink
|
|
70
|
-
var markdownLinkRule = (0,
|
|
71
|
+
var markdownLinkRule = (0, _utils.createRule)(/(^|[^!])\[(.*?)\]\((\S+)\)$/, function (state, match, start, end) {
|
|
71
72
|
var _toolbarKey$getState$2, _toolbarKey$getState2;
|
|
72
73
|
var schema = state.schema;
|
|
73
74
|
var _match = (0, _slicedToArray2.default)(match, 4),
|
|
@@ -89,6 +90,6 @@ function createInputRulePlugin(schema, editorAnalyticsApi) {
|
|
|
89
90
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent((0, _utils.getLinkCreationAnalyticsEvent)(_analytics.INPUT_METHOD.FORMATTING, url))(tr);
|
|
90
91
|
return tr;
|
|
91
92
|
});
|
|
92
|
-
return (0, _prosemirrorInputRules.createPlugin)('hyperlink', [urlWithASpaceRule, markdownLinkRule]);
|
|
93
|
+
return new _safePlugin.SafePlugin((0, _prosemirrorInputRules.createPlugin)('hyperlink', [urlWithASpaceRule, markdownLinkRule]));
|
|
93
94
|
}
|
|
94
95
|
var _default = exports.default = createInputRulePlugin;
|
package/dist/es2019/Toolbar.js
CHANGED
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT_ID, buildOpenedSettingsPayload, buildVisitedLinkPayload, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
5
|
+
import { productionLinkPreferencesUrl, stagingLinkPreferencesUrl } from '@atlaskit/editor-common/constants';
|
|
5
6
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
6
7
|
import { HyperlinkAddToolbar } from '@atlaskit/editor-common/link';
|
|
7
8
|
import { linkMessages, linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -88,7 +89,7 @@ const getSettingsButtonGroup = (intl, editorAnalyticsApi) => [{
|
|
|
88
89
|
icon: CogIcon,
|
|
89
90
|
title: intl.formatMessage(linkToolbarCommonMessages.settingsLink),
|
|
90
91
|
onClick: openLinkSettings(editorAnalyticsApi),
|
|
91
|
-
href:
|
|
92
|
+
href: process.env.NODE_ENV === 'production' ? productionLinkPreferencesUrl : stagingLinkPreferencesUrl,
|
|
92
93
|
target: '_blank'
|
|
93
94
|
}];
|
|
94
95
|
export const getToolbarConfig = (options, pluginInjectionApi) => (state, intl, providerFactory) => {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
2
2
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
4
|
+
import { createRule, findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches, LinkMatcher, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
5
|
+
import { createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
5
6
|
import { toolbarKey } from './toolbar-buttons';
|
|
6
7
|
export function createLinkInputRule(regexp, editorAnalyticsApi) {
|
|
7
8
|
// Plain typed text (eg, typing 'www.google.com') should convert to a hyperlink
|
|
@@ -80,6 +81,6 @@ export function createInputRulePlugin(schema, editorAnalyticsApi) {
|
|
|
80
81
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(INPUT_METHOD.FORMATTING, url))(tr);
|
|
81
82
|
return tr;
|
|
82
83
|
});
|
|
83
|
-
return createPlugin('hyperlink', [urlWithASpaceRule, markdownLinkRule]);
|
|
84
|
+
return new SafePlugin(createPlugin('hyperlink', [urlWithASpaceRule, markdownLinkRule]));
|
|
84
85
|
}
|
|
85
86
|
export default createInputRulePlugin;
|
package/dist/esm/Toolbar.js
CHANGED
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
7
7
|
import { ACTION, ACTION_SUBJECT_ID, buildOpenedSettingsPayload, buildVisitedLinkPayload, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
9
|
+
import { productionLinkPreferencesUrl, stagingLinkPreferencesUrl } from '@atlaskit/editor-common/constants';
|
|
9
10
|
import { useSharedPluginState } from '@atlaskit/editor-common/hooks';
|
|
10
11
|
import { HyperlinkAddToolbar } from '@atlaskit/editor-common/link';
|
|
11
12
|
import { linkMessages, linkToolbarMessages as linkToolbarCommonMessages } from '@atlaskit/editor-common/messages';
|
|
@@ -96,7 +97,7 @@ var getSettingsButtonGroup = function getSettingsButtonGroup(intl, editorAnalyti
|
|
|
96
97
|
icon: CogIcon,
|
|
97
98
|
title: intl.formatMessage(linkToolbarCommonMessages.settingsLink),
|
|
98
99
|
onClick: openLinkSettings(editorAnalyticsApi),
|
|
99
|
-
href:
|
|
100
|
+
href: process.env.NODE_ENV === 'production' ? productionLinkPreferencesUrl : stagingLinkPreferencesUrl,
|
|
100
101
|
target: '_blank'
|
|
101
102
|
}];
|
|
102
103
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
3
3
|
import { addLinkMetadata } from '@atlaskit/editor-common/card';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
|
+
import { createRule, findFilepaths, getLinkCreationAnalyticsEvent, isLinkInMatches, LinkMatcher, normalizeUrl } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
6
7
|
import { toolbarKey } from './toolbar-buttons';
|
|
7
8
|
export function createLinkInputRule(regexp, editorAnalyticsApi) {
|
|
8
9
|
// Plain typed text (eg, typing 'www.google.com') should convert to a hyperlink
|
|
@@ -80,6 +81,6 @@ export function createInputRulePlugin(schema, editorAnalyticsApi) {
|
|
|
80
81
|
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent(getLinkCreationAnalyticsEvent(INPUT_METHOD.FORMATTING, url))(tr);
|
|
81
82
|
return tr;
|
|
82
83
|
});
|
|
83
|
-
return createPlugin('hyperlink', [urlWithASpaceRule, markdownLinkRule]);
|
|
84
|
+
return new SafePlugin(createPlugin('hyperlink', [urlWithASpaceRule, markdownLinkRule]));
|
|
84
85
|
}
|
|
85
86
|
export default createInputRulePlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
5
5
|
export declare function createLinkInputRule(regexp: RegExp, editorAnalyticsApi: EditorAnalyticsAPI | undefined): InputRuleWrapper;
|
|
6
6
|
export declare function createInputRulePlugin(schema: Schema, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
7
7
|
export default createInputRulePlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import
|
|
2
|
+
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
3
|
+
import type { InputRuleWrapper } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { Schema } from '@atlaskit/editor-prosemirror/model';
|
|
4
|
-
import type { InputRuleWrapper } from '@atlaskit/prosemirror-input-rules';
|
|
5
5
|
export declare function createLinkInputRule(regexp: RegExp, editorAnalyticsApi: EditorAnalyticsAPI | undefined): InputRuleWrapper;
|
|
6
6
|
export declare function createInputRulePlugin(schema: Schema, editorAnalyticsApi: EditorAnalyticsAPI | undefined): SafePlugin | undefined;
|
|
7
7
|
export default createInputRulePlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/adf-schema": "^35.5.1",
|
|
36
36
|
"@atlaskit/analytics-next": "^9.2.0",
|
|
37
|
-
"@atlaskit/editor-common": "^78.
|
|
37
|
+
"@atlaskit/editor-common": "^78.9.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.0.0",
|
|
39
39
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
40
|
-
"@atlaskit/icon": "^22.
|
|
41
|
-
"@atlaskit/prosemirror-input-rules": "^
|
|
40
|
+
"@atlaskit/icon": "^22.1.0",
|
|
41
|
+
"@atlaskit/prosemirror-input-rules": "^3.0.0",
|
|
42
42
|
"@babel/runtime": "^7.0.0",
|
|
43
43
|
"uuid": "^3.1.0"
|
|
44
44
|
},
|