@atlaskit/editor-common 82.6.0 → 82.7.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 +12 -0
- package/dist/cjs/link/ConfigureLinkOverlay/OverlayButton.js +87 -0
- package/dist/cjs/link/index.js +7 -0
- package/dist/cjs/link/types.js +1 -0
- package/dist/cjs/monitoring/error.js +1 -1
- package/dist/cjs/ui/DropList/index.js +1 -1
- package/dist/es2019/link/ConfigureLinkOverlay/OverlayButton.js +80 -0
- package/dist/es2019/link/index.js +2 -1
- package/dist/es2019/link/types.js +1 -0
- package/dist/es2019/monitoring/error.js +1 -1
- package/dist/es2019/ui/DropList/index.js +1 -1
- package/dist/esm/link/ConfigureLinkOverlay/OverlayButton.js +79 -0
- package/dist/esm/link/index.js +2 -1
- package/dist/esm/link/types.js +1 -0
- package/dist/esm/monitoring/error.js +1 -1
- package/dist/esm/ui/DropList/index.js +1 -1
- package/dist/types/link/ConfigureLinkOverlay/OverlayButton.d.ts +8 -0
- package/dist/types/link/index.d.ts +2 -0
- package/dist/types/link/types.d.ts +5 -1
- package/dist/types-ts4.5/link/ConfigureLinkOverlay/OverlayButton.d.ts +8 -0
- package/dist/types-ts4.5/link/index.d.ts +2 -0
- package/dist/types-ts4.5/link/types.d.ts +5 -1
- package/package.json +16 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/editor-common
|
|
2
2
|
|
|
3
|
+
## 82.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#110802](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110802)
|
|
8
|
+
[`4ec8e069a729b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/4ec8e069a729b) -
|
|
9
|
+
Added a new overlay button component, which selects the passed in node at node position on click.
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
3
15
|
## 82.6.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.OverlayButton = void 0;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _react2 = require("@emotion/react");
|
|
10
|
+
var _reactIntlNext = require("react-intl-next");
|
|
11
|
+
var _button = _interopRequireDefault(require("@atlaskit/button"));
|
|
12
|
+
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
+
var _preferences = _interopRequireDefault(require("@atlaskit/icon/glyph/preferences"));
|
|
14
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
15
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
16
|
+
var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
|
|
17
|
+
var _messages = require("../../messages");
|
|
18
|
+
/** @jsx jsx */
|
|
19
|
+
|
|
20
|
+
var buttonStyles = (0, _react2.css)({
|
|
21
|
+
background: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
22
|
+
color: "var(--ds-icon, ".concat(_colors.N700, ")"),
|
|
23
|
+
'&:hover': {
|
|
24
|
+
background: "var(--ds-background-neutral-hovered, ".concat(_colors.N40A, ")")
|
|
25
|
+
},
|
|
26
|
+
'&:active': {
|
|
27
|
+
background: "var(--ds-background-neutral-pressed, ".concat(_colors.N60A, ")")
|
|
28
|
+
},
|
|
29
|
+
width: '1.375rem',
|
|
30
|
+
height: '1.25rem'
|
|
31
|
+
});
|
|
32
|
+
var buttonWrapperStyles = (0, _react2.css)({
|
|
33
|
+
position: 'absolute',
|
|
34
|
+
zIndex: _constants.layers.card(),
|
|
35
|
+
display: 'inline-flex',
|
|
36
|
+
top: '50%',
|
|
37
|
+
transform: 'translateY(-50%)',
|
|
38
|
+
background: "var(--ds-surface-raised, ".concat(_colors.N0, ")")
|
|
39
|
+
});
|
|
40
|
+
var OverlayButton = exports.OverlayButton = function OverlayButton(_ref) {
|
|
41
|
+
var _docNode$nodeSize;
|
|
42
|
+
var editorView = _ref.editorView,
|
|
43
|
+
_ref$testId = _ref.testId,
|
|
44
|
+
testId = _ref$testId === void 0 ? 'link-configure-overlay-button' : _ref$testId,
|
|
45
|
+
_ref$targetElementPos = _ref.targetElementPos,
|
|
46
|
+
targetElementPos = _ref$targetElementPos === void 0 ? 0 : _ref$targetElementPos;
|
|
47
|
+
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
48
|
+
formatMessage = _useIntl.formatMessage;
|
|
49
|
+
var docNode = editorView.state.doc.nodeAt(targetElementPos);
|
|
50
|
+
var nodeEnd = targetElementPos + ((_docNode$nodeSize = docNode === null || docNode === void 0 ? void 0 : docNode.nodeSize) !== null && _docNode$nodeSize !== void 0 ? _docNode$nodeSize : 0);
|
|
51
|
+
var isText = docNode === null || docNode === void 0 ? void 0 : docNode.isText;
|
|
52
|
+
var handleClick = (0, _react.useCallback)(function () {
|
|
53
|
+
var tr = editorView.state.tr;
|
|
54
|
+
if (isText) {
|
|
55
|
+
tr.setSelection(_state.TextSelection.create(tr.doc, targetElementPos, Math.min(nodeEnd, tr.doc.nodeSize)));
|
|
56
|
+
} else {
|
|
57
|
+
tr.setSelection(_state.NodeSelection.create(tr.doc, targetElementPos));
|
|
58
|
+
}
|
|
59
|
+
editorView.dispatch(tr);
|
|
60
|
+
}, [isText, editorView, nodeEnd, targetElementPos]);
|
|
61
|
+
var _editorView$state$sel = editorView.state.selection,
|
|
62
|
+
from = _editorView$state$sel.from,
|
|
63
|
+
to = _editorView$state$sel.to;
|
|
64
|
+
var isSelected = from === targetElementPos && to === nodeEnd;
|
|
65
|
+
if (!targetElementPos || isSelected) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
var configureLinkLabel = formatMessage(_messages.cardMessages.inlineConfigureLink);
|
|
69
|
+
return (0, _react2.jsx)("span", {
|
|
70
|
+
css: buttonWrapperStyles
|
|
71
|
+
}, (0, _react2.jsx)(_tooltip.default, {
|
|
72
|
+
content: configureLinkLabel,
|
|
73
|
+
hideTooltipOnClick: true,
|
|
74
|
+
testId: "".concat(testId, "-tooltip")
|
|
75
|
+
}, (0, _react2.jsx)(_button.default, {
|
|
76
|
+
testId: testId
|
|
77
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
78
|
+
,
|
|
79
|
+
css: buttonStyles,
|
|
80
|
+
onClick: handleClick,
|
|
81
|
+
iconBefore: (0, _react2.jsx)(_preferences.default, {
|
|
82
|
+
label: configureLinkLabel,
|
|
83
|
+
size: "small",
|
|
84
|
+
testId: "".concat(testId, "-configure-icon")
|
|
85
|
+
})
|
|
86
|
+
})));
|
|
87
|
+
};
|
package/dist/cjs/link/index.js
CHANGED
|
@@ -53,6 +53,12 @@ Object.defineProperty(exports, "LinkSearchListItem", {
|
|
|
53
53
|
return _LinkSearchListItem.default;
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
|
+
Object.defineProperty(exports, "OverlayButton", {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
get: function get() {
|
|
59
|
+
return _OverlayButton.OverlayButton;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
56
62
|
Object.defineProperty(exports, "RECENT_SEARCH_LIST_SIZE", {
|
|
57
63
|
enumerable: true,
|
|
58
64
|
get: function get() {
|
|
@@ -137,5 +143,6 @@ var _HyperlinkAddToolbar2 = _interopRequireWildcard(require("./LinkPicker/Hyperl
|
|
|
137
143
|
var _utils = require("./LinkPicker/HyperlinkAddToolbar/utils");
|
|
138
144
|
var _utils2 = require("./utils");
|
|
139
145
|
var _constants = require("./constants");
|
|
146
|
+
var _OverlayButton = require("./ConfigureLinkOverlay/OverlayButton");
|
|
140
147
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
141
148
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
package/dist/cjs/link/types.js
CHANGED
|
@@ -10,6 +10,7 @@ var LinkAction = exports.LinkAction = /*#__PURE__*/function (LinkAction) {
|
|
|
10
10
|
LinkAction["SELECTION_CHANGE"] = "SELECTION_CHANGE";
|
|
11
11
|
LinkAction["INSERT_LINK_TOOLBAR"] = "INSERT";
|
|
12
12
|
LinkAction["EDIT_INSERTED_TOOLBAR"] = "EDIT_INSERTED_TOOLBAR";
|
|
13
|
+
LinkAction["SET_CONFIGURE_BUTTON_TARGET_POS"] = "SET_CONFIGURE_BUTTON_TARGET_POS";
|
|
13
14
|
return LinkAction;
|
|
14
15
|
}({});
|
|
15
16
|
var InsertStatus = exports.InsertStatus = /*#__PURE__*/function (InsertStatus) {
|
|
@@ -17,7 +17,7 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
17
17
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
18
18
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
19
19
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
20
|
-
var packageVersion = "82.
|
|
20
|
+
var packageVersion = "82.7.0";
|
|
21
21
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
22
22
|
// Remove URL as it has UGC
|
|
23
23
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -20,7 +20,7 @@ var _Layer = _interopRequireDefault(require("../Layer"));
|
|
|
20
20
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
21
21
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /** @jsx jsx */
|
|
22
22
|
var packageName = "@atlaskit/editor-common";
|
|
23
|
-
var packageVersion = "82.
|
|
23
|
+
var packageVersion = "82.7.0";
|
|
24
24
|
var halfFocusRing = 1;
|
|
25
25
|
var dropOffset = '0, 8';
|
|
26
26
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { useIntl } from 'react-intl-next';
|
|
5
|
+
import Button from '@atlaskit/button';
|
|
6
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
8
|
+
import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
|
|
9
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
10
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { cardMessages } from '../../messages';
|
|
12
|
+
const buttonStyles = css({
|
|
13
|
+
background: `var(--ds-background-neutral, ${N30A})`,
|
|
14
|
+
color: `var(--ds-icon, ${N700})`,
|
|
15
|
+
'&:hover': {
|
|
16
|
+
background: `var(--ds-background-neutral-hovered, ${N40A})`
|
|
17
|
+
},
|
|
18
|
+
'&:active': {
|
|
19
|
+
background: `var(--ds-background-neutral-pressed, ${N60A})`
|
|
20
|
+
},
|
|
21
|
+
width: '1.375rem',
|
|
22
|
+
height: '1.25rem'
|
|
23
|
+
});
|
|
24
|
+
const buttonWrapperStyles = css({
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
zIndex: layers.card(),
|
|
27
|
+
display: 'inline-flex',
|
|
28
|
+
top: '50%',
|
|
29
|
+
transform: 'translateY(-50%)',
|
|
30
|
+
background: `var(--ds-surface-raised, ${N0})`
|
|
31
|
+
});
|
|
32
|
+
export const OverlayButton = ({
|
|
33
|
+
editorView,
|
|
34
|
+
testId = 'link-configure-overlay-button',
|
|
35
|
+
targetElementPos = 0
|
|
36
|
+
}) => {
|
|
37
|
+
var _docNode$nodeSize;
|
|
38
|
+
const {
|
|
39
|
+
formatMessage
|
|
40
|
+
} = useIntl();
|
|
41
|
+
const docNode = editorView.state.doc.nodeAt(targetElementPos);
|
|
42
|
+
const nodeEnd = targetElementPos + ((_docNode$nodeSize = docNode === null || docNode === void 0 ? void 0 : docNode.nodeSize) !== null && _docNode$nodeSize !== void 0 ? _docNode$nodeSize : 0);
|
|
43
|
+
const isText = docNode === null || docNode === void 0 ? void 0 : docNode.isText;
|
|
44
|
+
const handleClick = useCallback(() => {
|
|
45
|
+
const tr = editorView.state.tr;
|
|
46
|
+
if (isText) {
|
|
47
|
+
tr.setSelection(TextSelection.create(tr.doc, targetElementPos, Math.min(nodeEnd, tr.doc.nodeSize)));
|
|
48
|
+
} else {
|
|
49
|
+
tr.setSelection(NodeSelection.create(tr.doc, targetElementPos));
|
|
50
|
+
}
|
|
51
|
+
editorView.dispatch(tr);
|
|
52
|
+
}, [isText, editorView, nodeEnd, targetElementPos]);
|
|
53
|
+
const {
|
|
54
|
+
from,
|
|
55
|
+
to
|
|
56
|
+
} = editorView.state.selection;
|
|
57
|
+
const isSelected = from === targetElementPos && to === nodeEnd;
|
|
58
|
+
if (!targetElementPos || isSelected) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
const configureLinkLabel = formatMessage(cardMessages.inlineConfigureLink);
|
|
62
|
+
return jsx("span", {
|
|
63
|
+
css: buttonWrapperStyles
|
|
64
|
+
}, jsx(Tooltip, {
|
|
65
|
+
content: configureLinkLabel,
|
|
66
|
+
hideTooltipOnClick: true,
|
|
67
|
+
testId: `${testId}-tooltip`
|
|
68
|
+
}, jsx(Button, {
|
|
69
|
+
testId: testId
|
|
70
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
71
|
+
,
|
|
72
|
+
css: buttonStyles,
|
|
73
|
+
onClick: handleClick,
|
|
74
|
+
iconBefore: jsx(PreferencesIcon, {
|
|
75
|
+
label: configureLinkLabel,
|
|
76
|
+
size: "small",
|
|
77
|
+
testId: `${testId}-configure-icon`
|
|
78
|
+
})
|
|
79
|
+
})));
|
|
80
|
+
};
|
|
@@ -9,4 +9,5 @@ export { HyperlinkAddToolbar } from './LinkPicker/HyperlinkAddToolbar';
|
|
|
9
9
|
export { default as HyperlinkLinkAddToolbar, HyperlinkLinkAddToolbarWithIntl, RECENT_SEARCH_LIST_SIZE } from './LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar';
|
|
10
10
|
export { sha1 } from './LinkPicker/HyperlinkAddToolbar/utils';
|
|
11
11
|
export { isLinkAtPos, isTextAtPos, getLinkPreferencesURLFromENV } from './utils';
|
|
12
|
-
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
12
|
+
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
13
|
+
export { OverlayButton } from './ConfigureLinkOverlay/OverlayButton';
|
|
@@ -4,6 +4,7 @@ export let LinkAction = /*#__PURE__*/function (LinkAction) {
|
|
|
4
4
|
LinkAction["SELECTION_CHANGE"] = "SELECTION_CHANGE";
|
|
5
5
|
LinkAction["INSERT_LINK_TOOLBAR"] = "INSERT";
|
|
6
6
|
LinkAction["EDIT_INSERTED_TOOLBAR"] = "EDIT_INSERTED_TOOLBAR";
|
|
7
|
+
LinkAction["SET_CONFIGURE_BUTTON_TARGET_POS"] = "SET_CONFIGURE_BUTTON_TARGET_POS";
|
|
7
8
|
return LinkAction;
|
|
8
9
|
}({});
|
|
9
10
|
export let InsertStatus = /*#__PURE__*/function (InsertStatus) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isFedRamp } from './environment';
|
|
2
2
|
const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
3
3
|
const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
4
|
-
const packageVersion = "82.
|
|
4
|
+
const packageVersion = "82.7.0";
|
|
5
5
|
const sanitiseSentryEvents = (data, _hint) => {
|
|
6
6
|
// Remove URL as it has UGC
|
|
7
7
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -7,7 +7,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
7
7
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
8
8
|
import Layer from '../Layer';
|
|
9
9
|
const packageName = "@atlaskit/editor-common";
|
|
10
|
-
const packageVersion = "82.
|
|
10
|
+
const packageVersion = "82.7.0";
|
|
11
11
|
const halfFocusRing = 1;
|
|
12
12
|
const dropOffset = '0, 8';
|
|
13
13
|
class DropList extends Component {
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { useCallback } from 'react';
|
|
3
|
+
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { useIntl } from 'react-intl-next';
|
|
5
|
+
import Button from '@atlaskit/button';
|
|
6
|
+
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
+
import PreferencesIcon from '@atlaskit/icon/glyph/preferences';
|
|
8
|
+
import { N0, N30A, N40A, N60A, N700 } from '@atlaskit/theme/colors';
|
|
9
|
+
import { layers } from '@atlaskit/theme/constants';
|
|
10
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { cardMessages } from '../../messages';
|
|
12
|
+
var buttonStyles = css({
|
|
13
|
+
background: "var(--ds-background-neutral, ".concat(N30A, ")"),
|
|
14
|
+
color: "var(--ds-icon, ".concat(N700, ")"),
|
|
15
|
+
'&:hover': {
|
|
16
|
+
background: "var(--ds-background-neutral-hovered, ".concat(N40A, ")")
|
|
17
|
+
},
|
|
18
|
+
'&:active': {
|
|
19
|
+
background: "var(--ds-background-neutral-pressed, ".concat(N60A, ")")
|
|
20
|
+
},
|
|
21
|
+
width: '1.375rem',
|
|
22
|
+
height: '1.25rem'
|
|
23
|
+
});
|
|
24
|
+
var buttonWrapperStyles = css({
|
|
25
|
+
position: 'absolute',
|
|
26
|
+
zIndex: layers.card(),
|
|
27
|
+
display: 'inline-flex',
|
|
28
|
+
top: '50%',
|
|
29
|
+
transform: 'translateY(-50%)',
|
|
30
|
+
background: "var(--ds-surface-raised, ".concat(N0, ")")
|
|
31
|
+
});
|
|
32
|
+
export var OverlayButton = function OverlayButton(_ref) {
|
|
33
|
+
var _docNode$nodeSize;
|
|
34
|
+
var editorView = _ref.editorView,
|
|
35
|
+
_ref$testId = _ref.testId,
|
|
36
|
+
testId = _ref$testId === void 0 ? 'link-configure-overlay-button' : _ref$testId,
|
|
37
|
+
_ref$targetElementPos = _ref.targetElementPos,
|
|
38
|
+
targetElementPos = _ref$targetElementPos === void 0 ? 0 : _ref$targetElementPos;
|
|
39
|
+
var _useIntl = useIntl(),
|
|
40
|
+
formatMessage = _useIntl.formatMessage;
|
|
41
|
+
var docNode = editorView.state.doc.nodeAt(targetElementPos);
|
|
42
|
+
var nodeEnd = targetElementPos + ((_docNode$nodeSize = docNode === null || docNode === void 0 ? void 0 : docNode.nodeSize) !== null && _docNode$nodeSize !== void 0 ? _docNode$nodeSize : 0);
|
|
43
|
+
var isText = docNode === null || docNode === void 0 ? void 0 : docNode.isText;
|
|
44
|
+
var handleClick = useCallback(function () {
|
|
45
|
+
var tr = editorView.state.tr;
|
|
46
|
+
if (isText) {
|
|
47
|
+
tr.setSelection(TextSelection.create(tr.doc, targetElementPos, Math.min(nodeEnd, tr.doc.nodeSize)));
|
|
48
|
+
} else {
|
|
49
|
+
tr.setSelection(NodeSelection.create(tr.doc, targetElementPos));
|
|
50
|
+
}
|
|
51
|
+
editorView.dispatch(tr);
|
|
52
|
+
}, [isText, editorView, nodeEnd, targetElementPos]);
|
|
53
|
+
var _editorView$state$sel = editorView.state.selection,
|
|
54
|
+
from = _editorView$state$sel.from,
|
|
55
|
+
to = _editorView$state$sel.to;
|
|
56
|
+
var isSelected = from === targetElementPos && to === nodeEnd;
|
|
57
|
+
if (!targetElementPos || isSelected) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
var configureLinkLabel = formatMessage(cardMessages.inlineConfigureLink);
|
|
61
|
+
return jsx("span", {
|
|
62
|
+
css: buttonWrapperStyles
|
|
63
|
+
}, jsx(Tooltip, {
|
|
64
|
+
content: configureLinkLabel,
|
|
65
|
+
hideTooltipOnClick: true,
|
|
66
|
+
testId: "".concat(testId, "-tooltip")
|
|
67
|
+
}, jsx(Button, {
|
|
68
|
+
testId: testId
|
|
69
|
+
// eslint-disable-next-line @atlaskit/design-system/no-unsafe-style-overrides
|
|
70
|
+
,
|
|
71
|
+
css: buttonStyles,
|
|
72
|
+
onClick: handleClick,
|
|
73
|
+
iconBefore: jsx(PreferencesIcon, {
|
|
74
|
+
label: configureLinkLabel,
|
|
75
|
+
size: "small",
|
|
76
|
+
testId: "".concat(testId, "-configure-icon")
|
|
77
|
+
})
|
|
78
|
+
})));
|
|
79
|
+
};
|
package/dist/esm/link/index.js
CHANGED
|
@@ -9,4 +9,5 @@ export { HyperlinkAddToolbar } from './LinkPicker/HyperlinkAddToolbar';
|
|
|
9
9
|
export { default as HyperlinkLinkAddToolbar, HyperlinkLinkAddToolbarWithIntl, RECENT_SEARCH_LIST_SIZE } from './LinkPicker/HyperlinkAddToolbar/HyperlinkAddToolbar';
|
|
10
10
|
export { sha1 } from './LinkPicker/HyperlinkAddToolbar/utils';
|
|
11
11
|
export { isLinkAtPos, isTextAtPos, getLinkPreferencesURLFromENV } from './utils';
|
|
12
|
-
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
12
|
+
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
13
|
+
export { OverlayButton } from './ConfigureLinkOverlay/OverlayButton';
|
package/dist/esm/link/types.js
CHANGED
|
@@ -4,6 +4,7 @@ export var LinkAction = /*#__PURE__*/function (LinkAction) {
|
|
|
4
4
|
LinkAction["SELECTION_CHANGE"] = "SELECTION_CHANGE";
|
|
5
5
|
LinkAction["INSERT_LINK_TOOLBAR"] = "INSERT";
|
|
6
6
|
LinkAction["EDIT_INSERTED_TOOLBAR"] = "EDIT_INSERTED_TOOLBAR";
|
|
7
|
+
LinkAction["SET_CONFIGURE_BUTTON_TARGET_POS"] = "SET_CONFIGURE_BUTTON_TARGET_POS";
|
|
7
8
|
return LinkAction;
|
|
8
9
|
}({});
|
|
9
10
|
export var InsertStatus = /*#__PURE__*/function (InsertStatus) {
|
|
@@ -7,7 +7,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
7
7
|
import { isFedRamp } from './environment';
|
|
8
8
|
var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
|
|
9
9
|
var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
|
|
10
|
-
var packageVersion = "82.
|
|
10
|
+
var packageVersion = "82.7.0";
|
|
11
11
|
var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
|
|
12
12
|
// Remove URL as it has UGC
|
|
13
13
|
// TODO: Sanitise the URL instead of just removing it
|
|
@@ -15,7 +15,7 @@ import { createAndFireEvent, withAnalyticsContext, withAnalyticsEvents } from '@
|
|
|
15
15
|
import { N0, N50A, N60A, N900 } from '@atlaskit/theme/colors';
|
|
16
16
|
import Layer from '../Layer';
|
|
17
17
|
var packageName = "@atlaskit/editor-common";
|
|
18
|
-
var packageVersion = "82.
|
|
18
|
+
var packageVersion = "82.7.0";
|
|
19
19
|
var halfFocusRing = 1;
|
|
20
20
|
var dropOffset = '0, 8';
|
|
21
21
|
var DropList = /*#__PURE__*/function (_Component) {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export interface OverlayButtonProps {
|
|
4
|
+
editorView: EditorView;
|
|
5
|
+
testId?: string;
|
|
6
|
+
targetElementPos?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const OverlayButton: ({ editorView, testId, targetElementPos, }: OverlayButtonProps) => jsx.JSX.Element | null;
|
|
@@ -15,3 +15,5 @@ export type { HyperlinkAddToolbarProps } from './LinkPicker/HyperlinkAddToolbar'
|
|
|
15
15
|
export { sha1 } from './LinkPicker/HyperlinkAddToolbar/utils';
|
|
16
16
|
export { isLinkAtPos, isTextAtPos, getLinkPreferencesURLFromENV } from './utils';
|
|
17
17
|
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
18
|
+
export { OverlayButton } from './ConfigureLinkOverlay/OverlayButton';
|
|
19
|
+
export type { OverlayButtonProps } from './ConfigureLinkOverlay/OverlayButton';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import { type INPUT_METHOD } from '../analytics';
|
|
3
4
|
import type { EditorAppearance } from '../types';
|
|
4
5
|
export declare enum LinkAction {
|
|
@@ -6,7 +7,8 @@ export declare enum LinkAction {
|
|
|
6
7
|
HIDE_TOOLBAR = "HIDE_TOOLBAR",
|
|
7
8
|
SELECTION_CHANGE = "SELECTION_CHANGE",
|
|
8
9
|
INSERT_LINK_TOOLBAR = "INSERT",
|
|
9
|
-
EDIT_INSERTED_TOOLBAR = "EDIT_INSERTED_TOOLBAR"
|
|
10
|
+
EDIT_INSERTED_TOOLBAR = "EDIT_INSERTED_TOOLBAR",
|
|
11
|
+
SET_CONFIGURE_BUTTON_TARGET_POS = "SET_CONFIGURE_BUTTON_TARGET_POS"
|
|
10
12
|
}
|
|
11
13
|
export declare enum InsertStatus {
|
|
12
14
|
EDIT_LINK_TOOLBAR = "EDIT",
|
|
@@ -37,4 +39,6 @@ export interface HyperlinkState {
|
|
|
37
39
|
searchSessionId?: string;
|
|
38
40
|
inputMethod?: INPUT_METHOD;
|
|
39
41
|
editorAppearance?: EditorAppearance;
|
|
42
|
+
configureButtonTargetPos?: number;
|
|
43
|
+
decorations?: DecorationSet;
|
|
40
44
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { type EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
3
|
+
export interface OverlayButtonProps {
|
|
4
|
+
editorView: EditorView;
|
|
5
|
+
testId?: string;
|
|
6
|
+
targetElementPos?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare const OverlayButton: ({ editorView, testId, targetElementPos, }: OverlayButtonProps) => jsx.JSX.Element | null;
|
|
@@ -15,3 +15,5 @@ export type { HyperlinkAddToolbarProps } from './LinkPicker/HyperlinkAddToolbar'
|
|
|
15
15
|
export { sha1 } from './LinkPicker/HyperlinkAddToolbar/utils';
|
|
16
16
|
export { isLinkAtPos, isTextAtPos, getLinkPreferencesURLFromENV } from './utils';
|
|
17
17
|
export { stagingLinkPreferencesUrl, productionLinkPreferencesUrl } from './constants';
|
|
18
|
+
export { OverlayButton } from './ConfigureLinkOverlay/OverlayButton';
|
|
19
|
+
export type { OverlayButtonProps } from './ConfigureLinkOverlay/OverlayButton';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Node } from '@atlaskit/editor-prosemirror/model';
|
|
2
|
+
import { type DecorationSet } from '@atlaskit/editor-prosemirror/view';
|
|
2
3
|
import { type INPUT_METHOD } from '../analytics';
|
|
3
4
|
import type { EditorAppearance } from '../types';
|
|
4
5
|
export declare enum LinkAction {
|
|
@@ -6,7 +7,8 @@ export declare enum LinkAction {
|
|
|
6
7
|
HIDE_TOOLBAR = "HIDE_TOOLBAR",
|
|
7
8
|
SELECTION_CHANGE = "SELECTION_CHANGE",
|
|
8
9
|
INSERT_LINK_TOOLBAR = "INSERT",
|
|
9
|
-
EDIT_INSERTED_TOOLBAR = "EDIT_INSERTED_TOOLBAR"
|
|
10
|
+
EDIT_INSERTED_TOOLBAR = "EDIT_INSERTED_TOOLBAR",
|
|
11
|
+
SET_CONFIGURE_BUTTON_TARGET_POS = "SET_CONFIGURE_BUTTON_TARGET_POS"
|
|
10
12
|
}
|
|
11
13
|
export declare enum InsertStatus {
|
|
12
14
|
EDIT_LINK_TOOLBAR = "EDIT",
|
|
@@ -37,4 +39,6 @@ export interface HyperlinkState {
|
|
|
37
39
|
searchSessionId?: string;
|
|
38
40
|
inputMethod?: INPUT_METHOD;
|
|
39
41
|
editorAppearance?: EditorAppearance;
|
|
42
|
+
configureButtonTargetPos?: number;
|
|
43
|
+
decorations?: DecorationSet;
|
|
40
44
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-common",
|
|
3
|
-
"version": "82.
|
|
3
|
+
"version": "82.7.0",
|
|
4
4
|
"description": "A package that contains common classes and components for editor and renderer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -14,7 +14,10 @@
|
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
15
|
"typesVersions": {
|
|
16
16
|
">=4.5 <4.9": {
|
|
17
|
-
"*": [
|
|
17
|
+
"*": [
|
|
18
|
+
"dist/types-ts4.5/*",
|
|
19
|
+
"dist/types-ts4.5/index.d.ts"
|
|
20
|
+
]
|
|
18
21
|
}
|
|
19
22
|
},
|
|
20
23
|
"sideEffects": false,
|
|
@@ -120,11 +123,11 @@
|
|
|
120
123
|
"@atlaskit/media-file-preview": "^0.5.0",
|
|
121
124
|
"@atlaskit/media-picker": "^66.4.0",
|
|
122
125
|
"@atlaskit/media-ui": "^25.10.0",
|
|
123
|
-
"@atlaskit/media-viewer": "48.6.
|
|
126
|
+
"@atlaskit/media-viewer": "48.6.3",
|
|
124
127
|
"@atlaskit/mention": "^23.2.0",
|
|
125
128
|
"@atlaskit/menu": "^2.4.0",
|
|
126
129
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|
|
127
|
-
"@atlaskit/primitives": "^7.
|
|
130
|
+
"@atlaskit/primitives": "^7.3.0",
|
|
128
131
|
"@atlaskit/profilecard": "^19.14.0",
|
|
129
132
|
"@atlaskit/section-message": "^6.5.0",
|
|
130
133
|
"@atlaskit/smart-card": "^27.6.0",
|
|
@@ -193,13 +196,19 @@
|
|
|
193
196
|
},
|
|
194
197
|
"techstack": {
|
|
195
198
|
"@atlassian/frontend": {
|
|
196
|
-
"circular-dependencies": [
|
|
199
|
+
"circular-dependencies": [
|
|
200
|
+
"file-level"
|
|
201
|
+
],
|
|
197
202
|
"import-structure": "atlassian-conventions"
|
|
198
203
|
},
|
|
199
204
|
"@repo/internal": {
|
|
200
205
|
"deprecation": "no-deprecated-imports",
|
|
201
|
-
"design-tokens": [
|
|
202
|
-
|
|
206
|
+
"design-tokens": [
|
|
207
|
+
"color"
|
|
208
|
+
],
|
|
209
|
+
"styling": [
|
|
210
|
+
"emotion"
|
|
211
|
+
]
|
|
203
212
|
}
|
|
204
213
|
},
|
|
205
214
|
"platform-feature-flags": {
|