@atlaskit/editor-plugin-paste-options-toolbar 8.0.4 → 8.1.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.
Files changed (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/editor-commands/commands.js +6 -6
  3. package/dist/cjs/pasteOptionsToolbarPlugin.js +56 -8
  4. package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenu.js +130 -0
  5. package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +10 -0
  6. package/dist/cjs/ui/on-paste-actions-menu/PasteActionsMenuContent.js +39 -0
  7. package/dist/cjs/ui/toolbar.js +1 -1
  8. package/dist/es2019/editor-commands/commands.js +6 -6
  9. package/dist/es2019/pasteOptionsToolbarPlugin.js +45 -2
  10. package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenu.js +126 -0
  11. package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +10 -0
  12. package/dist/es2019/ui/on-paste-actions-menu/PasteActionsMenuContent.js +30 -0
  13. package/dist/es2019/ui/toolbar.js +1 -1
  14. package/dist/esm/editor-commands/commands.js +6 -6
  15. package/dist/esm/pasteOptionsToolbarPlugin.js +53 -8
  16. package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenu.js +122 -0
  17. package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.compiled.css +10 -0
  18. package/dist/esm/ui/on-paste-actions-menu/PasteActionsMenuContent.js +31 -0
  19. package/dist/esm/ui/toolbar.js +1 -1
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/types/pasteOptionsToolbarPluginType.d.ts +7 -0
  22. package/dist/types/pm-plugins/main.d.ts +1 -1
  23. package/dist/types/pm-plugins/plugin-factory.d.ts +2 -2
  24. package/dist/types/pm-plugins/reducer.d.ts +1 -1
  25. package/dist/types/pm-plugins/util/format-handlers.d.ts +4 -4
  26. package/dist/types/types/types.d.ts +1 -1
  27. package/dist/types/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +15 -0
  28. package/dist/types/ui/on-paste-actions-menu/PasteActionsMenuContent.d.ts +14 -0
  29. package/dist/types/ui/toolbar.d.ts +2 -2
  30. package/dist/types-ts4.5/index.d.ts +1 -1
  31. package/dist/types-ts4.5/pasteOptionsToolbarPluginType.d.ts +7 -0
  32. package/dist/types-ts4.5/pm-plugins/main.d.ts +1 -1
  33. package/dist/types-ts4.5/pm-plugins/plugin-factory.d.ts +2 -2
  34. package/dist/types-ts4.5/pm-plugins/reducer.d.ts +1 -1
  35. package/dist/types-ts4.5/pm-plugins/util/format-handlers.d.ts +4 -4
  36. package/dist/types-ts4.5/types/types.d.ts +1 -1
  37. package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteActionsMenu.d.ts +15 -0
  38. package/dist/types-ts4.5/ui/on-paste-actions-menu/PasteActionsMenuContent.d.ts +14 -0
  39. package/dist/types-ts4.5/ui/toolbar.d.ts +2 -2
  40. package/package.json +5 -1
@@ -0,0 +1,30 @@
1
+ /* PasteActionsMenuContent.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./PasteActionsMenuContent.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useContext } from 'react';
5
+ import { cx } from '@atlaskit/css';
6
+ import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
7
+ import { Box, Pressable } from '@atlaskit/primitives/compiled';
8
+ const styles = {
9
+ container: "_2rko12b0 _1rjc1b66 _bfhk1bhr _16qs130s",
10
+ option: "_1rjcu2gc _18zrpxbi _syazi7uo _bfhksm61 _irr31dpa",
11
+ selectedOption: "_k48pwu06"
12
+ };
13
+ export const PasteActionsMenuContent = ({
14
+ options,
15
+ onMouseDown,
16
+ onMouseEnter
17
+ }) => {
18
+ const setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
19
+ return /*#__PURE__*/React.createElement(Box, {
20
+ ref: setOutsideClickTargetRef,
21
+ xcss: styles.container
22
+ }, options.map(option => /*#__PURE__*/React.createElement(Pressable, {
23
+ key: option.id,
24
+ xcss: cx(styles.option, option.selected && styles.selectedOption),
25
+ onMouseDown: onMouseDown,
26
+ onMouseEnter: onMouseEnter,
27
+ onFocus: onMouseEnter,
28
+ onClick: option.onClick
29
+ }, option.label)));
30
+ };
@@ -73,7 +73,7 @@ export const buildToolbar = (state, intl, editorAnalyticsAPI) => {
73
73
  onPositionCalculated
74
74
  };
75
75
  };
76
- const onPositionCalculated = (editorView, nextPos) => {
76
+ const onPositionCalculated = (editorView, _nextPos) => {
77
77
  const {
78
78
  from
79
79
  } = editorView.state.selection;
@@ -5,7 +5,7 @@ import { createCommand } from '../pm-plugins/plugin-factory';
5
5
  import { formatMarkdown, formatPlainText, formatRichText } from '../pm-plugins/util/format-handlers';
6
6
  import { pasteOptionsPluginKey, ToolbarDropdownOption } from '../types/types';
7
7
  export var showToolbar = function showToolbar(lastContentPasted, selectedOption) {
8
- var commandAction = function commandAction(editorState) {
8
+ var commandAction = function commandAction(_editorState) {
9
9
  var _lastContentPasted$te;
10
10
  return {
11
11
  type: ActionTypes.SHOW_PASTE_OPTIONS,
@@ -29,7 +29,7 @@ export var changeToPlainText = function changeToPlainText() {
29
29
  }
30
30
  return formatPlainText(tr, pluginState);
31
31
  };
32
- var commandAction = function commandAction(editorState) {
32
+ var commandAction = function commandAction(_editorState) {
33
33
  return {
34
34
  type: ActionTypes.CHANGE_FORMAT,
35
35
  data: {
@@ -65,7 +65,7 @@ export var changeToRichText = function changeToRichText() {
65
65
  }
66
66
  return formatRichText(tr, pluginState);
67
67
  };
68
- var commandAction = function commandAction(editorState) {
68
+ var commandAction = function commandAction(_editorState) {
69
69
  return {
70
70
  type: ActionTypes.CHANGE_FORMAT,
71
71
  data: {
@@ -103,7 +103,7 @@ export var changeToMarkDown = function changeToMarkDown() {
103
103
  }
104
104
  return formatMarkdown(tr, pluginState);
105
105
  };
106
- var commandAction = function commandAction(editorState) {
106
+ var commandAction = function commandAction(_editorState) {
107
107
  return {
108
108
  type: ActionTypes.CHANGE_FORMAT,
109
109
  data: {
@@ -129,7 +129,7 @@ export var changeToMarkdownWithAnalytics = function changeToMarkdownWithAnalytic
129
129
  };
130
130
  };
131
131
  export var highlightContent = function highlightContent() {
132
- var commandAction = function commandAction(editorState) {
132
+ var commandAction = function commandAction(_editorState) {
133
133
  return {
134
134
  type: ActionTypes.HIGHLIGHT_CONTENT
135
135
  };
@@ -137,7 +137,7 @@ export var highlightContent = function highlightContent() {
137
137
  return createCommand(commandAction);
138
138
  };
139
139
  export var hideToolbar = function hideToolbar() {
140
- var commandAction = function commandAction(editorState) {
140
+ var commandAction = function commandAction(_editorState) {
141
141
  return {
142
142
  type: ActionTypes.HIDE_PASTE_OPTIONS
143
143
  };
@@ -1,15 +1,37 @@
1
- import { useEffect } from 'react';
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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
+ 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
+ import React, { useEffect } from 'react';
2
5
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
6
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
7
  import { hideToolbar, showToolbar } from './editor-commands/commands';
4
8
  import { createPlugin } from './pm-plugins/main';
5
9
  import { pasteOptionsPluginKey, ToolbarDropdownOption } from './types/types';
10
+ import { PasteActionsMenu } from './ui/on-paste-actions-menu/PasteActionsMenu';
6
11
  import { buildToolbar, isToolbarVisible } from './ui/toolbar';
7
12
  export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref) {
8
13
  var _api$analytics;
9
- var config = _ref.config,
10
- api = _ref.api;
14
+ var api = _ref.api;
11
15
  var editorAnalyticsAPI = api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions;
12
- return {
16
+ var getSharedState = function getSharedState(editorState) {
17
+ var _pluginState$isPlainT, _pluginState$plaintex, _pluginState$selected, _pluginState$showTool;
18
+ if (!editorState) {
19
+ return {
20
+ isPlainText: false,
21
+ plaintextLength: 0,
22
+ selectedOption: ToolbarDropdownOption.None,
23
+ showToolbar: false
24
+ };
25
+ }
26
+ var pluginState = pasteOptionsPluginKey.getState(editorState);
27
+ return {
28
+ isPlainText: (_pluginState$isPlainT = pluginState === null || pluginState === void 0 ? void 0 : pluginState.isPlainText) !== null && _pluginState$isPlainT !== void 0 ? _pluginState$isPlainT : false,
29
+ plaintextLength: (_pluginState$plaintex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.plaintext.length) !== null && _pluginState$plaintex !== void 0 ? _pluginState$plaintex : 0,
30
+ selectedOption: (_pluginState$selected = pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedOption) !== null && _pluginState$selected !== void 0 ? _pluginState$selected : ToolbarDropdownOption.None,
31
+ showToolbar: (_pluginState$showTool = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showToolbar) !== null && _pluginState$showTool !== void 0 ? _pluginState$showTool : false
32
+ };
33
+ };
34
+ return _objectSpread(_objectSpread({
13
35
  name: 'pasteOptionsToolbarPlugin',
14
36
  pmPlugins: function pmPlugins() {
15
37
  return [{
@@ -19,9 +41,15 @@ export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref)
19
41
  return createPlugin(dispatch);
20
42
  }
21
43
  }];
22
- },
44
+ }
45
+ }, expValEquals('platform_editor_paste_actions_menu', 'isEnabled', true) ? {
46
+ getSharedState: getSharedState
47
+ } : {}), {}, {
23
48
  pluginsOptions: {
24
49
  floatingToolbar: function floatingToolbar(state, intl) {
50
+ if (expValEquals('platform_editor_paste_actions_menu', 'isEnabled', true)) {
51
+ return;
52
+ }
25
53
  var pastePluginState = pasteOptionsPluginKey.getState(state);
26
54
  if (pastePluginState.showToolbar) {
27
55
  return buildToolbar(state, intl, editorAnalyticsAPI);
@@ -29,8 +57,25 @@ export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref)
29
57
  return;
30
58
  }
31
59
  },
32
- usePluginHook: function usePluginHook(_ref3) {
33
- var editorView = _ref3.editorView;
60
+ contentComponent: function contentComponent(_ref3) {
61
+ var editorView = _ref3.editorView,
62
+ popupsMountPoint = _ref3.popupsMountPoint,
63
+ popupsBoundariesElement = _ref3.popupsBoundariesElement,
64
+ popupsScrollableElement = _ref3.popupsScrollableElement;
65
+ if (!expValEquals('platform_editor_paste_actions_menu', 'isEnabled', true) || !editorView) {
66
+ return null;
67
+ }
68
+ return /*#__PURE__*/React.createElement(PasteActionsMenu, {
69
+ api: api,
70
+ editorView: editorView,
71
+ mountTo: popupsMountPoint,
72
+ boundariesElement: popupsBoundariesElement,
73
+ scrollableElement: popupsScrollableElement,
74
+ editorAnalyticsAPI: editorAnalyticsAPI
75
+ });
76
+ },
77
+ usePluginHook: function usePluginHook(_ref4) {
78
+ var editorView = _ref4.editorView;
34
79
  var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['paste'], function (states) {
35
80
  var _states$pasteState;
36
81
  return {
@@ -57,5 +102,5 @@ export var pasteOptionsToolbarPlugin = function pasteOptionsToolbarPlugin(_ref)
57
102
  showToolbar(lastContentPasted, selectedOption)(editorView.state, editorView.dispatch);
58
103
  }, [lastContentPasted, editorView]);
59
104
  }
60
- };
105
+ });
61
106
  };
@@ -0,0 +1,122 @@
1
+ import React, { useCallback, useMemo } from 'react';
2
+ import { useIntl } from 'react-intl-next';
3
+ import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
4
+ import { pasteOptionsToolbarMessages as messages } from '@atlaskit/editor-common/messages';
5
+ import { Popup } from '@atlaskit/editor-common/ui';
6
+ import { withReactEditorViewOuterListeners } from '@atlaskit/editor-common/ui-react';
7
+ import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
8
+ import { akEditorFloatingPanelZIndex } from '@atlaskit/editor-shared-styles';
9
+ import { changeToMarkdownWithAnalytics, changeToPlainTextWithAnalytics, changeToRichTextWithAnalytics, hideToolbar, highlightContent } from '../../editor-commands/commands';
10
+ import { ToolbarDropdownOption } from '../../types/types';
11
+ import { PasteActionsMenuContent } from './PasteActionsMenuContent';
12
+ var PopupWithListeners = withReactEditorViewOuterListeners(Popup);
13
+ function getTargetElement(editorView) {
14
+ var from = editorView.state.selection.from;
15
+ try {
16
+ var domRef = findDomRefAtPos(from, editorView.domAtPos.bind(editorView));
17
+ if (domRef instanceof HTMLElement) {
18
+ return domRef;
19
+ }
20
+ return null;
21
+ } catch (_unused) {
22
+ return null;
23
+ }
24
+ }
25
+ function getPopupOffset(dom) {
26
+ if (!dom) {
27
+ return [0, 20];
28
+ }
29
+ var rightEdge = dom.getBoundingClientRect().right;
30
+ return [-(window.innerWidth - rightEdge - 50), 20];
31
+ }
32
+ export var PasteActionsMenu = function PasteActionsMenu(_ref) {
33
+ var api = _ref.api,
34
+ editorView = _ref.editorView,
35
+ mountTo = _ref.mountTo,
36
+ boundariesElement = _ref.boundariesElement,
37
+ scrollableElement = _ref.scrollableElement,
38
+ editorAnalyticsAPI = _ref.editorAnalyticsAPI;
39
+ var intl = useIntl();
40
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['pasteOptionsToolbarPlugin'], function (states) {
41
+ var _pluginState$showTool, _pluginState$isPlainT, _pluginState$selected, _pluginState$plaintex;
42
+ var pluginState = states.pasteOptionsToolbarPluginState;
43
+ return {
44
+ showToolbar: (_pluginState$showTool = pluginState === null || pluginState === void 0 ? void 0 : pluginState.showToolbar) !== null && _pluginState$showTool !== void 0 ? _pluginState$showTool : false,
45
+ isPlainText: (_pluginState$isPlainT = pluginState === null || pluginState === void 0 ? void 0 : pluginState.isPlainText) !== null && _pluginState$isPlainT !== void 0 ? _pluginState$isPlainT : false,
46
+ selectedOption: (_pluginState$selected = pluginState === null || pluginState === void 0 ? void 0 : pluginState.selectedOption) !== null && _pluginState$selected !== void 0 ? _pluginState$selected : ToolbarDropdownOption.None,
47
+ plaintextLength: (_pluginState$plaintex = pluginState === null || pluginState === void 0 ? void 0 : pluginState.plaintextLength) !== null && _pluginState$plaintex !== void 0 ? _pluginState$plaintex : 0
48
+ };
49
+ }),
50
+ showToolbar = _useSharedPluginState.showToolbar,
51
+ isPlainText = _useSharedPluginState.isPlainText,
52
+ selectedOption = _useSharedPluginState.selectedOption,
53
+ plaintextLength = _useSharedPluginState.plaintextLength;
54
+ var preventEditorFocusLoss = useCallback(function (e) {
55
+ e.preventDefault();
56
+ }, []);
57
+ var handleDismiss = useCallback(function () {
58
+ hideToolbar()(editorView.state, editorView.dispatch);
59
+ }, [editorView]);
60
+ var handleMouseEnter = useCallback(function () {
61
+ highlightContent()(editorView.state, editorView.dispatch);
62
+ }, [editorView]);
63
+ var handleRichText = useCallback(function (e) {
64
+ e.preventDefault();
65
+ changeToRichTextWithAnalytics(editorAnalyticsAPI)()(editorView.state, editorView.dispatch);
66
+ }, [editorView, editorAnalyticsAPI]);
67
+ var handleMarkdown = useCallback(function (e) {
68
+ e.preventDefault();
69
+ changeToMarkdownWithAnalytics(editorAnalyticsAPI, plaintextLength)()(editorView.state, editorView.dispatch);
70
+ }, [editorView, editorAnalyticsAPI, plaintextLength]);
71
+ var handlePlainText = useCallback(function (e) {
72
+ e.preventDefault();
73
+ changeToPlainTextWithAnalytics(editorAnalyticsAPI, plaintextLength)()(editorView.state, editorView.dispatch);
74
+ }, [editorView, editorAnalyticsAPI, plaintextLength]);
75
+ var options = useMemo(function () {
76
+ var items = [];
77
+ if (!isPlainText) {
78
+ items.push({
79
+ id: 'editor.paste.richText',
80
+ label: intl.formatMessage(messages.richText),
81
+ selected: selectedOption === ToolbarDropdownOption.RichText,
82
+ onClick: handleRichText
83
+ });
84
+ }
85
+ items.push({
86
+ id: 'editor.paste.markdown',
87
+ label: intl.formatMessage(messages.markdown),
88
+ selected: selectedOption === ToolbarDropdownOption.Markdown,
89
+ onClick: handleMarkdown
90
+ });
91
+ items.push({
92
+ id: 'editor.paste.plainText',
93
+ label: intl.formatMessage(messages.plainText),
94
+ selected: selectedOption === ToolbarDropdownOption.PlainText,
95
+ onClick: handlePlainText
96
+ });
97
+ return items;
98
+ }, [isPlainText, selectedOption, intl, handleRichText, handleMarkdown, handlePlainText]);
99
+ if (!showToolbar) {
100
+ return null;
101
+ }
102
+ var target = getTargetElement(editorView);
103
+ if (!target) {
104
+ return null;
105
+ }
106
+ return /*#__PURE__*/React.createElement(PopupWithListeners, {
107
+ target: target,
108
+ mountTo: mountTo,
109
+ boundariesElement: boundariesElement,
110
+ scrollableElement: scrollableElement,
111
+ offset: getPopupOffset(target),
112
+ zIndex: akEditorFloatingPanelZIndex,
113
+ alignX: "right",
114
+ alignY: "bottom",
115
+ handleClickOutside: handleDismiss,
116
+ handleEscapeKeydown: handleDismiss
117
+ }, /*#__PURE__*/React.createElement(PasteActionsMenuContent, {
118
+ options: options,
119
+ onMouseDown: preventEditorFocusLoss,
120
+ onMouseEnter: handleMouseEnter
121
+ }));
122
+ };
@@ -0,0 +1,10 @@
1
+
2
+ ._2rko12b0{border-radius:var(--ds-radius-small,4px)}
3
+ ._18zrpxbi{padding-inline:var(--ds-space-200,1pc)}
4
+ ._1rjc1b66{padding-block:var(--ds-space-050,4px)}
5
+ ._1rjcu2gc{padding-block:var(--ds-space-100,8px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
6
+ ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
7
+ ._bfhksm61{background-color:var(--ds-background-neutral-subtle,#00000000)}
8
+ ._k48pwu06{font-weight:var(--ds-font-weight-bold,653)}
9
+ ._syazi7uo{color:var(--ds-text,#292a2e)}
10
+ ._irr31dpa:hover{background-color:var(--ds-background-neutral-subtle-hovered,#0515240f)}
@@ -0,0 +1,31 @@
1
+ /* PasteActionsMenuContent.tsx generated by @compiled/babel-plugin v0.38.1 */
2
+ import "./PasteActionsMenuContent.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { useContext } from 'react';
5
+ import { cx } from '@atlaskit/css';
6
+ import { OutsideClickTargetRefContext } from '@atlaskit/editor-common/ui-react';
7
+ import { Box, Pressable } from '@atlaskit/primitives/compiled';
8
+ var styles = {
9
+ container: "_2rko12b0 _1rjc1b66 _bfhk1bhr _16qs130s",
10
+ option: "_1rjcu2gc _18zrpxbi _syazi7uo _bfhksm61 _irr31dpa",
11
+ selectedOption: "_k48pwu06"
12
+ };
13
+ export var PasteActionsMenuContent = function PasteActionsMenuContent(_ref) {
14
+ var options = _ref.options,
15
+ onMouseDown = _ref.onMouseDown,
16
+ onMouseEnter = _ref.onMouseEnter;
17
+ var setOutsideClickTargetRef = useContext(OutsideClickTargetRefContext);
18
+ return /*#__PURE__*/React.createElement(Box, {
19
+ ref: setOutsideClickTargetRef,
20
+ xcss: styles.container
21
+ }, options.map(function (option) {
22
+ return /*#__PURE__*/React.createElement(Pressable, {
23
+ key: option.id,
24
+ xcss: cx(styles.option, option.selected && styles.selectedOption),
25
+ onMouseDown: onMouseDown,
26
+ onMouseEnter: onMouseEnter,
27
+ onFocus: onMouseEnter,
28
+ onClick: option.onClick
29
+ }, option.label);
30
+ }));
31
+ };
@@ -71,7 +71,7 @@ export var buildToolbar = function buildToolbar(state, intl, editorAnalyticsAPI)
71
71
  onPositionCalculated: onPositionCalculated
72
72
  };
73
73
  };
74
- var onPositionCalculated = function onPositionCalculated(editorView, nextPos) {
74
+ var onPositionCalculated = function onPositionCalculated(editorView, _nextPos) {
75
75
  var from = editorView.state.selection.from;
76
76
  var fromCoords = editorView.coordsAtPos(from);
77
77
 
@@ -1,2 +1,2 @@
1
1
  export { pasteOptionsToolbarPlugin } from './pasteOptionsToolbarPlugin';
2
- export type { PasteOptionsToolbarPlugin, PasteOptionsToolbarPluginDependencies, } from './pasteOptionsToolbarPluginType';
2
+ export type { PasteOptionsToolbarPlugin, PasteOptionsToolbarPluginDependencies, PasteOptionsToolbarSharedState, } from './pasteOptionsToolbarPluginType';
@@ -1,7 +1,14 @@
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 { ToolbarDropdownOption } from './types/types';
4
5
  export type PasteOptionsToolbarPluginDependencies = [OptionalPlugin<AnalyticsPlugin>, PastePlugin];
6
+ export interface PasteOptionsToolbarSharedState {
7
+ isPlainText: boolean;
8
+ plaintextLength: number;
9
+ selectedOption: ToolbarDropdownOption;
10
+ showToolbar: boolean;
11
+ }
5
12
  export type PasteOptionsToolbarPlugin = NextEditorPlugin<'pasteOptionsToolbarPlugin', {
6
13
  dependencies: PasteOptionsToolbarPluginDependencies;
7
14
  }>;
@@ -1,3 +1,3 @@
1
1
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- export declare function createPlugin(dispatch: Dispatch): SafePlugin<import("../types/types").PasteOtionsPluginState>;
3
+ export declare function createPlugin(dispatch: Dispatch): SafePlugin<import("../types/types").PasteOptionsPluginState>;
@@ -1,2 +1,2 @@
1
- import type { PasteOtionsPluginState } from '../types/types';
2
- export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: PasteOtionsPluginState | ((state: import("prosemirror-state").EditorState) => PasteOtionsPluginState)) => import("prosemirror-state").SafeStateField<PasteOtionsPluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => PasteOtionsPluginState;
1
+ import type { PasteOptionsPluginState } from '../types/types';
2
+ export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: PasteOptionsPluginState | ((state: import("prosemirror-state").EditorState) => PasteOptionsPluginState)) => import("prosemirror-state").SafeStateField<PasteOptionsPluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => PasteOptionsPluginState;
@@ -1,3 +1,3 @@
1
1
  import type { PastePluginAction as Action } from '../editor-actions/actions';
2
- import type { PasteOtionsPluginState as State } from '../types/types';
2
+ import type { PasteOptionsPluginState as State } from '../types/types';
3
3
  export declare const reducer: (state: State, action: Action) => State;
@@ -2,8 +2,8 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
- import type { PasteOtionsPluginState } from '../../types/types';
6
- export declare const formatMarkdown: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
7
- export declare const formatRichText: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
8
- export declare const formatPlainText: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
5
+ import type { PasteOptionsPluginState } from '../../types/types';
6
+ export declare const formatMarkdown: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
7
+ export declare const formatRichText: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
8
+ export declare const formatPlainText: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
9
9
  export declare function getMarkdownSlice(text: string, schema: Schema, selection: Selection): Slice | undefined;
@@ -8,7 +8,7 @@ export declare enum ToolbarDropdownOption {
8
8
  PlainText = 2,
9
9
  None = 3
10
10
  }
11
- export interface PasteOtionsPluginState {
11
+ export interface PasteOptionsPluginState {
12
12
  highlightContent: boolean;
13
13
  highlightDecorationSet: DecorationSet;
14
14
  isPlainText: boolean;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
6
+ interface PasteActionsMenuProps {
7
+ api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
8
+ boundariesElement?: HTMLElement;
9
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
10
+ editorView: EditorView;
11
+ mountTo?: HTMLElement;
12
+ scrollableElement?: HTMLElement;
13
+ }
14
+ export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement, editorAnalyticsAPI, }: PasteActionsMenuProps) => React.JSX.Element | null;
15
+ export {};
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface MenuOption {
3
+ id: string;
4
+ label: string;
5
+ onClick: (e: React.MouseEvent) => void;
6
+ selected: boolean;
7
+ }
8
+ interface PasteActionsMenuContentProps {
9
+ onMouseDown: (e: React.MouseEvent) => void;
10
+ onMouseEnter: () => void;
11
+ options: MenuOption[];
12
+ }
13
+ export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, }: PasteActionsMenuContentProps) => React.JSX.Element;
14
+ export {};
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command, FloatingToolbarConfig, FloatingToolbarDropdown } from '@atlaskit/editor-common/types';
4
4
  import type { LastContentPasted } from '@atlaskit/editor-plugin-paste';
5
5
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
- import type { PasteOtionsPluginState } from '../types/types';
6
+ import type { PasteOptionsPluginState } from '../types/types';
7
7
  export declare const isToolbarVisible: (state: EditorState, lastContentPasted: LastContentPasted) => boolean;
8
- export declare const getToolbarMenuConfig: (pluginState: PasteOtionsPluginState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarDropdown<Command>;
8
+ export declare const getToolbarMenuConfig: (pluginState: PasteOptionsPluginState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarDropdown<Command>;
9
9
  export declare const buildToolbar: (state: EditorState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarConfig | undefined;
@@ -1,2 +1,2 @@
1
1
  export { pasteOptionsToolbarPlugin } from './pasteOptionsToolbarPlugin';
2
- export type { PasteOptionsToolbarPlugin, PasteOptionsToolbarPluginDependencies, } from './pasteOptionsToolbarPluginType';
2
+ export type { PasteOptionsToolbarPlugin, PasteOptionsToolbarPluginDependencies, PasteOptionsToolbarSharedState, } from './pasteOptionsToolbarPluginType';
@@ -1,10 +1,17 @@
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 { ToolbarDropdownOption } from './types/types';
4
5
  export type PasteOptionsToolbarPluginDependencies = [
5
6
  OptionalPlugin<AnalyticsPlugin>,
6
7
  PastePlugin
7
8
  ];
9
+ export interface PasteOptionsToolbarSharedState {
10
+ isPlainText: boolean;
11
+ plaintextLength: number;
12
+ selectedOption: ToolbarDropdownOption;
13
+ showToolbar: boolean;
14
+ }
8
15
  export type PasteOptionsToolbarPlugin = NextEditorPlugin<'pasteOptionsToolbarPlugin', {
9
16
  dependencies: PasteOptionsToolbarPluginDependencies;
10
17
  }>;
@@ -1,3 +1,3 @@
1
1
  import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
- export declare function createPlugin(dispatch: Dispatch): SafePlugin<import("../types/types").PasteOtionsPluginState>;
3
+ export declare function createPlugin(dispatch: Dispatch): SafePlugin<import("../types/types").PasteOptionsPluginState>;
@@ -1,2 +1,2 @@
1
- import type { PasteOtionsPluginState } from '../types/types';
2
- export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: PasteOtionsPluginState | ((state: import("prosemirror-state").EditorState) => PasteOtionsPluginState)) => import("prosemirror-state").SafeStateField<PasteOtionsPluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => PasteOtionsPluginState;
1
+ import type { PasteOptionsPluginState } from '../types/types';
2
+ export declare const createPluginState: (dispatch: import("@atlaskit/editor-common/event-dispatcher").Dispatch, initialState: PasteOptionsPluginState | ((state: import("prosemirror-state").EditorState) => PasteOptionsPluginState)) => import("prosemirror-state").SafeStateField<PasteOptionsPluginState>, createCommand: <A = import("../editor-actions/actions").PastePluginAction>(action: A | ((state: Readonly<import("prosemirror-state").EditorState>) => false | A), transform?: (tr: import("prosemirror-state").Transaction, state: import("prosemirror-state").EditorState) => import("prosemirror-state").Transaction) => import("@atlaskit/editor-common/types").Command, getPluginState: (state: import("prosemirror-state").EditorState) => PasteOptionsPluginState;
@@ -1,3 +1,3 @@
1
1
  import type { PastePluginAction as Action } from '../editor-actions/actions';
2
- import type { PasteOtionsPluginState as State } from '../types/types';
2
+ import type { PasteOptionsPluginState as State } from '../types/types';
3
3
  export declare const reducer: (state: State, action: Action) => State;
@@ -2,8 +2,8 @@ import type { Schema } from '@atlaskit/editor-prosemirror/model';
2
2
  import { Slice } from '@atlaskit/editor-prosemirror/model';
3
3
  import type { Transaction } from '@atlaskit/editor-prosemirror/state';
4
4
  import { Selection } from '@atlaskit/editor-prosemirror/state';
5
- import type { PasteOtionsPluginState } from '../../types/types';
6
- export declare const formatMarkdown: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
7
- export declare const formatRichText: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
8
- export declare const formatPlainText: (tr: Transaction, pluginState: PasteOtionsPluginState) => Transaction;
5
+ import type { PasteOptionsPluginState } from '../../types/types';
6
+ export declare const formatMarkdown: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
7
+ export declare const formatRichText: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
8
+ export declare const formatPlainText: (tr: Transaction, pluginState: PasteOptionsPluginState) => Transaction;
9
9
  export declare function getMarkdownSlice(text: string, schema: Schema, selection: Selection): Slice | undefined;
@@ -8,7 +8,7 @@ export declare enum ToolbarDropdownOption {
8
8
  PlainText = 2,
9
9
  None = 3
10
10
  }
11
- export interface PasteOtionsPluginState {
11
+ export interface PasteOptionsPluginState {
12
12
  highlightContent: boolean;
13
13
  highlightDecorationSet: DecorationSet;
14
14
  isPlainText: boolean;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
+ import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
4
+ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
5
+ import type { PasteOptionsToolbarPlugin } from '../../pasteOptionsToolbarPluginType';
6
+ interface PasteActionsMenuProps {
7
+ api: ExtractInjectionAPI<PasteOptionsToolbarPlugin> | undefined;
8
+ boundariesElement?: HTMLElement;
9
+ editorAnalyticsAPI?: EditorAnalyticsAPI;
10
+ editorView: EditorView;
11
+ mountTo?: HTMLElement;
12
+ scrollableElement?: HTMLElement;
13
+ }
14
+ export declare const PasteActionsMenu: ({ api, editorView, mountTo, boundariesElement, scrollableElement, editorAnalyticsAPI, }: PasteActionsMenuProps) => React.JSX.Element | null;
15
+ export {};
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface MenuOption {
3
+ id: string;
4
+ label: string;
5
+ onClick: (e: React.MouseEvent) => void;
6
+ selected: boolean;
7
+ }
8
+ interface PasteActionsMenuContentProps {
9
+ onMouseDown: (e: React.MouseEvent) => void;
10
+ onMouseEnter: () => void;
11
+ options: MenuOption[];
12
+ }
13
+ export declare const PasteActionsMenuContent: ({ options, onMouseDown, onMouseEnter, }: PasteActionsMenuContentProps) => React.JSX.Element;
14
+ export {};
@@ -3,7 +3,7 @@ import type { EditorAnalyticsAPI } from '@atlaskit/editor-common/analytics';
3
3
  import type { Command, FloatingToolbarConfig, FloatingToolbarDropdown } from '@atlaskit/editor-common/types';
4
4
  import type { LastContentPasted } from '@atlaskit/editor-plugin-paste';
5
5
  import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
- import type { PasteOtionsPluginState } from '../types/types';
6
+ import type { PasteOptionsPluginState } from '../types/types';
7
7
  export declare const isToolbarVisible: (state: EditorState, lastContentPasted: LastContentPasted) => boolean;
8
- export declare const getToolbarMenuConfig: (pluginState: PasteOtionsPluginState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarDropdown<Command>;
8
+ export declare const getToolbarMenuConfig: (pluginState: PasteOptionsPluginState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarDropdown<Command>;
9
9
  export declare const buildToolbar: (state: EditorState, intl: IntlShape, editorAnalyticsAPI: EditorAnalyticsAPI | undefined) => FloatingToolbarConfig | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-paste-options-toolbar",
3
- "version": "8.0.4",
3
+ "version": "8.1.1",
4
4
  "description": "Paste options toolbar for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -29,6 +29,7 @@
29
29
  ],
30
30
  "atlaskit:src": "src/index.ts",
31
31
  "dependencies": {
32
+ "@atlaskit/css": "^0.19.0",
32
33
  "@atlaskit/editor-markdown-transformer": "^5.20.0",
33
34
  "@atlaskit/editor-plugin-analytics": "^7.0.0",
34
35
  "@atlaskit/editor-plugin-paste": "^8.2.0",
@@ -36,6 +37,9 @@
36
37
  "@atlaskit/editor-shared-styles": "^3.10.0",
37
38
  "@atlaskit/icon": "^32.0.0",
38
39
  "@atlaskit/platform-feature-flags": "^1.1.0",
40
+ "@atlaskit/primitives": "^18.0.0",
41
+ "@atlaskit/tmp-editor-statsig": "^30.0.0",
42
+ "@atlaskit/tokens": "^11.0.0",
39
43
  "@babel/runtime": "^7.0.0",
40
44
  "@emotion/react": "^11.7.1",
41
45
  "react-intl-next": "npm:react-intl@^5.18.1"