@atlaskit/editor-plugin-hyperlink 5.3.0 → 5.4.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/hyperlinkPlugin.js +15 -4
- package/dist/cjs/ui/toolbar/LinkButton.js +44 -0
- package/dist/cjs/ui/toolbar/LinkSection.js +37 -0
- package/dist/cjs/ui/toolbar-components.js +56 -0
- package/dist/es2019/hyperlinkPlugin.js +48 -38
- package/dist/es2019/ui/toolbar/LinkButton.js +41 -0
- package/dist/es2019/ui/toolbar/LinkSection.js +29 -0
- package/dist/es2019/ui/toolbar-components.js +50 -0
- package/dist/esm/hyperlinkPlugin.js +15 -4
- package/dist/esm/ui/toolbar/LinkButton.js +37 -0
- package/dist/esm/ui/toolbar/LinkSection.js +30 -0
- package/dist/esm/ui/toolbar-components.js +49 -0
- package/dist/types/hyperlinkPluginType.d.ts +3 -1
- package/dist/types/pm-plugins/decorations.d.ts +1 -1
- package/dist/types/ui/PrimaryToolbarComponent.d.ts +0 -1
- package/dist/types/ui/toolbar/LinkButton.d.ts +8 -0
- package/dist/types/ui/toolbar/LinkSection.d.ts +11 -0
- package/dist/types/ui/toolbar-components.d.ts +4 -0
- package/dist/types-ts4.5/hyperlinkPluginType.d.ts +3 -1
- package/dist/types-ts4.5/pm-plugins/decorations.d.ts +1 -1
- package/dist/types-ts4.5/ui/PrimaryToolbarComponent.d.ts +0 -1
- package/dist/types-ts4.5/ui/toolbar/LinkButton.d.ts +8 -0
- package/dist/types-ts4.5/ui/toolbar/LinkSection.d.ts +11 -0
- package/dist/types-ts4.5/ui/toolbar-components.d.ts +4 -0
- package/package.json +10 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 5.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#199487](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/199487)
|
|
8
|
+
[`54098ba4cc83c`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/54098ba4cc83c) -
|
|
9
|
+
Add LinkSection and TextSection and add logic to hide them when toolbar is pinned. Add
|
|
10
|
+
UserPreferencesPlugin and EditorViewModePlugin as a dependency to editor-plugin-toolbar.
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 5.4.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- [`f681ff4b37a3d`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f681ff4b37a3d) -
|
|
18
|
+
[ux] ED-28752 register link button to new toolbar behind platform_editor_toolbar_aifc
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
|
|
3
24
|
## 5.3.0
|
|
4
25
|
|
|
5
26
|
### Minor Changes
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.hyperlinkPlugin = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
8
9
|
var _react = _interopRequireDefault(require("react"));
|
|
9
10
|
var _adfSchema = require("@atlaskit/adf-schema");
|
|
10
11
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
@@ -16,6 +17,7 @@ var _quickInsert = require("@atlaskit/editor-common/quick-insert");
|
|
|
16
17
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
17
18
|
var _linkEditorLink = _interopRequireDefault(require("@atlaskit/icon/core/migration/link--editor-link"));
|
|
18
19
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
20
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
19
21
|
var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
|
|
20
22
|
var _commands = require("./editor-commands/commands");
|
|
21
23
|
var _fakeCursorForToolbar = _interopRequireDefault(require("./pm-plugins/fake-cursor-for-toolbar"));
|
|
@@ -23,7 +25,10 @@ var _inputRule = require("./pm-plugins/input-rule");
|
|
|
23
25
|
var _keymap = require("./pm-plugins/keymap");
|
|
24
26
|
var _main = require("./pm-plugins/main");
|
|
25
27
|
var _toolbarButtons = require("./pm-plugins/toolbar-buttons");
|
|
28
|
+
var _toolbarComponents = require("./ui/toolbar-components");
|
|
26
29
|
var _Toolbar = require("./ui/toolbar/Toolbar");
|
|
30
|
+
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; }
|
|
31
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
27
32
|
var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
|
|
28
33
|
if (state === undefined) {
|
|
29
34
|
return undefined;
|
|
@@ -47,6 +52,10 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
47
52
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
48
53
|
api = _ref.api;
|
|
49
54
|
var primaryToolbarComponent;
|
|
55
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true)) {
|
|
56
|
+
var _api$toolbar;
|
|
57
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents((0, _toolbarComponents.getToolbarComponents)(api));
|
|
58
|
+
}
|
|
50
59
|
return {
|
|
51
60
|
name: 'hyperlink',
|
|
52
61
|
marks: function marks() {
|
|
@@ -140,7 +149,7 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
140
149
|
}
|
|
141
150
|
}];
|
|
142
151
|
},
|
|
143
|
-
pluginsOptions: {
|
|
152
|
+
pluginsOptions: _objectSpread(_objectSpread({
|
|
144
153
|
quickInsert: function quickInsert(_ref4) {
|
|
145
154
|
var formatMessage = _ref4.formatMessage;
|
|
146
155
|
return [{
|
|
@@ -173,7 +182,8 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
173
182
|
}
|
|
174
183
|
}];
|
|
175
184
|
},
|
|
176
|
-
floatingToolbar: (0, _Toolbar.getToolbarConfig)(options, api)
|
|
185
|
+
floatingToolbar: (0, _Toolbar.getToolbarConfig)(options, api)
|
|
186
|
+
}, !(0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
177
187
|
selectionToolbar: function selectionToolbar(state, _ref5) {
|
|
178
188
|
var _api$userPreferences, _api$selectionToolbar;
|
|
179
189
|
var formatMessage = _ref5.formatMessage;
|
|
@@ -209,10 +219,11 @@ var hyperlinkPlugin = exports.hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
209
219
|
} else {
|
|
210
220
|
return undefined;
|
|
211
221
|
}
|
|
212
|
-
}
|
|
222
|
+
}
|
|
223
|
+
}), !(0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
213
224
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && (0, _experiments.editorExperiment)('platform_editor_controls', 'variant1', {
|
|
214
225
|
exposure: true
|
|
215
226
|
}) ? primaryToolbarComponent : undefined
|
|
216
|
-
}
|
|
227
|
+
})
|
|
217
228
|
};
|
|
218
229
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LinkButton = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _reactIntlNext = require("react-intl-next");
|
|
10
|
+
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _messages = require("@atlaskit/editor-common/messages");
|
|
12
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
13
|
+
var _utils = require("@atlaskit/editor-common/utils");
|
|
14
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
15
|
+
var LinkButton = exports.LinkButton = function LinkButton(_ref) {
|
|
16
|
+
var api = _ref.api;
|
|
17
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
18
|
+
formatMessage = _useIntl.formatMessage;
|
|
19
|
+
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
20
|
+
editorView = _useEditorToolbar.editorView;
|
|
21
|
+
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
22
|
+
state: null,
|
|
23
|
+
dispatch: null
|
|
24
|
+
},
|
|
25
|
+
state = _ref2.state;
|
|
26
|
+
var onClick = function onClick() {
|
|
27
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.hyperlink.commands.showLinkToolbar(_analytics.INPUT_METHOD.FLOATING_TB));
|
|
28
|
+
};
|
|
29
|
+
var isEnabled = state !== null && state !== void 0 && state.selection ? (0, _utils.canLinkBeCreatedInRange)(state === null || state === void 0 ? void 0 : state.selection.from, state === null || state === void 0 ? void 0 : state.selection.to)(state) : false;
|
|
30
|
+
return (
|
|
31
|
+
/*#__PURE__*/
|
|
32
|
+
// TODO: ED-28743 - add keyboard shortcut here
|
|
33
|
+
_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
34
|
+
content: formatMessage(_messages.toolbarInsertBlockMessages.link)
|
|
35
|
+
}, /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarButton, {
|
|
36
|
+
iconBefore: /*#__PURE__*/_react.default.createElement(_editorToolbar.LinkIcon, {
|
|
37
|
+
label: formatMessage(_messages.toolbarInsertBlockMessages.link)
|
|
38
|
+
}),
|
|
39
|
+
onClick: onClick,
|
|
40
|
+
testId: 'editor-toolbar__link-button',
|
|
41
|
+
isDisabled: !isEnabled
|
|
42
|
+
}))
|
|
43
|
+
);
|
|
44
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.LinkSection = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
|
+
var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
|
|
11
|
+
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
12
|
+
var shouldShowLinkSection = function shouldShowLinkSection(editMode, toolbar, toolbarDocking) {
|
|
13
|
+
if (editMode === 'view') {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === _toolbar.TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
};
|
|
24
|
+
var LinkSection = exports.LinkSection = function LinkSection(_ref) {
|
|
25
|
+
var children = _ref.children,
|
|
26
|
+
parents = _ref.parents,
|
|
27
|
+
api = _ref.api;
|
|
28
|
+
var editMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'editorViewMode.mode');
|
|
29
|
+
var toolbarDocking = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
30
|
+
var toolbar = parents.find(function (parent) {
|
|
31
|
+
return parent.type === 'toolbar';
|
|
32
|
+
});
|
|
33
|
+
if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarSection, null, children);
|
|
37
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getToolbarComponents = void 0;
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
10
|
+
var _LinkButton = require("./toolbar/LinkButton");
|
|
11
|
+
var _LinkSection = require("./toolbar/LinkSection");
|
|
12
|
+
var getToolbarComponents = exports.getToolbarComponents = function getToolbarComponents(api) {
|
|
13
|
+
var toolbarComponents = [{
|
|
14
|
+
type: _toolbar.LINKING_SECTION.type,
|
|
15
|
+
key: _toolbar.LINKING_SECTION.key,
|
|
16
|
+
parents: [{
|
|
17
|
+
type: 'toolbar',
|
|
18
|
+
key: _toolbar.TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
19
|
+
rank: _toolbar.TOOLBAR_RANK[_toolbar.LINKING_SECTION.key]
|
|
20
|
+
}, {
|
|
21
|
+
type: 'toolbar',
|
|
22
|
+
key: _toolbar.TOOLBARS.PRIMARY_TOOLBAR,
|
|
23
|
+
rank: _toolbar.TOOLBAR_RANK[_toolbar.LINKING_SECTION.key]
|
|
24
|
+
}],
|
|
25
|
+
component: function component(_ref) {
|
|
26
|
+
var children = _ref.children,
|
|
27
|
+
parents = _ref.parents;
|
|
28
|
+
return /*#__PURE__*/_react.default.createElement(_LinkSection.LinkSection, {
|
|
29
|
+
parents: parents,
|
|
30
|
+
api: api
|
|
31
|
+
}, children);
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
type: _toolbar.LINKING_GROUP.type,
|
|
35
|
+
key: _toolbar.LINKING_GROUP.key,
|
|
36
|
+
parents: [{
|
|
37
|
+
type: _toolbar.LINKING_SECTION.type,
|
|
38
|
+
key: _toolbar.LINKING_SECTION.key,
|
|
39
|
+
rank: _toolbar.LINKING_SECTION_RANK[_toolbar.LINKING_GROUP.key]
|
|
40
|
+
}]
|
|
41
|
+
}, {
|
|
42
|
+
type: _toolbar.LINKING_BUTTON.type,
|
|
43
|
+
key: _toolbar.LINKING_BUTTON.key,
|
|
44
|
+
parents: [{
|
|
45
|
+
type: _toolbar.LINKING_GROUP.type,
|
|
46
|
+
key: _toolbar.LINKING_GROUP.key,
|
|
47
|
+
rank: _toolbar.LINKING_GROUP_RANK[_toolbar.LINKING_BUTTON.key]
|
|
48
|
+
}],
|
|
49
|
+
component: function component() {
|
|
50
|
+
return /*#__PURE__*/_react.default.createElement(_LinkButton.LinkButton, {
|
|
51
|
+
api: api
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}];
|
|
55
|
+
return toolbarComponents;
|
|
56
|
+
};
|
|
@@ -9,6 +9,7 @@ import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
9
|
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
10
10
|
import LinkIcon from '@atlaskit/icon/core/migration/link--editor-link';
|
|
11
11
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
13
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
14
|
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, removeLinkEditorCommand, showLinkToolbar, updateLink, updateLinkEditorCommand } from './editor-commands/commands';
|
|
14
15
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
@@ -16,6 +17,7 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
|
16
17
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
17
18
|
import { plugin, stateKey } from './pm-plugins/main';
|
|
18
19
|
import { toolbarButtonsPlugin } from './pm-plugins/toolbar-buttons';
|
|
20
|
+
import { getToolbarComponents } from './ui/toolbar-components';
|
|
19
21
|
import { getToolbarConfig } from './ui/toolbar/Toolbar';
|
|
20
22
|
const getPosFromActiveLinkMark = state => {
|
|
21
23
|
if (state === undefined) {
|
|
@@ -40,6 +42,10 @@ export const hyperlinkPlugin = ({
|
|
|
40
42
|
api
|
|
41
43
|
}) => {
|
|
42
44
|
let primaryToolbarComponent;
|
|
45
|
+
if (expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true)) {
|
|
46
|
+
var _api$toolbar;
|
|
47
|
+
api === null || api === void 0 ? void 0 : (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 ? void 0 : _api$toolbar.actions.registerComponents(getToolbarComponents(api));
|
|
48
|
+
}
|
|
43
49
|
return {
|
|
44
50
|
name: 'hyperlink',
|
|
45
51
|
marks() {
|
|
@@ -154,47 +160,51 @@ export const hyperlinkPlugin = ({
|
|
|
154
160
|
}
|
|
155
161
|
}],
|
|
156
162
|
floatingToolbar: getToolbarConfig(options, api),
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
163
|
+
...(!expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
164
|
+
selectionToolbar: (state, {
|
|
165
|
+
formatMessage
|
|
166
|
+
}) => {
|
|
167
|
+
var _api$userPreferences, _api$userPreferences$, _api$selectionToolbar, _api$selectionToolbar2, _api$selectionToolbar3;
|
|
168
|
+
const toolbarDocking = fg('platform_editor_use_preferences_plugin') ? api === null || api === void 0 ? void 0 : (_api$userPreferences = api.userPreferences) === null || _api$userPreferences === void 0 ? void 0 : (_api$userPreferences$ = _api$userPreferences.sharedState.currentState()) === null || _api$userPreferences$ === void 0 ? void 0 : _api$userPreferences$.preferences.toolbarDockingPosition : api === null || api === void 0 ? void 0 : (_api$selectionToolbar = api.selectionToolbar) === null || _api$selectionToolbar === void 0 ? void 0 : (_api$selectionToolbar2 = _api$selectionToolbar.sharedState) === null || _api$selectionToolbar2 === void 0 ? void 0 : (_api$selectionToolbar3 = _api$selectionToolbar2.currentState()) === null || _api$selectionToolbar3 === void 0 ? void 0 : _api$selectionToolbar3.toolbarDocking;
|
|
169
|
+
if (toolbarDocking === 'none' && editorExperiment('platform_editor_controls', 'variant1', {
|
|
170
|
+
exposure: true
|
|
171
|
+
})) {
|
|
172
|
+
const toolbarButton = () => {
|
|
173
|
+
const {
|
|
174
|
+
from,
|
|
175
|
+
to
|
|
176
|
+
} = state.selection;
|
|
177
|
+
const isEnabled = canLinkBeCreatedInRange(from, to)(state);
|
|
178
|
+
const title = formatMessage(messages.link);
|
|
179
|
+
return {
|
|
180
|
+
type: 'button',
|
|
181
|
+
disabled: !isEnabled,
|
|
182
|
+
testId: `${selectionToolbarLinkButtonTestId}`,
|
|
183
|
+
icon: LinkIcon,
|
|
184
|
+
title: title,
|
|
185
|
+
tooltipContent: tooltip(addLink, title),
|
|
186
|
+
showTitle: false,
|
|
187
|
+
onClick: (state, dispatch) => {
|
|
188
|
+
var _api$analytics7;
|
|
189
|
+
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);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
};
|
|
172
193
|
return {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
icon: LinkIcon,
|
|
177
|
-
title: title,
|
|
178
|
-
tooltipContent: tooltip(addLink, title),
|
|
179
|
-
showTitle: false,
|
|
180
|
-
onClick: (state, dispatch) => {
|
|
181
|
-
var _api$analytics7;
|
|
182
|
-
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);
|
|
183
|
-
}
|
|
194
|
+
isToolbarAbove: true,
|
|
195
|
+
items: [toolbarButton()],
|
|
196
|
+
rank: 2
|
|
184
197
|
};
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
items: [toolbarButton()],
|
|
189
|
-
rank: 2
|
|
190
|
-
};
|
|
191
|
-
} else {
|
|
192
|
-
return undefined;
|
|
198
|
+
} else {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
193
201
|
}
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
202
|
+
}),
|
|
203
|
+
...(!expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
204
|
+
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'variant1', {
|
|
205
|
+
exposure: true
|
|
206
|
+
}) ? primaryToolbarComponent : undefined
|
|
207
|
+
})
|
|
198
208
|
}
|
|
199
209
|
};
|
|
200
210
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { LinkIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
|
+
export const LinkButton = ({
|
|
9
|
+
api
|
|
10
|
+
}) => {
|
|
11
|
+
const {
|
|
12
|
+
formatMessage
|
|
13
|
+
} = useIntl();
|
|
14
|
+
const {
|
|
15
|
+
editorView
|
|
16
|
+
} = useEditorToolbar();
|
|
17
|
+
const {
|
|
18
|
+
state
|
|
19
|
+
} = editorView !== null && editorView !== void 0 ? editorView : {
|
|
20
|
+
state: null,
|
|
21
|
+
dispatch: null
|
|
22
|
+
};
|
|
23
|
+
const onClick = () => {
|
|
24
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(api === null || api === void 0 ? void 0 : api.hyperlink.commands.showLinkToolbar(INPUT_METHOD.FLOATING_TB));
|
|
25
|
+
};
|
|
26
|
+
const isEnabled = state !== null && state !== void 0 && state.selection ? canLinkBeCreatedInRange(state === null || state === void 0 ? void 0 : state.selection.from, state === null || state === void 0 ? void 0 : state.selection.to)(state) : false;
|
|
27
|
+
return (
|
|
28
|
+
/*#__PURE__*/
|
|
29
|
+
// TODO: ED-28743 - add keyboard shortcut here
|
|
30
|
+
React.createElement(ToolbarTooltip, {
|
|
31
|
+
content: formatMessage(messages.link)
|
|
32
|
+
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
33
|
+
iconBefore: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
34
|
+
label: formatMessage(messages.link)
|
|
35
|
+
}),
|
|
36
|
+
onClick: onClick,
|
|
37
|
+
testId: 'editor-toolbar__link-button',
|
|
38
|
+
isDisabled: !isEnabled
|
|
39
|
+
}))
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { ToolbarSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
const shouldShowLinkSection = (editMode, toolbar, toolbarDocking) => {
|
|
6
|
+
if (editMode === 'view') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
export const LinkSection = ({
|
|
18
|
+
children,
|
|
19
|
+
parents,
|
|
20
|
+
api
|
|
21
|
+
}) => {
|
|
22
|
+
const editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
23
|
+
const toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
24
|
+
const toolbar = parents.find(parent => parent.type === 'toolbar');
|
|
25
|
+
if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/React.createElement(ToolbarSection, null, children);
|
|
29
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LINKING_BUTTON, LINKING_GROUP, LINKING_GROUP_RANK, LINKING_SECTION, LINKING_SECTION_RANK, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { LinkButton } from './toolbar/LinkButton';
|
|
4
|
+
import { LinkSection } from './toolbar/LinkSection';
|
|
5
|
+
export const getToolbarComponents = api => {
|
|
6
|
+
const toolbarComponents = [{
|
|
7
|
+
type: LINKING_SECTION.type,
|
|
8
|
+
key: LINKING_SECTION.key,
|
|
9
|
+
parents: [{
|
|
10
|
+
type: 'toolbar',
|
|
11
|
+
key: TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
12
|
+
rank: TOOLBAR_RANK[LINKING_SECTION.key]
|
|
13
|
+
}, {
|
|
14
|
+
type: 'toolbar',
|
|
15
|
+
key: TOOLBARS.PRIMARY_TOOLBAR,
|
|
16
|
+
rank: TOOLBAR_RANK[LINKING_SECTION.key]
|
|
17
|
+
}],
|
|
18
|
+
component: ({
|
|
19
|
+
children,
|
|
20
|
+
parents
|
|
21
|
+
}) => {
|
|
22
|
+
return /*#__PURE__*/React.createElement(LinkSection, {
|
|
23
|
+
parents: parents,
|
|
24
|
+
api: api
|
|
25
|
+
}, children);
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
type: LINKING_GROUP.type,
|
|
29
|
+
key: LINKING_GROUP.key,
|
|
30
|
+
parents: [{
|
|
31
|
+
type: LINKING_SECTION.type,
|
|
32
|
+
key: LINKING_SECTION.key,
|
|
33
|
+
rank: LINKING_SECTION_RANK[LINKING_GROUP.key]
|
|
34
|
+
}]
|
|
35
|
+
}, {
|
|
36
|
+
type: LINKING_BUTTON.type,
|
|
37
|
+
key: LINKING_BUTTON.key,
|
|
38
|
+
parents: [{
|
|
39
|
+
type: LINKING_GROUP.type,
|
|
40
|
+
key: LINKING_GROUP.key,
|
|
41
|
+
rank: LINKING_GROUP_RANK[LINKING_BUTTON.key]
|
|
42
|
+
}],
|
|
43
|
+
component: () => {
|
|
44
|
+
return /*#__PURE__*/React.createElement(LinkButton, {
|
|
45
|
+
api: api
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}];
|
|
49
|
+
return toolbarComponents;
|
|
50
|
+
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
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
|
+
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; }
|
|
1
4
|
import React from 'react';
|
|
2
5
|
import { link } from '@atlaskit/adf-schema';
|
|
3
6
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
@@ -9,6 +12,7 @@ import { IconLink } from '@atlaskit/editor-common/quick-insert';
|
|
|
9
12
|
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
10
13
|
import LinkIcon from '@atlaskit/icon/core/migration/link--editor-link';
|
|
11
14
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
15
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
12
16
|
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
|
|
13
17
|
import { hideLinkToolbarSetMeta, insertLinkWithAnalytics, removeLinkEditorCommand, showLinkToolbar as _showLinkToolbar, updateLink, updateLinkEditorCommand } from './editor-commands/commands';
|
|
14
18
|
import fakeCursorToolbarPlugin from './pm-plugins/fake-cursor-for-toolbar';
|
|
@@ -16,6 +20,7 @@ import { createInputRulePlugin } from './pm-plugins/input-rule';
|
|
|
16
20
|
import { createKeymapPlugin } from './pm-plugins/keymap';
|
|
17
21
|
import { plugin as _plugin, stateKey } from './pm-plugins/main';
|
|
18
22
|
import { toolbarButtonsPlugin } from './pm-plugins/toolbar-buttons';
|
|
23
|
+
import { getToolbarComponents } from './ui/toolbar-components';
|
|
19
24
|
import { getToolbarConfig } from './ui/toolbar/Toolbar';
|
|
20
25
|
var getPosFromActiveLinkMark = function getPosFromActiveLinkMark(state) {
|
|
21
26
|
if (state === undefined) {
|
|
@@ -40,6 +45,10 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
40
45
|
options = _ref$config === void 0 ? {} : _ref$config,
|
|
41
46
|
api = _ref.api;
|
|
42
47
|
var primaryToolbarComponent;
|
|
48
|
+
if (expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true)) {
|
|
49
|
+
var _api$toolbar;
|
|
50
|
+
api === null || api === void 0 || (_api$toolbar = api.toolbar) === null || _api$toolbar === void 0 || _api$toolbar.actions.registerComponents(getToolbarComponents(api));
|
|
51
|
+
}
|
|
43
52
|
return {
|
|
44
53
|
name: 'hyperlink',
|
|
45
54
|
marks: function marks() {
|
|
@@ -133,7 +142,7 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
133
142
|
}
|
|
134
143
|
}];
|
|
135
144
|
},
|
|
136
|
-
pluginsOptions: {
|
|
145
|
+
pluginsOptions: _objectSpread(_objectSpread({
|
|
137
146
|
quickInsert: function quickInsert(_ref4) {
|
|
138
147
|
var formatMessage = _ref4.formatMessage;
|
|
139
148
|
return [{
|
|
@@ -166,7 +175,8 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
166
175
|
}
|
|
167
176
|
}];
|
|
168
177
|
},
|
|
169
|
-
floatingToolbar: getToolbarConfig(options, api)
|
|
178
|
+
floatingToolbar: getToolbarConfig(options, api)
|
|
179
|
+
}, !expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
170
180
|
selectionToolbar: function selectionToolbar(state, _ref5) {
|
|
171
181
|
var _api$userPreferences, _api$selectionToolbar;
|
|
172
182
|
var formatMessage = _ref5.formatMessage;
|
|
@@ -202,10 +212,11 @@ export var hyperlinkPlugin = function hyperlinkPlugin(_ref) {
|
|
|
202
212
|
} else {
|
|
203
213
|
return undefined;
|
|
204
214
|
}
|
|
205
|
-
}
|
|
215
|
+
}
|
|
216
|
+
}), !expValEquals('platform_editor_toolbar_aifc', 'isEnabled', true) && {
|
|
206
217
|
primaryToolbarComponent: !(api !== null && api !== void 0 && api.primaryToolbar) && editorExperiment('platform_editor_controls', 'variant1', {
|
|
207
218
|
exposure: true
|
|
208
219
|
}) ? primaryToolbarComponent : undefined
|
|
209
|
-
}
|
|
220
|
+
})
|
|
210
221
|
};
|
|
211
222
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl-next';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
|
+
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
6
|
+
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { LinkIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
8
|
+
export var LinkButton = function LinkButton(_ref) {
|
|
9
|
+
var api = _ref.api;
|
|
10
|
+
var _useIntl = useIntl(),
|
|
11
|
+
formatMessage = _useIntl.formatMessage;
|
|
12
|
+
var _useEditorToolbar = useEditorToolbar(),
|
|
13
|
+
editorView = _useEditorToolbar.editorView;
|
|
14
|
+
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
15
|
+
state: null,
|
|
16
|
+
dispatch: null
|
|
17
|
+
},
|
|
18
|
+
state = _ref2.state;
|
|
19
|
+
var onClick = function onClick() {
|
|
20
|
+
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.hyperlink.commands.showLinkToolbar(INPUT_METHOD.FLOATING_TB));
|
|
21
|
+
};
|
|
22
|
+
var isEnabled = state !== null && state !== void 0 && state.selection ? canLinkBeCreatedInRange(state === null || state === void 0 ? void 0 : state.selection.from, state === null || state === void 0 ? void 0 : state.selection.to)(state) : false;
|
|
23
|
+
return (
|
|
24
|
+
/*#__PURE__*/
|
|
25
|
+
// TODO: ED-28743 - add keyboard shortcut here
|
|
26
|
+
React.createElement(ToolbarTooltip, {
|
|
27
|
+
content: formatMessage(messages.link)
|
|
28
|
+
}, /*#__PURE__*/React.createElement(ToolbarButton, {
|
|
29
|
+
iconBefore: /*#__PURE__*/React.createElement(LinkIcon, {
|
|
30
|
+
label: formatMessage(messages.link)
|
|
31
|
+
}),
|
|
32
|
+
onClick: onClick,
|
|
33
|
+
testId: 'editor-toolbar__link-button',
|
|
34
|
+
isDisabled: !isEnabled
|
|
35
|
+
}))
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
|
|
4
|
+
import { ToolbarSection } from '@atlaskit/editor-toolbar';
|
|
5
|
+
var shouldShowLinkSection = function shouldShowLinkSection(editMode, toolbar, toolbarDocking) {
|
|
6
|
+
if (editMode === 'view') {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.INLINE_TEXT_TOOLBAR && toolbarDocking !== 'top') {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if ((toolbar === null || toolbar === void 0 ? void 0 : toolbar.key) === TOOLBARS.PRIMARY_TOOLBAR && toolbarDocking !== 'none') {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
};
|
|
17
|
+
export var LinkSection = function LinkSection(_ref) {
|
|
18
|
+
var children = _ref.children,
|
|
19
|
+
parents = _ref.parents,
|
|
20
|
+
api = _ref.api;
|
|
21
|
+
var editMode = useSharedPluginStateSelector(api, 'editorViewMode.mode');
|
|
22
|
+
var toolbarDocking = useSharedPluginStateSelector(api, 'userPreferences.preferences.toolbarDockingPosition');
|
|
23
|
+
var toolbar = parents.find(function (parent) {
|
|
24
|
+
return parent.type === 'toolbar';
|
|
25
|
+
});
|
|
26
|
+
if (!shouldShowLinkSection(editMode, toolbar, toolbarDocking)) {
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return /*#__PURE__*/React.createElement(ToolbarSection, null, children);
|
|
30
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LINKING_BUTTON, LINKING_GROUP, LINKING_GROUP_RANK, LINKING_SECTION, LINKING_SECTION_RANK, TOOLBAR_RANK, TOOLBARS } from '@atlaskit/editor-common/toolbar';
|
|
3
|
+
import { LinkButton } from './toolbar/LinkButton';
|
|
4
|
+
import { LinkSection } from './toolbar/LinkSection';
|
|
5
|
+
export var getToolbarComponents = function getToolbarComponents(api) {
|
|
6
|
+
var toolbarComponents = [{
|
|
7
|
+
type: LINKING_SECTION.type,
|
|
8
|
+
key: LINKING_SECTION.key,
|
|
9
|
+
parents: [{
|
|
10
|
+
type: 'toolbar',
|
|
11
|
+
key: TOOLBARS.INLINE_TEXT_TOOLBAR,
|
|
12
|
+
rank: TOOLBAR_RANK[LINKING_SECTION.key]
|
|
13
|
+
}, {
|
|
14
|
+
type: 'toolbar',
|
|
15
|
+
key: TOOLBARS.PRIMARY_TOOLBAR,
|
|
16
|
+
rank: TOOLBAR_RANK[LINKING_SECTION.key]
|
|
17
|
+
}],
|
|
18
|
+
component: function component(_ref) {
|
|
19
|
+
var children = _ref.children,
|
|
20
|
+
parents = _ref.parents;
|
|
21
|
+
return /*#__PURE__*/React.createElement(LinkSection, {
|
|
22
|
+
parents: parents,
|
|
23
|
+
api: api
|
|
24
|
+
}, children);
|
|
25
|
+
}
|
|
26
|
+
}, {
|
|
27
|
+
type: LINKING_GROUP.type,
|
|
28
|
+
key: LINKING_GROUP.key,
|
|
29
|
+
parents: [{
|
|
30
|
+
type: LINKING_SECTION.type,
|
|
31
|
+
key: LINKING_SECTION.key,
|
|
32
|
+
rank: LINKING_SECTION_RANK[LINKING_GROUP.key]
|
|
33
|
+
}]
|
|
34
|
+
}, {
|
|
35
|
+
type: LINKING_BUTTON.type,
|
|
36
|
+
key: LINKING_BUTTON.key,
|
|
37
|
+
parents: [{
|
|
38
|
+
type: LINKING_GROUP.type,
|
|
39
|
+
key: LINKING_GROUP.key,
|
|
40
|
+
rank: LINKING_GROUP_RANK[LINKING_BUTTON.key]
|
|
41
|
+
}],
|
|
42
|
+
component: function component() {
|
|
43
|
+
return /*#__PURE__*/React.createElement(LinkButton, {
|
|
44
|
+
api: api
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}];
|
|
48
|
+
return toolbarComponents;
|
|
49
|
+
};
|
|
@@ -6,6 +6,7 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
8
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
9
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
9
10
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
10
11
|
import type { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './editor-commands/commands';
|
|
11
12
|
type HyperlinkPluginCommands = {
|
|
@@ -53,7 +54,8 @@ export type HyperlinkPluginDependencies = [
|
|
|
53
54
|
OptionalPlugin<ConnectivityPlugin>,
|
|
54
55
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
55
56
|
OptionalPlugin<SelectionToolbarPlugin>,
|
|
56
|
-
OptionalPlugin<UserPreferencesPlugin
|
|
57
|
+
OptionalPlugin<UserPreferencesPlugin>,
|
|
58
|
+
OptionalPlugin<ToolbarPlugin>
|
|
57
59
|
];
|
|
58
60
|
export type HyperlinkPluginActions = {
|
|
59
61
|
hideLinkToolbar: HideLinkToolbar;
|
|
@@ -5,7 +5,7 @@ import { type PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
export declare const ButtonWrapper: ({ editorView, pos, stateKey, intl, onOpenLinkClick, }: {
|
|
7
7
|
editorView: EditorView;
|
|
8
|
-
pos?: number
|
|
8
|
+
pos?: number;
|
|
9
9
|
stateKey: PluginKey<HyperlinkState>;
|
|
10
10
|
intl: IntlShape;
|
|
11
11
|
/** Callback fired when the Open Link dropdown item is clicked */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
|
|
4
|
+
type LinkButtonProps = {
|
|
5
|
+
api?: ExtractInjectionAPI<HyperlinkPlugin>;
|
|
6
|
+
};
|
|
7
|
+
export declare const LinkButton: ({ api }: LinkButtonProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
|
|
4
|
+
import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
|
|
5
|
+
type LinkSectionProps = {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
parents: ToolbarComponentTypes;
|
|
8
|
+
api?: ExtractInjectionAPI<HyperlinkPlugin>;
|
|
9
|
+
};
|
|
10
|
+
export declare const LinkSection: ({ children, parents, api }: LinkSectionProps) => React.JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { HyperlinkPlugin } from '../hyperlinkPluginType';
|
|
4
|
+
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<HyperlinkPlugin>) => RegisterComponent[];
|
|
@@ -6,6 +6,7 @@ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
|
|
|
6
6
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
7
7
|
import type { PrimaryToolbarPlugin } from '@atlaskit/editor-plugin-primary-toolbar';
|
|
8
8
|
import type { SelectionToolbarPlugin } from '@atlaskit/editor-plugin-selection-toolbar';
|
|
9
|
+
import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
|
|
9
10
|
import type { UserPreferencesPlugin } from '@atlaskit/editor-plugin-user-preferences';
|
|
10
11
|
import type { HideLinkToolbar, InsertLink, ShowLinkToolbar, UpdateLink } from './editor-commands/commands';
|
|
11
12
|
type HyperlinkPluginCommands = {
|
|
@@ -53,7 +54,8 @@ export type HyperlinkPluginDependencies = [
|
|
|
53
54
|
OptionalPlugin<ConnectivityPlugin>,
|
|
54
55
|
OptionalPlugin<PrimaryToolbarPlugin>,
|
|
55
56
|
OptionalPlugin<SelectionToolbarPlugin>,
|
|
56
|
-
OptionalPlugin<UserPreferencesPlugin
|
|
57
|
+
OptionalPlugin<UserPreferencesPlugin>,
|
|
58
|
+
OptionalPlugin<ToolbarPlugin>
|
|
57
59
|
];
|
|
58
60
|
export type HyperlinkPluginActions = {
|
|
59
61
|
hideLinkToolbar: HideLinkToolbar;
|
|
@@ -5,7 +5,7 @@ import { type PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
|
5
5
|
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
6
6
|
export declare const ButtonWrapper: ({ editorView, pos, stateKey, intl, onOpenLinkClick, }: {
|
|
7
7
|
editorView: EditorView;
|
|
8
|
-
pos?: number
|
|
8
|
+
pos?: number;
|
|
9
9
|
stateKey: PluginKey<HyperlinkState>;
|
|
10
10
|
intl: IntlShape;
|
|
11
11
|
/** Callback fired when the Open Link dropdown item is clicked */
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
|
|
4
|
+
type LinkButtonProps = {
|
|
5
|
+
api?: ExtractInjectionAPI<HyperlinkPlugin>;
|
|
6
|
+
};
|
|
7
|
+
export declare const LinkButton: ({ api }: LinkButtonProps) => React.JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { ToolbarComponentTypes } from '@atlaskit/editor-toolbar-model';
|
|
4
|
+
import type { HyperlinkPlugin } from '../../hyperlinkPluginType';
|
|
5
|
+
type LinkSectionProps = {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
parents: ToolbarComponentTypes;
|
|
8
|
+
api?: ExtractInjectionAPI<HyperlinkPlugin>;
|
|
9
|
+
};
|
|
10
|
+
export declare const LinkSection: ({ children, parents, api }: LinkSectionProps) => React.JSX.Element | null;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { RegisterComponent } from '@atlaskit/editor-toolbar-model';
|
|
3
|
+
import type { HyperlinkPlugin } from '../hyperlinkPluginType';
|
|
4
|
+
export declare const getToolbarComponents: (api?: ExtractInjectionAPI<HyperlinkPlugin>) => RegisterComponent[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,22 +35,25 @@
|
|
|
35
35
|
"@atlaskit/adf-schema": "^50.2.0",
|
|
36
36
|
"@atlaskit/analytics-next": "^11.1.0",
|
|
37
37
|
"@atlaskit/editor-plugin-analytics": "^3.0.0",
|
|
38
|
-
"@atlaskit/editor-plugin-card": "^7.
|
|
38
|
+
"@atlaskit/editor-plugin-card": "^7.3.0",
|
|
39
39
|
"@atlaskit/editor-plugin-connectivity": "^3.1.0",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
|
|
41
41
|
"@atlaskit/editor-plugin-primary-toolbar": "^4.1.0",
|
|
42
|
-
"@atlaskit/editor-plugin-selection-toolbar": "^4.
|
|
42
|
+
"@atlaskit/editor-plugin-selection-toolbar": "^4.3.0",
|
|
43
|
+
"@atlaskit/editor-plugin-toolbar": "^0.2.0",
|
|
43
44
|
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
44
|
-
"@atlaskit/
|
|
45
|
+
"@atlaskit/editor-toolbar": "^0.2.0",
|
|
46
|
+
"@atlaskit/editor-toolbar-model": "^0.1.0",
|
|
47
|
+
"@atlaskit/icon": "^27.11.0",
|
|
45
48
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
46
49
|
"@atlaskit/prosemirror-input-rules": "^3.4.0",
|
|
47
|
-
"@atlaskit/tmp-editor-statsig": "^9.
|
|
50
|
+
"@atlaskit/tmp-editor-statsig": "^9.27.0",
|
|
48
51
|
"@babel/runtime": "^7.0.0",
|
|
49
52
|
"@emotion/react": "^11.7.1",
|
|
50
53
|
"uuid": "^3.1.0"
|
|
51
54
|
},
|
|
52
55
|
"peerDependencies": {
|
|
53
|
-
"@atlaskit/editor-common": "^107.
|
|
56
|
+
"@atlaskit/editor-common": "^107.20.0",
|
|
54
57
|
"react": "^18.2.0",
|
|
55
58
|
"react-dom": "^18.2.0",
|
|
56
59
|
"react-intl-next": "npm:react-intl@^5.18.1"
|
|
@@ -60,11 +63,10 @@
|
|
|
60
63
|
"@atlaskit/link-test-helpers": "^8.3.0",
|
|
61
64
|
"@atlaskit/media-test-helpers": "^37.0.0",
|
|
62
65
|
"@atlaskit/ssr": "workspace:^",
|
|
63
|
-
"@atlaskit/util-data-test": "^18.
|
|
66
|
+
"@atlaskit/util-data-test": "^18.1.0",
|
|
64
67
|
"@atlaskit/visual-regression": "workspace:^",
|
|
65
68
|
"@testing-library/react": "^13.4.0",
|
|
66
69
|
"raf-stub": "^2.0.1",
|
|
67
|
-
"typescript": "~5.4.2",
|
|
68
70
|
"wait-for-expect": "^1.2.0"
|
|
69
71
|
},
|
|
70
72
|
"techstack": {
|