@atlaskit/editor-plugin-selection-marker 4.0.0 → 5.0.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,18 @@
1
1
  # @atlaskit/editor-plugin-selection-marker
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 4.0.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`528dc3058289e`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/528dc3058289e) -
14
+ [ux] ED-29066 Disable selection marker when selection toolbar is showing up
15
+
3
16
  ## 4.0.0
4
17
 
5
18
  ### Patch Changes
@@ -8,6 +8,7 @@ exports.selectionMarkerPlugin = void 0;
8
8
  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
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
11
12
  var _main = require("./pm-plugins/main");
12
13
  var _globalStyles = require("./ui/global-styles");
13
14
  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); }
@@ -78,20 +79,21 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
78
79
  // relatch when editorView changes (pretty good signal for reinit)
79
80
  editorHasNotBeenFocused.current = true;
80
81
  }, [editorView]);
81
- var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['focus', 'typeAhead', 'editorDisabled'], function (states) {
82
- var _states$focusState, _states$typeAheadStat, _states$editorDisable;
82
+ var _useSharedPluginState = (0, _hooks.useSharedPluginStateWithSelector)(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], function (states) {
83
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
83
84
  return {
84
85
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
85
86
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
86
- editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
87
+ 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
87
89
  };
88
90
  }),
89
91
  hasFocus = _useSharedPluginState.hasFocus,
90
92
  isOpen = _useSharedPluginState.isOpen,
91
- editorDisabled = _useSharedPluginState.editorDisabled;
93
+ editorDisabled = _useSharedPluginState.editorDisabled,
94
+ showToolbar = _useSharedPluginState.showToolbar;
92
95
  var isForcedHidden = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selectionMarker.isForcedHidden');
93
96
  (0, _react.useEffect)(function () {
94
- var _ref5;
95
97
  // On editor init we should use this latch to keep the marker hidden until
96
98
  // editor has received focus. This means editor will be initially hidden until
97
99
  // the first focus occurs, and after first focus the normal above rules will
@@ -108,11 +110,12 @@ var selectionMarkerPlugin = exports.selectionMarkerPlugin = function selectionMa
108
110
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
109
111
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
110
112
  */
111
- var shouldHide = (_ref5 = (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)) !== null && _ref5 !== void 0 ? _ref5 : true;
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);
114
+ true;
112
115
  requestAnimationFrame(function () {
113
116
  return (0, _main.dispatchShouldHideDecorations)(editorView, shouldHide);
114
117
  });
115
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled]);
118
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
116
119
  },
117
120
  contentComponent: function contentComponent() {
118
121
  return /*#__PURE__*/_react.default.createElement(_globalStyles.GlobalStylesWrapper, null);
@@ -126,8 +129,8 @@ function cleanupHiddenDecoration(api) {
126
129
  if (!hasRun && api !== null && api !== void 0 && (_api$selectionMarker3 = api.selectionMarker) !== null && _api$selectionMarker3 !== void 0 && (_api$selectionMarker3 = _api$selectionMarker3.sharedState.currentState()) !== null && _api$selectionMarker3 !== void 0 && _api$selectionMarker3.isForcedHidden) {
127
130
  var _api$core2;
128
131
  hasRun = true;
129
- return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref6) {
130
- var tr = _ref6.tr;
132
+ return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref5) {
133
+ var tr = _ref5.tr;
131
134
  return tr.setMeta(_main.key, {
132
135
  forceHide: false
133
136
  });
@@ -1,6 +1,7 @@
1
1
  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
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
5
6
  import { GlobalStylesWrapper } from './ui/global-styles';
6
7
  export const selectionMarkerPlugin = ({
@@ -73,18 +74,19 @@ export const selectionMarkerPlugin = ({
73
74
  const {
74
75
  hasFocus,
75
76
  isOpen,
76
- editorDisabled
77
- } = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled'], states => {
78
- var _states$focusState, _states$typeAheadStat, _states$editorDisable;
77
+ editorDisabled,
78
+ showToolbar
79
+ } = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], states => {
80
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
79
81
  return {
80
82
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
81
83
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
82
- editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
84
+ 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
83
86
  };
84
87
  });
85
88
  const isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
86
89
  useEffect(() => {
87
- var _ref;
88
90
  // On editor init we should use this latch to keep the marker hidden until
89
91
  // editor has received focus. This means editor will be initially hidden until
90
92
  // the first focus occurs, and after first focus the normal above rules will
@@ -101,9 +103,10 @@ export const selectionMarkerPlugin = ({
101
103
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
102
104
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
103
105
  */
104
- const shouldHide = (_ref = (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)) !== null && _ref !== void 0 ? _ref : true;
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);
107
+ true;
105
108
  requestAnimationFrame(() => dispatchShouldHideDecorations(editorView, shouldHide));
106
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled]);
109
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
107
110
  },
108
111
  contentComponent() {
109
112
  return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
@@ -1,6 +1,7 @@
1
1
  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
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
4
5
  import { createPlugin, dispatchShouldHideDecorations, key } from './pm-plugins/main';
5
6
  import { GlobalStylesWrapper } from './ui/global-styles';
6
7
  export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
@@ -70,20 +71,21 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
70
71
  // relatch when editorView changes (pretty good signal for reinit)
71
72
  editorHasNotBeenFocused.current = true;
72
73
  }, [editorView]);
73
- var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled'], function (states) {
74
- var _states$focusState, _states$typeAheadStat, _states$editorDisable;
74
+ var _useSharedPluginState = useSharedPluginStateWithSelector(api, ['focus', 'typeAhead', 'editorDisabled', 'toolbar'], function (states) {
75
+ var _states$focusState, _states$typeAheadStat, _states$editorDisable, _states$toolbarState;
75
76
  return {
76
77
  hasFocus: (_states$focusState = states.focusState) === null || _states$focusState === void 0 ? void 0 : _states$focusState.hasFocus,
77
78
  isOpen: (_states$typeAheadStat = states.typeAheadState) === null || _states$typeAheadStat === void 0 ? void 0 : _states$typeAheadStat.isOpen,
78
- editorDisabled: (_states$editorDisable = states.editorDisabledState) === null || _states$editorDisable === void 0 ? void 0 : _states$editorDisable.editorDisabled
79
+ 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
79
81
  };
80
82
  }),
81
83
  hasFocus = _useSharedPluginState.hasFocus,
82
84
  isOpen = _useSharedPluginState.isOpen,
83
- editorDisabled = _useSharedPluginState.editorDisabled;
85
+ editorDisabled = _useSharedPluginState.editorDisabled,
86
+ showToolbar = _useSharedPluginState.showToolbar;
84
87
  var isForcedHidden = useSharedPluginStateSelector(api, 'selectionMarker.isForcedHidden');
85
88
  useEffect(function () {
86
- var _ref5;
87
89
  // On editor init we should use this latch to keep the marker hidden until
88
90
  // editor has received focus. This means editor will be initially hidden until
89
91
  // the first focus occurs, and after first focus the normal above rules will
@@ -100,11 +102,12 @@ export var selectionMarkerPlugin = function selectionMarkerPlugin(_ref) {
100
102
  * - Disabled: So that it behaves similar to the renderer in live pages/disabled
101
103
  * - Via the API: If another plugin has requested it to be hidden (force hidden).
102
104
  */
103
- var shouldHide = (_ref5 = (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)) !== null && _ref5 !== void 0 ? _ref5 : true;
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);
106
+ true;
104
107
  requestAnimationFrame(function () {
105
108
  return dispatchShouldHideDecorations(editorView, shouldHide);
106
109
  });
107
- }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled]);
110
+ }, [editorView, hasFocus, isOpen, isForcedHidden, editorDisabled, showToolbar]);
108
111
  },
109
112
  contentComponent: function contentComponent() {
110
113
  return /*#__PURE__*/React.createElement(GlobalStylesWrapper, null);
@@ -118,8 +121,8 @@ function cleanupHiddenDecoration(api) {
118
121
  if (!hasRun && api !== null && api !== void 0 && (_api$selectionMarker3 = api.selectionMarker) !== null && _api$selectionMarker3 !== void 0 && (_api$selectionMarker3 = _api$selectionMarker3.sharedState.currentState()) !== null && _api$selectionMarker3 !== void 0 && _api$selectionMarker3.isForcedHidden) {
119
122
  var _api$core2;
120
123
  hasRun = true;
121
- return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref6) {
122
- var tr = _ref6.tr;
124
+ return api === null || api === void 0 || (_api$core2 = api.core) === null || _api$core2 === void 0 ? void 0 : _api$core2.actions.execute(function (_ref5) {
125
+ var tr = _ref5.tr;
123
126
  return tr.setMeta(key, {
124
127
  forceHide: false
125
128
  });
@@ -1,6 +1,7 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
3
3
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
4
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
4
5
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
5
6
  export type ReleaseHiddenDecoration = () => boolean | undefined;
6
7
  type SetCleanup = (cb: ReleaseHiddenDecoration | undefined) => void;
@@ -22,7 +23,8 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
22
23
  dependencies: [
23
24
  FocusPlugin,
24
25
  OptionalPlugin<TypeAheadPlugin>,
25
- OptionalPlugin<EditorDisabledPlugin>
26
+ OptionalPlugin<EditorDisabledPlugin>,
27
+ OptionalPlugin<ToolbarPlugin>
26
28
  ];
27
29
  pluginConfiguration?: SelectionMarkerPluginOptions;
28
30
  sharedState: {
@@ -1,6 +1,7 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { EditorDisabledPlugin } from '@atlaskit/editor-plugin-editor-disabled';
3
3
  import type { FocusPlugin } from '@atlaskit/editor-plugin-focus';
4
+ import type { ToolbarPlugin } from '@atlaskit/editor-plugin-toolbar';
4
5
  import type { TypeAheadPlugin } from '@atlaskit/editor-plugin-type-ahead';
5
6
  export type ReleaseHiddenDecoration = () => boolean | undefined;
6
7
  type SetCleanup = (cb: ReleaseHiddenDecoration | undefined) => void;
@@ -22,7 +23,8 @@ export type SelectionMarkerPlugin = NextEditorPlugin<'selectionMarker', {
22
23
  dependencies: [
23
24
  FocusPlugin,
24
25
  OptionalPlugin<TypeAheadPlugin>,
25
- OptionalPlugin<EditorDisabledPlugin>
26
+ OptionalPlugin<EditorDisabledPlugin>,
27
+ OptionalPlugin<ToolbarPlugin>
26
28
  ];
27
29
  pluginConfiguration?: SelectionMarkerPluginOptions;
28
30
  sharedState: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-selection-marker",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
4
  "description": "Selection marker plugin for @atlaskit/editor-core.",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -28,22 +28,23 @@
28
28
  ],
29
29
  "atlaskit:src": "src/index.ts",
30
30
  "dependencies": {
31
- "@atlaskit/editor-plugin-editor-disabled": "^4.0.0",
32
- "@atlaskit/editor-plugin-focus": "^3.0.0",
33
- "@atlaskit/editor-plugin-type-ahead": "^4.0.0",
31
+ "@atlaskit/editor-plugin-editor-disabled": "^5.0.0",
32
+ "@atlaskit/editor-plugin-focus": "^4.0.0",
33
+ "@atlaskit/editor-plugin-toolbar": "^2.0.0",
34
+ "@atlaskit/editor-plugin-type-ahead": "^5.0.0",
34
35
  "@atlaskit/editor-prosemirror": "7.0.0",
35
36
  "@atlaskit/link": "^3.2.0",
36
37
  "@atlaskit/platform-feature-flags": "^1.1.0",
37
- "@atlaskit/primitives": "^14.12.0",
38
+ "@atlaskit/primitives": "^14.14.0",
38
39
  "@atlaskit/theme": "^20.0.0",
39
- "@atlaskit/tmp-editor-statsig": "^12.0.0",
40
- "@atlaskit/tokens": "^6.1.0",
40
+ "@atlaskit/tmp-editor-statsig": "^12.9.0",
41
+ "@atlaskit/tokens": "^6.3.0",
41
42
  "@babel/runtime": "^7.0.0",
42
43
  "@emotion/react": "^11.7.1",
43
44
  "lodash": "^4.17.21"
44
45
  },
45
46
  "peerDependencies": {
46
- "@atlaskit/editor-common": "^108.0.0",
47
+ "@atlaskit/editor-common": "^109.0.0",
47
48
  "react": "^18.2.0",
48
49
  "react-dom": "^18.2.0"
49
50
  },