@atlaskit/editor-plugin-synced-block 10.3.8 → 10.4.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 CHANGED
@@ -1,5 +1,22 @@
1
1
  # @atlaskit/editor-plugin-synced-block
2
2
 
3
+ ## 10.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`b0cecd4d5b970`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b0cecd4d5b970) -
8
+ Add a product feedback trigger to synced block overflow actions.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
14
+ ## 10.3.9
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+
3
20
  ## 10.3.8
4
21
 
5
22
  ### Patch Changes
@@ -147,7 +147,7 @@ var syncedBlockPlugin = exports.syncedBlockPlugin = function syncedBlockPlugin(_
147
147
  if (!((_syncedBlockPluginKey = _main.syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
148
148
  return undefined;
149
149
  }
150
- return (0, _floatingToolbar.getToolbarConfig)(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
150
+ return (0, _floatingToolbar.getToolbarConfig)(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
151
151
  }
152
152
  },
153
153
  contentComponent: function contentComponent(_ref4) {
@@ -6,10 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.getToolbarConfig = void 0;
9
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _react = _interopRequireDefault(require("react"));
11
12
  var _analytics = require("@atlaskit/editor-common/analytics");
12
13
  var _messages = _interopRequireWildcard(require("@atlaskit/editor-common/messages"));
14
+ var _selection = require("@atlaskit/editor-common/selection");
13
15
  var _ui = require("@atlaskit/editor-common/ui");
14
16
  var _utils = require("@atlaskit/editor-prosemirror/utils");
15
17
  var _consts = require("@atlaskit/editor-shared-styles/consts");
@@ -18,6 +20,7 @@ var _copy = _interopRequireDefault(require("@atlaskit/icon/core/copy"));
18
20
  var _delete = _interopRequireDefault(require("@atlaskit/icon/core/delete"));
19
21
  var _edit = _interopRequireDefault(require("@atlaskit/icon/core/edit"));
20
22
  var _linkBroken = _interopRequireDefault(require("@atlaskit/icon/core/link-broken"));
23
+ var _megaphone = _interopRequireDefault(require("@atlaskit/icon/core/megaphone"));
21
24
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
22
25
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
26
  var _editorCommands = require("../editor-commands");
@@ -27,7 +30,7 @@ var _SyncedLocationDropdown = require("./SyncedLocationDropdown");
27
30
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
28
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; }
29
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; }
30
- var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage) {
33
+ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage, onGiveFeedback) {
31
34
  var _syncBlockInstance$er, _api$decorations, _api$connectivity;
32
35
  var syncBlockObject = (0, _utils2.findSyncBlockOrBodiedSyncBlock)(state.schema, state.selection);
33
36
  if (!syncBlockObject) {
@@ -171,14 +174,29 @@ var getToolbarConfig = exports.getToolbarConfig = function getToolbarConfig(stat
171
174
  var overflowMenuConfig = [{
172
175
  type: 'overflow-dropdown',
173
176
  testId: testId,
174
- options: [_objectSpread({
177
+ options: [].concat((0, _toConsumableArray2.default)(isSyncBlockActivationEnabled && onGiveFeedback ? [{
178
+ title: formatMessage(_messages.toolbarInsertBlockMessages.feedbackDialog),
179
+ icon: /*#__PURE__*/_react.default.createElement(_megaphone.default, {
180
+ label: ""
181
+ }),
182
+ onClick: function onClick() {
183
+ api === null || api === void 0 || api.core.actions.execute(function (_ref) {
184
+ var tr = _ref.tr;
185
+ return tr.setSelection(new _selection.GapCursorSelection(tr.doc.resolve(syncBlockObject.pos + syncBlockObject.node.nodeSize), _selection.Side.RIGHT));
186
+ });
187
+ onGiveFeedback({
188
+ blockType: isBodiedSyncBlock ? 'source' : 'reference'
189
+ });
190
+ return true;
191
+ }
192
+ }] : []), [_objectSpread({
175
193
  title: formatMessage(_messages.default.delete),
176
194
  onClick: (0, _editorCommands.removeSyncedBlock)(api),
177
195
  icon: /*#__PURE__*/_react.default.createElement(_delete.default, {
178
196
  label: ""
179
197
  }),
180
198
  testId: isBodiedSyncBlock ? _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSourceDelete : _types.SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete
181
- }, hoverDecorationProps(nodeType))]
199
+ }, hoverDecorationProps(nodeType))])
182
200
  }];
183
201
  items.push.apply(items, overflowMenuConfig);
184
202
  }
@@ -136,7 +136,7 @@ export const syncedBlockPlugin = ({
136
136
  if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
137
137
  return undefined;
138
138
  }
139
- return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
139
+ return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
140
140
  }
141
141
  },
142
142
  contentComponent: ({
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
3
- import commonMessages, { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
3
+ import commonMessages, { syncBlockMessages as messages, toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
4
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
4
5
  import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
5
6
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
6
7
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/consts';
@@ -9,13 +10,14 @@ import CopyIcon from '@atlaskit/icon/core/copy';
9
10
  import DeleteIcon from '@atlaskit/icon/core/delete';
10
11
  import EditIcon from '@atlaskit/icon/core/edit';
11
12
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
13
+ import MegaphoneIcon from '@atlaskit/icon/core/megaphone';
12
14
  import { fg } from '@atlaskit/platform-feature-flags';
13
15
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
14
16
  import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock, unsync } from '../editor-commands';
15
17
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
16
18
  import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
17
19
  import { SyncedLocationDropdown } from './SyncedLocationDropdown';
18
- export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage) => {
20
+ export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage, onGiveFeedback) => {
19
21
  var _syncBlockInstance$er, _api$decorations, _api$connectivity, _api$connectivity$sha;
20
22
  const syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
21
23
  if (!syncBlockObject) {
@@ -168,7 +170,21 @@ export const getToolbarConfig = (state, intl, api, syncBlockStore, isLivePage) =
168
170
  const overflowMenuConfig = [{
169
171
  type: 'overflow-dropdown',
170
172
  testId,
171
- options: [{
173
+ options: [...(isSyncBlockActivationEnabled && onGiveFeedback ? [{
174
+ title: formatMessage(toolbarInsertBlockMessages.feedbackDialog),
175
+ icon: /*#__PURE__*/React.createElement(MegaphoneIcon, {
176
+ label: ""
177
+ }),
178
+ onClick: () => {
179
+ api === null || api === void 0 ? void 0 : api.core.actions.execute(({
180
+ tr
181
+ }) => tr.setSelection(new GapCursorSelection(tr.doc.resolve(syncBlockObject.pos + syncBlockObject.node.nodeSize), Side.RIGHT)));
182
+ onGiveFeedback({
183
+ blockType: isBodiedSyncBlock ? 'source' : 'reference'
184
+ });
185
+ return true;
186
+ }
187
+ }] : []), {
172
188
  title: formatMessage(commonMessages.delete),
173
189
  onClick: removeSyncedBlock(api),
174
190
  icon: /*#__PURE__*/React.createElement(DeleteIcon, {
@@ -141,7 +141,7 @@ export var syncedBlockPlugin = function syncedBlockPlugin(_ref2) {
141
141
  if (!((_syncedBlockPluginKey = syncedBlockPluginKey.getState(state)) !== null && _syncedBlockPluginKey !== void 0 && _syncedBlockPluginKey.hasSyncedBlocks) && isPerfExperimentOn) {
142
142
  return undefined;
143
143
  }
144
- return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage);
144
+ return getToolbarConfig(state, intl, api, syncBlockStore, config === null || config === void 0 ? void 0 : config.__livePage, config === null || config === void 0 ? void 0 : config.onGiveFeedback);
145
145
  }
146
146
  },
147
147
  contentComponent: function contentComponent(_ref4) {
@@ -1,9 +1,11 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  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; }
3
4
  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) { _defineProperty(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; }
4
5
  import React from 'react';
5
6
  import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
6
- import commonMessages, { syncBlockMessages as messages } from '@atlaskit/editor-common/messages';
7
+ import commonMessages, { syncBlockMessages as messages, toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages';
8
+ import { GapCursorSelection, Side } from '@atlaskit/editor-common/selection';
7
9
  import { FloatingToolbarButton as Button } from '@atlaskit/editor-common/ui';
8
10
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
11
  import { akEditorSelectedNodeClassName } from '@atlaskit/editor-shared-styles/consts';
@@ -12,13 +14,14 @@ import CopyIcon from '@atlaskit/icon/core/copy';
12
14
  import DeleteIcon from '@atlaskit/icon/core/delete';
13
15
  import EditIcon from '@atlaskit/icon/core/edit';
14
16
  import LinkBrokenIcon from '@atlaskit/icon/core/link-broken';
17
+ import MegaphoneIcon from '@atlaskit/icon/core/megaphone';
15
18
  import { fg } from '@atlaskit/platform-feature-flags';
16
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
20
  import { copySyncedBlockReferenceToClipboard, editSyncedBlockSource, removeSyncedBlock, unsync } from '../editor-commands';
18
21
  import { findSyncBlockOrBodiedSyncBlock, isBodiedSyncBlockNode } from '../pm-plugins/utils/utils';
19
22
  import { SYNCED_BLOCK_BUTTON_TEST_ID } from '../types';
20
23
  import { SyncedLocationDropdown } from './SyncedLocationDropdown';
21
- export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage) {
24
+ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBlockStore, isLivePage, onGiveFeedback) {
22
25
  var _syncBlockInstance$er, _api$decorations, _api$connectivity;
23
26
  var syncBlockObject = findSyncBlockOrBodiedSyncBlock(state.schema, state.selection);
24
27
  if (!syncBlockObject) {
@@ -162,14 +165,29 @@ export var getToolbarConfig = function getToolbarConfig(state, intl, api, syncBl
162
165
  var overflowMenuConfig = [{
163
166
  type: 'overflow-dropdown',
164
167
  testId: testId,
165
- options: [_objectSpread({
168
+ options: [].concat(_toConsumableArray(isSyncBlockActivationEnabled && onGiveFeedback ? [{
169
+ title: formatMessage(toolbarInsertBlockMessages.feedbackDialog),
170
+ icon: /*#__PURE__*/React.createElement(MegaphoneIcon, {
171
+ label: ""
172
+ }),
173
+ onClick: function onClick() {
174
+ api === null || api === void 0 || api.core.actions.execute(function (_ref) {
175
+ var tr = _ref.tr;
176
+ return tr.setSelection(new GapCursorSelection(tr.doc.resolve(syncBlockObject.pos + syncBlockObject.node.nodeSize), Side.RIGHT));
177
+ });
178
+ onGiveFeedback({
179
+ blockType: isBodiedSyncBlock ? 'source' : 'reference'
180
+ });
181
+ return true;
182
+ }
183
+ }] : []), [_objectSpread({
166
184
  title: formatMessage(commonMessages.delete),
167
185
  onClick: removeSyncedBlock(api),
168
186
  icon: /*#__PURE__*/React.createElement(DeleteIcon, {
169
187
  label: ""
170
188
  }),
171
189
  testId: isBodiedSyncBlock ? SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarSourceDelete : SYNCED_BLOCK_BUTTON_TEST_ID.syncedBlockToolbarReferenceDelete
172
- }, hoverDecorationProps(nodeType))]
190
+ }, hoverDecorationProps(nodeType))])
173
191
  }];
174
192
  items.push.apply(items, overflowMenuConfig);
175
193
  }
@@ -1 +1 @@
1
- export type { SyncedBlockPlugin, SyncedBlockPluginOptions, SyncedBlockEditorProps, SyncedBlockRendererProps, } from '../syncedBlockPluginType';
1
+ export type { SyncedBlockFeedbackContext, SyncedBlockPlugin, SyncedBlockPluginOptions, SyncedBlockEditorProps, SyncedBlockRendererProps, } from '../syncedBlockPluginType';
@@ -43,6 +43,10 @@ export type SyncedBlockRendererProps = {
43
43
  api?: ExtractInjectionAPI<SyncedBlockPlugin>;
44
44
  syncBlockFetchResult: UseFetchSyncBlockDataResult;
45
45
  };
46
+ export type SyncedBlockFeedbackContext = {
47
+ blockType: 'source' | 'reference';
48
+ entryPoint?: string;
49
+ };
46
50
  export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOptions {
47
51
  /**
48
52
  * Enables Live Page specific behaviour for the synced block plugin.
@@ -53,6 +57,12 @@ export interface SyncedBlockPluginOptions extends LongPressSelectionPluginOption
53
57
  */
54
58
  __livePage?: boolean;
55
59
  enableSourceCreation?: boolean;
60
+ /**
61
+ * Opens the host product's synced-block feedback collector.
62
+ * The editor plugin owns the menu affordance; the product owns the collector
63
+ * configuration and lifecycle.
64
+ */
65
+ onGiveFeedback?: (context: SyncedBlockFeedbackContext) => void;
56
66
  syncBlockDataProvider: SyncBlockDataProviderInterface;
57
67
  syncedBlockRenderer: (props: SyncedBlockRendererProps) => React.JSX.Element;
58
68
  }
@@ -2,5 +2,5 @@ import type { IntlShape } from 'react-intl';
2
2
  import type { ExtractInjectionAPI, FloatingToolbarConfig } from '@atlaskit/editor-common/types';
3
3
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
4
4
  import type { SyncBlockStoreManager } from '@atlaskit/editor-synced-block-provider';
5
- import type { SyncedBlockPlugin } from '../syncedBlockPluginType';
6
- export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, syncBlockStore: SyncBlockStoreManager, isLivePage?: boolean) => FloatingToolbarConfig | undefined;
5
+ import type { SyncedBlockFeedbackContext, SyncedBlockPlugin } from '../syncedBlockPluginType';
6
+ export declare const getToolbarConfig: (state: EditorState, intl: IntlShape, api: ExtractInjectionAPI<SyncedBlockPlugin> | undefined, syncBlockStore: SyncBlockStoreManager, isLivePage?: boolean, onGiveFeedback?: (context: SyncedBlockFeedbackContext) => void) => FloatingToolbarConfig | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-synced-block",
3
- "version": "10.3.8",
3
+ "version": "10.4.0",
4
4
  "description": "SyncedBlock plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -46,8 +46,8 @@
46
46
  "@atlaskit/platform-feature-flags": "^2.1.0",
47
47
  "@atlaskit/primitives": "^22.1.0",
48
48
  "@atlaskit/spinner": "20.1.1",
49
- "@atlaskit/tmp-editor-statsig": "^132.1.0",
50
- "@atlaskit/tokens": "16.2.0",
49
+ "@atlaskit/tmp-editor-statsig": "^132.4.0",
50
+ "@atlaskit/tokens": "16.3.0",
51
51
  "@atlaskit/tooltip": "^23.1.0",
52
52
  "@atlaskit/visually-hidden": "^4.2.0",
53
53
  "@babel/runtime": "^7.0.0",
@@ -57,7 +57,7 @@
57
57
  "memoize-one": "^6.0.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@atlaskit/editor-common": "^116.35.0",
60
+ "@atlaskit/editor-common": "^116.37.0",
61
61
  "react": "^18.2.0",
62
62
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"
63
63
  },