@atlaskit/editor-plugin-emoji 2.7.8 → 2.7.10

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,20 @@
1
1
  # @atlaskit/editor-plugin-emoji
2
2
 
3
+ ## 2.7.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#173838](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/173838)
8
+ [`66ed8e1cd9c74`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/66ed8e1cd9c74) -
9
+ [ux] ED-25836 show comment in floating toolbar for emoji
10
+ - Updated dependencies
11
+
12
+ ## 2.7.9
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 2.7.8
4
19
 
5
20
  ### Patch Changes
@@ -16,14 +16,17 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
16
16
  var _react = _interopRequireDefault(require("react"));
17
17
  var _adfSchema = require("@atlaskit/adf-schema");
18
18
  var _analytics = require("@atlaskit/editor-common/analytics");
19
+ var _keymaps = require("@atlaskit/editor-common/keymaps");
19
20
  var _messages = require("@atlaskit/editor-common/messages");
20
21
  var _quickInsert = require("@atlaskit/editor-common/quick-insert");
21
22
  var _reactNodeView = require("@atlaskit/editor-common/react-node-view");
22
23
  var _safePlugin = require("@atlaskit/editor-common/safe-plugin");
23
24
  var _typeAhead = require("@atlaskit/editor-common/type-ahead");
25
+ var _utils = require("@atlaskit/editor-common/utils");
24
26
  var _model = require("@atlaskit/editor-prosemirror/model");
25
27
  var _state = require("@atlaskit/editor-prosemirror/state");
26
28
  var _emoji2 = require("@atlaskit/emoji");
29
+ var _comment = _interopRequireDefault(require("@atlaskit/icon/core/comment"));
27
30
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
28
31
  var _insertEmoji = require("./commands/insert-emoji");
29
32
  var _emoji3 = require("./nodeviews/emoji");
@@ -290,7 +293,50 @@ var emojiPlugin = exports.emojiPlugin = function emojiPlugin(_ref2) {
290
293
  }
291
294
  }];
292
295
  },
293
- typeAhead: typeAhead
296
+ typeAhead: typeAhead,
297
+ floatingToolbar: function floatingToolbar(state, intl) {
298
+ var _api$editorViewMode;
299
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
300
+ if (!isViewMode || !(0, _platformFeatureFlags.fg)('platform_inline_node_as_valid_annotation_selection')) {
301
+ return undefined;
302
+ }
303
+ var onClick = function onClick(stateFromClickEvent, dispatch) {
304
+ var _api$annotation;
305
+ if (!(api !== null && api !== void 0 && api.annotation)) {
306
+ return true;
307
+ }
308
+ var command = (_api$annotation = api.annotation) === null || _api$annotation === void 0 || (_api$annotation = _api$annotation.actions) === null || _api$annotation === void 0 ? void 0 : _api$annotation.setInlineCommentDraftState(true, _analytics.INPUT_METHOD.TOOLBAR);
309
+ return command(stateFromClickEvent, dispatch);
310
+ };
311
+ return {
312
+ title: 'Emoji floating toolbar',
313
+ nodeType: [state.schema.nodes.emoji],
314
+ onPositionCalculated: (0, _utils.calculateToolbarPositionAboveSelection)('Emoji floating toolbar'),
315
+ items: function items(node) {
316
+ var _api$annotation2;
317
+ var annotationState = api === null || api === void 0 || (_api$annotation2 = api.annotation) === null || _api$annotation2 === void 0 ? void 0 : _api$annotation2.sharedState.currentState();
318
+ var activeCommentMark = node.marks.find(function (mark) {
319
+ return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
320
+ });
321
+ var showAnnotation = annotationState && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !activeCommentMark;
322
+ if (showAnnotation) {
323
+ return [{
324
+ type: 'button',
325
+ showTitle: true,
326
+ testId: 'add-comment-emoji-button',
327
+ icon: _comment.default,
328
+ title: intl.formatMessage(_messages.annotationMessages.createComment),
329
+ onClick: onClick,
330
+ tooltipContent: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
331
+ description: intl.formatMessage(_messages.annotationMessages.createComment)
332
+ }),
333
+ supportsViewMode: true
334
+ }];
335
+ }
336
+ return [];
337
+ }
338
+ };
339
+ }
294
340
  }
295
341
  };
296
342
  };
@@ -1,14 +1,17 @@
1
1
  import React from 'react';
2
2
  import { emoji } from '@atlaskit/adf-schema';
3
3
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
4
- import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
4
+ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
5
+ import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
5
6
  import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
6
7
  import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
7
8
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
8
9
  import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
10
+ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
9
11
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
10
12
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
11
13
  import { EmojiTypeAheadItem, recordSelectionFailedSli, recordSelectionSucceededSli, SearchSort } from '@atlaskit/emoji';
14
+ import CommentIcon from '@atlaskit/icon/core/comment';
12
15
  import { fg } from '@atlaskit/platform-feature-flags';
13
16
  import { createEmojiFragment, insertEmoji } from './commands/insert-emoji';
14
17
  import { EmojiNodeView } from './nodeviews/emoji';
@@ -249,7 +252,48 @@ export const emojiPlugin = ({
249
252
  return tr;
250
253
  }
251
254
  }],
252
- typeAhead
255
+ typeAhead,
256
+ floatingToolbar: (state, intl) => {
257
+ var _api$editorViewMode, _api$editorViewMode$s;
258
+ const isViewMode = (api === null || api === void 0 ? void 0 : (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 ? void 0 : (_api$editorViewMode$s = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode$s === void 0 ? void 0 : _api$editorViewMode$s.mode) === 'view';
259
+ if (!isViewMode || !fg('platform_inline_node_as_valid_annotation_selection')) {
260
+ return undefined;
261
+ }
262
+ const onClick = (stateFromClickEvent, dispatch) => {
263
+ var _api$annotation, _api$annotation$actio;
264
+ if (!(api !== null && api !== void 0 && api.annotation)) {
265
+ return true;
266
+ }
267
+ const command = (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : (_api$annotation$actio = _api$annotation.actions) === null || _api$annotation$actio === void 0 ? void 0 : _api$annotation$actio.setInlineCommentDraftState(true, INPUT_METHOD.TOOLBAR);
268
+ return command(stateFromClickEvent, dispatch);
269
+ };
270
+ return {
271
+ title: 'Emoji floating toolbar',
272
+ nodeType: [state.schema.nodes.emoji],
273
+ onPositionCalculated: calculateToolbarPositionAboveSelection('Emoji floating toolbar'),
274
+ items: node => {
275
+ var _api$annotation2;
276
+ const annotationState = api === null || api === void 0 ? void 0 : (_api$annotation2 = api.annotation) === null || _api$annotation2 === void 0 ? void 0 : _api$annotation2.sharedState.currentState();
277
+ const activeCommentMark = node.marks.find(mark => mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false);
278
+ const showAnnotation = annotationState && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !activeCommentMark;
279
+ if (showAnnotation) {
280
+ return [{
281
+ type: 'button',
282
+ showTitle: true,
283
+ testId: 'add-comment-emoji-button',
284
+ icon: CommentIcon,
285
+ title: intl.formatMessage(annotationMessages.createComment),
286
+ onClick,
287
+ tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
288
+ description: intl.formatMessage(annotationMessages.createComment)
289
+ }),
290
+ supportsViewMode: true
291
+ }];
292
+ }
293
+ return [];
294
+ }
295
+ };
296
+ }
253
297
  }
254
298
  };
255
299
  };
@@ -6,14 +6,17 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
6
6
  import React from 'react';
7
7
  import { emoji } from '@atlaskit/adf-schema';
8
8
  import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
9
- import { toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
9
+ import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
10
+ import { annotationMessages, toolbarInsertBlockMessages as messages } from '@atlaskit/editor-common/messages';
10
11
  import { IconEmoji } from '@atlaskit/editor-common/quick-insert';
11
12
  import { getInlineNodeViewProducer } from '@atlaskit/editor-common/react-node-view';
12
13
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
13
14
  import { TypeAheadAvailableNodes } from '@atlaskit/editor-common/type-ahead';
15
+ import { calculateToolbarPositionAboveSelection } from '@atlaskit/editor-common/utils';
14
16
  import { Fragment } from '@atlaskit/editor-prosemirror/model';
15
17
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
16
18
  import { EmojiTypeAheadItem, recordSelectionFailedSli, recordSelectionSucceededSli, SearchSort } from '@atlaskit/emoji';
19
+ import CommentIcon from '@atlaskit/icon/core/comment';
17
20
  import { fg } from '@atlaskit/platform-feature-flags';
18
21
  import { createEmojiFragment, insertEmoji } from './commands/insert-emoji';
19
22
  import { EmojiNodeView } from './nodeviews/emoji';
@@ -278,7 +281,50 @@ export var emojiPlugin = function emojiPlugin(_ref2) {
278
281
  }
279
282
  }];
280
283
  },
281
- typeAhead: typeAhead
284
+ typeAhead: typeAhead,
285
+ floatingToolbar: function floatingToolbar(state, intl) {
286
+ var _api$editorViewMode;
287
+ var isViewMode = (api === null || api === void 0 || (_api$editorViewMode = api.editorViewMode) === null || _api$editorViewMode === void 0 || (_api$editorViewMode = _api$editorViewMode.sharedState.currentState()) === null || _api$editorViewMode === void 0 ? void 0 : _api$editorViewMode.mode) === 'view';
288
+ if (!isViewMode || !fg('platform_inline_node_as_valid_annotation_selection')) {
289
+ return undefined;
290
+ }
291
+ var onClick = function onClick(stateFromClickEvent, dispatch) {
292
+ var _api$annotation;
293
+ if (!(api !== null && api !== void 0 && api.annotation)) {
294
+ return true;
295
+ }
296
+ var command = (_api$annotation = api.annotation) === null || _api$annotation === void 0 || (_api$annotation = _api$annotation.actions) === null || _api$annotation === void 0 ? void 0 : _api$annotation.setInlineCommentDraftState(true, INPUT_METHOD.TOOLBAR);
297
+ return command(stateFromClickEvent, dispatch);
298
+ };
299
+ return {
300
+ title: 'Emoji floating toolbar',
301
+ nodeType: [state.schema.nodes.emoji],
302
+ onPositionCalculated: calculateToolbarPositionAboveSelection('Emoji floating toolbar'),
303
+ items: function items(node) {
304
+ var _api$annotation2;
305
+ var annotationState = api === null || api === void 0 || (_api$annotation2 = api.annotation) === null || _api$annotation2 === void 0 ? void 0 : _api$annotation2.sharedState.currentState();
306
+ var activeCommentMark = node.marks.find(function (mark) {
307
+ return mark.type.name === 'annotation' && (annotationState === null || annotationState === void 0 ? void 0 : annotationState.annotations[mark.attrs.id]) === false;
308
+ });
309
+ var showAnnotation = annotationState && annotationState.isVisible && !annotationState.bookmark && !annotationState.mouseData.isSelecting && !activeCommentMark;
310
+ if (showAnnotation) {
311
+ return [{
312
+ type: 'button',
313
+ showTitle: true,
314
+ testId: 'add-comment-emoji-button',
315
+ icon: CommentIcon,
316
+ title: intl.formatMessage(annotationMessages.createComment),
317
+ onClick: onClick,
318
+ tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
319
+ description: intl.formatMessage(annotationMessages.createComment)
320
+ }),
321
+ supportsViewMode: true
322
+ }];
323
+ }
324
+ return [];
325
+ }
326
+ };
327
+ }
282
328
  }
283
329
  };
284
330
  };
@@ -1,9 +1,29 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import type { EditorCommand, NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
2
+ import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { InlineCommentInputMethod, InlineCommentMap } from '@atlaskit/editor-plugin-annotation';
5
+ import { type EditorViewModePluginState } from '@atlaskit/editor-plugin-editor-viewmode';
4
6
  import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
7
+ import type { SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
5
8
  import type { EmojiDescription, EmojiId, EmojiProvider, EmojiResourceConfig } from '@atlaskit/emoji';
6
9
  import { type EmojiNodeDataProvider } from '@atlaskit/node-data-provider/emoji-provider';
10
+ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod) => Command;
11
+ type AnnotationPluginType = NextEditorPlugin<'annotation', {
12
+ sharedState: {
13
+ annotations: InlineCommentMap;
14
+ isVisible: boolean;
15
+ bookmark?: SelectionBookmark;
16
+ mouseData: {
17
+ isSelecting: boolean;
18
+ };
19
+ };
20
+ actions: {
21
+ setInlineCommentDraftState: SetInlineCommentDraftState;
22
+ };
23
+ }>;
24
+ type EditorViewModePluginType = NextEditorPlugin<'editorViewMode', {
25
+ sharedState: EditorViewModePluginState;
26
+ }>;
7
27
  export interface EmojiPluginOptions {
8
28
  headless?: boolean;
9
29
  emojiNodeDataProvider?: EmojiNodeDataProvider;
@@ -19,7 +39,12 @@ export type EmojiPluginSharedState = EmojiPluginState & {
19
39
  };
20
40
  export type EmojiPlugin = NextEditorPlugin<'emoji', {
21
41
  pluginConfiguration: EmojiPluginOptions | undefined;
22
- dependencies: [OptionalPlugin<AnalyticsPlugin>, TypeAheadPlugin];
42
+ dependencies: [
43
+ OptionalPlugin<AnalyticsPlugin>,
44
+ TypeAheadPlugin,
45
+ OptionalPlugin<AnnotationPluginType>,
46
+ OptionalPlugin<EditorViewModePluginType>
47
+ ];
23
48
  sharedState: EmojiPluginSharedState | undefined;
24
49
  commands: {
25
50
  insertEmoji: (emojiId: EmojiId, inputMethod?: INPUT_METHOD.PICKER | INPUT_METHOD.ASCII | INPUT_METHOD.TYPEAHEAD) => EditorCommand;
@@ -29,3 +54,4 @@ export type EmojiPlugin = NextEditorPlugin<'emoji', {
29
54
  setProvider: (provider: Promise<EmojiProvider>) => Promise<boolean>;
30
55
  };
31
56
  }>;
57
+ export {};
@@ -1,9 +1,29 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
- import type { EditorCommand, NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
2
+ import type { Command, EditorCommand, NextEditorPlugin, OptionalPlugin, TypeAheadHandler } from '@atlaskit/editor-common/types';
3
3
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
4
+ import type { InlineCommentInputMethod, InlineCommentMap } from '@atlaskit/editor-plugin-annotation';
5
+ import { type EditorViewModePluginState } from '@atlaskit/editor-plugin-editor-viewmode';
4
6
  import type { TypeAheadInputMethod, TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
7
+ import type { SelectionBookmark } from '@atlaskit/editor-prosemirror/state';
5
8
  import type { EmojiDescription, EmojiId, EmojiProvider, EmojiResourceConfig } from '@atlaskit/emoji';
6
9
  import { type EmojiNodeDataProvider } from '@atlaskit/node-data-provider/emoji-provider';
10
+ type SetInlineCommentDraftState = (drafting: boolean, inputMethod: InlineCommentInputMethod) => Command;
11
+ type AnnotationPluginType = NextEditorPlugin<'annotation', {
12
+ sharedState: {
13
+ annotations: InlineCommentMap;
14
+ isVisible: boolean;
15
+ bookmark?: SelectionBookmark;
16
+ mouseData: {
17
+ isSelecting: boolean;
18
+ };
19
+ };
20
+ actions: {
21
+ setInlineCommentDraftState: SetInlineCommentDraftState;
22
+ };
23
+ }>;
24
+ type EditorViewModePluginType = NextEditorPlugin<'editorViewMode', {
25
+ sharedState: EditorViewModePluginState;
26
+ }>;
7
27
  export interface EmojiPluginOptions {
8
28
  headless?: boolean;
9
29
  emojiNodeDataProvider?: EmojiNodeDataProvider;
@@ -21,7 +41,9 @@ export type EmojiPlugin = NextEditorPlugin<'emoji', {
21
41
  pluginConfiguration: EmojiPluginOptions | undefined;
22
42
  dependencies: [
23
43
  OptionalPlugin<AnalyticsPlugin>,
24
- TypeAheadPlugin
44
+ TypeAheadPlugin,
45
+ OptionalPlugin<AnnotationPluginType>,
46
+ OptionalPlugin<EditorViewModePluginType>
25
47
  ];
26
48
  sharedState: EmojiPluginSharedState | undefined;
27
49
  commands: {
@@ -32,3 +54,4 @@ export type EmojiPlugin = NextEditorPlugin<'emoji', {
32
54
  setProvider: (provider: Promise<EmojiProvider>) => Promise<boolean>;
33
55
  };
34
56
  }>;
57
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-emoji",
3
- "version": "2.7.8",
3
+ "version": "2.7.10",
4
4
  "description": "Emoji plugin for @atlaskit/editor-core",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -21,11 +21,14 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@atlaskit/adf-schema": "^46.1.0",
24
- "@atlaskit/editor-common": "^95.10.0",
24
+ "@atlaskit/editor-common": "^96.3.0",
25
25
  "@atlaskit/editor-plugin-analytics": "^1.10.0",
26
+ "@atlaskit/editor-plugin-annotation": "1.26.0",
27
+ "@atlaskit/editor-plugin-editor-viewmode": "^2.1.0",
26
28
  "@atlaskit/editor-plugin-type-ahead": "^1.11.0",
27
29
  "@atlaskit/editor-prosemirror": "6.2.1",
28
30
  "@atlaskit/emoji": "^67.11.0",
31
+ "@atlaskit/icon": "^23.0.1",
29
32
  "@atlaskit/node-data-provider": "^3.0.0",
30
33
  "@atlaskit/platform-feature-flags": "^0.3.0",
31
34
  "@atlaskit/prosemirror-input-rules": "^3.2.0",
@@ -96,6 +99,9 @@
96
99
  "platform-feature-flags": {
97
100
  "editor_inline_comments_paste_insert_nodes": {
98
101
  "type": "boolean"
102
+ },
103
+ "platform_inline_node_as_valid_annotation_selection": {
104
+ "type": "boolean"
99
105
  }
100
106
  }
101
107
  }