@atlaskit/editor-plugin-media 1.14.0 → 1.14.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-plugin-media
2
2
 
3
+ ## 1.14.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#88137](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/88137) [`0a744349d5e6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0a744349d5e6) - [ux] [ED-22833] Change icon used for comment button in media floating toolbar when there are active comments associated with the media. The icon will now be comment icon with a dot at top right corner.
8
+
3
9
  ## 1.14.0
4
10
 
5
11
  ### Minor Changes
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.CommentWithDotIcon = void 0;
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _icon = _interopRequireDefault(require("@atlaskit/icon"));
11
+ var _colors = require("@atlaskit/theme/colors");
12
+ var IconCommentWithDotGlyph = function IconCommentWithDotGlyph() {
13
+ return /*#__PURE__*/_react.default.createElement("svg", {
14
+ width: "24",
15
+ height: "24",
16
+ viewBox: "0 0 24 24",
17
+ fill: "none",
18
+ xmlns: "http://www.w3.org/2000/svg"
19
+ }, /*#__PURE__*/_react.default.createElement("path", {
20
+ fillRule: "evenodd",
21
+ clipRule: "evenodd",
22
+ d: "M4.998 11.513C4.998 8.475 8.139 6.003 12 6.003C15.861 6.003 19.002 8.475 19.002 11.513C19.002 14.552 15.861 17.023 12 17.023C8.139 17.023 4.998 14.552 4.998 11.513ZM19.838 19.284V19.282C19.838 19.282 18.274 17.022 19.071 16.166L19.034 16.186C20.261 14.902 21 13.279 21 11.513C21 7.371 16.963 4 12 4C7.037 4 3 7.37 3 11.513C3 15.656 7.037 19.027 12 19.027C13.42 19.027 14.76 18.742 15.957 18.251C16.96 19.273 18.244 19.823 19.197 19.97L19.199 19.967C19.2515 19.9867 19.3069 19.9979 19.363 20C19.448 20 19.5317 19.9789 19.6067 19.9386C19.6816 19.8984 19.7453 19.8402 19.7923 19.7693C19.8392 19.6984 19.8679 19.6169 19.8757 19.5323C19.8835 19.4476 19.8712 19.3623 19.838 19.284Z",
23
+ fill: "currentColor"
24
+ }), /*#__PURE__*/_react.default.createElement("path", {
25
+ d: "M16 9H8C7.44772 9 7 9.44772 7 10C7 10.5523 7.44772 11 8 11H16C16.5523 11 17 10.5523 17 10C17 9.44772 16.5523 9 16 9Z",
26
+ fill: "currentColor"
27
+ }), /*#__PURE__*/_react.default.createElement("path", {
28
+ d: "M11 12H8C7.44772 12 7 12.4477 7 13C7 13.5523 7.44772 14 8 14H11C11.5523 14 12 13.5523 12 13C12 12.4477 11.5523 12 11 12Z",
29
+ fill: "currentColor"
30
+ }), /*#__PURE__*/_react.default.createElement("rect", {
31
+ x: "14",
32
+ y: "2",
33
+ width: "8",
34
+ height: "8",
35
+ rx: "4",
36
+ fill: "var(--ds-background-warning-bold, ".concat(_colors.Y300, ")")
37
+ }));
38
+ };
39
+ var CommentWithDotIcon = exports.CommentWithDotIcon = function CommentWithDotIcon(props) {
40
+ return /*#__PURE__*/_react.default.createElement(_icon.default, (0, _extends2.default)({
41
+ glyph: IconCommentWithDotGlyph
42
+ }, props));
43
+ };
@@ -9,17 +9,26 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _analytics = require("@atlaskit/editor-common/analytics");
10
10
  var _keymaps = require("@atlaskit/editor-common/keymaps");
11
11
  var _media = require("@atlaskit/editor-common/media");
12
- var _state2 = require("@atlaskit/editor-prosemirror/state");
13
12
  var _comment = _interopRequireDefault(require("@atlaskit/icon/glyph/comment"));
14
- var commentButton = exports.commentButton = function commentButton(intl, _state, api) {
15
- var title = intl.formatMessage(_media.commentMessages.addCommentOnMedia);
13
+ var _commentWithDotIcon = require("./assets/commentWithDotIcon");
14
+ var _utils = require("./utils");
15
+ var commentButton = exports.commentButton = function commentButton(intl, state, api) {
16
+ var _getSelectedMediaSing, _api$annotation;
17
+ var selectMediaNode = (_getSelectedMediaSing = (0, _utils.getSelectedMediaSingle)(state)) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.node.firstChild;
18
+ var hasActiveComments = false;
19
+ var annotations = api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 || (_api$annotation = _api$annotation.sharedState.currentState()) === null || _api$annotation === void 0 ? void 0 : _api$annotation.annotations;
20
+ if (selectMediaNode && annotations) {
21
+ hasActiveComments = selectMediaNode.marks.some(function (mark) {
22
+ return mark.type.name === 'annotation' && !annotations[mark.attrs.id];
23
+ });
24
+ }
25
+ var title = intl.formatMessage(hasActiveComments ? _media.commentMessages.viewCommentsOnMedia : _media.commentMessages.addCommentOnMedia);
16
26
  var onClickHandler = function onClickHandler(state, dispatch) {
17
- if (api !== null && api !== void 0 && api.annotation && state.selection instanceof _state2.NodeSelection) {
18
- var mediaNode = state.selection.node.firstChild;
27
+ if (api !== null && api !== void 0 && api.annotation && selectMediaNode) {
19
28
  var _api$annotation$actio = api.annotation.actions,
20
29
  showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
21
30
  setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
22
- if (!showCommentForBlockNode(mediaNode)(state, dispatch)) {
31
+ if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
23
32
  setInlineCommentDraftState(true,
24
33
  // TODO: might need to update to reflect it's from media floating toolbar
25
34
  _analytics.INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
@@ -30,7 +39,7 @@ var commentButton = exports.commentButton = function commentButton(intl, _state,
30
39
  return {
31
40
  type: 'button',
32
41
  testId: 'add-comment-media-button',
33
- icon: _comment.default,
42
+ icon: hasActiveComments ? _commentWithDotIcon.CommentWithDotIcon : _comment.default,
34
43
  title: title,
35
44
  onClick: onClickHandler,
36
45
  tooltipContent: /*#__PURE__*/_react.default.createElement(_keymaps.ToolTipContent, {
@@ -0,0 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@atlaskit/icon';
4
+ import { Y300 } from '@atlaskit/theme/colors';
5
+ const IconCommentWithDotGlyph = () => {
6
+ return /*#__PURE__*/React.createElement("svg", {
7
+ width: "24",
8
+ height: "24",
9
+ viewBox: "0 0 24 24",
10
+ fill: "none",
11
+ xmlns: "http://www.w3.org/2000/svg"
12
+ }, /*#__PURE__*/React.createElement("path", {
13
+ fillRule: "evenodd",
14
+ clipRule: "evenodd",
15
+ d: "M4.998 11.513C4.998 8.475 8.139 6.003 12 6.003C15.861 6.003 19.002 8.475 19.002 11.513C19.002 14.552 15.861 17.023 12 17.023C8.139 17.023 4.998 14.552 4.998 11.513ZM19.838 19.284V19.282C19.838 19.282 18.274 17.022 19.071 16.166L19.034 16.186C20.261 14.902 21 13.279 21 11.513C21 7.371 16.963 4 12 4C7.037 4 3 7.37 3 11.513C3 15.656 7.037 19.027 12 19.027C13.42 19.027 14.76 18.742 15.957 18.251C16.96 19.273 18.244 19.823 19.197 19.97L19.199 19.967C19.2515 19.9867 19.3069 19.9979 19.363 20C19.448 20 19.5317 19.9789 19.6067 19.9386C19.6816 19.8984 19.7453 19.8402 19.7923 19.7693C19.8392 19.6984 19.8679 19.6169 19.8757 19.5323C19.8835 19.4476 19.8712 19.3623 19.838 19.284Z",
16
+ fill: "currentColor"
17
+ }), /*#__PURE__*/React.createElement("path", {
18
+ d: "M16 9H8C7.44772 9 7 9.44772 7 10C7 10.5523 7.44772 11 8 11H16C16.5523 11 17 10.5523 17 10C17 9.44772 16.5523 9 16 9Z",
19
+ fill: "currentColor"
20
+ }), /*#__PURE__*/React.createElement("path", {
21
+ d: "M11 12H8C7.44772 12 7 12.4477 7 13C7 13.5523 7.44772 14 8 14H11C11.5523 14 12 13.5523 12 13C12 12.4477 11.5523 12 11 12Z",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("rect", {
24
+ x: "14",
25
+ y: "2",
26
+ width: "8",
27
+ height: "8",
28
+ rx: "4",
29
+ fill: `var(--ds-background-warning-bold, ${Y300})`
30
+ }));
31
+ };
32
+ export const CommentWithDotIcon = props => {
33
+ return /*#__PURE__*/React.createElement(Icon, _extends({
34
+ glyph: IconCommentWithDotGlyph
35
+ }, props));
36
+ };
@@ -2,18 +2,25 @@ import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
4
4
  import { commentMessages as messages } from '@atlaskit/editor-common/media';
5
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
5
  import CommentIcon from '@atlaskit/icon/glyph/comment';
7
- export const commentButton = (intl, _state, api) => {
8
- const title = intl.formatMessage(messages.addCommentOnMedia);
6
+ import { CommentWithDotIcon } from './assets/commentWithDotIcon';
7
+ import { getSelectedMediaSingle } from './utils';
8
+ export const commentButton = (intl, state, api) => {
9
+ var _getSelectedMediaSing, _api$annotation, _api$annotation$share;
10
+ const selectMediaNode = (_getSelectedMediaSing = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.node.firstChild;
11
+ let hasActiveComments = false;
12
+ const annotations = api === null || api === void 0 ? void 0 : (_api$annotation = api.annotation) === null || _api$annotation === void 0 ? void 0 : (_api$annotation$share = _api$annotation.sharedState.currentState()) === null || _api$annotation$share === void 0 ? void 0 : _api$annotation$share.annotations;
13
+ if (selectMediaNode && annotations) {
14
+ hasActiveComments = selectMediaNode.marks.some(mark => mark.type.name === 'annotation' && !annotations[mark.attrs.id]);
15
+ }
16
+ const title = intl.formatMessage(hasActiveComments ? messages.viewCommentsOnMedia : messages.addCommentOnMedia);
9
17
  const onClickHandler = (state, dispatch) => {
10
- if (api !== null && api !== void 0 && api.annotation && state.selection instanceof NodeSelection) {
11
- const mediaNode = state.selection.node.firstChild;
18
+ if (api !== null && api !== void 0 && api.annotation && selectMediaNode) {
12
19
  const {
13
20
  showCommentForBlockNode,
14
21
  setInlineCommentDraftState
15
22
  } = api.annotation.actions;
16
- if (!showCommentForBlockNode(mediaNode)(state, dispatch)) {
23
+ if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
17
24
  setInlineCommentDraftState(true,
18
25
  // TODO: might need to update to reflect it's from media floating toolbar
19
26
  INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
@@ -24,7 +31,7 @@ export const commentButton = (intl, _state, api) => {
24
31
  return {
25
32
  type: 'button',
26
33
  testId: 'add-comment-media-button',
27
- icon: CommentIcon,
34
+ icon: hasActiveComments ? CommentWithDotIcon : CommentIcon,
28
35
  title,
29
36
  onClick: onClickHandler,
30
37
  tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
@@ -0,0 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import Icon from '@atlaskit/icon';
4
+ import { Y300 } from '@atlaskit/theme/colors';
5
+ var IconCommentWithDotGlyph = function IconCommentWithDotGlyph() {
6
+ return /*#__PURE__*/React.createElement("svg", {
7
+ width: "24",
8
+ height: "24",
9
+ viewBox: "0 0 24 24",
10
+ fill: "none",
11
+ xmlns: "http://www.w3.org/2000/svg"
12
+ }, /*#__PURE__*/React.createElement("path", {
13
+ fillRule: "evenodd",
14
+ clipRule: "evenodd",
15
+ d: "M4.998 11.513C4.998 8.475 8.139 6.003 12 6.003C15.861 6.003 19.002 8.475 19.002 11.513C19.002 14.552 15.861 17.023 12 17.023C8.139 17.023 4.998 14.552 4.998 11.513ZM19.838 19.284V19.282C19.838 19.282 18.274 17.022 19.071 16.166L19.034 16.186C20.261 14.902 21 13.279 21 11.513C21 7.371 16.963 4 12 4C7.037 4 3 7.37 3 11.513C3 15.656 7.037 19.027 12 19.027C13.42 19.027 14.76 18.742 15.957 18.251C16.96 19.273 18.244 19.823 19.197 19.97L19.199 19.967C19.2515 19.9867 19.3069 19.9979 19.363 20C19.448 20 19.5317 19.9789 19.6067 19.9386C19.6816 19.8984 19.7453 19.8402 19.7923 19.7693C19.8392 19.6984 19.8679 19.6169 19.8757 19.5323C19.8835 19.4476 19.8712 19.3623 19.838 19.284Z",
16
+ fill: "currentColor"
17
+ }), /*#__PURE__*/React.createElement("path", {
18
+ d: "M16 9H8C7.44772 9 7 9.44772 7 10C7 10.5523 7.44772 11 8 11H16C16.5523 11 17 10.5523 17 10C17 9.44772 16.5523 9 16 9Z",
19
+ fill: "currentColor"
20
+ }), /*#__PURE__*/React.createElement("path", {
21
+ d: "M11 12H8C7.44772 12 7 12.4477 7 13C7 13.5523 7.44772 14 8 14H11C11.5523 14 12 13.5523 12 13C12 12.4477 11.5523 12 11 12Z",
22
+ fill: "currentColor"
23
+ }), /*#__PURE__*/React.createElement("rect", {
24
+ x: "14",
25
+ y: "2",
26
+ width: "8",
27
+ height: "8",
28
+ rx: "4",
29
+ fill: "var(--ds-background-warning-bold, ".concat(Y300, ")")
30
+ }));
31
+ };
32
+ export var CommentWithDotIcon = function CommentWithDotIcon(props) {
33
+ return /*#__PURE__*/React.createElement(Icon, _extends({
34
+ glyph: IconCommentWithDotGlyph
35
+ }, props));
36
+ };
@@ -2,17 +2,26 @@ import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
3
  import { ToolTipContent } from '@atlaskit/editor-common/keymaps';
4
4
  import { commentMessages as messages } from '@atlaskit/editor-common/media';
5
- import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
6
5
  import CommentIcon from '@atlaskit/icon/glyph/comment';
7
- export var commentButton = function commentButton(intl, _state, api) {
8
- var title = intl.formatMessage(messages.addCommentOnMedia);
6
+ import { CommentWithDotIcon } from './assets/commentWithDotIcon';
7
+ import { getSelectedMediaSingle } from './utils';
8
+ export var commentButton = function commentButton(intl, state, api) {
9
+ var _getSelectedMediaSing, _api$annotation;
10
+ var selectMediaNode = (_getSelectedMediaSing = getSelectedMediaSingle(state)) === null || _getSelectedMediaSing === void 0 ? void 0 : _getSelectedMediaSing.node.firstChild;
11
+ var hasActiveComments = false;
12
+ var annotations = api === null || api === void 0 || (_api$annotation = api.annotation) === null || _api$annotation === void 0 || (_api$annotation = _api$annotation.sharedState.currentState()) === null || _api$annotation === void 0 ? void 0 : _api$annotation.annotations;
13
+ if (selectMediaNode && annotations) {
14
+ hasActiveComments = selectMediaNode.marks.some(function (mark) {
15
+ return mark.type.name === 'annotation' && !annotations[mark.attrs.id];
16
+ });
17
+ }
18
+ var title = intl.formatMessage(hasActiveComments ? messages.viewCommentsOnMedia : messages.addCommentOnMedia);
9
19
  var onClickHandler = function onClickHandler(state, dispatch) {
10
- if (api !== null && api !== void 0 && api.annotation && state.selection instanceof NodeSelection) {
11
- var mediaNode = state.selection.node.firstChild;
20
+ if (api !== null && api !== void 0 && api.annotation && selectMediaNode) {
12
21
  var _api$annotation$actio = api.annotation.actions,
13
22
  showCommentForBlockNode = _api$annotation$actio.showCommentForBlockNode,
14
23
  setInlineCommentDraftState = _api$annotation$actio.setInlineCommentDraftState;
15
- if (!showCommentForBlockNode(mediaNode)(state, dispatch)) {
24
+ if (!showCommentForBlockNode(selectMediaNode)(state, dispatch)) {
16
25
  setInlineCommentDraftState(true,
17
26
  // TODO: might need to update to reflect it's from media floating toolbar
18
27
  INPUT_METHOD.FLOATING_TB, 'block', true)(state, dispatch);
@@ -23,7 +32,7 @@ export var commentButton = function commentButton(intl, _state, api) {
23
32
  return {
24
33
  type: 'button',
25
34
  testId: 'add-comment-media-button',
26
- icon: CommentIcon,
35
+ icon: hasActiveComments ? CommentWithDotIcon : CommentIcon,
27
36
  title: title,
28
37
  onClick: onClickHandler,
29
38
  tooltipContent: /*#__PURE__*/React.createElement(ToolTipContent, {
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { GlyphProps } from '@atlaskit/icon/types';
3
+ export declare const CommentWithDotIcon: (props: GlyphProps) => JSX.Element;
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl-next';
2
2
  import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { MediaNextEditorPluginType } from '../next-plugin-type';
5
- export declare const commentButton: (intl: IntlShape, _state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
5
+ export declare const commentButton: (intl: IntlShape, state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { GlyphProps } from '@atlaskit/icon/types';
3
+ export declare const CommentWithDotIcon: (props: GlyphProps) => JSX.Element;
@@ -2,4 +2,4 @@ import type { IntlShape } from 'react-intl-next';
2
2
  import type { Command, ExtractInjectionAPI, FloatingToolbarButton } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { MediaNextEditorPluginType } from '../next-plugin-type';
5
- export declare const commentButton: (intl: IntlShape, _state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
5
+ export declare const commentButton: (intl: IntlShape, state: EditorState, api: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined) => FloatingToolbarButton<Command>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-media",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
4
4
  "description": "Media plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",