@atlaskit/editor-plugin-hyperlink 7.1.0 → 7.2.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
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-hyperlink
|
|
2
2
|
|
|
3
|
+
## 7.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`66414cddf2784`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/66414cddf2784) -
|
|
8
|
+
Add new platform_editor_toolbar_aifc_fix_editor_view experiment, replace destructured objects with
|
|
9
|
+
direct property access
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 7.1.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -8,26 +8,38 @@ exports.LinkButton = void 0;
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _reactIntlNext = require("react-intl-next");
|
|
10
10
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
11
|
+
var _hooks = require("@atlaskit/editor-common/hooks");
|
|
11
12
|
var _keymaps = require("@atlaskit/editor-common/keymaps");
|
|
12
13
|
var _messages = require("@atlaskit/editor-common/messages");
|
|
13
14
|
var _toolbar = require("@atlaskit/editor-common/toolbar");
|
|
14
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
15
16
|
var _editorToolbar = require("@atlaskit/editor-toolbar");
|
|
17
|
+
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
|
|
16
18
|
var LinkButton = exports.LinkButton = function LinkButton(_ref) {
|
|
17
19
|
var api = _ref.api;
|
|
18
20
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
19
21
|
formatMessage = _useIntl.formatMessage;
|
|
20
22
|
var _useEditorToolbar = (0, _toolbar.useEditorToolbar)(),
|
|
21
23
|
editorView = _useEditorToolbar.editorView;
|
|
24
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
22
25
|
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
23
26
|
state: null,
|
|
24
27
|
dispatch: null
|
|
25
28
|
},
|
|
26
29
|
state = _ref2.state;
|
|
30
|
+
var canInsertLink = (0, _hooks.useSharedPluginStateWithSelector)(api, ['hyperlink'], function (state) {
|
|
31
|
+
var _state$hyperlinkState, _state$hyperlinkState2;
|
|
32
|
+
return (_state$hyperlinkState = state === null || state === void 0 || (_state$hyperlinkState2 = state.hyperlinkState) === null || _state$hyperlinkState2 === void 0 ? void 0 : _state$hyperlinkState2.canInsertLink) !== null && _state$hyperlinkState !== void 0 ? _state$hyperlinkState : true;
|
|
33
|
+
});
|
|
27
34
|
var onClick = function onClick() {
|
|
28
35
|
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));
|
|
29
36
|
};
|
|
30
|
-
var isEnabled
|
|
37
|
+
var isEnabled;
|
|
38
|
+
if ((0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
39
|
+
isEnabled = canInsertLink;
|
|
40
|
+
} else {
|
|
41
|
+
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;
|
|
42
|
+
}
|
|
31
43
|
return /*#__PURE__*/_react.default.createElement(_editorToolbar.ToolbarTooltip, {
|
|
32
44
|
content: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
|
|
33
45
|
description: formatMessage(_messages.toolbarInsertBlockMessages.link),
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { ToolTipContent, addLink } from '@atlaskit/editor-common/keymaps';
|
|
5
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
7
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
8
|
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { LinkIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
11
|
export const LinkButton = ({
|
|
10
12
|
api
|
|
11
13
|
}) => {
|
|
@@ -15,16 +17,26 @@ export const LinkButton = ({
|
|
|
15
17
|
const {
|
|
16
18
|
editorView
|
|
17
19
|
} = useEditorToolbar();
|
|
20
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
18
21
|
const {
|
|
19
22
|
state
|
|
20
23
|
} = editorView !== null && editorView !== void 0 ? editorView : {
|
|
21
24
|
state: null,
|
|
22
25
|
dispatch: null
|
|
23
26
|
};
|
|
27
|
+
const canInsertLink = useSharedPluginStateWithSelector(api, ['hyperlink'], state => {
|
|
28
|
+
var _state$hyperlinkState, _state$hyperlinkState2;
|
|
29
|
+
return (_state$hyperlinkState = state === null || state === void 0 ? void 0 : (_state$hyperlinkState2 = state.hyperlinkState) === null || _state$hyperlinkState2 === void 0 ? void 0 : _state$hyperlinkState2.canInsertLink) !== null && _state$hyperlinkState !== void 0 ? _state$hyperlinkState : true;
|
|
30
|
+
});
|
|
24
31
|
const onClick = () => {
|
|
25
32
|
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));
|
|
26
33
|
};
|
|
27
|
-
|
|
34
|
+
let isEnabled;
|
|
35
|
+
if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
36
|
+
isEnabled = canInsertLink;
|
|
37
|
+
} else {
|
|
38
|
+
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;
|
|
39
|
+
}
|
|
28
40
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
29
41
|
content: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
30
42
|
description: formatMessage(messages.link),
|
|
@@ -1,26 +1,38 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl-next';
|
|
3
3
|
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
|
|
4
5
|
import { ToolTipContent, addLink } from '@atlaskit/editor-common/keymaps';
|
|
5
6
|
import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
7
|
import { useEditorToolbar } from '@atlaskit/editor-common/toolbar';
|
|
7
8
|
import { canLinkBeCreatedInRange } from '@atlaskit/editor-common/utils';
|
|
8
9
|
import { LinkIcon, ToolbarButton, ToolbarTooltip } from '@atlaskit/editor-toolbar';
|
|
10
|
+
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
|
|
9
11
|
export var LinkButton = function LinkButton(_ref) {
|
|
10
12
|
var api = _ref.api;
|
|
11
13
|
var _useIntl = useIntl(),
|
|
12
14
|
formatMessage = _useIntl.formatMessage;
|
|
13
15
|
var _useEditorToolbar = useEditorToolbar(),
|
|
14
16
|
editorView = _useEditorToolbar.editorView;
|
|
17
|
+
// Warning! Do not destructure editorView, it will become stale
|
|
15
18
|
var _ref2 = editorView !== null && editorView !== void 0 ? editorView : {
|
|
16
19
|
state: null,
|
|
17
20
|
dispatch: null
|
|
18
21
|
},
|
|
19
22
|
state = _ref2.state;
|
|
23
|
+
var canInsertLink = useSharedPluginStateWithSelector(api, ['hyperlink'], function (state) {
|
|
24
|
+
var _state$hyperlinkState, _state$hyperlinkState2;
|
|
25
|
+
return (_state$hyperlinkState = state === null || state === void 0 || (_state$hyperlinkState2 = state.hyperlinkState) === null || _state$hyperlinkState2 === void 0 ? void 0 : _state$hyperlinkState2.canInsertLink) !== null && _state$hyperlinkState !== void 0 ? _state$hyperlinkState : true;
|
|
26
|
+
});
|
|
20
27
|
var onClick = function onClick() {
|
|
21
28
|
api === null || api === void 0 || api.core.actions.execute(api === null || api === void 0 ? void 0 : api.hyperlink.commands.showLinkToolbar(INPUT_METHOD.FLOATING_TB));
|
|
22
29
|
};
|
|
23
|
-
var isEnabled
|
|
30
|
+
var isEnabled;
|
|
31
|
+
if (expValEquals('platform_editor_toolbar_aifc_fix_editor_view', 'isEnabled', true)) {
|
|
32
|
+
isEnabled = canInsertLink;
|
|
33
|
+
} else {
|
|
34
|
+
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;
|
|
35
|
+
}
|
|
24
36
|
return /*#__PURE__*/React.createElement(ToolbarTooltip, {
|
|
25
37
|
content: /*#__PURE__*/React.createElement(ToolTipContent, {
|
|
26
38
|
description: formatMessage(messages.link),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-hyperlink",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.0",
|
|
4
4
|
"description": "Hyperlink plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@atlaskit/icon": "^28.1.0",
|
|
46
46
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
47
47
|
"@atlaskit/prosemirror-input-rules": "^3.4.0",
|
|
48
|
-
"@atlaskit/tmp-editor-statsig": "^12.
|
|
48
|
+
"@atlaskit/tmp-editor-statsig": "^12.15.0",
|
|
49
49
|
"@babel/runtime": "^7.0.0",
|
|
50
50
|
"@emotion/react": "^11.7.1",
|
|
51
51
|
"uuid": "^3.1.0"
|