@atlaskit/editor-plugin-synced-block 4.0.0 → 4.0.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,13 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 4.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7e3353721fa66`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7e3353721fa66) -
8
+ [ux] EDITOR-1822 update sync blocks ui to new design
9
+ - Updated dependencies
10
+
3
11
  ## 4.0.0
4
12
 
5
13
  ### Major Changes
@@ -58,9 +58,24 @@
58
58
  {
59
59
  "path": "../../../design-system/icon/afm-cc/tsconfig.json"
60
60
  },
61
+ {
62
+ "path": "../../../design-system/logo/afm-cc/tsconfig.json"
63
+ },
64
+ {
65
+ "path": "../../../design-system/lozenge/afm-cc/tsconfig.json"
66
+ },
61
67
  {
62
68
  "path": "../../../design-system/modal-dialog/afm-cc/tsconfig.json"
63
69
  },
70
+ {
71
+ "path": "../../../design-system/primitives/afm-cc/tsconfig.json"
72
+ },
73
+ {
74
+ "path": "../../../design-system/tooltip/afm-cc/tsconfig.json"
75
+ },
76
+ {
77
+ "path": "../../../design-system/visually-hidden/afm-cc/tsconfig.json"
78
+ },
64
79
  {
65
80
  "path": "../../editor-common/afm-cc/tsconfig.json"
66
81
  }
@@ -58,9 +58,24 @@
58
58
  {
59
59
  "path": "../../../design-system/icon/afm-jira/tsconfig.json"
60
60
  },
61
+ {
62
+ "path": "../../../design-system/logo/afm-jira/tsconfig.json"
63
+ },
64
+ {
65
+ "path": "../../../design-system/lozenge/afm-jira/tsconfig.json"
66
+ },
61
67
  {
62
68
  "path": "../../../design-system/modal-dialog/afm-jira/tsconfig.json"
63
69
  },
70
+ {
71
+ "path": "../../../design-system/primitives/afm-jira/tsconfig.json"
72
+ },
73
+ {
74
+ "path": "../../../design-system/tooltip/afm-jira/tsconfig.json"
75
+ },
76
+ {
77
+ "path": "../../../design-system/visually-hidden/afm-jira/tsconfig.json"
78
+ },
64
79
  {
65
80
  "path": "../../editor-common/afm-jira/tsconfig.json"
66
81
  }
@@ -58,9 +58,24 @@
58
58
  {
59
59
  "path": "../../../design-system/icon/afm-products/tsconfig.json"
60
60
  },
61
+ {
62
+ "path": "../../../design-system/logo/afm-products/tsconfig.json"
63
+ },
64
+ {
65
+ "path": "../../../design-system/lozenge/afm-products/tsconfig.json"
66
+ },
61
67
  {
62
68
  "path": "../../../design-system/modal-dialog/afm-products/tsconfig.json"
63
69
  },
70
+ {
71
+ "path": "../../../design-system/primitives/afm-products/tsconfig.json"
72
+ },
73
+ {
74
+ "path": "../../../design-system/tooltip/afm-products/tsconfig.json"
75
+ },
76
+ {
77
+ "path": "../../../design-system/visually-hidden/afm-products/tsconfig.json"
78
+ },
64
79
  {
65
80
  "path": "../../editor-common/afm-products/tsconfig.json"
66
81
  }
@@ -50,10 +50,14 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
50
50
  // get document node from data provider
51
51
 
52
52
  return /*#__PURE__*/_react.default.createElement(_SyncBlockRendererWrapper.SyncBlockRendererWrapper, {
53
+ localId: this.node.attrs.localId,
53
54
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer,
54
55
  syncBlockRendererDataProviders: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncBlockRendererDataProviders,
55
56
  useFetchSyncBlockData: function useFetchSyncBlockData() {
56
57
  return (0, _editorSyncedBlockProvider.useFetchSyncBlockData)(_this2.syncBlockStore, _this2.node);
58
+ },
59
+ useFetchSyncBlockTitle: function useFetchSyncBlockTitle() {
60
+ return (0, _editorSyncedBlockProvider.useFetchSyncBlockTitle)(_this2.syncBlockStore, _this2.node);
57
61
  }
58
62
  });
59
63
  }
@@ -13,8 +13,11 @@ var BodiedSyncBlockWrapper = exports.BodiedSyncBlockWrapper = /*#__PURE__*/_reac
13
13
  syncBlockStore = _ref.syncBlockStore;
14
14
  // TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
15
15
  (0, _editorSyncedBlockProvider.useHandleContentChanges)(syncBlockStore, node);
16
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, null), /*#__PURE__*/_react.default.createElement("div", {
16
+ return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
17
17
  "data-testid": "bodied-sync-block-wrapper",
18
18
  ref: ref
19
+ }), /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
20
+ isSource: true,
21
+ localId: node.attrs.localId
19
22
  }));
20
23
  });
@@ -9,6 +9,8 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _editorToolbar = require("@atlaskit/editor-toolbar");
12
+ var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
13
+ var _compiled = require("@atlaskit/primitives/compiled");
12
14
  var _utils = require("../pm-plugins/utils/utils");
13
15
  var CreateSyncedBlockDropdownItem = exports.CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
14
16
  var _api$selection;
@@ -42,5 +44,10 @@ var CreateSyncedBlockDropdownItem = exports.CreateSyncedBlockDropdownItem = func
42
44
  label: ""
43
45
  }),
44
46
  onClick: onClick
45
- }, selection !== null && selection !== void 0 && selection.empty ? formatMessage(_messages.blockMenuMessages.createSyncedBlock) : formatMessage(_messages.blockMenuMessages.convertToSyncedBlock));
47
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Flex, {
48
+ alignItems: "center",
49
+ gap: "space.050"
50
+ }, /*#__PURE__*/_react.default.createElement(_compiled.Text, null, selection !== null && selection !== void 0 && selection.empty ? formatMessage(_messages.blockMenuMessages.createSyncedBlock) : formatMessage(_messages.blockMenuMessages.convertToSyncedBlock)), /*#__PURE__*/_react.default.createElement(_lozenge.default, {
51
+ appearance: "new"
52
+ }, formatMessage(_messages.blockMenuMessages.newLozenge))));
46
53
  };
@@ -9,15 +9,47 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _messages = require("@atlaskit/editor-common/messages");
11
11
  var _syncBlock = require("@atlaskit/editor-common/sync-block");
12
+ var _logo = require("@atlaskit/logo");
13
+ var _compiled = require("@atlaskit/primitives/compiled");
14
+ var _tooltip = _interopRequireDefault(require("@atlaskit/tooltip"));
15
+ var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
12
16
  var SyncBlockLabelDataId = 'sync-block-label';
13
- var SyncBlockLabelComponent = function SyncBlockLabelComponent() {
17
+ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
18
+ var isSource = _ref.isSource,
19
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
20
+ localId = _ref.localId;
14
21
  var _useIntl = (0, _reactIntlNext.useIntl)(),
15
22
  formatMessage = _useIntl.formatMessage;
16
- return /*#__PURE__*/_react.default.createElement("div", {
23
+ var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
24
+ var tooltipContent = isSource ? formatMessage(_messages.syncBlockMessages.sourceSyncBlockTooltip) : title ? formatMessage(_messages.syncBlockMessages.referenceSyncBlockTooltip, {
25
+ title: title
26
+ }) : formatMessage(_messages.syncBlockMessages.defaultSyncBlockTooltip);
27
+ var ariaDescribedById = "sync-block-label-description-".concat(localId);
28
+ return /*#__PURE__*/_react.default.createElement(_tooltip.default, {
29
+ position: "top",
30
+ content: tooltipContent
31
+ // workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
32
+ // this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
33
+ // tooltip content is available for screen readers in visually hidden content after the label
34
+ ,
35
+ isScreenReaderAnnouncementDisabled: true
36
+ }, /*#__PURE__*/_react.default.createElement("div", {
17
37
  "data-testid": SyncBlockLabelDataId
18
38
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
19
39
  ,
20
- className: _syncBlock.SyncBlockLabelSharedCssClassName.labelClassName
21
- }, formatMessage(_messages.syncBlockMessages.syncedBlockLabel));
40
+ className: _syncBlock.SyncBlockLabelSharedCssClassName.labelClassName,
41
+ "aria-describedby": ariaDescribedById
42
+ }, /*#__PURE__*/_react.default.createElement(_logo.ConfluenceIcon, {
43
+ size: "xsmall",
44
+ appearance: "neutral",
45
+ shouldUseNewLogoDesign: true
46
+ }), isSource || !title ? /*#__PURE__*/_react.default.createElement(_compiled.Text, {
47
+ size: "small"
48
+ }, formatMessage(_messages.syncBlockMessages.syncedBlockLabel)) : /*#__PURE__*/_react.default.createElement(_compiled.Text, {
49
+ maxLines: 1,
50
+ size: "small"
51
+ }, title)), /*#__PURE__*/_react.default.createElement(_visuallyHidden.default, {
52
+ id: ariaDescribedById
53
+ }, tooltipContent));
22
54
  };
23
55
  var SyncBlockLabel = exports.SyncBlockLabel = /*#__PURE__*/_react.default.memo(SyncBlockLabelComponent);
@@ -12,8 +12,10 @@ var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
12
12
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
13
13
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
14
14
  useFetchSyncBlockData = _ref.useFetchSyncBlockData,
15
- syncBlockRendererDataProviders = _ref.syncBlockRendererDataProviders;
16
- return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, null), /*#__PURE__*/_react.default.createElement("div", {
15
+ syncBlockRendererDataProviders = _ref.syncBlockRendererDataProviders,
16
+ localId = _ref.localId,
17
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle;
18
+ return /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
17
19
  "data-testid": SyncBlockRendererWrapperDataId
18
20
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
19
21
  ,
@@ -21,6 +23,10 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
21
23
  }, getSyncedBlockRenderer({
22
24
  syncBlockRendererDataProviders: syncBlockRendererDataProviders,
23
25
  useFetchSyncBlockData: useFetchSyncBlockData
24
- })));
26
+ })), /*#__PURE__*/_react.default.createElement(_SyncBlockLabel.SyncBlockLabel, {
27
+ isSource: false,
28
+ useFetchSyncBlockTitle: useFetchSyncBlockTitle,
29
+ localId: localId
30
+ }));
25
31
  };
26
32
  var SyncBlockRendererWrapper = exports.SyncBlockRendererWrapper = /*#__PURE__*/_react.default.memo(SyncBlockRendererWrapperComponent);
@@ -45,7 +45,7 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
45
45
  appearance: 'subtle',
46
46
  icon: _copy.default,
47
47
  title: formatMessage(_messages.syncBlockMessages.copySyncBlockLabel),
48
- showTitle: true,
48
+ showTitle: false,
49
49
  tooltipContent: formatMessage(_messages.syncBlockMessages.copySyncBlockTooltip),
50
50
  onClick: (0, _editorCommands.copySyncedBlockReferenceToClipboard)(api)
51
51
  }, hoverDecorationProps(nodeType, _consts.akEditorSelectedNodeClassName));
@@ -70,9 +70,6 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
70
70
  // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
71
71
  var testId = 'synced-block-overflow-dropdown-trigger';
72
72
  var overflowMenuConfig = [{
73
- type: 'separator',
74
- fullHeight: true
75
- }, {
76
73
  type: 'overflow-dropdown',
77
74
  testId: testId,
78
75
  options: [_objectSpread({
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
3
3
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
4
- import { useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
4
+ import { useFetchSyncBlockData, useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
5
5
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
6
6
  class SyncBlock extends ReactNodeView {
7
7
  constructor(props) {
@@ -23,9 +23,11 @@ class SyncBlock extends ReactNodeView {
23
23
  // get document node from data provider
24
24
 
25
25
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
26
+ localId: this.node.attrs.localId,
26
27
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer,
27
28
  syncBlockRendererDataProviders: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncBlockRendererDataProviders,
28
- useFetchSyncBlockData: () => useFetchSyncBlockData(this.syncBlockStore, this.node)
29
+ useFetchSyncBlockData: () => useFetchSyncBlockData(this.syncBlockStore, this.node),
30
+ useFetchSyncBlockTitle: () => useFetchSyncBlockTitle(this.syncBlockStore, this.node)
29
31
  });
30
32
  }
31
33
  destroy() {
@@ -7,8 +7,11 @@ export const BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(({
7
7
  }, ref) => {
8
8
  // TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
9
9
  useHandleContentChanges(syncBlockStore, node);
10
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
10
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
11
11
  "data-testid": "bodied-sync-block-wrapper",
12
12
  ref: ref
13
+ }), /*#__PURE__*/React.createElement(SyncBlockLabel, {
14
+ isSource: true,
15
+ localId: node.attrs.localId
13
16
  }));
14
17
  });
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
4
4
  import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
+ import Lozenge from '@atlaskit/lozenge';
6
+ import { Flex, Text } from '@atlaskit/primitives/compiled';
5
7
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
6
8
  export const CreateSyncedBlockDropdownItem = ({
7
9
  api
@@ -38,5 +40,10 @@ export const CreateSyncedBlockDropdownItem = ({
38
40
  label: ""
39
41
  }),
40
42
  onClick: onClick
41
- }, selection !== null && selection !== void 0 && selection.empty ? formatMessage(blockMenuMessages.createSyncedBlock) : formatMessage(blockMenuMessages.convertToSyncedBlock));
43
+ }, /*#__PURE__*/React.createElement(Flex, {
44
+ alignItems: "center",
45
+ gap: "space.050"
46
+ }, /*#__PURE__*/React.createElement(Text, null, selection !== null && selection !== void 0 && selection.empty ? formatMessage(blockMenuMessages.createSyncedBlock) : formatMessage(blockMenuMessages.convertToSyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
47
+ appearance: "new"
48
+ }, formatMessage(blockMenuMessages.newLozenge))));
42
49
  };
@@ -2,16 +2,49 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
5
+ import { ConfluenceIcon } from '@atlaskit/logo';
6
+ import { Text } from '@atlaskit/primitives/compiled';
7
+ import Tooltip from '@atlaskit/tooltip';
8
+ import VisuallyHidden from '@atlaskit/visually-hidden';
5
9
  const SyncBlockLabelDataId = 'sync-block-label';
6
- const SyncBlockLabelComponent = () => {
10
+ const SyncBlockLabelComponent = ({
11
+ isSource,
12
+ useFetchSyncBlockTitle,
13
+ localId
14
+ }) => {
7
15
  const {
8
16
  formatMessage
9
17
  } = useIntl();
10
- return /*#__PURE__*/React.createElement("div", {
18
+ const title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
19
+ const tooltipContent = isSource ? formatMessage(messages.sourceSyncBlockTooltip) : title ? formatMessage(messages.referenceSyncBlockTooltip, {
20
+ title
21
+ }) : formatMessage(messages.defaultSyncBlockTooltip);
22
+ const ariaDescribedById = `sync-block-label-description-${localId}`;
23
+ return /*#__PURE__*/React.createElement(Tooltip, {
24
+ position: "top",
25
+ content: tooltipContent
26
+ // workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
27
+ // this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
28
+ // tooltip content is available for screen readers in visually hidden content after the label
29
+ ,
30
+ isScreenReaderAnnouncementDisabled: true
31
+ }, /*#__PURE__*/React.createElement("div", {
11
32
  "data-testid": SyncBlockLabelDataId
12
33
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
13
34
  ,
14
- className: SyncBlockLabelSharedCssClassName.labelClassName
15
- }, formatMessage(messages.syncedBlockLabel));
35
+ className: SyncBlockLabelSharedCssClassName.labelClassName,
36
+ "aria-describedby": ariaDescribedById
37
+ }, /*#__PURE__*/React.createElement(ConfluenceIcon, {
38
+ size: "xsmall",
39
+ appearance: "neutral",
40
+ shouldUseNewLogoDesign: true
41
+ }), isSource || !title ? /*#__PURE__*/React.createElement(Text, {
42
+ size: "small"
43
+ }, formatMessage(messages.syncedBlockLabel)) : /*#__PURE__*/React.createElement(Text, {
44
+ maxLines: 1,
45
+ size: "small"
46
+ }, title)), /*#__PURE__*/React.createElement(VisuallyHidden, {
47
+ id: ariaDescribedById
48
+ }, tooltipContent));
16
49
  };
17
50
  export const SyncBlockLabel = /*#__PURE__*/React.memo(SyncBlockLabelComponent);
@@ -5,9 +5,11 @@ const SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
5
5
  const SyncBlockRendererWrapperComponent = ({
6
6
  getSyncedBlockRenderer,
7
7
  useFetchSyncBlockData,
8
- syncBlockRendererDataProviders
8
+ syncBlockRendererDataProviders,
9
+ localId,
10
+ useFetchSyncBlockTitle
9
11
  }) => {
10
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
12
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
11
13
  "data-testid": SyncBlockRendererWrapperDataId
12
14
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
13
15
  ,
@@ -15,6 +17,10 @@ const SyncBlockRendererWrapperComponent = ({
15
17
  }, getSyncedBlockRenderer({
16
18
  syncBlockRendererDataProviders,
17
19
  useFetchSyncBlockData
18
- })));
20
+ })), /*#__PURE__*/React.createElement(SyncBlockLabel, {
21
+ isSource: false,
22
+ useFetchSyncBlockTitle: useFetchSyncBlockTitle,
23
+ localId: localId
24
+ }));
19
25
  };
20
26
  export const SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
@@ -39,7 +39,7 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
39
39
  appearance: 'subtle',
40
40
  icon: CopyIcon,
41
41
  title: formatMessage(messages.copySyncBlockLabel),
42
- showTitle: true,
42
+ showTitle: false,
43
43
  tooltipContent: formatMessage(messages.copySyncBlockTooltip),
44
44
  onClick: copySyncedBlockReferenceToClipboard(api),
45
45
  ...hoverDecorationProps(nodeType, akEditorSelectedNodeClassName)
@@ -66,9 +66,6 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore) => {
66
66
  // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
67
67
  const testId = 'synced-block-overflow-dropdown-trigger';
68
68
  const overflowMenuConfig = [{
69
- type: 'separator',
70
- fullHeight: true
71
- }, {
72
69
  type: 'overflow-dropdown',
73
70
  testId,
74
71
  options: [{
@@ -10,7 +10,7 @@ function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prot
10
10
  import React from 'react';
11
11
  import ReactNodeView from '@atlaskit/editor-common/react-node-view';
12
12
  import { SyncBlockSharedCssClassName } from '@atlaskit/editor-common/sync-block';
13
- import { useFetchSyncBlockData as _useFetchSyncBlockData } from '@atlaskit/editor-synced-block-provider';
13
+ import { useFetchSyncBlockData as _useFetchSyncBlockData, useFetchSyncBlockTitle as _useFetchSyncBlockTitle } from '@atlaskit/editor-synced-block-provider';
14
14
  import { SyncBlockRendererWrapper } from '../ui/SyncBlockRendererWrapper';
15
15
  var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
16
16
  function SyncBlock(props) {
@@ -43,10 +43,14 @@ var SyncBlock = /*#__PURE__*/function (_ReactNodeView) {
43
43
  // get document node from data provider
44
44
 
45
45
  return /*#__PURE__*/React.createElement(SyncBlockRendererWrapper, {
46
+ localId: this.node.attrs.localId,
46
47
  getSyncedBlockRenderer: (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.getSyncedBlockRenderer,
47
48
  syncBlockRendererDataProviders: (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.syncBlockRendererDataProviders,
48
49
  useFetchSyncBlockData: function useFetchSyncBlockData() {
49
50
  return _useFetchSyncBlockData(_this2.syncBlockStore, _this2.node);
51
+ },
52
+ useFetchSyncBlockTitle: function useFetchSyncBlockTitle() {
53
+ return _useFetchSyncBlockTitle(_this2.syncBlockStore, _this2.node);
50
54
  }
51
55
  });
52
56
  }
@@ -6,8 +6,11 @@ export var BodiedSyncBlockWrapper = /*#__PURE__*/React.forwardRef(function (_ref
6
6
  syncBlockStore = _ref.syncBlockStore;
7
7
  // TODO: EDITOR-2429 - this should be debounced (either here or in the data provider) to avoid excessive API writes
8
8
  useHandleContentChanges(syncBlockStore, node);
9
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
9
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
10
10
  "data-testid": "bodied-sync-block-wrapper",
11
11
  ref: ref
12
+ }), /*#__PURE__*/React.createElement(SyncBlockLabel, {
13
+ isSource: true,
14
+ localId: node.attrs.localId
12
15
  }));
13
16
  });
@@ -2,6 +2,8 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { blockMenuMessages } from '@atlaskit/editor-common/messages';
4
4
  import { SyncBlocksIcon, ToolbarDropdownItem } from '@atlaskit/editor-toolbar';
5
+ import Lozenge from '@atlaskit/lozenge';
6
+ import { Flex, Text } from '@atlaskit/primitives/compiled';
5
7
  import { canBeConvertedToSyncBlock } from '../pm-plugins/utils/utils';
6
8
  export var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownItem(_ref) {
7
9
  var _api$selection;
@@ -35,5 +37,10 @@ export var CreateSyncedBlockDropdownItem = function CreateSyncedBlockDropdownIte
35
37
  label: ""
36
38
  }),
37
39
  onClick: onClick
38
- }, selection !== null && selection !== void 0 && selection.empty ? formatMessage(blockMenuMessages.createSyncedBlock) : formatMessage(blockMenuMessages.convertToSyncedBlock));
40
+ }, /*#__PURE__*/React.createElement(Flex, {
41
+ alignItems: "center",
42
+ gap: "space.050"
43
+ }, /*#__PURE__*/React.createElement(Text, null, selection !== null && selection !== void 0 && selection.empty ? formatMessage(blockMenuMessages.createSyncedBlock) : formatMessage(blockMenuMessages.convertToSyncedBlock)), /*#__PURE__*/React.createElement(Lozenge, {
44
+ appearance: "new"
45
+ }, formatMessage(blockMenuMessages.newLozenge))));
39
46
  };
@@ -2,15 +2,47 @@ import React from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
4
4
  import { SyncBlockLabelSharedCssClassName } from '@atlaskit/editor-common/sync-block';
5
+ import { ConfluenceIcon } from '@atlaskit/logo';
6
+ import { Text } from '@atlaskit/primitives/compiled';
7
+ import Tooltip from '@atlaskit/tooltip';
8
+ import VisuallyHidden from '@atlaskit/visually-hidden';
5
9
  var SyncBlockLabelDataId = 'sync-block-label';
6
- var SyncBlockLabelComponent = function SyncBlockLabelComponent() {
10
+ var SyncBlockLabelComponent = function SyncBlockLabelComponent(_ref) {
11
+ var isSource = _ref.isSource,
12
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle,
13
+ localId = _ref.localId;
7
14
  var _useIntl = useIntl(),
8
15
  formatMessage = _useIntl.formatMessage;
9
- return /*#__PURE__*/React.createElement("div", {
16
+ var title = useFetchSyncBlockTitle === null || useFetchSyncBlockTitle === void 0 ? void 0 : useFetchSyncBlockTitle();
17
+ var tooltipContent = isSource ? formatMessage(messages.sourceSyncBlockTooltip) : title ? formatMessage(messages.referenceSyncBlockTooltip, {
18
+ title: title
19
+ }) : formatMessage(messages.defaultSyncBlockTooltip);
20
+ var ariaDescribedById = "sync-block-label-description-".concat(localId);
21
+ return /*#__PURE__*/React.createElement(Tooltip, {
22
+ position: "top",
23
+ content: tooltipContent
24
+ // workaround because tooltip adds aria-describedby with a new id every time the tooltip is opened
25
+ // this causes an infinite rerender loop because of the forwardRef from the node view we are inside in bodiedSyncBlock
26
+ // tooltip content is available for screen readers in visually hidden content after the label
27
+ ,
28
+ isScreenReaderAnnouncementDisabled: true
29
+ }, /*#__PURE__*/React.createElement("div", {
10
30
  "data-testid": SyncBlockLabelDataId
11
31
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
12
32
  ,
13
- className: SyncBlockLabelSharedCssClassName.labelClassName
14
- }, formatMessage(messages.syncedBlockLabel));
33
+ className: SyncBlockLabelSharedCssClassName.labelClassName,
34
+ "aria-describedby": ariaDescribedById
35
+ }, /*#__PURE__*/React.createElement(ConfluenceIcon, {
36
+ size: "xsmall",
37
+ appearance: "neutral",
38
+ shouldUseNewLogoDesign: true
39
+ }), isSource || !title ? /*#__PURE__*/React.createElement(Text, {
40
+ size: "small"
41
+ }, formatMessage(messages.syncedBlockLabel)) : /*#__PURE__*/React.createElement(Text, {
42
+ maxLines: 1,
43
+ size: "small"
44
+ }, title)), /*#__PURE__*/React.createElement(VisuallyHidden, {
45
+ id: ariaDescribedById
46
+ }, tooltipContent));
15
47
  };
16
48
  export var SyncBlockLabel = /*#__PURE__*/React.memo(SyncBlockLabelComponent);
@@ -5,8 +5,10 @@ var SyncBlockRendererWrapperDataId = 'sync-block-plugin-renderer-wrapper';
5
5
  var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperComponent(_ref) {
6
6
  var getSyncedBlockRenderer = _ref.getSyncedBlockRenderer,
7
7
  useFetchSyncBlockData = _ref.useFetchSyncBlockData,
8
- syncBlockRendererDataProviders = _ref.syncBlockRendererDataProviders;
9
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(SyncBlockLabel, null), /*#__PURE__*/React.createElement("div", {
8
+ syncBlockRendererDataProviders = _ref.syncBlockRendererDataProviders,
9
+ localId = _ref.localId,
10
+ useFetchSyncBlockTitle = _ref.useFetchSyncBlockTitle;
11
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
10
12
  "data-testid": SyncBlockRendererWrapperDataId
11
13
  // eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
12
14
  ,
@@ -14,6 +16,10 @@ var SyncBlockRendererWrapperComponent = function SyncBlockRendererWrapperCompone
14
16
  }, getSyncedBlockRenderer({
15
17
  syncBlockRendererDataProviders: syncBlockRendererDataProviders,
16
18
  useFetchSyncBlockData: useFetchSyncBlockData
17
- })));
19
+ })), /*#__PURE__*/React.createElement(SyncBlockLabel, {
20
+ isSource: false,
21
+ useFetchSyncBlockTitle: useFetchSyncBlockTitle,
22
+ localId: localId
23
+ }));
18
24
  };
19
25
  export var SyncBlockRendererWrapper = /*#__PURE__*/React.memo(SyncBlockRendererWrapperComponent);
@@ -36,7 +36,7 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
36
36
  appearance: 'subtle',
37
37
  icon: CopyIcon,
38
38
  title: formatMessage(messages.copySyncBlockLabel),
39
- showTitle: true,
39
+ showTitle: false,
40
40
  tooltipContent: formatMessage(messages.copySyncBlockTooltip),
41
41
  onClick: copySyncedBlockReferenceToClipboard(api)
42
42
  }, hoverDecorationProps(nodeType, akEditorSelectedNodeClassName));
@@ -61,9 +61,6 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
61
61
  // see hideOnEsc in platform/packages/editor/editor-plugin-floating-toolbar/src/ui/Dropdown.tsx
62
62
  var testId = 'synced-block-overflow-dropdown-trigger';
63
63
  var overflowMenuConfig = [{
64
- type: 'separator',
65
- fullHeight: true
66
- }, {
67
64
  type: 'overflow-dropdown',
68
65
  testId: testId,
69
66
  options: [_objectSpread({
@@ -1,2 +1,8 @@
1
1
  import React from 'react';
2
- export declare const SyncBlockLabel: React.MemoExoticComponent<() => React.JSX.Element>;
2
+ type SyncBlockLabelProps = {
3
+ isSource: boolean;
4
+ localId: string;
5
+ useFetchSyncBlockTitle?: () => string | undefined;
6
+ };
7
+ export declare const SyncBlockLabel: React.MemoExoticComponent<({ isSource, useFetchSyncBlockTitle, localId }: SyncBlockLabelProps) => React.JSX.Element>;
8
+ export {};
@@ -4,8 +4,10 @@ import type { SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
5
5
  type Props = {
6
6
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
7
+ localId: string;
7
8
  syncBlockRendererDataProviders: SyncedBlockRendererDataProviders;
8
9
  useFetchSyncBlockData: () => SyncBlockInstance | null;
10
+ useFetchSyncBlockTitle: () => string | undefined;
9
11
  };
10
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, syncBlockRendererDataProviders, }: Props) => React.JSX.Element>;
12
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, syncBlockRendererDataProviders, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
11
13
  export {};
@@ -1,2 +1,8 @@
1
1
  import React from 'react';
2
- export declare const SyncBlockLabel: React.MemoExoticComponent<() => React.JSX.Element>;
2
+ type SyncBlockLabelProps = {
3
+ isSource: boolean;
4
+ localId: string;
5
+ useFetchSyncBlockTitle?: () => string | undefined;
6
+ };
7
+ export declare const SyncBlockLabel: React.MemoExoticComponent<({ isSource, useFetchSyncBlockTitle, localId }: SyncBlockLabelProps) => React.JSX.Element>;
8
+ export {};
@@ -4,8 +4,10 @@ import type { SyncBlockInstance } from '@atlaskit/editor-synced-block-provider';
4
4
  import type { SyncedBlockRendererProps } from '../syncedBlockPluginType';
5
5
  type Props = {
6
6
  getSyncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
7
+ localId: string;
7
8
  syncBlockRendererDataProviders: SyncedBlockRendererDataProviders;
8
9
  useFetchSyncBlockData: () => SyncBlockInstance | null;
10
+ useFetchSyncBlockTitle: () => string | undefined;
9
11
  };
10
- export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, syncBlockRendererDataProviders, }: Props) => React.JSX.Element>;
12
+ export declare const SyncBlockRendererWrapper: React.MemoExoticComponent<({ getSyncedBlockRenderer, useFetchSyncBlockData, syncBlockRendererDataProviders, localId, useFetchSyncBlockTitle, }: Props) => React.JSX.Element>;
11
13
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,12 @@
42
42
  "@atlaskit/editor-tables": "^2.9.0",
43
43
  "@atlaskit/editor-toolbar": "^0.17.0",
44
44
  "@atlaskit/icon": "28.5.3",
45
+ "@atlaskit/logo": "^19.9.0",
46
+ "@atlaskit/lozenge": "^13.0.0",
45
47
  "@atlaskit/modal-dialog": "^14.6.0",
48
+ "@atlaskit/primitives": "^16.1.0",
49
+ "@atlaskit/tooltip": "^20.7.0",
50
+ "@atlaskit/visually-hidden": "^3.0.0",
46
51
  "@babel/runtime": "^7.0.0",
47
52
  "react-intl-next": "npm:react-intl@^5.18.1"
48
53
  },