@atlaskit/editor-plugin-hyperlink 3.2.9 → 3.2.11
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 +14 -0
- package/dist/cjs/plugin.js +39 -1
- package/dist/es2019/plugin.js +41 -1
- package/dist/esm/plugin.js +39 -1
- package/dist/types/commands.d.ts +1 -1
- package/dist/types-ts4.5/commands.d.ts +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 3.2.11
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 3.2.10
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#169050](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/169050)
|
|
14
|
+
[`5c9efb7242669`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5c9efb7242669) -
|
|
15
|
+
[ux] Adds link button to the Selection toolbar.
|
|
16
|
+
|
|
3
17
|
## 3.2.9
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -11,7 +11,11 @@ var _analytics = require("@atlaskit/editor-common/analytics");
|
|
|
11
11
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
12
|
var _link = require("@atlaskit/editor-common/link");
|
|
13
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
14
|
+
var _preset = require("@atlaskit/editor-common/preset");
|
|
14
15
|
var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
16
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
|
+
var _linkEditorLink = _interopRequireDefault(require("@atlaskit/icon/core/migration/link--editor-link"));
|
|
18
|
+
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
15
19
|
var _commands = require("./commands");
|
|
16
20
|
var _fakeCursorForToolbar = _interopRequireDefault(require("./pm-plugins/fake-cursor-for-toolbar"));
|
|
17
21
|
var _inputRule = require("./pm-plugins/input-rule");
|
|
@@ -31,6 +35,7 @@ var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
|
|
|
31
35
|
return undefined;
|
|
32
36
|
}
|
|
33
37
|
};
|
|
38
|
+
var selectionToolbarLinkButtonTestId = 'ak-editor-selection-toolbar-link-button';
|
|
34
39
|
|
|
35
40
|
/**
|
|
36
41
|
* Hyperlink plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
@@ -166,7 +171,40 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
166
171
|
}
|
|
167
172
|
}];
|
|
168
173
|
},
|
|
169
|
-
floatingToolbar: (0, _Toolbar.getToolbarConfig)(options, api)
|
|
174
|
+
floatingToolbar: (0, _Toolbar.getToolbarConfig)(options, api),
|
|
175
|
+
selectionToolbar: function selectionToolbar(state, _ref5) {
|
|
176
|
+
var formatMessage = _ref5.formatMessage;
|
|
177
|
+
if ((0, _experiments.editorExperiment)('contextual_formatting_toolbar', true, {
|
|
178
|
+
exposure: true
|
|
179
|
+
})) {
|
|
180
|
+
var toolbarButton = function toolbarButton() {
|
|
181
|
+
var _state$selection = state.selection,
|
|
182
|
+
from = _state$selection.from,
|
|
183
|
+
to = _state$selection.to;
|
|
184
|
+
var isEnabled = (0, _utils.canLinkBeCreatedInRange)(from, to)(state);
|
|
185
|
+
var title = formatMessage(_messages.toolbarInsertBlockMessages.link);
|
|
186
|
+
return {
|
|
187
|
+
type: 'button',
|
|
188
|
+
disabled: !isEnabled,
|
|
189
|
+
testId: "".concat(selectionToolbarLinkButtonTestId),
|
|
190
|
+
icon: _linkEditorLink.default,
|
|
191
|
+
title: title,
|
|
192
|
+
tooltipContent: (0, _keymaps.tooltip)(_keymaps.addLink, title),
|
|
193
|
+
showTitle: false,
|
|
194
|
+
onClick: function onClick(state, dispatch) {
|
|
195
|
+
var _api$analytics7;
|
|
196
|
+
return (0, _preset.editorCommandToPMCommand)((0, _commands.showLinkToolbar)(_analytics.INPUT_METHOD.FLOATING_TB, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions))(state, dispatch);
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
return {
|
|
201
|
+
isToolbarAbove: true,
|
|
202
|
+
items: [toolbarButton()]
|
|
203
|
+
};
|
|
204
|
+
} else {
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
170
208
|
}
|
|
171
209
|
};
|
|
172
210
|
};
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -4,7 +4,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
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
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
7
8
|
import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
9
|
+
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import LinkIcon from '@atlaskit/icon/core/migration/link--editor-link';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
12
|
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, removeLinkEditorCommand, showLinkToolbar, updateLink, updateLinkEditorCommand } from './commands';
|
|
9
13
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
10
14
|
import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
@@ -24,6 +28,7 @@ const getPosFromActiveLinkMark = state => {
|
|
|
24
28
|
return undefined;
|
|
25
29
|
}
|
|
26
30
|
};
|
|
31
|
+
const selectionToolbarLinkButtonTestId = 'ak-editor-selection-toolbar-link-button';
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
34
|
* Hyperlink plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
@@ -146,7 +151,42 @@ export const hyperlinkPlugin = ({
|
|
|
146
151
|
return analyticsAttached !== false ? tr : false;
|
|
147
152
|
}
|
|
148
153
|
}],
|
|
149
|
-
floatingToolbar: getToolbarConfig(options, api)
|
|
154
|
+
floatingToolbar: getToolbarConfig(options, api),
|
|
155
|
+
selectionToolbar: (state, {
|
|
156
|
+
formatMessage
|
|
157
|
+
}) => {
|
|
158
|
+
if (editorExperiment('contextual_formatting_toolbar', true, {
|
|
159
|
+
exposure: true
|
|
160
|
+
})) {
|
|
161
|
+
const toolbarButton = () => {
|
|
162
|
+
const {
|
|
163
|
+
from,
|
|
164
|
+
to
|
|
165
|
+
} = state.selection;
|
|
166
|
+
const isEnabled = canLinkBeCreatedInRange(from, to)(state);
|
|
167
|
+
const title = formatMessage(messages.link);
|
|
168
|
+
return {
|
|
169
|
+
type: 'button',
|
|
170
|
+
disabled: !isEnabled,
|
|
171
|
+
testId: `${selectionToolbarLinkButtonTestId}`,
|
|
172
|
+
icon: LinkIcon,
|
|
173
|
+
title: title,
|
|
174
|
+
tooltipContent: tooltip(addLink, title),
|
|
175
|
+
showTitle: false,
|
|
176
|
+
onClick: (state, dispatch) => {
|
|
177
|
+
var _api$analytics7;
|
|
178
|
+
return editorCommandToPMCommand(showLinkToolbar(INPUT_METHOD.FLOATING_TB, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions))(state, dispatch);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
return {
|
|
183
|
+
isToolbarAbove: true,
|
|
184
|
+
items: [toolbarButton()]
|
|
185
|
+
};
|
|
186
|
+
} else {
|
|
187
|
+
return undefined;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
150
190
|
}
|
|
151
191
|
};
|
|
152
192
|
};
|
package/dist/esm/plugin.js
CHANGED
|
@@ -4,7 +4,11 @@ import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } f
|
|
|
4
4
|
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
|
+
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
7
8
|
import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
9
|
+
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
10
|
+
import LinkIcon from '@atlaskit/icon/core/migration/link--editor-link';
|
|
11
|
+
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
8
12
|
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, removeLinkEditorCommand, showLinkToolbar as _showLinkToolbar, updateLink, updateLinkEditorCommand } from './commands';
|
|
9
13
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
10
14
|
import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
@@ -24,6 +28,7 @@ var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
|
|
|
24
28
|
return undefined;
|
|
25
29
|
}
|
|
26
30
|
};
|
|
31
|
+
var selectionToolbarLinkButtonTestId = 'ak-editor-selection-toolbar-link-button';
|
|
27
32
|
|
|
28
33
|
/**
|
|
29
34
|
* Hyperlink plugin to be added to an `EditorPresetBuilder` and used with `ComposableEditor`
|
|
@@ -159,7 +164,40 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
159
164
|
}
|
|
160
165
|
}];
|
|
161
166
|
},
|
|
162
|
-
floatingToolbar: getToolbarConfig(options, api)
|
|
167
|
+
floatingToolbar: getToolbarConfig(options, api),
|
|
168
|
+
selectionToolbar: function selectionToolbar(state, _ref5) {
|
|
169
|
+
var formatMessage = _ref5.formatMessage;
|
|
170
|
+
if (editorExperiment('contextual_formatting_toolbar', true, {
|
|
171
|
+
exposure: true
|
|
172
|
+
})) {
|
|
173
|
+
var toolbarButton = function toolbarButton() {
|
|
174
|
+
var _state$selection = state.selection,
|
|
175
|
+
from = _state$selection.from,
|
|
176
|
+
to = _state$selection.to;
|
|
177
|
+
var isEnabled = canLinkBeCreatedInRange(from, to)(state);
|
|
178
|
+
var title = formatMessage(messages.link);
|
|
179
|
+
return {
|
|
180
|
+
type: 'button',
|
|
181
|
+
disabled: !isEnabled,
|
|
182
|
+
testId: "".concat(selectionToolbarLinkButtonTestId),
|
|
183
|
+
icon: LinkIcon,
|
|
184
|
+
title: title,
|
|
185
|
+
tooltipContent: tooltip(addLink, title),
|
|
186
|
+
showTitle: false,
|
|
187
|
+
onClick: function onClick(state, dispatch) {
|
|
188
|
+
var _api$analytics7;
|
|
189
|
+
return editorCommandToPMCommand(_showLinkToolbar(INPUT_METHOD.FLOATING_TB, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions))(state, dispatch);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
return {
|
|
194
|
+
isToolbarAbove: true,
|
|
195
|
+
items: [toolbarButton()]
|
|
196
|
+
};
|
|
197
|
+
} else {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
163
201
|
}
|
|
164
202
|
};
|
|
165
203
|
};
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from:
|
|
|
15
15
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
16
16
|
export declare function removeLinkEditorCommand(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
17
17
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
18
|
-
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
18
|
+
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FLOATING_TB;
|
|
19
19
|
export type ShowLinkToolbar = (inputMethod: InputMethod) => EditorCommand;
|
|
20
20
|
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
21
21
|
export declare function hideLinkToolbar(): Command;
|
|
@@ -15,7 +15,7 @@ export declare const insertLinkWithAnalytics: (inputMethod: LinkInputType, from:
|
|
|
15
15
|
export declare function removeLink(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
16
16
|
export declare function removeLinkEditorCommand(pos: number, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
17
17
|
export declare function editInsertedLink(editorAnalyticsApi: EditorAnalyticsAPI | undefined): Command;
|
|
18
|
-
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU;
|
|
18
|
+
type InputMethod = INPUT_METHOD.TOOLBAR | INPUT_METHOD.QUICK_INSERT | INPUT_METHOD.SHORTCUT | INPUT_METHOD.INSERT_MENU | INPUT_METHOD.FLOATING_TB;
|
|
19
19
|
export type ShowLinkToolbar = (inputMethod: InputMethod) => EditorCommand;
|
|
20
20
|
export declare function showLinkToolbar(inputMethod: InputMethod, editorAnalyticsApi: EditorAnalyticsAPI | undefined): EditorCommand;
|
|
21
21
|
export declare function hideLinkToolbar(): Command;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.11",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -33,14 +33,15 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
36
|
-
"@atlaskit/editor-common": "^95.
|
|
36
|
+
"@atlaskit/editor-common": "^95.8.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
38
|
-
"@atlaskit/editor-plugin-card": "4.4.
|
|
38
|
+
"@atlaskit/editor-plugin-card": "4.4.10",
|
|
39
39
|
"@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
|
|
40
40
|
"@atlaskit/editor-prosemirror": "6.0.0",
|
|
41
41
|
"@atlaskit/icon": "^22.26.0",
|
|
42
42
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
43
43
|
"@atlaskit/prosemirror-input-rules": "^3.2.0",
|
|
44
|
+
"@atlaskit/tmp-editor-statsig": "^2.21.0",
|
|
44
45
|
"@babel/runtime": "^7.0.0",
|
|
45
46
|
"uuid": "^3.1.0"
|
|
46
47
|
},
|