@atlaskit/editor-plugin-paste-options-toolbar 8.1.2 → 8.2.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,24 @@
1
1
  # @atlaskit/editor-plugin-paste-options-toolbar
2
2
 
3
+ ## 8.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`73fe865b67fd9`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/73fe865b67fd9) -
8
+ [ux] Adds new paste action buttons in editor-plugin-ai and registers them with the editor controls
9
+ registry - then renders these buttons from the registry into the (currently in development) paste
10
+ actions menu.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 8.1.3
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 8.1.2
4
23
 
5
24
  ### Patch Changes
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactIntlNext = require("react-intl-next");
10
10
  var _hooks = require("@atlaskit/editor-common/hooks");
11
11
  var _messages = require("@atlaskit/editor-common/messages");
12
+ var _toolbar = require("@atlaskit/editor-common/toolbar");
12
13
  var _ui = require("@atlaskit/editor-common/ui");
13
14
  var _uiReact = require("@atlaskit/editor-common/ui-react");
14
15
  var _utils = require("@atlaskit/editor-prosemirror/utils");
@@ -38,6 +39,7 @@ function getPopupOffset(dom) {
38
39
  return [-(window.innerWidth - rightEdge - 50), 20];
39
40
  }
40
41
  var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref) {
42
+ var _api$uiControlRegistr, _api$uiControlRegistr2;
41
43
  var api = _ref.api,
42
44
  editorView = _ref.editorView,
43
45
  mountTo = _ref.mountTo,
@@ -111,6 +113,11 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
111
113
  if (!target) {
112
114
  return null;
113
115
  }
116
+ var aiSurface = {
117
+ type: 'menu',
118
+ key: 'ai-paste-menu'
119
+ };
120
+ var aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(aiSurface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
114
121
  return /*#__PURE__*/_react.default.createElement(PopupWithListeners, {
115
122
  target: target,
116
123
  mountTo: mountTo,
@@ -122,9 +129,13 @@ var PasteActionsMenu = exports.PasteActionsMenu = function PasteActionsMenu(_ref
122
129
  alignY: "bottom",
123
130
  handleClickOutside: handleDismiss,
124
131
  handleEscapeKeydown: handleDismiss
132
+ }, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
133
+ editorView: editorView
125
134
  }, /*#__PURE__*/_react.default.createElement(_PasteActionsMenuContent.PasteActionsMenuContent, {
126
135
  options: options,
127
136
  onMouseDown: preventEditorFocusLoss,
128
- onMouseEnter: handleMouseEnter
129
- }));
137
+ onMouseEnter: handleMouseEnter,
138
+ aiSurface: aiSurface,
139
+ aiSurfaceComponents: aiSurfaceComponents
140
+ })));
130
141
  };
@@ -11,6 +11,7 @@ var _runtime = require("@compiled/react/runtime");
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _css = require("@atlaskit/css");
13
13
  var _uiReact = require("@atlaskit/editor-common/ui-react");
14
+ var _editorUiControlModel = require("@atlaskit/editor-ui-control-model");
14
15
  var _compiled = require("@atlaskit/primitives/compiled");
15
16
  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); }
16
17
  var styles = {
@@ -21,16 +22,21 @@ var styles = {
21
22
  var PasteActionsMenuContent = exports.PasteActionsMenuContent = function PasteActionsMenuContent(_ref) {
22
23
  var options = _ref.options,
23
24
  onMouseDown = _ref.onMouseDown,
24
- onMouseEnter = _ref.onMouseEnter;
25
+ onMouseEnter = _ref.onMouseEnter,
26
+ aiSurface = _ref.aiSurface,
27
+ aiSurfaceComponents = _ref.aiSurfaceComponents;
25
28
  var setOutsideClickTargetRef = (0, _react.useContext)(_uiReact.OutsideClickTargetRefContext);
26
29
  return /*#__PURE__*/_react.default.createElement(_compiled.Box, {
27
30
  ref: setOutsideClickTargetRef,
28
- xcss: styles.container
29
- }, options.map(function (option) {
31
+ xcss: styles.container,
32
+ onMouseDown: onMouseDown
33
+ }, aiSurface && aiSurfaceComponents && aiSurfaceComponents.length > 0 && /*#__PURE__*/_react.default.createElement(_editorUiControlModel.SurfaceRenderer, {
34
+ surface: aiSurface,
35
+ components: aiSurfaceComponents
36
+ }), options.map(function (option) {
30
37
  return /*#__PURE__*/_react.default.createElement(_compiled.Pressable, {
31
38
  key: option.id,
32
39
  xcss: (0, _css.cx)(styles.option, option.selected && styles.selectedOption),
33
- onMouseDown: onMouseDown,
34
40
  onMouseEnter: onMouseEnter,
35
41
  onFocus: onMouseEnter,
36
42
  onClick: option.onClick
@@ -2,6 +2,7 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
5
6
  import { Popup } from '@atlaskit/editor-common/ui';
6
7
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
7
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
@@ -39,6 +40,7 @@ export const PasteActionsMenu = ({
39
40
  scrollableElement,
40
41
  editorAnalyticsAPI
41
42
  }) => {
43
+ var _api$uiControlRegistr, _api$uiControlRegistr2;
42
44
  const intl = useIntl();
43
45
  const {
44
46
  showToolbar,
@@ -107,6 +109,11 @@ export const PasteActionsMenu = ({
107
109
  if (!target) {
108
110
  return null;
109
111
  }
112
+ const aiSurface = {
113
+ type: 'menu',
114
+ key: 'ai-paste-menu'
115
+ };
116
+ const aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 ? void 0 : (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(aiSurface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
110
117
  return /*#__PURE__*/React.createElement(PopupWithListeners, {
111
118
  target: target,
112
119
  mountTo: mountTo,
@@ -118,9 +125,13 @@ export const PasteActionsMenu = ({
118
125
  alignY: "bottom",
119
126
  handleClickOutside: handleDismiss,
120
127
  handleEscapeKeydown: handleDismiss
128
+ }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
129
+ editorView: editorView
121
130
  }, /*#__PURE__*/React.createElement(PasteActionsMenuContent, {
122
131
  options: options,
123
132
  onMouseDown: preventEditorFocusLoss,
124
- onMouseEnter: handleMouseEnter
125
- }));
133
+ onMouseEnter: handleMouseEnter,
134
+ aiSurface: aiSurface,
135
+ aiSurfaceComponents: aiSurfaceComponents
136
+ })));
126
137
  };
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useContext } from 'react';
5
5
  import { cx } from '@atlaskit/css';
6
6
  import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
7
+ import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
7
8
  import { Box, Pressable } from '@atlaskit/primitives/compiled';
8
9
  const styles = {
9
10
  container: "_2rko12b0 _1rjc1b66 _bfhk1bhr _16qs130s",
@@ -13,16 +14,21 @@ const styles = {
13
14
  export const PasteActionsMenuContent = ({
14
15
  options,
15
16
  onMouseDown,
16
- onMouseEnter
17
+ onMouseEnter,
18
+ aiSurface,
19
+ aiSurfaceComponents
17
20
  }) => {
18
21
  const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
19
22
  return /*#__PURE__*/React.createElement(Box, {
20
23
  ref: setOutsideClickTargetRef,
21
- xcss: styles.container
22
- }, options.map(option => /*#__PURE__*/React.createElement(Pressable, {
24
+ xcss: styles.container,
25
+ onMouseDown: onMouseDown
26
+ }, aiSurface && aiSurfaceComponents && aiSurfaceComponents.length > 0 && /*#__PURE__*/React.createElement(SurfaceRenderer, {
27
+ surface: aiSurface,
28
+ components: aiSurfaceComponents
29
+ }), options.map(option => /*#__PURE__*/React.createElement(Pressable, {
23
30
  key: option.id,
24
31
  xcss: cx(styles.option, option.selected && styles.selectedOption),
25
- onMouseDown: onMouseDown,
26
32
  onMouseEnter: onMouseEnter,
27
33
  onFocus: onMouseEnter,
28
34
  onClick: option.onClick
@@ -2,6 +2,7 @@ import React, { useCallback, useMemo } from 'react';
2
2
  import { useIntl } from 'react-intl-next';
3
3
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
4
  import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { EditorToolbarProvider } from '@atlaskit/editor-common/toolbar';
5
6
  import { Popup } from '@atlaskit/editor-common/ui';
6
7
  import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
7
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
@@ -30,6 +31,7 @@ function getPopupOffset(dom) {
30
31
  return [-(window.innerWidth - rightEdge - 50), 20];
31
32
  }
32
33
  export var PasteActionsMenu = function PasteActionsMenu(_ref) {
34
+ var _api$uiControlRegistr, _api$uiControlRegistr2;
33
35
  var api = _ref.api,
34
36
  editorView = _ref.editorView,
35
37
  mountTo = _ref.mountTo,
@@ -103,6 +105,11 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
103
105
  if (!target) {
104
106
  return null;
105
107
  }
108
+ var aiSurface = {
109
+ type: 'menu',
110
+ key: 'ai-paste-menu'
111
+ };
112
+ var aiSurfaceComponents = (_api$uiControlRegistr = api === null || api === void 0 || (_api$uiControlRegistr2 = api.uiControlRegistry) === null || _api$uiControlRegistr2 === void 0 ? void 0 : _api$uiControlRegistr2.actions.getComponents(aiSurface.key)) !== null && _api$uiControlRegistr !== void 0 ? _api$uiControlRegistr : [];
106
113
  return /*#__PURE__*/React.createElement(PopupWithListeners, {
107
114
  target: target,
108
115
  mountTo: mountTo,
@@ -114,9 +121,13 @@ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
114
121
  alignY: "bottom",
115
122
  handleClickOutside: handleDismiss,
116
123
  handleEscapeKeydown: handleDismiss
124
+ }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
125
+ editorView: editorView
117
126
  }, /*#__PURE__*/React.createElement(PasteActionsMenuContent, {
118
127
  options: options,
119
128
  onMouseDown: preventEditorFocusLoss,
120
- onMouseEnter: handleMouseEnter
121
- }));
129
+ onMouseEnter: handleMouseEnter,
130
+ aiSurface: aiSurface,
131
+ aiSurfaceComponents: aiSurfaceComponents
132
+ })));
122
133
  };
@@ -4,6 +4,7 @@ import { ax, ix } from "@compiled/react/runtime";
4
4
  import React, { useContext } from 'react';
5
5
  import { cx } from '@atlaskit/css';
6
6
  import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
7
+ import { SurfaceRenderer } from '@atlaskit/editor-ui-control-model';
7
8
  import { Box, Pressable } from '@atlaskit/primitives/compiled';
8
9
  var styles = {
9
10
  container: "_2rko12b0 _1rjc1b66 _bfhk1bhr _16qs130s",
@@ -13,16 +14,21 @@ var styles = {
13
14
  export var PasteActionsMenuContent = function PasteActionsMenuContent(_ref) {
14
15
  var options = _ref.options,
15
16
  onMouseDown = _ref.onMouseDown,
16
- onMouseEnter = _ref.onMouseEnter;
17
+ onMouseEnter = _ref.onMouseEnter,
18
+ aiSurface = _ref.aiSurface,
19
+ aiSurfaceComponents = _ref.aiSurfaceComponents;
17
20
  var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
18
21
  return /*#__PURE__*/React.createElement(Box, {
19
22
  ref: setOutsideClickTargetRef,
20
- xcss: styles.container
21
- }, options.map(function (option) {
23
+ xcss: styles.container,
24
+ onMouseDown: onMouseDown
25
+ }, aiSurface && aiSurfaceComponents && aiSurfaceComponents.length > 0 && /*#__PURE__*/React.createElement(SurfaceRenderer, {
26
+ surface: aiSurface,
27
+ components: aiSurfaceComponents
28
+ }), options.map(function (option) {
22
29
  return /*#__PURE__*/React.createElement(Pressable, {
23
30
  key: option.id,
24
31
  xcss: cx(styles.option, option.selected && styles.selectedOption),
25
- onMouseDown: onMouseDown,
26
32
  onMouseEnter: onMouseEnter,
27
33
  onFocus: onMouseEnter,
28
34
  onClick: option.onClick
@@ -1,8 +1,13 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { PastePlugin } from '@atlaskit/editor-plugin-paste';
4
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
4
5
  import type { ToolbarDropdownOption } from './types/types';
5
- export type PasteOptionsToolbarPluginDependencies = [OptionalPlugin<AnalyticsPlugin>, PastePlugin];
6
+ export type PasteOptionsToolbarPluginDependencies = [
7
+ OptionalPlugin<AnalyticsPlugin>,
8
+ PastePlugin,
9
+ OptionalPlugin<UiControlRegistryPlugin>
10
+ ];
6
11
  export interface PasteOptionsToolbarSharedState {
7
12
  isPlainText: boolean;
8
13
  plaintextLength: number;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { RegisterComponent, SurfaceIdentifier } from '@atlaskit/editor-ui-control-model';
2
3
  export interface MenuOption {
3
4
  id: string;
4
5
  label: string;
@@ -6,9 +7,11 @@ export interface MenuOption {
6
7
  selected: boolean;
7
8
  }
8
9
  interface PasteActionsMenuContentProps {
10
+ aiSurface?: SurfaceIdentifier;
11
+ aiSurfaceComponents?: RegisterComponent[];
9
12
  onMouseDown: (e: React.MouseEvent) => void;
10
13
  onMouseEnter: () => void;
11
14
  options: MenuOption[];
12
15
  }
13
- export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, }: PasteActionsMenuContentProps) => React.JSX.Element;
16
+ export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, aiSurface, aiSurfaceComponents, }: PasteActionsMenuContentProps) => React.JSX.Element;
14
17
  export {};
@@ -1,10 +1,12 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { AnalyticsPlugin } from '@atlaskit/editor-plugin-analytics';
3
3
  import type { PastePlugin } from '@atlaskit/editor-plugin-paste';
4
+ import type { UiControlRegistryPlugin } from '@atlaskit/editor-plugin-ui-control-registry';
4
5
  import type { ToolbarDropdownOption } from './types/types';
5
6
  export type PasteOptionsToolbarPluginDependencies = [
6
7
  OptionalPlugin<AnalyticsPlugin>,
7
- PastePlugin
8
+ PastePlugin,
9
+ OptionalPlugin<UiControlRegistryPlugin>
8
10
  ];
9
11
  export interface PasteOptionsToolbarSharedState {
10
12
  isPlainText: boolean;
@@ -1,4 +1,5 @@
1
1
  import React from 'react';
2
+ import type { RegisterComponent, SurfaceIdentifier } from '@atlaskit/editor-ui-control-model';
2
3
  export interface MenuOption {
3
4
  id: string;
4
5
  label: string;
@@ -6,9 +7,11 @@ export interface MenuOption {
6
7
  selected: boolean;
7
8
  }
8
9
  interface PasteActionsMenuContentProps {
10
+ aiSurface?: SurfaceIdentifier;
11
+ aiSurfaceComponents?: RegisterComponent[];
9
12
  onMouseDown: (e: React.MouseEvent) => void;
10
13
  onMouseEnter: () => void;
11
14
  options: MenuOption[];
12
15
  }
13
- export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, }: PasteActionsMenuContentProps) => React.JSX.Element;
16
+ export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, aiSurface, aiSurfaceComponents, }: PasteActionsMenuContentProps) => React.JSX.Element;
14
17
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "8.1.2",
3
+ "version": "8.2.0",
4
4
  "description": "Paste options toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -32,20 +32,22 @@
32
32
  "@atlaskit/css": "^0.19.0",
33
33
  "@atlaskit/editor-markdown-transformer": "^5.20.0",
34
34
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
35
- "@atlaskit/editor-plugin-paste": "^8.2.0",
35
+ "@atlaskit/editor-plugin-paste": "^8.4.0",
36
+ "@atlaskit/editor-plugin-ui-control-registry": "^1.1.0",
36
37
  "@atlaskit/editor-prosemirror": "^7.3.0",
37
38
  "@atlaskit/editor-shared-styles": "^3.10.0",
39
+ "@atlaskit/editor-ui-control-model": "^1.1.0",
38
40
  "@atlaskit/icon": "^32.0.0",
39
41
  "@atlaskit/platform-feature-flags": "^1.1.0",
40
42
  "@atlaskit/primitives": "^18.0.0",
41
- "@atlaskit/tmp-editor-statsig": "^31.0.0",
43
+ "@atlaskit/tmp-editor-statsig": "^32.12.0",
42
44
  "@atlaskit/tokens": "^11.0.0",
43
45
  "@babel/runtime": "^7.0.0",
44
46
  "@emotion/react": "^11.7.1",
45
47
  "react-intl-next": "npm:react-intl@^5.18.1"
46
48
  },
47
49
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^111.20.0",
50
+ "@atlaskit/editor-common": "^111.25.0",
49
51
  "react": "^18.2.0",
50
52
  "react-dom": "^18.2.0"
51
53
  },