@atlaskit/editor-plugin-card 4.4.12 → 4.5.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 +18 -0
- package/dist/cjs/plugin.js +4 -0
- package/dist/cjs/toolbar.js +30 -4
- package/dist/es2019/plugin.js +5 -0
- package/dist/es2019/toolbar.js +31 -5
- package/dist/esm/plugin.js +5 -0
- package/dist/esm/toolbar.js +31 -5
- package/dist/types/plugin.d.ts +12 -2
- package/dist/types-ts4.5/plugin.d.ts +12 -2
- package/package.json +9 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-card
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#175540](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/175540)
|
|
8
|
+
[`fa908f67c5dba`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/fa908f67c5dba) -
|
|
9
|
+
[ux] ED-25903 support comment on smart links floating toolbar
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 4.4.13
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
|
|
3
21
|
## 4.4.12
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/cjs/plugin.js
CHANGED
|
@@ -30,6 +30,10 @@ var _LayoutButton = _interopRequireDefault(require("./ui/LayoutButton"));
|
|
|
30
30
|
var _utils2 = require("./utils");
|
|
31
31
|
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; }
|
|
32
32
|
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; }
|
|
33
|
+
// Dummpy type of AnnotationPlugin
|
|
34
|
+
// This is used to avoid editor universal preset's inferred type maximum length error
|
|
35
|
+
// TODO: Remove this when the issue is fixed
|
|
36
|
+
|
|
33
37
|
var cardPlugin = exports.cardPlugin = function cardPlugin(_ref) {
|
|
34
38
|
var _options$lpLinkPicker;
|
|
35
39
|
var _ref$config = _ref.config,
|
package/dist/cjs/toolbar.js
CHANGED
|
@@ -18,10 +18,12 @@ var _styles = require("@atlaskit/editor-common/styles");
|
|
|
18
18
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
19
19
|
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
20
20
|
var _utils2 = require("@atlaskit/editor-prosemirror/utils");
|
|
21
|
+
var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
|
|
21
22
|
var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
|
|
22
23
|
var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
|
|
23
24
|
var _linkExternal = _interopRequireDefault(require("@atlaskit/icon/core/link-external"));
|
|
24
25
|
var _settings = _interopRequireDefault(require("@atlaskit/icon/core/settings"));
|
|
26
|
+
var _comment2 = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
|
|
25
27
|
var _remove = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/remove"));
|
|
26
28
|
var _settings2 = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/settings"));
|
|
27
29
|
var _unlink = _interopRequireDefault(require("@atlaskit/icon/glyph/editor/unlink"));
|
|
@@ -189,7 +191,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
|
189
191
|
};
|
|
190
192
|
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) {
|
|
191
193
|
return function (node) {
|
|
192
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs;
|
|
194
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs;
|
|
193
195
|
var _titleUrlPairFromNode2 = (0, _utils3.titleUrlPairFromNode)(node),
|
|
194
196
|
url = _titleUrlPairFromNode2.url;
|
|
195
197
|
var _ref = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
@@ -210,6 +212,19 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
210
212
|
hoverDecoration = _ref2.hoverDecoration;
|
|
211
213
|
var isDatasource = (0, _utils3.isDatasourceNode)(node);
|
|
212
214
|
var pluginState = _main.pluginKey.getState(state);
|
|
215
|
+
var annotationApiState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.sharedState.currentState();
|
|
216
|
+
var activeCommentMark = node.marks.find(function (mark) {
|
|
217
|
+
return mark.type.name === 'annotation' && (annotationApiState === null || annotationApiState === void 0 ? void 0 : annotationApiState.annotations[mark.attrs.id]) === false;
|
|
218
|
+
});
|
|
219
|
+
var isCommentEnabled = annotationApiState && annotationApiState.isVisible && !annotationApiState.bookmark && !annotationApiState.mouseData.isSelecting && !activeCommentMark && node.type === state.schema.nodes.inlineCard && (0, _platformFeatureFlags.fg)('platform_inline_node_as_valid_annotation_selection');
|
|
220
|
+
var onCommentButtonClick = function onCommentButtonClick(state, dispatch) {
|
|
221
|
+
if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.annotation) || !isCommentEnabled) {
|
|
222
|
+
return false;
|
|
223
|
+
}
|
|
224
|
+
var setInlineCommentDraftState = pluginInjectionApi.annotation.actions.setInlineCommentDraftState;
|
|
225
|
+
var command = setInlineCommentDraftState(true, _analytics.INPUT_METHOD.FLOATING_TB);
|
|
226
|
+
return command(state, dispatch);
|
|
227
|
+
};
|
|
213
228
|
var shouldRenderDatasourceToolbar = isDatasource && cardOptions.allowDatasource && (0, _utils.canRenderDatasource)(node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 || (_node$attrs = _node$attrs.datasource) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id);
|
|
214
229
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar) {
|
|
215
230
|
return [(0, _EditLinkToolbar.buildEditLinkToolbar)({
|
|
@@ -249,7 +264,18 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
249
264
|
}, {
|
|
250
265
|
type: 'separator'
|
|
251
266
|
}];
|
|
252
|
-
var
|
|
267
|
+
var commentItems = isCommentEnabled ? [{
|
|
268
|
+
id: 'editor.link.commentLink',
|
|
269
|
+
type: 'button',
|
|
270
|
+
icon: _comment.default,
|
|
271
|
+
testId: 'inline-card-toolbar-comment-button',
|
|
272
|
+
iconFallback: _comment2.default,
|
|
273
|
+
title: intl.formatMessage(_messages.annotationMessages.createComment),
|
|
274
|
+
onClick: onCommentButtonClick
|
|
275
|
+
}, {
|
|
276
|
+
type: 'separator'
|
|
277
|
+
}] : [];
|
|
278
|
+
var toolbarItems = [].concat(editItems, commentItems, [{
|
|
253
279
|
id: 'editor.link.openLink',
|
|
254
280
|
type: 'button',
|
|
255
281
|
icon: _linkExternal.default,
|
|
@@ -287,8 +313,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
287
313
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
288
314
|
}]);
|
|
289
315
|
if (currentAppearance === 'embed') {
|
|
290
|
-
var _pluginInjectionApi$
|
|
291
|
-
var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
316
|
+
var _pluginInjectionApi$a3;
|
|
317
|
+
var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, cardOptions);
|
|
292
318
|
if (alignmentOptions.length) {
|
|
293
319
|
alignmentOptions.push({
|
|
294
320
|
type: 'separator'
|
package/dist/es2019/plugin.js
CHANGED
|
@@ -18,6 +18,11 @@ import { EditorLinkingPlatformAnalytics } from './ui/EditorLinkingPlatformAnalyt
|
|
|
18
18
|
import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
19
19
|
import LayoutButton from './ui/LayoutButton';
|
|
20
20
|
import { isDatasourceConfigEditable } from './utils';
|
|
21
|
+
|
|
22
|
+
// Dummpy type of AnnotationPlugin
|
|
23
|
+
// This is used to avoid editor universal preset's inferred type maximum length error
|
|
24
|
+
// TODO: Remove this when the issue is fixed
|
|
25
|
+
|
|
21
26
|
export const cardPlugin = ({
|
|
22
27
|
config: options = {},
|
|
23
28
|
api
|
package/dist/es2019/toolbar.js
CHANGED
|
@@ -3,15 +3,17 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { buildLayoutButtons, commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
5
5
|
import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
|
|
6
|
-
import commonMessages, { linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
6
|
+
import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
7
7
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
8
8
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
9
9
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
10
10
|
import { findDomRefAtPos, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
11
|
+
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
11
12
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
12
13
|
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
13
14
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
14
15
|
import SettingsIcon from '@atlaskit/icon/core/settings';
|
|
16
|
+
import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
|
|
15
17
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
16
18
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
17
19
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
@@ -177,7 +179,7 @@ const getToolbarViewedItem = (url, display) => {
|
|
|
177
179
|
}];
|
|
178
180
|
};
|
|
179
181
|
const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) => node => {
|
|
180
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs, _node$attrs$datasourc;
|
|
182
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs, _node$attrs$datasourc;
|
|
181
183
|
const {
|
|
182
184
|
url
|
|
183
185
|
} = titleUrlPairFromNode(node);
|
|
@@ -202,6 +204,19 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
202
204
|
} = (_pluginInjectionApi$d = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d2 = pluginInjectionApi.decorations) === null || _pluginInjectionApi$d2 === void 0 ? void 0 : _pluginInjectionApi$d2.actions) !== null && _pluginInjectionApi$d !== void 0 ? _pluginInjectionApi$d : {};
|
|
203
205
|
const isDatasource = isDatasourceNode(node);
|
|
204
206
|
const pluginState = pluginKey.getState(state);
|
|
207
|
+
const annotationApiState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.sharedState.currentState();
|
|
208
|
+
const activeCommentMark = node.marks.find(mark => mark.type.name === 'annotation' && (annotationApiState === null || annotationApiState === void 0 ? void 0 : annotationApiState.annotations[mark.attrs.id]) === false);
|
|
209
|
+
const isCommentEnabled = annotationApiState && annotationApiState.isVisible && !annotationApiState.bookmark && !annotationApiState.mouseData.isSelecting && !activeCommentMark && node.type === state.schema.nodes.inlineCard && fg('platform_inline_node_as_valid_annotation_selection');
|
|
210
|
+
const onCommentButtonClick = (state, dispatch) => {
|
|
211
|
+
if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.annotation) || !isCommentEnabled) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
const {
|
|
215
|
+
setInlineCommentDraftState
|
|
216
|
+
} = pluginInjectionApi.annotation.actions;
|
|
217
|
+
const command = setInlineCommentDraftState(true, INPUT_METHOD.FLOATING_TB);
|
|
218
|
+
return command(state, dispatch);
|
|
219
|
+
};
|
|
205
220
|
const shouldRenderDatasourceToolbar = isDatasource && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : (_node$attrs$datasourc = _node$attrs.datasource) === null || _node$attrs$datasourc === void 0 ? void 0 : _node$attrs$datasourc.id);
|
|
206
221
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar) {
|
|
207
222
|
return [buildEditLinkToolbar({
|
|
@@ -241,7 +256,18 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
241
256
|
}, {
|
|
242
257
|
type: 'separator'
|
|
243
258
|
}];
|
|
244
|
-
const
|
|
259
|
+
const commentItems = isCommentEnabled ? [{
|
|
260
|
+
id: 'editor.link.commentLink',
|
|
261
|
+
type: 'button',
|
|
262
|
+
icon: CommentIcon,
|
|
263
|
+
testId: 'inline-card-toolbar-comment-button',
|
|
264
|
+
iconFallback: LegacyCommentIcon,
|
|
265
|
+
title: intl.formatMessage(annotationMessages.createComment),
|
|
266
|
+
onClick: onCommentButtonClick
|
|
267
|
+
}, {
|
|
268
|
+
type: 'separator'
|
|
269
|
+
}] : [];
|
|
270
|
+
const toolbarItems = [...editItems, ...commentItems, {
|
|
245
271
|
id: 'editor.link.openLink',
|
|
246
272
|
type: 'button',
|
|
247
273
|
icon: LinkExternalIcon,
|
|
@@ -279,8 +305,8 @@ const generateToolbarItems = (state, intl, providerFactory, cardOptions, lpLinkP
|
|
|
279
305
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
280
306
|
}];
|
|
281
307
|
if (currentAppearance === 'embed') {
|
|
282
|
-
var _pluginInjectionApi$
|
|
283
|
-
const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$
|
|
308
|
+
var _pluginInjectionApi$a3;
|
|
309
|
+
const alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, cardOptions);
|
|
284
310
|
if (alignmentOptions.length) {
|
|
285
311
|
alignmentOptions.push({
|
|
286
312
|
type: 'separator'
|
package/dist/esm/plugin.js
CHANGED
|
@@ -23,6 +23,11 @@ import { EditorLinkingPlatformAnalytics } from './ui/EditorLinkingPlatformAnalyt
|
|
|
23
23
|
import { EditorSmartCardEvents } from './ui/EditorSmartCardEvents';
|
|
24
24
|
import LayoutButton from './ui/LayoutButton';
|
|
25
25
|
import { isDatasourceConfigEditable } from './utils';
|
|
26
|
+
|
|
27
|
+
// Dummpy type of AnnotationPlugin
|
|
28
|
+
// This is used to avoid editor universal preset's inferred type maximum length error
|
|
29
|
+
// TODO: Remove this when the issue is fixed
|
|
30
|
+
|
|
26
31
|
export var cardPlugin = function cardPlugin(_ref) {
|
|
27
32
|
var _options$lpLinkPicker;
|
|
28
33
|
var _ref$config = _ref.config,
|
package/dist/esm/toolbar.js
CHANGED
|
@@ -7,15 +7,17 @@ import { isSafeUrl } from '@atlaskit/adf-schema';
|
|
|
7
7
|
import { ACTION, ACTION_SUBJECT, buildOpenedSettingsPayload, buildVisitedLinkPayload, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
8
8
|
import { buildLayoutButtons, commandWithMetadata } from '@atlaskit/editor-common/card';
|
|
9
9
|
import { getLinkPreferencesURLFromENV } from '@atlaskit/editor-common/link';
|
|
10
|
-
import commonMessages, { linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
10
|
+
import commonMessages, { annotationMessages, linkMessages, linkToolbarMessages, cardMessages as messages } from '@atlaskit/editor-common/messages';
|
|
11
11
|
import { FLOATING_TOOLBAR_LINKPICKER_CLASSNAME, richMediaClassName } from '@atlaskit/editor-common/styles';
|
|
12
12
|
import { canRenderDatasource } from '@atlaskit/editor-common/utils';
|
|
13
13
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
14
14
|
import { findDomRefAtPos, removeSelectedNode } from '@atlaskit/editor-prosemirror/utils';
|
|
15
|
+
import CommentIcon from '@atlaskit/icon/core/comment';
|
|
15
16
|
import DeleteIcon from '@atlaskit/icon/core/delete';
|
|
16
17
|
import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
|
|
17
18
|
import LinkExternalIcon from '@atlaskit/icon/core/link-external';
|
|
18
19
|
import SettingsIcon from '@atlaskit/icon/core/settings';
|
|
20
|
+
import LegacyCommentIcon from '@atlaskit/icon/glyph/comment';
|
|
19
21
|
import RemoveIcon from '@atlaskit/icon/glyph/editor/remove';
|
|
20
22
|
import CogIcon from '@atlaskit/icon/glyph/editor/settings';
|
|
21
23
|
import UnlinkIcon from '@atlaskit/icon/glyph/editor/unlink';
|
|
@@ -179,7 +181,7 @@ var getToolbarViewedItem = function getToolbarViewedItem(url, display) {
|
|
|
179
181
|
};
|
|
180
182
|
var generateToolbarItems = function generateToolbarItems(state, intl, providerFactory, cardOptions, lpLinkPicker, linkPicker, pluginInjectionApi) {
|
|
181
183
|
return function (node) {
|
|
182
|
-
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _node$attrs;
|
|
184
|
+
var _pluginInjectionApi$a, _pluginInjectionApi$d, _pluginInjectionApi$d2, _pluginInjectionApi$a2, _node$attrs;
|
|
183
185
|
var _titleUrlPairFromNode2 = titleUrlPairFromNode(node),
|
|
184
186
|
url = _titleUrlPairFromNode2.url;
|
|
185
187
|
var _ref = (_pluginInjectionApi$a = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.analytics) !== null && _pluginInjectionApi$a !== void 0 ? _pluginInjectionApi$a : {},
|
|
@@ -200,6 +202,19 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
200
202
|
hoverDecoration = _ref2.hoverDecoration;
|
|
201
203
|
var isDatasource = isDatasourceNode(node);
|
|
202
204
|
var pluginState = pluginKey.getState(state);
|
|
205
|
+
var annotationApiState = pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a2 = pluginInjectionApi.annotation) === null || _pluginInjectionApi$a2 === void 0 ? void 0 : _pluginInjectionApi$a2.sharedState.currentState();
|
|
206
|
+
var activeCommentMark = node.marks.find(function (mark) {
|
|
207
|
+
return mark.type.name === 'annotation' && (annotationApiState === null || annotationApiState === void 0 ? void 0 : annotationApiState.annotations[mark.attrs.id]) === false;
|
|
208
|
+
});
|
|
209
|
+
var isCommentEnabled = annotationApiState && annotationApiState.isVisible && !annotationApiState.bookmark && !annotationApiState.mouseData.isSelecting && !activeCommentMark && node.type === state.schema.nodes.inlineCard && fg('platform_inline_node_as_valid_annotation_selection');
|
|
210
|
+
var onCommentButtonClick = function onCommentButtonClick(state, dispatch) {
|
|
211
|
+
if (!(pluginInjectionApi !== null && pluginInjectionApi !== void 0 && pluginInjectionApi.annotation) || !isCommentEnabled) {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
var setInlineCommentDraftState = pluginInjectionApi.annotation.actions.setInlineCommentDraftState;
|
|
215
|
+
var command = setInlineCommentDraftState(true, INPUT_METHOD.FLOATING_TB);
|
|
216
|
+
return command(state, dispatch);
|
|
217
|
+
};
|
|
203
218
|
var shouldRenderDatasourceToolbar = isDatasource && cardOptions.allowDatasource && canRenderDatasource(node === null || node === void 0 || (_node$attrs = node.attrs) === null || _node$attrs === void 0 || (_node$attrs = _node$attrs.datasource) === null || _node$attrs === void 0 ? void 0 : _node$attrs.id);
|
|
204
219
|
if (pluginState !== null && pluginState !== void 0 && pluginState.showLinkingToolbar) {
|
|
205
220
|
return [buildEditLinkToolbar({
|
|
@@ -239,7 +254,18 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
239
254
|
}, {
|
|
240
255
|
type: 'separator'
|
|
241
256
|
}];
|
|
242
|
-
var
|
|
257
|
+
var commentItems = isCommentEnabled ? [{
|
|
258
|
+
id: 'editor.link.commentLink',
|
|
259
|
+
type: 'button',
|
|
260
|
+
icon: CommentIcon,
|
|
261
|
+
testId: 'inline-card-toolbar-comment-button',
|
|
262
|
+
iconFallback: LegacyCommentIcon,
|
|
263
|
+
title: intl.formatMessage(annotationMessages.createComment),
|
|
264
|
+
onClick: onCommentButtonClick
|
|
265
|
+
}, {
|
|
266
|
+
type: 'separator'
|
|
267
|
+
}] : [];
|
|
268
|
+
var toolbarItems = [].concat(editItems, commentItems, [{
|
|
243
269
|
id: 'editor.link.openLink',
|
|
244
270
|
type: 'button',
|
|
245
271
|
icon: LinkExternalIcon,
|
|
@@ -277,8 +303,8 @@ var generateToolbarItems = function generateToolbarItems(state, intl, providerFa
|
|
|
277
303
|
onClick: withToolbarMetadata(removeCard(editorAnalyticsApi))
|
|
278
304
|
}]);
|
|
279
305
|
if (currentAppearance === 'embed') {
|
|
280
|
-
var _pluginInjectionApi$
|
|
281
|
-
var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$
|
|
306
|
+
var _pluginInjectionApi$a3;
|
|
307
|
+
var alignmentOptions = buildAlignmentOptions(state, intl, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.width, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a3 = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a3 === void 0 ? void 0 : _pluginInjectionApi$a3.actions, cardOptions);
|
|
282
308
|
if (alignmentOptions.length) {
|
|
283
309
|
alignmentOptions.push({
|
|
284
310
|
type: 'separator'
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
2
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { InlineCommentPluginState } from '@atlaskit/editor-plugin-annotation';
|
|
4
6
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
7
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
6
8
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
@@ -10,6 +12,12 @@ import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
|
10
12
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
11
13
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
12
14
|
import type { CardPluginOptions, CardPluginState } from './types';
|
|
15
|
+
type DummyAnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
16
|
+
sharedState: InlineCommentPluginState;
|
|
17
|
+
actions: {
|
|
18
|
+
setInlineCommentDraftState: (isDraft: boolean, inputMethod: INPUT_METHOD) => Command;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
13
21
|
export type CardPlugin = NextEditorPlugin<'card', {
|
|
14
22
|
pluginConfiguration: CardPluginOptions | undefined;
|
|
15
23
|
dependencies: [
|
|
@@ -21,9 +29,11 @@ export type CardPlugin = NextEditorPlugin<'card', {
|
|
|
21
29
|
GridPlugin,
|
|
22
30
|
FloatingToolbarPlugin,
|
|
23
31
|
OptionalPlugin<EditorDisabledPlugin>,
|
|
24
|
-
OptionalPlugin<SelectionPlugin
|
|
32
|
+
OptionalPlugin<SelectionPlugin>,
|
|
33
|
+
OptionalPlugin<DummyAnnotationPlugin>
|
|
25
34
|
];
|
|
26
35
|
sharedState: CardPluginState | null;
|
|
27
36
|
actions: CardPluginActions;
|
|
28
37
|
}>;
|
|
29
38
|
export declare const cardPlugin: CardPlugin;
|
|
39
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
1
2
|
import type { CardPluginActions } from '@atlaskit/editor-common/card';
|
|
2
|
-
import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
|
|
3
|
+
import type { NextEditorPlugin, OptionalPlugin, Command } from '@atlaskit/editor-common/types';
|
|
3
4
|
import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
|
|
5
|
+
import type { InlineCommentPluginState } from '@atlaskit/editor-plugin-annotation';
|
|
4
6
|
import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
|
|
5
7
|
import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
|
|
6
8
|
import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
|
|
@@ -10,6 +12,12 @@ import type { GridPlugin } from '@atlaskit/editor-plugin-grid';
|
|
|
10
12
|
import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
|
|
11
13
|
import type { WidthPlugin } from '@atlaskit/editor-plugin-width';
|
|
12
14
|
import type { CardPluginOptions, CardPluginState } from './types';
|
|
15
|
+
type DummyAnnotationPlugin = NextEditorPlugin<'annotation', {
|
|
16
|
+
sharedState: InlineCommentPluginState;
|
|
17
|
+
actions: {
|
|
18
|
+
setInlineCommentDraftState: (isDraft: boolean, inputMethod: INPUT_METHOD) => Command;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
13
21
|
export type CardPlugin = NextEditorPlugin<'card', {
|
|
14
22
|
pluginConfiguration: CardPluginOptions | undefined;
|
|
15
23
|
dependencies: [
|
|
@@ -21,9 +29,11 @@ export type CardPlugin = NextEditorPlugin<'card', {
|
|
|
21
29
|
GridPlugin,
|
|
22
30
|
FloatingToolbarPlugin,
|
|
23
31
|
OptionalPlugin<EditorDisabledPlugin>,
|
|
24
|
-
OptionalPlugin<SelectionPlugin
|
|
32
|
+
OptionalPlugin<SelectionPlugin>,
|
|
33
|
+
OptionalPlugin<DummyAnnotationPlugin>
|
|
25
34
|
];
|
|
26
35
|
sharedState: CardPluginState | null;
|
|
27
36
|
actions: CardPluginActions;
|
|
28
37
|
}>;
|
|
29
38
|
export declare const cardPlugin: CardPlugin;
|
|
39
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-plugin-card",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.5.0",
|
|
4
4
|
"description": "Card plugin for @atlaskit/editor-core",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"@atlaskit/adf-schema": "^46.1.0",
|
|
35
35
|
"@atlaskit/analytics-next": "^10.1.0",
|
|
36
36
|
"@atlaskit/custom-steps": "^0.9.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
37
|
+
"@atlaskit/editor-common": "^96.3.0",
|
|
38
38
|
"@atlaskit/editor-plugin-analytics": "^1.10.0",
|
|
39
39
|
"@atlaskit/editor-plugin-decorations": "^1.3.0",
|
|
40
40
|
"@atlaskit/editor-plugin-editor-disabled": "^1.3.0",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
47
47
|
"@atlaskit/editor-shared-styles": "^3.2.0",
|
|
48
48
|
"@atlaskit/frontend-utilities": "^2.7.0",
|
|
49
|
-
"@atlaskit/icon": "^23.
|
|
50
|
-
"@atlaskit/link-analytics": "^8.
|
|
49
|
+
"@atlaskit/icon": "^23.1.0",
|
|
50
|
+
"@atlaskit/link-analytics": "^8.6.0",
|
|
51
51
|
"@atlaskit/link-client-extension": "^3.0.0",
|
|
52
52
|
"@atlaskit/link-datasource": "^3.13.0",
|
|
53
53
|
"@atlaskit/linking-common": "^6.0.0",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"@atlaskit/menu": "2.13.6",
|
|
56
56
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
57
57
|
"@atlaskit/primitives": "^13.3.0",
|
|
58
|
-
"@atlaskit/smart-card": "^32.
|
|
58
|
+
"@atlaskit/smart-card": "^32.6.0",
|
|
59
59
|
"@atlaskit/theme": "^14.0.0",
|
|
60
|
-
"@atlaskit/tmp-editor-statsig": "^2.
|
|
60
|
+
"@atlaskit/tmp-editor-statsig": "^2.23.0",
|
|
61
61
|
"@atlaskit/tokens": "^2.4.0",
|
|
62
62
|
"@babel/runtime": "^7.0.0",
|
|
63
63
|
"@emotion/react": "^11.7.1",
|
|
@@ -131,6 +131,9 @@
|
|
|
131
131
|
},
|
|
132
132
|
"platform_editor_remove_copy_button_from_view_mode": {
|
|
133
133
|
"type": "boolean"
|
|
134
|
+
},
|
|
135
|
+
"platform_inline_node_as_valid_annotation_selection": {
|
|
136
|
+
"type": "boolean"
|
|
134
137
|
}
|
|
135
138
|
},
|
|
136
139
|
"stricter": {
|