@atlaskit/editor-plugin-toolbar 0.2.2 → 0.2.4

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,19 @@
1
1
  # @atlaskit/editor-plugin-toolbar
2
2
 
3
+ ## 0.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [`03b0204b5eb82`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/03b0204b5eb82) -
8
+ ED=28738 Disable toolbar when editor is offline
9
+ - Updated dependencies
10
+
11
+ ## 0.2.3
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 0.2.2
4
18
 
5
19
  ### Patch Changes
@@ -17,6 +17,9 @@
17
17
  "../src/**/examples.*"
18
18
  ],
19
19
  "references": [
20
+ {
21
+ "path": "../../editor-plugin-connectivity/afm-cc/tsconfig.json"
22
+ },
20
23
  {
21
24
  "path": "../../editor-plugin-editor-viewmode/afm-cc/tsconfig.json"
22
25
  },
@@ -35,6 +38,9 @@
35
38
  {
36
39
  "path": "../../editor-toolbar-model/afm-cc/tsconfig.json"
37
40
  },
41
+ {
42
+ "path": "../../tmp-editor-statsig/afm-cc/tsconfig.json"
43
+ },
38
44
  {
39
45
  "path": "../../editor-common/afm-cc/tsconfig.json"
40
46
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-dev-agents/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-dev-agents/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-dev-agents/tsconfig.json"
40
43
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-jira/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-jira/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-jira/tsconfig.json"
40
43
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-passionfruit/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-passionfruit/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-passionfruit/tsconfig.json"
40
43
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-post-office/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-post-office/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-post-office/tsconfig.json"
40
43
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-rovo-extension/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-rovo-extension/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-rovo-extension/tsconfig.json"
40
43
  }
@@ -35,6 +35,9 @@
35
35
  {
36
36
  "path": "../../editor-toolbar-model/afm-townsquare/tsconfig.json"
37
37
  },
38
+ {
39
+ "path": "../../tmp-editor-statsig/afm-townsquare/tsconfig.json"
40
+ },
38
41
  {
39
42
  "path": "../../editor-common/afm-townsquare/tsconfig.json"
40
43
  }
@@ -15,6 +15,7 @@ var _state = require("@atlaskit/editor-prosemirror/state");
15
15
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
16
16
  var _editorToolbar = require("@atlaskit/editor-toolbar");
17
17
  var _editorToolbarModel = require("@atlaskit/editor-toolbar-model");
18
+ var _expValEqualsNoExposure = require("@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure");
18
19
  var _consts = require("../consts");
19
20
  var isToolbarComponent = function isToolbarComponent(component) {
20
21
  return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
@@ -28,14 +29,17 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
28
29
  return isToolbarComponent(component);
29
30
  });
30
31
  var currentUserIntent = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'userIntent.currentUserIntent');
32
+ var connectivityStateMode = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'connectivity.mode');
33
+ var isOffline = connectivityStateMode === 'offline';
31
34
  // TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
32
35
  // @ts-expect-error
33
36
  var selection = (0, _useSharedPluginStateSelector.useSharedPluginStateSelector)(api, 'selection.selection');
34
37
  var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof _state.TextSelection;
38
+ var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
35
39
  if (!components || !toolbar) {
36
40
  return null;
37
41
  }
38
- if (!isTextSelection || currentUserIntent === 'dragging' || (0, _coreUtils.isSSR)()) {
42
+ if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || currentUserIntent === 'blockMenuOpen' && (0, _expValEqualsNoExposure.expValEqualsNoExposure)('platform_editor_block_menu', 'isEnabled', true) || (0, _coreUtils.isSSR)()) {
39
43
  return null;
40
44
  }
41
45
  return /*#__PURE__*/_react.default.createElement(_ui.Popup, {
@@ -48,7 +52,8 @@ var SelectionToolbar = exports.SelectionToolbar = function SelectionToolbar(_ref
48
52
  }, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarProvider, {
49
53
  editorView: editorView
50
54
  }, /*#__PURE__*/_react.default.createElement(_toolbar.EditorToolbarUIProvider, {
51
- api: api
55
+ api: api,
56
+ isDisabled: isOffline
52
57
  }, /*#__PURE__*/_react.default.createElement(_editorToolbarModel.ToolbarModelRenderer, {
53
58
  toolbar: toolbar,
54
59
  components: components,
@@ -8,6 +8,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
10
10
  import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
11
12
  import { TOOLBAR_LABEL } from '../consts';
12
13
  const isToolbarComponent = component => {
13
14
  return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
@@ -20,14 +21,17 @@ export const SelectionToolbar = ({
20
21
  const components = api === null || api === void 0 ? void 0 : api.toolbar.actions.getComponents();
21
22
  const toolbar = components === null || components === void 0 ? void 0 : components.find(component => isToolbarComponent(component));
22
23
  const currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
24
+ const connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
25
+ const isOffline = connectivityStateMode === 'offline';
23
26
  // TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
24
27
  // @ts-expect-error
25
28
  const selection = useSharedPluginStateSelector(api, 'selection.selection');
26
29
  const isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
30
+ const isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
27
31
  if (!components || !toolbar) {
28
32
  return null;
29
33
  }
30
- if (!isTextSelection || currentUserIntent === 'dragging' || isSSR()) {
34
+ if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
31
35
  return null;
32
36
  }
33
37
  return /*#__PURE__*/React.createElement(Popup, {
@@ -38,7 +42,8 @@ export const SelectionToolbar = ({
38
42
  }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
39
43
  editorView: editorView
40
44
  }, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
41
- api: api
45
+ api: api,
46
+ isDisabled: isOffline
42
47
  }, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
43
48
  toolbar: toolbar,
44
49
  components: components,
@@ -8,6 +8,7 @@ import { TextSelection } from '@atlaskit/editor-prosemirror/state';
8
8
  import { findDomRefAtPos } from '@atlaskit/editor-prosemirror/utils';
9
9
  import { ToolbarSection, ToolbarButtonGroup, ToolbarDropdownItemSection } from '@atlaskit/editor-toolbar';
10
10
  import { ToolbarModelRenderer } from '@atlaskit/editor-toolbar-model';
11
+ import { expValEqualsNoExposure } from '@atlaskit/tmp-editor-statsig/exp-val-equals-no-exposure';
11
12
  import { TOOLBAR_LABEL } from '../consts';
12
13
  var isToolbarComponent = function isToolbarComponent(component) {
13
14
  return component.type === 'toolbar' && component.key === 'inline-text-toolbar';
@@ -21,14 +22,17 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
21
22
  return isToolbarComponent(component);
22
23
  });
23
24
  var currentUserIntent = useSharedPluginStateSelector(api, 'userIntent.currentUserIntent');
25
+ var connectivityStateMode = useSharedPluginStateSelector(api, 'connectivity.mode');
26
+ var isOffline = connectivityStateMode === 'offline';
24
27
  // TODO: ED-28735 - figure out a better way to control this - needed to re-render on selection change
25
28
  // @ts-expect-error
26
29
  var selection = useSharedPluginStateSelector(api, 'selection.selection');
27
30
  var isTextSelection = !editorView.state.selection.empty && editorView.state.selection instanceof TextSelection;
31
+ var isCellSelection = !editorView.state.selection.empty && '$anchorCell' in editorView.state.selection;
28
32
  if (!components || !toolbar) {
29
33
  return null;
30
34
  }
31
- if (!isTextSelection || currentUserIntent === 'dragging' || isSSR()) {
35
+ if (!(isTextSelection || isCellSelection) || currentUserIntent === 'dragging' || currentUserIntent === 'blockMenuOpen' && expValEqualsNoExposure('platform_editor_block_menu', 'isEnabled', true) || isSSR()) {
32
36
  return null;
33
37
  }
34
38
  return /*#__PURE__*/React.createElement(Popup, {
@@ -41,7 +45,8 @@ export var SelectionToolbar = function SelectionToolbar(_ref) {
41
45
  }, /*#__PURE__*/React.createElement(EditorToolbarProvider, {
42
46
  editorView: editorView
43
47
  }, /*#__PURE__*/React.createElement(EditorToolbarUIProvider, {
44
- api: api
48
+ api: api,
49
+ isDisabled: isOffline
45
50
  }, /*#__PURE__*/React.createElement(ToolbarModelRenderer, {
46
51
  toolbar: toolbar,
47
52
  components: components,
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
2
3
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
3
4
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
4
5
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
@@ -9,7 +10,8 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
9
10
  OptionalPlugin<UserIntentPlugin>,
10
11
  OptionalPlugin<SelectionPlugin>,
11
12
  OptionalPlugin<UserPreferencesPlugin>,
12
- OptionalPlugin<EditorViewModePlugin>
13
+ OptionalPlugin<EditorViewModePlugin>,
14
+ OptionalPlugin<ConnectivityPlugin>
13
15
  ];
14
16
  actions: {
15
17
  registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
@@ -1,4 +1,5 @@
1
1
  import type { NextEditorPlugin, OptionalPlugin } from '@atlaskit/editor-common/types';
2
+ import type { ConnectivityPlugin } from '@atlaskit/editor-plugin-connectivity';
2
3
  import type { EditorViewModePlugin } from '@atlaskit/editor-plugin-editor-viewmode';
3
4
  import type { SelectionPlugin } from '@atlaskit/editor-plugin-selection';
4
5
  import type { UserIntentPlugin } from '@atlaskit/editor-plugin-user-intent';
@@ -9,7 +10,8 @@ export type ToolbarPlugin = NextEditorPlugin<'toolbar', {
9
10
  OptionalPlugin<UserIntentPlugin>,
10
11
  OptionalPlugin<SelectionPlugin>,
11
12
  OptionalPlugin<UserPreferencesPlugin>,
12
- OptionalPlugin<EditorViewModePlugin>
13
+ OptionalPlugin<EditorViewModePlugin>,
14
+ OptionalPlugin<ConnectivityPlugin>
13
15
  ];
14
16
  actions: {
15
17
  registerComponents: (toolbarComponents: Array<RegisterComponent>) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-toolbar",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "Toolbar plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -31,6 +31,7 @@
31
31
  ".": "./src/index.ts"
32
32
  },
33
33
  "dependencies": {
34
+ "@atlaskit/editor-plugin-connectivity": "^3.1.0",
34
35
  "@atlaskit/editor-plugin-editor-viewmode": "^5.0.0",
35
36
  "@atlaskit/editor-plugin-selection": "^3.0.0",
36
37
  "@atlaskit/editor-plugin-user-intent": "^1.1.0",
@@ -38,11 +39,12 @@
38
39
  "@atlaskit/editor-prosemirror": "7.0.0",
39
40
  "@atlaskit/editor-toolbar": "^0.3.0",
40
41
  "@atlaskit/editor-toolbar-model": "^0.1.0",
42
+ "@atlaskit/tmp-editor-statsig": "^11.3.0",
41
43
  "@babel/runtime": "^7.0.0",
42
44
  "react-intl-next": "npm:react-intl@^5.18.1"
43
45
  },
44
46
  "peerDependencies": {
45
- "@atlaskit/editor-common": "^107.24.0",
47
+ "@atlaskit/editor-common": "^107.26.0",
46
48
  "react": "^18.2.0"
47
49
  },
48
50
  "techstack": {