@atlaskit/editor-plugin-selection-marker 6.0.0 → 6.1.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,16 @@
1
1
  # @atlaskit/editor-plugin-selection-marker
2
2
 
3
+ ## 6.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`f4c0936dc05fe`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f4c0936dc05fe) -
8
+ ED-29391 Add keyboard support for block menu
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies
13
+
3
14
  ## 6.0.0
4
15
 
5
16
  ### Patch Changes
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _hooks = require("@atlaskit/editor-common/hooks");
10
10
  var _useSharedPluginStateSelector = require("@atlaskit/editor-common/use-shared-plugin-state-selector");
11
11
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
12
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
12
13
  var _main = require("./pm-plugins/main");
13
14
  var _globalStyles = require("./ui/global-styles");
14
15
  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); }
@@ -79,19 +80,21 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
79
80
  // relatch when editorView changes (pretty good signal for reinit)
80
81
  editorHasNotBeenFocused.current = true;
81
82
  }, [editorView]);
82
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], function (states) {
83
- var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
83
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar', 'decorations'], function (states) {
84
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState, _states$decorationsSt;
84
85
  return {
85
86
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
86
87
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
87
88
  editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled,
88
- showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar
89
+ showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar,
90
+ hasDangerDecorations: (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_states$decorationsSt = states.decorationsState) === null || _states$decorationsSt === void 0 ? void 0 : _states$decorationsSt.hasDangerDecorations : undefined
89
91
  };
90
92
  }),
91
93
  hasFocus = _useSharedPluginState.hasFocus,
92
94
  isOpen = _useSharedPluginState.isOpen,
93
95
  editorDisabled = _useSharedPluginState.editorDisabled,
94
- showToolbar = _useSharedPluginState.showToolbar;
96
+ showToolbar = _useSharedPluginState.showToolbar,
97
+ hasDangerDecorations = _useSharedPluginState.hasDangerDecorations;
95
98
  var isForcedHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selectionMarker.isForcedHidden');
96
99
  (0, _react.useEffect)(function () {
97
100
  // On editor init we should use this latch to keep the marker hidden until
@@ -109,12 +112,13 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
109
112
  * - Typeahead Open: To ensure it doesn't show when we're typing in the typeahead
110
113
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
111
114
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
115
+ * - If danger styles is shown in decorationsPlugin, then we don't need to show the selection marker
112
116
  */
113
- var shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || (0, _expValEquals.expValEquals)('platform_editor_ai_aifc', 'isEnabled', true);
117
+ var shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || (0, _expValEquals.expValEquals)('platform_editor_ai_aifc', 'isEnabled', true) || !!hasDangerDecorations && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
114
118
  requestAnimationFrame(function () {
115
119
  return (0, _main.dispatchShouldHideDecorations)(editorView, shouldHide);
116
120
  });
117
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
121
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar, hasDangerDecorations]);
118
122
  },
119
123
  contentComponent: function contentComponent() {
120
124
  return /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null);
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
6
7
  import { GlobalStylesWrapper } from './ui/global-styles';
7
8
  export const selectionMarkerPlugin = ({
@@ -75,14 +76,16 @@ export const selectionMarkerPlugin = ({
75
76
  hasFocus,
76
77
  isOpen,
77
78
  editorDisabled,
78
- showToolbar
79
- } = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], states => {
80
- var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
79
+ showToolbar,
80
+ hasDangerDecorations
81
+ } = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar', 'decorations'], states => {
82
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState, _states$decorationsSt;
81
83
  return {
82
84
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
83
85
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
84
86
  editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled,
85
- showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar
87
+ showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar,
88
+ hasDangerDecorations: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_states$decorationsSt = states.decorationsState) === null || _states$decorationsSt === void 0 ? void 0 : _states$decorationsSt.hasDangerDecorations : undefined
86
89
  };
87
90
  });
88
91
  const isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
@@ -102,10 +105,11 @@ export const selectionMarkerPlugin = ({
102
105
  * - Typeahead Open: To ensure it doesn't show when we're typing in the typeahead
103
106
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
104
107
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
108
+ * - If danger styles is shown in decorationsPlugin, then we don't need to show the selection marker
105
109
  */
106
- const shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || expValEquals('platform_editor_ai_aifc', 'isEnabled', true);
110
+ const shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || expValEquals('platform_editor_ai_aifc', 'isEnabled', true) || !!hasDangerDecorations && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
107
111
  requestAnimationFrame(() => dispatchShouldHideDecorations(editorView, shouldHide));
108
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
112
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar, hasDangerDecorations]);
109
113
  },
110
114
  contentComponent() {
111
115
  return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
@@ -2,6 +2,7 @@ import React, { useEffect, useRef } from 'react';
2
2
  import { useSharedPluginStateWithSelector } from '@atlaskit/editor-common/hooks';
3
3
  import { useSharedPluginStateSelector } from '@atlaskit/editor-common/use-shared-plugin-state-selector';
4
4
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
5
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
5
6
  import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
6
7
  import { GlobalStylesWrapper } from './ui/global-styles';
7
8
  export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
@@ -71,19 +72,21 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
71
72
  // relatch when editorView changes (pretty good signal for reinit)
72
73
  editorHasNotBeenFocused.current = true;
73
74
  }, [editorView]);
74
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], function (states) {
75
- var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
75
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar', 'decorations'], function (states) {
76
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState, _states$decorationsSt;
76
77
  return {
77
78
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
78
79
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
79
80
  editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled,
80
- showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar
81
+ showToolbar: (_states$toolbarState = states.toolbarState) === null || _states$toolbarState === void 0 ? void 0 : _states$toolbarState.shouldShowToolbar,
82
+ hasDangerDecorations: expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true) ? (_states$decorationsSt = states.decorationsState) === null || _states$decorationsSt === void 0 ? void 0 : _states$decorationsSt.hasDangerDecorations : undefined
81
83
  };
82
84
  }),
83
85
  hasFocus = _useSharedPluginState.hasFocus,
84
86
  isOpen = _useSharedPluginState.isOpen,
85
87
  editorDisabled = _useSharedPluginState.editorDisabled,
86
- showToolbar = _useSharedPluginState.showToolbar;
88
+ showToolbar = _useSharedPluginState.showToolbar,
89
+ hasDangerDecorations = _useSharedPluginState.hasDangerDecorations;
87
90
  var isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
88
91
  useEffect(function () {
89
92
  // On editor init we should use this latch to keep the marker hidden until
@@ -101,12 +104,13 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
101
104
  * - Typeahead Open: To ensure it doesn't show when we're typing in the typeahead
102
105
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
103
106
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
107
+ * - If danger styles is shown in decorationsPlugin, then we don't need to show the selection marker
104
108
  */
105
- var shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || expValEquals('platform_editor_ai_aifc', 'isEnabled', true);
109
+ var shouldHide = (config === null || config === void 0 ? void 0 : config.hideCursorOnInit) && editorHasNotBeenFocused.current || hasFocus || (isOpen !== null && isOpen !== void 0 ? isOpen : false) || isForcedHidden || (editorDisabled !== null && editorDisabled !== void 0 ? editorDisabled : false) || expValEquals('platform_editor_toolbar_aifc_patch_1', 'isEnabled', true) && (showToolbar !== null && showToolbar !== void 0 ? showToolbar : false) || expValEquals('platform_editor_ai_aifc', 'isEnabled', true) || !!hasDangerDecorations && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) && expValEqualsNoExposure('platform_editor_block_menu_keyboard_navigation', 'isEnabled', true);
106
110
  requestAnimationFrame(function () {
107
111
  return dispatchShouldHideDecorations(editorView, shouldHide);
108
112
  });
109
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
113
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar, hasDangerDecorations]);
110
114
  },
111
115
  contentComponent: function contentComponent() {
112
116
  return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
2
3
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
3
4
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
4
5
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
@@ -24,7 +25,8 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
24
25
  FocusPlugin,
25
26
  OptionalPlugin<TypeAheadPlugin>,
26
27
  OptionalPlugin<EditorDisabledPlugin>,
27
- OptionalPlugin<ToolbarPlugin>
28
+ OptionalPlugin<ToolbarPlugin>,
29
+ OptionalPlugin<DecorationsPlugin>
28
30
  ];
29
31
  pluginConfiguration?: SelectionMarkerPluginOptions;
30
32
  sharedState: {
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { DecorationsPlugin } from '@atlaskit/editor-plugin-decorations';
2
3
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
3
4
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
4
5
  import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
@@ -24,7 +25,8 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
24
25
  FocusPlugin,
25
26
  OptionalPlugin<TypeAheadPlugin>,
26
27
  OptionalPlugin<EditorDisabledPlugin>,
27
- OptionalPlugin<ToolbarPlugin>
28
+ OptionalPlugin<ToolbarPlugin>,
29
+ OptionalPlugin<DecorationsPlugin>
28
30
  ];
29
31
  pluginConfiguration?: SelectionMarkerPluginOptions;
30
32
  sharedState: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-marker",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Selection marker plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,6 +28,7 @@
28
28
  ],
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
+ "@atlaskit/editor-plugin-decorations": "^6.1.0",
31
32
  "@atlaskit/editor-plugin-editor-disabled": "^6.0.0",
32
33
  "@atlaskit/editor-plugin-focus": "^5.0.0",
33
34
  "@atlaskit/editor-plugin-toolbar": "^3.0.0",
@@ -37,14 +38,14 @@
37
38
  "@atlaskit/platform-feature-flags": "^1.1.0",
38
39
  "@atlaskit/primitives": "^14.15.0",
39
40
  "@atlaskit/theme": "^21.0.0",
40
- "@atlaskit/tmp-editor-statsig": "^12.31.0",
41
+ "@atlaskit/tmp-editor-statsig": "^12.32.0",
41
42
  "@atlaskit/tokens": "^6.3.0",
42
43
  "@babel/runtime": "^7.0.0",
43
44
  "@emotion/react": "^11.7.1",
44
45
  "lodash": "^4.17.21"
45
46
  },
46
47
  "peerDependencies": {
47
- "@atlaskit/editor-common": "^110.0.0",
48
+ "@atlaskit/editor-common": "^110.1.0",
48
49
  "react": "^18.2.0",
49
50
  "react-dom": "^18.2.0"
50
51
  },